diff options
author | Kent Overstreet <kent.overstreet@linux.dev> | 2023-11-09 20:41:58 -0500 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-01 11:47:37 -0500 |
commit | bdde9829de1ef3c98edd872c6f181de9fe610cf6 (patch) | |
tree | 90f2ab2bfc425e5f4dfa9f9e4f048c2d7a07f585 /fs/bcachefs/recovery.c | |
parent | 43c7ede0095d7020ca03113b2fde84b00dd5cd49 (diff) | |
download | lwn-bdde9829de1ef3c98edd872c6f181de9fe610cf6.tar.gz lwn-bdde9829de1ef3c98edd872c6f181de9fe610cf6.zip |
bcachefs: Go rw before journal replay
This gets us slightly nicer log messages.
Also, this slightly clarifies synchronization of c->journal_keys; after
we go RW it's in use by multiple threads (so that the btree iterator
code can overlay keys from the journal); so it has to be prepped before
that point.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/recovery.c')
-rw-r--r-- | fs/bcachefs/recovery.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index d56c28b4c8d4..92b70e7977bd 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -149,9 +149,6 @@ static int bch2_journal_replay(struct bch_fs *c) size_t i; int ret = 0; - move_gap(keys->d, keys->nr, keys->size, keys->gap, keys->nr); - keys->gap = keys->nr; - keys_sorted = kvmalloc_array(keys->nr, sizeof(*keys_sorted), GFP_KERNEL); if (!keys_sorted) return -BCH_ERR_ENOMEM_journal_replay; @@ -180,7 +177,6 @@ static int bch2_journal_replay(struct bch_fs *c) replay_now_at(j, k->journal_seq); ret = bch2_trans_do(c, NULL, NULL, - BTREE_INSERT_LAZY_RW| BTREE_INSERT_NOFAIL| (!k->allocated ? BTREE_INSERT_JOURNAL_REPLAY|BCH_WATERMARK_reclaim @@ -497,7 +493,19 @@ static int bch2_check_allocations(struct bch_fs *c) static int bch2_set_may_go_rw(struct bch_fs *c) { + struct journal_keys *keys = &c->journal_keys; + + /* + * After we go RW, the journal keys buffer can't be modified (except for + * setting journal_key->overwritten: it will be accessed by multiple + * threads + */ + move_gap(keys->d, keys->nr, keys->size, keys->gap, keys->nr); + keys->gap = keys->nr; + set_bit(BCH_FS_MAY_GO_RW, &c->flags); + if (keys->nr) + return bch2_fs_read_write_early(c); return 0; } |