Whamcloud - gitweb
LU-8541 ldlm: don't use jiffies as sysfs parameter
[fs/lustre-release.git] / lustre / ldlm / ldlm_resource.c
index 5cb58f5..31ee704 100644 (file)
@@ -407,7 +407,7 @@ static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr,
        struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
                                                 ns_kobj);
 
-       return sprintf(buf, "%u\n", ns->ns_max_age);
+       return sprintf(buf, "%lld\n", ktime_to_ms(ns->ns_max_age));
 }
 
 static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr,
@@ -415,14 +415,27 @@ static ssize_t lru_max_age_store(struct kobject *kobj, struct attribute *attr,
 {
        struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
                                                 ns_kobj);
-       unsigned long tmp;
+       int scale = NSEC_PER_MSEC;
+       unsigned long long tmp;
+       char *buf;
        int err;
 
-       err = kstrtoul(buffer, 10, &tmp);
+       /* Did the user ask in seconds or milliseconds. Default is in ms */
+       buf = strstr(buffer, "ms");
+       if (!buf) {
+               buf = strchr(buffer, 's');
+               if (buf)
+                       scale = NSEC_PER_SEC;
+       }
+
+       if (buf)
+               *buf = '\0';
+
+       err = kstrtoull(buffer, 10, &tmp);
        if (err != 0)
                return -EINVAL;
 
-       ns->ns_max_age = tmp;
+       ns->ns_max_age = ktime_set(0, tmp * scale);
 
        return count;
 }
@@ -940,7 +953,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
         ns->ns_max_parallel_ast   = LDLM_DEFAULT_PARALLEL_AST_LIMIT;
         ns->ns_nr_unused          = 0;
         ns->ns_max_unused         = LDLM_DEFAULT_LRU_SIZE;
-        ns->ns_max_age            = LDLM_DEFAULT_MAX_ALIVE;
+       ns->ns_max_age            = ktime_set(LDLM_DEFAULT_MAX_ALIVE, 0);
         ns->ns_ctime_age_limit    = LDLM_CTIME_AGE_LIMIT;
         ns->ns_timeouts           = 0;
         ns->ns_orig_connect_flags = 0;