From nobody Fri Oct 2 03:51:25 2026 Received: from mail-pj1-f41.google.com (mail-pj1-f41.google.com [209.85.216.41]) (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 32A423E3150 for ; Wed, 5 Aug 2026 07:14:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785914064; cv=none; b=nMrb6go+LCyuDX0+0O57K+cAfmMWxo3klcGp/90iKh/J+hip3lZhR+dIr27r2ospfxtIhI7LVOOv2YMdZbbrXRxgmu4o+zuKiEpeuZcaz7yt+OyROY8d6/LNqGmFsxrD+M2OWYFLAWwGlioFylf6gSbTJnILGlB6Vu3VehnlLWM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785914064; c=relaxed/simple; bh=xP/+S3gu9wUEZoivUbQGBRxfYBOOQ6HSp2fiTw8BxT4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mMhwPyJN36TcBOQNpyspUdkTUPkIZsm0T1tQvM4oDAkuZNfWnrutw3H4qN5TX29aKL6ZuTxK2ja6RRC9b7n16/uWHbUUpq7pLuIivIh1pzvN1ywK+xtZXySpX6YHji6HmzKdTvRybhoCMi2DTb5vESsR1z8MTr13UztgO69dZRk= 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=XwdkUGyk; arc=none smtp.client-ip=209.85.216.41 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="XwdkUGyk" Received: by mail-pj1-f41.google.com with SMTP id 98e67ed59e1d1-383b4a3755fso638568a91.3 for ; Wed, 05 Aug 2026 00:14:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785914062; x=1786518862; darn=vger.kernel.org; h=content-transfer-encoding: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=jNUE3YxuYSlEa8cIidZ/GVsUJuIHpIRfbdJefsYc9As=; b=XwdkUGykmkgSd8ATmCOdmvLgM48Rhgk5AVsBINZca8rUE6VkmabFQaZFLWeeQnHEBO BJ3HMiHlCCTUFJgBl9OgOG3p1m65jF5ujgtY/36ie7BrfdNfiiMdguueouySe3BwTrFp QrI6gY+eljCY5G1/xjW6zDYDsbxjmR+YxRMRbaPaFKafP+Id6VjYAQs3mr5/yFBdx0S0 n+7/a8qag+xl4H6rlsC7Cg4Gtcjtq5C+C90H2qnHGwDeFgZFA84pb6pX13r7pkGCVvRr XGsl1PJho/sDLs1km0RtfOpiqXA7CxAh4/IhqGQavk+5rrZz5VIQVRvzDj7YLC+/eco/ Hc/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785914062; x=1786518862; h=content-transfer-encoding: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=jNUE3YxuYSlEa8cIidZ/GVsUJuIHpIRfbdJefsYc9As=; b=aec9g9mQKnJO0ZiGUXvc6lXdT4Rt74wBcd3tFV9dfMI786CnCGXMLUwRT2FnZ6YloC XFkX3GYVYPcX1zpmv41eDa7mXr9aE3HJZoDRoLWLi/qFPEdBY0k0gsscvOOZoV2EOVmD YckX9ZqlDhx3dtL7fnXBQ4h0Ny1EpmEWh/vtUhkHcdBj+Kyci7z/5WrYH3ZsHMqlva3Z 2iCTZS/tj8qYHh18DrDkXguE6WCM416a7VohWLrBs21VKrl44QkADHzjM+AISfTklYoQ EmDhHECzfyZX2zy6hf7JD/kz8t++MHCsCaGfT8Gd02jVKXnKH/IYgHPWofNjwW5fg0Xz bPhw== X-Forwarded-Encrypted: i=1; AHgh+RqwLvke9nBcYnk5xSC23Yqn6bXENbzAxXAo83TtVhpLI2kLNJ7CLibNiSStfxzXR4USVm4Q7ijobEPOaBM=@vger.kernel.org X-Gm-Message-State: AOJu0YxC2S38uRSiTa8b9xiKHAPTozUT+FOWniDQ8kBtLRzLf22lJ6od neKHPcdVa7XCXbo3NZmJ1FgXTfPXvwW0yjqoj+gLQdD5PauYaU5vTwSb X-Gm-Gg: AR+sD11KbPH0hrWU3C+RkgAuGp3344tMSuDf4N9bXNjzkviLBZnrszeMy1/NMnckJ18 x/rH6tYm9ODiuE2hKmgHpFJpBfxRbNtmAAtwmGugoQbtvrygK06BJcAVVaUc3iEXw1K5OWTNAL0 y+vmM8bj3X6IXBWkSBVvVKoiUVabiTxYthQ+JT/MyWssA4/oHfUzt6/fQjyLbxCXzVSjm1SOS/c k6sWoJn91g20P/OtBcybrpfEntg3t9Txu261scVdDXZLyG9eR7GfFamRnL3BVqBQnHunmvjbvYQ rKi9Ux3iy8xE0supw98iQ5q1oOGxxxkqJoulynqrv3tbyK/c+tcPa7xtmKvgTgsVsje2JG8zJB/ Znp93vQPJnQE8+EMWXkT6mEv4w/IRsOK3ami1UBQKmbzQQ555CfFSEa70STnPd47Ij6ydA0YLBJ Zq8VKVXcdP7zU8VENj8zyVXmxd1ygEhUoDc57JvUuKUQpZI2iv0CkQN8G+rj1teOGOVPWN8uTbZ JMpLujgU0L7aQwPHxliJiRWslit7N5X5uXeHEwfH6GStVczNzFduMprcU31KVECVT5YEhfn6TNF Ckq7LUkpaCOvVb2ZvUVT3805IdQmJO5ZKGruthvxb/3wHZwnYLw4 X-Received: by 2002:a17:90b:2785:b0:38e:6c37:d95a with SMTP id 98e67ed59e1d1-3903c5e1f07mr4992236a91.19.1785914062344; Wed, 05 Aug 2026 00:14:22 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 05 Aug 2026 00:14:22 -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 1/2] vfs: fail dedupe requests that cannot make progress Date: Wed, 5 Aug 2026 15:14:13 +0800 Message-ID: <20260805071414.3414870-2-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-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" FIDEDUPERANGE allows the VFS to shorten each destination range. An unaligned, non-EOF request shorter than the filesystem block size can therefore be shortened to zero. vfs_dedupe_file_range_one() then returns zero, but vfs_dedupe_file_range() reports the original length and success even though it made no progress. Reporting the actual return value would expose this as a successful zero-byte operation. While diagnosing the over-reporting, Darrick Wong pointed out that a caller such as duperemove, which advances only by bytes_deduped and has no zero-progress guard, can retry that range forever. Return per-destination -EINVAL when a nonzero request is shortened to zero. Keep the historical result for an explicit zero-length request: bytes_deduped remains zero with FILE_DEDUPE_RANGE_SAME. Other destinations in the same ioctl continue to be processed. Apply this guard before correcting bytes_deduped so that no intermediate kernel exposes a successful zero-progress result. With this guard and the following reporting correction, installed duperemove rounded its match to 98304 bytes and exited with status 0. Installed rmlint exercised the guard: it received 98304 bytes of progress, then 0/-EINVAL for the 1696-byte remainder, and exited with status 1 rather than retrying indefinitely. Link: https://lore.kernel.org/linux-fsdevel/Y93BkIA4Nd3IJAk+@magnolia/ Signed-off-by: Matthias Goergens Reviewed-by: Amir Goldstein --- fs/remap_range.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/fs/remap_range.c b/fs/remap_range.c index 26afbbbfb10c2..53330aa26b86f 100644 --- a/fs/remap_range.c +++ b/fs/remap_range.c @@ -555,6 +555,8 @@ int vfs_dedupe_file_range(struct file *file, struct fil= e_dedupe_range *same) info->status =3D FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) info->status =3D deduped; + else if (!deduped && len) + info->status =3D -EINVAL; else info->bytes_deduped =3D len; =20 --=20 2.55.0 From nobody Fri Oct 2 03:51:25 2026 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+aR8yyeZHmuj1F4d7LCKwAuy3tosQllOAnKDhm6ag3ldBOhg mazFl3WtRhliQ8fkqu1T1w0GTOAsGwo5Jmx4b79M2VmEAKp+wI1bEwm93dh0mNObDLtR 46JdDjaYCn0rUFiL0rNWxhI/6FQTpywGpPgzfLfzVz2Hob+znBAPQ1jneLH96xFnocuE qibA== X-Forwarded-Encrypted: i=1; AHgh+Rpv2JQGl5sF7qnNAnd4D94bIcM70BwHDYafJIC9r6UXYdvUIOheCACKBZRhukr6ls6iGC00lPsTt45xAaQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyU+0kaYz0V/OBlNg0b3CYEO//gWJ7V8qTO6GNmgeaIt1v64U8t 4k/Wu500EWKv5/bqrKG8IlpHZNbRST7VJvfRlqlqTZLEfIvxwXB2xpXm X-Gm-Gg: AR+sD129NX75yyR7DCHftTY8Gx/W87KwWk0MYwwQwFbL/I54zft9QLVm13Be3zh8ZYf 5nXFEVLEJraxblUMM2YJC20LSqhljhPkxJursfX8XW6EvsQwESoERUSf0SqcuDpVRmdMi3D25G/ BpFomsA4yAJgXKx82+LumGP0dct0Guq8XPuWDG7wuiAmbMYHTI8XNngVhycmB3apmbbJsfBoVNj mADVrtwiczJF3M+6tSaK3/0gZPd4yxE+6A8pG7ukzEvTw/MKLtqmRjoCBRuav4SSzZng0+FtXa6 Oi2d7T0eZbVqLhmyK87Ws3+9P0WqpUBsTsgR2/IxvUT8dT7zS0VeN+X8VMf1PlOy5yVUAFpeUjF xzbBgyzQ19FkRTzm+7MPwtfUN5i3k/Udjo3EoMBT9OiOY/Jomm08Hj3dPljzU3FxIkjUQFYZvMm lAUWjBHnh9w5zPFMS+gAg7xvzVgFtyG0sjYfznE1y6hmh8PNHUXyOPWdYe7ZcA+RsQGuADdXNQZ tb0SaWgvX8rTkjupYqycOTc8QEzEd7LCuR/Y2oevrBn1VK1TOpI/Rpd973m/446uCkHjZyU4rMT Y2wBPHke38YY/fasi+1tm6gbXQeO8E/TBRWi0/ihxY1mnA02HX+hABn/N5egtqE= X-Received: by 2002:a17: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: quoted-printable 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=C3=B6=C3=9Fer corrected the assignment in commit 4a57a8400075 ("vf/remap: return the amount of bytes actually deduplicated"), after reports from Max Schlecht and Bj=C3=B6rn Scheuermann. The change was rever= ted 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-03165ce= ccacc@tu-darmstadt.de/ Link: https://lore.kernel.org/all/20220714223238.GH3600936@dread.disaster.a= rea/ Signed-off-by: Matthias Goergens Reviewed-by: Amir Goldstein --- 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 fil= e_dedupe_range *same) else if (!deduped && len) info->status =3D -EINVAL; else - info->bytes_deduped =3D len; + info->bytes_deduped =3D deduped; =20 next_loop: if (fatal_signal_pending(current)) --=20 2.55.0