staging/lustre: use time64_t for l_last_activity
authorArnd Bergmann <arnd@arndb.de>
Sun, 27 Sep 2015 20:45:06 +0000 (16:45 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 29 Sep 2015 02:03:34 +0000 (04:03 +0200)
The l_last_activity struct member is used to keep track lock hold
times, and it is printed for debugging purposes. For the elapsed
time, we can use 'long' here, but it's better to use time64_t
for storing the real time to avoid an overflow in 2038.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/lustre_dlm.h
drivers/staging/lustre/lustre/ldlm/ldlm_lock.c
drivers/staging/lustre/lustre/ldlm/ldlm_request.c

index 92b24be7c21e04539422eeae19909ff0d99dc4b2..796a997ec94c9e766e196cd68c953721c9967227 100644 (file)
@@ -749,7 +749,7 @@ struct ldlm_lock {
         * Seconds. It will be updated if there is any activity related to
         * the lock, e.g. enqueue the lock or send blocking AST.
         */
-       unsigned long           l_last_activity;
+       time64_t                l_last_activity;
 
        /**
         * Time last used by e.g. being matched by lock match.
index cd340fc8ceab45238e51449434f130973b61cda4..12eb5ac3b3d843207e86f65da3519eed93197a81 100644 (file)
@@ -1564,7 +1564,7 @@ ldlm_error_t ldlm_lock_enqueue(struct ldlm_namespace *ns,
        ldlm_error_t rc = ELDLM_OK;
        struct ldlm_interval *node = NULL;
 
-       lock->l_last_activity = get_seconds();
+       lock->l_last_activity = ktime_get_real_seconds();
        /* policies are not executed on the client or during replay */
        if ((*flags & (LDLM_FL_HAS_INTENT|LDLM_FL_REPLAY)) == LDLM_FL_HAS_INTENT
            && !local && ns->ns_policy) {
index b5ee9bd9875f3d160f5a363dba93652266f4c3e4..f6d61e5a38e704899d5875115b2c7e37111badc4 100644 (file)
@@ -97,15 +97,14 @@ int ldlm_expired_completion_wait(void *data)
        if (lock->l_conn_export == NULL) {
                static unsigned long next_dump, last_dump;
 
-               LCONSOLE_WARN("lock timed out (enqueued at "CFS_TIME_T", "
-                             CFS_DURATION_T"s ago)\n",
-                             lock->l_last_activity,
-                             cfs_time_sub(get_seconds(),
-                                          lock->l_last_activity));
-               LDLM_DEBUG(lock, "lock timed out (enqueued at " CFS_TIME_T ", " CFS_DURATION_T "s ago); not entering recovery in server code, just going back to sleep",
-                          lock->l_last_activity,
-                          cfs_time_sub(get_seconds(),
-                                       lock->l_last_activity));
+               LCONSOLE_WARN("lock timed out (enqueued at %lld, %llds ago)\n",
+                             (s64)lock->l_last_activity,
+                             (s64)(ktime_get_real_seconds() -
+                                   lock->l_last_activity));
+               LDLM_DEBUG(lock, "lock timed out (enqueued at %lld, %llds ago); not entering recovery in server code, just going back to sleep",
+                          (s64)lock->l_last_activity,
+                          (s64)(ktime_get_real_seconds() -
+                                lock->l_last_activity));
                if (cfs_time_after(cfs_time_current(), next_dump)) {
                        last_dump = next_dump;
                        next_dump = cfs_time_shift(300);
@@ -120,11 +119,10 @@ int ldlm_expired_completion_wait(void *data)
        obd = lock->l_conn_export->exp_obd;
        imp = obd->u.cli.cl_import;
        ptlrpc_fail_import(imp, lwd->lwd_conn_cnt);
-       LDLM_ERROR(lock, "lock timed out (enqueued at "CFS_TIME_T", "
-                 CFS_DURATION_T"s ago), entering recovery for %s@%s",
-                 lock->l_last_activity,
-                 cfs_time_sub(get_seconds(), lock->l_last_activity),
-                 obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
+       LDLM_ERROR(lock, "lock timed out (enqueued at %lld, %llds ago), entering recovery for %s@%s",
+                  (s64)lock->l_last_activity,
+                  (s64)(ktime_get_real_seconds() - lock->l_last_activity),
+                  obd2cli_tgt(obd), imp->imp_connection->c_remote_uuid.uuid);
 
        return 0;
 }
@@ -159,10 +157,9 @@ static int ldlm_completion_tail(struct ldlm_lock *lock)
                LDLM_DEBUG(lock, "client-side enqueue: destroyed");
                result = -EIO;
        } else {
-               delay = cfs_time_sub(get_seconds(),
-                                    lock->l_last_activity);
-               LDLM_DEBUG(lock, "client-side enqueue: granted after "
-                          CFS_DURATION_T"s", delay);
+               delay = ktime_get_real_seconds() - lock->l_last_activity;
+               LDLM_DEBUG(lock, "client-side enqueue: granted after %lds",
+                          delay);
 
                /* Update our time estimate */
                at_measured(ldlm_lock_to_ns_at(lock),