From 673a6796f290fe8079af6a688f20c87e7416bba5 Mon Sep 17 00:00:00 2001 From: Oleg Drokin Date: Thu, 21 May 2015 15:32:09 -0400 Subject: [PATCH] staging/lustre/ptlrpc: move procfs threads* files to sysfs Move ptlrpc service threads_min, threads_max and threads_running entries from procfs to sysfs. Currently in use only by ldlm callback service only in /sys/fs/lustre/ldlm/services/ldlm_cbd/ Signed-off-by: Oleg Drokin Signed-off-by: Greg Kroah-Hartman --- .../lustre/lustre/ptlrpc/lproc_ptlrpc.c | 80 +++++++++---------- drivers/staging/lustre/sysfs-fs-lustre | 18 +++++ 2 files changed, 55 insertions(+), 43 deletions(-) diff --git a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c index 255798d2c7f4..ae1645042897 100644 --- a/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +++ b/drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c @@ -324,23 +324,23 @@ ptlrpc_lprocfs_req_history_max_seq_write(struct file *file, } LPROC_SEQ_FOPS(ptlrpc_lprocfs_req_history_max); -static int -ptlrpc_lprocfs_threads_min_seq_show(struct seq_file *m, void *n) + +static ssize_t threads_min_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); - seq_printf(m, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts); - return 0; + return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_init * svc->srv_ncpts); } -static ssize_t -ptlrpc_lprocfs_threads_min_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t threads_min_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int val; - int rc = lprocfs_write_helper(buffer, count, &val); + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + unsigned long val; + int rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -360,41 +360,41 @@ ptlrpc_lprocfs_threads_min_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_min); +LUSTRE_RW_ATTR(threads_min); -static int -ptlrpc_lprocfs_threads_started_seq_show(struct seq_file *m, void *n) +static ssize_t threads_started_show(struct kobject *kobj, + struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); struct ptlrpc_service_part *svcpt; - int total = 0; - int i; + int total = 0; + int i; ptlrpc_service_for_each_part(svcpt, i, svc) total += svcpt->scp_nthrs_running; - seq_printf(m, "%d\n", total); - return 0; + return sprintf(buf, "%d\n", total); } -LPROC_SEQ_FOPS_RO(ptlrpc_lprocfs_threads_started); +LUSTRE_RO_ATTR(threads_started); -static int -ptlrpc_lprocfs_threads_max_seq_show(struct seq_file *m, void *n) +static ssize_t threads_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) { - struct ptlrpc_service *svc = m->private; + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); - seq_printf(m, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts); - return 0; + return sprintf(buf, "%d\n", svc->srv_nthrs_cpt_limit * svc->srv_ncpts); } -static ssize_t -ptlrpc_lprocfs_threads_max_seq_write(struct file *file, - const char __user *buffer, - size_t count, loff_t *off) +static ssize_t threads_max_store(struct kobject *kobj, struct attribute *attr, + const char *buffer, size_t count) { - struct ptlrpc_service *svc = ((struct seq_file *)file->private_data)->private; - int val; - int rc = lprocfs_write_helper(buffer, count, &val); + struct ptlrpc_service *svc = container_of(kobj, struct ptlrpc_service, + srv_kobj); + unsigned long val; + int rc = kstrtoul(buffer, 10, &val); if (rc < 0) return rc; @@ -414,7 +414,7 @@ ptlrpc_lprocfs_threads_max_seq_write(struct file *file, return count; } -LPROC_SEQ_FOPS(ptlrpc_lprocfs_threads_max); +LUSTRE_RW_ATTR(threads_max); /** * \addtogoup nrs @@ -1050,6 +1050,9 @@ static ssize_t ptlrpc_lprocfs_hp_ratio_seq_write(struct file *file, LPROC_SEQ_FOPS(ptlrpc_lprocfs_hp_ratio); static struct attribute *ptlrpc_svc_attrs[] = { + &lustre_attr_threads_min.attr, + &lustre_attr_threads_started.attr, + &lustre_attr_threads_max.attr, NULL, }; @@ -1102,15 +1105,6 @@ void ptlrpc_lprocfs_register_service(struct proc_dir_entry *entry, {.name = "req_buffer_history_max", .fops = &ptlrpc_lprocfs_req_history_max_fops, .data = svc}, - {.name = "threads_min", - .fops = &ptlrpc_lprocfs_threads_min_fops, - .data = svc}, - {.name = "threads_max", - .fops = &ptlrpc_lprocfs_threads_max_fops, - .data = svc}, - {.name = "threads_started", - .fops = &ptlrpc_lprocfs_threads_started_fops, - .data = svc}, {.name = "timeouts", .fops = &ptlrpc_lprocfs_timeouts_fops, .data = svc}, diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre index 39295e84c8fd..ed09a1182399 100644 --- a/drivers/staging/lustre/sysfs-fs-lustre +++ b/drivers/staging/lustre/sysfs-fs-lustre @@ -311,3 +311,21 @@ Contact: "Oleg Drokin" Description: Controls length of time between recalculation of above values (in seconds). + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_min +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls minimum number of ldlm callback threads to start. + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_max +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Controls maximum number of ldlm callback threads to start. + +What: /sys/fs/lustre/ldlm/services/ldlm_cbd/threads_started +Date: May 2015 +Contact: "Oleg Drokin" +Description: + Shows actual number of ldlm callback threads running. -- 2.20.1