]> www.infradead.org Git - nvme.git/commitdiff
bcachefs: bch2_dir_emit() - fix directory reads in the fuse driver
authorAriel Miculas <ariel.miculas@gmail.com>
Thu, 30 May 2024 21:13:58 +0000 (00:13 +0300)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 14 Jul 2024 23:00:14 +0000 (19:00 -0400)
Commit 0c0cbfdb84725e9933a24ecf47c61bdeeda06ba2 dropped the ctx->pos
update before the call to dir_emit. This breaks the userspace
implementation, causing the directory reads to be stuck in an infinite
loop. This doesn't happen in the kernel because the vfs handles the
updates to ctx->pos, but in the fuse implementation nobody updates
it.

Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/dirent.c

index c67460d8205db44ac5084eb62cb7d0f7e2cf4edd..d743da89308ef768a400100534cd7371872ce9b5 100644 (file)
@@ -534,6 +534,14 @@ int bch2_empty_dir_trans(struct btree_trans *trans, subvol_inum dir)
 static int bch2_dir_emit(struct dir_context *ctx, struct bkey_s_c_dirent d, subvol_inum target)
 {
        struct qstr name = bch2_dirent_get_name(d);
+       /*
+        * Although not required by the kernel code, updating ctx->pos is needed
+        * for the bcachefs FUSE driver. Without this update, the FUSE
+        * implementation will be stuck in an infinite loop when reading
+        * directories (via the bcachefs_fuse_readdir callback).
+        * In kernel space, ctx->pos is updated by the VFS code.
+        */
+       ctx->pos = d.k->p.offset;
        bool ret = dir_emit(ctx, name.name,
                      name.len,
                      target.inum,