Whamcloud - gitweb
b=19813 cfs_hash_cond_del doesn't have dance of addref/decref anymore
authorVitaly Fertman <vitaly.fertman@sun.com>
Mon, 18 Oct 2010 22:50:27 +0000 (02:50 +0400)
committerVitaly Fertman <vitaly.fertman@sun.com>
Mon, 18 Oct 2010 22:50:27 +0000 (02:50 +0400)
o=liang
i=vitaly
i=tappro

libcfs/libcfs/hash.c
lustre/obdclass/lprocfs_status.c

index d676005..738e4f9 100644 (file)
@@ -1546,7 +1546,9 @@ CFS_EXPORT_SYMBOL(cfs_hash_is_empty);
 __u64
 cfs_hash_size_get(cfs_hash_t *hs)
 {
 __u64
 cfs_hash_size_get(cfs_hash_t *hs)
 {
-        return cfs_hash_for_each_tight(hs, NULL, NULL, 0);
+        return cfs_hash_with_counter(hs) ?
+               cfs_atomic_read(&hs->hs_count) :
+               cfs_hash_for_each_tight(hs, NULL, NULL, 0);
 }
 CFS_EXPORT_SYMBOL(cfs_hash_size_get);
 
 }
 CFS_EXPORT_SYMBOL(cfs_hash_size_get);
 
index 2b9e631..1d411c2 100644 (file)
@@ -1761,10 +1761,10 @@ int lprocfs_nid_stats_clear_write_cb(void *obj, void *data)
         struct nid_stat *stat = obj;
         int i;
         ENTRY;
         struct nid_stat *stat = obj;
         int i;
         ENTRY;
-        /* object has only hash + iterate_all references.
-         * add/delete blocked by hash bucket lock */
+
         CDEBUG(D_INFO,"refcnt %d\n", cfs_atomic_read(&stat->nid_exp_ref_count));
         CDEBUG(D_INFO,"refcnt %d\n", cfs_atomic_read(&stat->nid_exp_ref_count));
-        if (cfs_atomic_read(&stat->nid_exp_ref_count) == 2) {
+        if (cfs_atomic_read(&stat->nid_exp_ref_count) == 1) {
+                /* object has only hash references. */
                 cfs_spin_lock(&stat->nid_obd->obd_nid_lock);
                 cfs_list_move(&stat->nid_list, data);
                 cfs_spin_unlock(&stat->nid_obd->obd_nid_lock);
                 cfs_spin_lock(&stat->nid_obd->obd_nid_lock);
                 cfs_list_move(&stat->nid_list, data);
                 cfs_spin_unlock(&stat->nid_obd->obd_nid_lock);