diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2019-02-09 16:15:29 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2023-10-22 17:08:15 -0400 |
commit | b935a8a67ab744d20002aefd7f8053381b38532f (patch) | |
tree | d47a32534a65588b7cf289004b60d15c034a2836 | |
parent | 4c97e04aa8818da266a690543aca28e2e7c26820 (diff) | |
download | lwn-b935a8a67ab744d20002aefd7f8053381b38532f.tar.gz lwn-b935a8a67ab744d20002aefd7f8053381b38532f.zip |
bcachefs: Fix a bug when shutting down before allocator started
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
-rw-r--r-- | fs/bcachefs/alloc_background.c | 2 | ||||
-rw-r--r-- | fs/bcachefs/bcachefs.h | 1 | ||||
-rw-r--r-- | fs/bcachefs/super.c | 9 |
3 files changed, 11 insertions, 1 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c index 686287d12d14..83b3445cc76f 100644 --- a/fs/bcachefs/alloc_background.c +++ b/fs/bcachefs/alloc_background.c @@ -1535,6 +1535,8 @@ int bch2_fs_allocator_start(struct bch_fs *c) } } + set_bit(BCH_FS_ALLOCATOR_RUNNING, &c->flags); + return bch2_alloc_write(c, false, &wrote); } diff --git a/fs/bcachefs/bcachefs.h b/fs/bcachefs/bcachefs.h index 2d67c9911fbb..4a0e2f63e645 100644 --- a/fs/bcachefs/bcachefs.h +++ b/fs/bcachefs/bcachefs.h @@ -477,6 +477,7 @@ enum { /* startup: */ BCH_FS_ALLOC_READ_DONE, BCH_FS_ALLOCATOR_STARTED, + BCH_FS_ALLOCATOR_RUNNING, BCH_FS_INITIAL_GC_DONE, BCH_FS_FSCK_DONE, BCH_FS_STARTED, diff --git a/fs/bcachefs/super.c b/fs/bcachefs/super.c index f1e60c377fa2..9ec05410aeb4 100644 --- a/fs/bcachefs/super.c +++ b/fs/bcachefs/super.c @@ -191,6 +191,9 @@ static void __bch2_fs_read_only(struct bch_fs *c) */ bch2_journal_flush_all_pins(&c->journal); + if (!test_bit(BCH_FS_ALLOCATOR_RUNNING, &c->flags)) + goto allocator_not_running; + do { ret = bch2_alloc_write(c, false, &wrote); if (ret) { @@ -219,10 +222,12 @@ static void __bch2_fs_read_only(struct bch_fs *c) closure_wait_event(&c->btree_interior_update_wait, !bch2_btree_interior_updates_nr_pending(c)); } while (wrote); - +allocator_not_running: for_each_member_device(ca, c, i) bch2_dev_allocator_stop(ca); + clear_bit(BCH_FS_ALLOCATOR_RUNNING, &c->flags); + bch2_fs_journal_stop(&c->journal); /* XXX: mark super that alloc info is persistent */ @@ -349,6 +354,8 @@ const char *bch2_fs_read_write(struct bch_fs *c) goto err; } + set_bit(BCH_FS_ALLOCATOR_RUNNING, &c->flags); + err = "error starting btree GC thread"; if (bch2_gc_thread_start(c)) goto err; |