Whamcloud - gitweb
b=17511
authoryury <yury>
Fri, 7 Nov 2008 21:10:40 +0000 (21:10 +0000)
committeryury <yury>
Fri, 7 Nov 2008 21:10:40 +0000 (21:10 +0000)
r=johann,adilger

- removes deadlock possibility by disabling rehash in hash_del() operations and moving hash_add()
  out of spin_locks when calling. Hash table has own mechanisms for protecting its structures and it
  also has hash_add_unique() method for using in concurrent run contexts;

  - fixed missed lh_put() in hash_add_unique() which led to extra refs in some cases (extra ref to
  export) and inability to cleanup;

  - fixed __lustre_hash_set_theta() which set @max theta into ->lh_min_theta;

  - in lustre_hash_rehash_size() disable rehash also for the case when new and old hash sizes equal
  in corner cases (max_size or min_size). Before this fix it could be possible to do needless
  rehashes when size is actually did not change but we do this expensive operation;

  - disable rehash in hash_add_unique() if no actual add happened since entry with the same key is
  already found in the table;

  - some cleanups in hash table code;

lustre/include/class_hash.h

index b153cf1..78a946e 100644 (file)
@@ -233,8 +233,8 @@ void lustre_hash_exit(lustre_hash_t *lh);
 /* Hash addition functions */
 void lustre_hash_add(lustre_hash_t *lh, void *key,
                      struct hlist_node *hnode);
-int  lustre_hash_add_unique(lustre_hash_t *lh, void *key,
-                            struct hlist_node *hnode);
+int lustre_hash_add_unique(lustre_hash_t *lh, void *key,
+                           struct hlist_node *hnode);
 void *lustre_hash_findadd_unique(lustre_hash_t *lh, void *key,
                                  struct hlist_node *hnode);
 
@@ -269,7 +269,7 @@ __lustre_hash_set_theta(lustre_hash_t *lh, int min, int max)
 {
         LASSERT(min < max);
         lh->lh_min_theta = min;
-        lh->lh_min_theta = max;
+        lh->lh_max_theta = max;
 }
 
 /* Generic debug formatting routines mainly for proc handler */