Re: [RFC v3] copy_file_range.2: Update cross-filesystem support for 5.12

From: Amir Goldstein
Date: Mon Mar 01 2021 - 10:00:36 EST


On Mon, Mar 1, 2021 at 4:45 PM Alejandro Colomar <alx.manpages@xxxxxxxxx> wrote:
>
> Linux 5.12 fixes a regression.
>
> Cross-filesystem (introduced in 5.3) copies 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 <lhenriques@xxxxxxx>
> Reported-by: Amir Goldstein <amir73il@xxxxxxxxx>
> Related: <https://lwn.net/Articles/846403/>
> Cc: Greg KH <gregkh@xxxxxxxxxxxxxxxxxxx>
> Cc: Michael Kerrisk <mtk.manpages@xxxxxxxxx>
> Cc: Anna Schumaker <anna.schumaker@xxxxxxxxxx>
> Cc: Jeff Layton <jlayton@xxxxxxxxxx>
> Cc: Steve French <sfrench@xxxxxxxxx>
> Cc: Miklos Szeredi <miklos@xxxxxxxxxx>
> Cc: Trond Myklebust <trond.myklebust@xxxxxxxxxxxxxxx>
> Cc: Alexander Viro <viro@xxxxxxxxxxxxxxxxxx>
> Cc: "Darrick J. Wong" <darrick.wong@xxxxxxxxxx>
> Cc: Dave Chinner <dchinner@xxxxxxxxxx>
> Cc: Nicolas Boichat <drinkcat@xxxxxxxxxxxx>
> Cc: Ian Lance Taylor <iant@xxxxxxxxxx>
> Cc: Luis Lozano <llozano@xxxxxxxxxxxx>
> Cc: Andreas Dilger <adilger@xxxxxxxxx>
> Cc: Olga Kornievskaia <aglo@xxxxxxxxx>
> Cc: Christoph Hellwig <hch@xxxxxxxxxxxxx>
> Cc: ceph-devel <ceph-devel@xxxxxxxxxxxxxxx>
> Cc: linux-kernel <linux-kernel@xxxxxxxxxxxxxxx>
> Cc: CIFS <linux-cifs@xxxxxxxxxxxxxxx>
> Cc: samba-technical <samba-technical@xxxxxxxxxxxxxxx>
> Cc: linux-fsdevel <linux-fsdevel@xxxxxxxxxxxxxxx>
> Cc: Linux NFS Mailing List <linux-nfs@xxxxxxxxxxxxxxx>
> Cc: Walter Harms <wharms@xxxxxx>
> Signed-off-by: Alejandro Colomar <alx.manpages@xxxxxxxxx>
> ---
>
> v3:
> - Don't remove some important text.
> - Reword BUGS.
>
> ---
> Hi Amir,
>
> I covered your comments. I may need to add something else after your
> discussion with Steve; please comment.
>
> I tried to reword BUGS so that it's as specific and understandable as I can.
> If you still find it not good enough, please comment :)
>
> Thanks,
>
> Alex
>
> ---
> man2/copy_file_range.2 | 26 ++++++++++++++++++++++----
> 1 file changed, 22 insertions(+), 4 deletions(-)
>
> diff --git a/man2/copy_file_range.2 b/man2/copy_file_range.2
> index 611a39b80..1c0df3f74 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 " (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 filesystem.
> +.TP
> +.BR EXDEV " (since Linux 5.12)"
> 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,
> +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 ()
> @@ -200,8 +210,10 @@ 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.

Maybe refer to BUGS here for pre 5.12 behavior?

> .SH CONFORMING TO
> The
> .BR copy_file_range ()
> @@ -226,6 +238,12 @@ 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 by the kernel,
> +instead of being supported by individual filesystems.

Not so clear/accurate IMO. Maybe:

cross-filesystem copies were implemented by the kernel,
if the operation was not supported by individual filesystems.

> +However, on some virtual filesystems,
> +the call failed to copy, while still reporting success.

Thanks,
Amir.