recvfile by linux splice

Jeremy Allison jra at
Tue Sep 23 22:43:50 GMT 2008

On Tue, Sep 23, 2008 at 07:42:36PM +0800, Lin Mac wrote:
> hi,
> I've been trying to make the Linux splice work in samba. I'm using Linux and samba-3.2.2
> With splice tool at, and doing the test by running:
> # ./splice-fromnet  2001 | ./splice-out -m /dev/null
> # cat /dev/zero | netcat localhost 2001
> I think splice(socket to pipe)+splice(pipe to file) should work in Linux
> Using the original code of samba, splice would always failed due to splice directly from a socket to a file in samba. Linux require one of the input/output descriptor to be a pipe (FIFO) (, so I made a little modification with the following patch to make it work.
> 1. change splice(socket to file) to splice (socket to pipe)+splice (pipe to file)
> 2. the while (total_written < count) cause part of the data won't be written to file, so I changed it to while (count!=0). And I have no idea what while (total_written < count) and the latter drain_socket are used for...
> Now splice worked for small file ( <500kB), but larger files might failed (>800kB).
> Now I'm stuck again...

It looks like you're moving Samba's triggering of the kernel bug around :-(.


More information about the samba-technical mailing list