summaryrefslogtreecommitdiff
path: root/fs/bcachefs/btree_update_leaf.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2022-04-11 20:28:13 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:31 -0400
commit5650bb46be89a1254609d47e4c87d1e9cf9121fb (patch)
tree73506214235f46eed04b2e4675463db1b38b2ea4 /fs/bcachefs/btree_update_leaf.c
parent9b93596c33f6c23de96c05dce82b9aead271a286 (diff)
downloadlinux-5650bb46be89a1254609d47e4c87d1e9cf9121fb.tar.gz
linux-5650bb46be89a1254609d47e4c87d1e9cf9121fb.tar.bz2
linux-5650bb46be89a1254609d47e4c87d1e9cf9121fb.zip
bcachefs: Introduce bch2_journal_keys_peek_(upto|slot)()
When many journal replay keys have been overwritten, bch2_journal_keys_peek() was taking excessively long to scan before it found a key to return. Fix this by introducing bch2_journal_keys_peek_upto() which takes a parameter for the end of the range we want, so that we can terminate the search much sooner, and replace all uses of bch2_journal_keys_peek() with peek_upto() or peek_slot(). Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
Diffstat (limited to 'fs/bcachefs/btree_update_leaf.c')
-rw-r--r--fs/bcachefs/btree_update_leaf.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/fs/bcachefs/btree_update_leaf.c b/fs/bcachefs/btree_update_leaf.c
index bc7faf29b3bc..a63c2f36bae4 100644
--- a/fs/bcachefs/btree_update_leaf.c
+++ b/fs/bcachefs/btree_update_leaf.c
@@ -670,9 +670,10 @@ bch2_trans_commit_write_locked(struct btree_trans *trans,
if (unlikely(!test_bit(JOURNAL_REPLAY_DONE, &c->journal.flags))) {
struct bkey_i *j_k =
- bch2_journal_keys_peek(c, i->btree_id, i->level, i->k->k.p);
+ bch2_journal_keys_peek_slot(c, i->btree_id, i->level,
+ i->k->k.p);
- if (j_k && !bpos_cmp(j_k->k.p, i->k->k.p)) {
+ if (j_k) {
i->old_k = j_k->k;
i->old_v = &j_k->v;
}
@@ -1550,9 +1551,9 @@ bch2_trans_update_by_path_trace(struct btree_trans *trans, struct btree_path *pa
if (unlikely(trans->journal_replay_not_finished)) {
struct bkey_i *j_k =
- bch2_journal_keys_peek(c, n.btree_id, n.level, k->k.p);
+ bch2_journal_keys_peek_slot(c, n.btree_id, n.level, k->k.p);
- if (j_k && !bpos_cmp(j_k->k.p, i->k->k.p)) {
+ if (j_k) {
i->old_k = j_k->k;
i->old_v = &j_k->v;
}