bcachefs: Run bch2_fs_counters_init() earlier
authorKent Overstreet <kent.overstreet@linux.dev>
Mon, 26 Sep 2022 02:26:48 +0000 (22:26 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:09:41 +0000 (17:09 -0400)
We need counters to be initialized before initializing shrinkers - the
shrinker callbacks will update those counters. This fixes a segfault in
userspace.

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

index 8dc87c1032167a01dc0fb70dcdcf5fc2e425d634..29e2b76322d78afe70e2b5969679151c5d2b0b4a 100644 (file)
@@ -781,7 +781,8 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
                goto err;
        }
 
-       ret = bch2_io_clock_init(&c->io_clock[READ]) ?:
+       ret = bch2_fs_counters_init(c) ?:
+           bch2_io_clock_init(&c->io_clock[READ]) ?:
            bch2_io_clock_init(&c->io_clock[WRITE]) ?:
            bch2_fs_journal_init(&c->journal) ?:
            bch2_fs_replicas_init(c) ?:
@@ -795,8 +796,7 @@ static struct bch_fs *bch2_fs_alloc(struct bch_sb *sb, struct bch_opts opts)
            bch2_fs_encryption_init(c) ?:
            bch2_fs_compress_init(c) ?:
            bch2_fs_ec_init(c) ?:
-           bch2_fs_fsio_init(c) ?:
-           bch2_fs_counters_init(c);
+           bch2_fs_fsio_init(c);
        if (ret)
                goto err;