From 839544067f558288395439454909d0d059c012ed Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Sun, 25 Sep 2022 22:26:48 -0400 Subject: bcachefs: Run bch2_fs_counters_init() earlier 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 --- fs/bcachefs/super.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index 3ee6545a8721..ee31c61fe850 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -785,7 +785,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) ?: @@ -799,8 +800,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; -- cgit v1.2.3