Bug 216800 - copy_file_range() returns EXDEV for cross_fs copy between ext4 and xfs, ext4 and tmpfs, and ext2/ext3 and tmpfs
Summary: copy_file_range() returns EXDEV for cross_fs copy between ext4 and xfs, ext4 ...
Status: RESOLVED ANSWERED
Alias: None
Product: File System
Classification: Unclassified
Component: VFS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_vfs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2022-12-12 05:25 UTC by Nitin
Modified: 2022-12-13 12:16 UTC (History)
2 users (show)

See Also:
Kernel Version: 6.1.0-060100rc5-generic
Subsystem:
Regression: Yes
Bisected commit-id:


Attachments

Description Nitin 2022-12-12 05:25:49 UTC
copy_file_range() returns EXDEV while attempting cross_fs copy between ext2/ext3 and tmpfs. 

$ uname -r
6.1.0-060100rc5-generic
$ stat -f -c %T .
ext2/ext3
$ stat -f -c %T /tmpfs1
tmpfs
$ ./copy new.log /tmpfs1/new.log
copy_file_range: Invalid cross-device link
$

I think the issue is also observable between cross_fs use of copy_file_range() between ext4 -> xfs, ext4 -> tmpfs and xfs -> tmpfs. 

I observed this cross_fs issue somewhere around kernel 5.15.X and apparently it  still persists in 6.1.0-060100rc5-generic.
Comment 1 Amir Goldstein 2022-12-12 13:27:27 UTC
This is intentional.
EXDEV is kernel < 5.3 behavior.
This behavior was partially (*) restored due to regression reports.
See: https://git.kernel.org/pub/scm/docs/man-pages/man-pages.git/commit/?id=d7ba612d0ab10af2ed4e367306784212cc3f3595

(*) partially, because copy_file_range() between two different ext4 is still allowed.
(**) above man page commit wrongly states 5.12 as the kernel that changed behavior back. it was later. man page needs to be fixed
Comment 2 Nitin 2022-12-13 06:30:22 UTC
Thanks. Does later mean 5.15? It seems so. 

Please see below:
$ uname -r
5.15.0-56-generic
$ stat -f -c %T .
ext2/ext3
$ stat -f -c %T /tmpfsdir
tmpfs
$ ./copy a.out /tmpfsdir/a.out
copy_file_range: Invalid cross-device link
$
Comment 3 Amir Goldstein 2022-12-13 07:08:23 UTC
On Tue, Dec 13, 2022 at 8:30 AM <bugzilla-daemon@kernel.org> wrote:
>
> https://bugzilla.kernel.org/show_bug.cgi?id=216800
>
> --- Comment #2 from Nitin (bhutaninitin@rocketmail.com) ---
> Thanks. Does later mean 5.15? It seems so.

The change was merged in v5.19 and backported to v5.15.53.

868f9f2f8e00 vfs: fix copy_file_range() regression in cross-fs copies

>
> Please see below:
> $ uname -r
> 5.15.0-56-generic
> $ stat -f -c %T .
> ext2/ext3
> $ stat -f -c %T /tmpfsdir
> tmpfs
> $ ./copy a.out /tmpfsdir/a.out
> copy_file_range: Invalid cross-device link
> $
>
> --
> You may reply to this email to add a comment.
>
> You are receiving this mail because:
> You are on the CC list for the bug.
Comment 4 Nitin 2022-12-13 07:42:49 UTC
Thanks a bunch.
Comment 5 Amir Goldstein 2022-12-13 12:16:12 UTC
For the record, man page patch:
https://lore.kernel.org/linux-fsdevel/20221213120834.948163-1-amir73il@gmail.com/

Note You need to log in before you can comment on or make changes to this bug.