Use timeout_t for ns_ctime_age_limit since this is a relative time
and not an absolute time.
Use ktime_t for ns_dirty_age_limit internally, even though the user
interface is in seconds, since this is frequenty used together with
other ktime_t values in the kernel.
Fixes:
e920be681451 ("LU-9019 ldlm: migrate the rest of the code to 64 bit time")
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: Idb5ece834e56a95cd781cb871b1b7c20bf3ebbe5
Reviewed-on: https://review.whamcloud.com/38365
Reviewed-by: James Simmons <jsimmons@infradead.org>
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Shaun Tancheff <shaun.tancheff@hpe.com>
Reviewed-by: Yang Sheng <ys@whamcloud.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
*/
unsigned int ns_max_unused;
- /** Maximum allowed age (last used time) for locks in the LRU */
+ /** Maximum allowed age (last used time) for locks in the LRU. Set in
+ * seconds from userspace, but stored in ns to avoid repeat conversions.
+ */
ktime_t ns_max_age;
/**
*/
unsigned int ns_timeouts;
/**
- * Number of seconds since the file change time after which the
- * MDT will return an UPDATE lock along with a LOOKUP lock.
+ * Number of seconds since the file change time after which
+ * the MDT will return an UPDATE lock along with a LOOKUP lock.
* This allows the client to start caching negative dentries
* for a directory and may save an RPC for a later stat.
*/
- time64_t ns_ctime_age_limit;
+ timeout_t ns_ctime_age_limit;
/**
- * Number of seconds since the lock was last used. The client may
- * cancel the lock limited by this age and flush related data if
- * any other client shows interest in it doing glimpse request.
- * This allows to cache stat data locally for such files early.
+ * Number of (nano)seconds since the lock was last used. The client
+ * may cancel the lock older than this age and flush related data if
+ * another client shows interest in this lock by doing glimpse request.
+ * This allows to cache stat data locally for such files early. Set in
+ * seconds from userspace, but stored in ns to avoid repeat conversions.
*/
- time64_t ns_dirty_age_limit;
+ ktime_t ns_dirty_age_limit;
/**
* Used to rate-limit ldlm_namespace_dump calls.
* \see ldlm_namespace_dump. Increased by 10 seconds every time
if (lock->l_granted_mode == LCK_PW &&
!lock->l_readers && !lock->l_writers &&
ktime_after(ktime_get(),
- ktime_add(lock->l_last_used,
- ktime_set(ns->ns_dirty_age_limit, 0)))) {
+ ktime_add(lock->l_last_used, ns->ns_dirty_age_limit))) {
unlock_res_and_lock(lock);
/* For MDS glimpse it is always DOM lock, set corresponding
struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
ns_kobj);
- return sprintf(buf, "%llu\n", ns->ns_dirty_age_limit);
+ return snprintf(buf, PAGE_SIZE, "%llu\n",
+ ktime_divns(ns->ns_dirty_age_limit, NSEC_PER_SEC));
}
static ssize_t dirty_age_limit_store(struct kobject *kobj,
if (kstrtoull(buffer, 10, &tmp))
return -EINVAL;
- ns->ns_dirty_age_limit = tmp;
+ ns->ns_dirty_age_limit = ktime_set(tmp, 0);
return count;
}
struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
ns_kobj);
- return sprintf(buf, "%llu\n", ns->ns_ctime_age_limit);
+ return snprintf(buf, PAGE_SIZE, "%u\n", ns->ns_ctime_age_limit);
}
static ssize_t ctime_age_limit_store(struct kobject *kobj,
{
struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
ns_kobj);
- unsigned long long tmp;
+ unsigned long tmp;
- if (kstrtoull(buffer, 10, &tmp))
+ if (kstrtoul(buffer, 10, &tmp))
return -EINVAL;
ns->ns_ctime_age_limit = tmp;
ns->ns_max_unused = LDLM_DEFAULT_LRU_SIZE;
ns->ns_max_age = ktime_set(LDLM_DEFAULT_MAX_ALIVE, 0);
ns->ns_ctime_age_limit = LDLM_CTIME_AGE_LIMIT;
- ns->ns_dirty_age_limit = LDLM_DIRTY_AGE_LIMIT;
+ ns->ns_dirty_age_limit = ktime_set(LDLM_DIRTY_AGE_LIMIT, 0);
ns->ns_timeouts = 0;
ns->ns_orig_connect_flags = 0;
ns->ns_connect_flags = 0;
/* is lock is too old to be converted? */
lock_res_and_lock(lock);
if (ktime_after(ktime_get(),
- ktime_add(lock->l_last_used,
- ktime_set(ns->ns_dirty_age_limit, 0)))) {
+ ktime_add(lock->l_last_used, ns->ns_dirty_age_limit))) {
unlock_res_and_lock(lock);
return 0;
}