Whamcloud - gitweb
b=17511
authoryury <yury>
Fri, 7 Nov 2008 21:10:44 +0000 (21:10 +0000)
committeryury <yury>
Fri, 7 Nov 2008 21:10:44 +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/ldlm/ldlm_lib.c

index 913429c..5077f63 100644 (file)
@@ -932,13 +932,11 @@ int target_handle_connect(struct ptlrpc_request *req, svc_handler_t handler)
                                                        req->rq_self,
                                                        &remote_uuid);
 
-        spin_lock(&target->obd_dev_lock);
-        /* Export might be hashed already, e.g. if this is reconnect */
-        if (hlist_unhashed(&export->exp_nid_hash))
-                lustre_hash_add(export->exp_obd->obd_nid_hash,
-                                &export->exp_connection->c_peer.nid,
-                                &export->exp_nid_hash);
-        spin_unlock(&target->obd_dev_lock);
+        if (hlist_unhashed(&export->exp_nid_hash)) {
+                lustre_hash_add_unique(export->exp_obd->obd_nid_hash,
+                                       &export->exp_connection->c_peer.nid,
+                                       &export->exp_nid_hash);
+        }
 
         if (lustre_msg_get_op_flags(req->rq_repmsg) & MSG_CONNECT_RECONNECT) {
                 revimp = class_import_get(export->exp_imp_reverse);