Server-Side Copy

From SambaWiki
Revision as of 12:11, 17 June 2014 by Ddiss (talk | contribs) (add section describing Offload Data Transfer (ODX))

Introduction

Samba 4.1.0 was the first release to ship with support for server-side copy operations via the SMB2 FSCTL_SRV_COPYCHUNK request. Clients making use of server-side copy support, such as Windows Server 2012, can experience considerable performance improvements for file copy operations, as file data need not traverse the network. This feature is enabled by default on the smbd file server.


Traditional File Copy

Prior to Samba 4.1.0, clients traditionally copied files by reading the source file data over the network and writing it back to the server through to the destination file on disk.

Traditional copy.png

Sequence

  1. Client issues read requests to server
  2. Server reads file data off disk
  3. Server sends data to client
  4. Client sends duplicate file data to server
  5. Server writes duplicate file data to disk


Result

  • File data traverses network and disk
  • Duplicate file data stored on disk


Server-Side Copy Offload

With Samba 4.1.0 and later, clients can offload copy operations to the server using Copy-Chunk requests. In processing such a request, the network round-trip is avoided.

Serverside copy.png

Sequence

  1. Client issues FSCTL_SRV_COPYCHUNK requests to server
  2. Server reads file data off disk
  3. Server writes duplicate file data to disk


Result

  • File data traverses disk only
    • Network round trip avoided
  • Duplicate file data stored on disk

Samba's smbd file server supports SMB2 Copy-Chunk requests by default, no additional configuration is required.

Limitations

  • The client must support, and issue SMB2 FSCTL_SRV_COPYCHUNK server-side copy requests
  • Both source and destination files must reside on the same Samba share


Btrfs Enhanced Server-Side Copy Offload

Along with server-side copy support, a Btrfs specific Samba VFS Module was newly added with 4.1.0. This module improves the performance and efficiency of server-side copy operations on Btrfs backed shares, by using the Btrfs clone-range IOCTL.

Btrfs serverside copy.png

Sequence

  1. Client issues FSCTL_SRV_COPYCHUNK requests to server
  2. Server issues BTRFS_IOC_CLONE_RANGE filesystem ioctl


Result

  • File data does not traverse network or disk
    • Filesystem meta-data update only
  • No duplication of file data
    • Source and destination files share the same on disk data extents

Btrfs enhanced server-side copy can be enabled in smb.conf on a per share basis with:

   [share]
   path = /mnt/btrfs_fs/        # must reside within a Btrfs filesystem
   vfs objects = btrfs

Limitations

  • The client's FSCTL_SRV_COPYCHUNK server-side copy request must be Btrfs filesystem aligned
  • All other limitations associated with regular server-side copies


Client Support

Windows

Windows Server 2012, Windows 8, and later releases support SMB2 FSCTL_SRV_COPYCHUNK server-side copy operations. On these platforms, Windows Explorer initiated file copies attempt server-side copy offload by default.

Linux

The Linux Kernel CIFS client includes support for issuing SMB2 FSCTL_SRV_COPYCHUNK_WRITE server-side copy requests. This feature can currently only be utilised by issuing a special CIFS_IOC_COPYCHUNK_FILE ioctl. Attempts to plumb this into the cp --reflink code path were rejected.


Offload Data Transfer (ODX)

ODX makes use of the FSCTL_OFFLOAD_READ and FSCTL_OFFLOAD_WRITE requests, such that the underlying storage subsystem independently transfers data, represented by tokens, between source and destination. This allows for offloaded data transfer between independent servers, provided that they are connected to an intelligent storage subsystem capable of generating and handling the ODX tokens. See Neal Christiansen's SNIA SDC slides for further details.

Samba does not currently support ODX - SMB2 FSCTL_SRV_COPYCHUNK server-side copies offer similar benefits, without the need for an ODX capable storage array or emulation within Samba.