Skip to content

Commit cd35b6c

Browse files
ebiggerschucklever
authored andcommitted
nfs: add missing selections of CONFIG_CRC32
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]>
1 parent 26a8076 commit cd35b6c

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
@@ -368,6 +368,7 @@ config GRACE_PERIOD
368368
config LOCKD
369369
tristate
370370
depends on FILE_LOCKING
371+
select CRC32
371372
select GRACE_PERIOD
372373

373374
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_COMMON
@@ -196,7 +197,6 @@ config NFS_USE_KERNEL_DNS
196197
config NFS_DEBUG
197198
bool
198199
depends on NFS_FS && SUNRPC_DEBUG
199-
select CRC32
200200
default y
201201

202202
config NFS_DISABLE_UDP_SUPPORT

fs/nfs/internal.h

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

902-
#ifdef CONFIG_CRC32
903902
static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
904903
{
905904
return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
906905
NFS4_STATEID_OTHER_SIZE);
907906
}
908-
#else
909-
static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
910-
{
911-
return 0;
912-
}
913-
#endif
914907

915908
static inline bool nfs_error_is_fatal(int err)
916909
{

fs/nfs/nfs4session.h

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

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

163159
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
@@ -267,7 +267,6 @@ static inline bool fh_fsid_match(const struct knfsd_fh *fh1,
267267
return true;
268268
}
269269

270-
#ifdef CONFIG_CRC32
271270
/**
272271
* knfsd_fh_hash - calculate the crc32 hash for the filehandle
273272
* @fh - pointer to filehandle
@@ -279,12 +278,6 @@ static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh)
279278
{
280279
return ~crc32_le(0xFFFFFFFF, fh->fh_raw, fh->fh_size);
281280
}
282-
#else
283-
static inline u32 knfsd_fh_hash(const struct knfsd_fh *fh)
284-
{
285-
return 0;
286-
}
287-
#endif
288281

289282
/**
290283
* 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
@@ -55,7 +55,6 @@ enum nfs3_stable_how {
5555
NFS_INVALID_STABLE_HOW = -1
5656
};
5757

58-
#ifdef CONFIG_CRC32
5958
/**
6059
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
6160
* @fh - pointer to filehandle
@@ -67,10 +66,4 @@ static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
6766
{
6867
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
6968
}
70-
#else /* CONFIG_CRC32 */
71-
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
72-
{
73-
return 0;
74-
}
75-
#endif /* CONFIG_CRC32 */
7669
#endif /* _LINUX_NFS_H */

0 commit comments

Comments
 (0)