From mboxrd@z Thu Jan 1 00:00:00 1970 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: 8bit 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 --- 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 file_dedupe_range *same) info->status = FILE_DEDUPE_RANGE_DIFFERS; else if (deduped < 0) info->status = deduped; + else if (!deduped && len) + info->status = -EINVAL; else info->bytes_deduped = len; -- 2.55.0