nfs: add missing selections of CONFIG_CRC32
[ Upstream commit cd35b6cb46649750b7dbd0df0e2d767415d8917b ]
nfs.ko, nfsd.ko, and lockd.ko all use crc32_le(), which is available
only when CONFIG_CRC32 is enabled. But the only NFS kconfig option that
selected CONFIG_CRC32 was CONFIG_NFS_DEBUG, which is client-specific and
did not actually guard the use of crc32_le() even on the client.
The code worked around this bug by only actually calling crc32_le() when
CONFIG_CRC32 is built-in, instead hard-coding '0' in other cases. This
avoided randconfig build errors, and in real kernels the fallback code
was unlikely to be reached since CONFIG_CRC32 is 'default y'. But, this
really needs to just be done properly, especially now that I'm planning
to update CONFIG_CRC32 to not be 'default y'.
Therefore, make CONFIG_NFS_FS, CONFIG_NFSD, and CONFIG_LOCKD select
CONFIG_CRC32. Then remove the fallback code that becomes unnecessary,
as well as the selection of CONFIG_CRC32 from CONFIG_NFS_DEBUG.
Fixes: 1264a2f053 ("NFS: refactor code for calculating the crc32 hash of a filehandle")
Signed-off-by: Eric Biggers <ebiggers@google.com>
Acked-by: Anna Schumaker <anna.schumaker@oracle.com>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
e22c8b99c8
commit
33c0f51f1a
@@ -369,6 +369,7 @@ config GRACE_PERIOD
|
|||||||
config LOCKD
|
config LOCKD
|
||||||
tristate
|
tristate
|
||||||
depends on FILE_LOCKING
|
depends on FILE_LOCKING
|
||||||
|
select CRC32
|
||||||
select GRACE_PERIOD
|
select GRACE_PERIOD
|
||||||
|
|
||||||
config LOCKD_V4
|
config LOCKD_V4
|
||||||
|
|||||||
+1
-1
@@ -2,6 +2,7 @@
|
|||||||
config NFS_FS
|
config NFS_FS
|
||||||
tristate "NFS client support"
|
tristate "NFS client support"
|
||||||
depends on INET && FILE_LOCKING && MULTIUSER
|
depends on INET && FILE_LOCKING && MULTIUSER
|
||||||
|
select CRC32
|
||||||
select LOCKD
|
select LOCKD
|
||||||
select SUNRPC
|
select SUNRPC
|
||||||
select NFS_COMMON
|
select NFS_COMMON
|
||||||
@@ -196,7 +197,6 @@ config NFS_USE_KERNEL_DNS
|
|||||||
config NFS_DEBUG
|
config NFS_DEBUG
|
||||||
bool
|
bool
|
||||||
depends on NFS_FS && SUNRPC_DEBUG
|
depends on NFS_FS && SUNRPC_DEBUG
|
||||||
select CRC32
|
|
||||||
default y
|
default y
|
||||||
|
|
||||||
config NFS_DISABLE_UDP_SUPPORT
|
config NFS_DISABLE_UDP_SUPPORT
|
||||||
|
|||||||
@@ -895,18 +895,11 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)
|
|||||||
return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
|
return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_CRC32
|
|
||||||
static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
|
static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
|
||||||
{
|
{
|
||||||
return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
|
return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
|
||||||
NFS4_STATEID_OTHER_SIZE);
|
NFS4_STATEID_OTHER_SIZE);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static inline bool nfs_error_is_fatal(int err)
|
static inline bool nfs_error_is_fatal(int err)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -148,16 +148,12 @@ static inline void nfs4_copy_sessionid(struct nfs4_sessionid *dst,
|
|||||||
memcpy(dst->data, src->data, NFS4_MAX_SESSIONID_LEN);
|
memcpy(dst->data, src->data, NFS4_MAX_SESSIONID_LEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_CRC32
|
|
||||||
/*
|
/*
|
||||||
* nfs_session_id_hash - calculate the crc32 hash for the session id
|
* nfs_session_id_hash - calculate the crc32 hash for the session id
|
||||||
* @session - pointer to session
|
* @session - pointer to session
|
||||||
*/
|
*/
|
||||||
#define nfs_session_id_hash(sess_id) \
|
#define nfs_session_id_hash(sess_id) \
|
||||||
(~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data)))
|
(~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data)))
|
||||||
#else
|
|
||||||
#define nfs_session_id_hash(session) (0)
|
|
||||||
#endif
|
|
||||||
#else /* defined(CONFIG_NFS_V4_1) */
|
#else /* defined(CONFIG_NFS_V4_1) */
|
||||||
|
|
||||||
static inline int nfs4_init_session(struct nfs_client *clp)
|
static inline int nfs4_init_session(struct nfs_client *clp)
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ config NFSD
|
|||||||
depends on INET
|
depends on INET
|
||||||
depends on FILE_LOCKING
|
depends on FILE_LOCKING
|
||||||
depends on FSNOTIFY
|
depends on FSNOTIFY
|
||||||
|
select CRC32
|
||||||
select LOCKD
|
select LOCKD
|
||||||
select SUNRPC
|
select SUNRPC
|
||||||
select EXPORTFS
|
select EXPORTFS
|
||||||
|
|||||||
@@ -267,7 +267,6 @@ static inline bool fh_fsid_match(const struct knfsd_fh *fh1,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_CRC32
|
|
||||||
/**
|
/**
|
||||||
* knfsd_fh_hash - calculate the crc32 hash for the filehandle
|
* knfsd_fh_hash - calculate the crc32 hash for the filehandle
|
||||||
* @fh - pointer to filehandle
|
* @fh - pointer to filehandle
|
||||||
@@ -279,12 +278,6 @@ static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh)
|
|||||||
{
|
{
|
||||||
return ~crc32_le(0xFFFFFFFF, fh->fh_raw, fh->fh_size);
|
return ~crc32_le(0xFFFFFFFF, fh->fh_raw, fh->fh_size);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* fh_clear_pre_post_attrs - Reset pre/post attributes
|
* fh_clear_pre_post_attrs - Reset pre/post attributes
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ enum nfs3_stable_how {
|
|||||||
NFS_INVALID_STABLE_HOW = -1
|
NFS_INVALID_STABLE_HOW = -1
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef CONFIG_CRC32
|
|
||||||
/**
|
/**
|
||||||
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
|
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
|
||||||
* @fh - pointer to filehandle
|
* @fh - pointer to filehandle
|
||||||
@@ -67,10 +66,4 @@ static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
|
|||||||
{
|
{
|
||||||
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
|
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
|
||||||
}
|
}
|
||||||
#else /* CONFIG_CRC32 */
|
|
||||||
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
#endif /* CONFIG_CRC32 */
|
|
||||||
#endif /* _LINUX_NFS_H */
|
#endif /* _LINUX_NFS_H */
|
||||||
|
|||||||
Reference in New Issue
Block a user