Whamcloud - gitweb
LU-12931 ldlm: use proper units for timeouts
[fs/lustre-release.git] / lustre / ldlm / ldlm_resource.c
index 6691acd..735fad3 100644 (file)
@@ -458,7 +458,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 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,
@@ -472,7 +473,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;
 }
@@ -485,7 +486,7 @@ static ssize_t ctime_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_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,
@@ -494,9 +495,9 @@ 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;
@@ -549,7 +550,7 @@ static ssize_t contention_seconds_show(struct kobject *kobj,
        struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
                                                 ns_kobj);
 
-       return sprintf(buf, "%llu\n", ns->ns_contention_time);
+       return scnprintf(buf, PAGE_SIZE, "%d\n", ns->ns_contention_time);
 }
 
 static ssize_t contention_seconds_store(struct kobject *kobj,
@@ -558,9 +559,9 @@ static ssize_t contention_seconds_store(struct kobject *kobj,
 {
        struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
                                                 ns_kobj);
-       unsigned long long tmp;
+       unsigned int tmp;
 
-       if (kstrtoull(buffer, 10, &tmp))
+       if (kstrtouint(buffer, 10, &tmp))
                return -EINVAL;
 
        ns->ns_contention_time = tmp;
@@ -880,8 +881,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
        ns->ns_bucket_bits = ldlm_ns_hash_defs[ns_type].nsd_all_bits -
                             ldlm_ns_hash_defs[ns_type].nsd_bkt_bits;
 
-       OBD_ALLOC_LARGE(ns->ns_rs_buckets,
-                       BIT(ns->ns_bucket_bits) * sizeof(ns->ns_rs_buckets[0]));
+       OBD_ALLOC_PTR_ARRAY_LARGE(ns->ns_rs_buckets, 1 << ns->ns_bucket_bits);
        if (!ns->ns_rs_buckets)
                goto out_hash;
 
@@ -916,7 +916,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
        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;
@@ -951,8 +951,7 @@ out_sysfs:
        ldlm_namespace_sysfs_unregister(ns);
        ldlm_namespace_cleanup(ns, 0);
 out_hash:
-       OBD_FREE_LARGE(ns->ns_rs_buckets,
-                      BIT(ns->ns_bucket_bits) * sizeof(ns->ns_rs_buckets[0]));
+       OBD_FREE_PTR_ARRAY_LARGE(ns->ns_rs_buckets, 1 << ns->ns_bucket_bits);
        kfree(ns->ns_name);
        cfs_hash_putref(ns->ns_rs_hash);
 out_ns:
@@ -1221,8 +1220,7 @@ void ldlm_namespace_free_post(struct ldlm_namespace *ns)
        ldlm_namespace_debugfs_unregister(ns);
        ldlm_namespace_sysfs_unregister(ns);
        cfs_hash_putref(ns->ns_rs_hash);
-       OBD_FREE_LARGE(ns->ns_rs_buckets,
-                      BIT(ns->ns_bucket_bits) * sizeof(ns->ns_rs_buckets[0]));
+       OBD_FREE_PTR_ARRAY_LARGE(ns->ns_rs_buckets, 1 << ns->ns_bucket_bits);
        kfree(ns->ns_name);
        /* Namespace \a ns should be not on list at this time, otherwise
         * this will cause issues related to using freed \a ns in poold
@@ -1367,7 +1365,7 @@ static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type)
        struct ldlm_resource *res;
        bool rc;
 
-       res = kmem_cache_alloc(ldlm_resource_slab, GFP_NOFS);
+       OBD_SLAB_ALLOC_PTR_GFP(res, ldlm_resource_slab, GFP_NOFS);
        if (res == NULL)
                return NULL;
 
@@ -1383,21 +1381,20 @@ static struct ldlm_resource *ldlm_resource_new(enum ldlm_type ldlm_type)
                break;
        }
        if (!rc) {
-               kmem_cache_free(ldlm_resource_slab, res);
+               OBD_SLAB_FREE_PTR(res, ldlm_resource_slab);
                return NULL;
        }
 
        INIT_LIST_HEAD(&res->lr_granted);
        INIT_LIST_HEAD(&res->lr_waiting);
-       res->lr_lvb_data = NULL;
-       res->lr_lvb_inode = NULL;
-       res->lr_lvb_len = 0;
 
        atomic_set(&res->lr_refcount, 1);
+       spin_lock_init(&res->lr_lock);
        lu_ref_init(&res->lr_reference);
 
        /* Since LVB init can be delayed now, there is no longer need to
         * immediatelly acquire mutex here. */
+       mutex_init(&res->lr_lvb_mutex);
        res->lr_lvb_initialized = false;
 
        return res;
@@ -1414,7 +1411,7 @@ static void ldlm_resource_free(struct ldlm_resource *res)
                        OBD_FREE_PTR(res->lr_ibits_queues);
        }
 
-       kmem_cache_free(ldlm_resource_slab, res);
+       OBD_SLAB_FREE(res, ldlm_resource_slab, sizeof *res);
 }
 
 /**