[SMB3][PATCH] fix copy_file_range when copying beyond end of source file

Amir Goldstein amir73il at gmail.com
Thu Jun 20 04:54:42 UTC 2019


On Thu, Jun 20, 2019 at 6:28 AM ronnie sahlberg
<ronniesahlberg at gmail.com> wrote:
>
> Guess we need a fix to the man page.

You mean like this? ;-)
https://lore.kernel.org/linux-fsdevel/20190529174318.22424-15-amir73il@gmail.com/


@@ -1546,6 +1547,14 @@ smb2_copychunk_range(const unsigned int xid,
        tcon = tlink_tcon(trgtfile->tlink);

        while (len > 0) {
+               if (src_off >= inode->i_size) {
+                       cifs_dbg(FYI, "nothing to do on copychunk\n");
+                       goto cchunk_out; /* nothing to do */
+               } else if (src_off + len > inode->i_size) {
+                       /* consider adding check to see if src oplocked */
+                       len = inode->i_size - src_off;
+                       cifs_dbg(FYI, "adjust copychunk len %lld less\n", len);
+               }
                pcchunk->SourceOffset = cpu_to_le64(src_off);
                pcchunk->TargetOffset = cpu_to_le64(dest_off);
                pcchunk->Length =

You can do this shortening before entering the while loop,
then you won't need to SMB2_request_res_key() from the server.
and certainly no need to do that in every loop iteration...

Thanks,
Amir.



More information about the samba-technical mailing list