浏览代码

NFS: Make v2 configurable

With this patch NFS v2 can be disabled during Kconfig.  I default the
option to "y" to match the current behavior.

Signed-off-by: Bryan Schumaker <bjschuma@netapp.com>
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
Bryan Schumaker 13 年之前
父节点
当前提交
2ba68002a7
共有 3 个文件被更改,包括 27 次插入4 次删除
  1. 10 0
      fs/nfs/Kconfig
  2. 3 2
      fs/nfs/Makefile
  3. 14 2
      fs/nfs/client.c

+ 10 - 0
fs/nfs/Kconfig

@@ -29,6 +29,16 @@ config NFS_FS
 
 
 	  If unsure, say N.
 	  If unsure, say N.
 
 
+config NFS_V2
+	bool "NFS client support for NFS version 2"
+	depends on NFS_FS
+	default y
+	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
 config NFS_V3
 	bool "NFS client support for NFS version 3"
 	bool "NFS client support for NFS version 3"
 	depends on NFS_FS
 	depends on NFS_FS

+ 3 - 2
fs/nfs/Makefile

@@ -4,11 +4,12 @@
 
 
 obj-$(CONFIG_NFS_FS) += nfs.o
 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 \
 			   write.o namespace.o mount_clnt.o \
 			   dns_resolve.o cache_lib.o
 			   dns_resolve.o cache_lib.o
 nfs-$(CONFIG_ROOT_NFS)	+= nfsroot.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)	+= nfs3proc.o nfs3xdr.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V3_ACL)	+= nfs3acl.o
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \
 nfs-$(CONFIG_NFS_V4)	+= nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \

+ 14 - 2
fs/nfs/client.c

@@ -90,7 +90,9 @@ static bool nfs4_disable_idmapping = true;
  * RPC cruft for NFS
  * RPC cruft for NFS
  */
  */
 static const struct rpc_version *nfs_version[5] = {
 static const struct rpc_version *nfs_version[5] = {
+#ifdef CONFIG_NFS_V2
 	[2]			= &nfs_version2,
 	[2]			= &nfs_version2,
+#endif
 #ifdef CONFIG_NFS_V3
 #ifdef CONFIG_NFS_V3
 	[3]			= &nfs_version3,
 	[3]			= &nfs_version3,
 #endif
 #endif
@@ -847,7 +849,7 @@ static int nfs_init_server(struct nfs_server *server,
 		.hostname = data->nfs_server.hostname,
 		.hostname = data->nfs_server.hostname,
 		.addr = (const struct sockaddr *)&data->nfs_server.address,
 		.addr = (const struct sockaddr *)&data->nfs_server.address,
 		.addrlen = data->nfs_server.addrlen,
 		.addrlen = data->nfs_server.addrlen,
-		.rpc_ops = &nfs_v2_clientops,
+		.rpc_ops = NULL,
 		.proto = data->nfs_server.protocol,
 		.proto = data->nfs_server.protocol,
 		.net = data->net,
 		.net = data->net,
 	};
 	};
@@ -857,10 +859,20 @@ static int nfs_init_server(struct nfs_server *server,
 
 
 	dprintk("--> nfs_init_server()\n");
 	dprintk("--> nfs_init_server()\n");
 
 
+	switch (data->version) {
+#ifdef CONFIG_NFS_V2
+	case 2:
+		cl_init.rpc_ops = &nfs_v2_clientops;
+		break;
+#endif
 #ifdef CONFIG_NFS_V3
 #ifdef CONFIG_NFS_V3
-	if (data->version == 3)
+	case 3:
 		cl_init.rpc_ops = &nfs_v3_clientops;
 		cl_init.rpc_ops = &nfs_v3_clientops;
+		break;
 #endif
 #endif
+	default:
+		return -EPROTONOSUPPORT;
+	}
 
 
 	nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
 	nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
 			data->timeo, data->retrans);
 			data->timeo, data->retrans);