From 18c3e9cccbc2159bbc78769d7ae167ee899df366 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Wed, 7 Feb 2018 01:20:54 -0500 Subject: [PATCH] LU-9019 obd: migrate upcall cache to time64_t Move all the upcall cache time handling from jiffies to time64_t. Change-Id: I86039c6e6e35ac83b773753c952936f1b2f5e14a Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/31064 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Ben Evans Reviewed-by: Dmitry Eremin Reviewed-by: Sebastien Buisson Reviewed-by: Oleg Drokin --- lustre/include/upcall_cache.h | 8 ++++---- lustre/mdt/mdt_lproc.c | 10 ++++++---- lustre/obdclass/upcall_cache.c | 18 +++++++++--------- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/lustre/include/upcall_cache.h b/lustre/include/upcall_cache.h index 88aed30..1f02294 100644 --- a/lustre/include/upcall_cache.h +++ b/lustre/include/upcall_cache.h @@ -85,8 +85,8 @@ struct upcall_cache_entry { atomic_t ue_refcount; int ue_flags; wait_queue_head_t ue_waitq; - cfs_time_t ue_acquire_expire; - cfs_time_t ue_expire; + time64_t ue_acquire_expire; + time64_t ue_expire; union { struct md_identity identity; } u; @@ -121,8 +121,8 @@ struct upcall_cache { char uc_name[40]; /* for upcall */ char uc_upcall[UC_CACHE_UPCALL_MAXPATH]; - int uc_acquire_expire; /* seconds */ - int uc_entry_expire; /* seconds */ + time64_t uc_acquire_expire; /* seconds */ + time64_t uc_entry_expire; /* seconds */ struct upcall_cache_ops *uc_ops; }; diff --git a/lustre/mdt/mdt_lproc.c b/lustre/mdt/mdt_lproc.c index d3c1fc9..8c8f50b 100644 --- a/lustre/mdt/mdt_lproc.c +++ b/lustre/mdt/mdt_lproc.c @@ -213,7 +213,7 @@ static int mdt_identity_expire_seq_show(struct seq_file *m, void *data) struct obd_device *obd = m->private; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - seq_printf(m, "%u\n", mdt->mdt_identity_cache->uc_entry_expire); + seq_printf(m, "%lld\n", mdt->mdt_identity_cache->uc_entry_expire); return 0; } @@ -224,12 +224,13 @@ mdt_identity_expire_seq_write(struct file *file, const char __user *buffer, struct seq_file *m = file->private_data; struct obd_device *obd = m->private; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + time64_t val; int rc; - __s64 val; rc = lprocfs_str_to_s64(buffer, count, &val); if (rc) return rc; + if (val < 0 || val > INT_MAX) return -ERANGE; @@ -244,7 +245,7 @@ static int mdt_identity_acquire_expire_seq_show(struct seq_file *m, void *data) struct obd_device *obd = m->private; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); - seq_printf(m, "%u\n", mdt->mdt_identity_cache->uc_acquire_expire); + seq_printf(m, "%lld\n", mdt->mdt_identity_cache->uc_acquire_expire); return 0; } @@ -256,12 +257,13 @@ mdt_identity_acquire_expire_seq_write(struct file *file, struct seq_file *m = file->private_data; struct obd_device *obd = m->private; struct mdt_device *mdt = mdt_dev(obd->obd_lu_dev); + time64_t val; int rc; - __s64 val; rc = lprocfs_str_to_s64(buffer, count, &val); if (rc) return rc; + if (val < 0 || val > INT_MAX) return -ERANGE; diff --git a/lustre/obdclass/upcall_cache.c b/lustre/obdclass/upcall_cache.c index e31b9ea..6023346 100644 --- a/lustre/obdclass/upcall_cache.c +++ b/lustre/obdclass/upcall_cache.c @@ -115,14 +115,14 @@ static inline void put_entry(struct upcall_cache *cache, static int check_unlink_entry(struct upcall_cache *cache, struct upcall_cache_entry *entry) { - if (UC_CACHE_IS_VALID(entry) && - cfs_time_before(cfs_time_current(), entry->ue_expire)) + time64_t now = ktime_get_seconds(); + + if (UC_CACHE_IS_VALID(entry) && now < entry->ue_expire) return 0; if (UC_CACHE_IS_ACQUIRING(entry)) { if (entry->ue_acquire_expire == 0 || - cfs_time_before(cfs_time_current(), - entry->ue_acquire_expire)) + now < entry->ue_acquire_expire) return 0; UC_CACHE_SET_EXPIRED(entry); @@ -198,8 +198,8 @@ find_again: spin_unlock(&cache->uc_lock); rc = refresh_entry(cache, entry); spin_lock(&cache->uc_lock); - entry->ue_acquire_expire = - cfs_time_shift(cache->uc_acquire_expire); + entry->ue_acquire_expire = ktime_get_seconds() + + cache->uc_acquire_expire; if (rc < 0) { UC_CACHE_CLEAR_ACQUIRING(entry); UC_CACHE_SET_INVALID(entry); @@ -340,7 +340,7 @@ int upcall_cache_downcall(struct upcall_cache *cache, __u32 err, __u64 key, if (rc) GOTO(out, rc); - entry->ue_expire = cfs_time_shift(cache->uc_entry_expire); + entry->ue_expire = ktime_get_seconds() + cache->uc_entry_expire; UC_CACHE_SET_VALID(entry); CDEBUG(D_OTHER, "%s: created upcall cache entry %p for key %llu\n", cache->uc_name, entry, entry->ue_key); @@ -400,10 +400,10 @@ void upcall_cache_flush_one(struct upcall_cache *cache, __u64 key, void *args) if (found) { CWARN("%s: flush entry %p: key %llu, ref %d, fl %x, " - "cur %lu, ex %ld/%ld\n", + "cur %lld, ex %lld/%lld\n", cache->uc_name, entry, entry->ue_key, atomic_read(&entry->ue_refcount), entry->ue_flags, - cfs_time_current_sec(), entry->ue_acquire_expire, + ktime_get_real_seconds(), entry->ue_acquire_expire, entry->ue_expire); UC_CACHE_SET_EXPIRED(entry); if (!atomic_read(&entry->ue_refcount)) -- 1.8.3.1