Skip to content

Commit 26bea35

Browse files
ebiggersvijay-suman
authored andcommitted
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: 1264a2f ("NFS: refactor code for calculating the crc32 hash of a filehandle") Signed-off-by: Eric Biggers <[email protected]> Acked-by: Anna Schumaker <[email protected]> Signed-off-by: Chuck Lever <[email protected]> Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit bf5f65aebeafc158de14e5762c8fc92a58b76c06) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent 43f9483 commit 26bea35

File tree

7 files changed

+3
-26
lines changed

7 files changed

+3
-26
lines changed

fs/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ config GRACE_PERIOD
339339
config LOCKD
340340
tristate
341341
depends on FILE_LOCKING
342+
select CRC32
342343
select GRACE_PERIOD
343344

344345
config LOCKD_V4

fs/nfs/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
config NFS_FS
33
tristate "NFS client support"
44
depends on INET && FILE_LOCKING && MULTIUSER
5+
select CRC32
56
select LOCKD
67
select SUNRPC
78
select NFS_ACL_SUPPORT if NFS_V3_ACL
@@ -194,7 +195,6 @@ config NFS_USE_KERNEL_DNS
194195
config NFS_DEBUG
195196
bool
196197
depends on NFS_FS && SUNRPC_DEBUG
197-
select CRC32
198198
default y
199199

200200
config NFS_DISABLE_UDP_SUPPORT

fs/nfs/internal.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -770,18 +770,11 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)
770770
return ((u64)ts->tv_sec << 30) + ts->tv_nsec;
771771
}
772772

773-
#ifdef CONFIG_CRC32
774773
static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
775774
{
776775
return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
777776
NFS4_STATEID_OTHER_SIZE);
778777
}
779-
#else
780-
static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
781-
{
782-
return 0;
783-
}
784-
#endif
785778

786779
static inline bool nfs_error_is_fatal(int err)
787780
{

fs/nfs/nfs4session.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,12 @@ static inline void nfs4_copy_sessionid(struct nfs4_sessionid *dst,
147147
memcpy(dst->data, src->data, NFS4_MAX_SESSIONID_LEN);
148148
}
149149

150-
#ifdef CONFIG_CRC32
151150
/*
152151
* nfs_session_id_hash - calculate the crc32 hash for the session id
153152
* @session - pointer to session
154153
*/
155154
#define nfs_session_id_hash(sess_id) \
156155
(~crc32_le(0xFFFFFFFF, &(sess_id)->data[0], sizeof((sess_id)->data)))
157-
#else
158-
#define nfs_session_id_hash(session) (0)
159-
#endif
160156
#else /* defined(CONFIG_NFS_V4_1) */
161157

162158
static inline int nfs4_init_session(struct nfs_client *clp)

fs/nfsd/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ config NFSD
44
depends on INET
55
depends on FILE_LOCKING
66
depends on FSNOTIFY
7+
select CRC32
78
select LOCKD
89
select SUNRPC
910
select EXPORTFS

fs/nfsd/nfsfh.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,6 @@ static inline bool fh_fsid_match(const struct knfsd_fh *fh1,
263263
return true;
264264
}
265265

266-
#ifdef CONFIG_CRC32
267266
/**
268267
* knfsd_fh_hash - calculate the crc32 hash for the filehandle
269268
* @fh - pointer to filehandle
@@ -275,12 +274,6 @@ static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh)
275274
{
276275
return ~crc32_le(0xFFFFFFFF, fh->fh_raw, fh->fh_size);
277276
}
278-
#else
279-
static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh)
280-
{
281-
return 0;
282-
}
283-
#endif
284277

285278
/**
286279
* fh_clear_pre_post_attrs - Reset pre/post attributes

include/linux/nfs.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@ enum nfs3_stable_how {
4646
NFS_INVALID_STABLE_HOW = -1
4747
};
4848

49-
#ifdef CONFIG_CRC32
5049
/**
5150
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
5251
* @fh - pointer to filehandle
@@ -58,10 +57,4 @@ static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
5857
{
5958
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
6059
}
61-
#else /* CONFIG_CRC32 */
62-
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
63-
{
64-
return 0;
65-
}
66-
#endif /* CONFIG_CRC32 */
6760
#endif /* _LINUX_NFS_H */

0 commit comments

Comments
 (0)