From patchwork Mon Jan 7 04:21:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eric Dumazet X-Patchwork-Id: 209850 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 9CC9E2C007C for ; Mon, 7 Jan 2013 15:22:14 +1100 (EST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753524Ab3AGEVz (ORCPT ); Sun, 6 Jan 2013 23:21:55 -0500 Received: from mail-pb0-f50.google.com ([209.85.160.50]:39122 "EHLO mail-pb0-f50.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753477Ab3AGEVy (ORCPT ); Sun, 6 Jan 2013 23:21:54 -0500 Received: by mail-pb0-f50.google.com with SMTP id wz7so10346687pbc.23 for ; Sun, 06 Jan 2013 20:21:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:subject:from:to:cc:in-reply-to:references:content-type :date:message-id:mime-version:x-mailer:content-transfer-encoding; bh=V7q8w4NRJPERSmwO5G5XP4i6/zP4zmwK//I/JbicJvU=; b=ZD6IcqQCZcxHHFfx8kYzMn3dKY3ZiPS+hPM3FuIjFCCr+MFB9tuNreLcix68iWFyav j9uHRfkIL38DilhVOuG1XlQskMD+9rI7rSRVdcfiTF+Kep1Be350Ic20pIbSrnBG3YzY hYC03umZoLKCAtkZHA/FZFdUjzeWL5WHnkT93rjo0gBR/Ox0QdOr+q7sRGRuLEB2djQ9 vEbI7OtFkSTWHyfZhEoKsK0cmtZbKC3YNhy7J687lbHxsfkia6i7vR+InAA700PswtqZ BMi7TlTq6CZsCJZNSwA+4skobnquTF3/vrHsGLaCpnUCSTw1BEuwp9BKb+VQhVQD+P2T wOpQ== X-Received: by 10.66.82.198 with SMTP id k6mr174494552pay.53.1357532512093; Sun, 06 Jan 2013 20:21:52 -0800 (PST) Received: from [172.19.251.188] ([172.19.251.188]) by mx.google.com with ESMTPS id ue7sm36859001pbc.53.2013.01.06.20.21.50 (version=SSLv3 cipher=OTHER); Sun, 06 Jan 2013 20:21:50 -0800 (PST) Subject: [PATCH] tcp: fix MSG_SENDPAGE_NOTLAST logic From: Eric Dumazet To: Willy Tarreau , David Miller Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20130106195359.GN16031@1wt.eu> References: <1357490393.6919.267.camel@edumazet-glaptop> <20130106164416.GF16031@1wt.eu> <1357492255.6919.336.camel@edumazet-glaptop> <20130106173543.GB22432@1wt.eu> <1357497541.6919.519.camel@edumazet-glaptop> <1357497809.6919.529.camel@edumazet-glaptop> <1357498276.6919.547.camel@edumazet-glaptop> <1357498815.6919.570.camel@edumazet-glaptop> <20130106193410.GL16031@1wt.eu> <1357501171.6919.650.camel@edumazet-glaptop> <20130106195359.GN16031@1wt.eu> Date: Sun, 06 Jan 2013 20:21:49 -0800 Message-ID: <1357532509.6919.1715.camel@edumazet-glaptop> Mime-Version: 1.0 X-Mailer: Evolution 2.28.3 Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Eric Dumazet commit 35f9c09fe9c72e (tcp: tcp_sendpages() should call tcp_push() once) added an internal flag : MSG_SENDPAGE_NOTLAST meant to be set on all frags but the last one for a splice() call. The condition used to set the flag in pipe_to_sendpage() relied on splice() user passing the exact number of bytes present in the pipe, or a smaller one. But some programs pass an arbitrary high value, and the test fails. The effect of this bug is a lack of tcp_push() at the end of a splice(pipe -> socket) call, and possibly very slow or erratic TCP sessions. We should both test sd->total_len and fact that another fragment is in the pipe (pipe->nrbufs > 1) Many thanks to Willy for providing very clear bug report, bisection and test programs. Reported-by: Willy Tarreau Bisected-by: Willy Tarreau Tested-by: Willy Tarreau Signed-off-by: Eric Dumazet --- fs/splice.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) -- To unsubscribe from this list: send the line "unsubscribe netdev" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/fs/splice.c b/fs/splice.c index 8890604..6909d89 100644 --- a/fs/splice.c +++ b/fs/splice.c @@ -696,8 +696,10 @@ static int pipe_to_sendpage(struct pipe_inode_info *pipe, return -EINVAL; more = (sd->flags & SPLICE_F_MORE) ? MSG_MORE : 0; - if (sd->len < sd->total_len) + + if (sd->len < sd->total_len && pipe->nrbufs > 1) more |= MSG_SENDPAGE_NOTLAST; + return file->f_op->sendpage(file, buf->page, buf->offset, sd->len, &pos, more); }