bcachefs: Call bch2_fs_start before getting vfs superblock
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 5 May 2025 19:52:57 +0000 (15:52 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Mon, 5 May 2025 20:06:35 +0000 (16:06 -0400)
This reverts

1fdbe0b184c8 bcachefs: Make sure c->vfs_sb is set before starting fs

switched up bch2_fs_get_tree() so that we got a superblock before
calling bch2_fs_start, so that c->vfs_sb would always be initialized
while the filesystem was active.

This turned out not to be necessary, because blk_holder_ops were
implemented using our own locking, not vfs locking.

And this had the side effect of creating a super_block and doing our
full recovery (including potentially fsck) before setting SB_BORN, which
causes things like sync calls to hang until our recovery is finished.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs.c

index 113db85..b680186 100644 (file)
@@ -2502,10 +2502,9 @@ static int bch2_fs_get_tree(struct fs_context *fc)
 
        bch2_opts_apply(&c->opts, opts);
 
-       /*
-        * need to initialise sb and set c->vfs_sb _before_ starting fs,
-        * for blk_holder_ops
-        */
+       ret = bch2_fs_start(c);
+       if (ret)
+               goto err_stop_fs;
 
        sb = sget(fc->fs_type, NULL, bch2_set_super, fc->sb_flags|SB_NOSEC, c);
        ret = PTR_ERR_OR_ZERO(sb);
@@ -2567,10 +2566,6 @@ got_sb:
 
        sb->s_shrink->seeks = 0;
 
-       ret = bch2_fs_start(c);
-       if (ret)
-               goto err_put_super;
-
 #ifdef CONFIG_UNICODE
        sb->s_encoding = c->cf_encoding;
 #endif