summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2019-02-09 16:15:29 -0500
committerKent Overstreet <kent.overstreet@gmail.com>2019-04-03 12:44:04 -0400
commitd5db14b026502c0eb441d87e8195c0941aedab3b (patch)
tree8ccbf394bdb195696fd28851ccd10e5bbb00efb8
parentd1034c5e8e727fe415c52c52e75212ffcf7aa520 (diff)
bcachefs: Fix a bug when shutting down before allocator started
-rw-r--r--fs/bcachefs/alloc_background.c2
-rw-r--r--fs/bcachefs/bcachefs.h1
-rw-r--r--fs/bcachefs/super.c9
3 files changed, 11 insertions, 1 deletions
diff --git a/fs/bcachefs/alloc_background.c b/fs/bcachefs/alloc_background.c
index 2552d45799ca..e9a91617da9d 100644
--- a/fs/bcachefs/alloc_background.c
+++ b/fs/bcachefs/alloc_background.c
@@ -1534,6 +1534,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 17f28c379db9..21da6f13518b 100644
--- a/fs/bcachefs/bcachefs.h
+++ b/fs/bcachefs/bcachefs.h
@@ -474,6 +474,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 1835b5355c67..5ac6935b4b44 100644
--- a/fs/bcachefs/super.c
+++ b/fs/bcachefs/super.c
@@ -222,6 +222,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) {
@@ -250,10 +253,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 */
@@ -380,6 +385,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;