@@ -513,19 +513,21 @@ static inline int rhashtable_compare(struct rhashtable_compare_arg *arg,
}
/**
- * rhashtable_lookup_fast - search hash table, inlined version
+ * rhashtable_lookup_fast_cmpfn - search hash table, inlined version
* @ht: hash table
* @key: the pointer to the key
* @params: hash table parameters
+ * @obj_cmpfn: compare function
*
* Computes the hash value for the key and traverses the bucket chain looking
* for a entry with an identical key. The first matching entry is returned.
*
* Returns the first entry on which the compare function returned true.
*/
-static inline void *rhashtable_lookup_fast(
+static inline void *rhashtable_lookup_fast_cmpfn(
struct rhashtable *ht, const void *key,
- const struct rhashtable_params params)
+ const struct rhashtable_params params,
+ rht_obj_cmpfn_t obj_cmpfn)
{
struct rhashtable_compare_arg arg = {
.ht = ht,
@@ -541,8 +543,8 @@ static inline void *rhashtable_lookup_fast(
restart:
hash = rht_key_hashfn(ht, tbl, key, params);
rht_for_each_rcu(he, tbl, hash) {
- if (params.obj_cmpfn ?
- params.obj_cmpfn(&arg, rht_obj(ht, he)) :
+ if (obj_cmpfn ?
+ obj_cmpfn(&arg, rht_obj(ht, he)) :
rhashtable_compare(&arg, rht_obj(ht, he)))
continue;
rcu_read_unlock();
@@ -560,6 +562,14 @@ restart:
return NULL;
}
+static inline void *rhashtable_lookup_fast(
+ struct rhashtable *ht, const void *key,
+ const struct rhashtable_params params)
+{
+ return rhashtable_lookup_fast_cmpfn(ht, key, params,
+ params.obj_cmpfn);
+}
+
/* Internal function, please use rhashtable_insert_fast() instead */
static inline int __rhashtable_insert_fast(
struct rhashtable *ht, const void *key, struct rhash_head *obj,
Added rhashtable_lookup_fast_cmpfn which does a lookup in an rhash table with the compare function being taken from an argument. This allows different compare functions to be used on the same table. Signed-off-by: Tom Herbert <tom@herbertland.com> --- include/linux/rhashtable.h | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-)