Skip to content

Commit 43f9483

Browse files
jtlaytonvijay-suman
authored andcommitted
nfs: move nfs_fhandle_hash to common include file
[ Upstream commit e59fb67 ] lockd needs to be able to hash filehandles for tracepoints. Move the nfs_fhandle_hash() helper to a common nfs include file. Signed-off-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]> Stable-dep-of: cd35b6cb4664 ("nfs: add missing selections of CONFIG_CRC32") Signed-off-by: Sasha Levin <[email protected]> (cherry picked from commit 72f7ccad7ed5096cc71e85543dd1d850997bc53a) Signed-off-by: Vijayendra Suman <[email protected]>
1 parent f2e3f8d commit 43f9483

File tree

2 files changed

+20
-15
lines changed

2 files changed

+20
-15
lines changed

fs/nfs/internal.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -771,27 +771,12 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)
771771
}
772772

773773
#ifdef CONFIG_CRC32
774-
/**
775-
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
776-
* @fh - pointer to filehandle
777-
*
778-
* returns a crc32 hash for the filehandle that is compatible with
779-
* the one displayed by "wireshark".
780-
*/
781-
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
782-
{
783-
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
784-
}
785774
static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
786775
{
787776
return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
788777
NFS4_STATEID_OTHER_SIZE);
789778
}
790779
#else
791-
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
792-
{
793-
return 0;
794-
}
795780
static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
796781
{
797782
return 0;

include/linux/nfs.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
#include <linux/sunrpc/msg_prot.h>
1212
#include <linux/string.h>
13+
#include <linux/crc32.h>
1314
#include <uapi/linux/nfs.h>
1415

1516
/*
@@ -44,4 +45,23 @@ enum nfs3_stable_how {
4445
/* used by direct.c to mark verf as invalid */
4546
NFS_INVALID_STABLE_HOW = -1
4647
};
48+
49+
#ifdef CONFIG_CRC32
50+
/**
51+
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
52+
* @fh - pointer to filehandle
53+
*
54+
* returns a crc32 hash for the filehandle that is compatible with
55+
* the one displayed by "wireshark".
56+
*/
57+
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
58+
{
59+
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
60+
}
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 */
4767
#endif /* _LINUX_NFS_H */

0 commit comments

Comments
 (0)