Linux NFS development
 help / color / mirror / Atom feed
From: Jeff Layton <jlayton@kernel.org>
To: Trond Myklebust <trondmy@kernel.org>,
	Anna Schumaker <anna@kernel.org>,
	 Chuck Lever <chuck.lever@oracle.com>, Neil Brown <neilb@suse.de>,
	 Olga Kornievskaia <okorniev@redhat.com>,
	Dai Ngo <Dai.Ngo@oracle.com>,  Tom Talpey <tom@talpey.com>,
	"David S. Miller" <davem@davemloft.net>,
	 Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>,
	 Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>
Cc: Josef Bacik <josef@toxicpanda.com>,
	 Benjamin Coddington <bcodding@redhat.com>,
	linux-nfs@vger.kernel.org,  linux-kernel@vger.kernel.org,
	netdev@vger.kernel.org,  Jeff Layton <jlayton@kernel.org>
Subject: [PATCH RFC 4/9] nfs: transplant nfs_server shutdown into a helper function
Date: Mon, 17 Mar 2025 16:59:56 -0400	[thread overview]
Message-ID: <20250317-rpc-shutdown-v1-4-85ba8e20b75d@kernel.org> (raw)
In-Reply-To: <20250317-rpc-shutdown-v1-0-85ba8e20b75d@kernel.org>

Move the guts of shutdown_store() into a new helper for shutting down a
nfs_server.

Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
 fs/nfs/internal.h |  1 +
 fs/nfs/super.c    | 18 ++++++++++++++++++
 fs/nfs/sysfs.c    | 16 ++--------------
 3 files changed, 21 insertions(+), 14 deletions(-)

diff --git a/fs/nfs/internal.h b/fs/nfs/internal.h
index fae2c7ae4acc286e1c5ad2b2225b1e9a6930b56b..968c8c845f49f5b7ca6f78e391ba2a3024ce64ff 100644
--- a/fs/nfs/internal.h
+++ b/fs/nfs/internal.h
@@ -507,6 +507,7 @@ bool nfs_auth_info_match(const struct nfs_auth_info *, rpc_authflavor_t);
 int nfs_try_get_tree(struct fs_context *);
 int nfs_get_tree_common(struct fs_context *);
 void nfs_kill_super(struct super_block *);
+void nfs_server_shutdown(struct nfs_server *server);
 
 extern int __init register_nfs_fs(void);
 extern void __exit unregister_nfs_fs(void);
diff --git a/fs/nfs/super.c b/fs/nfs/super.c
index aeb715b4a6902dc907b4b4cf2712232b080c497f..b78251dde6b717738847ebf4b75f6de10e7ea644 100644
--- a/fs/nfs/super.c
+++ b/fs/nfs/super.c
@@ -56,6 +56,7 @@
 #include <linux/parser.h>
 #include <linux/nsproxy.h>
 #include <linux/rcupdate.h>
+#include <linux/lockd/lockd.h>
 
 #include <linux/uaccess.h>
 #include <linux/nfs_ssc.h>
@@ -1386,6 +1387,23 @@ void nfs_kill_super(struct super_block *s)
 }
 EXPORT_SYMBOL_GPL(nfs_kill_super);
 
