Re: [PATCH v3] dax: fix wrong error code returned from dax_dedupe_file_range_compare()

From: Jianyun Gao

Date: Sat Oct 17 2026 - 11:52:38 EST


Hi Alison,

Thanks for the heads-up. The Sashiko complaint in v3 is about a
pre-existing bug in dax_range_compare_iter() — the size parameter
passed to dax_iomap_direct_access() is an absolute file offset
(ALIGN(pos1 + len, PAGE_SIZE)) rather than a relative length.

This is indeed a real bug, but it is a separate issue from what
this patch fixes (wrong error code propagation). I have already
addressed it in a separate patch:

"dax: fix dax_range_compare_iter() to use correct size and address offset"

That patch fixes both the size parameter and the memcmp() addresses
(missing offset_in_page()). The two patches fix independent bugs and
can be applied separately.

I've also replied to Sashiko.

Thanks,
Jianyun

On Fri, Oct 16, 2026 at 9:23 AM Alison Schofield
<alison.schofield@xxxxxxxxx> wrote:
>
> On Thu, Oct 15, 2026 at 10:34:25PM +0800, jianyungao89@xxxxxxxxx wrote:
> > From: Jianyun Gao <jianyungao89@xxxxxxxxx>
> >
> > When dax_range_compare_iter() returns a negative error code (e.g. -EIO),
> > dax_dedupe_file_range_compare() incorrectly returns 'ret' which holds the
> > positive return value from iomap_iter() indicating more iterations remain.
> > This positive value leaks to the caller, where vfs_dedupe_file_range()
> > interprets it as success (bytes_deduped = len), causing userspace to
> > incorrectly believe deduplication completed.
> >
> > Return 'status' instead to propagate the actual error code.
>
> Hi Jianyun,
>
> I looked at merging this today but the Sashiko response stopped me.
>
> I do see you addressed Sashiko in v1, ignored Sashiko in v2.
> If this v3 Sashiko complaint is one you've already addressed, please
> reply saying so. Thanks!
>
> -- Alison
>
> >
> > Fixes: 0e79e3736d54 ("fsdax: dedupe: iter two files at the same time")
> > Cc: stable@xxxxxxxxxxxxxxx
> > Signed-off-by: Jianyun Gao <jianyungao89@xxxxxxxxx>
> > Reviewed-by: Jan Kara <jack@xxxxxxx>
> > Reviewed-by: "Darrick J. Wong" <djwong@xxxxxxxxxx>
> > ---
> > Changes in v3:
> > - Fix the Fixes tag to point to the commit that actually introduced
> > the bug (0e79e3736d54), not the one that renamed the variable
> > - Add Reviewed-by from Darrick J. Wong
> >
> > Link: https://lore.kernel.org/lkml/20261012144925.6728-1-jianyungao89@xxxxxxxxx/ # v2
> > fs/dax.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/dax.c b/fs/dax.c
> > index 6ba50142eeb2..1f6a4fbb97bd 100644
> > --- a/fs/dax.c
> > +++ b/fs/dax.c
> > @@ -2261,7 +2261,7 @@ int dax_dedupe_file_range_compare(struct inode *src, loff_t srcoff,
> > status = dax_range_compare_iter(&src_iter, &dst_iter,
> > min(src_iter.len, dst_iter.len), same);
> > if (status < 0)
> > - return ret;
> > + return status;
> > src_iter.status = dst_iter.status = status;
> > }
> > return ret;
> > --
> > 2.34.1
> >
> >