From patchwork Wed Nov 8 14:59:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Watt X-Patchwork-Id: 10048637 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 D557360381 for ; Wed, 8 Nov 2017 15:00:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCDED2A62F for ; Wed, 8 Nov 2017 15:00:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C19752A641; Wed, 8 Nov 2017 15:00:23 +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 5DA8A2A635 for ; Wed, 8 Nov 2017 15:00:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752624AbdKHPAW (ORCPT ); Wed, 8 Nov 2017 10:00:22 -0500 Received: from mail-io0-f194.google.com ([209.85.223.194]:45378 "EHLO mail-io0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752603AbdKHPAU (ORCPT ); Wed, 8 Nov 2017 10:00:20 -0500 Received: by mail-io0-f194.google.com with SMTP id i38so6225851iod.2 for ; Wed, 08 Nov 2017 07:00:20 -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=qglzs3evol/Wg2pVfTPRTsdGcv1z2b1PYtLvWwE2Mn4=; b=MlD2hYmJj0WzMMDiF+u6NYkMAVNmKsk7djE84j/VU0SUl1C0PEvt8SqWYA1Bny4hSG xitZabECXKqN3UDgsU2aeckR/tty2r1RaeAuu0UZ3T1f10Cb+PIe68MB88YZTn2mzuPi JGM5zC5hUAPepBOo18RPbDCkt9cvOd79jCobgffPsZ8JPyAXHhqtp2qC495wK6GJwGzy HKuNSBvhqx0FE/GeT+v2ttGuzG9xbjtsdAs+8hDY0GgaXi6Ya2gxzHSK8JREmaLUz5st voA3mk9ddFsN0rTxtEci9cq8+1A0udLvWCaVjYvklyb1l83RHXg/C5rLsuzG0mEUEEr2 4ksg== 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=qglzs3evol/Wg2pVfTPRTsdGcv1z2b1PYtLvWwE2Mn4=; b=WwNYGZz9bR8B6EiIwfN9GgR8qtLbpGfp/lMVn/btWyFsauP+5WGZytkD/n1d9+5vdI p9TeVv27xTk9cG3F7COV2ryxKaIrn6xp3BCv9bJXkMAWmwF5gGN5vzFkEtkbCIZSDKHN KgwPd/4nLkWp+U7gZWc7hQYgMLwPjiS8D6OKxVSMn2Z8JAtX8NlvmY+b1IuEaZahPeGC xQ2rz2VrwRG8borc4YsRzkn2/AX7X3DG6ABswjfmuaJxOam3pSsZ+ViEftrWkWhxNiVU vVA4DzJkmm6rg/1VJOYEByWHM/LJSvdRgs+FIoOnZ24GtJYUa/lQwj0beo7A5wyJfL6Q FITA== X-Gm-Message-State: AJaThX6teyB7UGAoFTMJKYWcv4wgjJm1H2xUxH5HMnFQXkK0YO21AGrF OmOQg56S9gximBCi2Jbd8x0= X-Google-Smtp-Source: AGs4zMYxgS8fyr/i9C372SfQqagzEjtYBAKb8c3J/e7mIAlFP/PZSz79Up44EEVjwqUdDJBHxNMYtQ== X-Received: by 10.107.18.170 with SMTP id 42mr1018958ios.55.1510153220261; Wed, 08 Nov 2017 07:00:20 -0800 (PST) Received: from ola-842mrw1.ad.garmin.com ([204.77.163.55]) by smtp.googlemail.com with ESMTPSA id q191sm9170077itb.1.2017.11.08.07.00.19 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 08 Nov 2017 07:00:19 -0800 (PST) From: Joshua Watt X-Google-Original-From: Joshua Watt To: NeilBrown , Jeff Layton , Trond Myklebust Cc: linux-nfs@vger.kernel.org, Al Viro , "J . Bruce Fields" , David Howells , Joshua Watt Subject: [RFC 2/4] SUNRPC: Kill client tasks from debugfs Date: Wed, 8 Nov 2017 08:59:40 -0600 Message-Id: <20171108145942.5127-3-JPEWhacker@gmail.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171108145942.5127-1-JPEWhacker@gmail.com> References: <20171108145942.5127-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 "kill" client entry in debugfs can be used to kill client tasks. Writing "0" causes only the currently pending tasks to be killed, while writing "1" all currently pending, and any future pending tasks to be killed. Signed-off-by: Joshua Watt --- net/sunrpc/debugfs.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/net/sunrpc/debugfs.c b/net/sunrpc/debugfs.c index e980d2a493de..a2f33d168873 100644 --- a/net/sunrpc/debugfs.c +++ b/net/sunrpc/debugfs.c @@ -118,6 +118,50 @@ static const struct file_operations tasks_fops = { .release = tasks_release, }; +static int +kill_set(void *data, u64 val) +{ + struct rpc_clnt *clnt = data; + + rpc_killall_tasks(clnt, (int)val); + return 0; +} + +static int +kill_open(struct inode *inode, struct file *filp) +{ + int ret = simple_attr_open(inode, filp, NULL, kill_set, "%i"); + + if (!ret) { + struct rpc_clnt *clnt = inode->i_private; + + if (!atomic_inc_not_zero(&clnt->cl_count)) { + simple_attr_release(inode, filp); + ret = -EINVAL; + } + } + + return ret; +} + +static int +kill_release(struct inode *inode, struct file *filp) +{ + struct rpc_clnt *clnt = inode->i_private; + + rpc_release_client(clnt); + + return simple_attr_release(inode, filp); +} + +static const struct file_operations kill_fops = { + .owner = THIS_MODULE, + .open = kill_open, + .release = kill_release, + .write = debugfs_attr_write, + .llseek = no_llseek, +}; + void rpc_clnt_debugfs_register(struct rpc_clnt *clnt) { @@ -160,6 +204,10 @@ rpc_clnt_debugfs_register(struct rpc_clnt *clnt) if (!debugfs_create_symlink("xprt", clnt->cl_debugfs, name)) goto out_err; + if (!debugfs_create_file("kill", S_IFREG | 0200, clnt->cl_debugfs, + clnt, &kill_fops)) + goto out_err; + return; out_err: debugfs_remove_recursive(clnt->cl_debugfs);