Whamcloud - gitweb
LU-8130 obd: convert obd_nid_hash to rhashtable
[fs/lustre-release.git] / lustre / ldlm / ldlm_lib.c
index d0c7fd7..b0649fd 100644 (file)
@@ -787,12 +787,37 @@ int server_disconnect_export(struct obd_export *exp)
 }
 EXPORT_SYMBOL(server_disconnect_export);
 
+static inline int target_check_recovery_timer(struct obd_device *target)
+{
+       ktime_t remaining;
+       s64 timeout;
+
+       if (!target->obd_recovering || target->obd_recovery_start == 0)
+               return 0;
+
+       remaining = hrtimer_expires_remaining(&target->obd_recovery_timer);
+       timeout = ktime_divns(remaining, NSEC_PER_SEC);
+       if (timeout > -30)
+               return 0;
+
+       /* the recovery timer should expire, but it isn't triggered,
+        * it's better to abort the recovery of this target to speed up
+        * the recovery of the whole cluster. */
+       spin_lock(&target->obd_dev_lock);
+       if (target->obd_recovering) {
+               CERROR("%s: Aborting recovery\n", target->obd_name);
+               target->obd_abort_recovery = 1;
+               wake_up(&target->obd_next_transno_waitq);
+       }
+       spin_unlock(&target->obd_dev_lock);
+       return 0;
+}
+
 /*
  * --------------------------------------------------------------------------
  * from old lib/target.c
  * --------------------------------------------------------------------------
  */
-
 static int target_handle_reconnect(struct lustre_handle *conn,
                                   struct obd_export *exp,
                                   struct obd_uuid *cluuid)
@@ -853,6 +878,8 @@ static int target_handle_reconnect(struct lustre_handle *conn,
                int count = 0;
                char *buf = NULL;
 
+               target_check_recovery_timer(target);
+
                tdtd = class_exp2tgt(exp)->lut_tdtd;
                if (tdtd && tdtd->tdtd_show_update_logs_retrievers)
                        buf = tdtd->tdtd_show_update_logs_retrievers(
@@ -1340,6 +1367,8 @@ no_export:
                        } else {
                                msg = "already passed deadline";
                                timeout = -left;
+
+                               target_check_recovery_timer(target);
                        }
 
                        LCONSOLE_WARN("%s: Denying connection for new client %s (at %s), waiting for %d known clients (%d recovered, %d in progress, and %d evicted) %s %lld:%.02lld\n",
@@ -1418,11 +1447,8 @@ dont_check_exports:
 
        if (export->exp_connection != NULL) {
                /* Check to see if connection came from another NID. */
-               if ((export->exp_connection->c_peer.nid != req->rq_peer.nid) &&
-                   !hlist_unhashed(&export->exp_nid_hash))
-                       cfs_hash_del(export->exp_obd->obd_nid_hash,
-                                    &export->exp_connection->c_peer.nid,
-                                    &export->exp_nid_hash);
+               if (export->exp_connection->c_peer.nid != req->rq_peer.nid)
+                       obd_nid_del(export->exp_obd, export);
 
                ptlrpc_connection_put(export->exp_connection);
        }
@@ -1430,10 +1456,7 @@ dont_check_exports:
        export->exp_connection = ptlrpc_connection_get(req->rq_peer,
                                                       req->rq_self,
                                                       &cluuid);
-       if (hlist_unhashed(&export->exp_nid_hash))
-               cfs_hash_add(export->exp_obd->obd_nid_hash,
-                            &export->exp_connection->c_peer.nid,
-                            &export->exp_nid_hash);
+       obd_nid_add(export->exp_obd, export);
 
        lustre_msg_set_handle(req->rq_repmsg, &conn);