Skip to content

Commit 5e63d57

Browse files
author
Kent Overstreet
committed
bcachefs: readdir fixes
- Don't call bch2_trans_relock() after dir_emit(); taking a transaction restart here will cause us to emit the same dirent to userspace twice - Fix incorrect checking of the return value on dir_emit(): "true" means success, keep going, but bch2_dir_emit() needs to return true when we're finished iterating. koverstreet/bcachefs#867 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent 2feaa92 commit 5e63d57

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

fs/bcachefs/dirent.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,7 @@ static int bch2_dir_emit(struct dir_context *ctx, struct bkey_s_c_dirent d, subv
685685
vfs_d_type(d.v->d_type));
686686
if (ret)
687687
ctx->pos = d.k->p.offset + 1;
688-
return ret;
688+
return !ret;
689689
}
690690

691691
int bch2_readdir(struct bch_fs *c, subvol_inum inum, struct dir_context *ctx)
@@ -710,7 +710,7 @@ int bch2_readdir(struct bch_fs *c, subvol_inum inum, struct dir_context *ctx)
710710
if (ret2 > 0)
711711
continue;
712712

713-
ret2 ?: drop_locks_do(trans, bch2_dir_emit(ctx, dirent, target));
713+
ret2 ?: (bch2_trans_unlock(trans), bch2_dir_emit(ctx, dirent, target));
714714
})));
715715

716716
bch2_bkey_buf_exit(&sk, c);

0 commit comments

Comments
 (0)