From: James Simmons Date: Tue, 17 Oct 2017 00:40:19 +0000 (-0400) Subject: LU-9019 ofd: migrate to 64 bit time X-Git-Tag: 2.10.55~37 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=a3f734db9b60c4f574ce104e4f03418d53a00215;p=fs%2Flustre-release.git LU-9019 ofd: migrate to 64 bit time Change fmd_expire and ofd_fmd_max_age to time64_t fields since we don't need more than seconds resolution. Move several parts of the code away from jiffies handling since it can be different across a set of nodes. We leave l_last_used and the stats timeout code alone since it affects more than the ofd layer. Change-Id: I505ad9b1c553bf1769241a5920cf146595a3812c Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28976 Reviewed-by: John L. Hammond Reviewed-by: Andreas Dilger Tested-by: Jenkins Reviewed-by: Dmitry Eremin Reviewed-by: Fan Yong Tested-by: Maloo --- diff --git a/lustre/ofd/lproc_ofd.c b/lustre/ofd/lproc_ofd.c index b23eda2..85ed221 100644 --- a/lustre/ofd/lproc_ofd.c +++ b/lustre/ofd/lproc_ofd.c @@ -298,9 +298,6 @@ LPROC_SEQ_FOPS(ofd_fmd_max_num); /** * Show the maximum age of FMD data in seconds. * - * Though it is shown in seconds, it is stored internally in units - * of jiffies for efficiency. - * * \param[in] m seq_file handle * \param[in] data unused for single entry * @@ -312,8 +309,7 @@ static int ofd_fmd_max_age_seq_show(struct seq_file *m, void *data) struct obd_device *obd = m->private; struct ofd_device *ofd = ofd_dev(obd->obd_lu_dev); - seq_printf(m, "%ld\n", jiffies_to_msecs(ofd->ofd_fmd_max_age) / - MSEC_PER_SEC); + seq_printf(m, "%lld\n", ofd->ofd_fmd_max_age); return 0; } @@ -321,7 +317,6 @@ static int ofd_fmd_max_age_seq_show(struct seq_file *m, void *data) * Set the maximum age of FMD data in seconds. * * This defines how long FMD data stays in the FMD list. - * It is stored internally in units of jiffies for efficiency. * * \param[in] file proc file * \param[in] buffer string which represents maximum number @@ -348,7 +343,7 @@ ofd_fmd_max_age_seq_write(struct file *file, const char __user *buffer, if (val > 65536 || val < 1) return -EINVAL; - ofd->ofd_fmd_max_age = msecs_to_jiffies(val * MSEC_PER_SEC); + ofd->ofd_fmd_max_age = val; return count; } LPROC_SEQ_FOPS(ofd_fmd_max_age); diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index 3bb3d59..02cf82a 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -1698,10 +1698,10 @@ static int ofd_create_hdl(struct tgt_session_info *tsi) } } if (diff > 0) { - cfs_time_t enough_time = cfs_time_shift(DISK_TIMEOUT); - u64 next_id; - int created = 0; - int count; + time64_t enough_time = ktime_get_seconds() + DISK_TIMEOUT; + u64 next_id; + int created = 0; + int count; if (!(oa->o_valid & OBD_MD_FLFLAGS) || !(oa->o_flags & OBD_FL_DELORPHAN)) { @@ -1749,7 +1749,7 @@ static int ofd_create_hdl(struct tgt_session_info *tsi) count, seq, next_id); if (!(lustre_msg_get_flags(req->rq_reqmsg) & MSG_REPLAY) - && cfs_time_after(jiffies, enough_time)) { + && ktime_get_seconds() > enough_time) { CDEBUG(D_HA, "%s: Slow creates, %d/%lld objects" " created at a rate of %d/s\n", ofd_name(ofd), created, diff + created, diff --git a/lustre/ofd/ofd_fmd.c b/lustre/ofd/ofd_fmd.c index 9c68078..9ff073d 100644 --- a/lustre/ofd/ofd_fmd.c +++ b/lustre/ofd/ofd_fmd.c @@ -111,17 +111,16 @@ void ofd_fmd_put(struct obd_export *exp, struct ofd_mod_data *fmd) static void ofd_fmd_expire_nolock(struct obd_export *exp, struct ofd_mod_data *keep) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_device *ofd = ofd_exp(exp); - struct ofd_mod_data *fmd, *tmp; - - cfs_time_t now = cfs_time_current(); + struct filter_export_data *fed = &exp->exp_filter_data; + struct ofd_device *ofd = ofd_exp(exp); + time64_t now = ktime_get_seconds(); + struct ofd_mod_data *fmd, *tmp; list_for_each_entry_safe(fmd, tmp, &fed->fed_mod_list, fmd_list) { if (fmd == keep) break; - if (cfs_time_before(now, fmd->fmd_expire) && + if (now < fmd->fmd_expire && fed->fed_mod_count < ofd->ofd_fmd_max_num) break; @@ -162,11 +161,10 @@ void ofd_fmd_expire(struct obd_export *exp) static struct ofd_mod_data *ofd_fmd_find_nolock(struct obd_export *exp, const struct lu_fid *fid) { - struct filter_export_data *fed = &exp->exp_filter_data; - struct ofd_mod_data *found = NULL, *fmd; - struct ofd_device *ofd = ofd_exp(exp); - - cfs_time_t now = cfs_time_current(); + struct filter_export_data *fed = &exp->exp_filter_data; + struct ofd_mod_data *found = NULL, *fmd; + struct ofd_device *ofd = ofd_exp(exp); + time64_t now = ktime_get_seconds(); assert_spin_locked(&fed->fed_lock); @@ -175,7 +173,7 @@ static struct ofd_mod_data *ofd_fmd_find_nolock(struct obd_export *exp, found = fmd; list_del(&fmd->fmd_list); list_add_tail(&fmd->fmd_list, &fed->fed_mod_list); - fmd->fmd_expire = cfs_time_add(now, ofd->ofd_fmd_max_age); + fmd->fmd_expire = now + ofd->ofd_fmd_max_age; break; } } @@ -230,8 +228,7 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, const struct lu_fid *fi struct filter_export_data *fed = &exp->exp_filter_data; struct ofd_device *ofd = ofd_exp(exp); struct ofd_mod_data *found = NULL, *fmd_new = NULL; - - cfs_time_t now = cfs_time_current(); + time64_t now = ktime_get_seconds(); OBD_SLAB_ALLOC_PTR(fmd_new, ll_fmd_cachep); @@ -251,7 +248,7 @@ struct ofd_mod_data *ofd_fmd_get(struct obd_export *exp, const struct lu_fid *fi } if (found) { found->fmd_refcount++; /* caller reference */ - found->fmd_expire = cfs_time_add(now, ofd->ofd_fmd_max_age); + found->fmd_expire = now + ofd->ofd_fmd_max_age; } spin_unlock(&fed->fed_lock); diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 611c8db..2af6d26 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -56,12 +56,12 @@ struct ofd_mod_data { struct list_head fmd_list; /* linked to fed_mod_list */ struct lu_fid fmd_fid; /* FID being written to */ __u64 fmd_mactime_xid; /* xid highest {m,a,c}time setattr */ - cfs_time_t fmd_expire; /* time when the fmd should expire */ + time64_t fmd_expire; /* time when the fmd should expire */ int fmd_refcount; /* reference counter - list holds 1 */ }; #define OFD_FMD_MAX_NUM_DEFAULT 128 -#define OFD_FMD_MAX_AGE_DEFAULT msecs_to_jiffies((obd_timeout+10)*MSEC_PER_SEC) +#define OFD_FMD_MAX_AGE_DEFAULT (obd_timeout + 10) #define OFD_SOFT_SYNC_LIMIT_DEFAULT 16 @@ -137,7 +137,7 @@ struct ofd_device { /* ofd mod data: ofd_device wide values */ int ofd_fmd_max_num; /* per ofd ofd_mod_data */ - cfs_duration_t ofd_fmd_max_age; /* time to fmd expiry */ + time64_t ofd_fmd_max_age; /* time to fmd expiry */ spinlock_t ofd_flags_lock; unsigned long ofd_raid_degraded:1,