From patchwork Wed Mar 19 21:01:43 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 3861271 Return-Path: X-Original-To: patchwork-ocfs2-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6AFA99F373 for ; Wed, 19 Mar 2014 21:02:27 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 55AD1201FA for ; Wed, 19 Mar 2014 21:02:26 +0000 (UTC) Received: from aserp1040.oracle.com (aserp1040.oracle.com [141.146.126.69]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C83A0201F4 for ; Wed, 19 Mar 2014 21:02:24 +0000 (UTC) Received: from acsinet21.oracle.com (acsinet21.oracle.com [141.146.126.237]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s2JL2608024817 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 19 Mar 2014 21:02:07 GMT Received: from oss.oracle.com (oss-external.oracle.com [137.254.96.51]) by acsinet21.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s2JL22bn021397 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 19 Mar 2014 21:02:03 GMT Received: from localhost ([127.0.0.1] helo=oss.oracle.com) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1WQNcg-0002ig-Px; Wed, 19 Mar 2014 14:02:02 -0700 Received: from acsinet22.oracle.com ([141.146.126.238]) by oss.oracle.com with esmtp (Exim 4.63) (envelope-from ) id 1WQNcQ-0002hi-Jx for ocfs2-devel@oss.oracle.com; Wed, 19 Mar 2014 14:01:46 -0700 Received: from userp1020.oracle.com (userp1020.oracle.com [156.151.31.79]) by acsinet22.oracle.com (8.14.4+Sun/8.14.4) with ESMTP id s2JL1jQ0020823 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 19 Mar 2014 21:01:46 GMT Received: from mail.linuxfoundation.org (mail.linuxfoundation.org [140.211.169.12]) by userp1020.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id s2JL1jY0012106 for ; Wed, 19 Mar 2014 21:01:45 GMT Received: from akpm3.mtv.corp.google.com (unknown [216.239.45.95]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 9F40FB35; Wed, 19 Mar 2014 21:01:44 +0000 (UTC) Date: Wed, 19 Mar 2014 14:01:43 -0700 From: Andrew Morton To: tariq saeed Message-Id: <20140319140143.b3a0fa14b49284fb79c1bd61@linux-foundation.org> In-Reply-To: <52E2E7C1.7070801@oracle.com> References: <20140124204702.9871031C2C7@corp2gmr1-1.hot.corp.google.com> <20140124215554.GC24361@wotan.suse.de> <52E2E7C1.7070801@oracle.com> X-Mailer: Sylpheed 3.2.0beta5 (GTK+ 2.24.10; x86_64-pc-linux-gnu) Mime-Version: 1.0 X-Flow-Control-Info: class=Pass-to-MM reputation=ipRisk-All ip=140.211.169.12 ct-class=T1 ct-vol1=0 ct-vol2=4 ct-vol3=4 ct-risk=10 ct-spam1=0 ct-spam2=0 ct-bulk=89 rcpts=1 size=5480 X-Sendmail-CM-Score: 0.00% X-Sendmail-CM-Analysis: v=2.1 cv=KOFjUj1o c=1 sm=1 tr=0 a=5MPDoNpceV4HFXFrvkM3CQ==:117 a=5MPDoNpceV4HFXFrvkM3CQ==:17 a=dn5YJCShVNUA:10 a=NEiEQogP1MkA:10 a=kj9zAlcOel0A:10 a=Z4Rwk6OoAAAA:8 a=1XWaLZrsAAAA:8 a=ag1SF4gXAAAA:8 a=yPCof4ZbAAAA:8 a=iox4zFpeAAAA:8 a=IXr _WNlcAAAA:8 a=rhMXawaxbtzkLcmsE30A:9 a=CjuIK1q_8ugA:10 a=7DSvI1NPTFQA:10 a=jbrJJM5MRmoA:10 a=n9GBPR9yFnkA:10 a=T5ZRoNnfl4MA:10 X-Sendmail-CT-RefID: str=0001.0A090202.532A05B9.017D:SCFSTAT19734153, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0 X-Sendmail-CT-Classification: not spam Cc: Mark Fasheh , ocfs2-devel@oss.oracle.com Subject: Re: [Ocfs2-devel] [patch 03/11] ocfs2/o2net: incorrect to terminate accepting connections loop upon rejecting an invalid one X-BeenThere: ocfs2-devel@oss.oracle.com X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: ocfs2-devel-bounces@oss.oracle.com Errors-To: ocfs2-devel-bounces@oss.oracle.com X-Source-IP: acsinet21.oracle.com [141.146.126.237] X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Fri, 24 Jan 2014 14:22:57 -0800 tariq saeed wrote: > On 1/24/2014 1:55 PM, Mark Fasheh wrote: > > On Fri, Jan 24, 2014 at 12:47:02PM -0800, akpm@linux-foundation.org wrote: > >> From: Tariq Saeed > >> Subject: ocfs2/o2net: incorrect to terminate accepting connections loop upon rejecting an invalid one > >> > >> When o2net-accept-one() rejects an illegal connection, it terminates the > >> loop picking up the remaining queued connections. This fix will continue > >> accepting connections till the queue is emtpy. > >> > >> Addresses Orabug 17489469. > > Thanks for sending this, review comments below. > > > > > >> diff -puN fs/ocfs2/cluster/tcp.c~ocfs2-o2net-incorrect-to-terminate-accepting-connections-loop-upon-rejecting-an-invalid-one fs/ocfs2/cluster/tcp.c > >> --- a/fs/ocfs2/cluster/tcp.c~ocfs2-o2net-incorrect-to-terminate-accepting-connections-loop-upon-rejecting-an-invalid-one > >> +++ a/fs/ocfs2/cluster/tcp.c > >> @@ -1826,7 +1826,7 @@ int o2net_register_hb_callbacks(void) > >> > >> /* ------------------------------------------------------------ */ > >> > >> -static int o2net_accept_one(struct socket *sock) > >> +static int o2net_accept_one(struct socket *sock, int *more) > >> { > >> int ret, slen; > >> struct sockaddr_in sin; > >> @@ -1837,6 +1837,7 @@ static int o2net_accept_one(struct socke > >> struct o2net_node *nn; > >> > >> BUG_ON(sock == NULL); > >> + *more = 0; > >> ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type, > >> sock->sk->sk_protocol, &new_sock); > >> if (ret) > >> @@ -1848,6 +1849,7 @@ static int o2net_accept_one(struct socke > >> if (ret < 0) > >> goto out; > >> > >> + *more = 1; > >> new_sock->sk->sk_allocation = GFP_ATOMIC; > >> > >> ret = o2net_set_nodelay(new_sock); > >> @@ -1949,8 +1951,15 @@ out: > >> static void o2net_accept_many(struct work_struct *work) > >> { > >> struct socket *sock = o2net_listen_sock; > >> - while (o2net_accept_one(sock) == 0) > >> + int more; > >> + int err; > >> + > >> + for (;;) { > >> + err = o2net_accept_one(sock, &more); > >> + if (!more) > >> + break; > > We're throwing out 'err' here and trusting the variable 'more'. However, err > > could be set and more would be 0 regardless of whether there actually are > > more connections to be had. This makes more sense given when 'more' is set: > > Thanks for the comments. > To understand the consequences of ignoring the err, we need to look at > what is going on. > We get a softIRQ when a connection packet (tcp SYN). It is critical to > note that we may not > get a softIRQ_for every connection s_ince connection packets can arrive > back-to-back (as happened in this bug). So, one softIRQ could be > delivered for > 1 pending accept. > _This is the KEY point. _ > > If we terminate the loop calling o2net_accept_one() upon seeing an > error, what happens > to the rest of the connections in the queue. If no new connection > arrives for hours, no new softIRQ > will be delivered, and the connections will just sit in the queue. Please note that I had to edit your email to undo the top-posting so I could reply to it. Please don't top-post. Mark, are you now OK with the patch as-is? From: Tariq Saeed Subject: ocfs2/o2net: incorrect to terminate accepting connections loop upon rejecting an invalid one When o2net-accept-one() rejects an illegal connection, it terminates the loop picking up the remaining queued connections. This fix will continue accepting connections till the queue is emtpy. Addresses Orabug 17489469. Signed-off-by: Tariq Saseed Cc: Mark Fasheh Cc: Joel Becker Signed-off-by: Andrew Morton --- fs/ocfs2/cluster/tcp.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff -puN fs/ocfs2/cluster/tcp.c~ocfs2-o2net-incorrect-to-terminate-accepting-connections-loop-upon-rejecting-an-invalid-one fs/ocfs2/cluster/tcp.c --- a/fs/ocfs2/cluster/tcp.c~ocfs2-o2net-incorrect-to-terminate-accepting-connections-loop-upon-rejecting-an-invalid-one +++ a/fs/ocfs2/cluster/tcp.c @@ -1826,7 +1826,7 @@ int o2net_register_hb_callbacks(void) /* ------------------------------------------------------------ */ -static int o2net_accept_one(struct socket *sock) +static int o2net_accept_one(struct socket *sock, int *more) { int ret, slen; struct sockaddr_in sin; @@ -1837,6 +1837,7 @@ static int o2net_accept_one(struct socke struct o2net_node *nn; BUG_ON(sock == NULL); + *more = 0; ret = sock_create_lite(sock->sk->sk_family, sock->sk->sk_type, sock->sk->sk_protocol, &new_sock); if (ret) @@ -1848,6 +1849,7 @@ static int o2net_accept_one(struct socke if (ret < 0) goto out; + *more = 1; new_sock->sk->sk_allocation = GFP_ATOMIC; ret = o2net_set_nodelay(new_sock); @@ -1949,8 +1951,15 @@ out: static void o2net_accept_many(struct work_struct *work) { struct socket *sock = o2net_listen_sock; - while (o2net_accept_one(sock) == 0) + int more; + int err; + + for (;;) { + err = o2net_accept_one(sock, &more); + if (!more) + break; cond_resched(); + } } static void o2net_listen_data_ready(struct sock *sk, int bytes)