From: James Simmons Date: Mon, 14 Aug 2017 18:25:19 +0000 (-0400) Subject: LU-9019 mdd: migrate from jiffies64 to ktime X-Git-Tag: 2.10.53~64 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a9e0b853aabc1c817e3f4c250714ed86bb76a1ee;p=fs%2Flustre-release.git LU-9019 mdd: migrate from jiffies64 to ktime The mdd layer uses cfs_time_xxx_64() for 64 bit time percision. This was written before ktime_t came into existence and it uses 64 bit version of jiffies which can vary between nodes due to HZ being configurable. This provides a consistent format with nanosecond precision on any node. Change-Id: Ibec17227fd70a148c83296e8d1c41668f67e9201 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28407 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Fan Yong Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Reviewed-by: Oleg Drokin --- diff --git a/lustre/mdd/mdd_device.c b/lustre/mdd/mdd_device.c index c034a40..d43bf3b 100644 --- a/lustre/mdd/mdd_device.c +++ b/lustre/mdd/mdd_device.c @@ -417,7 +417,7 @@ static int mdd_changelog_init(const struct lu_env *env, struct mdd_device *mdd) mdd->mdd_cl.mc_index = 0; spin_lock_init(&mdd->mdd_cl.mc_lock); - mdd->mdd_cl.mc_starttime = cfs_time_current_64(); + mdd->mdd_cl.mc_starttime = ktime_get(); spin_lock_init(&mdd->mdd_cl.mc_user_lock); mdd->mdd_cl.mc_lastuser = 0; @@ -494,7 +494,7 @@ mdd_changelog_llog_cancel(const struct lu_env *env, struct mdd_device *mdd, /* Some records were purged, so reset repeat-access time (so we record new mtime update records, so users can see a file has been changed since the last purge) */ - mdd->mdd_cl.mc_starttime = cfs_time_current_64(); + mdd->mdd_cl.mc_starttime = ktime_get(); rc = llog_cancel(env, ctxt, (struct llog_cookie *)&endrec, 0); out: @@ -521,7 +521,7 @@ int mdd_changelog_write_header(const struct lu_env *env, ENTRY; if (mdd->mdd_cl.mc_mask & (1 << CL_MARK)) { - mdd->mdd_cl.mc_starttime = cfs_time_current_64(); + mdd->mdd_cl.mc_starttime = ktime_get(); RETURN(0); } @@ -554,7 +554,7 @@ int mdd_changelog_write_header(const struct lu_env *env, llog_ctxt_put(ctxt); /* assume on or off event; reset repeat-access time */ - mdd->mdd_cl.mc_starttime = cfs_time_current_64(); + mdd->mdd_cl.mc_starttime = ktime_get(); RETURN(rc); } diff --git a/lustre/mdd/mdd_dir.c b/lustre/mdd/mdd_dir.c index b0120ab..ed18566 100644 --- a/lustre/mdd/mdd_dir.c +++ b/lustre/mdd/mdd_dir.c @@ -941,7 +941,7 @@ int mdd_changelog_ns_store(const struct lu_env *env, if (likely(target != NULL)) { rec->cr.cr_tfid = *mdo2fid(target); - target->mod_cltime = cfs_time_current_64(); + target->mod_cltime = ktime_get(); } else { fid_zero(&rec->cr.cr_tfid); } diff --git a/lustre/mdd/mdd_internal.h b/lustre/mdd/mdd_internal.h index 2588436..7d1d8e6 100644 --- a/lustre/mdd/mdd_internal.h +++ b/lustre/mdd/mdd_internal.h @@ -66,7 +66,7 @@ struct mdd_changelog { int mc_flags; int mc_mask; __u64 mc_index; - __u64 mc_starttime; + ktime_t mc_starttime; spinlock_t mc_user_lock; int mc_lastuser; }; @@ -121,12 +121,12 @@ enum mod_flags { }; struct mdd_object { - struct md_object mod_obj; - /* open count */ - __u32 mod_count; - __u32 mod_valid; - __u64 mod_cltime; - unsigned long mod_flags; + struct md_object mod_obj; + /* open count */ + u32 mod_count; + u32 mod_valid; + ktime_t mod_cltime; + unsigned long mod_flags; }; struct mdd_thread_info { diff --git a/lustre/mdd/mdd_object.c b/lustre/mdd/mdd_object.c index 76e2fd2..7ab1a1a 100644 --- a/lustre/mdd/mdd_object.c +++ b/lustre/mdd/mdd_object.c @@ -141,7 +141,7 @@ static int mdd_object_init(const struct lu_env *env, struct lu_object *o, struct lu_device *under; ENTRY; - mdd_obj->mod_cltime = 0; + mdd_obj->mod_cltime = ktime_set(0, 0); under = &d->mdd_child->dd_lu_dev; below = under->ld_ops->ldo_object_alloc(env, o->lo_header, under); if (IS_ERR(below)) @@ -180,9 +180,9 @@ static int mdd_object_print(const struct lu_env *env, void *cookie, struct mdd_object *mdd = lu2mdd_obj((struct lu_object *)o); return (*p)(env, cookie, - LUSTRE_MDD_NAME"-object@%p(open_count=%d, valid=%x, cltime=%llu, flags=%lx)", + LUSTRE_MDD_NAME"-object@%p(open_count=%d, valid=%x, cltime=%lldns, flags=%lx)", mdd, mdd->mod_count, mdd->mod_valid, - mdd->mod_cltime, mdd->mod_flags); + ktime_to_ns(mdd->mod_cltime), mdd->mod_flags); } static const struct lu_object_operations mdd_lu_obj_ops = { @@ -692,7 +692,7 @@ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd, RETURN(0); if ((type >= CL_MTIME) && (type <= CL_ATIME) && - cfs_time_before_64(mdd->mdd_cl.mc_starttime, mdd_obj->mod_cltime)) { + ktime_before(mdd->mdd_cl.mc_starttime, mdd_obj->mod_cltime)) { /* Don't need multiple updates in this log */ /* Don't check under lock - no big deal if we get an extra entry */ @@ -702,7 +702,7 @@ int mdd_changelog_data_store(const struct lu_env *env, struct mdd_device *mdd, rc = mdd_changelog_data_store_by_fid(env, mdd, type, flags, mdo2fid(mdd_obj), handle); if (rc == 0) - mdd_obj->mod_cltime = cfs_time_current_64(); + mdd_obj->mod_cltime = ktime_get(); RETURN(rc); }