From patchwork Fri Nov 17 17:45:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joshua Watt X-Patchwork-Id: 10063067 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 03BFC6023A for ; Fri, 17 Nov 2017 17:46:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E705F2AD16 for ; Fri, 17 Nov 2017 17:46:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DBE212AD3A; Fri, 17 Nov 2017 17:46:21 +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 769572AD16 for ; Fri, 17 Nov 2017 17:46:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1161136AbdKQRqU (ORCPT ); Fri, 17 Nov 2017 12:46:20 -0500 Received: from mail-it0-f68.google.com ([209.85.214.68]:36916 "EHLO mail-it0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030313AbdKQRqN (ORCPT ); Fri, 17 Nov 2017 12:46:13 -0500 Received: by mail-it0-f68.google.com with SMTP id m191so4973268itg.2 for ; Fri, 17 Nov 2017 09:46:13 -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=pUSnXzVX2r5UCvzBIvIS6lGcw79SO0d21w+SsmOQ6Eo=; b=KO6J+spIQLdfsdRu4dwjC9eB+fD0fAJs6Tiy9c63hbSnoSZ5RiYlfpMPXw9ibK2osO TQjIGU7mClVTdTSJnoQwsr975WdBC/+yqf5cwiHYR1/L9w4FRwuU7q5mnst7QWhzRJ4a G/FqQuIjyU60oIAUPO2My1kOcUhnnyN9v1D1vf6JF9XBZo2J5f19HbVMLGq1qjMtDlEb qxItegrto08Ckm6tlSrOC1g1zduZlaAhf9KyjvT9fg6fwWEQm+ePjTz+IU40uRHyZ6WS cmVU/XxlT+38GyYk2UUQn8wbiw5LhqZj8HkeMDhb0e+KzWV3Z2VFZ1r34HAjUwS+FkOh mf5Q== 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=pUSnXzVX2r5UCvzBIvIS6lGcw79SO0d21w+SsmOQ6Eo=; b=FiDptkAXfF71CD4U2minjAuMXiRAuZRaarPzI4Y7a+Gy1urpgdpXtkiRawU0JspCp0 Z6cSpixn9efWszKyszrELoixp7G6Va3y7v4pzy7EWAyfzD8EC8flhamsIG8c4sLi3mpo u4+iIFh/QG0HdwqQM0pzHCcSBW/os89zPskDPzbXFmgzly2QB5ZO+PRWTemccminkpPz 8/BjVkmEzm1y/SRdQYTfHfL5bAevt4mwqidGjvb4wHpQothmSIdg/PIEDe0sNPjnUJgV G+eV8+JCcnK+ia69YLQXIYtGsiJuXfgUjRNFb1RYyTcp74B7Gr2qsSIkzOCyYJw29Uc/ 0+OQ== X-Gm-Message-State: AJaThX5L4/3SHSVlKGapt4S3zc6HKJi9JpvFmo9vazsnWsqrMEEkB/1g Tju/Zx5ozQFgU7wA4Q7PNdw= X-Google-Smtp-Source: AGs4zMb1Td7WYx9R1rQ8CsALqBhXRYrTs+O+FyOdfRsnjebbB08evnvhAKM3rZsrEdcQmH9+ydTp9g== X-Received: by 10.36.111.194 with SMTP id x185mr7434703itb.54.1510940772694; Fri, 17 Nov 2017 09:46:12 -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.46.11 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 17 Nov 2017 09:46:12 -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 5/9] NFS: Kill RPCs for the duration of umount Date: Fri, 17 Nov 2017 11:45:48 -0600 Message-Id: <20171117174552.18722-6-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 RPCs are now killed for the duration of the umount operation when MNT_FORCE is specified. Specifically, if the umount flags are MNT_FORCE | MNT_DETACH, all future RPCs will be killed. Signed-off-by: Joshua Watt --- fs/nfs/internal.h | 1 + fs/nfs/nfs4super.c | 1 + fs/nfs/super.c | 36 +++++++++++++++++++++++++++++------- 3 files changed, 31 insertions(+), 7 deletions(-) diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h index f9a4a5524bd5..3ec165368a08 100644 --- a/fs/nfs/internal.h +++ b/fs/nfs/internal.h @@ -461,6 +461,7 @@ extern void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio); /* super.c */ void nfs_umount_begin(struct super_block *); +void nfs_umount_end(struct super_block *sb); int nfs_statfs(struct dentry *, struct kstatfs *); int nfs_show_options(struct seq_file *, struct dentry *); int nfs_show_devname(struct seq_file *, struct dentry *); diff --git a/fs/nfs/nfs4super.c b/fs/nfs/nfs4super.c index 6fb7cb6b3f4b..e9788f9c3394 100644 --- a/fs/nfs/nfs4super.c +++ b/fs/nfs/nfs4super.c @@ -56,6 +56,7 @@ static const struct super_operations nfs4_sops = { .statfs = nfs_statfs, .evict_inode = nfs4_evict_inode, .umount_begin = nfs_umount_begin, + .umount_end = nfs_umount_end, .show_options = nfs_show_options, .show_devname = nfs_show_devname, .show_path = nfs_show_path, diff --git a/fs/nfs/super.c b/fs/nfs/super.c index 216f67d628b3..71361ca6d6b4 100644 --- a/fs/nfs/super.c +++ b/fs/nfs/super.c @@ -315,6 +315,7 @@ const struct super_operations nfs_sops = { .statfs = nfs_statfs, .evict_inode = nfs_evict_inode, .umount_begin = nfs_umount_begin, + .umount_end = nfs_umount_end, .show_options = nfs_show_options, .show_devname = nfs_show_devname, .show_path = nfs_show_path, @@ -890,6 +891,15 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root) } EXPORT_SYMBOL_GPL(nfs_show_stats); +static void +kill_rpc(struct rpc_clnt *rpc) +{ + if (!IS_ERR(rpc)) { + atomic_inc(&rpc->cl_kill_new_tasks); + rpc_killall_tasks(rpc); + } +} + /* * Begin unmount by attempting to remove all automounted mountpoints we added * in response to xdev traversals and referrals @@ -897,19 +907,31 @@ EXPORT_SYMBOL_GPL(nfs_show_stats); void nfs_umount_begin(struct super_block *sb) { struct nfs_server *server; - struct rpc_clnt *rpc; server = NFS_SB(sb); /* -EIO all pending I/O */ - rpc = server->client_acl; - if (!IS_ERR(rpc)) - rpc_killall_tasks(rpc); - rpc = server->client; - if (!IS_ERR(rpc)) - rpc_killall_tasks(rpc); + kill_rpc(server->client_acl); + kill_rpc(server->client); } EXPORT_SYMBOL_GPL(nfs_umount_begin); +static void +restore_rpc(struct rpc_clnt *rpc) +{ + if (!IS_ERR(rpc)) + __atomic_add_unless(&rpc->cl_kill_new_tasks, -1, 0); +} + +void +nfs_umount_end(struct super_block *sb) +{ + struct nfs_server *server = NFS_SB(sb); + + restore_rpc(server->client_acl); + restore_rpc(server->client); +} +EXPORT_SYMBOL_GPL(nfs_umount_end); + static struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(void) { struct nfs_parsed_mount_data *data;