Skip to contentSkip to conversation

NFS: Create NFS Modules

RFC Superseded [email protected] 3 participants 25 messages Feb 10, 2012 – Feb 13, 2012

Subsystems (3)

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

cover NFS: Create NFS Modules

From: Bryan Schumaker <[email protected]>

This patch series turns NFS v2, v3 and v4 into loadable kernel modules that need to be loaded before using. This should eventually help clean up all of the NFS code by giving us a chance to remove most of the ifdefs that check for CONFIG_NFS_V3 and CONFIG_NFS_V4.

This time around, I tried to move as little code as possible while still getting everything to compile as their own module. I still had to move a large chunk of v4 specific code from super.c, but most other files should be (mostly) untouched. Rather than creating new subdirectories, I instead kept everything in fs/nfs/, significantly cutting down on the number of patches to modularize everything.

These patches are about a week out-of-date with Trond's nfs-for-next tree, so I expect to spend some time addressing comments and updating them so they apply nicely. I have also found some bugs that I'll fix up in the next version as well.

Patch Map
---------
- Patch 1 does basic preparations
- Patches 2 - 4 make NFS v2 an optional kernel module
- Patches 5 - 9 make NFS v3 an optional kernel module
- Patches 10 - 20 make NFS v4 an optional kernel module
- Patch 21 exports functions from nfs4.ko to nfs.ko to fix modpost errors

Known bugs
----------
- Depmod detects a dependency loop when you try to install
- #include errors when NFS v4 isn't enabled
- I don't yet use request_module()

Comments and suggestions are appreciated. Thanks!

- Bryan

#1 lore raw

RFC 2/21 NFS: Make v2 configurable

From: Bryan Schumaker <[email protected]>

With this patch NFS v2 will no longer be automatically compiled in. Instead, users will have to select NFS_V2 during Kconfig if they want to use v2.

---
 fs/nfs/Kconfig  |    9 +++++++++
 fs/nfs/Makefile |    5 +++--
 fs/nfs/client.c |   11 ++++++++++-
 3 files changed, 22 insertions(+), 3 deletions(-)
fs/nfs/Kconfig +9 -0
index dbcd821..5419166 100644
@@ -29,6 +29,15 @@ config NFS_FS
 
 	  If unsure, say N.
 
+config NFS_V2
+	bool "NFS client support for NFS version 2"
+	depends on NFS_FS
+	help
+	  This option enables support for version 2 of the NFS protocol
+	  (RFC 1094) in the kernel's NFS client.
+
+	  If unsure, say Y.
+
 config NFS_V3
 	bool "NFS client support for NFS version 3"
 	depends on NFS_FS
fs/nfs/Makefile +3 -2
index b58613d..7ddd45d 100644
@@ -4,11 +4,12 @@
 
 obj-$(CONFIG_NFS_FS) += nfs.o
 
-nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \
-			   direct.o pagelist.o proc.o read.o symlink.o unlink.o \
+nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
+			   direct.o pagelist.o read.o symlink.o unlink.o \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
+nfs-$(CONFIG_NFS_V2)	+= proc.o nfs2xdr.o
 nfs-$(CONFIG_NFS_V3)	+= nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
