]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
staging/lustre/ptlrpc: move procfs threads* files to sysfs
authorOleg Drokin <green@linuxhacker.ru>
Thu, 21 May 2015 19:32:09 +0000 (15:32 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 31 May 2015 02:13:20 +0000 (11:13 +0900)
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 <oleg.drokin@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c
drivers/staging/lustre/sysfs-fs-lustre

index 255798d2c7f467c0b77a5b7bab980e0c3fc4e747..ae16450428975fda08279028d1c1c9dddba83566 100644 (file)
@@ -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},
index 39295e84c8fdbf80174767367ad917fc7fecb83d..ed09a1182399f07e02b8220fa6dddc4e2af8e9b9 100644 (file)
@@ -311,3 +311,21 @@ Contact:   "Oleg Drokin" <oleg.drokin@intel.com>
 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" <oleg.drokin@intel.com>
+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" <oleg.drokin@intel.com>
+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" <oleg.drokin@intel.com>
+Description:
+               Shows actual number of ldlm callback threads running.