Re: [RFC][PATCH 0/5] Proposal for Cross-fs copy_file_range()
Amir Goldstein <[email protected]> Sat, 1 Aug 2026 20:54:17 +0200
| Newsgroups | org.kernel.vger.linux-unionfs,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <CAOQ4uxgcU1EzsOfWZRMzubso1bd-QfQ54w_TfBBCniQVSAHoiQ@mail.gmail.com> |
On Fri, Jul 24, 2026 at 1:29=E2=80=AFAM Gao Xiang <[email protected]> wrote: > > 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 Between EROFS and overlayfs? I think the proposed API is general enough to support this - first the dest fs (overlayfs) copy method is called, which calls vfs_copy_file_range() from erofs to (e.g.) the upper xfs and then the erofs cross copy method is called to copy from backing file to upper fs= . > 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. This optimized copy up does not require copy from EROFS to overlayfs, only copy from from file backed EROFS to upper basefs: - erofs should support for copy file range to another fs (similar to patch = 5) - ovl_copy_up_file() should use vfs_copy_file_range() instead of vfs_clone_file_range() - or some variation of this > > 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. I think it should be pretty straightforward to implement this in erofs however, calling vfs_copy_file_range() with the backing file would populate its page cache, so maybe you would want to limit this to when the destination file and backing file are on the same fs which supports clone, perhap via a flag COPY_FILE_REMAP to vfs_copy_file_range(). Thanks, Amir.