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__ */
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 */
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);
/** 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 */
/** 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;
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;
* 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,
* 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;
}
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,
* 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;
}
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 {
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);
* 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);
}
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;
/* 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;
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);
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;
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;
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;
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);
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);
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);
}
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;
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++) {
/* 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);
}
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;
/* 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);
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);
}
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:
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;
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);
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);
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);
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);
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;
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;
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;
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);
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);
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;
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;
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);
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 */
* \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);
}
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);
}
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;
* \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;
}
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);
/* 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;
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;
}
"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)
* \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.
/* 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)
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;
/* 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;