From patchwork Mon Nov 21 03:24:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: NeilBrown X-Patchwork-Id: 9438685 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id BE82260469 for ; Mon, 21 Nov 2016 03:24:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FE1928753 for ; Mon, 21 Nov 2016 03:24:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9404B2878F; Mon, 21 Nov 2016 03:24:27 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, T_TVD_MIME_EPI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9EF0A28753 for ; Mon, 21 Nov 2016 03:24:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752654AbcKUDYZ (ORCPT ); Sun, 20 Nov 2016 22:24:25 -0500 Received: from mx2.suse.de ([195.135.220.15]:60078 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752307AbcKUDYZ (ORCPT ); Sun, 20 Nov 2016 22:24:25 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay1.suse.de (charybdis-ext.suse.de [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id 87F72AAD0; Mon, 21 Nov 2016 03:24:23 +0000 (UTC) From: NeilBrown To: Trond Myklebust Date: Mon, 21 Nov 2016 14:24:17 +1100 Cc: List Linux NFS Mailing Subject: Re: [PATCH] Revert "SUNRPC: xs_sock_mark_closed() does not need to trigger socket autoclose" In-Reply-To: References: <87a8gtpgw4.fsf@notabene.neil.brown.name> <87d1lhml90.fsf@notabene.neil.brown.name> User-Agent: Notmuch/0.22.1 (http://notmuchmail.org) Emacs/24.5.1 (x86_64-suse-linux-gnu) Message-ID: <87lgwdecri.fsf@notabene.neil.brown.name> MIME-Version: 1.0 Sender: linux-nfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-nfs@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP On Sat, Nov 19 2016, Trond Myklebust wrote: >> On Aug 9, 2016, at 22:05, NeilBrown wrote: .... >> >> Another approach which works is: >> diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c >> index 7f79fb7dc6a0..f80b135b4830 100644 >> --- a/net/sunrpc/clnt.c >> +++ b/net/sunrpc/clnt.c >> @@ -1936,8 +1936,10 @@ call_connect_status(struct rpc_task *task) >> case -EADDRINUSE: >> case -ENOBUFS: >> case -EPIPE: >> - if (RPC_IS_SOFTCONN(task)) >> + if (RPC_IS_SOFTCONN(task)) { >> + xprt_force_disconnect(task->tk_rqstp->rq_xprt); >> break; >> + } >> /* retry with existing socket, after a delay */ >> rpc_delay(task, 3*HZ); >> case -EAGAIN: >> >> so that we force a disconnect precisely when a connection attempt fails >> on a SOFTCONN task. >> >> Which of these solutions do you prefer? > > > Instead of the above, could we rather look at adding a call to xprt_conditional_disconnect() to ensure that we don’t keep disconnecting multiple times? It means we’d have to set req->rq_connect_cookie in xprt_connect() before sleeping on xprt->pending, but I don’t think that is a major imposition. > > I also think we might not want to make that call conditional on RPC_IS_SOFTCONN. Something like this maybe? Just using xprt_conditional_disconnect() doesn't work as it does nothing when !xprt_connected(xprt). I commented out that test and then the change works. I don't know if that is what you want though. Thanks, NeilBrown diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index b31ca97e754e..53acd4e3a317 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -1926,6 +1926,8 @@ call_connect_status(struct rpc_task *task) case -EADDRINUSE: case -ENOBUFS: case -EPIPE: + xprt_conditional_disconnect(task->tk_rqstp->rq_xprt, + task->tk_rqstp->rq_connect_cookie); if (RPC_IS_SOFTCONN(task)) break; /* retry with existing socket, after a delay */ diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c index 685e6d225414..52007d018135 100644 --- a/net/sunrpc/xprt.c +++ b/net/sunrpc/xprt.c @@ -669,7 +669,7 @@ void xprt_conditional_disconnect(struct rpc_xprt *xprt, unsigned int cookie) spin_lock_bh(&xprt->transport_lock); if (cookie != xprt->connect_cookie) goto out; - if (test_bit(XPRT_CLOSING, &xprt->state) || !xprt_connected(xprt)) + if (test_bit(XPRT_CLOSING, &xprt->state) /*|| !xprt_connected(xprt)*/) goto out; set_bit(XPRT_CLOSE_WAIT, &xprt->state); /* Try to schedule an autoclose RPC call */ @@ -772,6 +772,7 @@ void xprt_connect(struct rpc_task *task) if (!xprt_connected(xprt)) { task->tk_rqstp->rq_bytes_sent = 0; task->tk_timeout = task->tk_rqstp->rq_timeout; + task->tk_rqstp->rq_connect_cookie = xprt->connect_cookie; rpc_sleep_on(&xprt->pending, task, xprt_connect_status); if (test_bit(XPRT_CLOSING, &xprt->state))