]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
fsdax: dedupe should compare the min of two iters' length
authorShiyang Ruan <ruansy.fnst@fujitsu.com>
Wed, 22 Mar 2023 07:25:58 +0000 (07:25 +0000)
committerAndrew Morton <akpm@linux-foundation.org>
Tue, 28 Mar 2023 22:24:32 +0000 (15:24 -0700)
In an dedupe comparison iter loop, the length of iomap_iter decreases
because it implies the remaining length after each iteration.

The dedupe command will fail with -EIO if the range is larger than one
page size and not aligned to the page size.  Also report warning in dmesg:

[ 4338.498374] ------------[ cut here ]------------
[ 4338.498689] WARNING: CPU: 3 PID: 1415645 at fs/iomap/iter.c:16
...

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@fujitsu.com
Fixes: 0e79e3736d54 ("fsdax: dedupe: iter two files at the same time")
Signed-off-by: Shiyang Ruan <ruansy.fnst@fujitsu.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Jan Kara <jack@suse.cz>
Cc: Matthew Wilcox (Oracle) <willy@infradead.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/dax.c

index e48d68902a8c1b3a778d2ffa905a0027e36d2ffa..5d2e9b10030e9056a1274e538a7a7fa0df59458f 100644 (file)
--- a/fs/dax.c
+++ b/fs/dax.c
@@ -2027,8 +2027,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;