The patch titled Subject: fsdax: dedupe should compare the min of two iters' length has been added to the -mm mm-unstable branch. Its filename is fsdax-dedupe-should-compare-the-min-of-two-iters-length.patch This patch will shortly appear at https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/fsdax-dedupe-should-compare-the-min-of-two-iters-length.patch This patch will later appear in the mm-unstable branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/process/submit-checklist.rst when testing your code *** The -mm tree is included into linux-next via the mm-everything branch at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm and is updated there every 2-3 working days ------------------------------------------------------ From: Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx> Subject: fsdax: dedupe should compare the min of two iters' length Date: Wed, 22 Mar 2023 07:25:58 +0000 In an dedupe comparison 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. Link: https://lkml.kernel.org/r/1679469958-2-1-git-send-email-ruansy.fnst@xxxxxxxxxxx Fixes: 0e79e3736d54 ("fsdax: dedupe: iter two files at the same time") Signed-off-by: Shiyang Ruan <ruansy.fnst@xxxxxxxxxxx> Reviewed-by: Darrick J. Wong <djwong@xxxxxxxxxx> Cc: Dan Williams <dan.j.williams@xxxxxxxxx> Cc: Jan Kara <jack@xxxxxxx> Cc: Matthew Wilcox (Oracle) <willy@xxxxxxxxxxxxx> Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- --- a/fs/dax.c~fsdax-dedupe-should-compare-the-min-of-two-iters-length +++ a/fs/dax.c @@ -2027,8 +2027,8 @@ int dax_dedupe_file_range_compare(struct 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; _ Patches currently in -mm which might be from ruansy.fnst@xxxxxxxxxxx are fsdax-unshare-zero-destination-if-srcmap-is-hole-or-unwritten.patch fsdax-dedupe-should-compare-the-min-of-two-iters-length.patch