mirror of
git://git.yoctoproject.org/linux-yocto.git
synced 2025-08-22 00:42:01 +02:00

[ Upstream commitcd35b6cb46
] 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>
61 lines
1.5 KiB
C
61 lines
1.5 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
/*
|
|
* NFS protocol definitions
|
|
*
|
|
* This file contains constants mostly for Version 2 of the protocol,
|
|
* but also has a couple of NFSv3 bits in (notably the error codes).
|
|
*/
|
|
#ifndef _LINUX_NFS_H
|
|
#define _LINUX_NFS_H
|
|
|
|
#include <linux/sunrpc/msg_prot.h>
|
|
#include <linux/string.h>
|
|
#include <linux/crc32.h>
|
|
#include <uapi/linux/nfs.h>
|
|
|
|
/*
|
|
* This is the kernel NFS client file handle representation
|
|
*/
|
|
#define NFS_MAXFHSIZE 128
|
|
struct nfs_fh {
|
|
unsigned short size;
|
|
unsigned char data[NFS_MAXFHSIZE];
|
|
};
|
|
|
|
/*
|
|
* Returns a zero iff the size and data fields match.
|
|
* Checks only "size" bytes in the data field.
|
|
*/
|
|
static inline int nfs_compare_fh(const struct nfs_fh *a, const struct nfs_fh *b)
|
|
{
|
|
return a->size != b->size || memcmp(a->data, b->data, a->size) != 0;
|
|
}
|
|
|
|
static inline void nfs_copy_fh(struct nfs_fh *target, const struct nfs_fh *source)
|
|
{
|
|
target->size = source->size;
|
|
memcpy(target->data, source->data, source->size);
|
|
}
|
|
|
|
enum nfs3_stable_how {
|
|
NFS_UNSTABLE = 0,
|
|
NFS_DATA_SYNC = 1,
|
|
NFS_FILE_SYNC = 2,
|
|
|
|
/* used by direct.c to mark verf as invalid */
|
|
NFS_INVALID_STABLE_HOW = -1
|
|
};
|
|
|
|
/**
|
|
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
|
|
* @fh - pointer to filehandle
|
|
*
|
|
* returns a crc32 hash for the filehandle that is compatible with
|
|
* the one displayed by "wireshark".
|
|
*/
|
|
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
|
|
{
|
|
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
|
|
}
|
|
#endif /* _LINUX_NFS_H */
|