Subject: [PATCH] [CIFS] Do not use btrfs refcopy ioctl for SMB2 copy offload

Steve French smfrench at gmail.com
Tue Nov 26 12:41:36 MST 2013


Resending since subject line was dropped (empty) first time

---------- Forwarded message ----------
From: Steve French <smfrench at gmail.com>
Date: Mon, Nov 25, 2013 at 9:59 AM
Subject: [PATCH] [CIFS] Do not use btrfs refcopy ioctl for SMB2 copy offload
To: samba-technical <samba-technical at lists.samba.org>,
"linux-cifs at vger.kernel.org" <linux-cifs at vger.kernel.org>,
linux-fsdevel <linux-fsdevel at vger.kernel.org>
Cc: David Disseldorp <ddiss at suse.de>, Christoph Hellwig <hch at infradead.org>


>From f19e84df37bda502a2248d507a9cf2b9e693279e Mon Sep 17 00:00:00 2001
From: Steve French <smfrench at gmail.com>
Date: Sun, 24 Nov 2013 21:53:17 -0600
Subject: [PATCH] [CIFS] Do not use btrfs refcopy ioctl for SMB2 copy offload

Change cifs.ko to using CIFS_IOCTL_COPYCHUNK instead
of BTRFS_IOC_CLONE to avoid confusion about whether
copy-on-write is required or optional for this operation.

SMB2/SMB3 copyoffload had used the BTRFS_IOC_CLONE ioctl since
they both speed up copy by offloading the copy rather than
passing many read and write requests back and forth and both have
identical syntax (passing file handles), but for SMB2/SMB3
CopyChunk the server is not required to use copy-on-write
to make a copy of the file (although some do), and Christoph
has commented that since CopyChunk does not require
copy-on-write we should not reuse BTRFS_IOC_CLONE.

This patch renames the ioctl to use a cifs specific IOCTL
CIFS_IOCTL_COPYCHUNK.  This ioctl is particularly important
for SMB2/SMB3 since large file copy over the network otherwise
can be very slow, and with this is often more than 100 times
faster putting less load on server and client.

Note that if a copy syscall is ever introduced, depending on
its requirements/format it could end up using one of the other
three methods that CIFS/SMB2/SMB3 protocol allows for copy offload,
but this method is particularly useful for file copy
and broadly supported (not just by Samba server).

Signed-off-by: Steve French <smfrench at gmail.com>
Reviewed-by: Jeff Layton <jlayton at redhat.com>
Reviewed-by: David Disseldorp <ddiss at samba.org>
---
 fs/cifs/ioctl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/fs/cifs/ioctl.c b/fs/cifs/ioctl.c
index 409b45e..7749230 100644
--- a/fs/cifs/ioctl.c
+++ b/fs/cifs/ioctl.c
@@ -26,13 +26,15 @@
 #include <linux/mount.h>
 #include <linux/mm.h>
 #include <linux/pagemap.h>
-#include <linux/btrfs.h>
 #include "cifspdu.h"
 #include "cifsglob.h"
 #include "cifsproto.h"
 #include "cifs_debug.h"
 #include "cifsfs.h"

+#define CIFS_IOCTL_MAGIC    0xCF
+#define CIFS_IOC_COPYCHUNK_FILE    _IOW(CIFS_IOCTL_MAGIC, 3, int)
+
 static long cifs_ioctl_clone(unsigned int xid, struct file *dst_file,
             unsigned long srcfd, u64 off, u64 len, u64 destoff)
 {
@@ -213,7 +215,7 @@ long cifs_ioctl(struct file *filep, unsigned int
command, unsigned long arg)
                 cifs_dbg(FYI, "set compress flag rc %d\n", rc);
             }
             break;
-        case BTRFS_IOC_CLONE:
+        case CIFS_IOC_COPYCHUNK_FILE:
             rc = cifs_ioctl_clone(xid, filep, arg, 0, 0, 0);
             break;
         default:
-- 
1.8.3.1


-- 
Thanks,

Steve



-- 
Thanks,

Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-CIFS-Do-not-use-btrfs-refcopy-ioctl-for-SMB2-copy-of.patch
Type: text/x-patch
Size: 2564 bytes
Desc: not available
URL: <http://lists.samba.org/pipermail/samba-technical/attachments/20131126/2a2c8536/attachment.bin>


More information about the samba-technical mailing list