提交 63af1f57 编写于 作者: O Oleg Drokin 提交者: Greg Kroah-Hartman

staging/lustre/ldlm: move namespace/lock_count to sysfs

Move ldlm display of lock_count from procfs to sysfs
Signed-off-by: NOleg Drokin <green@linuxhacker.ru>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 61d4a2e4
...@@ -166,16 +166,18 @@ static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr, ...@@ -166,16 +166,18 @@ static ssize_t resource_count_show(struct kobject *kobj, struct attribute *attr,
} }
LUSTRE_RO_ATTR(resource_count); LUSTRE_RO_ATTR(resource_count);
static int lprocfs_ns_locks_seq_show(struct seq_file *m, void *v) static ssize_t lock_count_show(struct kobject *kobj, struct attribute *attr,
char *buf)
{ {
struct ldlm_namespace *ns = m->private; struct ldlm_namespace *ns = container_of(kobj, struct ldlm_namespace,
ns_kobj);
__u64 locks; __u64 locks;
locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS, locks = lprocfs_stats_collector(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_FIELDS_FLAGS_SUM); LPROCFS_FIELDS_FLAGS_SUM);
return lprocfs_rd_u64(m, &locks); return sprintf(buf, "%lld\n", locks);
} }
LPROC_SEQ_FOPS_RO(lprocfs_ns_locks); LUSTRE_RO_ATTR(lock_count);
static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v) static int lprocfs_lru_size_seq_show(struct seq_file *m, void *v)
{ {
...@@ -308,6 +310,7 @@ LPROC_SEQ_FOPS(lprocfs_elc); ...@@ -308,6 +310,7 @@ LPROC_SEQ_FOPS(lprocfs_elc);
/* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */ /* These are for namespaces in /sys/fs/lustre/ldlm/namespaces/ */
static struct attribute *ldlm_ns_attrs[] = { static struct attribute *ldlm_ns_attrs[] = {
&lustre_attr_resource_count.attr, &lustre_attr_resource_count.attr,
&lustre_attr_lock_count.attr,
NULL, NULL,
}; };
...@@ -360,6 +363,15 @@ int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns) ...@@ -360,6 +363,15 @@ int ldlm_namespace_sysfs_register(struct ldlm_namespace *ns)
err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL, err = kobject_init_and_add(&ns->ns_kobj, &ldlm_ns_ktype, NULL,
"%s", ldlm_ns_name(ns)); "%s", ldlm_ns_name(ns));
ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
if (ns->ns_stats == NULL) {
kobject_put(&ns->ns_kobj);
return -ENOMEM;
}
lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_CNTR_AVGMINMAX, "locks", "locks");
return err; return err;
} }
...@@ -381,20 +393,11 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns) ...@@ -381,20 +393,11 @@ int ldlm_namespace_proc_register(struct ldlm_namespace *ns)
ns->ns_proc_dir_entry = ns_pde; ns->ns_proc_dir_entry = ns_pde;
} }
ns->ns_stats = lprocfs_alloc_stats(LDLM_NSS_LAST, 0);
if (ns->ns_stats == NULL)
return -ENOMEM;
lprocfs_counter_init(ns->ns_stats, LDLM_NSS_LOCKS,
LPROCFS_CNTR_AVGMINMAX, "locks", "locks");
lock_name[MAX_STRING_SIZE] = '\0'; lock_name[MAX_STRING_SIZE] = '\0';
memset(lock_vars, 0, sizeof(lock_vars)); memset(lock_vars, 0, sizeof(lock_vars));
lock_vars[0].name = lock_name; lock_vars[0].name = lock_name;
LDLM_NS_ADD_VAR("lock_count", ns, &lprocfs_ns_locks_fops);
if (ns_is_client(ns)) { if (ns_is_client(ns)) {
LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused, LDLM_NS_ADD_VAR("lock_unused_count", &ns->ns_nr_unused,
&ldlm_uint_fops); &ldlm_uint_fops);
......
...@@ -207,3 +207,9 @@ Contact: "Oleg Drokin" <oleg.drokin@intel.com> ...@@ -207,3 +207,9 @@ Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description: Description:
Displays number of lock resources (objects on which individual Displays number of lock resources (objects on which individual
locks are taken) currently allocated in this namespace. locks are taken) currently allocated in this namespace.
What: /sys/fs/lustre/ldlm/namespaces/<name>/lock_count
Date: May 2015
Contact: "Oleg Drokin" <oleg.drokin@intel.com>
Description:
Displays number or locks allocated in this namespace.
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册