linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joshua Watt <jpewhacker@gmail.com>
To: NeilBrown <neilb@suse.com>, Jeff Layton <jlayton@redhat.com>,
	Trond Myklebust <trond.myklebust@primarydata.com>,
	"J . Bruce Fields" <bfields@fieldses.org>
Cc: linux-nfs@vger.kernel.org, Al Viro <viro@zeniv.linux.org.uk>,
	David Howells <dhowells@redhat.com>,
	Joshua Watt <JPEWhacker@gmail.com>
Subject: [RFC v4 5/9] NFS: Kill RPCs for the duration of umount
Date: Fri, 17 Nov 2017 11:45:48 -0600	[thread overview]
Message-ID: <20171117174552.18722-6-JPEWhacker@gmail.com> (raw)
In-Reply-To: <20171117174552.18722-1-JPEWhacker@gmail.com>

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 <JPEWhacker@gmail.com>
---
 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;
-- 
2.13.6


  parent reply	other threads:[~2017-11-17 17:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-17 17:45 [RFC v4 0/9] NFS Force Unmounting Joshua Watt
2017-11-17 17:45 ` [RFC v4 1/9] SUNRPC: Add flag to kill new tasks Joshua Watt
2017-12-05 22:59   ` NeilBrown
2017-11-17 17:45 ` [RFC v4 2/9] SUNRPC: Expose kill_new_tasks in debugfs Joshua Watt
2017-11-17 17:45 ` [RFC v4 3/9] SUNRPC: Simplify client shutdown Joshua Watt
2017-11-17 17:45 ` [RFC v4 4/9] namespace: Add umount_end superblock operation Joshua Watt
2017-12-06 11:54   ` Jeff Layton
2017-12-06 12:14   ` Al Viro
2017-12-06 12:33     ` Al Viro
2017-12-06 15:41       ` Joshua Watt
2017-11-17 17:45 ` Joshua Watt [this message]
2017-12-05 23:07   ` [RFC v4 5/9] NFS: Kill RPCs for the duration of umount NeilBrown
2017-11-17 17:45 ` [RFC v4 6/9] NFS: Add debugfs for nfs_server and nfs_client Joshua Watt
2017-11-17 17:45 ` [RFC v4 7/9] NFS: Add transient mount option Joshua Watt
2017-12-06 12:23   ` Jeff Layton
2017-11-17 17:45 ` [RFC v4 8/9] NFS: Don't shared transient clients Joshua Watt
2017-11-17 17:45 ` [RFC v4 9/9] NFS: Kill all client RPCs if transient Joshua Watt
2017-12-04 14:36 ` [RFC v4 0/9] NFS Force Unmounting Joshua Watt
2017-12-05 23:34   ` NeilBrown
2017-12-06 13:03     ` Jeff Layton
2017-12-06 16:40       ` Joshua Watt
2017-12-08  2:10       ` NeilBrown
2017-12-14 18:22         ` Joshua Watt
2017-12-14 21:52           ` NeilBrown
2017-12-18 21:48             ` Joshua Watt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20171117174552.18722-6-JPEWhacker@gmail.com \
    --to=jpewhacker@gmail.com \
    --cc=bfields@fieldses.org \
    --cc=dhowells@redhat.com \
    --cc=jlayton@redhat.com \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.com \
    --cc=trond.myklebust@primarydata.com \
    --cc=viro@zeniv.linux.org.uk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).