From a861f8deb4d064a5835c3ba81a756aace625b88c Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 8 Nov 2017 19:44:19 -0500 Subject: [PATCH] LU-9019 mdt: migrate to 64 bit time Port the remaining time code from 32 bits to 64 bits. Replace cfs_time_current_sec() to avoid the overflow issues in 2038 with ktime_get_real_seconds(). Change-Id: Ia97dbfe00cd90dc6ef04583ba2eb512a8feca8c8 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28788 Reviewed-by: Quentin Bouget Reviewed-by: Andreas Dilger Reviewed-by: Sebastien Buisson Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Oleg Drokin --- lustre/mdt/mdt_coordinator.c | 28 ++++++++++++++-------------- lustre/mdt/mdt_handler.c | 2 +- lustre/mdt/mdt_hsm_cdt_actions.c | 6 +++--- lustre/mdt/mdt_hsm_cdt_requests.c | 4 ++-- lustre/mdt/mdt_internal.h | 10 +++++----- lustre/mdt/mdt_xattr.c | 2 +- 6 files changed, 26 insertions(+), 26 deletions(-) diff --git a/lustre/mdt/mdt_coordinator.c b/lustre/mdt/mdt_coordinator.c index d369a5d..d2618f4 100644 --- a/lustre/mdt/mdt_coordinator.c +++ b/lustre/mdt/mdt_coordinator.c @@ -299,8 +299,8 @@ static int mdt_coordinator_cb(const struct lu_env *env, case ARS_STARTED: { struct hsm_progress_kernel pgs; struct cdt_agent_req *car; - cfs_time_t now = cfs_time_current_sec(); - cfs_time_t last; + time64_t now = ktime_get_real_seconds(); + time64_t last; if (!hsd->housekeeping) break; @@ -376,7 +376,7 @@ static int mdt_coordinator_cb(const struct lu_env *env, break; if ((larr->arr_req_change + cdt->cdt_grace_delay) < - cfs_time_current_sec()) { + ktime_get_real_seconds()) { cdt_agent_record_hash_del(cdt, larr->arr_hai.hai_cookie); RETURN(LLOG_DEL_RECORD); @@ -536,7 +536,6 @@ static int mdt_coordinator(void *data) struct mdt_device *mdt = mti->mti_mdt; struct coordinator *cdt = &mdt->mdt_coordinator; struct hsm_scan_data hsd = { NULL }; - time64_t wait_event_time = 1 * HZ; time64_t last_housekeeping = 0; int rc = 0; int request_sz; @@ -566,13 +565,14 @@ static int mdt_coordinator(void *data) struct hsm_record_update *updates; /* Limit execution of the expensive requests traversal - * to at most every "wait_event_time" jiffies. This prevents - * repeatedly locking/unlocking the catalog for each request - * and preventing other HSM operations from happening */ + * to at most one second. This prevents repeatedly + * locking/unlocking the catalog for each request + * and preventing other HSM operations from happening + */ wait_event_interruptible_timeout(cdt->cdt_waitq, kthread_should_stop() || cdt->cdt_wakeup_coordinator, - wait_event_time); + cfs_time_seconds(1)); cdt->cdt_wakeup_coordinator = false; CDEBUG(D_HSM, "coordinator resumes\n"); @@ -592,8 +592,8 @@ static int mdt_coordinator(void *data) /* If no event, and no housekeeping to do, continue to * wait. */ if (last_housekeeping + cdt->cdt_loop_period <= - get_seconds()) { - last_housekeeping = get_seconds(); + ktime_get_real_seconds()) { + last_housekeeping = ktime_get_real_seconds(); hsd.housekeeping = true; } else if (cdt->cdt_event) { hsd.housekeeping = false; @@ -804,7 +804,7 @@ static int hsm_restore_cb(const struct lu_env *env, * when being re-started */ if (larr->arr_status == ARS_STARTED) { larr->arr_status = ARS_WAITING; - larr->arr_req_change = cfs_time_current_sec(); + larr->arr_req_change = ktime_get_real_seconds(); rc = llog_write(env, llh, hdr, hdr->lrh_index); if (rc != 0) GOTO(out, rc); @@ -963,7 +963,7 @@ int mdt_hsm_cdt_init(struct mdt_device *mdt) /* Initialize cdt_compound_id here to allow its usage for * delayed requests from RAoLU policy */ - atomic_set(&cdt->cdt_compound_id, cfs_time_current_sec()); + atomic_set(&cdt->cdt_compound_id, ktime_get_real_seconds()); /* by default do not remove archives on last unlink */ cdt->cdt_remove_archive_on_last_unlink = false; @@ -1038,7 +1038,7 @@ static int mdt_hsm_cdt_start(struct mdt_device *mdt) /* just need to be larger than previous one */ /* cdt_last_cookie is protected by cdt_llog_lock */ - cdt->cdt_last_cookie = cfs_time_current_sec(); + cdt->cdt_last_cookie = ktime_get_real_seconds(); atomic_set(&cdt->cdt_request_count, 0); cdt->cdt_user_request_mask = (1UL << HSMA_RESTORE); cdt->cdt_group_request_mask = (1UL << HSMA_RESTORE); @@ -1665,7 +1665,7 @@ static int mdt_cancel_all_cb(const struct lu_env *env, if (larr->arr_status == ARS_WAITING || larr->arr_status == ARS_STARTED) { larr->arr_status = ARS_CANCELED; - larr->arr_req_change = cfs_time_current_sec(); + larr->arr_req_change = ktime_get_real_seconds(); rc = llog_write(env, llh, hdr, hdr->lrh_index); } diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 5ef06db..625fa0b 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -1733,7 +1733,7 @@ static int mdt_getattr_name_lock(struct mdt_thread_info *info, if (ma->ma_valid & MA_INODE && ma->ma_attr.la_valid & LA_CTIME && info->mti_mdt->mdt_namespace->ns_ctime_age_limit + - ma->ma_attr.la_ctime < cfs_time_current_sec()) + ma->ma_attr.la_ctime < ktime_get_real_seconds()) child_bits |= MDS_INODELOCK_UPDATE; } diff --git a/lustre/mdt/mdt_hsm_cdt_actions.c b/lustre/mdt/mdt_hsm_cdt_actions.c index b17aa17..32ea69f 100644 --- a/lustre/mdt/mdt_hsm_cdt_actions.c +++ b/lustre/mdt/mdt_hsm_cdt_actions.c @@ -279,7 +279,7 @@ int mdt_agent_record_add(const struct lu_env *env, larr->arr_compound_id = compound_id; larr->arr_archive_id = archive_id; larr->arr_flags = flags; - larr->arr_req_create = cfs_time_current_sec(); + larr->arr_req_create = ktime_get_real_seconds(); larr->arr_req_change = larr->arr_req_create; memcpy(&larr->arr_hai, hai, hai->hai_len); @@ -321,7 +321,7 @@ struct data_update_cb { struct hsm_record_update *updates; unsigned int updates_count; unsigned int updates_done; - cfs_time_t change_time; + time64_t change_time; }; /** @@ -442,7 +442,7 @@ int mdt_agent_record_update(const struct lu_env *env, struct mdt_device *mdt, ducb.updates = updates; ducb.updates_count = updates_count; ducb.updates_done = 0; - ducb.change_time = cfs_time_current_sec(); + ducb.change_time = ktime_get_real_seconds(); rc = cdt_llog_process(env, mdt, mdt_agent_record_update_cb, &ducb, start_cat_idx, start_rec_idx, WRITE); diff --git a/lustre/mdt/mdt_hsm_cdt_requests.c b/lustre/mdt/mdt_hsm_cdt_requests.c index a07cb7c..60872ed 100644 --- a/lustre/mdt/mdt_hsm_cdt_requests.c +++ b/lustre/mdt/mdt_hsm_cdt_requests.c @@ -304,7 +304,7 @@ struct cdt_agent_req *mdt_cdt_alloc_request(__u64 compound_id, __u32 archive_id, car->car_archive_id = archive_id; car->car_flags = flags; car->car_canceled = 0; - car->car_req_start = cfs_time_current_sec(); + car->car_req_start = ktime_get_real_seconds(); car->car_req_update = car->car_req_start; car->car_uuid = *uuid; OBD_ALLOC(car->car_hai, hai->hai_len); @@ -459,7 +459,7 @@ struct cdt_agent_req *mdt_cdt_update_request(struct coordinator *cdt, if (car == NULL) RETURN(ERR_PTR(-ENOENT)); - car->car_req_update = cfs_time_current_sec(); + car->car_req_update = ktime_get_real_seconds(); /* update data move progress done by copy tool */ if (car->car_hai->hai_action != HSMA_REMOVE && pgs->hpk_errval == 0 && diff --git a/lustre/mdt/mdt_internal.h b/lustre/mdt/mdt_internal.h index ecd0a85..2a9d21c 100644 --- a/lustre/mdt/mdt_internal.h +++ b/lustre/mdt/mdt_internal.h @@ -147,10 +147,10 @@ struct coordinator { * list */ struct mutex cdt_restore_lock; /**< protect restore * list */ - cfs_time_t cdt_loop_period; /**< llog scan period */ - cfs_time_t cdt_grace_delay; /**< request grace + time64_t cdt_loop_period; /**< llog scan period */ + time64_t cdt_grace_delay; /**< request grace * delay */ - cfs_time_t cdt_active_req_timeout; /**< request timeout */ + time64_t cdt_active_req_timeout; /**< request timeout */ __u32 cdt_default_archive_id; /**< archive id used * when none are * specified */ @@ -502,8 +502,8 @@ struct cdt_agent_req { struct obd_uuid car_uuid; /**< agent doing the req. */ __u32 car_archive_id; /**< archive id */ int car_canceled; /**< request was canceled */ - cfs_time_t car_req_start; /**< start time */ - cfs_time_t car_req_update; /**< last update time */ + time64_t car_req_start; /**< start time */ + time64_t car_req_update; /**< last update time */ struct hsm_action_item *car_hai; /**< req. to the agent */ struct cdt_req_progress car_progress; /**< track data mvt * progress */ diff --git a/lustre/mdt/mdt_xattr.c b/lustre/mdt/mdt_xattr.c index 3cd39f4..872cb77 100644 --- a/lustre/mdt/mdt_xattr.c +++ b/lustre/mdt/mdt_xattr.c @@ -398,7 +398,7 @@ int mdt_reint_setxattr(struct mdt_thread_info *info, "setxattr %s: [object "DFID"] [valid %llu]\n", mdt_obd_name(info->mti_mdt), xattr_name, PFID(rr->rr_fid1), valid); - attr->la_ctime = cfs_time_current_sec(); + attr->la_ctime = ktime_get_real_seconds(); } attr->la_valid = LA_CTIME; child = mdt_object_child(obj); -- 1.8.3.1