Skip to content

Commit 2ba6800

Browse files
Bryan SchumakerTrond Myklebust
authored andcommitted
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>
1 parent 5e7e5a0 commit 2ba6800

3 files changed

Lines changed: 27 additions & 4 deletions

File tree

‎fs/nfs/Kconfig‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,16 @@ config NFS_FS
2929

3030
If unsure, say N.
3131

32+
config NFS_V2
33+
bool "NFS client support for NFS version 2"
34+
depends on NFS_FS
35+
default y
36+
help
37+
This option enables support for version 2 of the NFS protocol
38+
(RFC 1094) in the kernel's NFS client.
39+
40+
If unsure, say Y.
41+
3242
config NFS_V3
3343
bool "NFS client support for NFS version 3"
3444
depends on NFS_FS

‎fs/nfs/Makefile‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
obj-$(CONFIG_NFS_FS) += nfs.o
66

7-
nfs-y := client.o dir.o file.o getroot.o inode.o super.o nfs2xdr.o \
8-
direct.o pagelist.o proc.o read.o symlink.o unlink.o \
7+
nfs-y := client.o dir.o file.o getroot.o inode.o super.o \
8+
direct.o pagelist.o read.o symlink.o unlink.o \
99
write.o namespace.o mount_clnt.o \
1010
dns_resolve.o cache_lib.o
1111
nfs-$(CONFIG_ROOT_NFS) += nfsroot.o
12+
nfs-$(CONFIG_NFS_V2) += proc.o nfs2xdr.o
1213
nfs-$(CONFIG_NFS_V3) += nfs3proc.o nfs3xdr.o
1314
nfs-$(CONFIG_NFS_V3_ACL) += nfs3acl.o
1415
nfs-$(CONFIG_NFS_V4) += nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o \

‎fs/nfs/client.c‎

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,9 @@ static bool nfs4_disable_idmapping = true;
9090
* RPC cruft for NFS
9191
*/
9292
static const struct rpc_version *nfs_version[5] = {
93+
#ifdef CONFIG_NFS_V2
9394
[2] = &nfs_version2,
95+
#endif
9496
#ifdef CONFIG_NFS_V3
9597
[3] = &nfs_version3,
9698
#endif
@@ -847,7 +849,7 @@ static int nfs_init_server(struct nfs_server *server,
847849
.hostname = data->nfs_server.hostname,
848850
.addr = (const struct sockaddr *)&data->nfs_server.address,
849851
.addrlen = data->nfs_server.addrlen,
850-
.rpc_ops = &nfs_v2_clientops,
852+
.rpc_ops = NULL,
851853
.proto = data->nfs_server.protocol,
852854
.net = data->net,
853855
};
@@ -857,10 +859,20 @@ static int nfs_init_server(struct nfs_server *server,
857859

858860
dprintk("--> nfs_init_server()\n");
859861

862+
switch (data->version) {
863+
#ifdef CONFIG_NFS_V2
864+
case 2:
865+
cl_init.rpc_ops = &nfs_v2_clientops;
866+
break;
867+
#endif
860868
#ifdef CONFIG_NFS_V3
861-
if (data->version == 3)
869+
case 3:
862870
cl_init.rpc_ops = &nfs_v3_clientops;
871+
break;
863872
#endif
873+
default:
874+
return -EPROTONOSUPPORT;
875+
}
864876

865877
nfs_init_timeout_values(&timeparms, data->nfs_server.protocol,
866878
data->timeo, data->retrans);

0 commit comments

Comments
 (0)