fs/nfs/client.c +10 -1
index 872521e..02a33d8 100644
@@ -90,7 +90,9 @@ static bool nfs4_disable_idmapping = true;
  * RPC cruft for NFS
  */
 static const struct rpc_version *nfs_version[5] = {
+#ifdef CONFIG_NFS_V2
 	[2]			= &nfs_version2,
+#endif
 #ifdef CONFIG_NFS_V3
 	[3]			= &nfs_version3,
 #endif
@@ -834,7 +836,7 @@ static int nfs_init_server(struct nfs_server *server,
 		.hostname = data->nfs_server.hostname,
 		.addr = (const struct sockaddr *)&data->nfs_server.address,
 		.addrlen = data->nfs_server.addrlen,
-		.rpc_ops = &nfs_v2_clientops,
+		.rpc_ops = NULL,
 		.proto = data->nfs_server.protocol,
 		.net = data->net,
 	};
@@ -844,10 +846,17 @@ static int nfs_init_server(struct nfs_server *server,
 
 	dprintk("--> nfs_init_server()\n");
 
+
+#ifdef CONFIG_NFS_V2
+	if (data->version == 2)
+		cl_init.rpc_ops = &nfs_v2_clientops;
+#endif
 #ifdef CONFIG_NFS_V3
 	if (data->version == 3)
 		cl_init.rpc_ops = &nfs_v3_clientops;
 #endif
+	if (cl_init.rpc_ops == NULL)
+		return -EPROTONOSUPPORT;
 
 	nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
 			data->timeo, data->retrans);
Signature · 1 line
1.7.9
#2 lore raw

RFC 3/21 NFS: Add version registering framework

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This patch adds in the code to track multiple versions of the NFS protocol. I created default structures for v2, v3 and v4 so that each version can continue to work while I convert them into kernel modules. I also removed the const parameter from the rpc_version array so that I can change it at runtime.

---
 fs/lockd/clnt4xdr.c         |    2 +-
 fs/lockd/clntxdr.c          |    6 +-
 fs/lockd/mon.c              |    4 +-
 fs/nfs/Makefile             |    6 +-
 fs/nfs/client.c             |  108 +++++++++++++++++++++++++++++++++---------
 fs/nfs/inode.c              |    2 +
 fs/nfs/mount_clnt.c         |    6 +-
 fs/nfs/nfs.h                |   35 ++++++++++++++
 fs/nfs/nfs2super.c          |   31 ++++++++++++
 fs/nfs/nfs2xdr.c            |    2 +-
 fs/nfs/nfs3super.c          |   31 ++++++++++++
 fs/nfs/nfs3xdr.c            |    4 +-
 fs/nfs/nfs4super.c          |   31 ++++++++++++
 fs/nfs/nfs4xdr.c            |    2 +-
 fs/nfs/super.c              |   48 ++++++++++++++-----
 fs/nfsd/nfs4callback.c      |    2 +-
 include/linux/lockd/xdr4.h  |    2 +-
 include/linux/nfs_xdr.h     |    8 ++--
 include/linux/sunrpc/clnt.h |    2 +-
 net/sunrpc/rpcb_clnt.c      |    8 ++--
 20 files changed, 277 insertions(+), 63 deletions(-)
 create mode 100644 fs/nfs/nfs.h
 create mode 100644 fs/nfs/nfs2super.c
 create mode 100644 fs/nfs/nfs3super.c
 create mode 100644 fs/nfs/nfs4super.c
fs/lockd/clnt4xdr.c +1 -1
index 3ddcbb1..580dbe2 100644
@@ -598,7 +598,7 @@ static struct rpc_procinfo	nlm4_procedures[] = {
 	PROC(GRANTED_RES,	res,		norep),
 };
 
-const struct rpc_version nlm_version4 = {
+struct rpc_version nlm_version4 = {
 	.number		= 4,
 	.nrprocs	= ARRAY_SIZE(nlm4_procedures),
 	.procs		= nlm4_procedures,
fs/lockd/clntxdr.c +3 -3
index 3d35e3e..78e80c4 100644
@@ -596,19 +596,19 @@ static struct rpc_procinfo	nlm_procedures[] = {
 	PROC(GRANTED_RES,	res,		norep),
 };
 
-static const struct rpc_version	nlm_version1 = {
+static struct rpc_version	nlm_version1 = {
 		.number		= 1,
 		.nrprocs	= ARRAY_SIZE(nlm_procedures),
 		.procs		= nlm_procedures,
 };
 
-static const struct rpc_version	nlm_version3 = {
+static struct rpc_version	nlm_version3 = {
 		.number		= 3,
 		.nrprocs	= ARRAY_SIZE(nlm_procedures),
 		.procs		= nlm_procedures,
 };
 
-static const struct rpc_version	*nlm_versions[] = {
+static struct rpc_version	*nlm_versions[] = {
 	[1] = &nlm_version1,
 	[3] = &nlm_version3,
 #ifdef CONFIG_LOCKD_V4
fs/lockd/mon.c +2 -2
index c196030..ff247f4 100644
@@ -534,13 +534,13 @@ static struct rpc_procinfo	nsm_procedures[] = {
 	},
 };
 
-static const struct rpc_version nsm_version1 = {
+static struct rpc_version nsm_version1 = {
 		.number		= 1,
 		.nrprocs	= ARRAY_SIZE(nsm_procedures),
 		.procs		= nsm_procedures
 };
 
-static const struct rpc_version *nsm_version[] = {
+static struct rpc_version *nsm_version[] = {
 	[1] = &nsm_version1,
 };
 
fs/nfs/Makefile +3 -3
index 7ddd45d..c6e7844 100644
@@ -9,11 +9,11 @@ nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V2)	+= proc.o nfs2xdr.o
-nfs-$(CONFIG_NFS_V3)	+= nfs3proc.o nfs3xdr.o
+nfs-$(CONFIG_NFS_V2)	+= nfs2super.o proc.o nfs2xdr.o
+nfs-$(CONFIG_NFS_V3)	+= nfs3super.o nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
-			   delegation.o idmap.o \
+			   nfs4super.o delegation.o idmap.o \
 			   callback.o callback_xdr.o callback_proc.o \
 			   nfs4namespace.o
 nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
fs/nfs/client.c +85 -23

148 lines not on this page · raw message

fs/nfs/inode.c +2 -0
index d2c760e..e30d6d3 100644
@@ -51,6 +51,7 @@
 #include "fscache.h"
 #include "dns_resolve.h"
 #include "pnfs.h"
+#include "nfs.h"
 #include "netns.h"
 
 #define NFSDBG_FACILITY		NFSDBG_VFS
@@ -1629,6 +1630,7 @@ static int __init init_nfs_fs(void)
 #endif
 	if ((err = register_nfs_fs()) != 0)
 		goto out;
+	nfs_register_versions();
 	return 0;
 out:
 #ifdef CONFIG_PROC_FS
fs/nfs/mount_clnt.c +3 -3
index b37ca34..4d147a3 100644
@@ -488,19 +488,19 @@ static struct rpc_procinfo mnt3_procedures[] = {
 };
 
 
-static const struct rpc_version mnt_version1 = {
+static struct rpc_version mnt_version1 = {
 	.number		= 1,
 	.nrprocs	= ARRAY_SIZE(mnt_procedures),
 	.procs		= mnt_procedures,
 };
 
-static const struct rpc_version mnt_version3 = {
+static struct rpc_version mnt_version3 = {
 	.number		= 3,
 	.nrprocs	= ARRAY_SIZE(mnt3_procedures),
 	.procs		= mnt3_procedures,
 };
 
-static const struct rpc_version *mnt_version[] = {
+static struct rpc_version *mnt_version[] = {
 	NULL,
 	&mnt_version1,
 	NULL,
fs/nfs/nfs.h new file +35 -0
new file mode 100644
index 0000000..05f6849
@@ -0,0 +1,35 @@
+/*
+ * Copyright (c) 2012 Netapp, Inc. All rights reserved.
+ *
+ * Function and structures exported by the NFS module
+ * for use by NFS version-specific modules.
+ */
+#ifndef __LINUX_INTERNAL_NFS_H
+#define __LINUX_INTERNAL_NFS_H
+
+#include <linux/fs.h>
+#include <linux/sunrpc/sched.h>
+#include <linux/nfs_xdr.h>
+
+struct nfs_subversion {
+	unsigned int version;		/* Protocol number */
+	struct rpc_version *rpc_vers;	/* NFS version information */
+	const struct nfs_rpc_ops *rpc_ops;	/* NFS operations */
+	struct list_head list;		/* List of NFS versions */
+
+	void (*reference)(void);	/* For reference counting */
+	void (*unreference)(void);	/* Also for reference counting */
+};
+
+void nfs_register_versions(void);
+int init_nfs_v2(void);
+int init_nfs_v3(void);
+int init_nfs_v4(void);
+
+struct nfs_subversion *get_nfs_version(unsigned int);
+struct nfs_subversion *get_nfs_client_version(struct nfs_client *);
+struct nfs_subversion *get_nfs_server_version(struct nfs_server *);
+void register_nfs_version(struct nfs_subversion *);
+void unregister_nfs_version(struct nfs_subversion *);
+
+#endif /* __LINUX_INTERNAL_NFS_H */
fs/nfs/nfs2super.c new file +31 -0
new file mode 100644
index 0000000..12fa906
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012 Netapp, Inc. All rights reserved.
+ */
+#include <linux/module.h>
+#include <linux/nfs_fs.h>
+#include "nfs.h"
+
+static void nfs2_reference(void)
+{
+	try_module_get(THIS_MODULE);
+}
+
+static void nfs2_unreference(void)
+{
+	module_put(THIS_MODULE);
+}
+
+static struct nfs_subversion nfs_v2 = {
+	.version  = 2,
+	.rpc_vers = &nfs_version2,
+	.rpc_ops  = &nfs_v2_clientops,
+
+	.reference = nfs2_reference,
+	.unreference = nfs2_unreference,
+};
+
+int __init init_nfs_v2(void)
+{
+	register_nfs_version(&nfs_v2);
+	return 0;
+}
fs/nfs/nfs2xdr.c +1 -1
index a01084d..5d9ec8b 100644
@@ -1086,7 +1086,7 @@ struct rpc_procinfo	nfs_procedures[] = {
 	PROC(STATFS,	fhandle,	statfsres,	0),
 };
 
-const struct rpc_version nfs_version2 = {
+struct rpc_version nfs_version2 = {
 	.number			= 2,
 	.nrprocs		= ARRAY_SIZE(nfs_procedures),
 	.procs			= nfs_procedures
fs/nfs/nfs3super.c new file +31 -0
new file mode 100644
index 0000000..a02c815
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012 Netapp, Inc. All rights reserved.
+ */
+#include <linux/module.h>
+#include <linux/nfs_fs.h>
+#include "nfs.h"
+
+static void nfs3_reference(void)
+{
+	try_module_get(THIS_MODULE);
+}
+
+static void nfs3_unreference(void)
+{
+	module_put(THIS_MODULE);
+}
+
+static struct nfs_subversion nfs_v3 = {
+	.version  = 3,
+	.rpc_vers = &nfs_version3,
+	.rpc_ops  = &nfs_v3_clientops,
+
+	.reference = nfs3_reference,
+	.unreference = nfs3_unreference,
+};
+
+int __init init_nfs_v3(void)
+{
+	register_nfs_version(&nfs_v3);
+	return 0;
+}
fs/nfs/nfs3xdr.c +2 -2
index a77cc9a..5f9aabd 100644
@@ -2461,7 +2461,7 @@ struct rpc_procinfo	nfs3_procedures[] = {
 	PROC(COMMIT,		commit,		commit,		5),
 };
 
-const struct rpc_version nfs_version3 = {
+struct rpc_version nfs_version3 = {
 	.number			= 3,
 	.nrprocs		= ARRAY_SIZE(nfs3_procedures),
 	.procs			= nfs3_procedures
@@ -2489,7 +2489,7 @@ static struct rpc_procinfo	nfs3_acl_procedures[] = {
 	},
 };
 
-const struct rpc_version nfsacl_version3 = {
+struct rpc_version nfsacl_version3 = {
 	.number			= 3,
 	.nrprocs		= sizeof(nfs3_acl_procedures)/
 				  sizeof(nfs3_acl_procedures[0]),
fs/nfs/nfs4super.c new file +31 -0
new file mode 100644
index 0000000..9b2a679
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2012 Netapp, Inc. All rights reserved.
+ */
+#include <linux/module.h>
+#include <linux/nfs_fs.h>
+#include "nfs.h"
+
+static void nfs4_reference(void)
+{
+	try_module_get(THIS_MODULE);
+}
+
+static void nfs4_unreference(void)
+{
+	module_put(THIS_MODULE);
+}
+
+static struct nfs_subversion nfs_v4 = {
+	.version  = 4,
+	.rpc_vers = &nfs_version4,
+	.rpc_ops  = &nfs_v4_clientops,
+
+	.reference = nfs4_reference,
+	.unreference = nfs4_unreference,
+};
+
+int __init init_nfs_v4(void)
+{
+	register_nfs_version(&nfs_v4);
+	return 0;
+}
fs/nfs/nfs4xdr.c +1 -1
index ca288d1..c091f73 100644
@@ -7114,7 +7114,7 @@ struct rpc_procinfo	nfs4_procedures[] = {
 #endif /* CONFIG_NFS_V4_1 */
 };
 
-const struct rpc_version nfs_version4 = {
+struct rpc_version nfs_version4 = {
 	.number			= 4,
 	.nrprocs		= ARRAY_SIZE(nfs4_procedures),
 	.procs			= nfs4_procedures
fs/nfs/super.c +35 -13

138 lines not on this page · raw message

fs/nfsd/nfs4callback.c +1 -1
index 0e262f3..74d19d4 100644
@@ -605,7 +605,7 @@ static struct rpc_version nfs_cb_version4 = {
 	.procs			= nfs4_cb_procedures
 };
 
-static const struct rpc_version *nfs_cb_version[] = {
+static struct rpc_version *nfs_cb_version[] = {
 	&nfs_cb_version4,
 };
 
include/linux/lockd/xdr4.h +1 -1
index e58c88b..7353821 100644
@@ -42,6 +42,6 @@ int	nlmclt_encode_lockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
 int	nlmclt_encode_cancargs(struct rpc_rqst *, u32 *, struct nlm_args *);
 int	nlmclt_encode_unlockargs(struct rpc_rqst *, u32 *, struct nlm_args *);
  */
-extern const struct rpc_version nlm_version4;
+extern struct rpc_version nlm_version4;
 
 #endif /* LOCKD_XDR4_H */
include/linux/nfs_xdr.h +4 -4
index 144419a..9eaa8f7 100644
@@ -1274,11 +1274,11 @@ struct nfs_rpc_ops {
 extern const struct nfs_rpc_ops	nfs_v2_clientops;
 extern const struct nfs_rpc_ops	nfs_v3_clientops;
 extern const struct nfs_rpc_ops	nfs_v4_clientops;
-extern const struct rpc_version nfs_version2;
-extern const struct rpc_version nfs_version3;
-extern const struct rpc_version nfs_version4;
+extern struct rpc_version nfs_version2;
+extern struct rpc_version nfs_version3;
+extern struct rpc_version nfs_version4;
 
-extern const struct rpc_version nfsacl_version3;
+extern struct rpc_version nfsacl_version3;
 extern const struct rpc_program nfsacl_program;
 
 #endif
include/linux/sunrpc/clnt.h +1 -1
index a4c62e9..0c0ee9e 100644
@@ -73,7 +73,7 @@ struct rpc_program {
 	const char *		name;		/* protocol name */
 	u32			number;		/* program number */
 	unsigned int		nrvers;		/* number of versions */
-	const struct rpc_version **	version;	/* version array */
+	struct rpc_version **	version;	/* version array */
 	struct rpc_stat *	stats;		/* statistics */
 	const char *		pipe_dir_name;	/* path to rpc_pipefs dir */
 };
net/sunrpc/rpcb_clnt.c +4 -4
index b1f08bd..bd3954f 100644
@@ -1075,25 +1075,25 @@ static const struct rpcb_info rpcb_next_version6[] = {
 	},
 };
 
-static const struct rpc_version rpcb_version2 = {
+static struct rpc_version rpcb_version2 = {
 	.number		= RPCBVERS_2,
 	.nrprocs	= ARRAY_SIZE(rpcb_procedures2),
 	.procs		= rpcb_procedures2
 };
 
-static const struct rpc_version rpcb_version3 = {
+static struct rpc_version rpcb_version3 = {
 	.number		= RPCBVERS_3,
 	.nrprocs	= ARRAY_SIZE(rpcb_procedures3),
 	.procs		= rpcb_procedures3
 };
 
-static const struct rpc_version rpcb_version4 = {
+static struct rpc_version rpcb_version4 = {
 	.number		= RPCBVERS_4,
 	.nrprocs	= ARRAY_SIZE(rpcb_procedures4),
 	.procs		= rpcb_procedures4
 };
 
-static const struct rpc_version *rpcb_version[] = {
+static struct rpc_version *rpcb_version[] = {
 	NULL,
 	NULL,
 	&rpcb_version2,
Signature · 1 line
1.7.9
#3 lore raw

RFC 4/21 NFS: Convert v2 into a module

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

The module will be created in the same subdirectory as nfs.ko. You need to run modprobe nfs2 before you can use it.

---
 fs/nfs/Kconfig     |    2 +-
 fs/nfs/Makefile    |    4 +++-
 fs/nfs/client.c    |    5 ++---
 fs/nfs/dir.c       |    4 ++++
 fs/nfs/file.c      |    3 +++
 fs/nfs/inode.c     |    8 ++++++++
 fs/nfs/nfs.h       |    3 ++-
 fs/nfs/nfs2super.c |   14 +++++++++++++-
 8 files changed, 36 insertions(+), 7 deletions(-)
fs/nfs/Kconfig +1 -1
index 5419166..b28e56f 100644
@@ -30,7 +30,7 @@ config NFS_FS
 	  If unsure, say N.
 
 config NFS_V2
-	bool "NFS client support for NFS version 2"
+	tristate "NFS client support for NFS version 2"
 	depends on NFS_FS
 	help
 	  This option enables support for version 2 of the NFS protocol
fs/nfs/Makefile +3 -1
index c6e7844..bc2ba86 100644
@@ -9,7 +9,6 @@ nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V2)	+= nfs2super.o proc.o nfs2xdr.o
 nfs-$(CONFIG_NFS_V3)	+= nfs3super.o nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
@@ -20,6 +19,9 @@ nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
 nfs-$(CONFIG_SYSCTL) += sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 
+obj-$(CONFIG_NFS_V2) += nfs2.o
+nfs2-y += nfs2super.o proc.o nfs2xdr.o
+
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
 nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o
 
fs/nfs/client.c +2 -3
index 59bf964..4312a51 100644
@@ -197,9 +197,6 @@ EXPORT_SYMBOL_GPL(unregister_nfs_version);
  */
 void __init nfs_register_versions(void)
 {
-#ifdef CONFIG_NFS_V2
-	init_nfs_v2();
-#endif
 #ifdef CONFIG_NFS_V3
 	init_nfs_v3();
 #endif
@@ -893,6 +890,7 @@ error:
 	dprintk("<-- nfs_init_client() = xerror %d\n", error);
 	return error;
 }
+EXPORT_SYMBOL_GPL(nfs_init_client);
 
 /*
  * Create a version 2 or 3 client
@@ -2137,6 +2135,7 @@ int nfs_stat_to_errno(enum nfs_stat status)
 	dprintk("NFS: Unrecognized nfs status value: %u\n", status);
 	return nfs_errtbl[i].errno;
 }
+EXPORT_SYMBOL_GPL(nfs_stat_to_errno);
 
 module_param(nfs4_disable_idmapping, bool, 0644);
 MODULE_PARM_DESC(nfs4_disable_idmapping,
fs/nfs/dir.c +4 -0
index bb132a8..0a2bf0e 100644
@@ -17,6 +17,7 @@
  *  6 Jun 1999	Cache readdir lookups in the page cache. -DaveM
  */
 
+#include <linux/module.h>
 #include <linux/time.h>
 #include <linux/errno.h>
 #include <linux/stat.h>
@@ -83,6 +84,7 @@ const struct inode_operations nfs_dir_inode_operations = {
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
 };
+EXPORT_SYMBOL_GPL(nfs_dir_inode_operations);
 
 const struct address_space_operations nfs_dir_aops = {
 	.freepage = nfs_readdir_clear_array,
@@ -1262,6 +1264,7 @@ const struct dentry_operations nfs_dentry_operations = {
 	.d_automount	= nfs_d_automount,
 	.d_release	= nfs_d_release,
 };
+EXPORT_SYMBOL_GPL(nfs_dentry_operations);
 
 static struct dentry *nfs_lookup(struct inode *dir, struct dentry * dentry, struct nameidata *nd)
 {
@@ -1670,6 +1673,7 @@ out_error:
 	dput(parent);
 	return error;
 }
+EXPORT_SYMBOL_GPL(nfs_instantiate);
 
 /*
  * Following a failed create operation, we drop the dentry rather
fs/nfs/file.c +3 -0
index 4fdaaa6..94af2db 100644
@@ -16,6 +16,7 @@
  *  nfs regular file handling functions
  */
 
+#include <linux/module.h>
 #include <linux/time.h>
 #include <linux/kernel.h>
 #include <linux/errno.h>
@@ -47,6 +48,7 @@ const struct inode_operations nfs_file_inode_operations = {
 	.getattr	= nfs_getattr,
 	.setattr	= nfs_setattr,
 };
+EXPORT_SYMBOL_GPL(nfs_file_inode_operations);
 
 #ifdef CONFIG_NFS_V3
 const struct inode_operations nfs3_file_inode_operations = {
@@ -867,6 +869,7 @@ const struct file_operations nfs_file_operations = {
 	.check_flags	= nfs_check_flags,
 	.setlease	= nfs_setlease,
 };
+EXPORT_SYMBOL_GPL(nfs_file_operations);
 
 #ifdef CONFIG_NFS_V4
 static int
fs/nfs/inode.c +8 -0
index e30d6d3..773dfb9 100644
@@ -194,6 +194,7 @@ void nfs_invalidate_atime(struct inode *inode)
 	NFS_I(inode)->cache_validity |= NFS_INO_INVALID_ATIME;
 	spin_unlock(&inode->i_lock);
 }
+EXPORT_SYMBOL_GPL(nfs_invalidate_atime);
 
 /*
  * Invalidate, but do not unhash, the inode.
@@ -505,6 +506,7 @@ void nfs_setattr_update_inode(struct inode *inode, struct iattr *attr)
 		nfs_vmtruncate(inode, attr->ia_size);
 	}
 }
+EXPORT_SYMBOL_GPL(nfs_setattr_update_inode);
 
 int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 {
@@ -631,6 +633,7 @@ void nfs_close_context(struct nfs_open_context *ctx, int is_sync)
 		return;
 	nfs_revalidate_inode(server, inode);
 }
+EXPORT_SYMBOL_GPL(nfs_close_context);
 
 struct nfs_open_context *alloc_nfs_open_context(struct dentry *dentry, fmode_t f_mode)
 {
@@ -1025,6 +1028,7 @@ void nfs_fattr_init(struct nfs_fattr *fattr)
 	fattr->owner_name = NULL;
 	fattr->group_name = NULL;
 }
+EXPORT_SYMBOL_GPL(nfs_fattr_init);
 
 struct nfs_fattr *nfs_alloc_fattr(void)
 {
@@ -1035,6 +1039,7 @@ struct nfs_fattr *nfs_alloc_fattr(void)
 		nfs_fattr_init(fattr);
 	return fattr;
 }
+EXPORT_SYMBOL_GPL(nfs_alloc_fattr);
 
 struct nfs_fh *nfs_alloc_fhandle(void)
 {
@@ -1045,6 +1050,7 @@ struct nfs_fh *nfs_alloc_fhandle(void)
 		fh->size = 0;
 	return fh;
 }
+EXPORT_SYMBOL_GPL(nfs_alloc_fhandle);
 
 /**
  * nfs_inode_attrs_need_update - check if the inode attributes need updating
@@ -1104,6 +1110,7 @@ int nfs_refresh_inode(struct inode *inode, struct nfs_fattr *fattr)
 
 	return status;
 }
+EXPORT_SYMBOL_GPL(nfs_refresh_inode);
 
 static int nfs_post_op_update_inode_locked(struct inode *inode, struct nfs_fattr *fattr)
 {
@@ -1191,6 +1198,7 @@ out_noforce:
 	spin_unlock(&inode->i_lock);
 	return status;
 }
+EXPORT_SYMBOL_GPL(nfs_post_op_update_inode_force_wcc);
 
 /*
  * Many nfs protocol calls return the new file attributes after
fs/nfs/nfs.h +2 -1
index 05f6849..4e4802e 100644
@@ -9,6 +9,8 @@
 
 #include <linux/fs.h>
 #include <linux/sunrpc/sched.h>
+#include <linux/nfs_fs.h>
+#include <linux/nfs4.h>
 #include <linux/nfs_xdr.h>
 
 struct nfs_subversion {
@@ -22,7 +24,6 @@ struct nfs_subversion {
 };
 
 void nfs_register_versions(void);
-int init_nfs_v2(void);
 int init_nfs_v3(void);
 int init_nfs_v4(void);
 
fs/nfs/nfs2super.c +13 -1
index 12fa906..773342d 100644
@@ -1,5 +1,7 @@
 /*
  * Copyright (c) 2012 Netapp, Inc. All rights reserved.
+ *
+ * Initialize the NFS v2 module
  */
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
@@ -24,8 +26,18 @@ static struct nfs_subversion nfs_v2 = {
 	.unreference = nfs2_unreference,
 };
 
-int __init init_nfs_v2(void)
+static int __init init_nfs_v2(void)
 {
 	register_nfs_version(&nfs_v2);
 	return 0;
 }
+
+static void __exit exit_nfs_v2(void)
+{
+	unregister_nfs_version(&nfs_v2);
+}
+
+MODULE_LICENSE("GPL");
+
+module_init(init_nfs_v2);
+module_exit(exit_nfs_v2);
Signature · 1 line
1.7.9
#4 lore raw

RFC 5/21 NFS: Break up the nfs_fs_mount function

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

I keep the first few generic steps before calling into a specific NFS version to allocate a server and complete the mount. This will eventually allow each NFS version to do custom server initialization before attempting a mount, such as setting up the v3 aclclient or initializing v4.1 pnfs.

---
 fs/nfs/client.c    |    1 +
 fs/nfs/nfs.h       |   13 ++++++++
 fs/nfs/nfs2super.c |   12 +++++++
 fs/nfs/nfs3super.c |   12 +++++++
 fs/nfs/nfs4_fs.h   |    5 +++
 fs/nfs/nfs4super.c |   10 ++++++
 fs/nfs/super.c     |   84 ++++++++++++++++++++++++++-------------------------
 7 files changed, 96 insertions(+), 41 deletions(-)
fs/nfs/client.c +1 -0
index 4312a51..67a6187 100644
@@ -1263,6 +1263,7 @@ error:
 	nfs_free_server(server);
 	return ERR_PTR(error);
 }
+EXPORT_SYMBOL_GPL(nfs_create_server);
 
 #ifdef CONFIG_NFS_V4
 /*
fs/nfs/nfs.h +13 -0
index 4e4802e..dc7d047 100644
@@ -13,6 +13,8 @@
 #include <linux/nfs4.h>
 #include <linux/nfs_xdr.h>
 
+struct nfs_parsed_mount_data;
+
 struct nfs_subversion {
 	unsigned int version;		/* Protocol number */
 	struct rpc_version *rpc_vers;	/* NFS version information */
@@ -21,6 +23,8 @@ struct nfs_subversion {
 
 	void (*reference)(void);	/* For reference counting */
 	void (*unreference)(void);	/* Also for reference counting */
+	struct dentry *(*fs_mount)(struct file_system_type *, int, const char *,
+				   struct nfs_fh *, struct nfs_parsed_mount_data *);
 };
 
 void nfs_register_versions(void);
@@ -33,4 +37,13 @@ struct nfs_subversion *get_nfs_server_version(struct nfs_server *);
 void register_nfs_version(struct nfs_subversion *);
 void unregister_nfs_version(struct nfs_subversion *);
 
+/* Exported in client.c */
+struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
+
+/* Exported in super.c */
+struct dentry *_nfs_fs_mount(struct file_system_type *, struct nfs_server *,
+			     int, const char *, struct nfs_fh *,
+			     struct nfs_parsed_mount_data *);
+
+
 #endif /* __LINUX_INTERNAL_NFS_H */
fs/nfs/nfs2super.c +12 -0
index 773342d..8f92f5d 100644
@@ -17,6 +17,17 @@ static void nfs2_unreference(void)
 	module_put(THIS_MODULE);
 }
 
+static struct dentry *nfs2_fs_mount(struct file_system_type *fs_type,
+				    int flags, const char *dev_name,
+				    struct nfs_fh *mntfh,
+				    struct nfs_parsed_mount_data *data)
+{
+	struct nfs_server *server = nfs_create_server(data, mntfh);
+	if (IS_ERR(server))
+		return ERR_CAST(server);
+	return _nfs_fs_mount(fs_type, server, flags, dev_name, mntfh, data);
+}
+
 static struct nfs_subversion nfs_v2 = {
 	.version  = 2,
 	.rpc_vers = &nfs_version2,
@@ -24,6 +35,7 @@ static struct nfs_subversion nfs_v2 = {
 
 	.reference = nfs2_reference,
 	.unreference = nfs2_unreference,
+	.fs_mount = nfs2_fs_mount,
 };
 
 static int __init init_nfs_v2(void)
fs/nfs/nfs3super.c +12 -0
index a02c815..2048460 100644
@@ -15,6 +15,17 @@ static void nfs3_unreference(void)
 	module_put(THIS_MODULE);
 }
 
+struct dentry *nfs3_fs_mount(struct file_system_type *fs_type,
+			     int flags, const char *dev_name,
+			     struct nfs_fh *mntfh,
+			     struct nfs_parsed_mount_data *data)
+{
+	struct nfs_server *server = nfs_create_server(data, mntfh);
+	if (IS_ERR(server))
+		return ERR_CAST(server);
+	return _nfs_fs_mount(fs_type, server, flags, dev_name, mntfh, data);
+}
+
 static struct nfs_subversion nfs_v3 = {
 	.version  = 3,
 	.rpc_vers = &nfs_version3,
@@ -22,6 +33,7 @@ static struct nfs_subversion nfs_v3 = {
 
 	.reference = nfs3_reference,
 	.unreference = nfs3_unreference,
+	.fs_mount = nfs3_fs_mount,
 };
 
 int __init init_nfs_v3(void)
fs/nfs/nfs4_fs.h +5 -0
index b133b50..b888151 100644
@@ -11,6 +11,8 @@
 
 #ifdef CONFIG_NFS_V4
 
+#include "nfs.h"
+
 struct idmap;
 
 enum nfs4_client_state {
@@ -204,6 +206,9 @@ struct nfs4_state_maintenance_ops {
 extern const struct dentry_operations nfs4_dentry_operations;
 extern const struct inode_operations nfs4_dir_inode_operations;
 
+/* super.c */
+struct dentry *nfs4_try_mount(int flags, const char *dev_name, struct nfs_parsed_mount_data *);
+
 /* nfs4proc.c */
 extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
 extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
fs/nfs/nfs4super.c +10 -0
index 9b2a679..0cc67b6 100644
@@ -3,6 +3,7 @@
  */
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
+#include "nfs4_fs.h"
 #include "nfs.h"
 
 static void nfs4_reference(void)
@@ -15,6 +16,14 @@ static void nfs4_unreference(void)
 	module_put(THIS_MODULE);
 }
 
+struct dentry *nfs4_fs_mount(struct file_system_type *fs_type,
+			     int flags, const char *dev_name,
+			     struct nfs_fh *mntfh,
+			     struct nfs_parsed_mount_data *data)
+{
+	return nfs4_try_mount(flags, dev_name, data);
+}
+
 static struct nfs_subversion nfs_v4 = {
 	.version  = 4,
 	.rpc_vers = &nfs_version4,
@@ -22,6 +31,7 @@ static struct nfs_subversion nfs_v4 = {
 
 	.reference = nfs4_reference,
 	.unreference = nfs4_unreference,
+	.fs_mount = nfs4_fs_mount,
 };
 
 int __init init_nfs_v4(void)
fs/nfs/super.c +43 -41

123 lines not on this page · raw message

Signature · 1 line
1.7.9
#5 lore raw

RFC 6/21 NFS: Create a single nfs_clone_super() function

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

v2 and v3 shared a function for this, but v4 implemented something different. When I looked closer at the v4 implementation, I found it was basically doing the same thing as v3. Might as well share the code whenever possible...

---
 fs/nfs/super.c |   33 +++++++--------------------------
 1 files changed, 7 insertions(+), 26 deletions(-)
fs/nfs/super.c +7 -26
index c1e8994..ea1d932 100644
@@ -2089,7 +2089,7 @@ static void nfs_fill_super(struct super_block *sb,
 }
 
 /*
- * Finish setting up a cloned NFS2/3 superblock
+ * Finish setting up a cloned NFS2/3/4 superblock
  */
 static void nfs_clone_super(struct super_block *sb,
 			    const struct super_block *old_sb)
@@ -2099,17 +2099,18 @@ static void nfs_clone_super(struct super_block *sb,
 	sb->s_blocksize_bits = old_sb->s_blocksize_bits;
 	sb->s_blocksize = old_sb->s_blocksize;
 	sb->s_maxbytes = old_sb->s_maxbytes;
+	sb->s_xattr = old_sb->s_xattr;
+	sb->s_op = old_sb->s_op;
+	sb->s_time_gran = 1;
 
-	if (server->nfs_client->rpc_ops->version == 3) {
+	if (server->nfs_client->rpc_ops->version != 2) {
 		/* The VFS shouldn't apply the umask to mode bits. We will do
 		 * so ourselves when necessary.
 		 */
 		sb->s_flags |= MS_POSIXACL;
-		sb->s_time_gran = 1;
 	}
 
-	sb->s_op = old_sb->s_op;
- 	nfs_initialise_sb(sb);
+	nfs_initialise_sb(sb);
 }
 
 static int nfs_compare_mount_options(const struct super_block *s, const struct nfs_server *b, int flags)
@@ -2462,26 +2463,6 @@ error_splat_bdi:
 #ifdef CONFIG_NFS_V4
 
 /*
- * Finish setting up a cloned NFS4 superblock
- */
-static void nfs4_clone_super(struct super_block *sb,
-			    const struct super_block *old_sb)
-{
-	sb->s_blocksize_bits = old_sb->s_blocksize_bits;
-	sb->s_blocksize = old_sb->s_blocksize;
-	sb->s_maxbytes = old_sb->s_maxbytes;
-	sb->s_time_gran = 1;
-	sb->s_op = old_sb->s_op;
-	/*
-	 * The VFS shouldn't apply the umask to mode bits. We will do
-	 * so ourselves when necessary.
-	 */
-	sb->s_flags  |= MS_POSIXACL;
-	sb->s_xattr  = old_sb->s_xattr;
-	nfs_initialise_sb(sb);
-}
-
-/*
  * Set up an NFS4 superblock
  */
 static void nfs4_fill_super(struct super_block *sb)
@@ -2950,7 +2931,7 @@ nfs4_xdev_mount(struct file_system_type *fs_type, int flags,
 
 	if (!s->s_root) {
 		/* initial superblock/root creation */
-		nfs4_clone_super(s, data->sb);
+		nfs_clone_super(s, data->sb);
 		nfs_fscache_get_super_cookie(s, NULL, data);
 	}
 
Signature · 1 line
1.7.9
#6 lore raw

RFC 7/21 NFS: Version specific xdev mounting

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

I set up a common _nfs_xdev_mount() function that can be called by v2, v3 and v4 with different parameters. This also gives each version a chance to do their own thing both before and after the call.

---
 fs/nfs/nfs.h       |    4 ++
 fs/nfs/nfs2super.c |   10 ++++-
 fs/nfs/nfs3super.c |    8 +++
 fs/nfs/nfs4_fs.h   |    1 +
 fs/nfs/nfs4super.c |   11 +++++
 fs/nfs/super.c     |  126 +++++++++------------------------------------------
 6 files changed, 56 insertions(+), 104 deletions(-)
fs/nfs/nfs.h +4 -0
index dc7d047..a813d00 100644
@@ -14,6 +14,7 @@
 #include <linux/nfs_xdr.h>
 
 struct nfs_parsed_mount_data;
+struct nfs_clone_mount;
 
 struct nfs_subversion {
 	unsigned int version;		/* Protocol number */
@@ -25,6 +26,7 @@ struct nfs_subversion {
 	void (*unreference)(void);	/* Also for reference counting */
 	struct dentry *(*fs_mount)(struct file_system_type *, int, const char *,
 				   struct nfs_fh *, struct nfs_parsed_mount_data *);
+	struct dentry *(*xdev_mount)(int, const char *, struct nfs_clone_mount *);
 };
 
 void nfs_register_versions(void);
@@ -41,9 +43,11 @@ void unregister_nfs_version(struct nfs_subversion *);
 struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
 
 /* Exported in super.c */
+extern struct file_system_type nfs_fs_type;
 struct dentry *_nfs_fs_mount(struct file_system_type *, struct nfs_server *,
 			     int, const char *, struct nfs_fh *,
 			     struct nfs_parsed_mount_data *);
+struct dentry *_nfs_xdev_mount(struct file_system_type *, int, const char *, void *, int);
 
 
 #endif /* __LINUX_INTERNAL_NFS_H */
fs/nfs/nfs2super.c +9 -1
index 8f92f5d..d1074a9 100644
@@ -1,10 +1,11 @@
 /*
  * Copyright (c) 2012 Netapp, Inc. All rights reserved.
  *
- * Initialize the NFS v2 module
+ Initialize[* Initialize the NFS v2 module
  */
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
+#include <linux/nfs_mount.h>
 #include "nfs.h"
 
 static void nfs2_reference(void)
@@ -28,6 +29,12 @@ static struct dentry *nfs2_fs_mount(struct file_system_type *fs_type,
 	return _nfs_fs_mount(fs_type, server, flags, dev_name, mntfh, data);
 }
 
+static struct dentry *nfs2_xdev_mount(int flags, const char *dev_name,
+				      struct nfs_clone_mount *data)
+{
+	return _nfs_xdev_mount(&nfs_fs_type, flags, dev_name, data, NFS_MOUNT_UNSHARED);
+}
+
 static struct nfs_subversion nfs_v2 = {
 	.version  = 2,
 	.rpc_vers = &nfs_version2,
@@ -36,6 +43,7 @@ static struct nfs_subversion nfs_v2 = {
 	.reference = nfs2_reference,
 	.unreference = nfs2_unreference,
 	.fs_mount = nfs2_fs_mount,
+	.xdev_mount = nfs2_xdev_mount,
 };
 
 static int __init init_nfs_v2(void)
fs/nfs/nfs3super.c +8 -0
index 2048460..7bdd388 100644
@@ -3,6 +3,7 @@
  */
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
+#include <linux/nfs_mount.h>
 #include "nfs.h"
 
 static void nfs3_reference(void)
@@ -26,6 +27,12 @@ struct dentry *nfs3_fs_mount(struct file_system_type *fs_type,
 	return _nfs_fs_mount(fs_type, server, flags, dev_name, mntfh, data);
 }
 
+static struct dentry *nfs3_xdev_mount(int flags, const char *dev_name,
+				      struct nfs_clone_mount *data)
+{
+	return _nfs_xdev_mount(&nfs_fs_type, flags, dev_name, data, NFS_MOUNT_UNSHARED);
+}
+
 static struct nfs_subversion nfs_v3 = {
 	.version  = 3,
 	.rpc_vers = &nfs_version3,
@@ -34,6 +41,7 @@ static struct nfs_subversion nfs_v3 = {
 	.reference = nfs3_reference,
 	.unreference = nfs3_unreference,
 	.fs_mount = nfs3_fs_mount,
+	.xdev_mount = nfs3_xdev_mount,
 };
 
 int __init init_nfs_v3(void)
fs/nfs/nfs4_fs.h +1 -0
index b888151..449b943 100644
@@ -207,6 +207,7 @@ extern const struct dentry_operations nfs4_dentry_operations;
 extern const struct inode_operations nfs4_dir_inode_operations;
 
 /* super.c */
+extern struct file_system_type nfs4_fs_type;
 struct dentry *nfs4_try_mount(int flags, const char *dev_name, struct nfs_parsed_mount_data *);
 
 /* nfs4proc.c */
fs/nfs/nfs4super.c +11 -0
index 0cc67b6..8a297c5 100644
@@ -3,6 +3,7 @@
  */
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
+#include <linux/nfs4_mount.h>
 #include "nfs4_fs.h"
 #include "nfs.h"
 
@@ -24,6 +25,15 @@ struct dentry *nfs4_fs_mount(struct file_system_type *fs_type,
 	return nfs4_try_mount(flags, dev_name, data);
 }
 
+/*
+ * Clone an NFS4 server record on xdev traversal (FSID-change)
+ */
+struct dentry *nfs4_xdev_mount(int flags, const char *dev_name,
+			       struct nfs_clone_mount *data)
+{
+	return _nfs_xdev_mount(&nfs4_fs_type, flags, dev_name, data, NFS4_MOUNT_UNSHARED);
+}
+
 static struct nfs_subversion nfs_v4 = {
 	.version  = 4,
 	.rpc_vers = &nfs_version4,
@@ -32,6 +42,7 @@ static struct nfs_subversion nfs_v4 = {
 	.reference = nfs4_reference,
 	.unreference = nfs4_unreference,
 	.fs_mount = nfs4_fs_mount,
+	.xdev_mount = nfs4_xdev_mount,
 };
 
 int __init init_nfs_v4(void)
fs/nfs/super.c +23 -103

205 lines not on this page · raw message

Signature · 1 line
1.7.9
#7 lore raw

RFC 8/21 NFS: Only initialize the ACL client in the v3 case

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

v2 and v4 don't use it, so the function can be limited to v3 only.

---
 fs/nfs/Makefile     |    2 +-
 fs/nfs/client.c     |   35 +----------------------------
 fs/nfs/nfs.h        |    3 +-
 fs/nfs/nfs2super.c  |    6 ++++-
 fs/nfs/nfs3client.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs3super.c  |   12 ++++++++-
 fs/nfs/nfs4super.c  |    6 ++++-
 fs/nfs/super.c      |   12 +--------
 8 files changed, 87 insertions(+), 50 deletions(-)
 create mode 100644 fs/nfs/nfs3client.c
fs/nfs/Makefile +1 -1
index bc2ba86..6764e66 100644
@@ -9,7 +9,7 @@ nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V3)	+= nfs3super.o nfs3proc.o nfs3xdr.o
+nfs-$(CONFIG_NFS_V3)	+= nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 			   nfs4super.o delegation.o idmap.o \
fs/nfs/client.c +1 -34
index 67a6187..ca3a408 100644
@@ -794,36 +794,6 @@ static int nfs_start_lockd(struct nfs_server *server)
 }
 
 /*
- * Initialise an NFSv3 ACL client connection
- */
-#ifdef CONFIG_NFS_V3_ACL
-static void nfs_init_server_aclclient(struct nfs_server *server)
-{
-	if (server->nfs_client->rpc_ops->version != 3)
-		goto out_noacl;
-	if (server->flags & NFS_MOUNT_NOACL)
-		goto out_noacl;
-
-	server->client_acl = rpc_bind_new_program(server->client, &nfsacl_program, 3);
-	if (IS_ERR(server->client_acl))
-		goto out_noacl;
-
-	/* No errors! Assume that Sun nfsacls are supported */
-	server->caps |= NFS_CAP_ACLS;
-	return;
-
-out_noacl:
-	server->caps &= ~NFS_CAP_ACLS;
-}
-#else
-static inline void nfs_init_server_aclclient(struct nfs_server *server)
-{
-	server->flags &= ~NFS_MOUNT_NOACL;
-	server->caps &= ~NFS_CAP_ACLS;
-}
-#endif
-
-/*
  * Create a general RPC client
  */
 static int nfs_init_server_rpcclient(struct nfs_server *server,
@@ -970,8 +940,6 @@ static int nfs_init_server(struct nfs_server *server,
 	server->mountd_protocol = data->mount_server.protocol;
 
 	server->namelen  = data->namlen;
-	/* Create a client RPC handle for the NFSv3 ACL management interface */
-	nfs_init_server_aclclient(server);
 	dprintk("<-- nfs_init_server() = 0 [new %p]\n", clp);
 	return 0;
 
@@ -1794,8 +1762,6 @@ struct nfs_server *nfs_clone_server(struct nfs_server *source,
 			source->client->cl_auth->au_flavor);
 	if (error < 0)
 		goto out_free_server;
-	if (!IS_ERR(source->client_acl))
-		nfs_init_server_aclclient(server);
 
 	/* probe the filesystem info for this server filesystem */
 	error = nfs_probe_fsinfo(server, fh, fattr_fsinfo);
@@ -1826,6 +1792,7 @@ out_free_server:
 	dprintk("<-- nfs_clone_server() = error %d\n", error);
 	return ERR_PTR(error);
 }
+EXPORT_SYMBOL_GPL(nfs_clone_server);
 
 #ifdef CONFIG_PROC_FS
 static struct proc_dir_entry *proc_fs_nfs;
fs/nfs/nfs.h +2 -1
index a813d00..921e8c8 100644
@@ -47,7 +47,8 @@ extern struct file_system_type nfs_fs_type;
 struct dentry *_nfs_fs_mount(struct file_system_type *, struct nfs_server *,
 			     int, const char *, struct nfs_fh *,
 			     struct nfs_parsed_mount_data *);
-struct dentry *_nfs_xdev_mount(struct file_system_type *, int, const char *, void *, int);
+struct dentry *_nfs_xdev_mount(struct file_system_type *, struct nfs_server *,
+			       int, const char *, void *, int);
 
 
 #endif /* __LINUX_INTERNAL_NFS_H */
fs/nfs/nfs2super.c +5 -1
index d1074a9..ddcc4d1 100644
@@ -6,6 +6,7 @@
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs_mount.h>
+#include "internal.h"
 #include "nfs.h"
 
 static void nfs2_reference(void)
@@ -32,7 +33,10 @@ static struct dentry *nfs2_fs_mount(struct file_system_type *fs_type,
 static struct dentry *nfs2_xdev_mount(int flags, const char *dev_name,
 				      struct nfs_clone_mount *data)
 {
-	return _nfs_xdev_mount(&nfs_fs_type, flags, dev_name, data, NFS_MOUNT_UNSHARED);
+	struct nfs_server *server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
+	if (IS_ERR(server))
+		return ERR_CAST(server);
+	return _nfs_xdev_mount(&nfs_fs_type, server, flags, dev_name, data, NFS_MOUNT_UNSHARED);
 }
 
 static struct nfs_subversion nfs_v2 = {
fs/nfs/nfs3client.c new file +61 -0

61 lines not on this page · raw message

fs/nfs/nfs3super.c +10 -2
index 7bdd388..5702895 100644
@@ -4,8 +4,13 @@
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs_mount.h>
+#include "internal.h"
 #include "nfs.h"
 
+/* From nfs3client.c */
+struct nfs_server *nfs3_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
+struct nfs_server *nfs3_clone_server(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *);
+
 static void nfs3_reference(void)
 {
 	try_module_get(THIS_MODULE);
@@ -21,7 +26,7 @@ struct dentry *nfs3_fs_mount(struct file_system_type *fs_type,
 			     struct nfs_fh *mntfh,
 			     struct nfs_parsed_mount_data *data)
 {
-	struct nfs_server *server = nfs_create_server(data, mntfh);
+	struct nfs_server *server = nfs3_create_server(data, mntfh);
 	if (IS_ERR(server))
 		return ERR_CAST(server);
 	return _nfs_fs_mount(fs_type, server, flags, dev_name, mntfh, data);
@@ -30,7 +35,10 @@ struct dentry *nfs3_fs_mount(struct file_system_type *fs_type,
 static struct dentry *nfs3_xdev_mount(int flags, const char *dev_name,
 				      struct nfs_clone_mount *data)
 {
-	return _nfs_xdev_mount(&nfs_fs_type, flags, dev_name, data, NFS_MOUNT_UNSHARED);
+	struct nfs_server *server = nfs3_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
+	if (IS_ERR(server))
+		return ERR_CAST(server);
+	return _nfs_xdev_mount(&nfs_fs_type, server, flags, dev_name, data, NFS_MOUNT_UNSHARED);
 }
 
 static struct nfs_subversion nfs_v3 = {
fs/nfs/nfs4super.c +5 -1
index 8a297c5..f6c8f9f 100644
@@ -4,6 +4,7 @@
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs4_mount.h>
+#include "internal.h"
 #include "nfs4_fs.h"
 #include "nfs.h"
 
@@ -31,7 +32,10 @@ struct dentry *nfs4_fs_mount(struct file_system_type *fs_type,
 struct dentry *nfs4_xdev_mount(int flags, const char *dev_name,
 			       struct nfs_clone_mount *data)
 {
-	return _nfs_xdev_mount(&nfs4_fs_type, flags, dev_name, data, NFS4_MOUNT_UNSHARED);
+	struct nfs_server *server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
+	if (IS_ERR(server))
+		return ERR_CAST(server);
+	return _nfs_xdev_mount(&nfs4_fs_type, server, flags, dev_name, data, NFS4_MOUNT_UNSHARED);
 }
 
 static struct nfs_subversion nfs_v4 = {
fs/nfs/super.c +2 -10
index e6c62b5..ec5287d 100644
@@ -2373,12 +2373,11 @@ static void nfs_kill_super(struct super_block *s)
  * Clone an NFS2/3 server record on xdev traversal (FSID-change)
  */
 struct dentry *
-_nfs_xdev_mount(struct file_system_type *fs_type, int flags,
-		const char *dev_name, void *raw_data, int unshared_flag)
+_nfs_xdev_mount(struct file_system_type *fs_type, struct nfs_server *server,
+		int flags, const char *dev_name, void *raw_data, int unshared_flag)
 {
 	struct nfs_clone_mount *data = raw_data;
 	struct super_block *s;
-	struct nfs_server *server;
 	struct dentry *mntroot;
 	int (*compare_super)(struct super_block *, void *) = nfs_compare_super;
 	struct nfs_sb_mountdata sb_mntdata = {
@@ -2388,12 +2387,6 @@ _nfs_xdev_mount(struct file_system_type *fs_type, int flags,
 
 	dprintk("--> _nfs_xdev_mount()\n");
 
-	/* create a new volume representation */
-	server = nfs_clone_server(NFS_SB(data->sb), data->fh, data->fattr);
-	if (IS_ERR(server)) {
-		error = PTR_ERR(server);
-		goto out_err_noserver;
-	}
 	sb_mntdata.server = server;
 
 	if (server->flags & unshared_flag)
@@ -2446,7 +2439,6 @@ _nfs_xdev_mount(struct file_system_type *fs_type, int flags,
 
 out_err_nosb:
 	nfs_free_server(server);
-out_err_noserver:
 	dprintk("<-- _nfs_xdev_mount() = %d [error]\n", error);
 	return ERR_PTR(error);
 
Signature · 1 line
1.7.9
#8 lore raw

RFC 9/21 NFS: Convert v3 into a module

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This patch exports symbols and moves over the final structures needed by the v3 module. In addition, I also switch over to using IS_ENABLED() to check if CONFIG_NFS_V3 or CONFIG_NFS_V3_MODULE are set.

The module will be created in the same directory as nfs.ko. You need to run modprobe nfs3 before you can use it.

---
 fs/nfs/Kconfig         |    2 +-
 fs/nfs/Makefile        |    6 +++-
 fs/nfs/client.c        |   18 -------------
 fs/nfs/dir.c           |   65 ++++++++++++++++-------------------------------
 fs/nfs/direct.c        |    2 +-
 fs/nfs/file.c          |   12 ---------
 fs/nfs/inode.c         |    5 +++
 fs/nfs/nfs.h           |   12 ++++++++-
 fs/nfs/nfs3client.c    |   15 ++++++++++-
 fs/nfs/nfs3super.c     |   39 ++++++++++++++++++++++++++++
 fs/nfs/super.c         |    6 ++--
 fs/nfs/write.c         |    8 +++---
 include/linux/nfs_fs.h |    6 ++--
 13 files changed, 107 insertions(+), 89 deletions(-)
 create mode 100644 fs/nfs/dangling.txt
fs/nfs/Kconfig +1 -1
index b28e56f..57c4b19 100644
@@ -39,7 +39,7 @@ config NFS_V2
 	  If unsure, say Y.
 
 config NFS_V3
-	bool "NFS client support for NFS version 3"
+	tristate "NFS client support for NFS version 3"
 	depends on NFS_FS
 	help
 	  This option enables support for version 3 of the NFS protocol
fs/nfs/Makefile +4 -2
index 6764e66..938db05 100644
@@ -9,8 +9,6 @@ nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V3)	+= nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
-nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 			   nfs4super.o delegation.o idmap.o \
 			   callback.o callback_xdr.o callback_proc.o \
@@ -22,6 +20,10 @@ nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 obj-$(CONFIG_NFS_V2) += nfs2.o
 nfs2-y += nfs2super.o proc.o nfs2xdr.o
 
+obj-$(CONFIG_NFS_V3) += nfs3.o
+nfs3-y += nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
+nfs3-y += nfs3acl.o
+
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
 nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o
 
fs/nfs/client.c +0 -18
index ca3a408..75fe112 100644
@@ -111,21 +111,6 @@ struct rpc_stat nfs_rpcstat = {
 	.program		= &nfs_program
 };
 
-#ifdef CONFIG_NFS_V3_ACL
-static struct rpc_stat		nfsacl_rpcstat = { &nfsacl_program };
-static struct rpc_version *nfsacl_version[] = {
-	[3]			= &nfsacl_version3,
-};
-
-const struct rpc_program nfsacl_program = {
-	.name			= "nfsacl",
-	.number			= NFS_ACL_PROGRAM,
-	.nrvers			= ARRAY_SIZE(nfsacl_version),
-	.version		= nfsacl_version,
-	.stats			= &nfsacl_rpcstat,
-};
-#endif  /* CONFIG_NFS_V3_ACL */
-
 struct nfs_client_initdata {
 	const char *hostname;
 	const struct sockaddr *addr;
@@ -197,9 +182,6 @@ EXPORT_SYMBOL_GPL(unregister_nfs_version);
  */
 void __init nfs_register_versions(void)
 {
-#ifdef CONFIG_NFS_V3
-	init_nfs_v3();
-#endif
 #ifdef CONFIG_NFS_V4
 	init_nfs_v4();
 #endif
fs/nfs/dangling.txt new file +0 -0
new file mode 100644
index 0000000..e69de29
fs/nfs/dir.c +22 -43

194 lines not on this page · raw message

fs/nfs/direct.c +1 -1
index 1940f1a..185e177 100644
@@ -460,7 +460,7 @@ static void nfs_direct_free_writedata(struct nfs_direct_req *dreq)
 	}
 }
 
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
 {
 	struct inode *inode = dreq->inode;
fs/nfs/file.c +0 -12
index 94af2db..c678c00 100644
@@ -50,18 +50,6 @@ const struct inode_operations nfs_file_inode_operations = {
 };
 EXPORT_SYMBOL_GPL(nfs_file_inode_operations);
 
-#ifdef CONFIG_NFS_V3
-const struct inode_operations nfs3_file_inode_operations = {
-	.permission	= nfs_permission,
-	.getattr	= nfs_getattr,
-	.setattr	= nfs_setattr,
-	.listxattr	= nfs3_listxattr,
-	.getxattr	= nfs3_getxattr,
-	.setxattr	= nfs3_setxattr,
-	.removexattr	= nfs3_removexattr,
-};
-#endif  /* CONFIG_NFS_v3 */
-
 /* Hack for future NFS swap support */
 #ifndef IS_SWAPFILE
 # define IS_SWAPFILE(inode)	(0)
fs/nfs/inode.c +5 -0
index 773dfb9..a78d701 100644
@@ -187,6 +187,7 @@ void nfs_zap_acl_cache(struct inode *inode)
 	NFS_I(inode)->cache_validity &= ~NFS_INO_INVALID_ACL;
 	spin_unlock(&inode->i_lock);
 }
+EXPORT_SYMBOL_GPL(nfs_zap_acl_cache);
 
 void nfs_invalidate_atime(struct inode *inode)
 {
@@ -448,6 +449,7 @@ nfs_setattr(struct dentry *dentry, struct iattr *attr)
 out:
 	return error;
 }
+EXPORT_SYMBOL_GPL(nfs_setattr);
 
 /**
  * nfs_vmtruncate - unmap mappings "freed" by truncate() syscall
@@ -545,6 +547,7 @@ int nfs_getattr(struct vfsmount *mnt, struct dentry *dentry, struct kstat *stat)
 out:
 	return err;
 }
+EXPORT_SYMBOL_GPL(nfs_getattr);
 
 static void nfs_init_lock_context(struct nfs_lock_context *l_ctx)
 {
@@ -851,6 +854,7 @@ int nfs_revalidate_inode(struct nfs_server *server, struct inode *inode)
 		return NFS_STALE(inode) ? -ESTALE : 0;
 	return __nfs_revalidate_inode(server, inode);
 }
+EXPORT_SYMBOL_GPL(nfs_revalidate_inode);
 
 static int nfs_invalidate_mapping(struct inode *inode, struct address_space *mapping)
 {
@@ -1147,6 +1151,7 @@ int nfs_post_op_update_inode(struct inode *inode, struct nfs_fattr *fattr)
 	spin_unlock(&inode->i_lock);
 	return status;
 }
+EXPORT_SYMBOL_GPL(nfs_post_op_update_inode);
 
 /**
  * nfs_post_op_update_inode_force_wcc - try to update the inode attribute cache
fs/nfs/nfs.h +11 -1
index 921e8c8..dccbcfc 100644
@@ -30,7 +30,6 @@ struct nfs_subversion {
 };
 
 void nfs_register_versions(void);
-int init_nfs_v3(void);
 int init_nfs_v4(void);
 
 struct nfs_subversion *get_nfs_version(unsigned int);
@@ -42,6 +41,17 @@ void unregister_nfs_version(struct nfs_subversion *);
 /* Exported in client.c */
 struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
 
+/* Exported in dir.c */
+struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *);
+int nfs_create(struct inode *, struct dentry *, umode_t, struct nameidata *);
+int nfs_mkdir(struct inode *, struct dentry *, umode_t);
+int nfs_rmdir(struct inode *, struct dentry *);
+int nfs_unlink(struct inode *, struct dentry *);
+int nfs_symlink(struct inode *, struct dentry *, const char *);
+int nfs_link(struct dentry *, struct inode *, struct dentry *);
+int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
+int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
+
 /* Exported in super.c */
 extern struct file_system_type nfs_fs_type;
 struct dentry *_nfs_fs_mount(struct file_system_type *, struct nfs_server *,
fs/nfs/nfs3client.c +14 -1
index f23fc46..f246cbd 100644
@@ -12,10 +12,23 @@
 #include "internal.h"
 #include "nfs.h"
 
+#ifdef CONFIG_NFS_V3_ACL
+static struct rpc_stat		nfsacl_rpcstat = { &nfsacl_program };
+static struct rpc_version *nfsacl_version[] = {
+	[3]			= &nfsacl_version3,
+};
+
+const struct rpc_program nfsacl_program = {
+	.name			= "nfsacl",
+	.number			= NFS_ACL_PROGRAM,
+	.nrvers			= ARRAY_SIZE(nfsacl_version),
+	.version		= nfsacl_version,
+	.stats			= &nfsacl_rpcstat,
+};
+
 /*
  * Initialise an NFSv3 ACL client connection
  */
-#ifdef CONFIG_NFS_V3_ACL
 static void nfs_init_server_aclclient(struct nfs_server *server)
 {
 	if (server->flags & NFS_MOUNT_NOACL)
fs/nfs/nfs3super.c +39 -0
index 5702895..474840f 100644
@@ -41,6 +41,35 @@ static struct dentry *nfs3_xdev_mount(int flags, const char *dev_name,
 	return _nfs_xdev_mount(&nfs_fs_type, server, flags, dev_name, data, NFS_MOUNT_UNSHARED);
 }
 
+const struct inode_operations nfs3_file_inode_operations = {
+	.permission	= nfs_permission,
+	.getattr	= nfs_getattr,
+	.setattr	= nfs_setattr,
+	.listxattr	= nfs3_listxattr,
+	.getxattr	= nfs3_getxattr,
+	.setxattr	= nfs3_setxattr,
+	.removexattr	= nfs3_removexattr,
+};
+
+const struct inode_operations nfs3_dir_inode_operations = {
+	.create		= nfs_create,
+	.lookup		= nfs_lookup,
+	.link		= nfs_link,
+	.unlink		= nfs_unlink,
+	.symlink	= nfs_symlink,
+	.mkdir		= nfs_mkdir,
+	.rmdir		= nfs_rmdir,
+	.mknod		= nfs_mknod,
+	.rename		= nfs_rename,
+	.permission	= nfs_permission,
+	.getattr	= nfs_getattr,
+	.setattr	= nfs_setattr,
+	.listxattr	= nfs3_listxattr,
+	.getxattr	= nfs3_getxattr,
+	.setxattr	= nfs3_setxattr,
+	.removexattr	= nfs3_removexattr,
+};
+
 static struct nfs_subversion nfs_v3 = {
 	.version  = 3,
 	.rpc_vers = &nfs_version3,
@@ -57,3 +86,13 @@ int __init init_nfs_v3(void)
 	register_nfs_version(&nfs_v3);
 	return 0;
 }
+
+static void __exit exit_nfs_v3(void)
+{
+	unregister_nfs_version(&nfs_v3);
+}
+
+MODULE_LICENSE("GPL");
+
+module_init(init_nfs_v3);
+module_exit(exit_nfs_v3);
fs/nfs/super.c +3 -3
index ec5287d..88bbebe 100644
@@ -68,7 +68,7 @@
 
 #define NFSDBG_FACILITY		NFSDBG_VFS
 
-#ifdef CONFIG_NFS_V3
+#if IS_ENABLED(CONFIG_NFS_V3)
 #define NFS_DEFAULT_VERSION 3
 #else
 #define NFS_DEFAULT_VERSION 2
@@ -1910,7 +1910,7 @@ static int nfs_validate_mount_data(void *options,
 		}
 	}
 
-#ifndef CONFIG_NFS_V3
+#if !IS_ENABLED(CONFIG_NFS_V3)
 	if (args->version == 3)
 		goto out_v3_not_compiled;
 #endif /* !CONFIG_NFS_V3 */
@@ -1930,7 +1930,7 @@ out_no_sec:
 	dfprintk(MOUNT, "NFS: nfs_mount_data version supports only AUTH_SYS\n");
 	return -EINVAL;
 
-#ifndef CONFIG_NFS_V3
+#if !IS_ENABLED(CONFIG_NFS_V3)
 out_v3_not_compiled:
 	dfprintk(MOUNT, "NFS: NFSv3 is not compiled into kernel\n");
 	return -EPROTONOSUPPORT;
fs/nfs/write.c +4 -4
index 0b1831d..b8111cb 100644
@@ -431,7 +431,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
 	__set_page_dirty_nobuffers(req->wb_page);
 }
 
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 /*
  * Add a request to the inode's commit list.
  */
@@ -516,7 +516,7 @@ int nfs_reschedule_unstable_write(struct nfs_page *req,
 }
 #endif
 
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 static int
 nfs_need_commit(struct nfs_inode *nfsi)
 {
@@ -1238,7 +1238,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
 		return;
 	nfs_add_stats(data->inode, NFSIOS_SERVERWRITTENBYTES, resp->count);
 
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 	if (resp->verf->committed < argp->stable && task->tk_status >= 0) {
 		/* We tried a write call, but the server did not
 		 * commit data to stable storage even though we
@@ -1297,7 +1297,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
 }
 
 
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 static int nfs_commit_set_lock(struct nfs_inode *nfsi, int may_wait)
 {
 	int ret;
include/linux/nfs_fs.h +3 -3
index 8c29950..766ea02 100644
@@ -406,7 +406,7 @@ extern __be32 root_nfs_parse_addr(char *name); /*__init*/
  * linux/fs/nfs/file.c
  */
 extern const struct inode_operations nfs_file_inode_operations;
-#ifdef CONFIG_NFS_V3
+#if IS_ENABLED(CONFIG_NFS_V3)
 extern const struct inode_operations nfs3_file_inode_operations;
 #endif /* CONFIG_NFS_V3 */
 extern const struct file_operations nfs_file_operations;
@@ -464,7 +464,7 @@ extern ssize_t nfs_file_direct_write(struct kiocb *iocb,
  * linux/fs/nfs/dir.c
  */
 extern const struct inode_operations nfs_dir_inode_operations;
-#ifdef CONFIG_NFS_V3
+#if IS_ENABLED(CONFIG_NFS_V3)
 extern const struct inode_operations nfs3_dir_inode_operations;
 #endif /* CONFIG_NFS_V3 */
 extern const struct file_operations nfs_dir_operations;
@@ -524,7 +524,7 @@ extern void nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
 extern int nfs_wb_all(struct inode *inode);
 extern int nfs_wb_page(struct inode *inode, struct page* page);
 extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
-#if defined(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
 extern int  nfs_commit_inode(struct inode *, int);
 extern struct nfs_write_data *nfs_commitdata_alloc(void);
 extern void nfs_commit_free(struct nfs_write_data *wdata);
Signature · 1 line
1.7.9
#9 lore raw

RFC 10/21 NFS: Initialize NFS v4 from nfs4super.c

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This includes starting the idmapper, registering sysctls and registering the nfs_subversion struct with the generic NFS client. I also added in a call to exit_nfs_v4() when the NFS module exits to undo everything before exiting.

---
 fs/nfs/Makefile                   |    2 +-
 fs/nfs/client.c                   |   12 ----------
 fs/nfs/inode.c                    |   14 +++++-------
 fs/nfs/nfs.h                      |    2 +-
 fs/nfs/nfs4_fs.h                  |    9 ++++++++
 fs/nfs/nfs4super.c                |   23 ++++++++++++++++++++
 fs/nfs/{sysctl.c => nfs4sysctl.c} |   42 ++++++++++--------------------------
 fs/nfs/sysctl.c                   |   28 ------------------------
 8 files changed, 52 insertions(+), 80 deletions(-)
 copy fs/nfs/{sysctl.c => nfs4sysctl.c} (53%)
fs/nfs/Makefile +1 -1
index 938db05..92ebf2f 100644
@@ -14,7 +14,7 @@ nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 			   callback.o callback_xdr.o callback_proc.o \
 			   nfs4namespace.o
 nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
-nfs-$(CONFIG_SYSCTL) += sysctl.o
+nfs-$(CONFIG_SYSCTL) += sysctl.o nfs4sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 
 obj-$(CONFIG_NFS_V2) += nfs2.o
fs/nfs/client.c +0 -12
index 75fe112..a954a12 100644
@@ -176,18 +176,6 @@ void unregister_nfs_version(struct nfs_subversion *nfs)
 EXPORT_SYMBOL_GPL(unregister_nfs_version);
 
 /*
- * Preload all configured NFS versions during module init.
- * This function should be edited after each protocol is converted,
- * and eventually removed.
- */
-void __init nfs_register_versions(void)
-{
-#ifdef CONFIG_NFS_V4
-	init_nfs_v4();
-#endif
-}
-
-/*
  * Allocate a shared client record
  *
  * Since these are allocated/deallocated very rarely, we don't
fs/nfs/inode.c +6 -8
index a78d701..da01c56 100644
@@ -1594,10 +1594,6 @@ static int __init init_nfs_fs(void)
 {
 	int err;
 
-	err = nfs_idmap_init();
-	if (err < 0)
-		goto out10;
-
 	err = nfs_dns_resolver_init();
 	if (err < 0)
 		goto out9;
@@ -1643,7 +1639,9 @@ static int __init init_nfs_fs(void)
 #endif
 	if ((err = register_nfs_fs()) != 0)
 		goto out;
-	nfs_register_versions();
+#ifdef CONFIG_NFS_V4
+	init_nfs_v4();
+#endif
 	return 0;
 out:
 #ifdef CONFIG_PROC_FS
@@ -1669,13 +1667,14 @@ out7:
 out8:
 	nfs_dns_resolver_destroy();
 out9:
-	nfs_idmap_quit();
-out10:
 	return err;
 }
 
 static void __exit exit_nfs_fs(void)
 {
+#ifdef CONFIG_NFS_V4
+	exit_nfs_v4();
+#endif
 	nfs_destroy_directcache();
 	nfs_destroy_writepagecache();
 	nfs_destroy_readpagecache();
@@ -1684,7 +1683,6 @@ static void __exit exit_nfs_fs(void)
 	nfs_fscache_unregister();
 	unregister_pernet_subsys(&nfs_net_ops);
 	nfs_dns_resolver_destroy();
-	nfs_idmap_quit();
 #ifdef CONFIG_PROC_FS
 	rpc_proc_unregister(&init_net, "nfs");
 #endif
fs/nfs/nfs.h +1 -1
index dccbcfc..cf49c63 100644
@@ -29,8 +29,8 @@ struct nfs_subversion {
 	struct dentry *(*xdev_mount)(int, const char *, struct nfs_clone_mount *);
 };
 
-void nfs_register_versions(void);
 int init_nfs_v4(void);
+void exit_nfs_v4(void);
 
 struct nfs_subversion *get_nfs_version(unsigned int);
 struct nfs_subversion *get_nfs_client_version(struct nfs_client *);
fs/nfs/nfs4_fs.h +9 -0
index 449b943..1147640 100644
@@ -345,6 +345,15 @@ extern void nfs_free_seqid(struct nfs_seqid *seqid);
 
 extern const nfs4_stateid zero_stateid;
 
+/* nfs4sysctl.h */
+#ifdef CONFIG_SYSCTL
+int nfs4_register_sysctl(void);
+void nfs4_unregister_sysctl(void);
+#else
+inline int nfs4_register_sysctl(void) { return 0; }
+inline void nfs4_unregister_sysctl(void) { }
+#endif /* CONFIG_SYSCTL */
+
 /* nfs4xdr.c */
 extern struct rpc_procinfo nfs4_procedures[];
 
fs/nfs/nfs4super.c +23 -0
index f6c8f9f..9dc0c37 100644
@@ -4,6 +4,7 @@
 #include <linux/module.h>
 #include <linux/nfs_fs.h>
 #include <linux/nfs4_mount.h>
+#include <linux/nfs_idmap.h>
 #include "internal.h"
 #include "nfs4_fs.h"
 #include "nfs.h"
@@ -51,6 +52,28 @@ static struct nfs_subversion nfs_v4 = {
 
 int __init init_nfs_v4(void)
 {
+	int err;
+
+	err = nfs_idmap_init();
+	if (err < 0)
+		goto out_1;
+
+	err = nfs4_register_sysctl();
+	if (err < 0)
+		goto out_0;
+
 	register_nfs_version(&nfs_v4);
 	return 0;
+
+out_0:
+	nfs_idmap_quit();
+out_1:
+	return err;
+}
+
+void __exit exit_nfs_v4(void)
+{
+	unregister_nfs_version(&nfs_v4);
+	nfs4_unregister_sysctl();
+	nfs_idmap_quit();
 }
fs/nfs/nfs4sysctl.c renamed from fs/nfs/sysctl.c +12 -30

78 lines not on this page · raw message

fs/nfs/sysctl.c +0 -28
index 978aaeb..6b3f253 100644
@@ -9,39 +9,11 @@
 #include <linux/fs.h>
 #include <linux/sysctl.h>
 #include <linux/module.h>
-#include <linux/nfs4.h>
-#include <linux/nfs_idmap.h>
 #include <linux/nfs_fs.h>
 
-#include "callback.h"
-
-#ifdef CONFIG_NFS_V4
-static const int nfs_set_port_min = 0;
-static const int nfs_set_port_max = 65535;
-#endif
 static struct ctl_table_header *nfs_callback_sysctl_table;
 
 static ctl_table nfs_cb_sysctls[] = {
-#ifdef CONFIG_NFS_V4
-	{
-		.procname = "nfs_callback_tcpport",
-		.data = &nfs_callback_set_tcpport,
-		.maxlen = sizeof(int),
-		.mode = 0644,
-		.proc_handler = proc_dointvec_minmax,
-		.extra1 = (int *)&nfs_set_port_min,
-		.extra2 = (int *)&nfs_set_port_max,
-	},
-#ifndef CONFIG_NFS_USE_NEW_IDMAPPER
-	{
-		.procname = "idmap_cache_timeout",
-		.data = &nfs_idmap_cache_timeout,
-		.maxlen = sizeof(int),
-		.mode = 0644,
-		.proc_handler = proc_dointvec_jiffies,
-	},
-#endif /* CONFIG_NFS_USE_NEW_IDMAPPER */
-#endif
 	{
 		.procname	= "nfs_mountpoint_timeout",
 		.data		= &nfs_mountpoint_expiry_timeout,
Signature · 1 line
1.7.9
#10 lore raw

RFC 11/21 NFS: Move lots of code from super.c

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

Each function that I moved required me to move two more functions... and then solve a bunch of modpost errors. I really wanted this to be less than 1500 lines (actually, I was hoping for less than 1000). Too bad that didn't work out...

---
 fs/nfs/fscache.c   |    3 +
 fs/nfs/inode.c     |    3 +
 fs/nfs/nfs.h       |   26 ++-
 fs/nfs/nfs4super.c |  571 +++++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/super.c     |  649 ++++------------------------------------------------
 fs/nfs/write.c     |    1 +
 6 files changed, 646 insertions(+), 607 deletions(-)
fs/nfs/fscache.c +3 -0
index 419119c..a5460ff 100644
@@ -9,6 +9,7 @@
  * 2 of the Licence, or (at your option) any later version.
  */
 
+#include <linux/module.h>
 #include <linux/init.h>
 #include <linux/kernel.h>
 #include <linux/sched.h>
@@ -163,6 +164,7 @@ non_unique:
 	printk(KERN_WARNING "NFS:"
 	       " Cache request denied due to non-unique superblock keys\n");
 }
+EXPORT_SYMBOL_GPL(nfs_fscache_get_super_cookie);
 
 /*
  * release a per-superblock cookie
@@ -185,6 +187,7 @@ void nfs_fscache_release_super_cookie(struct super_block *sb)
 		nfss->fscache_key = NULL;
 	}
 }
+EXPORT_SYMBOL_GPL(nfs_fscache_release_super_cookie);
 
 /*
  * Initialise the per-inode cache cookie pointer for an NFS inode.
fs/nfs/inode.c +3 -0
index da01c56..53bb916 100644
@@ -1459,6 +1459,7 @@ void nfs4_evict_inode(struct inode *inode)
 	/* First call standard NFS clear_inode() code */
 	nfs_clear_inode(inode);
 }
+EXPORT_SYMBOL_GPL(nfs4_evict_inode);
 #endif
 
 struct inode *nfs_alloc_inode(struct super_block *sb)
@@ -1478,6 +1479,7 @@ struct inode *nfs_alloc_inode(struct super_block *sb)
 #endif /* CONFIG_NFS_V4 */
 	return &nfsi->vfs_inode;
 }
+EXPORT_SYMBOL_GPL(nfs_alloc_inode);
 
 static void nfs_i_callback(struct rcu_head *head)
 {
@@ -1489,6 +1491,7 @@ void nfs_destroy_inode(struct inode *inode)
 {
 	call_rcu(&inode->i_rcu, nfs_i_callback);
 }
+EXPORT_SYMBOL_GPL(nfs_destroy_inode);
 
 static inline void nfs4_init_once(struct nfs_inode *nfsi)
 {
fs/nfs/nfs.h +25 -1
index cf49c63..dc1854c 100644
@@ -29,6 +29,11 @@ struct nfs_subversion {
 	struct dentry *(*xdev_mount)(int, const char *, struct nfs_clone_mount *);
 };
 
+struct nfs_sb_mountdata {
+	struct nfs_server *server;
+	int mntflags;
+};
+
 int init_nfs_v4(void);
 void exit_nfs_v4(void);
 
@@ -59,6 +64,25 @@ struct dentry *_nfs_fs_mount(struct file_system_type *, struct nfs_server *,
 			     struct nfs_parsed_mount_data *);
 struct dentry *_nfs_xdev_mount(struct file_system_type *, struct nfs_server *,
 			       int, const char *, void *, int);
-
+struct dentry * nfs_xdev_mount(struct file_system_type *, int, const char *, void *);
+int nfs_statfs(struct dentry *, struct kstatfs *);
+void nfs_umount_begin(struct super_block *);
+struct nfs_parsed_mount_data *nfs_alloc_parsed_mount_data(unsigned);
+void nfs_free_parsed_mount_data(struct nfs_parsed_mount_data *);
+int nfs_verify_server_address(struct sockaddr *);
+void nfs_validate_transport_protocol(struct nfs_parsed_mount_data *);
+int nfs_parse_mount_options(char *, struct nfs_parsed_mount_data *);
+int nfs_show_options(struct seq_file *, struct dentry *);
+int nfs_show_devname(struct seq_file *, struct dentry *);
+int nfs_show_path(struct seq_file *, struct dentry *);
+int nfs_show_stats(struct seq_file *, struct dentry *);
+int nfs_remount(struct super_block *, int *, char *);
+inline void nfs_initialise_sb(struct super_block *);
+int nfs_compare_super(struct super_block *, void *);
+int nfs_register(struct nfs_server *);
+void nfs_unregister(struct nfs_server *);
+void nfs_put_super(struct super_block *);
+int nfs_set_super(struct super_block *, void *);
+int nfs4_validate_text_mount_data(void *, struct nfs_parsed_mount_data *, const char *);
 
 #endif /* __LINUX_INTERNAL_NFS_H */
fs/nfs/nfs4super.c +571 -0

583 lines not on this page · raw message

fs/nfs/super.c +43 -606

875 lines not on this page · raw message

fs/nfs/write.c +1 -0
index b8111cb..d906336 100644
@@ -1607,6 +1607,7 @@ int nfs_write_inode(struct inode *inode, struct writeback_control *wbc)
 	}
 	return ret;
 }
+EXPORT_SYMBOL_GPL(nfs_write_inode);
 
 /*
  * flush the inode to disk.
Signature · 1 line
1.7.9
#11 lore raw

RFC 12/21 NFS: module-specific submount function

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This gives v4 the chance to check for referrals and allows each version to pass their own xdev_fs_type structure.

---
 fs/nfs/namespace.c     |   54 ++++++++++++++++++-----------------------------
 fs/nfs/nfs.h           |    5 ++++
 fs/nfs/nfs2super.c     |    9 ++++++++
 fs/nfs/nfs3super.c     |    9 ++++++++
 fs/nfs/nfs4_fs.h       |    3 ++
 fs/nfs/nfs4namespace.c |   11 +++++++++
 fs/nfs/nfs4super.c     |    1 +
 fs/nfs/super.c         |    1 +
 8 files changed, 60 insertions(+), 33 deletions(-)
fs/nfs/namespace.c +21 -33
index 8102391..31c3fcb 100644
@@ -7,6 +7,7 @@
  * NFS namespace
  */
 
+#include <linux/module.h>
 #include <linux/dcache.h>
 #include <linux/gfp.h>
 #include <linux/mount.h>
@@ -26,7 +27,8 @@ static LIST_HEAD(nfs_automount_list);
 static DECLARE_DELAYED_WORK(nfs_automount_task, nfs_expire_automounts);
 int nfs_mountpoint_expiry_timeout = 500 * HZ;
 
-static struct vfsmount *nfs_do_submount(struct dentry *dentry,
+static struct vfsmount *nfs_do_submount(struct nfs_server *server,
+					struct dentry *dentry,
 					struct nfs_fh *fh,
 					struct nfs_fattr *fattr,
 					rpc_authflavor_t authflavor);
@@ -260,10 +262,7 @@ struct vfsmount *nfs_d_automount(struct path *path)
 		goto out;
 	}
 
-	if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)
-		mnt = nfs_do_refmount(path->dentry);
-	else
-		mnt = nfs_do_submount(path->dentry, fh, fattr, flavor);
+	mnt = nfs_do_submount(server, path->dentry, fh, fattr, flavor);
 	if (IS_ERR(mnt))
 		goto out;
 
@@ -302,29 +301,6 @@ void nfs_release_automount_timer(void)
 		cancel_delayed_work(&nfs_automount_task);
 }
 
-/*
- * Clone a mountpoint of the appropriate type
- */
-static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
-					   const char *devname,
-					   struct nfs_clone_mount *mountdata)
-{
-#ifdef CONFIG_NFS_V4
-	struct vfsmount *mnt = ERR_PTR(-EINVAL);
-	switch (server->nfs_client->rpc_ops->version) {
-		case 2:
-		case 3:
-			mnt = vfs_kern_mount(&nfs_xdev_fs_type, 0, devname, mountdata);
-			break;
-		case 4:
-			mnt = vfs_kern_mount(&nfs4_xdev_fs_type, 0, devname, mountdata);
-	}
-	return mnt;
-#else
-	return vfs_kern_mount(&nfs_xdev_fs_type, 0, devname, mountdata);
-#endif
-}
-
 /**
  * nfs_do_submount - set up mountpoint when crossing a filesystem boundary
  * @dentry - parent directory
@@ -333,10 +309,11 @@ static struct vfsmount *nfs_do_clone_mount(struct nfs_server *server,
  * @authflavor - security flavor to use when performing the mount
  *
  */
-static struct vfsmount *nfs_do_submount(struct dentry *dentry,
-					struct nfs_fh *fh,
-					struct nfs_fattr *fattr,
-					rpc_authflavor_t authflavor)
+struct vfsmount *_nfs_do_submount(struct file_system_type *xdev,
+				  struct dentry *dentry,
+				  struct nfs_fh *fh,
+				  struct nfs_fattr *fattr,
+				  rpc_authflavor_t authflavor)
 {
 	struct nfs_clone_mount mountdata = {
 		.sb = dentry->d_sb,
@@ -360,7 +337,7 @@ static struct vfsmount *nfs_do_submount(struct dentry *dentry,
 	mnt = (struct vfsmount *)devname;
 	if (IS_ERR(devname))
 		goto free_page;
-	mnt = nfs_do_clone_mount(NFS_SB(dentry->d_sb), devname, &mountdata);
+	mnt = vfs_kern_mount(xdev, 0, devname, &mountdata);
 free_page:
 	free_page((unsigned long)page);
 out:
@@ -369,3 +346,14 @@ out:
 	dprintk("<-- nfs_do_submount() = %p\n", mnt);
 	return mnt;
 }
+EXPORT_SYMBOL_GPL(_nfs_do_submount);
+
+static struct vfsmount *nfs_do_submount(struct nfs_server *server,
+					struct dentry *dentry,
+					struct nfs_fh *fh,
+					struct nfs_fattr *fattr,
+					rpc_authflavor_t authflavor)
+{
+	struct nfs_subversion *nfs_mod = get_nfs_server_version(server);
+	return nfs_mod->submount(dentry, fh, fattr, authflavor);
+}
fs/nfs/nfs.h +5 -0
index dc1854c..dd3496a 100644
@@ -27,6 +27,7 @@ struct nfs_subversion {
 	struct dentry *(*fs_mount)(struct file_system_type *, int, const char *,
 				   struct nfs_fh *, struct nfs_parsed_mount_data *);
 	struct dentry *(*xdev_mount)(int, const char *, struct nfs_clone_mount *);
+	struct vfsmount *(*submount)(struct dentry *, struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
 };
 
 struct nfs_sb_mountdata {
@@ -57,6 +58,10 @@ int nfs_link(struct dentry *, struct inode *, struct dentry *);
 int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
 int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
 
+/* Exported in namespace.c */
+struct vfsmount *_nfs_do_submount(struct file_system_type *, struct dentry *,
+				  struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
+
 /* Exported in super.c */
 extern struct file_system_type nfs_fs_type;
 struct dentry *_nfs_fs_mount(struct file_system_type *, struct nfs_server *,
fs/nfs/nfs2super.c +9 -0
index ddcc4d1..6d2a1fd 100644
@@ -39,6 +39,14 @@ static struct dentry *nfs2_xdev_mount(int flags, const char *dev_name,
 	return _nfs_xdev_mount(&nfs_fs_type, server, flags, dev_name, data, NFS_MOUNT_UNSHARED);
 }
 
+static struct vfsmount *nfs2_do_submount(struct dentry *dentry,
+					 struct nfs_fh *fh,
+					 struct nfs_fattr *fattr,
+					 rpc_authflavor_t authflavor)
+{
+	return _nfs_do_submount(&nfs_xdev_fs_type, dentry, fh, fattr, authflavor);
+}
+
 static struct nfs_subversion nfs_v2 = {
 	.version  = 2,
 	.rpc_vers = &nfs_version2,
@@ -48,6 +56,7 @@ static struct nfs_subversion nfs_v2 = {
 	.unreference = nfs2_unreference,
 	.fs_mount = nfs2_fs_mount,
 	.xdev_mount = nfs2_xdev_mount,
+	.submount = nfs2_do_submount,
 };
 
 static int __init init_nfs_v2(void)
fs/nfs/nfs3super.c +9 -0
index 474840f..c8ca918 100644
@@ -41,6 +41,14 @@ static struct dentry *nfs3_xdev_mount(int flags, const char *dev_name,
 	return _nfs_xdev_mount(&nfs_fs_type, server, flags, dev_name, data, NFS_MOUNT_UNSHARED);
 }
 
+static struct vfsmount *nfs3_do_submount(struct dentry *dentry,
+					 struct nfs_fh *fh,
+					 struct nfs_fattr *fattr,
+					 rpc_authflavor_t authflavor)
+{
+	return _nfs_do_submount(&nfs_xdev_fs_type, dentry, fh, fattr, authflavor);
+}
+
 const struct inode_operations nfs3_file_inode_operations = {
 	.permission	= nfs_permission,
 	.getattr	= nfs_getattr,
@@ -79,6 +87,7 @@ static struct nfs_subversion nfs_v3 = {
 	.unreference = nfs3_unreference,
 	.fs_mount = nfs3_fs_mount,
 	.xdev_mount = nfs3_xdev_mount,
+	.submount = nfs3_do_submount,
 };
 
 int __init init_nfs_v3(void)
fs/nfs/nfs4_fs.h +3 -0
index 1147640..2328d68 100644
@@ -210,6 +210,9 @@ extern const struct inode_operations nfs4_dir_inode_operations;
 extern struct file_system_type nfs4_fs_type;
 struct dentry *nfs4_try_mount(int flags, const char *dev_name, struct nfs_parsed_mount_data *);
 
+/* nfs4namespace.c */
+struct vfsmount *nfs4_do_submount(struct dentry *, struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
+
 /* nfs4proc.c */
 extern int nfs4_proc_setclientid(struct nfs_client *, u32, unsigned short, struct rpc_cred *, struct nfs4_setclientid_res *);
 extern int nfs4_proc_setclientid_confirm(struct nfs_client *, struct nfs4_setclientid_res *arg, struct rpc_cred *);
fs/nfs/nfs4namespace.c +11 -0
index 48a9acd..92a5b9a 100644
@@ -19,6 +19,7 @@
 #include "internal.h"
 #include "nfs4_fs.h"
 #include "dns_resolve.h"
+#include "nfs.h"
 
 #define NFSDBG_FACILITY		NFSDBG_VFS
 
@@ -265,3 +266,13 @@ out:
 	dprintk("%s: done\n", __func__);
 	return mnt;
 }
+
+struct vfsmount *nfs4_do_submount(struct dentry *dentry,
+				  struct nfs_fh *fh,
+				  struct nfs_fattr *fattr,
+				  rpc_authflavor_t authflavor)
+{
+	if (fattr->valid & NFS_ATTR_FATTR_V4_REFERRAL)
+		return nfs_do_refmount(dentry);
+	return _nfs_do_submount(&nfs4_xdev_fs_type, dentry, fh, fattr, authflavor);
+}
fs/nfs/nfs4super.c +1 -0
index b35840e..d9bd619 100644
@@ -619,6 +619,7 @@ static struct nfs_subversion nfs_v4 = {
 	.unreference = nfs4_unreference,
 	.fs_mount = nfs4_fs_mount,
 	.xdev_mount = nfs4_xdev_mount,
+	.submount = nfs4_do_submount,
 };
 
 int __init init_nfs_v4(void)
fs/nfs/super.c +1 -0
index 30e903c..c8fcec5 100644
@@ -284,6 +284,7 @@ struct file_system_type nfs_xdev_fs_type = {
 	.kill_sb	= nfs_kill_super,
 	.fs_flags	= FS_RENAME_DOES_D_MOVE|FS_REVAL_DOT|FS_BINARY_MOUNTDATA,
 };
+EXPORT_SYMBOL_GPL(nfs_xdev_fs_type);
 
 static const struct super_operations nfs_sops = {
 	.alloc_inode	= nfs_alloc_inode,
Signature · 1 line
1.7.9
#12 lore raw

RFC 13/21 NFS: Custom alloc and free client functions for modules

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This gives v4 a chance to do any setup and teardown that it needs (such as pnfs or v4.1 sessions).

---
 fs/nfs/Makefile     |    2 +-
 fs/nfs/client.c     |   95 ++++++++++++--------------------------------------
 fs/nfs/nfs.h        |   15 ++++++++
 fs/nfs/nfs2super.c  |    2 +
 fs/nfs/nfs3super.c  |    2 +
 fs/nfs/nfs4_fs.h    |    4 ++
 fs/nfs/nfs4client.c |   80 +++++++++++++++++++++++++++++++++++++++++++
 fs/nfs/nfs4super.c  |    2 +
 8 files changed, 129 insertions(+), 73 deletions(-)
 create mode 100644 fs/nfs/nfs4client.c
fs/nfs/Makefile +1 -1
index 92ebf2f..1961606 100644
@@ -12,7 +12,7 @@ nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 			   nfs4super.o delegation.o idmap.o \
 			   callback.o callback_xdr.o callback_proc.o \
-			   nfs4namespace.o
+			   nfs4namespace.o nfs4client.o
 nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
 nfs-$(CONFIG_SYSCTL) += sysctl.o nfs4sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
fs/nfs/client.c +23 -72

170 lines not on this page · raw message

fs/nfs/nfs.h +15 -0
index dd3496a..e538207 100644
@@ -16,6 +16,16 @@
 struct nfs_parsed_mount_data;
 struct nfs_clone_mount;
 
+struct nfs_client_initdata {
+	const char *hostname;
+	const struct sockaddr *addr;
+	size_t addrlen;
+	const struct nfs_rpc_ops *rpc_ops;
+	int proto;
+	u32 minorversion;
+	struct net *net;
+};
+
 struct nfs_subversion {
 	unsigned int version;		/* Protocol number */
 	struct rpc_version *rpc_vers;	/* NFS version information */
@@ -24,6 +34,8 @@ struct nfs_subversion {
 
 	void (*reference)(void);	/* For reference counting */
 	void (*unreference)(void);	/* Also for reference counting */
+	struct nfs_client *(*alloc_client)(const struct nfs_client_initdata *);
+	void (*free_client)(struct nfs_client *);
 	struct dentry *(*fs_mount)(struct file_system_type *, int, const char *,
 				   struct nfs_fh *, struct nfs_parsed_mount_data *);
 	struct dentry *(*xdev_mount)(int, const char *, struct nfs_clone_mount *);
@@ -45,7 +57,10 @@ void register_nfs_version(struct nfs_subversion *);
 void unregister_nfs_version(struct nfs_subversion *);
 
 /* Exported in client.c */
+int nfs_get_cb_ident_idr(struct nfs_client *, int);
 struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
+struct nfs_client *_nfs_alloc_client(const struct nfs_client_initdata *);
+void _nfs_free_client(struct nfs_client *);
 
 /* Exported in dir.c */
 struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *);
fs/nfs/nfs2super.c +2 -0
index 6d2a1fd..697356f 100644
@@ -54,6 +54,8 @@ static struct nfs_subversion nfs_v2 = {
 
 	.reference = nfs2_reference,
 	.unreference = nfs2_unreference,
+	.alloc_client = _nfs_alloc_client,
+	.free_client = _nfs_free_client,
 	.fs_mount = nfs2_fs_mount,
 	.xdev_mount = nfs2_xdev_mount,
 	.submount = nfs2_do_submount,
fs/nfs/nfs3super.c +2 -0
index c8ca918..d17ca8e 100644
@@ -85,6 +85,8 @@ static struct nfs_subversion nfs_v3 = {
 
 	.reference = nfs3_reference,
 	.unreference = nfs3_unreference,
+	.alloc_client = _nfs_alloc_client,
+	.free_client = _nfs_free_client,
 	.fs_mount = nfs3_fs_mount,
 	.xdev_mount = nfs3_xdev_mount,
 	.submount = nfs3_do_submount,
fs/nfs/nfs4_fs.h +4 -0
index 2328d68..9a27673 100644
@@ -210,6 +210,10 @@ extern const struct inode_operations nfs4_dir_inode_operations;
 extern struct file_system_type nfs4_fs_type;
 struct dentry *nfs4_try_mount(int flags, const char *dev_name, struct nfs_parsed_mount_data *);
 
+/* nfs4client.c */
+struct nfs_client *nfs4_alloc_client(const struct nfs_client_initdata *);
+void nfs4_free_client(struct nfs_client *);
+
 /* nfs4namespace.c */
 struct vfsmount *nfs4_do_submount(struct dentry *, struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
 
fs/nfs/nfs4client.c new file +80 -0

80 lines not on this page · raw message

fs/nfs/nfs4super.c +2 -0
index d9bd619..d874d2f 100644
@@ -617,6 +617,8 @@ static struct nfs_subversion nfs_v4 = {
 
 	.reference = nfs4_reference,
 	.unreference = nfs4_unreference,
+	.alloc_client = nfs4_alloc_client,
+	.free_client = nfs4_free_client,
 	.fs_mount = nfs4_fs_mount,
 	.xdev_mount = nfs4_xdev_mount,
 	.submount = nfs4_do_submount,
Signature · 1 line
1.7.9
#13 lore raw

RFC 14/21 NFS: Move nfs4_set_client() and support code to nfs4client.c

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This chunk of code is only used by NFS v4, so it can safely move to a v4-only file that won't even be compiled if v4 isn't selected. This also helps to avoid future modpost errors when v4 is turned into a module.

---
 fs/nfs/client.c     |  356 +++------------------------------------------------
 fs/nfs/nfs.h        |   12 ++-
 fs/nfs/nfs4client.c |  335 ++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 362 insertions(+), 341 deletions(-)
fs/nfs/client.c +16 -340
index bf90169..69b563d 100644
@@ -85,10 +85,6 @@ retry:
 }
 EXPORT_SYMBOL_GPL(nfs_get_cb_ident_idr);
 #endif /* CONFIG_NFS_V4 */
-/*
- * Turn off NFSv4 uid/gid mapping when using AUTH_SYS
- */
-static bool nfs4_disable_idmapping = true;
 
 /*
  * RPC cruft for NFS
@@ -228,11 +224,6 @@ static void pnfs_init_server(struct nfs_server *server)
 	rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC");
 }
 
-static void nfs4_destroy_server(struct nfs_server *server)
-{
-	nfs4_purge_state_owners(server);
-}
-
 /* idr_remove_all is not needed as all id's are removed by nfs_put_client */
 void nfs_cleanup_cb_ident_idr(void)
 {
@@ -485,7 +476,7 @@ static struct nfs_client *nfs_match_client(const struct nfs_client_initdata *dat
  * Look up a client by IP address and protocol version
  * - creates a new record if one doesn't yet exist
  */
-static struct nfs_client *
+struct nfs_client *
 nfs_get_client(const struct nfs_client_initdata *cl_init,
 	       const struct rpc_timeout *timeparms,
 	       const char *ip_addr,
@@ -558,6 +549,7 @@ found_client:
 	dprintk("--> nfs_get_client() = %p [share]\n", clp);
 	return clp;
 }
+EXPORT_SYMBOL_GPL(nfs_get_client);
 
 /*
  * Mark a server as ready or failed
@@ -587,8 +579,8 @@ int nfs4_check_client_ready(struct nfs_client *clp)
 /*
  * Initialise the timeout values for a connection
  */
-static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
-				    unsigned int timeo, unsigned int retrans)
+void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
+			     unsigned int timeo, unsigned int retrans)
 {
 	to->to_initval = timeo * HZ / 10;
 	to->to_retries = retrans;
@@ -624,6 +616,7 @@ static void nfs_init_timeout_values(struct rpc_timeout *to, int proto,
 		BUG();
 	}
 }
+EXPORT_SYMBOL_GPL(nfs_init_timeout_values);
 
 /*
  * Create an RPC client handle
@@ -717,7 +710,7 @@ static int nfs_start_lockd(struct nfs_server *server)
 /*
  * Create a general RPC client
  */
-static int nfs_init_server_rpcclient(struct nfs_server *server,
+int nfs_init_server_rpcclient(struct nfs_server *server,
 		const struct rpc_timeout *timeo,
 		rpc_authflavor_t pseudoflavour)
 {
@@ -749,6 +742,7 @@ static int nfs_init_server_rpcclient(struct nfs_server *server,
 
 	return 0;
 }
+EXPORT_SYMBOL_GPL(nfs_init_server_rpcclient);
 
 /*
  * Initialise an NFS2 or NFS3 client
@@ -933,7 +927,7 @@ static void nfs_server_set_fsinfo(struct nfs_server *server,
 /*
  * Probe filesystem information, including the FSID on v2/v3
  */
-static int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs_fattr *fattr)
+int nfs_probe_fsinfo(struct nfs_server *server, struct nfs_fh *mntfh, struct nfs_fattr *fattr)
 {
 	struct nfs_fsinfo fsinfo;
 	struct nfs_client *clp = server->nfs_client;
@@ -973,11 +967,12 @@ out_error:
 	dprintk("nfs_probe_fsinfo: error = %d\n", -error);
 	return error;
 }
+EXPORT_SYMBOL_GPL(nfs_probe_fsinfo);
 
 /*
  * Copy useful information when duplicating a server record
  */
-static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source)
+void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_server *source)
 {
 	target->flags = source->flags;
 	target->rsize = source->rsize;
@@ -989,8 +984,9 @@ static void nfs_server_copy_userdata(struct nfs_server *target, struct nfs_serve
 	target->caps = source->caps;
 	target->options = source->options;
 }
+EXPORT_SYMBOL_GPL(nfs_server_copy_userdata);
 
-static void nfs_server_insert_lists(struct nfs_server *server)
+void nfs_server_insert_lists(struct nfs_server *server)
 {
 	struct nfs_client *clp = server->nfs_client;
 
@@ -1001,6 +997,7 @@ static void nfs_server_insert_lists(struct nfs_server *server)
 	spin_unlock(&nfs_client_lock);
 
 }
+EXPORT_SYMBOL_GPL(nfs_server_insert_lists);
 
 static void nfs_server_remove_lists(struct nfs_server *server)
 {
@@ -1019,7 +1016,7 @@ static void nfs_server_remove_lists(struct nfs_server *server)
 /*
  * Allocate and initialise a server record
  */
-static struct nfs_server *nfs_alloc_server(void)
+struct nfs_server *nfs_alloc_server(void)
 {
 	struct nfs_server *server;
 
@@ -1056,6 +1053,7 @@ static struct nfs_server *nfs_alloc_server(void)
 
 	return server;
 }
+EXPORT_SYMBOL_GPL(nfs_alloc_server);
 
 /*
  * Free up a server record
@@ -1085,6 +1083,7 @@ void nfs_free_server(struct nfs_server *server)
 	nfs_release_automount_timer();
 	dprintk("<-- nfs_free_server()\n");
 }
+EXPORT_SYMBOL_GPL(nfs_free_server);
 
 /*
  * Create a version 2 or 3 volume record
@@ -1325,325 +1324,6 @@ error:
 	return error;
 }
 
-/*
- * Set up an NFS4 client
- */
-static int nfs4_set_client(struct nfs_server *server,
-		const char *hostname,
-		const struct sockaddr *addr,
-		const size_t addrlen,
-		const char *ip_addr,
-		rpc_authflavor_t authflavour,
-		int proto, const struct rpc_timeout *timeparms,
-		u32 minorversion, struct net *net)
-{
-	struct nfs_client_initdata cl_init = {
-		.hostname = hostname,
-		.addr = addr,
-		.addrlen = addrlen,
-		.rpc_ops = &nfs_v4_clientops,
-		.proto = proto,
-		.minorversion = minorversion,
-		.net = net,
-	};
-	struct nfs_client *clp;
-	int error;
-
-	dprintk("--> nfs4_set_client()\n");
-
-	/* Allocate or find a client reference we can use */
-	clp = nfs_get_client(&cl_init, timeparms, ip_addr, authflavour,
-			     server->flags & NFS_MOUNT_NORESVPORT);
-	if (IS_ERR(clp)) {
-		error = PTR_ERR(clp);
-		goto error;
-	}
-
-	/*
-	 * Query for the lease time on clientid setup or renewal
-	 *
-	 * Note that this will be set on nfs_clients that were created
-	 * only for the DS role and did not set this bit, but now will
-	 * serve a dual role.
-	 */
-	set_bit(NFS_CS_CHECK_LEASE_TIME, &clp->cl_res_state);
-
-	server->nfs_client = clp;
-	dprintk("<-- nfs4_set_client() = 0 [new %p]\n", clp);
-	return 0;
-error:
-	dprintk("<-- nfs4_set_client() = xerror %d\n", error);
-	return error;
-}
-
-/*
- * Set up a pNFS Data Server client.
- *
- * Return any existing nfs_client that matches server address,port,version
- * and minorversion.
- *
- * For a new nfs_client, use a soft mount (default), a low retrans and a
- * low timeout interval so that if a connection is lost, we retry through
- * the MDS.
- */
-struct nfs_client *nfs4_set_ds_client(struct nfs_client* mds_clp,
-		const struct sockaddr *ds_addr,
-		int ds_addrlen, int ds_proto)
-{
-	struct nfs_client_initdata cl_init = {
-		.addr = ds_addr,
-		.addrlen = ds_addrlen,
-		.rpc_ops = &nfs_v4_clientops,
-		.proto = ds_proto,
-		.minorversion = mds_clp->cl_minorversion,
-		.net = mds_clp->net,
-	};
-	struct rpc_timeout ds_timeout = {
-		.to_initval = 15 * HZ,
-		.to_maxval = 15 * HZ,
-		.to_retries = 1,
-		.to_exponential = 1,
-	};
-	struct nfs_client *clp;
-
-	/*
-	 * Set an authflavor equual to the MDS value. Use the MDS nfs_client
-	 * cl_ipaddr so as to use the same EXCHANGE_ID co_ownerid as the MDS
-	 * (section 13.1 RFC 5661).
-	 */
-	clp = nfs_get_client(&cl_init, &ds_timeout, mds_clp->cl_ipaddr,
-			     mds_clp->cl_rpcclient->cl_auth->au_flavor, 0);
-
-	dprintk("<-- %s %p\n", __func__, clp);
-	return clp;
-}
-EXPORT_SYMBOL_GPL(nfs4_set_ds_client);
-
-/*
- * Session has been established, and the client marked ready.
- * Set the mount rsize and wsize with negotiated fore channel
- * attributes which will be bound checked in nfs_server_set_fsinfo.
- */
-static void nfs4_session_set_rwsize(struct nfs_server *server)
-{
-#ifdef CONFIG_NFS_V4_1
-	struct nfs4_session *sess;
-	u32 server_resp_sz;
-	u32 server_rqst_sz;
-
-	if (!nfs4_has_session(server->nfs_client))
-		return;
-	sess = server->nfs_client->cl_session;
-	server_resp_sz = sess->fc_attrs.max_resp_sz - nfs41_maxread_overhead;
-	server_rqst_sz = sess->fc_attrs.max_rqst_sz - nfs41_maxwrite_overhead;
-
-	if (server->rsize > server_resp_sz)
-		server->rsize = server_resp_sz;
-	if (server->wsize > server_rqst_sz)
-		server->wsize = server_rqst_sz;
-#endif /* CONFIG_NFS_V4_1 */
-}
-
-static int nfs4_server_common_setup(struct nfs_server *server,
-		struct nfs_fh *mntfh)
-{
-	struct nfs_fattr *fattr;
-	int error;
-
-	BUG_ON(!server->nfs_client);
-	BUG_ON(!server->nfs_client->rpc_ops);
-	BUG_ON(!server->nfs_client->rpc_ops->file_inode_ops);
-
-	/* data servers support only a subset of NFSv4.1 */
-	if (is_ds_only_client(server->nfs_client))
-		return -EPROTONOSUPPORT;
-
-	fattr = nfs_alloc_fattr();
-	if (fattr == NULL)
-		return -ENOMEM;
-
-	/* We must ensure the session is initialised first */
-	error = nfs4_init_session(server);
-	if (error < 0)
-		goto out;
-
-	/* Probe the root fh to retrieve its FSID and filehandle */
-	error = nfs4_get_rootfh(server, mntfh);
-	if (error < 0)
-		goto out;
-
-	dprintk("Server FSID: %llx:%llx\n",
-			(unsigned long long) server->fsid.major,
-			(unsigned long long) server->fsid.minor);
-	dprintk("Mount FH: %d\n", mntfh->size);
-
-	nfs4_session_set_rwsize(server);
-
-	error = nfs_probe_fsinfo(server, mntfh, fattr);
-	if (error < 0)
-		goto out;
-
-	if (server->namelen == 0 || server->namelen > NFS4_MAXNAMLEN)
-		server->namelen = NFS4_MAXNAMLEN;
-
-	nfs_server_insert_lists(server);
-	server->mount_time = jiffies;
-	server->destroy = nfs4_destroy_server;
-out:
-	nfs_free_fattr(fattr);
-	return error;
-}
-
-/*
- * Create a version 4 volume record
- */
-static int nfs4_init_server(struct nfs_server *server,
-		const struct nfs_parsed_mount_data *data)
-{
-	struct rpc_timeout timeparms;
-	int error;
-
-	dprintk("--> nfs4_init_server()\n");
-
-	nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
-			data->timeo, data->retrans);
-
-	/* Initialise the client representation from the mount data */
-	server->flags = data->flags;
-	server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR|NFS_CAP_POSIX_LOCK;
-	if (!(data->flags & NFS_MOUNT_NORDIRPLUS))
-			server->caps |= NFS_CAP_READDIRPLUS;
-	server->options = data->options;
-
-	/* Get a client record */
-	error = nfs4_set_client(server,
-			data->nfs_server.hostname,
-			(const struct sockaddr *)&data->nfs_server.address,
-			data->nfs_server.addrlen,
-			data->client_address,
-			data->auth_flavors[0],
-			data->nfs_server.protocol,
-			&timeparms,
-			data->minorversion,
-			data->net);
-	if (error < 0)
-		goto error;
-
-	/*
-	 * Don't use NFS uid/gid mapping if we're using AUTH_SYS or lower
-	 * authentication.
-	 */
-	if (nfs4_disable_idmapping && data->auth_flavors[0] == RPC_AUTH_UNIX)
-		server->caps |= NFS_CAP_UIDGID_NOMAP;
-
-	if (data->rsize)
-		server->rsize = nfs_block_size(data->rsize, NULL);
-	if (data->wsize)
-		server->wsize = nfs_block_size(data->wsize, NULL);
-
-	server->acregmin = data->acregmin * HZ;
-	server->acregmax = data->acregmax * HZ;
-	server->acdirmin = data->acdirmin * HZ;
-	server->acdirmax = data->acdirmax * HZ;
-
-	server->port = data->nfs_server.port;
-
-	error = nfs_init_server_rpcclient(server, &timeparms, data->auth_flavors[0]);
-
-error:
-	/* Done */
-	dprintk("<-- nfs4_init_server() = %d\n", error);
-	return error;
-}
-
-/*
- * Create a version 4 volume record
- * - keyed on server and FSID
- */
-struct nfs_server *nfs4_create_server(const struct nfs_parsed_mount_data *data,
-				      struct nfs_fh *mntfh)
-{
-	struct nfs_server *server;
-	int error;
-
-	dprintk("--> nfs4_create_server()\n");
-
-	server = nfs_alloc_server();
-	if (!server)
-		return ERR_PTR(-ENOMEM);
-
-	/* set up the general RPC client */
-	error = nfs4_init_server(server, data);
-	if (error < 0)
-		goto error;
-
-	error = nfs4_server_common_setup(server, mntfh);
-	if (error < 0)
-		goto error;
-
-	dprintk("<-- nfs4_create_server() = %p\n", server);
-	return server;
-
-error:
-	nfs_free_server(server);
-	dprintk("<-- nfs4_create_server() = error %d\n", error);
-	return ERR_PTR(error);
-}
-
-/*
- * Create an NFS4 referral server record
- */
-struct nfs_server *nfs4_create_referral_server(struct nfs_clone_mount *data,
-					       struct nfs_fh *mntfh)
-{
-	struct nfs_client *parent_client;
-	struct nfs_server *server, *parent_server;
-	int error;
-
-	dprintk("--> nfs4_create_referral_server()\n");
-
-	server = nfs_alloc_server();
-	if (!server)
-		return ERR_PTR(-ENOMEM);
-
-	parent_server = NFS_SB(data->sb);
-	parent_client = parent_server->nfs_client;
-
-	/* Initialise the client representation from the parent server */
-	nfs_server_copy_userdata(server, parent_server);
-	server->caps |= NFS_CAP_ATOMIC_OPEN|NFS_CAP_CHANGE_ATTR;
-
-	/* Get a client representation.
-	 * Note: NFSv4 always uses TCP, */
-	error = nfs4_set_client(server, data->hostname,
-				data->addr,
-				data->addrlen,
-				parent_client->cl_ipaddr,
-				data->authflavor,
-				parent_server->client->cl_xprt->prot,
-				parent_server->client->cl_timeout,
-				parent_client->cl_mvops->minor_version,
-				parent_client->net);
-	if (error < 0)
-		goto error;
-
-	error = nfs_init_server_rpcclient(server, parent_server->client->cl_timeout, data->authflavor);
-	if (error < 0)
-		goto error;
-
-	error = nfs4_server_common_setup(server, mntfh);
-	if (error < 0)
-		goto error;
-
-	dprintk("<-- nfs_create_referral_server() = %p\n", server);
-	return server;
-
-error:
-	nfs_free_server(server);
-	dprintk("<-- nfs4_create_referral_server() = error %d\n", error);
-	return ERR_PTR(error);
-}
-
 #endif /* CONFIG_NFS_V4 */
 
 /*
@@ -2025,7 +1705,3 @@ int nfs_stat_to_errno(enum nfs_stat status)
 	return nfs_errtbl[i].errno;
 }
 EXPORT_SYMBOL_GPL(nfs_stat_to_errno);
-
-module_param(nfs4_disable_idmapping, bool, 0644);
-MODULE_PARM_DESC(nfs4_disable_idmapping,
-		"Turn off NFSv4 idmapping when using 'sec=sys'");
fs/nfs/nfs.h +11 -1
index e538207..1934399 100644
@@ -58,9 +58,19 @@ void unregister_nfs_version(struct nfs_subversion *);
 
 /* Exported in client.c */
 int nfs_get_cb_ident_idr(struct nfs_client *, int);
-struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
 struct nfs_client *_nfs_alloc_client(const struct nfs_client_initdata *);
 void _nfs_free_client(struct nfs_client *);
+struct nfs_client *nfs_get_client(const struct nfs_client_initdata *,
+				  const struct rpc_timeout *, const char *,
+				  rpc_authflavor_t, int);
+void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int);
+int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *,
+			      rpc_authflavor_t);
+int nfs_probe_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *);
+void nfs_server_copy_userdata(struct nfs_server *, struct nfs_server *);
+void nfs_server_insert_lists(struct nfs_server *);
+struct nfs_server *nfs_alloc_server(void);
+struct nfs_server *nfs_create_server(const struct nfs_parsed_mount_data *, struct nfs_fh *);
 
 /* Exported in dir.c */
 struct dentry *nfs_lookup(struct inode *, struct dentry *, struct nameidata *);
fs/nfs/nfs4client.c +335 -0

357 lines not on this page · raw message

Signature · 1 line
1.7.9
#14 lore raw

RFC 15/21 NFS: Move the nfs4_init_client() to nfs4client.c

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

---
 fs/nfs/client.c     |  117 ++------------------------------------------------
 fs/nfs/nfs.h        |    2 +
 fs/nfs/nfs4client.c |  108 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 115 insertions(+), 112 deletions(-)
fs/nfs/client.c +5 -112
index 69b563d..b709c38 100644
@@ -38,7 +38,6 @@
 #include <linux/slab.h>
 #include <net/ipv6.h>
 #include <linux/nfs_xdr.h>
-#include <linux/sunrpc/bc_xprt.h>
 
 #include <asm/system.h>
 
@@ -621,10 +620,10 @@ EXPORT_SYMBOL_GPL(nfs_init_timeout_values);
 /*
  * Create an RPC client handle
  */
-static int nfs_create_rpc_client(struct nfs_client *clp,
-				 const struct rpc_timeout *timeparms,
-				 rpc_authflavor_t flavor,
-				 int discrtry, int noresvport)
+int nfs_create_rpc_client(struct nfs_client *clp,
+			  const struct rpc_timeout *timeparms,
+			  rpc_authflavor_t flavor,
+			  int discrtry, int noresvport)
 {
 	struct rpc_clnt		*clnt = NULL;
 	struct rpc_create_args args = {
@@ -657,6 +656,7 @@ static int nfs_create_rpc_client(struct nfs_client *clp,
 	clp->cl_rpcclient = clnt;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(nfs_create_rpc_client);
 
 /*
  * Version 2 or 3 client destruction
@@ -1217,113 +1217,6 @@ nfs4_find_client_sessionid(const struct sockaddr *addr,
 }
 #endif /* CONFIG_NFS_V4_1 */
 
-/*
- * Initialize the NFS4 callback service
- */
-static int nfs4_init_callback(struct nfs_client *clp)
-{
-	int error;
-
-	if (clp->rpc_ops->version == 4) {
-		if (nfs4_has_session(clp)) {
-			error = xprt_setup_backchannel(
-						clp->cl_rpcclient->cl_xprt,
-						NFS41_BC_MIN_CALLBACKS);
-			if (error < 0)
-				return error;
-		}
-
-		error = nfs_callback_up(clp->cl_mvops->minor_version,
-					clp->cl_rpcclient->cl_xprt);
-		if (error < 0) {
-			dprintk("%s: failed to start callback. Error = %d\n",
-				__func__, error);
-			return error;
-		}
-		__set_bit(NFS_CS_CALLBACK, &clp->cl_res_state);
-	}
-	return 0;
-}
-
-/*
- * Initialize the minor version specific parts of an NFS4 client record
- */
-static int nfs4_init_client_minor_version(struct nfs_client *clp)
-{
-#if defined(CONFIG_NFS_V4_1)
-	if (clp->cl_mvops->minor_version) {
-		struct nfs4_session *session = NULL;
-		/*
-		 * Create the session and mark it expired.
-		 * When a SEQUENCE operation encounters the expired session
-		 * it will do session recovery to initialize it.
-		 */
-		session = nfs4_alloc_session(clp);
-		if (!session)
-			return -ENOMEM;
-
-		clp->cl_session = session;
-		/*
-		 * The create session reply races with the server back
-		 * channel probe. Mark the client NFS_CS_SESSION_INITING
-		 * so that the client back channel can find the
-		 * nfs_client struct
-		 */
-		clp->cl_cons_state = NFS_CS_SESSION_INITING;
-	}
-#endif /* CONFIG_NFS_V4_1 */
-
-	return nfs4_init_callback(clp);
-}
-
-/*
- * Initialise an NFS4 client record
- */
-int nfs4_init_client(struct nfs_client *clp,
-		     const struct rpc_timeout *timeparms,
-		     const char *ip_addr,
-		     rpc_authflavor_t authflavour,
-		     int noresvport)
-{
-	int error;
-
-	if (clp->cl_cons_state == NFS_CS_READY) {
-		/* the client is initialised already */
-		dprintk("<-- nfs4_init_client() = 0 [already %p]\n", clp);
-		return 0;
-	}
-
-	/* Check NFS protocol revision and initialize RPC op vector */
-	clp->rpc_ops = &nfs_v4_clientops;
-
-	error = nfs_create_rpc_client(clp, timeparms, authflavour,
-				      1, noresvport);
-	if (error < 0)
-		goto error;
-	strlcpy(clp->cl_ipaddr, ip_addr, sizeof(clp->cl_ipaddr));
-
-	error = nfs_idmap_new(clp);
-	if (error < 0) {
-		dprintk("%s: failed to create idmapper. Error = %d\n",
-			__func__, error);
-		goto error;
-	}
-	__set_bit(NFS_CS_IDMAP, &clp->cl_res_state);
-
-	error = nfs4_init_client_minor_version(clp);
-	if (error < 0)
-		goto error;
-
-	if (!nfs4_has_session(clp))
-		nfs_mark_client_ready(clp, NFS_CS_READY);
-	return 0;
-
-error:
-	nfs_mark_client_ready(clp, error);
-	dprintk("<-- nfs4_init_client() = xerror %d\n", error);
-	return error;
-}
-
 #endif /* CONFIG_NFS_V4 */
 
 /*
fs/nfs/nfs.h +2 -0
index 1934399..38113b5 100644
@@ -64,6 +64,8 @@ struct nfs_client *nfs_get_client(const struct nfs_client_initdata *,
 				  const struct rpc_timeout *, const char *,
 				  rpc_authflavor_t, int);
 void nfs_init_timeout_values(struct rpc_timeout *, int, unsigned int, unsigned int);
+int nfs_create_rpc_client(struct nfs_client *, const struct rpc_timeout *,
+			  rpc_authflavor_t, int, int);
 int nfs_init_server_rpcclient(struct nfs_server *, const struct rpc_timeout *,
 			      rpc_authflavor_t);
 int nfs_probe_fsinfo(struct nfs_server *, struct nfs_fh *, struct nfs_fattr *);
fs/nfs/nfs4client.c +108 -0

120 lines not on this page · raw message

Signature · 1 line
1.7.9
#15 lore raw

RFC 16/21 NFS: Move the v4 getroot code to nfs4getroot.c

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

---
 fs/nfs/Makefile      |    2 +-
 fs/nfs/getroot.c     |  130 +-----------------------------------------------
 fs/nfs/nfs.h         |    3 +
 fs/nfs/nfs4getroot.c |  135 ++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 141 insertions(+), 129 deletions(-)
 create mode 100644 fs/nfs/nfs4getroot.c
fs/nfs/Makefile +1 -1
index 1961606..e983eb0 100644
@@ -12,7 +12,7 @@ nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 			   nfs4super.o delegation.o idmap.o \
 			   callback.o callback_xdr.o callback_proc.o \
-			   nfs4namespace.o nfs4client.o
+			   nfs4namespace.o nfs4client.o nfs4getroot.o
 nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
 nfs-$(CONFIG_SYSCTL) += sysctl.o nfs4sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
fs/nfs/getroot.c +2 -128

145 lines not on this page · raw message

fs/nfs/nfs.h +3 -0
index 38113b5..0c05f14 100644
@@ -85,6 +85,9 @@ int nfs_link(struct dentry *, struct inode *, struct dentry *);
 int nfs_mknod(struct inode *, struct dentry *, umode_t, dev_t);
 int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *);
 
+/* Exported in getroot.c */
+int nfs_superblock_set_dummy_root(struct super_block *, struct inode *);
+
 /* Exported in namespace.c */
 struct vfsmount *_nfs_do_submount(struct file_system_type *, struct dentry *,
 				  struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
fs/nfs/nfs4getroot.c new file +135 -0

135 lines not on this page · raw message

Signature · 1 line
1.7.9
#16 lore raw

RFC 17/21 NFS: Deal with delegations

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

Modules can implement their own have_delegation and return_delegation functions. If not, then a default value is returned. I also moved over the nfs4_evict_inode() function so it can find the return_delegation_noreclaim function.

---
 fs/nfs/delegation.c |    8 ++++----
 fs/nfs/delegation.h |    9 +++++----
 fs/nfs/inode.c      |   41 ++++++++++++++++++-----------------------
 fs/nfs/internal.h   |    3 ---
 fs/nfs/nfs.h        |    7 +++++++
 fs/nfs/nfs4proc.c   |    4 ++--
 fs/nfs/nfs4super.c  |   18 ++++++++++++++++++
 7 files changed, 54 insertions(+), 36 deletions(-)
fs/nfs/delegation.c +4 -4
index 7f26540..0430513 100644
@@ -41,13 +41,13 @@ void nfs_mark_delegation_referenced(struct nfs_delegation *delegation)
 }
 
 /**
- * nfs_have_delegation - check if inode has a delegation
+ * nfs4_have_delegation - check if inode has a delegation
  * @inode: inode to check
  * @flags: delegation types to check for
  *
  * Returns one if inode has the indicated delegation, otherwise zero.
  */
-int nfs_have_delegation(struct inode *inode, fmode_t flags)
+int nfs4_have_delegation(struct inode *inode, fmode_t flags)
 {
 	struct nfs_delegation *delegation;
 	int ret = 0;
@@ -376,12 +376,12 @@ void nfs_inode_return_delegation_noreclaim(struct inode *inode)
 }
 
 /**
- * nfs_inode_return_delegation - synchronously return a delegation
+ * nfs4_inode_return_delegation - synchronously return a delegation
  * @inode: inode to process
  *
  * Returns zero on success, or a negative errno value.
  */
-int nfs_inode_return_delegation(struct inode *inode)
+int nfs4_inode_return_delegation(struct inode *inode)
 {
 	struct nfs_server *server = NFS_SERVER(inode);
 	struct nfs_inode *nfsi = NFS_I(inode);
fs/nfs/delegation.h +5 -4
index d9322e4..0b388d7 100644
@@ -9,6 +9,7 @@
 #define FS_NFS_DELEGATION_H
 
 #if defined(CONFIG_NFS_V4)
+#include "nfs.h"
 /*
  * NFSv4 delegation
  */
@@ -33,7 +34,7 @@ enum {
 
 int nfs_inode_set_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
 void nfs_inode_reclaim_delegation(struct inode *inode, struct rpc_cred *cred, struct nfs_openres *res);
-int nfs_inode_return_delegation(struct inode *inode);
+int nfs4_inode_return_delegation(struct inode *inode);
 int nfs_async_inode_return_delegation(struct inode *inode, const nfs4_stateid *stateid);
 void nfs_inode_return_delegation_noreclaim(struct inode *inode);
 
@@ -56,15 +57,15 @@ int nfs4_lock_delegation_recall(struct nfs4_state *state, struct file_lock *fl);
 int nfs4_copy_delegation_stateid(nfs4_stateid *dst, struct inode *inode);
 
 void nfs_mark_delegation_referenced(struct nfs_delegation *delegation);
-int nfs_have_delegation(struct inode *inode, fmode_t flags);
+int nfs4_have_delegation(struct inode *inode, fmode_t flags);
 
 #else
-static inline int nfs_have_delegation(struct inode *inode, fmode_t flags)
+static inline int nfs4_have_delegation(struct inode *inode, fmode_t flags)
 {
 	return 0;
 }
 
-static inline int nfs_inode_return_delegation(struct inode *inode)
+static inline int nfs4_inode_return_delegation(struct inode *inode)
 {
 	return 0;
 }
fs/nfs/inode.c +18 -23

65 lines not on this page · raw message

fs/nfs/internal.h +0 -3
index cdb121d..4ea1b93 100644
@@ -258,9 +258,6 @@ extern struct inode *nfs_alloc_inode(struct super_block *sb);
 extern void nfs_destroy_inode(struct inode *);
 extern int nfs_write_inode(struct inode *, struct writeback_control *);
 extern void nfs_evict_inode(struct inode *);
-#ifdef CONFIG_NFS_V4
-extern void nfs4_evict_inode(struct inode *);
-#endif
 void nfs_zap_acl_cache(struct inode *inode);
 extern int nfs_wait_bit_killable(void *word);
 
fs/nfs/nfs.h +7 -0
index 0c05f14..a83e154 100644
@@ -40,6 +40,8 @@ struct nfs_subversion {
 				   struct nfs_fh *, struct nfs_parsed_mount_data *);
 	struct dentry *(*xdev_mount)(int, const char *, struct nfs_clone_mount *);
 	struct vfsmount *(*submount)(struct dentry *, struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
+	int (*have_delegation)(struct inode *, fmode_t);
+	int (*return_delegation)(struct inode *);
 };
 
 struct nfs_sb_mountdata {
@@ -88,6 +90,11 @@ int nfs_rename(struct inode *, struct dentry *, struct inode *, struct dentry *)
 /* Exported in getroot.c */
 int nfs_superblock_set_dummy_root(struct super_block *, struct inode *);
 
+/* inode.c */
+void nfs_clear_inode(struct inode *);
+int nfs_have_delegation(struct inode *, fmode_t);
+int nfs_inode_return_delegation(struct inode *);
+
 /* Exported in namespace.c */
 struct vfsmount *_nfs_do_submount(struct file_system_type *, struct dentry *,
 				  struct nfs_fh *, struct nfs_fattr *, rpc_authflavor_t);
fs/nfs/nfs4proc.c +2 -2
index 1bb0be3..3ae8485 100644
@@ -1028,7 +1028,7 @@ static void nfs4_return_incompatible_delegation(struct inode *inode, fmode_t fmo
 		return;
 	}
 	rcu_read_unlock();
-	nfs_inode_return_delegation(inode);
+	nfs4_inode_return_delegation(inode);
 }
 
 static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
@@ -3694,7 +3694,7 @@ static int __nfs4_proc_set_acl(struct inode *inode, const void *buf, size_t bufl
 	i = buf_to_pages_noslab(buf, buflen, arg.acl_pages, &arg.acl_pgbase);
 	if (i < 0)
 		return i;
-	nfs_inode_return_delegation(inode);
+	nfs4_inode_return_delegation(inode);
 	ret = nfs4_call_sync(server->client, server, &msg, &arg.seq_args, &res.seq_res, 1);
 
 	/*
fs/nfs/nfs4super.c +18 -0
index d874d2f..2764c28 100644
@@ -10,6 +10,7 @@
 #include "delegation.h"
 #include "fscache.h"
 #include "nfs4_fs.h"
+#include "pnfs.h"
 #include "nfs.h"
 
 #define NFSDBG_FACILITY		NFSDBG_VFS
@@ -26,6 +27,23 @@ static struct dentry *nfs4_remote_referral_mount(struct file_system_type *fs_typ
 	int flags, const char *dev_name, void *raw_data);
 static void nfs4_kill_super(struct super_block *sb);
 
+/*
+ * Clean out any remaining NFSv4 state that might be left over due
+ * to open() calls that passed nfs_atomic_lookup, but failed to call
+ * nfs_open().
+ */
+void nfs4_evict_inode(struct inode *inode)
+{
+	truncate_inode_pages(&inode->i_data, 0);
+	end_writeback(inode);
+	pnfs_return_layout(inode);
+	pnfs_destroy_layout(NFS_I(inode));
+	/* If we are holding a delegation, return it! */
+	nfs_inode_return_delegation_noreclaim(inode);
+	/* First call standard NFS clear_inode() code */
+	nfs_clear_inode(inode);
+}
+
 struct file_system_type nfs4_fs_type = {
 	.owner		= THIS_MODULE,
 	.name		= "nfs4",
Signature · 1 line
1.7.9
#17 lore raw

RFC 18/21 NFS: Use the IS_ENABLED macro for CONFIG_NFS_V4

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

Once v4 is a module CONFIG_NFS_V4_MODULE may be set instead of CONFIG_NFS_V4. This code doesn't care if it's a module or built in, but it does need to know if any form of the option is enabled. This patch should probably be squashed with the next one before the end...

---
 fs/nfs/callback.h         |    2 +-
 fs/nfs/client.c           |    6 +++---
 fs/nfs/delegation.h       |    2 +-
 fs/nfs/dir.c              |    4 ++--
 fs/nfs/direct.c           |    2 +-
 fs/nfs/file.c             |    2 +-
 fs/nfs/inode.c            |    8 ++++----
 fs/nfs/internal.h         |   14 +++++++-------
 fs/nfs/namespace.c        |    2 +-
 fs/nfs/nfs4_fs.h          |    2 +-
 fs/nfs/super.c            |   20 ++++++++++----------
 fs/nfs/write.c            |    8 ++++----
 include/linux/nfs_fs.h    |    6 +++---
 include/linux/nfs_fs_sb.h |    6 +++---
 include/linux/nfs_idmap.h |    2 +-
 include/linux/nfs_xdr.h   |    4 ++--
 16 files changed, 45 insertions(+), 45 deletions(-)
fs/nfs/callback.h +1 -1
index c89d3b9..8e6cf9f 100644
@@ -191,7 +191,7 @@ extern __be32 nfs4_callback_getattr(struct cb_getattrargs *args,
 				    struct cb_process_state *cps);
 extern __be32 nfs4_callback_recall(struct cb_recallargs *args, void *dummy,
 				   struct cb_process_state *cps);
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern int nfs_callback_up(u32 minorversion, struct rpc_xprt *xprt);
 extern void nfs_callback_down(int minorversion);
 extern int nfs4_validate_delegation_stateid(struct nfs_delegation *delegation,
fs/nfs/client.c +3 -3
index b709c38..6743a28 100644
@@ -59,7 +59,7 @@ static LIST_HEAD(nfs_versions);
 LIST_HEAD(nfs_client_list);
 static LIST_HEAD(nfs_volume_list);
 static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq);
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 static DEFINE_IDR(cb_ident_idr); /* Protected by nfs_client_lock */
 
 /*
@@ -217,7 +217,7 @@ static struct nfs_client *nfs_alloc_client(const struct nfs_client_initdata *cl_
 	return nfs_mod->alloc_client(cl_init);
 }
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 static void pnfs_init_server(struct nfs_server *server)
 {
 	rpc_init_wait_queue(&server->roc_rpcwaitq, "pNFS ROC");
@@ -1153,7 +1153,7 @@ error:
 }
 EXPORT_SYMBOL_GPL(nfs_create_server);
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 /*
  * NFSv4.0 callback thread helper
  *
fs/nfs/delegation.h +1 -1
index 0b388d7..29d3502 100644
@@ -8,7 +8,7 @@
 #ifndef FS_NFS_DELEGATION_H
 #define FS_NFS_DELEGATION_H
 
-#if defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V4)
 #include "nfs.h"
 /*
  * NFSv4 delegation
fs/nfs/dir.c +2 -2
index 07ed31d..840a811 100644
@@ -81,7 +81,7 @@ const struct address_space_operations nfs_dir_aops = {
 	.freepage = nfs_readdir_clear_array,
 };
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 
 static struct dentry *nfs_atomic_lookup(struct inode *, struct dentry *, struct nameidata *);
 static int nfs_open_create(struct inode *dir, struct dentry *dentry, umode_t mode, struct nameidata *nd);
@@ -1301,7 +1301,7 @@ out:
 }
 EXPORT_SYMBOL_GPL(nfs_lookup);
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 static int nfs_open_revalidate(struct dentry *, struct nameidata *);
 
 const struct dentry_operations nfs4_dentry_operations = {
fs/nfs/direct.c +1 -1
index 185e177..7aa353c 100644
@@ -460,7 +460,7 @@ static void nfs_direct_free_writedata(struct nfs_direct_req *dreq)
 	}
 }
 
-#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
 static void nfs_direct_write_reschedule(struct nfs_direct_req *dreq)
 {
 	struct inode *inode = dreq->inode;
fs/nfs/file.c +1 -1
index c678c00..5158bd3 100644
@@ -859,7 +859,7 @@ const struct file_operations nfs_file_operations = {
 };
 EXPORT_SYMBOL_GPL(nfs_file_operations);
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 static int
 nfs4_file_open(struct inode *inode, struct file *filp)
 {
fs/nfs/inode.c +4 -4
index 2f48355..cb645e3f 100644
@@ -1469,7 +1469,7 @@ struct inode *nfs_alloc_inode(struct super_block *sb)
 	nfsi->acl_access = ERR_PTR(-EAGAIN);
 	nfsi->acl_default = ERR_PTR(-EAGAIN);
 #endif
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	nfsi->nfs4_acl = NULL;
 #endif /* CONFIG_NFS_V4 */
 	return &nfsi->vfs_inode;
@@ -1490,7 +1490,7 @@ EXPORT_SYMBOL_GPL(nfs_destroy_inode);
 
 static inline void nfs4_init_once(struct nfs_inode *nfsi)
 {
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	INIT_LIST_HEAD(&nfsi->open_states);
 	nfsi->delegation = NULL;
 	nfsi->delegation_state = 0;
@@ -1637,7 +1637,7 @@ static int __init init_nfs_fs(void)
 #endif
 	if ((err = register_nfs_fs()) != 0)
 		goto out;
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	init_nfs_v4();
 #endif
 	return 0;
@@ -1670,7 +1670,7 @@ out9:
 
 static void __exit exit_nfs_fs(void)
 {
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	exit_nfs_v4();
 #endif
 	nfs_destroy_directcache();
fs/nfs/internal.h +7 -7
index 4ea1b93..d66e660 100644
@@ -181,13 +181,13 @@ static inline void nfs_fs_proc_exit(void)
 {
 }
 #endif
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern spinlock_t nfs_client_lock;
 extern struct list_head nfs_client_list;
 #endif
 
 /* nfs4namespace.c */
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern struct vfsmount *nfs_do_refmount(struct dentry *dentry);
 #else
 static inline
@@ -224,7 +224,7 @@ extern int nfs3_decode_dirent(struct xdr_stream *,
 				struct nfs_entry *, int);
 
 /* nfs4xdr.c */
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern int nfs4_decode_dirent(struct xdr_stream *,
 				struct nfs_entry *, int);
 #endif
@@ -234,7 +234,7 @@ extern const u32 nfs41_maxwrite_overhead;
 #endif
 
 /* nfs4proc.c */
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern struct rpc_procinfo nfs4_procedures[];
 void nfs_fixup_secinfo_attributes(struct nfs_fattr *, struct nfs_fh *);
 #endif
@@ -263,7 +263,7 @@ extern int nfs_wait_bit_killable(void *word);
 
 /* super.c */
 extern struct file_system_type nfs_xdev_fs_type;
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern struct file_system_type nfs4_xdev_fs_type;
 extern struct file_system_type nfs4_referral_fs_type;
 #endif
@@ -279,14 +279,14 @@ extern void nfs_sb_deactive(struct super_block *sb);
 extern char *nfs_path(char **p, struct dentry *dentry,
 		      char *buffer, ssize_t buflen);
 extern struct vfsmount *nfs_d_automount(struct path *path);
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *);
 #endif
 
 /* getroot.c */
 extern struct dentry *nfs_get_root(struct super_block *, struct nfs_fh *,
 				   const char *);
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern struct dentry *nfs4_get_root(struct super_block *, struct nfs_fh *,
 				    const char *);
 
fs/nfs/namespace.c +1 -1
index 31c3fcb..289560d 100644
@@ -120,7 +120,7 @@ Elong:
 	return ERR_PTR(-ENAMETOOLONG);
 }
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
 {
 	struct gss_api_mech *mech;
fs/nfs/nfs4_fs.h +1 -1
index 9a27673..6096a8d 100644
@@ -9,7 +9,7 @@
 #ifndef __LINUX_FS_NFS_NFS4_FS_H
 #define __LINUX_FS_NFS_NFS4_FS_H
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 
 #include "nfs.h"
 
fs/nfs/super.c +10 -10
index c8fcec5..427865f 100644
@@ -320,7 +320,7 @@ int __init register_nfs_fs(void)
 	ret = nfs_register_sysctl();
 	if (ret < 0)
 		goto error_1;
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	ret = register_filesystem(&nfs4_fs_type);
 	if (ret < 0)
 		goto error_2;
@@ -328,7 +328,7 @@ int __init register_nfs_fs(void)
 	register_shrinker(&acl_shrinker);
 	return 0;
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 error_2:
 	nfs_unregister_sysctl();
 #endif
@@ -344,7 +344,7 @@ error_0:
 void __exit unregister_nfs_fs(void)
 {
 	unregister_shrinker(&acl_shrinker);
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	unregister_filesystem(&nfs4_fs_type);
 #endif
 	nfs_unregister_sysctl();
@@ -537,7 +537,7 @@ static void nfs_show_mountd_options(struct seq_file *m, struct nfs_server *nfss,
 	nfs_show_mountd_netid(m, nfss, showdefaults);
 }
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 static void nfs_show_nfsv4_options(struct seq_file *m, struct nfs_server *nfss,
 				    int showdefaults)
 {
@@ -658,7 +658,7 @@ int nfs_show_options(struct seq_file *m, struct dentry *root)
 }
 EXPORT_SYMBOL_GPL(nfs_show_options);
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 #ifdef CONFIG_NFS_V4_1
 static void show_sessions(struct seq_file *m, struct nfs_server *server)
 {
@@ -670,7 +670,7 @@ static void show_sessions(struct seq_file *m, struct nfs_server *server) {}
 #endif
 #endif
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 #ifdef CONFIG_NFS_V4_1
 static void show_pnfs(struct seq_file *m, struct nfs_server *server)
 {
@@ -740,7 +740,7 @@ int nfs_show_stats(struct seq_file *m, struct dentry *root)
 	seq_printf(m, ",bsize=%u", nfss->bsize);
 	seq_printf(m, ",namlen=%u", nfss->namelen);
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	if (nfss->nfs_client->rpc_ops->version == 4) {
 		seq_printf(m, "\n\tnfsv4:\t");
 		seq_printf(m, "bm0=0x%x", nfss->attr_bitmask[0]);
@@ -1813,7 +1813,7 @@ static int nfs_validate_mount_data(void *options,
 			goto out_no_address;
 
 		if (args->version == 4)
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 			return nfs4_validate_text_mount_data(options,
 							     args, dev_name);
 #else
@@ -1868,7 +1868,7 @@ out_v3_not_compiled:
 	return -EPROTONOSUPPORT;
 #endif /* !CONFIG_NFS_V3 */
 
-#ifndef CONFIG_NFS_V4
+#if !IS_ENABLED(CONFIG_NFS_V4)
 out_v4_not_compiled:
 	dfprintk(MOUNT, "NFS: NFSv4 is not compiled into kernel\n");
 	return -EPROTONOSUPPORT;
@@ -2395,7 +2395,7 @@ nfs_xdev_mount(struct file_system_type *fs_type, int flags,
 }
 EXPORT_SYMBOL_GPL(nfs_xdev_mount);
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 
 static void nfs4_validate_mount_flags(struct nfs_parsed_mount_data *args)
 {
fs/nfs/write.c +4 -4
index d906336..9788bee 100644
@@ -431,7 +431,7 @@ nfs_mark_request_dirty(struct nfs_page *req)
 	__set_page_dirty_nobuffers(req->wb_page);
 }
 
-#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
 /*
  * Add a request to the inode's commit list.
  */
@@ -516,7 +516,7 @@ int nfs_reschedule_unstable_write(struct nfs_page *req,
 }
 #endif
 
-#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
 static int
 nfs_need_commit(struct nfs_inode *nfsi)
 {
@@ -1238,7 +1238,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
 		return;
 	nfs_add_stats(data->inode, NFSIOS_SERVERWRITTENBYTES, resp->count);
 
-#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
 	if (resp->verf->committed < argp->stable && task->tk_status >= 0) {
 		/* We tried a write call, but the server did not
 		 * commit data to stable storage even though we
@@ -1297,7 +1297,7 @@ void nfs_writeback_done(struct rpc_task *task, struct nfs_write_data *data)
 }
 
 
-#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
 static int nfs_commit_set_lock(struct nfs_inode *nfsi, int may_wait)
 {
 	int ret;
include/linux/nfs_fs.h +3 -3
index 766ea02..3017614 100644
@@ -188,7 +188,7 @@ struct nfs_inode {
 	struct hlist_head	silly_list;
 	wait_queue_head_t	waitqueue;
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	struct nfs4_cached_acl	*nfs4_acl;
         /* NFSv4 state */
 	struct list_head	open_states;
@@ -410,7 +410,7 @@ extern const struct inode_operations nfs_file_inode_operations;
 extern const struct inode_operations nfs3_file_inode_operations;
 #endif /* CONFIG_NFS_V3 */
 extern const struct file_operations nfs_file_operations;
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 extern const struct file_operations nfs4_file_operations;
 #endif /* CONFIG_NFS_V4 */
 extern const struct address_space_operations nfs_file_aops;
@@ -524,7 +524,7 @@ extern void nfs_writeback_done(struct rpc_task *, struct nfs_write_data *);
 extern int nfs_wb_all(struct inode *inode);
 extern int nfs_wb_page(struct inode *inode, struct page* page);
 extern int nfs_wb_page_cancel(struct inode *inode, struct page* page);
-#if IS_ENABLED(CONFIG_NFS_V3) || defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V3) || IS_ENABLED(CONFIG_NFS_V4)
 extern int  nfs_commit_inode(struct inode *, int);
 extern struct nfs_write_data *nfs_commitdata_alloc(void);
 extern void nfs_commit_free(struct nfs_write_data *wdata);
include/linux/nfs_fs_sb.h +3 -3
index c234693..50cef88 100644
@@ -47,7 +47,7 @@ struct nfs_client {
 	u32			cl_minorversion;/* NFSv4 minorversion */
 	struct rpc_cred		*cl_machine_cred;
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	u64			cl_clientid;	/* constant */
 	nfs4_verifier		cl_confirm;	/* Clientid verifier */
 	unsigned long		cl_state;
@@ -134,7 +134,7 @@ struct nfs_server {
 #endif
 
 	u32			pnfs_blksize;	/* layout_blksize attr */
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	u32			attr_bitmask[3];/* V4 bitmask representing the set
 						   of attributes supported on this
 						   filesystem */
@@ -192,7 +192,7 @@ struct nfs_server {
 /* maximum number of slots to use */
 #define NFS4_MAX_SLOT_TABLE RPC_MAX_SLOT_TABLE
 
-#if defined(CONFIG_NFS_V4)
+#if IS_ENABLED(CONFIG_NFS_V4)
 
 /* Sessions */
 #define SLOT_TABLE_SZ (NFS4_MAX_SLOT_TABLE/(8*sizeof(long)))
include/linux/nfs_idmap.h +1 -1
index 3c9eeb7..7ee83d6 100644
@@ -69,7 +69,7 @@ struct nfs_server;
 struct nfs_fattr;
 struct nfs4_string;
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 int nfs_idmap_init(void);
 void nfs_idmap_quit(void);
 #else
include/linux/nfs_xdr.h +2 -2
index 9eaa8f7..c23dee4 100644
@@ -789,7 +789,7 @@ struct nfs3_getaclres {
 	struct posix_acl *	acl_default;
 };
 
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 
 typedef u64 clientid4;
 
@@ -1183,7 +1183,7 @@ struct nfs_write_data {
 	int			ds_commit_index;
 	const struct rpc_call_ops *mds_ops;
 	int (*write_done_cb) (struct rpc_task *task, struct nfs_write_data *data);
-#ifdef CONFIG_NFS_V4
+#if IS_ENABLED(CONFIG_NFS_V4)
 	unsigned long		timestamp;	/* For lease renewal */
 #endif
 	__u64			mds_offset;	/* Filelayout dense stripe */
Signature · 1 line
1.7.9
#18 lore raw

RFC 19/21 NFS: Convert v4 into a module

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

The module will be created in the same directory as nfs.ko. You need to run modprobe nfs4 before you can use it.

---
 fs/nfs/Kconfig     |    2 +-
 fs/nfs/Makefile    |   14 ++++++++------
 fs/nfs/inode.c     |    6 ------
 fs/nfs/nfs4super.c |    5 +++++
 4 files changed, 14 insertions(+), 13 deletions(-)
fs/nfs/Kconfig +1 -1
index 57c4b19..608b84a 100644
@@ -70,7 +70,7 @@ config NFS_V3_ACL
 	  If unsure, say N.
 
 config NFS_V4
-	bool "NFS client support for NFS version 4"
+	tristate "NFS client support for NFS version 4"
 	depends on NFS_FS
 	select SUNRPC_GSS
 	help
fs/nfs/Makefile +8 -6
index e983eb0..c356cda 100644
@@ -7,14 +7,10 @@ obj-$(CONFIG_NFS_FS) += nfs.o
 nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   direct.o pagelist.o read.o symlink.o unlink.o \
 			   write.o namespace.o mount_clnt.o \
-			   dns_resolve.o cache_lib.o
+			   cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
-			   nfs4super.o delegation.o idmap.o \
-			   callback.o callback_xdr.o callback_proc.o \
-			   nfs4namespace.o nfs4client.o nfs4getroot.o
 nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
-nfs-$(CONFIG_SYSCTL) += sysctl.o nfs4sysctl.o
+nfs-$(CONFIG_SYSCTL) += sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 
 obj-$(CONFIG_NFS_V2) += nfs2.o
@@ -24,6 +20,12 @@ obj-$(CONFIG_NFS_V3) += nfs3.o
 nfs3-y += nfs3super.o nfs3client.o nfs3proc.o nfs3xdr.o
 nfs3-y += nfs3acl.o
 
+obj-$(CONFIG_NFS_V4) += nfs4.o
+nfs4-y = nfs4super.o nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
+	 delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \
+	 nfs4namespace.o dns_resolve.o nfs4client.o nfs4getroot.o
+nfs4-$(CONFIG_SYSCTL) += nfs4sysctl.o
+
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
 nfs_layout_nfsv41_files-y := nfs4filelayout.o nfs4filelayoutdev.o
 
fs/nfs/inode.c +0 -6
index cb645e3f..2ee6259 100644
@@ -1637,9 +1637,6 @@ static int __init init_nfs_fs(void)
 #endif
 	if ((err = register_nfs_fs()) != 0)
 		goto out;
-#if IS_ENABLED(CONFIG_NFS_V4)
-	init_nfs_v4();
-#endif
 	return 0;
 out:
 #ifdef CONFIG_PROC_FS
@@ -1670,9 +1667,6 @@ out9:
 
 static void __exit exit_nfs_fs(void)
 {
-#if IS_ENABLED(CONFIG_NFS_V4)
-	exit_nfs_v4();
-#endif
 	nfs_destroy_directcache();
 	nfs_destroy_writepagecache();
 	nfs_destroy_readpagecache();
fs/nfs/nfs4super.c +5 -0
index 2764c28..3e515db 100644
@@ -669,3 +669,8 @@ void __exit exit_nfs_v4(void)
 	nfs4_unregister_sysctl();
 	nfs_idmap_quit();
 }
+
+MODULE_LICENSE("GPL");
+
+module_init(init_nfs_v4);
+module_exit(exit_nfs_v4);
Signature · 1 line
1.7.9
#23 lore raw

RFC 20/21 Export symbols for v4 module

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

This patch should be squashed with the previous one for everything to work. I also need to double check that all of these are actually needed...

---
 fs/nfs/client.c    |    6 ++++++
 fs/nfs/dir.c       |    4 ++++
 fs/nfs/file.c      |    1 +
 fs/nfs/inode.c     |    5 +++++
 fs/nfs/namespace.c |    2 ++
 fs/nfs/pagelist.c  |    3 +++
 fs/nfs/pnfs.c      |   15 +++++++++++++++
 fs/nfs/pnfs_dev.c  |    1 +
 fs/nfs/read.c      |    3 +++
 fs/nfs/super.c     |    3 +++
 fs/nfs/write.c     |    4 ++++
 11 files changed, 47 insertions(+), 0 deletions(-)
fs/nfs/client.c +6 -0
index 6743a28..abd7d86 100644
@@ -57,6 +57,7 @@ EXPORT_SYMBOL_GPL(nfs_client_lock);
 static DEFINE_SPINLOCK(nfs_version_lock);
 static LIST_HEAD(nfs_versions);
 LIST_HEAD(nfs_client_list);
+EXPORT_SYMBOL_GPL(nfs_client_list);
 static LIST_HEAD(nfs_volume_list);
 static DECLARE_WAIT_QUEUE_HEAD(nfs_client_active_wq);
 #if IS_ENABLED(CONFIG_NFS_V4)
@@ -558,6 +559,7 @@ void nfs_mark_client_ready(struct nfs_client *clp, int state)
 	clp->cl_cons_state = state;
 	wake_up_all(&nfs_client_active_wq);
 }
+EXPORT_SYMBOL_GPL(nfs_mark_client_ready);
 
 /*
  * With sessions, the client is not marked ready until after a
@@ -574,6 +576,7 @@ int nfs4_check_client_ready(struct nfs_client *clp)
 		return -EPROTONOSUPPORT;
 	return 0;
 }
+EXPORT_SYMBOL_GPL(nfs4_check_client_ready);
 
 /*
  * Initialise the timeout values for a connection
@@ -1171,6 +1174,7 @@ nfs4_find_client_ident(int cb_ident)
 	spin_unlock(&nfs_client_lock);
 	return clp;
 }
+EXPORT_SYMBOL_GPL(nfs4_find_client_ident);
 
 #if defined(CONFIG_NFS_V4_1)
 /*
@@ -1206,6 +1210,7 @@ nfs4_find_client_sessionid(const struct sockaddr *addr,
 	spin_unlock(&nfs_client_lock);
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(nfs4_find_client_sessionid);
 
 #else /* CONFIG_NFS_V4_1 */
 
@@ -1215,6 +1220,7 @@ nfs4_find_client_sessionid(const struct sockaddr *addr,
 {
 	return NULL;
 }
+EXPORT_SYMBOL_GPL(nfs4_find_client_sessionid);
 #endif /* CONFIG_NFS_V4_1 */
 
 #endif /* CONFIG_NFS_V4 */
fs/nfs/dir.c +4 -0
index 840a811..39c71ed 100644
@@ -103,6 +103,7 @@ const struct inode_operations nfs4_dir_inode_operations = {
 	.listxattr	= generic_listxattr,
 	.removexattr	= generic_removexattr,
 };
+EXPORT_SYMBOL_GPL(nfs4_dir_inode_operations);
 
 #endif /* CONFIG_NFS_V4 */
 
@@ -958,6 +959,7 @@ void nfs_force_lookup_revalidate(struct inode *dir)
 {
 	NFS_I(dir)->cache_change_attribute++;
 }
+EXPORT_SYMBOL_GPL(nfs_force_lookup_revalidate);
 
 /*
  * A check for whether or not the parent directory has changed.
@@ -1311,6 +1313,7 @@ const struct dentry_operations nfs4_dentry_operations = {
 	.d_automount	= nfs_d_automount,
 	.d_release	= nfs_d_release,
 };
+EXPORT_SYMBOL_GPL(nfs4_dentry_operations);
 
 /*
  * Use intent information to determine whether we need to substitute
@@ -2276,6 +2279,7 @@ int nfs_may_open(struct inode *inode, struct rpc_cred *cred, int openflags)
 {
 	return nfs_do_access(inode, cred, nfs_open_permission_mask(openflags));
 }
+EXPORT_SYMBOL_GPL(nfs_may_open);
 
 int nfs_permission(struct inode *inode, int mask)
 {
fs/nfs/file.c +1 -0
index 5158bd3..219bb22 100644
@@ -889,4 +889,5 @@ const struct file_operations nfs4_file_operations = {
 	.check_flags	= nfs_check_flags,
 	.setlease	= nfs_setlease,
 };
+EXPORT_SYMBOL_GPL(nfs4_file_operations);
 #endif /* CONFIG_NFS_V4 */
fs/nfs/inode.c +5 -0
index 2ee6259..e2c372c 100644
@@ -83,6 +83,7 @@ int nfs_wait_bit_killable(void *word)
 	freezable_schedule();
 	return 0;
 }
+EXPORT_SYMBOL_GPL(nfs_wait_bit_killable);
 
 /**
  * nfs_compat_user_ino64 - returns the user-visible inode number
@@ -421,6 +422,7 @@ out_no_inode:
 	dprintk("nfs_fhget: iget failed with error %ld\n", PTR_ERR(inode));
 	goto out;
 }
+EXPORT_SYMBOL_GPL(nfs_fhget);
 
 #define NFS_VALID_ATTRS (ATTR_MODE|ATTR_UID|ATTR_GID|ATTR_SIZE|ATTR_ATIME|ATTR_ATIME_SET|ATTR_MTIME|ATTR_MTIME_SET|ATTR_FILE|ATTR_OPEN)
 
@@ -686,6 +688,7 @@ struct nfs_open_context *get_nfs_open_context(struct nfs_open_context *ctx)
 		atomic_inc(&ctx->lock_context.count);
 	return ctx;
 }
+EXPORT_SYMBOL_GPL(get_nfs_open_context);
 
 static void __put_nfs_open_context(struct nfs_open_context *ctx, int is_sync)
 {
@@ -712,6 +715,7 @@ void put_nfs_open_context(struct nfs_open_context *ctx)
 {
 	__put_nfs_open_context(ctx, 0);
 }
+EXPORT_SYMBOL_GPL(put_nfs_open_context);
 
 /*
  * Ensure that mmap has a recent RPC credential for use when writing out
@@ -1536,6 +1540,7 @@ static void nfs_destroy_inodecache(void)
 }
 
 struct workqueue_struct *nfsiod_workqueue;
+EXPORT_SYMBOL_GPL(nfsiod_workqueue);
 
 /*
  * start up the nfsiod workqueue
fs/nfs/namespace.c +2 -0
index 289560d..69ec69b 100644
@@ -119,6 +119,7 @@ Elong_unlock:
 Elong:
 	return ERR_PTR(-ENAMETOOLONG);
 }
+EXPORT_SYMBOL_GPL(nfs_path);
 
 #if IS_ENABLED(CONFIG_NFS_V4)
 rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
@@ -149,6 +150,7 @@ rpc_authflavor_t nfs_find_best_sec(struct nfs4_secinfo_flavors *flavors)
 
 	return pseudoflavor;
 }
+EXPORT_SYMBOL_GPL(nfs_find_best_sec);
 
 static int nfs_negotiate_security(const struct dentry *parent,
 				  const struct dentry *dentry,
fs/nfs/pagelist.c +3 -0
index 77a184e..0864530 100644
@@ -249,6 +249,7 @@ void nfs_pageio_init(struct nfs_pageio_descriptor *desc,
 	desc->pg_error = 0;
 	desc->pg_lseg = NULL;
 }
+EXPORT_SYMBOL_GPL(nfs_pageio_init);
 
 /**
  * nfs_can_coalesce_requests - test two requests for compatibility
@@ -390,6 +391,7 @@ int nfs_pageio_add_request(struct nfs_pageio_descriptor *desc,
 	} while (ret);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(nfs_pageio_add_request);
 
 /**
  * nfs_pageio_complete - Complete I/O on an nfs_pageio_descriptor
@@ -405,6 +407,7 @@ void nfs_pageio_complete(struct nfs_pageio_descriptor *desc)
 			break;
 	}
 }
+EXPORT_SYMBOL_GPL(nfs_pageio_complete);
 
 /**
  * nfs_pageio_cond_complete - Conditional I/O completion
fs/nfs/pnfs.c +15 -0
index 9292787..f7edc4a 100644
@@ -189,6 +189,7 @@ get_layout_hdr(struct pnfs_layout_hdr *lo)
 {
 	atomic_inc(&lo->plh_refcount);
 }
+EXPORT_SYMBOL_GPL(get_layout_hdr);
 
 static struct pnfs_layout_hdr *
 pnfs_alloc_layout_hdr(struct inode *ino, gfp_t gfp_flags)
@@ -232,6 +233,7 @@ put_layout_hdr(struct pnfs_layout_hdr *lo)
 		spin_unlock(&inode->i_lock);
 	}
 }
+EXPORT_SYMBOL_GPL(put_layout_hdr);
 
 static void
 init_lseg(struct pnfs_layout_hdr *lo, struct pnfs_layout_segment *lseg)
@@ -412,6 +414,7 @@ mark_matching_lsegs_invalid(struct pnfs_layout_hdr *lo,
 	dprintk("%s:Return %i\n", __func__, invalid - removed);
 	return invalid - removed;
 }
+EXPORT_SYMBOL_GPL(mark_matching_lsegs_invalid);
 
 /* note free_me must contain lsegs from a single layout_hdr */
 void
@@ -439,6 +442,7 @@ pnfs_free_lseg_list(struct list_head *free_me)
 		free_lseg(lseg);
 	}
 }
+EXPORT_SYMBOL_GPL(pnfs_free_lseg_list);
 
 void
 pnfs_destroy_layout(struct nfs_inode *nfsi)
@@ -455,6 +459,7 @@ pnfs_destroy_layout(struct nfs_inode *nfsi)
 	spin_unlock(&nfsi->vfs_inode.i_lock);
 	pnfs_free_lseg_list(&tmp_list);
 }
+EXPORT_SYMBOL_GPL(pnfs_destroy_layout);
 
 /*
  * Called by the state manger to remove all layouts established under an
@@ -488,6 +493,7 @@ pnfs_destroy_all_layouts(struct nfs_client *clp)
 		pnfs_destroy_layout(NFS_I(lo->plh_inode));
 	}
 }
+EXPORT_SYMBOL_GPL(pnfs_destroy_all_layouts);
 
 /* update lo->plh_stateid with new if is more recent */
 void
@@ -518,6 +524,7 @@ pnfs_set_layout_stateid(struct pnfs_layout_hdr *lo, const nfs4_stateid *new,
 		}
 	}
 }
+EXPORT_SYMBOL_GPL(pnfs_set_layout_stateid);
 
 /* lget is set to 1 if called from inside send_layoutget call chain */
 static bool
@@ -558,6 +565,7 @@ pnfs_choose_layoutget_stateid(nfs4_stateid *dst, struct pnfs_layout_hdr *lo,
 	dprintk("<-- %s\n", __func__);
 	return status;
 }
+EXPORT_SYMBOL_GPL(pnfs_choose_layoutget_stateid);
 
 /*
 * Get layout from server.
@@ -693,6 +701,7 @@ out:
 	dprintk("<-- %s status: %d\n", __func__, status);
 	return status;
 }
+EXPORT_SYMBOL_GPL(_pnfs_return_layout);
 
 bool pnfs_roc(struct inode *ino)
 {
@@ -723,6 +732,7 @@ out_nolayout:
 	spin_unlock(&ino->i_lock);
 	return false;
 }
+EXPORT_SYMBOL_GPL(pnfs_roc);
 
 void pnfs_roc_release(struct inode *ino)
 {
@@ -734,6 +744,7 @@ void pnfs_roc_release(struct inode *ino)
 	put_layout_hdr_locked(lo);
 	spin_unlock(&ino->i_lock);
 }
+EXPORT_SYMBOL_GPL(pnfs_roc_release);
 
 void pnfs_roc_set_barrier(struct inode *ino, u32 barrier)
 {
@@ -745,6 +756,7 @@ void pnfs_roc_set_barrier(struct inode *ino, u32 barrier)
 		lo->plh_barrier = barrier;
 	spin_unlock(&ino->i_lock);
 }
+EXPORT_SYMBOL_GPL(pnfs_roc_set_barrier);
 
 bool pnfs_roc_drain(struct inode *ino, u32 *barrier)
 {
@@ -770,6 +782,7 @@ bool pnfs_roc_drain(struct inode *ino, u32 *barrier)
 	spin_unlock(&ino->i_lock);
 	return found;
 }
+EXPORT_SYMBOL_GPL(pnfs_roc_drain);
 
 /*
  * Compare two layout segments for sorting into layout cache.
@@ -1080,6 +1093,7 @@ out_forget_reply:
 	NFS_SERVER(ino)->pnfs_curr_ld->free_lseg(lseg);
 	goto out;
 }
+EXPORT_SYMBOL_GPL(pnfs_layout_process);
 
 void
 pnfs_generic_pg_init_read(struct nfs_pageio_descriptor *pgio, struct nfs_page *req)
@@ -1473,6 +1487,7 @@ void pnfs_cleanup_layoutcommit(struct nfs4_layoutcommit_data *data)
 	if (nfss->pnfs_curr_ld->cleanup_layoutcommit)
 		nfss->pnfs_curr_ld->cleanup_layoutcommit(data);
 }
+EXPORT_SYMBOL_GPL(pnfs_cleanup_layoutcommit);
 
 /*
  * For the LAYOUT4_NFSV4_1_FILES layout type, NFS_DATA_SYNC WRITEs and
fs/nfs/pnfs_dev.c +1 -0
index 4f359d2..e0041f3 100644
@@ -255,6 +255,7 @@ nfs4_deviceid_purge_client(const struct nfs_client *clp)
 	for (h = 0; h < NFS4_DEVICE_ID_HASH_SIZE; h++)
 		_deviceid_purge_client(clp, h);
 }
+EXPORT_SYMBOL_GPL(nfs4_deviceid_purge_client);
 
 /*
  * Stop use of all deviceids associated with an nfs_client
fs/nfs/read.c +3 -0
index 3c2540d..cdeffdc 100644
@@ -70,6 +70,7 @@ void nfs_readdata_release(struct nfs_read_data *rdata)
 	put_nfs_open_context(rdata->args.context);
 	nfs_readdata_free(rdata);
 }
+EXPORT_SYMBOL_GPL(nfs_readdata_release);
 
 static
 int nfs_return_empty_page(struct page *page)
@@ -115,6 +116,7 @@ void nfs_pageio_init_read_mds(struct nfs_pageio_descriptor *pgio,
 	nfs_pageio_init(pgio, inode, &nfs_pageio_read_ops,
 			NFS_SERVER(inode)->rsize, 0);
 }
+EXPORT_SYMBOL_GPL(nfs_pageio_init_read_mds);
 
 void nfs_pageio_reset_read_mds(struct nfs_pageio_descriptor *pgio)
 {
@@ -368,6 +370,7 @@ int nfs_generic_pagein(struct nfs_pageio_descriptor *desc, struct list_head *hea
 		return nfs_pagein_multi(desc, head);
 	return nfs_pagein_one(desc, head);
 }
+EXPORT_SYMBOL_GPL(nfs_generic_pagein);
 
 static int nfs_generic_pg_readpages(struct nfs_pageio_descriptor *desc)
 {
fs/nfs/super.c +3 -0
index 427865f..ad5b528 100644
@@ -358,6 +358,7 @@ void nfs_sb_active(struct super_block *sb)
 	if (atomic_inc_return(&server->active) == 1)
 		atomic_inc(&sb->s_active);
 }
+EXPORT_SYMBOL_GPL(nfs_sb_active);
 
 void nfs_sb_deactive(struct super_block *sb)
 {
@@ -366,6 +367,7 @@ void nfs_sb_deactive(struct super_block *sb)
 	if (atomic_dec_and_test(&server->active))
 		deactivate_super(sb);
 }
+EXPORT_SYMBOL_GPL(nfs_sb_deactive);
 
 /*
  * Deliver file system statistics to userspace
@@ -2439,5 +2441,6 @@ int nfs4_validate_text_mount_data(void *options,
 				   &args->nfs_server.export_path,
 				   NFS4_MAXPATHLEN);
 }
+EXPORT_SYMBOL_GPL(nfs4_validate_text_mount_data);
 
 #endif /* CONFIG_NFS_V4 */
fs/nfs/write.c +4 -0
index 9788bee..87437e3 100644
@@ -104,6 +104,7 @@ void nfs_writedata_release(struct nfs_write_data *wdata)
 	put_nfs_open_context(wdata->args.context);
 	nfs_writedata_free(wdata);
 }
+EXPORT_SYMBOL_GPL(nfs_writedata_release);
 
 static void nfs_context_set_write_error(struct nfs_open_context *ctx, int error)
 {
@@ -1034,6 +1035,7 @@ int nfs_generic_flush(struct nfs_pageio_descriptor *desc, struct list_head *head
 		return nfs_flush_multi(desc, head);
 	return nfs_flush_one(desc, head);
 }
+EXPORT_SYMBOL_GPL(nfs_generic_flush);
 
 static int nfs_generic_pg_writepages(struct nfs_pageio_descriptor *desc)
 {
@@ -1058,6 +1060,7 @@ void nfs_pageio_init_write_mds(struct nfs_pageio_descriptor *pgio,
 	nfs_pageio_init(pgio, inode, &nfs_pageio_write_ops,
 				NFS_SERVER(inode)->wsize, ioflags);
 }
+EXPORT_SYMBOL_GPL(nfs_pageio_init_write_mds);
 
 void nfs_pageio_reset_write_mds(struct nfs_pageio_descriptor *pgio)
 {
@@ -1623,6 +1626,7 @@ int nfs_wb_all(struct inode *inode)
 
 	return sync_inode(inode, &wbc);
 }
+EXPORT_SYMBOL_GPL(nfs_wb_all);
 
 int nfs_wb_page_cancel(struct inode *inode, struct page *page)
 {
Signature · 1 line
1.7.9
#24 lore raw

RFC 21/21 NFS: Export v4.1 symbols back to nfs.ko

In reply to [email protected]

From: Bryan Schumaker <[email protected]>

pnfs is buried too deep in the generic client to make it easy to separate out. Instead, I just export the symbols back so when CONFIG_V4_1 is selected nfs.ko will depend on nfs4.ko

---
 fs/nfs/Makefile   |    2 +-
 fs/nfs/nfs4proc.c |    1 +
 fs/nfs/pnfs.c     |    5 +++++
 3 files changed, 7 insertions(+), 1 deletions(-)
fs/nfs/Makefile +1 -1
index c356cda..863bf85 100644
@@ -9,7 +9,6 @@ nfs-y 			:= client.o dir.o file.o getroot.o inode.o super.o \
 			   write.o namespace.o mount_clnt.o \
 			   cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.o
-nfs-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
 nfs-$(CONFIG_SYSCTL) += sysctl.o
 nfs-$(CONFIG_NFS_FSCACHE) += fscache.o fscache-index.o
 
@@ -24,6 +23,7 @@ obj-$(CONFIG_NFS_V4) += nfs4.o
 nfs4-y = nfs4super.o nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 	 delegation.o idmap.o callback.o callback_xdr.o callback_proc.o \
 	 nfs4namespace.o dns_resolve.o nfs4client.o nfs4getroot.o
+nfs4-$(CONFIG_NFS_V4_1)	+= pnfs.o pnfs_dev.o
 nfs4-$(CONFIG_SYSCTL) += nfs4sysctl.o
 
 obj-$(CONFIG_PNFS_FILE_LAYOUT) += nfs_layout_nfsv41_files.o
fs/nfs/nfs4proc.c +1 -0
index 3ae8485..1cb940b 100644
@@ -631,6 +631,7 @@ out:
 	dprintk("<-- %s status=%d\n", __func__, ret);
 	return ret;
 }
+EXPORT_SYMBOL_GPL(nfs4_setup_sequence);
 
 struct nfs41_call_sync_data {
 	const struct nfs_server *seq_server;
fs/nfs/pnfs.c +5 -0
index f7edc4a..ef2053f 100644
@@ -84,6 +84,7 @@ unset_pnfs_layoutdriver(struct nfs_server *nfss)
 	}
 	nfss->pnfs_curr_ld = NULL;
 }
+EXPORT_SYMBOL_GPL(unset_pnfs_layoutdriver);
 
 /*
  * Try to set the server's pnfs module to the pnfs layout type specified by id.
@@ -135,6 +136,7 @@ out_no_driver:
 	dprintk("%s: Using NFSv4 I/O\n", __func__);
 	server->pnfs_curr_ld = NULL;
 }
+EXPORT_SYMBOL_GPL(set_pnfs_layoutdriver);
 
 int
 pnfs_register_layoutdriver(struct pnfs_layoutdriver_type *ld_type)
@@ -1141,6 +1143,7 @@ pnfs_pageio_init_read(struct nfs_pageio_descriptor *pgio, struct inode *inode)
 	nfs_pageio_init(pgio, inode, ld->pg_read_ops, server->rsize, 0);
 	return true;
 }
+EXPORT_SYMBOL_GPL(pnfs_pageio_init_read);
 
 bool
 pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode, int ioflags)
@@ -1153,6 +1156,7 @@ pnfs_pageio_init_write(struct nfs_pageio_descriptor *pgio, struct inode *inode,
 	nfs_pageio_init(pgio, inode, ld->pg_write_ops, server->wsize, ioflags);
 	return true;
 }
+EXPORT_SYMBOL_GPL(pnfs_pageio_init_write);
 
 bool
 pnfs_generic_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
@@ -1567,3 +1571,4 @@ out_free:
 	kfree(data);
 	goto out;
 }
+EXPORT_SYMBOL_GPL(pnfs_layoutcommit_inode);
Signature · 1 line
1.7.9
#19 lore raw

Re: [RFC 19/21] NFS: Convert v4 into a module

In reply to [email protected]
Quoted 3 lines · On 02/11/2012 12:02 AM, [email protected] wrote:

The module will be created in the same directory as nfs.ko. You need to run modprobe nfs4 before you can use it.

Can we do this mod_alias and autoloading magic like we do with LD drivers, so if NFSv4 is requested it is automatically loaded by Kernel.

This way the impact on user-mode will be minimal.

Thanks
Boaz

#20 lore raw

Re: [RFC 19/21] NFS: Convert v4 into a module

T24gU3VuLCAyMDEyLTAyLTEyIGF0IDIwOjAyICswMjAwLCBCb2F6IEhhcnJvc2ggd3JvdGU6DQo+ IE9uIDAyLzExLzIwMTIgMTI6MDIgQU0sIGJqc2NodW1hQG5ldGFwcC5jb20gd3JvdGU6DQo+ID4g VGhlIG1vZHVsZSB3aWxsIGJlIGNyZWF0ZWQgaW4gdGhlIHNhbWUgZGlyZWN0b3J5IGFzIG5mcy5r by4gIFlvdSBuZWVkIHRvDQo+ID4gcnVuIGBtb2Rwcm9iZSBuZnM0YCBiZWZvcmUgeW91IGNhbiB1 c2UgaXQuDQo+ID4gDQo+IA0KPiBDYW4gd2UgZG8gdGhpcyBtb2RfYWxpYXMgYW5kIGF1dG9sb2Fk aW5nIG1hZ2ljIGxpa2Ugd2UgZG8gd2l0aCANCj4gTEQgZHJpdmVycywgc28gaWYgTkZTdjQgaXMg cmVxdWVzdGVkIGl0IGlzIGF1dG9tYXRpY2FsbHkgbG9hZGVkDQo+IGJ5IEtlcm5lbC4gDQoNCllv dSBuZWVkIHRvIGNhbGwgcmVxdWVzdC1tb2R1bGUoKSBmcm9tIHRoZSBuZnMua28gbW9kdWxlIGFz IHNvb24gYXMgeW91DQprbm93IHdoaWNoIHZlcnNpb24gdGhlIHVzZXIgaXMgdHJ5aW5nIHRvIGxv YWQuLi4NCkkgZG9uJ3Qgc2VlIHdoeSB5b3UgbmVlZCBtb2RfYWxpYXM/DQoNCi0tIA0KVHJvbmQg TXlrbGVidXN0DQpMaW51eCBORlMgY2xpZW50IG1haW50YWluZXINCg0KTmV0QXBwDQpUcm9uZC5N eWtsZWJ1c3RAbmV0YXBwLmNvbQ0Kd3d3Lm5ldGFwcC5jb20NCg0K

#21 lore raw

Re: [RFC 19/21] NFS: Convert v4 into a module

Quoted 6 lines · Trond
Quoted 5 lines · Boaz Harrosh
Quoted 3 lines · On 02/11/2012 12:02 AM, [email protected] wrote:

The module will be created in the same directory as nfs.ko. You need to run modprobe nfs4 before you can use it.

Quoted 8 lines
Quoted 3 lines

Can we do this mod_alias and autoloading magic like we do with LD drivers, so if NFSv4 is requested it is automatically loaded by Kernel.

You need to call request-module() from the nfs.ko module as soon as you know which version the user is trying to load...
I don't see why you need mod_alias?

That will work. I can now see that it's on the todo in the [00/21] mail Sorry for the noise

Thanks
Boaz

#22 lore raw

Re: [RFC 19/21] NFS: Convert v4 into a module

Quoted 11 lines · Boaz Harrosh
Quoted 10 lines · Trond
Quoted 8 lines · Boaz Harrosh
Quoted 3 lines · On 02/11/2012 12:02 AM, [email protected] wrote:

The module will be created in the same directory as nfs.ko. You need to run modprobe nfs4 before you can use it.

Can we do this mod_alias and autoloading magic like we do with LD drivers, so if NFSv4 is requested it is automatically loaded by Kernel.

Quoted 7 lines
Quoted 4 lines

You need to call request-module() from the nfs.ko module as soon as you know which version the user is trying to load...
I don't see why you need mod_alias?

That will work. I can now see that it's on the todo in the [00/21] mail Sorry for the noise

I agree that it's important to do, so don't worry about the extra reminder!

- Bryan

Quoted 3 lines

Thanks
Boaz