From 4f948723eda1ca44e470c31fcab4a453ed53aa13 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Fri, 9 Dec 2022 14:09:14 -0500 Subject: [PATCH] bcachefs: Fix bch2_journal_keys_peek_upto() bch2_journal_keys_peek_upto() was comparing against btree_id & level incorrectly - fix this by using __journal_key_cmp(). Signed-off-by: Kent Overstreet --- fs/bcachefs/recovery.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/bcachefs/recovery.c b/fs/bcachefs/recovery.c index aff813e3e3604..15a676196e2fd 100644 --- a/fs/bcachefs/recovery.c +++ b/fs/bcachefs/recovery.c @@ -128,12 +128,12 @@ search: if (!*idx) *idx = __bch2_journal_key_search(keys, btree_id, level, pos); - while (*idx < keys->nr && - (k = idx_to_key(keys, *idx), - k->btree_id == btree_id && - k->level == level && - bpos_le(k->k->k.p, end_pos))) { - if (bpos_ge(k->k->k.p, pos) && !k->overwritten) + while ((k = *idx < keys->nr ? idx_to_key(keys, *idx) : NULL)) { + if (__journal_key_cmp(btree_id, level, end_pos, k) < 0) + return NULL; + + if (__journal_key_cmp(btree_id, level, pos, k) <= 0 && + !k->overwritten) return k->k; (*idx)++; -- 2.30.2