Skip to content

Commit ef4f6c3

Browse files
author
Kent Overstreet
committed
bcachefs: Ensure BCH_FS_may_go_rw is set before exiting recovery
If BCH_FS_may_go_rw is not yet set, it indicates to the transaction commit path that updates should be done via the list of journal replay keys. This must be set before multithreaded use commences. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
1 parent cec136d commit ef4f6c3

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

fs/bcachefs/recovery.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,13 @@ int bch2_fs_recovery(struct bch_fs *c)
862862
if (ret)
863863
goto err;
864864

865+
/*
866+
* Normally set by the appropriate recovery pass: when cleared, this
867+
* indicates we're in early recovery and btree updates should be done by
868+
* being applied to the journal replay keys. _Must_ be cleared before
869+
* multithreaded use:
870+
*/
871+
set_bit(BCH_FS_may_go_rw, &c->flags);
865872
clear_bit(BCH_FS_fsck_running, &c->flags);
866873

867874
/* in case we don't run journal replay, i.e. norecovery mode */

fs/bcachefs/recovery_passes.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,12 @@ int bch2_run_recovery_passes(struct bch_fs *c)
221221
{
222222
int ret = 0;
223223

224+
/*
225+
* We can't allow set_may_go_rw to be excluded; that would cause us to
226+
* use the journal replay keys for updates where it's not expected.
227+
*/
228+
c->opts.recovery_passes_exclude &= ~BCH_RECOVERY_PASS_set_may_go_rw;
229+
224230
while (c->curr_recovery_pass < ARRAY_SIZE(recovery_pass_fns)) {
225231
if (c->opts.recovery_pass_last &&
226232
c->curr_recovery_pass > c->opts.recovery_pass_last)

0 commit comments

Comments
 (0)