Re: [RFC][PATCH 0/5] Proposal for Cross-fs copy_file_range()
Daan De Meyer <[email protected]> Thu, 23 Jul 2026 15:05:16 +0200
| Newsgroups | org.kernel.vger.linux-unionfs,org.kernel.vger.linux-fsdevel |
|---|---|
| Message-ID | <CAO8sHcn=b94SL6KTfPtnqau++-g9CXD0LOpPjp4L+b9cu8mMSQ@mail.gmail.com> |
Hi Amir, I tested the series on top of f6cde11eb46e and cherry-picked these selftests: https://github.com/daandemeyer/vfs/commit/0b0e47d408311fe2b4a3e1711656f836b56e10f4 All four tests failed. The accounting test reports two reads and writes, and 128 KiB accounted in each direction, for one 64 KiB copy. The outer and recursive backing-file VFS calls both account the operation. The credential test fails with EPERM. The explicit source check uses the source mount credentials, but the recursive VFS call checks the real source again while the destination mount credentials are active. The permission-order test times out because the real source FAN_ACCESS_PERM event happens after the destination inode has been locked. The process handling the event cannot update the destination while the copy is waiting for its response. Finally, denying that permission event still clears the destination's setuid and setgid bits. ovl_copyfile() removes them before checking permission on the real source. It looks like the root cause is that OverlayFS-to-OverlayFS is classified as FS_COPY_SAME_FS before the FOP_CROSS_FS_COPY checks. That leaves it on the existing recursive VFS path, so these issues remain even with the series applied. My (admittedly much larger) patch set does pass all of these selftests by moving most of the authorization checks out of overlayfs and into vfs and can be found here: https://github.com/linux-fsdevel/vfs/compare/vfs.base...daandemeyer:vfs:push-zolnnszvmkry for those interested in taking a look. Happy to post it directly to the list as an RFC if that's preferred over a github link. That patch set also lays a foundation for cross sb copy_file_range() but I opted to not post those patches yet so we can figure out how we want to deal with the above issues first. Cheers, Daan On Thu, 23 Jul 2026 at 13:48, Amir Goldstein <[email protected]> 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). > > 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 >