Server-side copy with sendfile system call

David Disseldorp ddiss at suse.de
Mon May 12 03:04:01 MDT 2014


On Mon, 12 May 2014 16:18:11 +0800, Teng-Feng Yang wrote:

> I recently noticed that samba now supports server-side copy feature.
> For BTRFS, the btrfs VFS module will override the copy_chunk_send/recv
> to utilize the copy_range ioctl to improve the copy performance
> further. For other filesystem such as ext4, it will fallback to
> default copy_chunk behavior which pread the file data and pwrite them
> to the copy destination.
> 
> This makes me wonder if we can replace the read-then-write procedure
> with sendfile system call which claims to outperform the file copy in
> userspace.

Yes...

1347 static struct tevent_req *vfswrap_copy_chunk_send(struct vfs_handle_struct *handle,
...
1387         /* could use 2.6.33+ sendfile here to do this in kernel */

We most certainly could, with appropriate sendfile support checks in
place of course. One thing to watch-out for would be sendfile when
out_fd == in_fd. The protocol allows for overlapping ranges in
copy-chunk requests.

Cheers, David


More information about the samba-technical mailing list