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.
I will take a look during weekend
The problem seems here if (src_inode == target_inode) { rc = -EINVAL; goto out; }
Not sure if we can remove this check ?
Checked in as: commit 9ab70ca653307771589e1414102c552d8dbdbbef Author: Kovtunenko Oleksandr <alexander198961@gmail.com> Date: Tue May 14 05:52:34 2019 +0000 Fixed https://bugzilla.kernel.org/show_bug.cgi?id=202935 allow write on the same file Copychunk allows source and target to be on the same file. For details on restrictions see MS-SMB2 3.3.5.15.6