Whamcloud - gitweb
LU-9019 obd: express timeouts in timeout_t
[fs/lustre-release.git] / lustre / ldlm / ldlm_request.c
index 53791f2..a8084b1 100644 (file)
@@ -119,9 +119,8 @@ void ldlm_expired_completion_wait(struct lock_wait_data *lwd)
 
                LDLM_ERROR(lock,
                           "lock timed out (enqueued at %lld, %llds ago); not entering recovery in server code, just going back to sleep",
-                          (s64)lock->l_activity,
-                          (s64)(ktime_get_real_seconds() -
-                                lock->l_activity));
+                          lock->l_activity,
+                          ktime_get_real_seconds() - lock->l_activity);
                if (ktime_get_seconds() > next_dump) {
                        last_dump = next_dump;
                        next_dump = ktime_get_seconds() + 300;
@@ -138,8 +137,8 @@ void ldlm_expired_completion_wait(struct lock_wait_data *lwd)
        ptlrpc_fail_import(imp, lwd->lwd_conn_cnt);
        LDLM_ERROR(lock,
                   "lock timed out (enqueued at %lld, %llds ago), entering recovery for %s@%s",
-                  (s64)lock->l_activity,
-                  (s64)(ktime_get_real_seconds() - lock->l_activity),
+                  lock->l_activity,
+                  ktime_get_real_seconds() - lock->l_activity,
                   obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
 
        EXIT;
@@ -171,9 +170,9 @@ EXPORT_SYMBOL(is_granted_or_cancelled_nolock);
  * We use the same basis for both server side and client side functions
  * from a single node.
  */
-static time64_t ldlm_cp_timeout(struct ldlm_lock *lock)
+static timeout_t ldlm_cp_timeout(struct ldlm_lock *lock)
 {
-       time64_t timeout;
+       timeout_t timeout;
 
        if (AT_OFF)
                return obd_timeout;
@@ -184,7 +183,7 @@ static time64_t ldlm_cp_timeout(struct ldlm_lock *lock)
         * doesn't respond reasonably, and then give us the lock.
         */
        timeout = at_get(ldlm_lock_to_ns_at(lock));
-       return max(3 * timeout, (time64_t) ldlm_enqueue_min);
+       return max(3 * timeout, (timeout_t)ldlm_enqueue_min);
 }
 
 /**
@@ -193,7 +192,6 @@ static time64_t ldlm_cp_timeout(struct ldlm_lock *lock)
  */
 static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
 {
-       time64_t delay;
        int result = 0;
 
        if (ldlm_is_destroyed(lock) || ldlm_is_failed(lock)) {
@@ -203,10 +201,16 @@ static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
                LDLM_DEBUG(lock, "client-side enqueue: granted");
        } else {
                /* Take into AT only CP RPC, not immediately granted locks */
-               delay = ktime_get_real_seconds() - lock->l_activity;
-               LDLM_DEBUG(lock, "client-side enqueue: granted after %llds",
-                          (s64)delay);
+               timeout_t delay = 0;
 
+               /* Discard negative timeouts. We should also limit the
+                * maximum value of the timeout
+                */
+               if (ktime_get_real_seconds() > lock->l_activity)
+                       delay = ktime_get_real_seconds() - lock->l_activity;
+
+               LDLM_DEBUG(lock, "client-side enqueue: granted after %ds",
+                          delay);
                /* Update our time estimate */
                at_measured(ldlm_lock_to_ns_at(lock), delay);
        }
@@ -264,7 +268,7 @@ int ldlm_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
        struct lock_wait_data lwd;
        struct obd_device *obd;
        struct obd_import *imp = NULL;
-       time64_t timeout;
+       timeout_t timeout;
        int rc = 0;
 
        ENTRY;