Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1956908pxb; Sat, 27 Feb 2021 06:01:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2TVxO1TmpmL6bdTI8Ty/2UDmJElXmU54a21yd90vMYnDZGsebq+NDgDeoIyXRzveAv7qZ X-Received: by 2002:a17:907:7781:: with SMTP id ky1mr7939023ejc.255.1614434466559; Sat, 27 Feb 2021 06:01:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614434466; cv=none; d=google.com; s=arc-20160816; b=B/j2O3jTcDglFWvV60cGa2UTF657PVqLfyiQSYe8SESwQm6eMjwU5G9b+xUtXWpoD4 hUqhwlGeghOUAJX+/1s2sIROKBmScyFKUY9uJHQM74eNI3j3ttT5jahnY6DpprvqtozH Kri6FeN/9JD/g6rDakhgOFVFSWkjnXAPGkesezZH1yN4rSk7a8foPyDxeBN0G/s/mSvD GW7k3Ibo+d60BWSd43OkyO3Xh0Wp66QBS9bP+M8y79HlOLDN23mrAh8CNN/7QdxksAks EUS9rrQy5iDs9KAIv21IkwdLI22DTdc6AkvAe/RRENH7en4iqpKGaME5Zny0Ch6WNyIa nHUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=tvAI4IdeCO4sgAZNtE9xDAeulh8mRYshdjpgF2TPJtQ=; b=gbMjjJpm16rzpQHQ4BubjEY4dx+PaH7SBuWGxUJsM9fDwy/5dubyjKLXYafdPpFLGT /Xi6/INrxT9zlJyBMlDLRrcAu4w7pM0rG2F9AkeKxNGP49+IyKmeAIc7CPwfdxGyaoRB TQ85Td/UshNBvalm8WtTQxhsNmb/tIjKoGjB+/5T51EDDetIqdP9L5kB+xTG8EMQsIFM SLLmKWWGZ3YqZw0xqbsT0TukJZuVZ+e3dfCvkT25PX3XSJiICNVBbBVQ/mVNYBo1oxDl ZN3+sv6in7ifhVux2RG9Sczsp0ABZVIPDF2qwnlEmLrNDkb7kzSELcAtDla05HR1EJY8 DwLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b3FMrX8Y; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p17si7833372ejf.513.2021.02.27.06.00.30; Sat, 27 Feb 2021 06:01:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=b3FMrX8Y; spf=pass (google.com: domain of linux-nfs-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-nfs-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230184AbhB0OAL (ORCPT + 99 others); Sat, 27 Feb 2021 09:00:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41494 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbhB0OAJ (ORCPT ); Sat, 27 Feb 2021 09:00:09 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3FB68C061756; Sat, 27 Feb 2021 05:59:29 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id u11so3991085wmq.5; Sat, 27 Feb 2021 05:59:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tvAI4IdeCO4sgAZNtE9xDAeulh8mRYshdjpgF2TPJtQ=; b=b3FMrX8YKqdozH2POjKQ+nxkWJquvm5hRtl3h1dXTQJoPlINIRcY6gEeQWkGu4UwTf 3JgyqYgejIWxklabYKU1NL1rsXaPWtA6qB/9OGWxoUuCGMQ2ga9eyaUTow9ROHIPX6s1 gO9PUHl5oM30m63BL+b5iWtgPAIPSCgup+sieUe8U/PEJwCIIObPyKuTCxjx36guplVJ AcUt8MXyc60m7K1uFQA25F63QMDHrzDrQ9gYprwbfkoBBmZj0FNxFxS6F29Zn5UzOl11 ILjHw9/94z7IjKjZEQAI5zaeCmA8kq6AcBom8vo5MsdIQSg/h7eYKD4z2Wt/jmJEahdQ Yv0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tvAI4IdeCO4sgAZNtE9xDAeulh8mRYshdjpgF2TPJtQ=; b=e6COPEbP0AD+vm1rh50eRl/LIhmz48No6XhS5JgWoOp3hxcOHVAkZDNe752dCCG6QA XUnu45K6xgrpch+EKUTk34wprterSmerkUhxq5RTDDKFdKzXPzJhEDz7qwJVHS5RRn1o 4f/QrsC6dfcNIzOBaR3hnVMvuLLAJE/0KUhIsITCf7OOi9ykK8acrX/2Z/0Mw64K5JvU geQDf0pvMMqFGlS1oTsgrlTuqyvzjLXHvGMjzxZR+PAqthFoledR5NX+AYHvooqu/UsT ANQ6czEvrm718NmDq6lO3Y2mpg8zYplQfarhwCxTnC39lhILL16+TaCLYfofVLO2Svc+ NzWw== X-Gm-Message-State: AOAM5319eAKKY6JwHco5G7omM37djwLWc+y6drjXt1X5EBYgap0PIopM +CCOsPvhkIMgRbiG5VWj6s8= X-Received: by 2002:a05:600c:350c:: with SMTP id h12mr7336570wmq.39.1614434367999; Sat, 27 Feb 2021 05:59:27 -0800 (PST) Received: from localhost.localdomain ([170.253.51.130]) by smtp.googlemail.com with ESMTPSA id f22sm3871680wmc.33.2021.02.27.05.59.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Feb 2021 05:59:27 -0800 (PST) From: Alejandro Colomar To: Amir Goldstein , Michael Kerrisk , linux-man@vger.kernel.org, Luis Henriques Cc: Alejandro Colomar , Greg KH , Anna Schumaker , Jeff Layton , Steve French , Miklos Szeredi , Trond Myklebust , Alexander Viro , "Darrick J. Wong" , Dave Chinner , Nicolas Boichat , Ian Lance Taylor , Luis Lozano , Andreas Dilger , Olga Kornievskaia , Christoph Hellwig , ceph-devel , linux-kernel , CIFS , samba-technical , linux-fsdevel , Linux NFS Mailing List , Walter Harms Subject: [RFC v2] copy_file_range.2: Update cross-filesystem support for 5.12 Date: Sat, 27 Feb 2021 14:49:23 +0100 Message-Id: <20210227134922.5706-1-alx.manpages@gmail.com> X-Mailer: git-send-email 2.30.1.721.g45526154a5 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org Linux 5.12 fixes a regression. Cross-filesystem copies (introduced in 5.3) were buggy. Move the statements documenting cross-fs to BUGS. Kernels 5.3..5.11 should be patched soon. State version information for some errors related to this. Reported-by: Luis Henriques Reported-by: Amir Goldstein Related: Cc: Greg KH Cc: Michael Kerrisk Cc: Anna Schumaker Cc: Jeff Layton Cc: Steve French Cc: Miklos Szeredi Cc: Trond Myklebust Cc: Alexander Viro Cc: "Darrick J. Wong" Cc: Dave Chinner Cc: Nicolas Boichat Cc: Ian Lance Taylor Cc: Luis Lozano Cc: Andreas Dilger Cc: Olga Kornievskaia Cc: Christoph Hellwig Cc: ceph-devel Cc: linux-kernel Cc: CIFS Cc: samba-technical Cc: linux-fsdevel Cc: Linux NFS Mailing List Cc: Walter Harms Signed-off-by: Alejandro Colomar --- Hi all, Please check that this is correct. I wrote it as I understood copy_file_range() from the LWN article, and the conversation on this thread, but maybe someone with more experience on this syscall find bugs in my patch. When kernels 5.3..5.11 fix this, some info could be compacted a bit more, and maybe the BUGS section could be removed. Also, I'd like to know which filesystems support cross-fs, and since when. Amir, you said that it was only cifs and nfs (since when? 5.3? 5.12?). Also, I'm a bit surprised that <5.3 could fail with EOPNOTSUPP and it wasn't documented. Is that for sure, Amir? Thanks, Alex --- man2/copy_file_range.2 | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/man2/copy_file_range.2 b/man2/copy_file_range.2 index 611a39b80..93f54889d 100644 --- a/man2/copy_file_range.2 +++ b/man2/copy_file_range.2 @@ -169,6 +169,9 @@ Out of memory. .B ENOSPC There is not enough space on the target filesystem to complete the copy. .TP +.BR EOPNOTSUPP " (before Linux 5.3; or since Linux 5.12)" +The filesystem does not support this operation. +.TP .B EOVERFLOW The requested source or destination range is too large to represent in the specified data types. @@ -184,10 +187,17 @@ or .I fd_out refers to an active swap file. .TP -.B EXDEV +.BR EXDEV " (before Linux 5.3)" The files referred to by .IR fd_in " and " fd_out -are not on the same mounted filesystem (pre Linux 5.3). +are not on the same filesystem. +.TP +.BR EXDEV " (or since Linux 5.12)" +The files referred to by +.IR fd_in " and " fd_out +are not on the same filesystem, +and the source and target filesystems are not of the same type, +or do not support cross-filesystem copy. .SH VERSIONS The .BR copy_file_range () @@ -195,13 +205,10 @@ system call first appeared in Linux 4.5, but glibc 2.27 provides a user-space emulation when it is not available. .\" https://sourceware.org/git/?p=glibc.git;a=commit;f=posix/unistd.h;h=bad7a0c81f501fbbcc79af9eaa4b8254441c4a1f .PP -A major rework of the kernel implementation occurred in 5.3. -Areas of the API that weren't clearly defined were clarified and the API bounds -are much more strictly checked than on earlier kernels. -Applications should target the behaviour and requirements of 5.3 kernels. -.PP -First support for cross-filesystem copies was introduced in Linux 5.3. -Older kernels will return -EXDEV when cross-filesystem copies are attempted. +Since 5.12, +cross-filesystem copies can be achieved +when both filesystems are of the same type, +and that filesystem implements support for it. .SH CONFORMING TO The .BR copy_file_range () @@ -226,6 +233,10 @@ gives filesystems an opportunity to implement "copy acceleration" techniques, such as the use of reflinks (i.e., two or more inodes that share pointers to the same copy-on-write disk blocks) or server-side-copy (in the case of NFS). +.SH BUGS +In Linux kernels 5.3 to 5.11, cross-filesystem copies were supported. +However, on some virtual filesystems, the call failed to copy, +eventhough it may have reported success. .SH EXAMPLES .EX #define _GNU_SOURCE -- 2.30.1.721.g45526154a5