rhashtable: involve rhashtable_lookup_compare_insert routine
Introduce a new function called rhashtable_lookup_compare_insert() which is very similar to rhashtable_lookup_insert(). But the former makes use of users' given compare function to look for an object, and then inserts it into hash table if found. As the entire process of search and insertion is under protection of per bucket lock, this can help users to avoid the involvement of extra lock. Signed-off-by: Ying Xue <ying.xue@windriver.com> Cc: Thomas Graf <tgraf@suug.ch> Acked-by: Thomas Graf <tgraf@suug.ch> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:

committed by
David S. Miller

parent
d2c60b1350
commit
7a868d1e9a
@@ -168,7 +168,12 @@ int rhashtable_shrink(struct rhashtable *ht);
|
||||
void *rhashtable_lookup(struct rhashtable *ht, const void *key);
|
||||
void *rhashtable_lookup_compare(struct rhashtable *ht, const void *key,
|
||||
bool (*compare)(void *, void *), void *arg);
|
||||
|
||||
bool rhashtable_lookup_insert(struct rhashtable *ht, struct rhash_head *obj);
|
||||
bool rhashtable_lookup_compare_insert(struct rhashtable *ht,
|
||||
struct rhash_head *obj,
|
||||
bool (*compare)(void *, void *),
|
||||
void *arg);
|
||||
|
||||
void rhashtable_destroy(struct rhashtable *ht);
|
||||
|
||||
|
Reference in New Issue
Block a user