Re: [RFC][PATCH 0/5] Proposal for Cross-fs copy_file_range()

Gao Xiang <[email protected]> Fri, 24 Jul 2026 07:29:14 +0800
Newsgroups org.kernel.vger.linux-unionfs,org.kernel.vger.linux-fsdevel
Message-ID <amKjyp78ngW2Kmku@debian>
Hi Amir,

On Thu, Jul 23, 2026 at 01:48:43PM +0200, Amir Goldstein wrote:
> Hi all,
> 
> Daan De Meyer requested a way to do copy_file_range() from overlayfs
> to/from another fs, where if that fs is the base fs of overlayfs layer
> the copy could be an efficient clone.
> 
> TBH, he also requested support also for cross-fs clone_file_range(),
> but I am not happy about providing that.
> 
> copy_file_range() already supports cross-sb efficient copy (e.g. with
> NFS/SMB server-side copy).

I once had a long-term goal of supporting copy_file_range() between
overlayfs and EROFS for file-backed mounts, as long as the EROFS inodes
are plain (i.e. uncompressed). Such cross-fs copies could be decomposed
into one or more sub-copies from the EROFS backing file to the
overlayfs upper file, so the underlying backing filesystem can perform
the actual data transfer. If the backing filesystem supports reflinks,
those operations could even be implemented as efficient reflinks.

This would greatly optimize overlayfs copy-up for file-backed EROFS
mounts.

I think this should be feasible, although I haven't had time to work
on it yet. If clean interfaces in this area make that easier, I'd be
very happy to make use of them and enable this later.

Thanks,
Gao Xiang

> 
> The current limitation of staying on the same fstype is mainly an
> internal technical limitation (choosing the right f_op), which is
> something that this RFC is trying to address.
> 
> The overlayfs implementation itself is pretty trivial.
> 
> Thanks,
> Amir.
> 
> 
> Amir Goldstein (5):
>   fs: clarify cross-sb copy_file_range() code
>   fs: add support for copy file range from another fs
>   fs: add support for copy file range to another fs
>   ovl: add support for copy file range from another fs
>   ovl: add support for copy file range to another fs
> 
>  fs/overlayfs/file.c      |  35 ++++++++++++
>  fs/overlayfs/ovl_entry.h |   7 ++-
>  fs/read_write.c          | 119 ++++++++++++++++++++++++++++-----------
>  include/linux/fs.h       |   2 +
>  4 files changed, 130 insertions(+), 33 deletions(-)
> 
> -- 
> 2.54.0
>