mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 13:29:17 -04:00
bcachefs: Fix a bug when shutting down before allocator started
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This commit is contained in:
committed by
Kent Overstreet
parent
4c97e04aa8
commit
b935a8a67a
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user