Skip to content

Commit cab18be

Browse files
author
Kent Overstreet
committed
bcachefs: Fix replay_now_at() assert
Journal replay, in the slowpath where we insert keys in journal order, was inserting keys in the wrong order; keys from early repair come last. Reported-by: [email protected] Signed-off-by: Kent Overstreet <[email protected]>
1 parent 6575b8c commit cab18be

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

fs/bcachefs/recovery.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,13 @@ static int journal_sort_seq_cmp(const void *_l, const void *_r)
241241
const struct journal_key *l = *((const struct journal_key **)_l);
242242
const struct journal_key *r = *((const struct journal_key **)_r);
243243

244-
return cmp_int(l->journal_seq, r->journal_seq);
244+
/*
245+
* Map 0 to U64_MAX, so that keys with journal_seq === 0 come last
246+
*
247+
* journal_seq == 0 means that the key comes from early repair, and
248+
* should be inserted last so as to avoid overflowing the journal
249+
*/
250+
return cmp_int(l->journal_seq - 1, r->journal_seq - 1);
245251
}
246252

247253
int bch2_journal_replay(struct bch_fs *c)

0 commit comments

Comments
 (0)