bcachefs: Dont't del sysfs dir until after we go RO
authorKent Overstreet <kent.overstreet@gmail.com>
Thu, 27 Feb 2020 20:03:53 +0000 (15:03 -0500)
committerKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:08:36 +0000 (17:08 -0400)
This will help for debugging hangs during unmount

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

index 2ba04b08529d5e45c62404fee8f41c377867714f..8670be394239f0ef024758fbb76a8ef0d9c28293 100644 (file)
@@ -518,6 +518,10 @@ void bch2_fs_stop(struct bch_fs *c)
 
        cancel_work_sync(&c->journal_seq_blacklist_gc_work);
 
+       mutex_lock(&c->state_lock);
+       bch2_fs_read_only(c);
+       mutex_unlock(&c->state_lock);
+
        for_each_member_device(ca, c, i)
                if (ca->kobj.state_in_sysfs &&
                    ca->disk_sb.bdev)
@@ -540,10 +544,6 @@ void bch2_fs_stop(struct bch_fs *c)
        closure_sync(&c->cl);
        closure_debug_destroy(&c->cl);
 
-       mutex_lock(&c->state_lock);
-       bch2_fs_read_only(c);
-       mutex_unlock(&c->state_lock);
-
        /* btree prefetch might have kicked off reads in the background: */
        bch2_btree_flush_all_reads(c);