Whamcloud - gitweb
LU-14130 osc: skip 0 row for rpc_stats
[fs/lustre-release.git] / lustre / mdc / lproc_mdc.c
index cf21905..b52f241 100644 (file)
 static ssize_t active_show(struct kobject *kobj, struct attribute *attr,
                           char *buf)
 {
-       struct obd_device *dev = container_of(kobj, struct obd_device,
+       struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
+       struct obd_import *imp;
        ssize_t len;
 
-       LPROCFS_CLIMP_CHECK(dev);
-       len = sprintf(buf, "%d\n", !dev->u.cli.cl_import->imp_deactive);
-       LPROCFS_CLIMP_EXIT(dev);
+       with_imp_locked(obd, imp, len)
+               len = sprintf(buf, "%d\n", !imp->imp_deactive);
        return len;
 }
 
 static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
                            const char *buffer, size_t count)
 {
-       struct obd_device *dev = container_of(kobj, struct obd_device,
+       struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        bool val;
        int rc;
@@ -64,8 +64,8 @@ static ssize_t active_store(struct kobject *kobj, struct attribute *attr,
                return rc;
 
        /* opposite senses */
-       if (dev->u.cli.cl_import->imp_deactive == val)
-               rc = ptlrpc_set_import_active(dev->u.cli.cl_import, val);
+       if (obd->u.cli.cl_import->imp_deactive == val)
+               rc = ptlrpc_set_import_active(obd->u.cli.cl_import, val);
        else
                CDEBUG(D_CONFIG, "activate %u: ignoring repeat request\n",
                       val);
@@ -78,12 +78,12 @@ static ssize_t max_rpcs_in_flight_show(struct kobject *kobj,
                                       struct attribute *attr,
                                       char *buf)
 {
-       struct obd_device *dev = container_of(kobj, struct obd_device,
+       struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        ssize_t len;
        u32 max;
 
-       max = obd_get_max_rpcs_in_flight(&dev->u.cli);
+       max = obd_get_max_rpcs_in_flight(&obd->u.cli);
        len = sprintf(buf, "%u\n", max);
 
        return len;
@@ -94,7 +94,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
                                        const char *buffer,
                                        size_t count)
 {
-       struct obd_device *dev = container_of(kobj, struct obd_device,
+       struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        unsigned int val;
        int rc;
@@ -103,7 +103,7 @@ static ssize_t max_rpcs_in_flight_store(struct kobject *kobj,
        if (rc)
                return rc;
 
-       rc = obd_set_max_rpcs_in_flight(&dev->u.cli, val);
+       rc = obd_set_max_rpcs_in_flight(&obd->u.cli, val);
        if (rc)
                count = rc;
 
@@ -115,11 +115,11 @@ static ssize_t max_mod_rpcs_in_flight_show(struct kobject *kobj,
                                           struct attribute *attr,
                                           char *buf)
 {
-       struct obd_device *dev = container_of(kobj, struct obd_device,
+       struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        u16 max;
 
-       max = obd_get_max_mod_rpcs_in_flight(&dev->u.cli);
+       max = obd_get_max_mod_rpcs_in_flight(&obd->u.cli);
        return sprintf(buf, "%hu\n", max);
 }
 
@@ -128,7 +128,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
                                            const char *buffer,
                                            size_t count)
 {
-       struct obd_device *dev = container_of(kobj, struct obd_device,
+       struct obd_device *obd = container_of(kobj, struct obd_device,
                                              obd_kset.kobj);
        u16 val;
        int rc;
@@ -137,7 +137,7 @@ static ssize_t max_mod_rpcs_in_flight_store(struct kobject *kobj,
        if (rc)
                return rc;
 
-       rc = obd_set_max_mod_rpcs_in_flight(&dev->u.cli, val);
+       rc = obd_set_max_mod_rpcs_in_flight(&obd->u.cli, val);
        if (rc)
                count = rc;
 
@@ -147,15 +147,10 @@ LUSTRE_RW_ATTR(max_mod_rpcs_in_flight);
 
 static int mdc_max_dirty_mb_seq_show(struct seq_file *m, void *v)
 {
-       struct obd_device *dev = m->private;
-       struct client_obd *cli = &dev->u.cli;
-       unsigned long val;
+       struct obd_device *obd = m->private;
+       struct client_obd *cli = &obd->u.cli;
 
-       spin_lock(&cli->cl_loi_list_lock);
-       val = PAGES_TO_MiB(cli->cl_dirty_max_pages);
-       spin_unlock(&cli->cl_loi_list_lock);
-
-       seq_printf(m, "%lu\n", val);
+       seq_printf(m, "%lu\n", PAGES_TO_MiB(cli->cl_dirty_max_pages));
        return 0;
 }
 
@@ -164,8 +159,8 @@ static ssize_t mdc_max_dirty_mb_seq_write(struct file *file,
                                          size_t count, loff_t *off)
 {
        struct seq_file *sfl = file->private_data;
-       struct obd_device *dev = sfl->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = sfl->private;
+       struct client_obd *cli = &obd->u.cli;
        char kernbuf[22] = "";
        u64 pages_number;
        int rc;
@@ -236,8 +231,8 @@ LUSTRE_RW_ATTR(ping);
 
 static int mdc_cached_mb_seq_show(struct seq_file *m, void *v)
 {
-       struct obd_device *dev = m->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = m->private;
+       struct client_obd *cli = &obd->u.cli;
        int shift = 20 - PAGE_SHIFT;
 
        seq_printf(m, "used_mb: %ld\n"
@@ -257,8 +252,8 @@ mdc_cached_mb_seq_write(struct file *file, const char __user *buffer,
                        size_t count, loff_t *off)
 {
        struct seq_file *sfl = file->private_data;
-       struct obd_device *dev = sfl->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = sfl->private;
+       struct client_obd *cli = &obd->u.cli;
        u64 pages_number;
        const char *tmp;
        long rc;
@@ -296,8 +291,8 @@ LPROC_SEQ_FOPS(mdc_cached_mb);
 
 static int mdc_unstable_stats_seq_show(struct seq_file *m, void *v)
 {
-       struct obd_device *dev = m->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = m->private;
+       struct client_obd *cli = &obd->u.cli;
        long pages;
        int mb;
 
@@ -315,8 +310,8 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file,
                                       size_t len, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
-       struct obd_device *dev = seq->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = seq->private;
+       struct client_obd *cli = &obd->u.cli;
 
        lprocfs_oh_clear(&cli->cl_mod_rpcs_hist);
 
@@ -332,12 +327,12 @@ static ssize_t mdc_rpc_stats_seq_write(struct file *file,
 
 static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 {
-       struct obd_device *dev = seq->private;
-       struct client_obd *cli = &dev->u.cli;
+       struct obd_device *obd = seq->private;
+       struct client_obd *cli = &obd->u.cli;
        unsigned long read_tot = 0, write_tot = 0, read_cum, write_cum;
        int i;
 
-       obd_mod_rpc_stats_seq_show(&dev->u.cli, seq);
+       obd_mod_rpc_stats_seq_show(cli, seq);
 
        spin_lock(&cli->cl_loi_list_lock);
 
@@ -383,7 +378,7 @@ static int mdc_rpc_stats_seq_show(struct seq_file *seq, void *v)
 
        read_cum = 0;
        write_cum = 0;
-       for (i = 0; i < OBD_HIST_MAX; i++) {
+       for (i = 1; i < OBD_HIST_MAX; i++) {
                unsigned long r = cli->cl_read_rpc_hist.oh_buckets[i];
                unsigned long w = cli->cl_write_rpc_hist.oh_buckets[i];
 
@@ -427,8 +422,8 @@ LPROC_SEQ_FOPS(mdc_rpc_stats);
 static int mdc_stats_seq_show(struct seq_file *seq, void *v)
 {
        struct timespec64 now;
-       struct obd_device *dev = seq->private;
-       struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
+       struct obd_device *obd = seq->private;
+       struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
 
        ktime_get_real_ts64(&now);
 
@@ -448,8 +443,8 @@ static ssize_t mdc_stats_seq_write(struct file *file,
                                   size_t len, loff_t *off)
 {
        struct seq_file *seq = file->private_data;
-       struct obd_device *dev = seq->private;
-       struct osc_stats *stats = &obd2osc_dev(dev)->od_stats;
+       struct obd_device *obd = seq->private;
+       struct osc_stats *stats = &obd2osc_dev(obd)->od_stats;
 
        memset(stats, 0, sizeof(*stats));
        return len;
@@ -458,9 +453,9 @@ LPROC_SEQ_FOPS(mdc_stats);
 
 static int mdc_dom_min_repsize_seq_show(struct seq_file *m, void *v)
 {
-       struct obd_device *dev = m->private;
+       struct obd_device *obd = m->private;
 
-       seq_printf(m, "%u\n", dev->u.cli.cl_dom_min_inline_repsize);
+       seq_printf(m, "%u\n", obd->u.cli.cl_dom_min_inline_repsize);
 
        return 0;
 }
@@ -470,7 +465,7 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file,
                                             size_t count, loff_t *off)
 {
        struct seq_file *m = file->private_data;
-       struct obd_device *dev = m->private;
+       struct obd_device *obd = m->private;
        unsigned int val;
        int rc;
 
@@ -481,7 +476,7 @@ static ssize_t mdc_dom_min_repsize_seq_write(struct file *file,
        if (val > MDC_DOM_MAX_INLINE_REPSIZE)
                return -ERANGE;
 
-       dev->u.cli.cl_dom_min_inline_repsize = val;
+       obd->u.cli.cl_dom_min_inline_repsize = val;
        return count;
 }
 LPROC_SEQ_FOPS(mdc_dom_min_repsize);