All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] fsdax: dedupe should compare the min of two iters' length
@ 2023-03-22  7:25 Shiyang Ruan
  2023-03-22 14:44 ` Darrick J. Wong
  2023-03-22 23:12 ` Andrew Morton
  0 siblings, 2 replies; 7+ messages in thread
From: Shiyang Ruan @ 2023-03-22  7:25 UTC (permalink / raw)
  To: linux-fsdevel, nvdimm; +Cc: dan.j.williams, willy, jack, akpm

In an dedupe corporation iter loop, the length of iomap_iter decreases
because it implies the remaining length after each iteration.  The
compare function should use the min length of the current iters, not the
total length.

Fixes: 0e79e3736d54 ("fsdax: dedupe: iter two files at the same time")
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
---
 fs/dax.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/dax.c b/fs/dax.c
index 3e457a16c7d1..9800b93ee14d 100644
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -2022,8 +2022,8 @@ int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
 
 	while ((ret = iomap_iter(&src_iter, ops)) > 0 &&
 	       (ret = iomap_iter(&dst_iter, ops)) > 0) {
-		compared = dax_range_compare_iter(&src_iter, &dst_iter, len,
-						  same);
+		compared = dax_range_compare_iter(&src_iter, &dst_iter,
+				min(src_iter.len, dst_iter.len), same);
 		if (compared < 0)
 			return ret;
 		src_iter.processed = dst_iter.processed = compared;
-- 
2.39.2


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-03-24 20:34 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-22  7:25 [PATCH] fsdax: dedupe should compare the min of two iters' length Shiyang Ruan
2023-03-22 14:44 ` Darrick J. Wong
2023-03-22 23:12 ` Andrew Morton
2023-03-23  6:48   ` Shiyang Ruan
2023-03-23 22:12     ` Andrew Morton
2023-03-24  4:19       ` Shiyang Ruan
2023-03-24 20:34         ` Andrew Morton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.