Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

NFS: Add a way to disable NFS v4.0 via KConfig

I introduce NFS4_MIN_MINOR_VERSION as a parallel to
NFS4_MAX_MINOR_VERSION to check if NFS v4.0 has been compiled in and
return an appropriate error if not.

Signed-off-by: Anna Schumaker <anna.schumaker@oracle.com>

+47 -5
+9
fs/nfs/Kconfig
··· 96 96 help 97 97 This option enables swapon to work on files located on NFS mounts. 98 98 99 + config NFS_V4_0 100 + bool "NFS client support for NFSv4.0" 101 + depends on NFS_V4 102 + help 103 + This option enables support for minor version 0 of the NFSv4 protocol 104 + (RFC 3530) in the kernel's NFS client. 105 + 106 + If unsure, say N. 107 + 99 108 config NFS_V4_1 100 109 bool "NFS client support for NFSv4.1" 101 110 depends on NFS_V4
+2 -1
fs/nfs/Makefile
··· 27 27 nfsv4-y := nfs4proc.o nfs4xdr.o nfs4state.o nfs4renewd.o nfs4super.o nfs4file.o \ 28 28 delegation.o nfs4idmap.o callback.o callback_xdr.o callback_proc.o \ 29 29 nfs4namespace.o nfs4getroot.o nfs4client.o nfs4session.o \ 30 - dns_resolve.o nfs4trace.o nfs40proc.o nfs40client.o 30 + dns_resolve.o nfs4trace.o 31 31 nfsv4-$(CONFIG_NFS_USE_LEGACY_DNS) += cache_lib.o 32 32 nfsv4-$(CONFIG_SYSCTL) += nfs4sysctl.o 33 + nfsv4-$(CONFIG_NFS_V4_0) += nfs40client.o nfs40proc.o 33 34 nfsv4-$(CONFIG_NFS_V4_1) += pnfs.o pnfs_dev.o pnfs_nfs.o 34 35 nfsv4-$(CONFIG_NFS_V4_2) += nfs42proc.o nfs42xattr.o 35 36
+2 -1
fs/nfs/fs_context.c
··· 806 806 ctx->mount_server.version = result.uint_32; 807 807 break; 808 808 case Opt_minorversion: 809 - if (result.uint_32 > NFS4_MAX_MINOR_VERSION) 809 + if (result.uint_32 < NFS4_MIN_MINOR_VERSION || 810 + result.uint_32 > NFS4_MAX_MINOR_VERSION) 810 811 goto out_of_bounds; 811 812 ctx->minorversion = result.uint_32; 812 813 break;
+6
fs/nfs/nfs4_fs.h
··· 10 10 #ifndef __LINUX_FS_NFS_NFS4_FS_H 11 11 #define __LINUX_FS_NFS_NFS4_FS_H 12 12 13 + #if defined(CONFIG_NFS_V4_0) 14 + #define NFS4_MIN_MINOR_VERSION 0 15 + #else 16 + #define NFS4_MIN_MINOR_VERSION 1 17 + #endif 18 + 13 19 #if defined(CONFIG_NFS_V4_2) 14 20 #define NFS4_MAX_MINOR_VERSION 2 15 21 #elif defined(CONFIG_NFS_V4_1)
+2 -1
fs/nfs/nfs4client.c
··· 203 203 if (err) 204 204 goto error; 205 205 206 - if (cl_init->minorversion > NFS4_MAX_MINOR_VERSION) { 206 + if (cl_init->minorversion < NFS4_MIN_MINOR_VERSION || 207 + cl_init->minorversion > NFS4_MAX_MINOR_VERSION) { 207 208 err = -EINVAL; 208 209 goto error; 209 210 }
+2
fs/nfs/nfs4proc.c
··· 10591 10591 #endif 10592 10592 10593 10593 const struct nfs4_minor_version_ops *nfs_v4_minor_ops[] = { 10594 + #if defined(CONFIG_NFS_V4_0) 10594 10595 [0] = &nfs_v4_0_minor_ops, 10596 + #endif /* CONFIG_NFS_V4_0 */ 10595 10597 #if defined(CONFIG_NFS_V4_1) 10596 10598 [1] = &nfs_v4_1_minor_ops, 10597 10599 #endif
+2
fs/nfs/nfs4state.c
··· 1804 1804 switch (error) { 1805 1805 case 0: 1806 1806 break; 1807 + #if IS_ENABLED(CONFIG_NFS_V4_0) 1807 1808 case -NFS4ERR_CB_PATH_DOWN: 1808 1809 nfs40_handle_cb_pathdown(clp); 1809 1810 break; 1811 + #endif /* CONFIG_NFS_V4_0 */ 1810 1812 case -NFS4ERR_NO_GRACE: 1811 1813 nfs4_state_end_reclaim_reboot(clp); 1812 1814 break;
+22 -2
fs/nfs/nfs4xdr.c
··· 1399 1399 xdr_encode_hyper(p, nfs4_lock_length(args->fl)); 1400 1400 } 1401 1401 1402 + #if defined(CONFIG_NFS_V4_0) 1402 1403 static void encode_release_lockowner(struct xdr_stream *xdr, const struct nfs_lowner *lowner, struct compound_hdr *hdr) 1403 1404 { 1404 1405 encode_op_hdr(xdr, OP_RELEASE_LOCKOWNER, decode_release_lockowner_maxsz, hdr); 1405 1406 encode_lockowner(xdr, lowner); 1406 1407 } 1408 + #endif /* CONFIG_NFS_V4_0 */ 1407 1409 1408 1410 static void encode_lookup(struct xdr_stream *xdr, const struct qstr *name, struct compound_hdr *hdr) 1409 1411 { ··· 2585 2583 encode_nops(&hdr); 2586 2584 } 2587 2585 2586 + #if defined(CONFIG_NFS_V4_0) 2588 2587 static void nfs4_xdr_enc_release_lockowner(struct rpc_rqst *req, 2589 2588 struct xdr_stream *xdr, 2590 2589 const void *data) ··· 2599 2596 encode_release_lockowner(xdr, &args->lock_owner, &hdr); 2600 2597 encode_nops(&hdr); 2601 2598 } 2599 + #endif /* CONFIG_NFS_V4_0 */ 2602 2600 2603 2601 /* 2604 2602 * Encode a READLINK request ··· 2829 2825 /* 2830 2826 * a RENEW request 2831 2827 */ 2828 + #if defined(CONFIG_NFS_V4_0) 2832 2829 static void nfs4_xdr_enc_renew(struct rpc_rqst *req, struct xdr_stream *xdr, 2833 2830 const void *data) 2834 2831 ··· 2843 2838 encode_renew(xdr, clp->cl_clientid, &hdr); 2844 2839 encode_nops(&hdr); 2845 2840 } 2841 + #endif /* CONFIG_NFS_V4_0 */ 2846 2842 2847 2843 /* 2848 2844 * a SETCLIENTID request ··· 5230 5224 return status; 5231 5225 } 5232 5226 5227 + #if defined(CONFIG_NFS_V4_0) 5233 5228 static int decode_release_lockowner(struct xdr_stream *xdr) 5234 5229 { 5235 5230 return decode_op_hdr(xdr, OP_RELEASE_LOCKOWNER); 5236 5231 } 5232 + #endif /* CONFIG_NFS_V4_0 */ 5237 5233 5238 5234 static int decode_lookup(struct xdr_stream *xdr) 5239 5235 { ··· 6938 6930 return status; 6939 6931 } 6940 6932 6933 + #if defined(CONFIG_NFS_V4_0) 6941 6934 static int nfs4_xdr_dec_release_lockowner(struct rpc_rqst *rqstp, 6942 6935 struct xdr_stream *xdr, void *dummy) 6943 6936 { ··· 6950 6941 status = decode_release_lockowner(xdr); 6951 6942 return status; 6952 6943 } 6944 + #endif /* CONFIG_NFS_V4_0 */ 6953 6945 6954 6946 /* 6955 6947 * Decode READLINK response ··· 7172 7162 /* 7173 7163 * Decode RENEW response 7174 7164 */ 7165 + #if defined(CONFIG_NFS_V4_0) 7175 7166 static int nfs4_xdr_dec_renew(struct rpc_rqst *rqstp, struct xdr_stream *xdr, 7176 7167 void *__unused) 7177 7168 { ··· 7184 7173 status = decode_renew(xdr); 7185 7174 return status; 7186 7175 } 7176 + #endif /* CONFIG_NFS_V4_0 */ 7187 7177 7188 7178 /* 7189 7179 * Decode SETCLIENTID response ··· 7766 7754 .p_name = #proc, \ 7767 7755 } 7768 7756 7757 + #if defined(CONFIG_NFS_V4_0) 7758 + #define PROC40(proc, argtype, restype) \ 7759 + PROC(proc, argtype, restype) 7760 + #else 7761 + #define PROC40(proc, argtype, restype) \ 7762 + STUB(proc) 7763 + #endif /* CONFIG_NFS_V4_0 */ 7764 + 7769 7765 #if defined(CONFIG_NFS_V4_1) 7770 7766 #define PROC41(proc, argtype, restype) \ 7771 7767 PROC(proc, argtype, restype) ··· 7801 7781 PROC(CLOSE, enc_close, dec_close), 7802 7782 PROC(SETATTR, enc_setattr, dec_setattr), 7803 7783 PROC(FSINFO, enc_fsinfo, dec_fsinfo), 7804 - PROC(RENEW, enc_renew, dec_renew), 7784 + PROC40(RENEW, enc_renew, dec_renew), 7805 7785 PROC(SETCLIENTID, enc_setclientid, dec_setclientid), 7806 7786 PROC(SETCLIENTID_CONFIRM, enc_setclientid_confirm, dec_setclientid_confirm), 7807 7787 PROC(LOCK, enc_lock, dec_lock), ··· 7825 7805 PROC(GETACL, enc_getacl, dec_getacl), 7826 7806 PROC(SETACL, enc_setacl, dec_setacl), 7827 7807 PROC(FS_LOCATIONS, enc_fs_locations, dec_fs_locations), 7828 - PROC(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), 7808 + PROC40(RELEASE_LOCKOWNER, enc_release_lockowner, dec_release_lockowner), 7829 7809 PROC(SECINFO, enc_secinfo, dec_secinfo), 7830 7810 PROC(FSID_PRESENT, enc_fsid_present, dec_fsid_present), 7831 7811 PROC41(EXCHANGE_ID, enc_exchange_id, dec_exchange_id),