Whamcloud - gitweb
LU-4423 ptlrpc: use 64-bit times for ptlrpc sec expiry 09/24709/2
authorArnd Bergmann <arnd@arndb.de>
Wed, 4 Jan 2017 21:41:46 +0000 (16:41 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 18 Jan 2017 18:59:40 +0000 (18:59 +0000)
The exp_flvr_expire and imp_sec_expire are defined as 'unsigned long',
which doesn't overflow until 2106, but to be on the safe side, this
changes the code to use time64_t like we do everywhere else.

Linux-commit: 986ef135c2afce959971b0086fc04e0f9f654120

Change-Id: Id1a560504e9a9c673e0880ac4e3e80938b3789bc
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>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/24709
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
lustre/include/lustre_export.h
lustre/include/lustre_import.h
lustre/ptlrpc/sec.c
lustre/ptlrpc/sec_config.c

index 50fc3cc..410b185 100644 (file)
@@ -274,7 +274,7 @@ struct obd_export {
         enum lustre_sec_part      exp_sp_peer;
         struct sptlrpc_flavor     exp_flvr;             /* current */
         struct sptlrpc_flavor     exp_flvr_old[2];      /* about-to-expire */
-        cfs_time_t                exp_flvr_expire[2];   /* seconds */
+       time64_t                  exp_flvr_expire[2];   /* seconds */
 
         /** protects exp_hp_rpcs */
        spinlock_t              exp_rpc_lock;
index 51351a4..39b3369 100644 (file)
@@ -206,7 +206,7 @@ struct obd_import {
          */
        struct ptlrpc_sec        *imp_sec;
        struct mutex              imp_sec_mutex;
-       cfs_time_t                imp_sec_expire;
+       time64_t                imp_sec_expire;
        pid_t                     imp_sec_refpid;
         /** @} */
 
index 77e62fb..79237a0 100644 (file)
@@ -364,7 +364,7 @@ static int import_sec_check_expire(struct obd_import *imp)
 
        spin_lock(&imp->imp_lock);
        if (imp->imp_sec_expire &&
-           imp->imp_sec_expire < cfs_time_current_sec()) {
+           imp->imp_sec_expire < ktime_get_real_seconds()) {
                adapt = 1;
                imp->imp_sec_expire = 0;
        }
@@ -1806,7 +1806,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
                 exp->exp_flvr_old[1] = exp->exp_flvr_old[0];
                 exp->exp_flvr_expire[1] = exp->exp_flvr_expire[0];
                 exp->exp_flvr_old[0] = exp->exp_flvr;
-                exp->exp_flvr_expire[0] = cfs_time_current_sec() +
+               exp->exp_flvr_expire[0] = ktime_get_real_seconds() +
                                           EXP_FLVR_UPDATE_EXPIRE;
                 exp->exp_flvr = flavor;
 
@@ -1880,15 +1880,14 @@ int sptlrpc_target_export_check(struct obd_export *exp,
         }
 
         if (exp->exp_flvr_expire[0]) {
-                if (exp->exp_flvr_expire[0] >= cfs_time_current_sec()) {
+               if (exp->exp_flvr_expire[0] >= ktime_get_real_seconds()) {
                         if (flavor_allowed(&exp->exp_flvr_old[0], req)) {
-                                CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the "
-                                       "middle one ("CFS_DURATION_T")\n", exp,
+                               CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the middle one (%lld)\n", exp,
                                        exp->exp_flvr.sf_rpc,
                                        exp->exp_flvr_old[0].sf_rpc,
                                        exp->exp_flvr_old[1].sf_rpc,
-                                       exp->exp_flvr_expire[0] -
-                                                cfs_time_current_sec());
+                                      (s64)(exp->exp_flvr_expire[0] -
+                                      ktime_get_real_seconds()));
                                spin_unlock(&exp->exp_lock);
                                 return 0;
                         }
@@ -1905,15 +1904,15 @@ int sptlrpc_target_export_check(struct obd_export *exp,
         /* now it doesn't match the current flavor, the only chance we can
          * accept it is match the old flavors which is not expired. */
         if (exp->exp_flvr_changed == 0 && exp->exp_flvr_expire[1]) {
-                if (exp->exp_flvr_expire[1] >= cfs_time_current_sec()) {
+               if (exp->exp_flvr_expire[1] >= ktime_get_real_seconds()) {
                         if (flavor_allowed(&exp->exp_flvr_old[1], req)) {
-                                CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the "
-                                       "oldest one ("CFS_DURATION_T")\n", exp,
+                               CDEBUG(D_SEC, "exp %p (%x|%x|%x): match the oldest one (%lld)\n",
+                                      exp,
                                        exp->exp_flvr.sf_rpc,
                                        exp->exp_flvr_old[0].sf_rpc,
                                        exp->exp_flvr_old[1].sf_rpc,
-                                       exp->exp_flvr_expire[1] -
-                                                cfs_time_current_sec());
+                                      (s64)(exp->exp_flvr_expire[1] -
+                                      ktime_get_real_seconds()));
                                spin_unlock(&exp->exp_lock);
                                 return 0;
                         }
@@ -1933,8 +1932,7 @@ int sptlrpc_target_export_check(struct obd_export *exp,
 
        spin_unlock(&exp->exp_lock);
 
-        CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with "
-              "unauthorized flavor %x, expect %x|%x(%+ld)|%x(%+ld)\n",
+       CWARN("exp %p(%s): req %p (%u|%u|%u|%u|%u|%u) with unauthorized flavor %x, expect %x|%x(%+lld)|%x(%+lld)\n",
               exp, exp->exp_obd->obd_name,
               req, req->rq_auth_gss, req->rq_ctx_init, req->rq_ctx_fini,
               req->rq_auth_usr_root, req->rq_auth_usr_mdt, req->rq_auth_usr_ost,
@@ -1942,12 +1940,10 @@ int sptlrpc_target_export_check(struct obd_export *exp,
               exp->exp_flvr.sf_rpc,
               exp->exp_flvr_old[0].sf_rpc,
               exp->exp_flvr_expire[0] ?
-              (unsigned long) (exp->exp_flvr_expire[0] -
-                               cfs_time_current_sec()) : 0,
+             (s64)(exp->exp_flvr_expire[0] - ktime_get_real_seconds()) : 0,
               exp->exp_flvr_old[1].sf_rpc,
               exp->exp_flvr_expire[1] ?
-              (unsigned long) (exp->exp_flvr_expire[1] -
-                               cfs_time_current_sec()) : 0);
+             (s64)(exp->exp_flvr_expire[1] - ktime_get_real_seconds()) : 0);
         return -EACCES;
 }
 EXPORT_SYMBOL(sptlrpc_target_export_check);
index 69b3beb..2407f9d 100644 (file)
@@ -924,7 +924,7 @@ void sptlrpc_conf_client_adapt(struct obd_device *obd)
        if (imp) {
                spin_lock(&imp->imp_lock);
                if (imp->imp_sec)
-                       imp->imp_sec_expire = cfs_time_current_sec() +
+                       imp->imp_sec_expire = ktime_get_real_seconds() +
                                SEC_ADAPT_DELAY;
                spin_unlock(&imp->imp_lock);
        }