--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __LINUX_HASH_LUSTRE_H__
+#define __LINUX_HASH_LUSTRE_H__
+
+#include <linux/types.h>
+#include <linux/hash.h>
+
+#ifdef HAVE_BROKEN_HASH_64
+
+#define GOLDEN_RATIO_32 0x61C88647
+#define GOLDEN_RATIO_64 0x61C8864680B583EBull
+
+static inline u32 cfs_hash_32(u32 val, unsigned int bits)
+{
+ /* High bits are more random, so use them. */
+ return (val * GOLDEN_RATIO_32) >> (32 - bits);
+}
+
+static __always_inline u32 cfs_hash_64(u64 val, unsigned int bits)
+{
+#if BITS_PER_LONG == 64
+ /* 64x64-bit multiply is efficient on all 64-bit processors */
+ return val * GOLDEN_RATIO_64 >> (64 - bits);
+#else
+ /* Hash 64 bits using only 32x32-bit multiply. */
+ return cfs_hash_32(((u32)val ^ ((val >> 32) * GOLDEN_RATIO_32)), bits);
+#endif
+}
+
+#if BITS_PER_LONG == 32
+#define cfs_hash_long(val, bits) cfs_hash_32(val, bits)
+#elif BITS_PER_LONG == 64
+#define cfs_hash_long(val, bits) cfs_hash_64(val, bits)
+#else
+#error Wordsize not 32 or 64
+#endif
+
+#else
+
+#define cfs_hash_32 hash_32
+#define cfs_hash_64 hash_64
+#define cfs_hash_long hash_long
+
+#endif /* HAVE_BROKEN_HASH_64 */
+#endif /* __LINUX_HASH_LUSTRE_H__ */
/* SPDX-License-Identifier: GPL-2.0 */
-#ifndef __LIBCFS_LINUX_HASH_H__
-#define __LIBCFS_LINUX_HASH_H__
+#ifndef _LINUX_RHASHTABLE_LUSTRE_H
+#define _LINUX_RHASHTABLE_LUSTRE_H
-#include <linux/dcache.h>
#include <linux/rhashtable.h>
-u64 cfs_hashlen_string(const void *salt, const char *name);
-
-#ifndef hashlen_hash
-#define hashlen_hash(hashlen) ((u32)(hashlen))
-#endif
-
-#ifndef HAVE_STRINGHASH
-#ifndef hashlen_create
-#define hashlen_create(hash, len) ((u64)(len)<<32 | (u32)(hash))
-#endif
-#endif /* !HAVE_STRINGHASH */
-
-#ifdef HAVE_BROKEN_HASH_64
-
-#define GOLDEN_RATIO_32 0x61C88647
-#define GOLDEN_RATIO_64 0x61C8864680B583EBull
-
-static inline u32 cfs_hash_32(u32 val, unsigned int bits)
-{
- /* High bits are more random, so use them. */
- return (val * GOLDEN_RATIO_32) >> (32 - bits);
-}
-
-static __always_inline u32 cfs_hash_64(u64 val, unsigned int bits)
-{
-#if BITS_PER_LONG == 64
- /* 64x64-bit multiply is efficient on all 64-bit processors */
- return val * GOLDEN_RATIO_64 >> (64 - bits);
-#else
- /* Hash 64 bits using only 32x32-bit multiply. */
- return cfs_hash_32(((u32)val ^ ((val >> 32) * GOLDEN_RATIO_32)), bits);
-#endif
-}
-
-#if BITS_PER_LONG == 32
-#define cfs_hash_long(val, bits) cfs_hash_32(val, bits)
-#elif BITS_PER_LONG == 64
-#define cfs_hash_long(val, bits) cfs_hash_64(val, bits)
-#else
-#error Wordsize not 32 or 64
-#endif
-
-#else
-
-#define cfs_hash_32 hash_32
-#define cfs_hash_64 hash_64
-#define cfs_hash_long hash_long
-
-#endif /* HAVE_BROKEN_HASH_64 */
-
#ifndef HAVE_RHASHTABLE_WALK_ENTER
static int rhashtable_walk_enter(struct rhashtable *ht,
struct rhashtable_iter *iter)
}
#endif /* HAVE_RHASHTABLE_REPLACE */
-#endif /* __LIBCFS_LINUX_HASH_H__ */
+#endif /* _LINUX_RHASHTABLE_LUSTRE_H */
--- /dev/null
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef __LINUX_STRINGHASH_LUSTRE_H
+#define __LINUX_STRINGHASH_LUSTRE_H
+
+#include <linux/dcache.h>
+#include <linux/types.h>
+
+#ifndef HAVE_STRINGHASH
+
+u64 hashlen_string(const void *salt, const char *name);
+
+#ifndef hashlen_hash
+#define hashlen_hash(hashlen) ((u32)(hashlen))
+#endif
+
+#ifndef hashlen_create
+#define hashlen_create(hash, len) ((u64)(len)<<32 | (u32)(hash))
+#endif
+
+#else
+#include <linux/stringhash.h>
+#endif /* !HAVE_STRINGHASH */
+
+#endif /* !__LINUX_STRINGHASH_LUSTRE_H */
#include <linux/sched/signal.h>
#endif
-#include <libcfs/linux/linux-hash.h>
#include <libcfs/linux/linux-misc.h>
#include <libcfs/linux/linux-mem.h>
#include <libcfs/linux/linux-time.h>
#
EXTRA_DIST = linux-misc.h linux-fs.h linux-mem.h linux-time.h linux-cpu.h \
- linux-list.h linux-hash.h linux-wait.h linux-net.h \
+ linux-list.h linux-wait.h linux-net.h \
refcount.h processor.h linux-fortify-string.h
include $(libcfs_dir)/../../lustre_compat/lib/Makefile
libcfs-linux-objs := linux-prim.o
-libcfs-linux-objs += linux-hash.o
libcfs-linux-objs += linux-wait.o
libcfs-compat-objs += $(patsubst %,$(COMPAT)%,$(compat_objs))
#
EXTRA_DIST = linux-prim.c \
- linux-hash.c \
linux-wait.c
+++ /dev/null
-// SPDX-License-Identifier: GPL-2.0
-
-#define DEBUG_SUBSYSTEM S_LNET
-
-#include <linux/module.h>
-#ifdef HAVE_STRINGHASH
-#include <linux/stringhash.h>
-#else
-#include <linux/dcache.h>
-#endif
-#include <linux/hash.h>
-
-#include <libcfs/linux/linux-hash.h>
-
-/* Return the "hash_len" (hash and length) of a null-terminated string */
-/* The kernel equivalent is in fs/namei.c but for some strange reason
- * RHEL7.5 stuck it in dax/super.c instead. This placement never existed
- * upstream so to make life easier we just have the equavilent
- */
-u64 cfs_hashlen_string(const void *salt, const char *name)
-{
-#ifdef HAVE_FULL_NAME_HASH_3ARGS
- unsigned long hash = init_name_hash(salt);
-#else
- unsigned long hash = init_name_hash();
-#endif
- unsigned long len = 0, c;
-
- c = (unsigned char)*name;
- while (c) {
- len++;
- hash = partial_name_hash(c, hash);
- c = (unsigned char)name[len];
- }
- return hashlen_create(end_name_hash(hash), len);
-}
-EXPORT_SYMBOL(cfs_hashlen_string);
* The implementation of the wait_bit*() and related waiting APIs:
*/
-#include <libcfs/linux/linux-hash.h>
#include <linux/sched.h>
#ifdef HAVE_SCHED_HEADERS
#include <linux/sched/signal.h>
#define CFS_FAIL_DELAY_MSG_FORWARD 0xe002
#include <lustre_compat/linux/generic-radix-tree.h>
+#include <lustre_compat/linux/hash.h>
#include <linux/netdevice.h>
#include <libcfs/libcfs.h>
#include <linux/workqueue.h>
#include <linux/refcount.h>
#include <libcfs/libcfs.h>
-#include <libcfs/linux/linux-hash.h>
/* disable debug */
#define CFS_HASH_DEBUG_NONE 0
* Even so, the MDT and OST resources are also in different LDLM namespaces.
*/
+#include <lustre_compat/linux/hash.h>
#include <libcfs/libcfs.h>
#include <lu_object.h>
#include <uapi/linux/lustre/lustre_fid.h>
* CRR-N, Client Round Robin over NIDs
* @{
*/
-#include <libcfs/linux/linux-hash.h>
/**
* private data structure for CRR-N NRS
#include <lustre_dlm.h>
#include <lustre_fid.h>
#include <obd_class.h>
-#include <libcfs/linux/linux-hash.h>
#include "ldlm_internal.h"
struct kmem_cache *ldlm_resource_slab, *ldlm_lock_slab;
#include <linux/seq_file.h>
#include <linux/namei.h>
+#include <lustre_compat/linux/stringhash.h>
+
#include <obd_support.h>
#include <lustre_lib.h>
#include <lustre_net.h>
#include <uapi/linux/lustre/lustre_ioctl.h>
#include <lustre_ioctl_old.h>
#include <lustre_kernelcomm.h>
+
#include "lmv_internal.h"
static int lmv_check_connect(struct obd_device *obd);
{
const char *name = data;
- return hashlen_hash(cfs_hashlen_string((void *)(unsigned long)seed,
- name));
+ return hashlen_hash(hashlen_string((void *)(unsigned long)seed,
+ name));
}
static int qos_exclude_cmpfn(struct rhashtable_compare_arg *arg,
#define DEBUG_SUBSYSTEM S_LOV
+#include <lustre_compat/linux/stringhash.h>
+#include <lustre_compat/linux/rhashtable.h>
+
#include <libcfs/libcfs.h>
-#include <libcfs/linux/linux-hash.h>
#include <libcfs/linux/linux-fs.h>
#include <obd.h>
+
#include "lod_internal.h"
#define pool_tgt(_p, _i) OST_TGT(lu2lod_dev((_p)->pool_lobd->obd_lu_dev), \
{
const char *pool_name = data;
- return hashlen_hash(cfs_hashlen_string((void *)(unsigned long)seed,
- pool_name));
+ return hashlen_hash(hashlen_string((void *)(unsigned long)seed,
+ pool_name));
}
static int pool_cmpfn(struct rhashtable_compare_arg *arg, const void *obj)
#define DEBUG_SUBSYSTEM S_LOV
+#include <lustre_compat/linux/stringhash.h>
+#include <lustre_compat/linux/rhashtable.h>
+
#include <libcfs/libcfs.h>
-#include <libcfs/linux/linux-hash.h>
#include <libcfs/linux/linux-fs.h>
-
#include <obd.h>
+
#include "lov_internal.h"
#define pool_tgt(_p, _i) \
{
const char *pool_name = data;
- return hashlen_hash(cfs_hashlen_string((void *)(unsigned long)seed,
- pool_name));
+ return hashlen_hash(hashlen_string((void *)(unsigned long)seed,
+ pool_name));
}
/**
#include <linux/processor.h>
#include <linux/random.h>
+#include <lustre_compat/linux/rhashtable.h>
+
#include <libcfs/libcfs.h>
#include <libcfs/linux/linux-mem.h>
-#include <libcfs/linux/linux-hash.h>
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_disk.h>
#define DEBUG_SUBSYSTEM S_RPC
#include <linux/delay.h>
-#include <libcfs/linux/linux-hash.h>
+#include <lustre_compat/linux/rhashtable.h>
#include <obd_support.h>
#include <obd_class.h>
#include <lustre_net.h>
#include <net/sock.h>
#include <linux/un.h>
+#include <lustre_compat/linux/hash.h>
+
#include <obd.h>
#include <obd_class.h>
#include <obd_support.h>
#include <lustre_net.h>
#include <lustre_nodemap.h>
#include <lustre_sec.h>
-#include <libcfs/linux/linux-hash.h>
#include "gss_err.h"
#include "gss_internal.h"