Skip to content

Commit f9fe1c1

Browse files
Andreas Gruenbacherdavem330
authored andcommitted
rhashtable: Add rhashtable_lookup_get_insert_fast
Add rhashtable_lookup_get_insert_fast for fixed keys, similar to rhashtable_lookup_get_insert_key for explicit keys. Signed-off-by: Andreas Gruenbacher <agruenba@redhat.com> Acked-by: Herbert Xu <herbert@gondor.apana.org.au> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 9549c6c commit f9fe1c1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

include/linux/rhashtable.h

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -915,6 +915,28 @@ static inline int rhashtable_lookup_insert_fast(
915915
return ret == NULL ? 0 : -EEXIST;
916916
}
917917

918+
/**
919+
* rhashtable_lookup_get_insert_fast - lookup and insert object into hash table
920+
* @ht: hash table
921+
* @obj: pointer to hash head inside object
922+
* @params: hash table parameters
923+
*
924+
* Just like rhashtable_lookup_insert_fast(), but this function returns the
925+
* object if it exists, NULL if it did not and the insertion was successful,
926+
* and an ERR_PTR otherwise.
927+
*/
928+
static inline void *rhashtable_lookup_get_insert_fast(
929+
struct rhashtable *ht, struct rhash_head *obj,
930+
const struct rhashtable_params params)
931+
{
932+
const char *key = rht_obj(ht, obj);
933+
934+
BUG_ON(ht->p.obj_hashfn);
935+
936+
return __rhashtable_insert_fast(ht, key + ht->p.key_offset, obj, params,
937+
false);
938+
}
939+
918940
/**
919941
* rhashtable_lookup_insert_key - search and insert object to hash table
920942
* with explicit key

0 commit comments

Comments
 (0)