Whamcloud - gitweb
LU-9019 target: migrate to 64 bit time 09/27909/5
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 13 Jul 2017 16:53:28 +0000 (12:53 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 22 Jul 2017 02:54:42 +0000 (02:54 +0000)
Replace cfs_time_current_sec() to avoid the overflow
issues in 2038 with ktime_get_real_seconds(). Change
time_t bi_deadline to time64_t. Do a direction compare
instead of cfs_time_beforeeq() wrapper.

Change-Id: I93d1cab9ebdcc1f910096e8a229d6c37b244f41d
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/27909
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Fan Yong <fan.yong@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/target/barrier.c
lustre/target/out_lib.c

index 6145e0e..b9363a2 100644 (file)
@@ -53,7 +53,7 @@ struct barrier_instance {
        rwlock_t                 bi_rwlock;
        struct percpu_counter    bi_writers;
        atomic_t                 bi_ref;
        rwlock_t                 bi_rwlock;
        struct percpu_counter    bi_writers;
        atomic_t                 bi_ref;
-       time_t                   bi_deadline;
+       time64_t                 bi_deadline;
        __u32                    bi_status;
 };
 
        __u32                    bi_status;
 };
 
@@ -173,7 +173,7 @@ static void barrier_set(struct barrier_instance *barrier, __u32 status)
 static int barrier_freeze(const struct lu_env *env,
                          struct barrier_instance *barrier, bool phase1)
 {
 static int barrier_freeze(const struct lu_env *env,
                          struct barrier_instance *barrier, bool phase1)
 {
-       int left;
+       time64_t left;
        int rc = 0;
        __s64 inflight = 0;
        ENTRY;
        int rc = 0;
        __s64 inflight = 0;
        ENTRY;
@@ -195,7 +195,7 @@ static int barrier_freeze(const struct lu_env *env,
 
        LASSERT(barrier->bi_deadline != 0);
 
 
        LASSERT(barrier->bi_deadline != 0);
 
-       left = barrier->bi_deadline - cfs_time_current_sec();
+       left = barrier->bi_deadline - ktime_get_real_seconds();
        if (left <= 0)
                RETURN(1);
 
        if (left <= 0)
                RETURN(1);
 
@@ -214,8 +214,7 @@ static int barrier_freeze(const struct lu_env *env,
                if (rc)
                        RETURN(rc);
 
                if (rc)
                        RETURN(rc);
 
-               if (cfs_time_beforeq(barrier->bi_deadline,
-                                    cfs_time_current_sec()))
+               if (ktime_get_real_seconds() > barrier->bi_deadline)
                        RETURN(1);
        }
 
                        RETURN(1);
        }
 
@@ -252,7 +251,7 @@ bool barrier_entry(struct dt_device *key)
        if (likely(barrier->bi_status != BS_FREEZING_P1 &&
                   barrier->bi_status != BS_FREEZING_P2 &&
                   barrier->bi_status != BS_FROZEN) ||
        if (likely(barrier->bi_status != BS_FREEZING_P1 &&
                   barrier->bi_status != BS_FREEZING_P2 &&
                   barrier->bi_status != BS_FROZEN) ||
-           cfs_time_beforeq(barrier->bi_deadline, cfs_time_current_sec())) {
+           ktime_get_real_seconds() > barrier->bi_deadline) {
                percpu_counter_inc(&barrier->bi_writers);
                entered = true;
        }
                percpu_counter_inc(&barrier->bi_writers);
                entered = true;
        }
@@ -326,8 +325,8 @@ int barrier_handler(struct dt_device *key, struct ptlrpc_request *req)
                if (OBD_FAIL_CHECK(OBD_FAIL_BARRIER_FAILURE))
                        GOTO(fini, rc = -EINVAL);
 
                if (OBD_FAIL_CHECK(OBD_FAIL_BARRIER_FAILURE))
                        GOTO(fini, rc = -EINVAL);
 
-               barrier->bi_deadline = cfs_time_current_sec() +
-                                       desc->lgbd_timeout;
+               barrier->bi_deadline = ktime_get_real_seconds() +
+                                      desc->lgbd_timeout;
                rc = barrier_freeze(&env, barrier,
                                    desc->lgbd_status == BS_FREEZING_P1);
                break;
                rc = barrier_freeze(&env, barrier,
                                    desc->lgbd_status == BS_FREEZING_P1);
                break;
@@ -358,7 +357,7 @@ out_barrier:
        lvb->lvb_index = barrier_dev_idx(barrier);
 
        CDEBUG(D_SNAPSHOT, "%s: handled barrier request: status %u, "
        lvb->lvb_index = barrier_dev_idx(barrier);
 
        CDEBUG(D_SNAPSHOT, "%s: handled barrier request: status %u, "
-              "deadline %lu: rc = %d\n", barrier_barrier2name(barrier),
+              "deadline %lld: rc = %d\n", barrier_barrier2name(barrier),
               lvb->lvb_status, barrier->bi_deadline, rc);
 
        barrier_instance_put(barrier);
               lvb->lvb_status, barrier->bi_deadline, rc);
 
        barrier_instance_put(barrier);
index c267ed2..c486f3f 100644 (file)
@@ -797,8 +797,7 @@ static int out_tx_xattr_set_exec(const struct lu_env *env,
 
                                lu_buf_free(&tbuf);
                                if (update) {
 
                                lu_buf_free(&tbuf);
                                if (update) {
-                                       leh->leh_overflow_time =
-                                                       cfs_time_current_sec();
+                                       leh->leh_overflow_time = ktime_get_real_seconds();
                                        if (unlikely(!leh->leh_overflow_time))
                                                leh->leh_overflow_time++;
                                }
                                        if (unlikely(!leh->leh_overflow_time))
                                                leh->leh_overflow_time++;
                                }