From e1f6739c4a9fee1db7d94a5087a253041542cb62 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 14 May 2020 21:45:08 -0400 Subject: [PATCH] bcachefs: Fix another iterator counting bug We were marking the end of where we could insert incorrectly for indirect extents. Signed-off-by: Kent Overstreet --- fs/bcachefs/extent_update.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/bcachefs/extent_update.c b/fs/bcachefs/extent_update.c index d0af1bc17018ad..fd011df3cb9943 100644 --- a/fs/bcachefs/extent_update.c +++ b/fs/bcachefs/extent_update.c @@ -76,7 +76,8 @@ static int count_iters_for_insert(struct btree_trans *trans, if (*nr_iters >= max_iters) { struct bpos pos = bkey_start_pos(k.k); - pos.offset += r_k.k->p.offset - idx; + pos.offset += min_t(u64, k.k->size, + r_k.k->p.offset - idx); *end = bpos_min(*end, pos); ret = 1;