]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
nfs: move nfs_fhandle_hash to common include file
authorJeff Layton <jlayton@kernel.org>
Fri, 3 Mar 2023 12:16:02 +0000 (07:16 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 2 May 2025 05:39:20 +0000 (07:39 +0200)
[ Upstream commit e59fb6749ed833deee5b3cfd7e89925296d41f49 ]

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 <jlayton@kernel.org>
Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
Stable-dep-of: cd35b6cb4664 ("nfs: add missing selections of CONFIG_CRC32")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/nfs/internal.h
include/linux/nfs.h

index e8b692d41b26ebfb2e00a1d840a9bc130da26b0b..5c9166357ae7c849da53c51f8ee947a9a9661d5b 100644 (file)
@@ -721,27 +721,12 @@ u64 nfs_timespec_to_change_attr(const struct timespec *ts)
 }
 
 #ifdef CONFIG_CRC32
-/**
- * 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);
-}
 static inline u32 nfs_stateid_hash(const nfs4_stateid *stateid)
 {
        return ~crc32_le(0xFFFFFFFF, &stateid->other[0],
                                NFS4_STATEID_OTHER_SIZE);
 }
 #else
-static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
-{
-       return 0;
-}
 static inline u32 nfs_stateid_hash(nfs4_stateid *stateid)
 {
        return 0;
index 0dc7ad38a0da4f4df118806c8f9cf01876b1bcd5..a8b62a08e784f686506162f6f477aa2f1ec305aa 100644 (file)
@@ -10,6 +10,7 @@
 
 #include <linux/sunrpc/msg_prot.h>
 #include <linux/string.h>
+#include <linux/crc32.h>
 #include <uapi/linux/nfs.h>
 
 /*
@@ -52,4 +53,23 @@ enum nfs3_stable_how {
        /* used by direct.c to mark verf as invalid */
        NFS_INVALID_STABLE_HOW = -1
 };
+
+#ifdef CONFIG_CRC32
+/**
+ * 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);
+}
+#else /* CONFIG_CRC32 */
+static inline u32 nfs_fhandle_hash(const struct nfs_fh *fh)
+{
+       return 0;
+}
+#endif /* CONFIG_CRC32 */
 #endif /* _LINUX_NFS_H */