Whamcloud - gitweb
LU-11518 ldlm: control lru_size for extent lock
[fs/lustre-release.git] / lustre / ldlm / ldlm_resource.c
index a805e3f..e262e7f 100644 (file)
@@ -372,6 +372,32 @@ static ssize_t lru_size_store(struct kobject *kobj, struct attribute *attr,
 }
 LUSTRE_RW_ATTR(lru_size);
 
+static ssize_t lru_cancel_batch_show(struct kobject *kobj,
+                                struct attribute *attr, char *buf)
+{
+       struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+                                                ns_kobj);
+
+       return snprintf(buf, sizeof(buf) - 1, "%u\n", ns->ns_cancel_batch);
+}
+
+static ssize_t lru_cancel_batch_store(struct kobject *kobj,
+                                 struct attribute *attr,
+                                 const char *buffer, size_t count)
+{
+       struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
+                                                ns_kobj);
+       unsigned long tmp;
+
+       if (kstrtoul(buffer, 10, &tmp))
+               return -EINVAL;
+
+       ns->ns_cancel_batch = (unsigned int)tmp;
+
+       return count;
+}
+LUSTRE_RW_ATTR(lru_cancel_batch);
+
 static ssize_t lru_max_age_show(struct kobject *kobj, struct attribute *attr,
                                char *buf)
 {
@@ -624,6 +650,7 @@ static struct attribute *ldlm_ns_attrs[] = {
        &lustre_attr_lock_count.attr,
        &lustre_attr_lock_unused_count.attr,
        &lustre_attr_lru_size.attr,
+       &lustre_attr_lru_cancel_batch.attr,
        &lustre_attr_lru_max_age.attr,
        &lustre_attr_early_lock_cancel.attr,
        &lustre_attr_dirty_age_limit.attr,
@@ -904,6 +931,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_cancel_batch       = LDLM_DEFAULT_LRU_SHRINK_BATCH;
        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    = ktime_set(LDLM_DIRTY_AGE_LIMIT, 0);
@@ -913,6 +941,7 @@ struct ldlm_namespace *ldlm_namespace_new(struct obd_device *obd, char *name,
        ns->ns_stopping           = 0;
        ns->ns_reclaim_start      = 0;
        ns->ns_last_pos           = &ns->ns_unused_list;
+       ns->ns_flags              = 0;
 
        rc = ldlm_namespace_sysfs_register(ns);
        if (rc) {