4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License version 2 only,
8 * as published by the Free Software Foundation.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License version 2 for more details (a copy is included
14 * in the LICENSE file that accompanied this code).
16 * You should have received a copy of the GNU General Public License
17 * version 2 along with this program; If not, see
18 * http://www.gnu.org/licenses/gpl-2.0.html
23 #ifndef __LIBCFS_LINUX_HASH_H__
24 #define __LIBCFS_LINUX_HASH_H__
26 #include <linux/dcache.h>
27 #include <linux/rhashtable.h>
29 u64 cfs_hashlen_string(const void *salt, const char *name);
32 #define hashlen_hash(hashlen) ((u32)(hashlen))
35 #ifndef HAVE_STRINGHASH
36 #ifndef hashlen_create
37 #define hashlen_create(hash, len) ((u64)(len)<<32 | (u32)(hash))
39 #endif /* !HAVE_STRINGHASH */
41 #ifndef HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST
43 * rhashtable_lookup_get_insert_fast - lookup and insert object into hash table
45 * @obj: pointer to hash head inside object
46 * @params: hash table parameters
48 * Just like rhashtable_lookup_insert_fast(), but this function returns the
49 * object if it exists, NULL if it did not and the insertion was successful,
50 * and an ERR_PTR otherwise.
52 static inline void *rhashtable_lookup_get_insert_fast(
53 struct rhashtable *ht, struct rhash_head *obj,
54 const struct rhashtable_params params)
60 rc = rhashtable_lookup_insert_fast(ht, obj, params);
63 key = rht_obj(ht, obj);
64 ret = rhashtable_lookup_fast(ht, key, params);
75 #endif /* !HAVE_RHASHTABLE_LOOKUP_GET_INSERT_FAST */
77 #endif /* __LIBCFS_LINUX_MISC_H__ */