[PATCH 2/2] vfs: report the amount of bytes actually deduplicated
Matthias Goergens <[email protected]> Wed, 5 Aug 2026 15:14:14 +0800
| Newsgroups | gmane.linux.file-systems,gmane.linux.kernel |
|---|---|
| Message-ID | <[email protected]> |
FIDEDUPERANGE promises to return the number of bytes successfully
deduplicated in bytes_deduped. vfs_dedupe_file_range_one() can shorten
a request and returns the resulting byte count. However,
vfs_dedupe_file_range() discards that value and reports the original
request length.
The VFS ioctl originally accumulated the returned byte count in commit
54dbc1517237 ("vfs: hoist the btrfs deduplication ioctl to the vfs").
Commit 5740c99e9d30 ("vfs: dedupe: return int") changed the filesystem
callback to return status and substituted the requested length. The
helper once again returns a loff_t byte count, but the stale assignment
remained.
Ansgar Lößer corrected the assignment in commit 4a57a8400075
("vf/remap: return the amount of bytes actually deduplicated"), after
reports from Max Schlecht and Björn Scheuermann. The change was reverted
the next day after generic/517 exposed its expectation of the
over-reported value and the userspace impact still needed investigation.
Restore that correction. A nonzero request shortened to zero now fails
with -EINVAL due to the preceding change. Callers that advance by
bytes_deduped therefore cannot retry such a range forever.
Updated generic/517 and raw multi-destination coverage in generic/806
pass on both btrfs and XFS. Installed duperemove rounded its match to
98304 bytes and exited with status 0. Installed rmlint received 98304
bytes of progress followed by 0/-EINVAL for the 1696-byte remainder and
exited with status 1 instead of silently accepting the over-reported
request.
Link: https://lore.kernel.org/linux-fsdevel/[email protected]/
Link: https://lore.kernel.org/all/[email protected]/
Signed-off-by: Matthias Goergens <[email protected]>
---
fs/remap_range.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/remap_range.c b/fs/remap_range.c
index 53330aa26b86f..9fedc22b52761 100644
--- a/fs/remap_range.c
+++ b/fs/remap_range.c
@@ -558,7 +558,7 @@ int vfs_dedupe_file_range(struct file *file, struct file_dedupe_range *same)
else if (!deduped && len)
info->status = -EINVAL;
else
- info->bytes_deduped = len;
+ info->bytes_deduped = deduped;
next_loop:
if (fatal_signal_pending(current))
--
2.55.0