Skip to contentSkip to conversation

NFS: Make v2 configurable

PATCH Superseded [email protected] 1 participant 3 messages Apr 24, 2012

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover NFS: Make v2 configurable

From: Bryan Schumaker <[email protected]>

These patches were initially part of my modules patchset, but since they work on their own I figured I would resend them as a standalone patch set while I work on responding to comments for everything else.

- Bryan

Bryan Schumaker (2):
NFS: Create an NFS v3 stat_to_errno()
NFS: Make v2 configurable

 fs/nfs/Kconfig    |    9 +++++
 fs/nfs/Makefile   |    5 +--
 fs/nfs/client.c   |   11 +++++-
 fs/nfs/internal.h |    1 -
 fs/nfs/nfs2xdr.c  |    3 +-
 fs/nfs/nfs3xdr.c  |  103 +++++++++++++++++++++++++++++++++++++++++++----------
 6 files changed, 109 insertions(+), 23 deletions(-)
Signature · 1 line
1.7.10
#1 lore raw

PATCH 1/2 NFS: Create an NFS v3 stat_to_errno()

From: Bryan Schumaker <[email protected]>

In theory, NFS v3 can have different error versions than NFS v2. v4 is already using its own nfs4_stat_to_errno() to mapp error codes, so rather than create something in the generic client for v2 and v3 to share I instead give v3 its own function.

---
 fs/nfs/internal.h |    1 -
 fs/nfs/nfs2xdr.c  |    3 +-
 fs/nfs/nfs3xdr.c  |  103 +++++++++++++++++++++++++++++++++++++++++++----------
 3 files changed, 87 insertions(+), 20 deletions(-)
fs/nfs/internal.h +0 -1
index f4e7066..d02b645 100644
@@ -201,7 +201,6 @@ extern int __init nfs_init_directcache(void);
 extern void nfs_destroy_directcache(void);
 
 /* nfs2xdr.c */
-extern int nfs_stat_to_errno(enum nfs_stat);
 extern struct rpc_procinfo nfs_procedures[];
 extern int nfs2_decode_dirent(struct xdr_stream *,
 				struct nfs_entry *, int);
fs/nfs/nfs2xdr.c +2 -1
index 1f56000..73e3e67 100644
@@ -61,6 +61,7 @@
 #define NFS_readdirres_sz	(1)
 #define NFS_statfsres_sz	(1+NFS_info_sz)
 
+static int nfs_stat_to_errno(enum nfs_stat);
 
 /*
  * While encoding arguments, set up the reply buffer in advance to
@@ -1109,7 +1110,7 @@ static const struct {
  * Returns a local errno value, or -EIO if the NFS status code is
  * not recognized.  This function is used jointly by NFSv2 and NFSv3.
  */
-int nfs_stat_to_errno(enum nfs_stat status)
+static int nfs_stat_to_errno(enum nfs_stat status)
 {
 	int i;
 
fs/nfs/nfs3xdr.c +85 -18

221 lines not on this page · raw message

Signature · 1 line
1.7.10
#2 lore raw

PATCH 2/2 NFS: Make v2 configurable

In reply to [email protected]

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 2a0e6c5..4995b24 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 60f7e4e..b3922e6 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
@@ -847,7 +849,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,
 	};
@@ -857,10 +859,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.10