From c4ff984dc55b29d810ee996a0d30ebd817c09df4 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Thu, 13 Jul 2017 12:53:28 -0400 Subject: [PATCH] LU-9019 target: migrate to 64 bit time 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 Reviewed-on: https://review.whamcloud.com/27909 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: Andreas Dilger --- lustre/target/barrier.c | 17 ++++++++--------- lustre/target/out_lib.c | 3 +-- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/lustre/target/barrier.c b/lustre/target/barrier.c index 6145e0e..b9363a2 100644 --- a/lustre/target/barrier.c +++ b/lustre/target/barrier.c @@ -53,7 +53,7 @@ struct barrier_instance { rwlock_t bi_rwlock; struct percpu_counter bi_writers; atomic_t bi_ref; - time_t bi_deadline; + time64_t bi_deadline; __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) { - int left; + time64_t left; 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); - left = barrier->bi_deadline - cfs_time_current_sec(); + left = barrier->bi_deadline - ktime_get_real_seconds(); if (left <= 0) RETURN(1); @@ -214,8 +214,7 @@ static int barrier_freeze(const struct lu_env *env, 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); } @@ -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) || - 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; } @@ -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); - 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; @@ -358,7 +357,7 @@ out_barrier: 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); diff --git a/lustre/target/out_lib.c b/lustre/target/out_lib.c index c267ed2..c486f3f 100644 --- a/lustre/target/out_lib.c +++ b/lustre/target/out_lib.c @@ -797,8 +797,7 @@ static int out_tx_xattr_set_exec(const struct lu_env *env, 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++; } -- 1.8.3.1