Whamcloud - gitweb
LU-9019 mdt: migrate to 64 bit time 88/28788/15
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 9 Nov 2017 00:44:19 +0000 (19:44 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 22 Nov 2017 03:54:39 +0000 (03:54 +0000)
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 <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/28788
Reviewed-by: Quentin Bouget <quentin.bouget@cea.fr>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/mdt/mdt_coordinator.c
lustre/mdt/mdt_handler.c
lustre/mdt/mdt_hsm_cdt_actions.c
lustre/mdt/mdt_hsm_cdt_requests.c
lustre/mdt/mdt_internal.h
lustre/mdt/mdt_xattr.c

index d369a5d..d2618f4 100644 (file)
@@ -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;
        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;
 
                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) <
                        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);
                        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 };
        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;
        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
                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_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");
 
                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 <=
                /* 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;
                        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;
         * 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);
                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 */
 
        /* 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;
 
        /* 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 */
 
        /* 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);
        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;
        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);
        }
 
                rc = llog_write(env, llh, hdr, hdr->lrh_index);
        }
 
index 5ef06db..625fa0b 100644 (file)
@@ -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 +
                         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;
                 }
 
                                 child_bits |= MDS_INODELOCK_UPDATE;
                 }
 
index b17aa17..32ea69f 100644 (file)
@@ -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_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);
 
        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;
        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.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);
 
        rc = cdt_llog_process(env, mdt, mdt_agent_record_update_cb, &ducb,
                              start_cat_idx, start_rec_idx, WRITE);
index a07cb7c..60872ed 100644 (file)
@@ -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_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);
        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));
 
        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 &&
 
        /* update data move progress done by copy tool */
        if (car->car_hai->hai_action != HSMA_REMOVE && pgs->hpk_errval == 0 &&
index ecd0a85..2a9d21c 100644 (file)
@@ -147,10 +147,10 @@ struct coordinator {
                                                       * list */
        struct mutex             cdt_restore_lock;    /**< protect restore
                                                       * list */
                                                       * 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 */
                                                       * 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 */
        __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 */
        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 */
        struct hsm_action_item  *car_hai;          /**< req. to the agent */
        struct cdt_req_progress  car_progress;     /**< track data mvt
                                                    *   progress */
index 3cd39f4..872cb77 100644 (file)
@@ -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);
                      "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);
        }
        attr->la_valid = LA_CTIME;
        child = mdt_object_child(obj);