From patchwork Fri Nov 17 17:45:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Watt X-Patchwork-Id: 10063061 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 105466023A for ; Fri, 17 Nov 2017 17:46:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F3B6B2AD16 for ; Fri, 17 Nov 2017 17:46:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E89E32AD3A; Fri, 17 Nov 2017 17:46:17 +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.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID 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 915CD2AD16 for ; Fri, 17 Nov 2017 17:46:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161120AbdKQRqQ (ORCPT ); Fri, 17 Nov 2017 12:46:16 -0500 Received: from mail-it0-f67.google.com ([209.85.214.67]:41022 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161130AbdKQRqK (ORCPT ); Fri, 17 Nov 2017 12:46:10 -0500 Received: by mail-it0-f67.google.com with SMTP id x28so4984426ita.0 for ; Fri, 17 Nov 2017 09:46:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=cypRLUtUziGz6THwEGNCKQsc4TsCUiJLoJPKQbdKy8g=; b=dquXxrFGq8KpKISFAdqPOyq24rFRsoNgysb3ShPMjyTxEzbpiZZ+ZZouk254NFYJwz Uxeo9Z8VnXNJpcNu37AdpCEdGPl8QkKa51jZl+dS+GR9KVvH06ZFEHePSC4AFpUkLHy+ t951eUj2q/O2mi2QdHd/8131vLHFMzMXt30iPLzu+6FAkSqVYTleoBZQo+LhrXJj24nK iMgo2/VBQKt/207/aWoE4zvoDNaa+SqKJRronoKbCPqtJmak+kHpO01yT3g4O1S6btuK n8w6zTFzws9gyhOZkMtAQt8QzDkr223bAE4npuBLcvWJ4Fa7i4d9pWcyWk/e+wKNFYK8 DzGw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=cypRLUtUziGz6THwEGNCKQsc4TsCUiJLoJPKQbdKy8g=; b=njV5NZDZVWintAwX3WrOUzKiloagp7PMdL87494vnzKqodjHlNyOKuoWxAfDoq5RjC 3zWicap8qKZn4/kWgzeLvBDKAO1WUx2CG/0hntPYHKFHIGt1z13U2q8vwzowGJIXcved lXjYijoepesF+q/VfhRDYo/GLu9Ixz/xe6M7xVwhU7fFnW65nYNsnpPRxy5GedFOrtZH cfHnKGkmr5azf+ugmeDEP++ZUl1eFAeKJDrMYpI7NcV2Kk4QqZF52FEmZaWEaBRRW/2q jXyjmjaGOBkc0lST6tvfiuNIUw0Mzrzd+ro6lI+THH6uQrFnNl3PFroSqCMoJaAQsL3C LqhQ== X-Gm-Message-State: AJaThX4L7wpPPfdgR38nfI4kUvjmmVQYBZ6Lkd3xDoLIeNRSx8qnX0L8 Ejq+o8NXcw3CY3WqQCAbrIw= X-Google-Smtp-Source: AGs4zMb1x25bvxNqPdd2DBub7aPZbPyKJgrz1QIDmhYC2+GBRzgdC7G7gt2eDSMceK7et7nIsJpRxQ== X-Received: by 10.36.80.14 with SMTP id m14mr7778335itb.148.1510940769084; Fri, 17 Nov 2017 09:46:09 -0800 (PST) Received: from ola-842mrw1.ad.garmin.com ([204.77.163.55]) by smtp.googlemail.com with ESMTPSA id h21sm1878189iod.59.2017.11.17.09.45.59 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 09:46:08 -0800 (PST) From: Joshua Watt X-Google-Original-From: Joshua Watt To: NeilBrown , Jeff Layton , Trond Myklebust , "J . Bruce Fields" Cc: linux-nfs@vger.kernel.org, Al Viro , David Howells , Joshua Watt Subject: [RFC v4 1/9] SUNRPC: Add flag to kill new tasks Date: Fri, 17 Nov 2017 11:45:44 -0600 Message-Id: <20171117174552.18722-2-JPEWhacker@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171117174552.18722-1-JPEWhacker@gmail.com> References: <20171117174552.18722-1-JPEWhacker@gmail.com> 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 The flag causes any new tasks that are queued to exit immediately with -EIO instead of executing. This will allow clients (particularly NFS) to prevents these task from delaying shutdown of the RPC session longer than necessary. Signed-off-by: Joshua Watt --- include/linux/sunrpc/clnt.h | 1 + net/sunrpc/clnt.c | 5 ++--- net/sunrpc/sched.c | 3 +++ 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/include/linux/sunrpc/clnt.h b/include/linux/sunrpc/clnt.h index 71c237e8240e..d36dc529fdf0 100644 --- a/include/linux/sunrpc/clnt.h +++ b/include/linux/sunrpc/clnt.h @@ -54,6 +54,7 @@ struct rpc_clnt { cl_noretranstimeo: 1,/* No retransmit timeouts */ cl_autobind : 1,/* use getport() */ cl_chatty : 1;/* be verbose */ + atomic_t cl_kill_new_tasks; /* Kill all new tasks */ struct rpc_rtt * cl_rtt; /* RTO estimator data */ const struct rpc_timeout *cl_timeout; /* Timeout strategy */ diff --git a/net/sunrpc/clnt.c b/net/sunrpc/clnt.c index df4ecb042ebe..d5eedabf0b4d 100644 --- a/net/sunrpc/clnt.c +++ b/net/sunrpc/clnt.c @@ -626,6 +626,8 @@ static struct rpc_clnt *__rpc_clone_client(struct rpc_create_args *args, new->cl_noretranstimeo = clnt->cl_noretranstimeo; new->cl_discrtry = clnt->cl_discrtry; new->cl_chatty = clnt->cl_chatty; + atomic_set(&new->cl_kill_new_tasks, + atomic_read(&clnt->cl_kill_new_tasks)); return new; out_err: @@ -818,9 +820,6 @@ void rpc_killall_tasks(struct rpc_clnt *clnt) { struct rpc_task *rovr; - - if (list_empty(&clnt->cl_tasks)) - return; dprintk("RPC: killing all tasks for client %p\n", clnt); /* * Spin lock all_tasks to prevent changes... diff --git a/net/sunrpc/sched.c b/net/sunrpc/sched.c index 0cc83839c13c..e70034e19ccd 100644 --- a/net/sunrpc/sched.c +++ b/net/sunrpc/sched.c @@ -748,6 +748,9 @@ static void __rpc_execute(struct rpc_task *task) dprintk("RPC: %5u __rpc_execute flags=0x%x\n", task->tk_pid, task->tk_flags); + if (atomic_read(&task->tk_client->cl_kill_new_tasks)) + rpc_exit(task, -EIO); + WARN_ON_ONCE(RPC_IS_QUEUED(task)); if (RPC_IS_QUEUED(task)) return;