1 From 8b19905f4cf882dc5fbc403aa3077b01e33c5b4d Mon Sep 17 00:00:00 2001
2 From: Eric Dumazet <edumazet@google.com>
3 Date: Sun, 6 Jan 2013 18:21:49 +0000
4 Subject: tcp: fix MSG_SENDPAGE_NOTLAST logic
7 From: Eric Dumazet <edumazet@google.com>
9 [ Upstream commit ae62ca7b03217be5e74759dc6d7698c95df498b3 ]
11 commit 35f9c09fe9c72e (tcp: tcp_sendpages() should call tcp_push() once)
12 added an internal flag : MSG_SENDPAGE_NOTLAST meant to be set on all
13 frags but the last one for a splice() call.
15 The condition used to set the flag in pipe_to_sendpage() relied on
16 splice() user passing the exact number of bytes present in the pipe,
19 But some programs pass an arbitrary high value, and the test fails.
21 The effect of this bug is a lack of tcp_push() at the end of a
22 splice(pipe -> socket) call, and possibly very slow or erratic TCP
25 We should both test sd->total_len and fact that another fragment
26 is in the pipe (pipe->nrbufs > 1)
28 Many thanks to Willy for providing very clear bug report, bisection
31 Reported-by: Willy Tarreau <w@1wt.eu>
32 Bisected-by: Willy Tarreau <w@1wt.eu>
33 Tested-by: Willy Tarreau <w@1wt.eu>
34 Signed-off-by: Eric Dumazet <edumazet@google.com>
35 Signed-off-by: David S. Miller <davem@davemloft.net>
36 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
39 1 file changed, 3 insertions(+), 1 deletion(-)
43 @@ -696,8 +696,10 @@ static int pipe_to_sendpage(struct pipe_
46 more = (sd->flags & SPLICE_F_MORE) ? MSG_MORE : 0;
47 - if (sd->len < sd->total_len)
49 + if (sd->len < sd->total_len && pipe->nrbufs > 1)
50 more |= MSG_SENDPAGE_NOTLAST;
52 return file->f_op->sendpage(file, buf->page, buf->offset,