@@ -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);
@@ -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)
/*
@@ -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;
}
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(-)