Zero Copy writes for Samba

Jeremy Allison jra at
Wed Feb 26 14:37:05 MST 2014

On Wed, Feb 26, 2014 at 09:22:30PM +0000, Kuhn, Steven wrote:
> Hello All,
> I have some questions regarding zero copy writes using splice for recvfile for Samba writes.
> I am using kernel version OpenWrt 3.4.0 and Samba version 3.6.5.
> Has anyone been able to make this work?
> Is there a patch that exists to allow splice to be used for recvfile for Samba Writes?
> I would like to use zero copy writes for Samba to improve performance.
> But it does not seem to work, as I never see any calls to splice happen.
> While looking into this, I see that in function sys_recvfile() in file ./lib/recvfile.c,
> there exists logic to try to use splice but fall back for older kernels.  For reference,
> the following comment:
>     /*
>      * Older Linux kernels have splice for sendfile,
>      * but it fails for recvfile. Ensure we only try
>      * this once and always fall back to the userspace
>      * implementation if recvfile splice fails. JRA.
>      */
> This logic is implemented by means of a static bool try_splice_call flag,
> that is meant to be set false upon error while using the splice.
> But, first issue I see is this flag try_splice_call  is initially set false and so no attempt is ever made to use splice for writes from recvfile.
> Second issue I see is if I try to set this flag try_splice_call true initially, the TCP socket is filled and never emptied (the receiver sets it's TCP Window size to 0) before any of the error conditions that exist in the code that set the flag false according to the above mentioned error logic.
> Any help or pointers to more info is greatly appreciated.

Once we discovered that the splice() call on a standard
Linux kernel made Samba substantially *slower*, then
this code was deliberately not used.

If you have a modified kernel that fixes the performance
problem with splice, then we can investigate making this
code work for you.

Do you have such a modified kernel ? If not, then using
splice will simply make your performance worse.


More information about the samba-technical mailing list