From 2728de4db8c0f8177202e2ffcad74a1893b210c9 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sun, 14 Jan 2018 19:17:01 -0500 Subject: [PATCH] LU-9019 libcfs: remove cfs_time_XXX_64 wrappers In an attempt to support 64 bit time handling before the linux kernel developed time64_t and ktime lustre attempted to use 64 bit jiffies with a libcfs abstraction. Lets remove these wrappers and replace them with modern 64 bit time support. The lustre code that used these wrappers needs time resolution at the seconds level so replace the code with time64_t handling. Change-Id: I2bd53c4ce83830bedd4448678dffce9f2b2173b1 Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/30867 Tested-by: Jenkins Reviewed-by: Andreas Dilger Tested-by: Maloo Reviewed-by: Dmitry Eremin --- libcfs/include/libcfs/linux/linux-time.h | 23 --------------- lustre/include/lu_target.h | 4 +-- lustre/include/lustre_import.h | 6 ++-- lustre/include/obd.h | 6 ++-- lustre/include/obd_class.h | 14 +++++----- lustre/llite/llite_internal.h | 2 +- lustre/llite/llite_lib.c | 6 ++-- lustre/llite/lproc_llite.c | 12 ++++---- lustre/lmv/lmv_obd.c | 4 +-- lustre/lod/lod_qos.c | 17 +++++------ lustre/lov/lov_obd.c | 4 +-- lustre/lov/lov_request.c | 4 +-- lustre/mdc/mdc_request.c | 5 ++-- lustre/mdt/mdt_handler.c | 2 +- lustre/obdclass/genops.c | 2 +- lustre/obdclass/lprocfs_status.c | 48 ++++++++++++++++++++------------ lustre/obdecho/echo_client.c | 4 +-- lustre/ofd/ofd_dev.c | 2 +- lustre/ofd/ofd_internal.h | 2 +- lustre/ofd/ofd_obd.c | 2 +- lustre/osc/osc_request.c | 4 +-- lustre/osp/osp_dev.c | 2 +- lustre/ptlrpc/import.c | 10 +++---- lustre/target/tgt_grant.c | 12 ++++---- lustre/target/tgt_main.c | 2 +- 25 files changed, 93 insertions(+), 106 deletions(-) diff --git a/libcfs/include/libcfs/linux/linux-time.h b/libcfs/include/libcfs/linux/linux-time.h index 115092f..67fb5c7 100644 --- a/libcfs/include/libcfs/linux/linux-time.h +++ b/libcfs/include/libcfs/linux/linux-time.h @@ -244,27 +244,4 @@ static inline time_t cfs_duration_sec(cfs_duration_t d) return d / msecs_to_jiffies(MSEC_PER_SEC); } -#define cfs_time_current_64 get_jiffies_64 - -static inline __u64 cfs_time_add_64(__u64 t, __u64 d) -{ - return t + d; -} - -static inline __u64 cfs_time_shift_64(int seconds) -{ - return cfs_time_add_64(cfs_time_current_64(), - cfs_time_seconds(seconds)); -} - -static inline int cfs_time_before_64(__u64 t1, __u64 t2) -{ - return (__s64)t2 - (__s64)t1 > 0; -} - -static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2) -{ - return (__s64)t2 - (__s64)t1 >= 0; -} - #endif /* __LIBCFS_LINUX_LINUX_TIME_H__ */ diff --git a/lustre/include/lu_target.h b/lustre/include/lu_target.h index c5f0501..b927d04 100644 --- a/lustre/include/lu_target.h +++ b/lustre/include/lu_target.h @@ -136,7 +136,7 @@ struct tg_grants_data { int tgd_grant_compat_disable; /* protect all statfs-related counters */ spinlock_t tgd_osfs_lock; - __u64 tgd_osfs_age; + time64_t tgd_osfs_age; int tgd_blockbits; /* counters used during statfs update, protected by ofd_osfs_lock. * record when some statfs refresh are in progress */ @@ -521,7 +521,7 @@ int tgt_grant_commit_cb_add(struct thandle *th, struct obd_export *exp, long tgt_grant_create(const struct lu_env *env, struct obd_export *exp, s64 *nr); int tgt_statfs_internal(const struct lu_env *env, struct lu_target *lut, - struct obd_statfs *osfs, __u64 max_age, + struct obd_statfs *osfs, time64_t max_age, int *from_cache); int tgt_tot_dirty_seq_show(struct seq_file *m, void *data); int tgt_tot_granted_seq_show(struct seq_file *m, void *data); diff --git a/lustre/include/lustre_import.h b/lustre/include/lustre_import.h index ef677d1..d48dee1 100644 --- a/lustre/include/lustre_import.h +++ b/lustre/include/lustre_import.h @@ -139,9 +139,9 @@ struct obd_import_conn { /** uuid of remote side */ struct obd_uuid oic_uuid; /** - * Time (64 bit jiffies) of last connection attempt on this connection + * Time (64 bit seconds) of last connection attempt on this connection */ - __u64 oic_last_attempt; + time64_t oic_last_attempt; }; /* state history */ @@ -257,7 +257,7 @@ struct obd_import { /** When to perform next ping. time in jiffies. */ time64_t imp_next_ping; /** When we last successfully connected. time in 64bit jiffies */ - __u64 imp_last_success_conn; + time64_t imp_last_success_conn; /** List of all possible connection for import. */ struct list_head imp_conn_list; diff --git a/lustre/include/obd.h b/lustre/include/obd.h index 9db3a90..6dc319d 100644 --- a/lustre/include/obd.h +++ b/lustre/include/obd.h @@ -639,7 +639,7 @@ struct obd_device { spinlock_t obd_dev_lock; /* protect OBD bitfield above */ spinlock_t obd_osfs_lock; struct obd_statfs obd_osfs; /* locked by obd_osfs_lock */ - __u64 obd_osfs_age; + time64_t obd_osfs_age; __u64 obd_last_committed; struct mutex obd_dev_mutex; struct lvfs_run_ctxt obd_lvfs_ctxt; @@ -934,9 +934,9 @@ struct obd_ops { * about this. */ int (*o_statfs)(const struct lu_env *, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, __u32 flags); + struct obd_statfs *osfs, time64_t max_age, __u32 flags); int (*o_statfs_async)(struct obd_export *exp, struct obd_info *oinfo, - __u64 max_age, struct ptlrpc_request_set *set); + time64_t max_age, struct ptlrpc_request_set *set); int (*o_create)(const struct lu_env *env, struct obd_export *exp, struct obdo *oa); int (*o_destroy)(const struct lu_env *env, struct obd_export *exp, diff --git a/lustre/include/obd_class.h b/lustre/include/obd_class.h index be2bf54..72da1c8 100644 --- a/lustre/include/obd_class.h +++ b/lustre/include/obd_class.h @@ -1079,7 +1079,7 @@ static inline int obd_destroy_export(struct obd_export *exp) * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ static inline int obd_statfs_async(struct obd_export *exp, struct obd_info *oinfo, - __u64 max_age, + time64_t max_age, struct ptlrpc_request_set *rqset) { int rc = 0; @@ -1097,9 +1097,9 @@ static inline int obd_statfs_async(struct obd_export *exp, } OBD_COUNTER_INCREMENT(obd, statfs); - CDEBUG(D_SUPER, "%s: osfs %p age %llu, max_age %llu\n", + CDEBUG(D_SUPER, "%s: osfs %p age %lld, max_age %lld\n", obd->obd_name, &obd->obd_osfs, obd->obd_osfs_age, max_age); - if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { + if (obd->obd_osfs_age < max_age) { rc = OBP(obd, statfs_async)(exp, oinfo, max_age, rqset); } else { CDEBUG(D_SUPER, @@ -1122,7 +1122,7 @@ static inline int obd_statfs_async(struct obd_export *exp, * If the cache is older than @max_age we will get a new value from the * target. Use a value of "cfs_time_current() + HZ" to guarantee freshness. */ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, + struct obd_statfs *osfs, time64_t max_age, __u32 flags) { int rc = 0; @@ -1138,14 +1138,14 @@ static inline int obd_statfs(const struct lu_env *env, struct obd_export *exp, } OBD_COUNTER_INCREMENT(obd, statfs); - CDEBUG(D_SUPER, "osfs %llu, max_age %llu\n", + CDEBUG(D_SUPER, "osfs %lld, max_age %lld\n", obd->obd_osfs_age, max_age); - if (cfs_time_before_64(obd->obd_osfs_age, max_age)) { + if (obd->obd_osfs_age < max_age) { rc = OBP(obd, statfs)(env, exp, osfs, max_age, flags); if (rc == 0) { spin_lock(&obd->obd_osfs_lock); memcpy(&obd->obd_osfs, osfs, sizeof(obd->obd_osfs)); - obd->obd_osfs_age = cfs_time_current_64(); + obd->obd_osfs_age = ktime_get_seconds(); spin_unlock(&obd->obd_osfs_lock); } } else { diff --git a/lustre/llite/llite_internal.h b/lustre/llite/llite_internal.h index cf5423f..0f345dc 100644 --- a/lustre/llite/llite_internal.h +++ b/lustre/llite/llite_internal.h @@ -913,7 +913,7 @@ int ll_setattr_raw(struct dentry *dentry, struct iattr *attr, bool hsm_import); int ll_setattr(struct dentry *de, struct iattr *attr); int ll_statfs(struct dentry *de, struct kstatfs *sfs); int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, - __u64 max_age, __u32 flags); + time64_t max_age, __u32 flags); int ll_update_inode(struct inode *inode, struct lustre_md *md); int ll_read_inode2(struct inode *inode, void *opaque); void ll_delete_inode(struct inode *inode); diff --git a/lustre/llite/llite_lib.c b/lustre/llite/llite_lib.c index 6381545..e9924ce 100644 --- a/lustre/llite/llite_lib.c +++ b/lustre/llite/llite_lib.c @@ -299,7 +299,7 @@ static int client_common_fill_super(struct super_block *sb, char *md, char *dt, * can make sure the client can be mounted as long as MDT0 is * avaible */ err = obd_statfs(NULL, sbi->ll_md_exp, osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() -OBD_STATFS_CACHE_SECONDS, OBD_STATFS_FOR_MDT0); if (err) GOTO(out_md_fid, err); @@ -1773,7 +1773,7 @@ int ll_setattr(struct dentry *de, struct iattr *attr) } int ll_statfs_internal(struct super_block *sb, struct obd_statfs *osfs, - __u64 max_age, __u32 flags) + time64_t max_age, __u32 flags) { struct ll_sb_info *sbi = ll_s2sbi(sb); struct obd_statfs obd_osfs; @@ -1833,7 +1833,7 @@ int ll_statfs(struct dentry *de, struct kstatfs *sfs) /* Some amount of caching on the client is allowed */ rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, 0); if (rc) return rc; diff --git a/lustre/llite/lproc_llite.c b/lustre/llite/lproc_llite.c index 15c1f21..dd3b825 100644 --- a/lustre/llite/lproc_llite.c +++ b/lustre/llite/lproc_llite.c @@ -60,7 +60,7 @@ static int ll_blksize_seq_show(struct seq_file *m, void *v) LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) seq_printf(m, "%u\n", osfs.os_bsize); @@ -107,7 +107,7 @@ static int ll_kbytestotal_seq_show(struct seq_file *m, void *v) LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -130,7 +130,7 @@ static int ll_kbytesfree_seq_show(struct seq_file *m, void *v) LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -153,7 +153,7 @@ static int ll_kbytesavail_seq_show(struct seq_file *m, void *v) LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) { __u32 blk_size = osfs.os_bsize >> 10; @@ -176,7 +176,7 @@ static int ll_filestotal_seq_show(struct seq_file *m, void *v) LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) seq_printf(m, "%llu\n", osfs.os_files); @@ -192,7 +192,7 @@ static int ll_filesfree_seq_show(struct seq_file *m, void *v) LASSERT(sb != NULL); rc = ll_statfs_internal(sb, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, OBD_STATFS_NODELAY); if (!rc) seq_printf(m, "%llu\n", osfs.os_ffree); diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 5ce50cb..df6d19e 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -934,7 +934,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, RETURN(-EFAULT); rc = obd_statfs(NULL, tgt->ltd_exp, &stat_buf, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, 0); if (rc) RETURN(rc); @@ -1362,7 +1362,7 @@ out: } static int lmv_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, __u32 flags) + struct obd_statfs *osfs, time64_t max_age, __u32 flags) { struct obd_device *obd = class_exp2obd(exp); struct lmv_obd *lmv = &obd->u.lmv; diff --git a/lustre/lod/lod_qos.c b/lustre/lod/lod_qos.c index f554cf9..7101f54 100644 --- a/lustre/lod/lod_qos.c +++ b/lustre/lod/lod_qos.c @@ -263,20 +263,21 @@ static void lod_qos_statfs_update(const struct lu_env *env, struct lod_device *lod) { struct obd_device *obd = lod2obd(lod); - struct ost_pool *osts = &(lod->lod_pool_info); - unsigned int i; - int idx; - __u64 max_age, avail; + struct ost_pool *osts = &(lod->lod_pool_info); + time64_t max_age; + unsigned int i; + u64 avail; + int idx; ENTRY; - max_age = cfs_time_shift_64(-2 * lod->lod_desc.ld_qos_maxage); + max_age = ktime_get_seconds() - 2 * lod->lod_desc.ld_qos_maxage; - if (cfs_time_beforeq_64(max_age, obd->obd_osfs_age)) + if (obd->obd_osfs_age > max_age) /* statfs data are quite recent, don't need to refresh it */ RETURN_EXIT; down_write(&lod->lod_qos.lq_rw_sem); - if (cfs_time_beforeq_64(max_age, obd->obd_osfs_age)) + if (max_age <= obd->obd_osfs_age) goto out; for (i = 0; i < osts->op_count; i++) { @@ -289,7 +290,7 @@ static void lod_qos_statfs_update(const struct lu_env *env, /* recalculate weigths */ lod->lod_qos.lq_dirty = 1; } - obd->obd_osfs_age = cfs_time_current_64(); + obd->obd_osfs_age = ktime_get_seconds(); out: up_write(&lod->lod_qos.lq_rw_sem); diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index c5284a3..88844e8 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -956,7 +956,7 @@ out: } static int lov_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, __u32 flags) + struct obd_statfs *osfs, time64_t max_age, __u32 flags) { struct obd_device *obd = class_exp2obd(exp); struct lov_obd *lov = &obd->u.lov; @@ -1045,7 +1045,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, /* got statfs data */ rc = obd_statfs(NULL, lov->lov_tgts[index]->ltd_exp, &stat_buf, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, flags); if (rc) RETURN(rc); diff --git a/lustre/lov/lov_request.c b/lustre/lov/lov_request.c index 57cb568..e7dda50 100644 --- a/lustre/lov/lov_request.c +++ b/lustre/lov/lov_request.c @@ -162,7 +162,7 @@ lov_fini_statfs(struct obd_device *obd, struct obd_statfs *osfs, int success) spin_lock(&obd->obd_osfs_lock); memcpy(&obd->obd_osfs, osfs, sizeof(*osfs)); - obd->obd_osfs_age = cfs_time_current_64(); + obd->obd_osfs_age = ktime_get_seconds(); spin_unlock(&obd->obd_osfs_lock); RETURN(0); } @@ -293,7 +293,7 @@ static int cb_statfs_update(void *cookie, int rc) spin_lock(&tgtobd->obd_osfs_lock); memcpy(&tgtobd->obd_osfs, lov_sfs, sizeof(*lov_sfs)); if ((oinfo->oi_flags & OBD_STATFS_FROM_CACHE) == 0) - tgtobd->obd_osfs_age = cfs_time_current_64(); + tgtobd->obd_osfs_age = ktime_get_seconds(); spin_unlock(&tgtobd->obd_osfs_lock); out_update: diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index ad3f62ba..b21c2b2 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -1445,10 +1445,9 @@ fail: goto out_unlock; } - static int mdc_statfs(const struct lu_env *env, struct obd_export *exp, struct obd_statfs *osfs, - __u64 max_age, __u32 flags) + time64_t max_age, __u32 flags) { struct obd_device *obd = class_exp2obd(exp); struct ptlrpc_request *req; @@ -1994,7 +1993,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, GOTO(out, rc = -EFAULT); rc = mdc_statfs(NULL, obd->obd_self_export, &stat_buf, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, 0); if (rc != 0) GOTO(out, rc); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index 7b0c612..57426d9 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -442,7 +442,7 @@ static int mdt_statfs(struct tgt_session_info *tsi) GOTO(out, rc = -EPROTO); rc = tgt_statfs_internal(tsi->tsi_env, &mdt->mdt_lut, osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, NULL); if (unlikely(rc)) GOTO(out, rc); diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 463e4ab5..cd006e7 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -369,7 +369,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name, spin_lock_init(&newdev->obd_osfs_lock); /* newdev->obd_osfs_age must be set to a value in the distant * past to guarantee a fresh statfs is fetched on mount. */ - newdev->obd_osfs_age = cfs_time_shift_64(-1000); + newdev->obd_osfs_age = ktime_get_seconds() - 1000; /* XXX belongs in setup not attach */ init_rwsem(&newdev->obd_observer_link_sem); diff --git a/lustre/obdclass/lprocfs_status.c b/lustre/obdclass/lprocfs_status.c index 0f15606..86a0a01 100644 --- a/lustre/obdclass/lprocfs_status.c +++ b/lustre/obdclass/lprocfs_status.c @@ -469,9 +469,11 @@ static ssize_t blocksize_show(struct kobject *kobj, struct attribute *attr, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct obd_statfs osfs; - int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - OBD_STATFS_NODELAY); + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); if (!rc) return sprintf(buf, "%u\n", osfs.os_bsize); @@ -485,9 +487,11 @@ static ssize_t kbytestotal_show(struct kobject *kobj, struct attribute *attr, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct obd_statfs osfs; - int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - OBD_STATFS_NODELAY); + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); if (!rc) { u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_blocks; @@ -508,9 +512,11 @@ static ssize_t kbytesfree_show(struct kobject *kobj, struct attribute *attr, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct obd_statfs osfs; - int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - OBD_STATFS_NODELAY); + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); if (!rc) { u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_bfree; @@ -531,9 +537,11 @@ static ssize_t kbytesavail_show(struct kobject *kobj, struct attribute *attr, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct obd_statfs osfs; - int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - OBD_STATFS_NODELAY); + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); if (!rc) { u32 blk_size = osfs.os_bsize >> 10; u64 result = osfs.os_bavail; @@ -554,9 +562,11 @@ static ssize_t filestotal_show(struct kobject *kobj, struct attribute *attr, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct obd_statfs osfs; - int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - OBD_STATFS_NODELAY); + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); if (!rc) return sprintf(buf, "%llu\n", osfs.os_files); @@ -570,9 +580,11 @@ static ssize_t filesfree_show(struct kobject *kobj, struct attribute *attr, struct obd_device *obd = container_of(kobj, struct obd_device, obd_kset.kobj); struct obd_statfs osfs; - int rc = obd_statfs(NULL, obd->obd_self_export, &osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), - OBD_STATFS_NODELAY); + int rc; + + rc = obd_statfs(NULL, obd->obd_self_export, &osfs, + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, + OBD_STATFS_NODELAY); if (!rc) return sprintf(buf, "%llu\n", osfs.os_ffree); diff --git a/lustre/obdecho/echo_client.c b/lustre/obdecho/echo_client.c index 9ec7e31..ae63296 100644 --- a/lustre/obdecho/echo_client.c +++ b/lustre/obdecho/echo_client.c @@ -1741,7 +1741,7 @@ static int echo_create_md_object(const struct lu_env *env, ma->ma_attr.la_mode = mode; ma->ma_attr.la_valid = LA_CTIME | LA_MODE; - ma->ma_attr.la_ctime = cfs_time_current_64(); + ma->ma_attr.la_ctime = ktime_get_real_seconds(); if (name != NULL) { lname->ln_name = name; @@ -2084,7 +2084,7 @@ static int echo_destroy_object(const struct lu_env *env, memset(ma, 0, sizeof(*ma)); ma->ma_attr.la_mode = mode; ma->ma_attr.la_valid = LA_CTIME; - ma->ma_attr.la_ctime = cfs_time_current_64(); + ma->ma_attr.la_ctime = ktime_get_real_seconds(); ma->ma_need = MA_INODE; ma->ma_valid = 0; diff --git a/lustre/ofd/ofd_dev.c b/lustre/ofd/ofd_dev.c index f7eb89c..3ef00be 100644 --- a/lustre/ofd/ofd_dev.c +++ b/lustre/ofd/ofd_dev.c @@ -1878,7 +1878,7 @@ static int ofd_statfs_hdl(struct tgt_session_info *tsi) osfs = req_capsule_server_get(tsi->tsi_pill, &RMF_OBD_STATFS); rc = ofd_statfs(tsi->tsi_env, tsi->tsi_exp, osfs, - cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS), 0); + ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS, 0); if (rc != 0) CERROR("%s: statfs failed: rc = %d\n", tgt_name(tsi->tsi_tgt), rc); diff --git a/lustre/ofd/ofd_internal.h b/lustre/ofd/ofd_internal.h index 16d3d3d..24a04b5 100644 --- a/lustre/ofd/ofd_internal.h +++ b/lustre/ofd/ofd_internal.h @@ -299,7 +299,7 @@ extern struct obd_ops ofd_obd_ops; int ofd_destroy_by_fid(const struct lu_env *env, struct ofd_device *ofd, const struct lu_fid *fid, int orphan); int ofd_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, __u32 flags); + struct obd_statfs *osfs, time64_t max_age, __u32 flags); int ofd_obd_disconnect(struct obd_export *exp); /* ofd_fs.c */ diff --git a/lustre/ofd/ofd_obd.c b/lustre/ofd/ofd_obd.c index 512f433..771f7bd 100644 --- a/lustre/ofd/ofd_obd.c +++ b/lustre/ofd/ofd_obd.c @@ -714,7 +714,7 @@ static int ofd_get_info(const struct lu_env *env, struct obd_export *exp, * \retval negative value on error */ int ofd_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, __u32 flags) + struct obd_statfs *osfs, time64_t max_age, __u32 flags) { struct obd_device *obd = class_exp2obd(exp); struct ofd_device *ofd = ofd_exp(exp); diff --git a/lustre/osc/osc_request.c b/lustre/osc/osc_request.c index 518a30f..2969858 100644 --- a/lustre/osc/osc_request.c +++ b/lustre/osc/osc_request.c @@ -2454,7 +2454,7 @@ out: } static int osc_statfs_async(struct obd_export *exp, - struct obd_info *oinfo, __u64 max_age, + struct obd_info *oinfo, time64_t max_age, struct ptlrpc_request_set *rqset) { struct obd_device *obd = class_exp2obd(exp); @@ -2498,7 +2498,7 @@ static int osc_statfs_async(struct obd_export *exp, } static int osc_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 max_age, __u32 flags) + struct obd_statfs *osfs, time64_t max_age, __u32 flags) { struct obd_device *obd = class_exp2obd(exp); struct obd_statfs *msfs; diff --git a/lustre/osp/osp_dev.c b/lustre/osp/osp_dev.c index 4c66255..daac499 100644 --- a/lustre/osp/osp_dev.c +++ b/lustre/osp/osp_dev.c @@ -1513,7 +1513,7 @@ static int osp_obd_disconnect(struct obd_export *exp) * \retval negative negative errno if statfs failed. */ static int osp_obd_statfs(const struct lu_env *env, struct obd_export *exp, - struct obd_statfs *osfs, __u64 unused, __u32 flags) + struct obd_statfs *osfs, time64_t unused, __u32 flags) { struct obd_statfs *msfs; struct ptlrpc_request *req; diff --git a/lustre/ptlrpc/import.c b/lustre/ptlrpc/import.c index 49ca64b..126b7e7 100644 --- a/lustre/ptlrpc/import.c +++ b/lustre/ptlrpc/import.c @@ -518,7 +518,7 @@ static int import_select_connection(struct obd_import *imp) } list_for_each_entry(conn, &imp->imp_conn_list, oic_item) { - CDEBUG(D_HA, "%s: connect to NID %s last attempt %llu\n", + CDEBUG(D_HA, "%s: connect to NID %s last attempt %lld\n", imp->imp_obd->obd_name, libcfs_nid2str(conn->oic_conn->c_peer.nid), conn->oic_last_attempt); @@ -526,8 +526,7 @@ static int import_select_connection(struct obd_import *imp) /* If we have not tried this connection since the last successful attempt, go with this one */ if ((conn->oic_last_attempt == 0) || - cfs_time_beforeq_64(conn->oic_last_attempt, - imp->imp_last_success_conn)) { + conn->oic_last_attempt <= imp->imp_last_success_conn) { imp_conn = conn; tried_all = 0; break; @@ -538,8 +537,7 @@ static int import_select_connection(struct obd_import *imp) least recently used */ if (!imp_conn) imp_conn = conn; - else if (cfs_time_before_64(conn->oic_last_attempt, - imp_conn->oic_last_attempt)) + else if (imp_conn->oic_last_attempt > conn->oic_last_attempt) imp_conn = conn; } @@ -568,7 +566,7 @@ static int import_select_connection(struct obd_import *imp) "to %ds\n", imp->imp_obd->obd_name, at_get(at)); } - imp_conn->oic_last_attempt = cfs_time_current_64(); + imp_conn->oic_last_attempt = ktime_get_seconds(); /* switch connection, don't mind if it's same as the current one */ if (imp->imp_connection) diff --git a/lustre/target/tgt_grant.c b/lustre/target/tgt_grant.c index 34b6e15..659afb3 100644 --- a/lustre/target/tgt_grant.c +++ b/lustre/target/tgt_grant.c @@ -280,14 +280,14 @@ EXPORT_SYMBOL(tgt_grant_sanity_check); * \retval negative value on error */ int tgt_statfs_internal(const struct lu_env *env, struct lu_target *lut, - struct obd_statfs *osfs, __u64 max_age, int *from_cache) + struct obd_statfs *osfs, time64_t max_age, int *from_cache) { struct tg_grants_data *tgd = &lut->lut_tgd; int rc = 0; ENTRY; spin_lock(&tgd->tgd_osfs_lock); - if (cfs_time_before_64(tgd->tgd_osfs_age, max_age) || max_age == 0) { + if (tgd->tgd_osfs_age < max_age || max_age == 0) { u64 unstable; /* statfs data are too old, get up-to-date one. @@ -344,7 +344,7 @@ int tgt_statfs_internal(const struct lu_env *env, struct lu_target *lut, /* finally udpate cached statfs data */ tgd->tgd_osfs = *osfs; - tgd->tgd_osfs_age = cfs_time_current_64(); + tgd->tgd_osfs_age = ktime_get_seconds(); tgd->tgd_statfs_inflight--; /* stop tracking */ if (tgd->tgd_statfs_inflight == 0) @@ -390,13 +390,13 @@ static void tgt_grant_statfs(const struct lu_env *env, struct obd_export *exp, struct tg_grants_data *tgd = &lut->lut_tgd; struct tgt_thread_info *tti; struct obd_statfs *osfs; - __u64 max_age; - int rc; + time64_t max_age; + int rc; if (force) max_age = 0; /* get fresh statfs data */ else - max_age = cfs_time_shift_64(-OBD_STATFS_CACHE_SECONDS); + max_age = ktime_get_seconds() - OBD_STATFS_CACHE_SECONDS; tti = tgt_th_info(env); osfs = &tti->tti_u.osfs; diff --git a/lustre/target/tgt_main.c b/lustre/target/tgt_main.c index 55fa9d6..448cd2e 100644 --- a/lustre/target/tgt_main.c +++ b/lustre/target/tgt_main.c @@ -195,7 +195,7 @@ int tgt_init(const struct lu_env *env, struct lu_target *lut, /* statfs data */ spin_lock_init(&tgd->tgd_osfs_lock); - tgd->tgd_osfs_age = cfs_time_shift_64(-1000); + tgd->tgd_osfs_age = ktime_get_seconds() - 1000; tgd->tgd_osfs_unstable = 0; tgd->tgd_statfs_inflight = 0; tgd->tgd_osfs_inflight = 0; -- 1.8.3.1