mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
@ 2026-10-10  2:10 jianyungao89
  2026-10-12  9:47 ` Jan Kara
  2026-10-12 13:40 ` Markus Elfring
  0 siblings, 2 replies; 4+ messages in thread
From: jianyungao89 @ 2026-10-10  2:10 UTC (permalink / raw)
  To: linux-kernel
  Cc: Jianyun Gao, Dan Williams, Matthew Wilcox, Jan Kara,
	Alexander Viro, Christian Brauner,
	open list:FILESYSTEM DIRECT ACCESS (DAX),
	open list:FILESYSTEM DIRECT ACCESS (DAX)

From: Jianyun Gao <jianyungao89@gmail.com>

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.

Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>
---
 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


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

* Re: [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
  2026-10-10  2:10 [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare() jianyungao89
@ 2026-10-12  9:47 ` Jan Kara
  2026-10-12 13:40 ` Markus Elfring
  1 sibling, 0 replies; 4+ messages in thread
From: Jan Kara @ 2026-10-12  9:47 UTC (permalink / raw)
  To: jianyungao89
  Cc: linux-kernel, Dan Williams, Matthew Wilcox, Jan Kara,
	Alexander Viro, Christian Brauner,
	open list:FILESYSTEM DIRECT ACCESS (DAX),
	open list:FILESYSTEM DIRECT ACCESS (DAX)

On Sat 10-10-26 10:10:09, jianyungao89@gmail.com wrote:
> From: Jianyun Gao <jianyungao89@gmail.com>
> 
> 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.
> 
> Signed-off-by: Jianyun Gao <jianyungao89@gmail.com>

Looks good. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

> ---
>  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
> 
-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

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

* Re: [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
  2026-10-10  2:10 [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare() jianyungao89
  2026-10-12  9:47 ` Jan Kara
@ 2026-10-12 13:40 ` Markus Elfring
  2026-10-12 14:13   ` Jianyun Gao
  1 sibling, 1 reply; 4+ messages in thread
From: Markus Elfring @ 2026-10-12 13:40 UTC (permalink / raw)
  To: Jianyun Gao, linux-fsdevel, nvdimm
  Cc: LKML, Alexander Viro, Christian Brauner, Dan Williams, Jan Kara,
	Matthew Wilcox

…
> Return 'status' instead to propagate the actual error code.

How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?

See also:
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc7#n145
* https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.3-rc7#n34


Regards,
Markus

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

* Re: [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare()
  2026-10-12 13:40 ` Markus Elfring
@ 2026-10-12 14:13   ` Jianyun Gao
  0 siblings, 0 replies; 4+ messages in thread
From: Jianyun Gao @ 2026-10-12 14:13 UTC (permalink / raw)
  To: Markus Elfring
  Cc: linux-fsdevel, nvdimm, LKML, Alexander Viro, Christian Brauner,
	Dan Williams, Jan Kara, Matthew Wilcox

Hi Markus,

Thank you for the suggestion! I will add the "Fixes" and "Cc" tags in
the next version.

Best regards,
Jianyun

On Mon, Oct 12, 2026 at 9:40 PM Markus Elfring <Markus.Elfring@web.de> wrote:
>
> …
> > Return 'status' instead to propagate the actual error code.
>
> How do you think about to add any tags (like “Fixes” and “Cc”) accordingly?
>
> See also:
> * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v7.3-rc7#n145
> * https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/stable-kernel-rules.rst?h=v7.3-rc7#n34
>
>
> Regards,
> Markus

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

end of thread, other threads:[~2026-10-12 14:13 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-10  2:10 [PATCH] dax: fix wrong error code returned from dax_dedupe_file_range_compare() jianyungao89
2026-10-12  9:47 ` Jan Kara
2026-10-12 13:40 ` Markus Elfring
2026-10-12 14:13   ` Jianyun Gao

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®