From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f47.google.com (mail-pj1-f47.google.com [209.85.216.47]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 391303E1218 for ; Wed, 5 Aug 2026 07:14:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.47 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785914069; cv=none; b=POi7svrjxIHHI/BHkU86UmzyCqN5LV7Kezx2L8UcJFz5pz5/1RXQqBf1qJwWCcotsNvdpX+Q5L8XbN45Pe9A7R7Kqq1HcFP2MTqSqq6E0BW2E8KKEyhW/55DJmEo/NRxayQk+YaJZ07VCfbh1XGzwbd/f64siKZQAQfDUMPjsOs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785914069; c=relaxed/simple; bh=Cbors7LYoRtUFE3UxPDL9X6jDJmMzv9wqC58FSZ74rI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=R5ZC2KNOg4z7e06rmUOuIyqinu9R/xxk2cUFhz84Lh7VMo2+nQ60JPUPKPPAMFhREiFj9nV/B+sP+DEy0o75hxTBQC04MMvfbqtpm0ECfz3OtSVIHcHxYMPa3Ey8cwP/POYJmWldc1AacMhb+Ji9PWShZ3fVWHoKusAFlPkMM2I= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BWH927wK; arc=none smtp.client-ip=209.85.216.47 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BWH927wK" Received: by mail-pj1-f47.google.com with SMTP id 98e67ed59e1d1-38dc4553f62so718358a91.0 for ; Wed, 05 Aug 2026 00:14:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785914065; x=1786518865; darn=vger.kernel.org; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:from:to:cc:subject :date:message-id:reply-to:content-type; bh=N9yS6OSlFyckyo9C2NOANFCam/YF/XXAlqIaEJvC654=; b=BWH927wK6IS1nIuqnLGL5e9EOZ7JQj4c1NDuWiATVRQBSFbMMXdHg7JgsWo5+xf+Vm zFQ0cKv+Aly6DiRISuJlHjr6FHANYpvA7lt0585V0nhMxY31wDGZilhY+qiu9FiL15kJ +tmywDyuzAD51dA43q4PuPr42Eow9emktk3p1eudX5caf2tQkjay1SA/sQr9u6o9AhIH Skz4v9rEJrdWOCGOhL0GqjSCHqf8DLQXdg43OJN8fQ8ZIQMHGBohZ8OB7oxgVbQs5yae woywrkMEeHnrxwniOPsvJ6x74yUK+T0YkeloBvcnaCKLG9S2xFYam0Mf/3dbTkYdIpHc YFbA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785914065; x=1786518865; h=content-transfer-encoding:content-type:mime-version:references :in-reply-to:message-id:date:subject:cc:to:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=N9yS6OSlFyckyo9C2NOANFCam/YF/XXAlqIaEJvC654=; b=TZuxapzyT9nfaxs3J3k9CTzWXjKFsrZTzNSr38nRbeL4HxqPtxmPCrqcWZ529qjfoO DJyx7U/neb+HTXMB7P1sb8h3CG1eATs3MnBjNPFEpB02UC4znOR5z5AieHll02XnVQBM 85BCVKwl8cSMDghJ8YWo+aR8yyeZHmuj1F4d7LCKwAuy3tosQllOA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90b:1809:b0:37f:e177:f58 with SMTP id 98e67ed59e1d1-3903c583c08mr4196054a91.9.1785914065537; Wed, 05 Aug 2026 00:14:25 -0700 (PDT) Received: from spider.bream-herring.ts.net ([103.252.203.158]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-390392aef87sm2158639a91.13.2026.08.05.00.14.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 00:14:25 -0700 (PDT) From: Matthias Goergens To: Alexander Viro , Christian Brauner , Jan Kara Cc: Matthias Goergens , linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, =?UTF-8?q?Ansgar=20L=C3=B6=C3=9Fer?= , "Darrick J . Wong" , Dave Chinner , Amir Goldstein Subject: [PATCH 2/2] vfs: report the amount of bytes actually deduplicated Date: Wed, 5 Aug 2026 15:14:14 +0800 Message-ID: <20260805071414.3414870-3-matthias.goergens@gmail.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260805071414.3414870-1-matthias.goergens@gmail.com> References: <20260805071414.3414870-1-matthias.goergens@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/5548ef63-62f9-4f46-5793-03165ceccacc@tu-darmstadt.de/ Link: https://lore.kernel.org/all/20220714223238.GH3600936@dread.disaster.area/ Signed-off-by: Matthias Goergens --- 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