@@ -415,15 +415,18 @@ struct ldlm_namespace {
*/
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;
/**
- * 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
@@ -378,8 +378,7 @@ static void ldlm_handle_gl_callback(struct ptlrpc_request *req,
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
@@ -332,7 +332,8 @@ static ssize_t dirty_age_limit_show(struct kobject *kobj,
struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
ns_kobj);
- return sprintf(buf, "%llu\n", ns->ns_dirty_age_limit);
+ return scnprintf(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,
@@ -346,7 +347,7 @@ 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;
}
@@ -646,7 +647,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
ns->ns_max_age = ktime_set(LDLM_DEFAULT_MAX_ALIVE, 0);
ns->ns_orig_connect_flags = 0;
ns->ns_connect_flags = 0;
- ns->ns_dirty_age_limit = LDLM_DIRTY_AGE_LIMIT;
+ ns->ns_dirty_age_limit = ktime_set(LDLM_DIRTY_AGE_LIMIT, 0);
ns->ns_stopping = 0;
ns->ns_last_pos = &ns->ns_unused_list;
@@ -418,8 +418,7 @@ int ll_md_need_convert(struct ldlm_lock *lock)
/* 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;
}