Bug 202935 - CIFS: copy_file_range return "Invalid argument" when copy in the same file
Summary: CIFS: copy_file_range return "Invalid argument" when copy in the same file
Status: NEW
Alias: None
Product: File System
Classification: Unclassified
Component: CIFS (show other bugs)
Hardware: All Linux
: P1 normal
Assignee: fs_cifs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-03-15 06:51 UTC by Xiaoli Feng
Modified: 2019-04-17 05:15 UTC (History)
1 user (show)

See Also:
Kernel Version: 5.0.0+
Tree: Mainline
Regression: No


Attachments
reproducer c program (1.20 KB, text/plain)
2019-03-15 06:51 UTC, Xiaoli Feng
Details

Description Xiaoli Feng 2019-03-15 06:51:36 UTC
Created attachment 281843 [details]
reproducer c program

Do the copy_file range operation on the same file. It return "Invalid argument".
[root@kvm-01-guest23 ~]# mount //localhost/cifs cifs -o vers=3.0,user=root,password=redhat
[root@kvm-01-guest23 ~]# dd if=/dev/zero of=cifs/file bs=1M count=1
1+0 records in
1+0 records out
1048576 bytes (1.0 MB, 1.0 MiB) copied, 0.00542753 s, 193 MB/s
[root@kvm-01-guest23 ~]# ls -l cifs/file
-rwxr-xr-x. 1 root root 1048576 Mar 15 02:35 cifs/file
[root@kvm-01-guest23 ~]# gcc -o copy_offload_file copy_offload_file.c 
[root@kvm-01-guest23 ~]# ./copy_offload_file cifs/file
len=1048576,fd_in=3
copy_file_range: Invalid argument

It's successful for xfs,ext4,nfs filesystem.
Comment 1 Oleksandr 2019-04-12 12:14:47 UTC
I will take a look during weekend
Comment 2 Oleksandr 2019-04-17 03:27:22 UTC
The problem seems here 
        if (src_inode == target_inode) {
                rc = -EINVAL;
                goto out;
        }
Comment 3 Oleksandr 2019-04-17 05:15:26 UTC
Not sure if we can remove this check ?

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