rcuja: implement lookup
[userspace-rcu.git] / rcuja / rcuja-shadow-nodes.c
index cfc7073c0b5fb89416417b62f5d88dabcd365420..2b369add76b7df205789f0aa0687639f32ae18a8 100644 (file)
@@ -176,7 +176,7 @@ int match_pointer(struct cds_lfht_node *node, const void *key)
 
 __attribute__((visibility("protected")))
 struct cds_ja_shadow_node *rcuja_shadow_lookup_lock(struct cds_lfht *ht,
-               struct cds_ja_node *node)
+               struct cds_ja_inode *node)
 {
        struct cds_lfht_iter iter;
        struct cds_lfht_node *lookup_node;
@@ -219,7 +219,7 @@ void rcuja_shadow_unlock(struct cds_ja_shadow_node *shadow_node)
 
 __attribute__((visibility("protected")))
 int rcuja_shadow_set(struct cds_lfht *ht,
-               struct cds_ja_node *new_node,
+               struct cds_ja_inode *new_node,
                struct cds_ja_shadow_node *inherit_from)
 {
        struct cds_ja_shadow_node *shadow_node;
@@ -282,7 +282,7 @@ void free_shadow_node_and_node_and_lock(struct rcu_head *head)
 
 __attribute__((visibility("protected")))
 int rcuja_shadow_clear(struct cds_lfht *ht,
-               struct cds_ja_node *node,
+               struct cds_ja_inode *node,
                unsigned int flags)
 {
        struct cds_lfht_iter iter;
@@ -329,6 +329,38 @@ rcu_unlock:
        return ret;
 }
 
+/*
+ * Delete all shadow nodes and nodes from hash table, along with their
+ * associated lock.
+ */
+__attribute__((visibility("protected")))
+void rcuja_shadow_prune(struct cds_lfht *ht,
+               unsigned int flags)
+{
+       const struct rcu_flavor_struct *flavor;
+       struct cds_ja_shadow_node *shadow_node;
+       struct cds_lfht_iter iter;
+       int ret, lockret;
+
+       flavor = cds_lfht_rcu_flavor(ht);
+       flavor->read_lock();
+       cds_lfht_for_each_entry(ht, &iter, shadow_node, ht_node) {
+               lockret = pthread_mutex_lock(shadow_node->lock);
+               assert(!lockret);
+       
+               ret = cds_lfht_del(ht, &shadow_node->ht_node);
+               if (!ret) {
+                       assert((flags & RCUJA_SHADOW_CLEAR_FREE_NODE)
+                               && (flags & RCUJA_SHADOW_CLEAR_FREE_LOCK));
+                       flavor->update_call_rcu(&shadow_node->head,
+                               free_shadow_node_and_node_and_lock);
+               }
+               lockret = pthread_mutex_unlock(shadow_node->lock);
+               assert(!lockret);
+       }
+       flavor->read_unlock();
+}
+
 __attribute__((visibility("protected")))
 struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor)
 {
@@ -338,12 +370,9 @@ struct cds_lfht *rcuja_create_ht(const struct rcu_flavor_struct *flavor)
 }
 
 __attribute__((visibility("protected")))
-void rcuja_delete_ht(struct cds_lfht *ht)
+int rcuja_delete_ht(struct cds_lfht *ht)
 {
-       int ret;
-
-       ret = cds_lfht_destroy(ht, NULL);
-       assert(!ret);
+       return cds_lfht_destroy(ht, NULL);
 }
 
 __attribute__((constructor))
This page took 0.024582 seconds and 4 git commands to generate.