Whamcloud - gitweb
LU-4423 ldlm: use time64_t for l_last_activity 41/23141/2
authorArnd Bergmann <arnd@arndb.de>
Thu, 13 Oct 2016 18:50:00 +0000 (14:50 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sun, 1 Jan 2017 01:58:41 +0000 (01:58 +0000)
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.

Update server side code as well that is not present in upstream
client.

Linux-commit: bf6d21539d58f64812d71c956ecec3d67650b2ee

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Change-Id: Idbbc64afbb9307e6133c671a7aa2122318c62679
Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/23141
Reviewed-by: Frank Zago <fzago@cray.com>
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/include/lustre_dlm.h
lustre/ldlm/ldlm_lockd.c
lustre/ldlm/ldlm_request.c

index 2c53e35..9d6058a 100644 (file)
@@ -789,7 +789,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.
         */
-       cfs_time_t              l_last_activity;
+       time64_t                l_last_activity;
 
        /**
         * Time last used by e.g. being matched by lock match.
index b0a0706..7649bae 100644 (file)
@@ -326,9 +326,9 @@ static void waiting_locks_callback(unsigned long unused)
                         continue;
                 }
                 ldlm_lock_to_ns(lock)->ns_timeouts++;
-                LDLM_ERROR(lock, "lock callback timer expired after %lds: "
+               LDLM_ERROR(lock, "lock callback timer expired after %llds: "
                            "evicting client at %s ",
-                           cfs_time_current_sec() - lock->l_last_activity,
+                          ktime_get_real_seconds() - lock->l_last_activity,
                            libcfs_nid2str(
                                    lock->l_export->exp_connection->c_peer.nid));
 
@@ -460,7 +460,7 @@ static int ldlm_add_waiting_lock(struct ldlm_lock *lock)
        }
 
        ldlm_set_waited(lock);
-       lock->l_last_activity = cfs_time_current_sec();
+       lock->l_last_activity = ktime_get_real_seconds();
        ret = __ldlm_add_waiting_lock(lock, timeout);
        if (ret) {
                /* grab ref on the lock if it has been added to the
@@ -922,7 +922,7 @@ int ldlm_server_blocking_ast(struct ldlm_lock *lock,
         if (AT_OFF)
                 req->rq_timeout = ldlm_get_rq_timeout();
 
-       lock->l_last_activity = cfs_time_current_sec();
+       lock->l_last_activity = ktime_get_real_seconds();
 
         if (lock->l_export && lock->l_export->exp_nid_stats &&
             lock->l_export->exp_nid_stats->nid_ldlm_stats)
@@ -1012,7 +1012,7 @@ int ldlm_server_completion_ast(struct ldlm_lock *lock, __u64 flags, void *data)
                }
         }
 
-       lock->l_last_activity = cfs_time_current_sec();
+       lock->l_last_activity = ktime_get_real_seconds();
 
        LDLM_DEBUG(lock, "server preparing completion AST");
 
@@ -1122,7 +1122,7 @@ int ldlm_server_glimpse_ast(struct ldlm_lock *lock, void *data)
         if (AT_OFF)
                 req->rq_timeout = ldlm_get_rq_timeout();
 
-       lock->l_last_activity = cfs_time_current_sec();
+       lock->l_last_activity = ktime_get_real_seconds();
 
        req->rq_interpret_reply = ldlm_cb_interpret;
 
@@ -1679,10 +1679,10 @@ int ldlm_request_cancel(struct ptlrpc_request *req,
                 }
 
                if ((flags & LATF_STATS) && ldlm_is_ast_sent(lock)) {
-                       long delay = cfs_time_sub(cfs_time_current_sec(),
-                                                 lock->l_last_activity);
-                       LDLM_DEBUG(lock, "server cancels blocked lock after "
-                                  CFS_DURATION_T"s", delay);
+                       time64_t delay = ktime_get_real_seconds() -
+                                        lock->l_last_activity;
+                       LDLM_DEBUG(lock, "server cancels blocked lock after %llds",
+                                  (s64)delay);
                        at_measured(&lock->l_export->exp_bl_lock_at, delay);
                }
                 ldlm_lock_cancel(lock);
index 9e1b468..754633f 100644 (file)
@@ -121,12 +121,11 @@ int ldlm_expired_completion_wait(void *data)
         if (lock->l_conn_export == NULL) {
                 static cfs_time_t next_dump = 0, last_dump = 0;
 
-               LDLM_ERROR(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(cfs_time_current_sec(),
-                                       lock->l_last_activity));
+               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_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);
@@ -141,10 +140,9 @@ 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(cfs_time_current_sec(), lock->l_last_activity),
+       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);
@@ -182,8 +180,8 @@ static unsigned int ldlm_cp_timeout(struct ldlm_lock *lock)
  */
 static int ldlm_completion_tail(struct ldlm_lock *lock, void *data)
 {
-       long delay;
-       int  result = 0;
+       time64_t delay;
+       int result = 0;
 
        if (ldlm_is_destroyed(lock) || ldlm_is_failed(lock)) {
                LDLM_DEBUG(lock, "client-side enqueue: destroyed");
@@ -192,10 +190,9 @@ 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 = cfs_time_sub(cfs_time_current_sec(),
-                                    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 %llds",
+                          (s64)delay);
 
                /* Update our time estimate */
                at_measured(ldlm_lock_to_ns_at(lock), delay);