+void nfs_server_shutdown(struct nfs_server *server)
+{
+	/* already shut down? */
+	if (server->flags & NFS_MOUNT_SHUTDOWN)
+		return;
+
+	server->flags |= NFS_MOUNT_SHUTDOWN;
+	rpc_clnt_shutdown(server->client);
+	rpc_clnt_shutdown(server->nfs_client->cl_rpcclient);
+
+	if (!IS_ERR(server->client_acl))
+		rpc_clnt_shutdown(server->client_acl);
+
+	if (server->nlm_host)
+		nlm_host_shutdown_rpc(server->nlm_host);
+}
+
 #if IS_ENABLED(CONFIG_NFS_V4)
 
 /*
diff --git a/fs/nfs/sysfs.c b/fs/nfs/sysfs.c
index c0bfe6df53b51c0fcc541c33ab7590813114d7ec..1b2e2ed10a1bf8d4ad06dc676ec5831d6eba99b4 100644
--- a/fs/nfs/sysfs.c
+++ b/fs/nfs/sysfs.c
@@ -14,6 +14,7 @@
 #include <linux/rcupdate.h>
 #include <linux/lockd/lockd.h>
 
+#include "internal.h"
 #include "nfs4_fs.h"
 #include "netns.h"
 #include "sysfs.h"
@@ -242,20 +243,7 @@ shutdown_store(struct kobject *kobj, struct kobj_attribute *attr,
 	if (val != 1)
 		return -EINVAL;
 
-	/* already shut down? */
-	if (server->flags & NFS_MOUNT_SHUTDOWN)
-		goto out;
-
-	server->flags |= NFS_MOUNT_SHUTDOWN;
-	rpc_clnt_shutdown(server->client);
-	rpc_clnt_shutdown(server->nfs_client->cl_rpcclient);
-
-	if (!IS_ERR(server->client_acl))
-		rpc_clnt_shutdown(server->client_acl);
-
-	if (server->nlm_host)
-		nlm_host_shutdown_rpc(server->nlm_host);
-out:
+	nfs_server_shutdown(server);
 	return count;
 }
 

-- 
2.48.1


  parent reply	other threads:[~2025-03-17 21:00 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-17 20:59 [PATCH RFC 0/9] nfs/sunrpc: stop holding netns references in client-side NFS and RPC objects Jeff Layton
2025-03-17 20:59 ` [PATCH RFC 1/9] sunrpc: transplant shutdown_client() to sunrpc module Jeff Layton
2025-03-17 20:59 ` [PATCH RFC 2/9] lockd: add a helper to shut down rpc_clnt in nlm_host Jeff Layton
2025-03-17 20:59 ` [PATCH RFC 3/9] lockd: don't #include debug.h from lockd.h Jeff Layton
2025-03-17 20:59 ` Jeff Layton [this message]
2025-03-17 20:59 ` [PATCH RFC 5/9] nfs: don't hold a reference to struct net in struct nfs_client Jeff Layton
2025-03-17 20:59 ` [PATCH RFC 6/9] auth_gss: shut down gssproxy rpc_clnt in net pre_exit Jeff Layton
2025-03-17 20:59 ` [PATCH RFC 7/9] auth_gss: don't hold a net reference in gss_auth Jeff Layton
2025-03-17 21:00 ` [PATCH RFC 8/9] sunrpc: don't hold a struct net reference in rpc_xprt Jeff Layton
2025-03-17 21:00 ` [PATCH RFC 9/9] sunrpc: don't upgrade passive net reference in xs_create_sock Jeff Layton
2025-03-17 21:28   ` Trond Myklebust
2025-03-17 21:36     ` Jeff Layton
2025-03-17 21:37       ` Trond Myklebust
2025-03-17 21:41         ` Jeff Layton
2025-03-17 21:35 ` [PATCH RFC 0/9] nfs/sunrpc: stop holding netns references in client-side NFS and RPC objects Trond Myklebust
2025-03-17 21:57   ` Jeff Layton
2025-03-17 22:11     ` Trond Myklebust
2025-03-18 11:30       ` Jeff Layton

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=20250317-rpc-shutdown-v1-4-85ba8e20b75d@kernel.org \
    --to=jlayton@kernel.org \
    --cc=Dai.Ngo@oracle.com \
    --cc=anna@kernel.org \
    --cc=bcodding@redhat.com \
    --cc=chuck.lever@oracle.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=josef@toxicpanda.com \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-nfs@vger.kernel.org \
    --cc=neilb@suse.de \
    --cc=netdev@vger.kernel.org \
    --cc=okorniev@redhat.com \
    --cc=pabeni@redhat.com \
    --cc=tom@talpey.com \
    --cc=trondmy@kernel.org \
    /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