summaryrefslogtreecommitdiffstats
path: root/fs/bcachefs/reflink.c
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2022-10-11 04:32:41 -0400
committerKent Overstreet <kent.overstreet@linux.dev>2023-10-22 17:09:50 -0400
commitc72f687a1ff1801b404fab804fdddcaf034e6ef4 (patch)
tree53648acc4521cf44688250b6402edf871bec0781 /fs/bcachefs/reflink.c
parent5b3008bc6182e56fdd5ba36fdf324430d0792e0c (diff)
downloadlinux-stable-c72f687a1ff1801b404fab804fdddcaf034e6ef4.tar.gz
linux-stable-c72f687a1ff1801b404fab804fdddcaf034e6ef4.tar.bz2
linux-stable-c72f687a1ff1801b404fab804fdddcaf034e6ef4.zip
bcachefs: Use for_each_btree_key_upto() more consistently
It's important that in BTREE_ITER_FILTER_SNAPSHOTS mode we always use peek_upto() and provide an end for the interval we're searching for - otherwise, when we hit the end of the inode the next inode be in a different subvolume and not have any keys in the current snapshot, and we'd iterate over arbitrarily many keys before returning one. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'fs/bcachefs/reflink.c')
-rw-r--r--fs/bcachefs/reflink.c6
1 files changed, 1 insertions, 5 deletions
diff --git a/fs/bcachefs/reflink.c b/fs/bcachefs/reflink.c
index 08c98ac03c13..130ecc3a05c6 100644
--- a/fs/bcachefs/reflink.c
+++ b/fs/bcachefs/reflink.c
@@ -251,13 +251,9 @@ static struct bkey_s_c get_next_src(struct btree_iter *iter, struct bpos end)
struct bkey_s_c k;
int ret;
- for_each_btree_key_continue_norestart(*iter, 0, k, ret) {
- if (bkey_ge(iter->pos, end))
- break;
-
+ for_each_btree_key_upto_continue_norestart(*iter, end, 0, k, ret)
if (bkey_extent_is_data(k.k))
return k;
- }
if (bkey_ge(iter->pos, end))
bch2_btree_iter_set_pos(iter, end);