Skip to content

Commit e59fb67

Browse files
jtlaytonchucklever
authored andcommitted
nfs: move nfs_fhandle_hash to common include file
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]>
1 parent 244cc19 commit e59fb67

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
@@ -846,27 +846,12 @@ u64 nfs_timespec_to_change_attr(const struct timespec64 *ts)
846846
}
847847

848848
#ifdef CONFIG_CRC32
849-
/**
850-
* nfs_fhandle_hash - calculate the crc32 hash for the filehandle
851-
* @fh - pointer to filehandle
852-
*
853-
* returns a crc32 hash for the filehandle that is compatible with
854-
* the one displayed by "wireshark".
855-
*/
856-
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
857-
{
858-
return ~crc32_le(0xFFFFFFFF, &fh->data[0], fh->size);
859-
}
860849
static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
861850
{
862851
return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
863852
NFS4_STATEID_OTHER_SIZE);
864853
}
865854
#else
866-
static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
867-
{
868-
return 0;
869-
}
870855
static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
871856
{
872857
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)