Netdev List
 help / color / mirror / Atom feed
From: Eric Dumazet <eric.dumazet@gmail.com>
To: Changli Gao <xiaosuo@gmail.com>
Cc: Jens Axboe <axboe@kernel.dk>, Ofer Heifetz <oferh@marvell.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>
Subject: Re: Splice status
Date: Tue, 06 Jul 2010 05:56:20 +0200	[thread overview]
Message-ID: <1278388580.2466.305.camel@edumazet-laptop> (raw)
In-Reply-To: <AANLkTim_eBmT-6HmkqG5d7k0jjrGKAFBjzqVCricTpgK@mail.gmail.com>

Le mardi 06 juillet 2010 à 10:01 +0800, Changli Gao a écrit :
> On Mon, Jul 5, 2010 at 8:50 PM, Eric Dumazet <eric.dumazet@gmail.com> wrote:
> > Le lundi 05 juillet 2010 à 13:52 +0300, Ofer Heifetz a écrit :
> >> I am using Samba, so from my understanding of the source code, it
> > loops and performs splice(sock, pipe) and splice(pipe, fd). There is no
> > flush of any sort in between.
> >>
> >> When you say drain you mean to flush all data to pipe?
> >>
> >
> > Draining pipe before splice() call would only trigger the bug less
> > often.
> 
> If we don't drain the pipe before calling splice(2), the data spliced
> from pipe maybe not be what we expect. Then data corruption occurs.
> 

This is not true. A pipe is a pipe is a buffer. You dont need it to be
empty when using it. Nowhere in documentation its stated.

However, a single skb can fill a pipe, even if "its empty"



> >
> > splice(sock, pipe) can block if caller dont use appropriate "non
> > blocking pipe' splice() mode, even if pipe is empty before a splice()
> > call.
> 
> I don't think it is expected. The code of sys_recvfile is much like
> the sendfile(2) implementation in kernel. If sys_recvfile may block
> without non_block flag, sendfile(2) may block too.

Then it would be a bug. You might fix it easily.

Using splice() correctly (ie, not blocking on sock->pipe) should work
too.

Again, you can block on splice(sock, pipe), iff you have a second thread
doing the opposite (pipe->file) in parallel to unblock you. But samba
recvfile algo is using a single thread.

> 
> BTW: Samba can use sendfile(2) instead in sys_recvfile.
> 



  parent reply	other threads:[~2010-07-06  3:56 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-05  9:26 Splice status Ofer Heifetz
2010-07-05  9:59 ` Changli Gao
2010-07-05 10:52   ` Ofer Heifetz
2010-07-05 12:08     ` Changli Gao
2010-07-05 12:50     ` Eric Dumazet
2010-07-05 13:47       ` Ofer Heifetz
2010-07-05 15:34         ` Eric Dumazet
2010-07-06  2:01       ` Changli Gao
2010-07-06  2:36         ` Ofer Heifetz
2010-07-06  3:56         ` Eric Dumazet [this message]
2010-07-11 13:08           ` Changli Gao
2010-07-13 11:41             ` Ofer Heifetz
2010-07-13 12:32               ` Changli Gao
2010-07-13 12:42                 ` Ofer Heifetz
2010-07-13 13:58                   ` Changli Gao
2010-07-13 14:40                     ` Ofer Heifetz
2010-07-13 14:11               ` Eric Dumazet
2010-07-14 15:08                 ` Ofer Heifetz
2010-07-15  3:47                 ` Ofer Heifetz
2010-07-25 14:47                 ` Ofer Heifetz
2010-07-26  7:41                   ` Changli Gao
2010-07-26 20:37                   ` Jarek Poplawski
2010-07-26 20:50                     ` Eric Dumazet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1278388580.2466.305.camel@edumazet-laptop \
    --to=eric.dumazet@gmail.com \
    --cc=axboe@kernel.dk \
    --cc=netdev@vger.kernel.org \
    --cc=oferh@marvell.com \
    --cc=xiaosuo@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox