diff options
author | Kent Overstreet <kent.overstreet@gmail.com> | 2021-12-30 19:30:42 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@gmail.com> | 2022-05-30 18:16:56 -0400 |
commit | 2adfb8f45057d860f4c3e283766199910aa214c6 (patch) | |
tree | f2b29d4751d85896b5eba19750ccd98cf62cca82 /fs/bcachefs/recovery.c | |
parent | 82e4d3684e54b6a1055ebe58b394f8ed1dc6f582 (diff) |
bcachefs: Don't start allocator threads too early
If the allocator threads start before journal replay has finished
replaying alloc keys, journal replay might overwrite the allocator's
btree updates.
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r-- | fs/bcachefs/recovery.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index 9916fad292be..d0ceac0f2b39 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -567,9 +567,10 @@ static int bch2_journal_replay(struct bch_fs *c, struct journal_keys keys) { struct journal *j = &c->journal; + struct bch_dev *ca; struct journal_key *i; u64 seq; - int ret; + int ret, idx; sort(keys.d, keys.nr, sizeof(keys.d[0]), journal_sort_seq_cmp, NULL); @@ -593,6 +594,11 @@ static int bch2_journal_replay(struct bch_fs *c, } } + /* Now we can start the allocator threads: */ + set_bit(BCH_FS_ALLOC_REPLAY_DONE, &c->flags); + for_each_member_device(ca, c, idx) + bch2_wake_allocator(ca); + /* * Next replay updates to interior btree nodes: */ @@ -1391,6 +1397,7 @@ int bch2_fs_initialize(struct bch_fs *c) for (i = 0; i < BTREE_ID_NR; i++) bch2_btree_root_alloc(c, i); + set_bit(BCH_FS_ALLOC_REPLAY_DONE, &c->flags); set_bit(BCH_FS_BTREE_INTERIOR_REPLAY_DONE, &c->flags); set_bit(JOURNAL_RECLAIM_STARTED, &c->journal.flags); |