Whamcloud - gitweb
LU-8066 osc: fix idle_timeout handling 19/32719/4
authorJames Simmons <uja.ornl@yahoo.com>
Thu, 14 Jun 2018 16:53:29 +0000 (12:53 -0400)
committerOleg Drokin <green@whamcloud.com>
Wed, 18 Jul 2018 06:00:57 +0000 (06:00 +0000)
The patch that landed for LU-7236 introduced new sysfs entries
which were done wrong.

1) For idle_timeout it returns -ERANGE for
   any value passed in expect setting idle_timeout to zero. This
   does not match what the commit message said for LU-7236. So
   I changed lprocfs_str_with_units_to_s64() into kstrtouint()
   since a signed 64 bit timeout is not needed. Using kstrtouint()
   ensures that negative values are not possible and also cap the
   value to CONNECTION_SWITCH_MAX since the max of 4 billion
   seconds is over kill.

2) For the next procfs idle_connect it is really a write only file
   but it was treated as both read and write. There is no need for
   the osc_idle_connect_seq_show() function.

3) Lastly no more stuffing new entries into proc or debugfs. For
   this patch convert these new proc entries to sysfs. It seems
   to be a common occurrence so add LPROC_SEQ_* to spelling.txt
   so checkpatch will complain about using LPROC_SEQ_* which will
   go away.

Change-Id: I1c992b2db47aade6a887919824d869e8d5354c71
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/32719
Reviewed-by: Alex Zhuravlev <bzzz@whamcloud.com>
Reviewed-by: John L. Hammond <jhammond@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
contrib/scripts/spelling.txt
lustre/osc/lproc_osc.c

index 9061f01..4dfc385 100644 (file)
@@ -128,6 +128,11 @@ LPLD||%ld
 LPLX||%#lx
 LPPID||%d
 LPROCFS||CONFIG_PROC_FS
+LPROC_SEQ_FOPS_WR_ONLY||LUSTRE_WO_ATTR
+LPROC_SEQ_FOPS_RO_TYPE||LUSTRE_RO_ATTR
+LPROC_SEQ_FOPS_RO||LUSTRE_RO_ATTR
+LPROC_SEQ_FOPS_RW_TYPE||LUSTRE_RW_ATTR
+LPROC_SEQ_FOPS||LUSTRE_RW_ATTR
 lprocfs_str_to_s64||kstrtoxxx_from_user
 mktemp||mkstemp
 sprintf||snprintf
index 3c0e138..5c012e4 100644 (file)
@@ -608,29 +608,31 @@ static int osc_unstable_stats_seq_show(struct seq_file *m, void *v)
 }
 LPROC_SEQ_FOPS_RO(osc_unstable_stats);
 
-static int osc_idle_timeout_seq_show(struct seq_file *m, void *v)
+static ssize_t idle_timeout_show(struct kobject *kobj, struct attribute *attr,
+                                char *buf)
 {
-       struct obd_device *obd = m->private;
+       struct obd_device *obd = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct client_obd *cli = &obd->u.cli;
 
-       seq_printf(m, "%u\n", cli->cl_import->imp_idle_timeout);
-       return 0;
+       return sprintf(buf, "%u\n", cli->cl_import->imp_idle_timeout);
 }
 
-static ssize_t osc_idle_timeout_seq_write(struct file *f,
-                                         const char __user *buffer,
-                                         size_t count, loff_t *off)
+static ssize_t idle_timeout_store(struct kobject *kobj, struct attribute *attr,
+                                 const char *buffer, size_t count)
 {
-       struct obd_device *dev = ((struct seq_file *)f->private_data)->private;
+       struct obd_device *dev = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct client_obd *cli = &dev->u.cli;
        struct ptlrpc_request *req;
-       __s64 val;
+       unsigned int val;
        int rc;
 
-       rc = lprocfs_str_with_units_to_s64(buffer, count, &val, '1');
+       rc = kstrtouint(buffer, 10, &val);
        if (rc)
                return rc;
-       if (val < 0 || val > 1)
+
+       if (val > CONNECTION_SWITCH_MAX)
                return -ERANGE;
 
        cli->cl_import->imp_idle_timeout = val;
@@ -644,30 +646,25 @@ static ssize_t osc_idle_timeout_seq_write(struct file *f,
 
        return count;
 }
-LPROC_SEQ_FOPS(osc_idle_timeout);
-
-static int osc_idle_connect_seq_show(struct seq_file *m, void *v)
-{
-       return 0;
-}
+LUSTRE_RW_ATTR(idle_timeout);
 
-static ssize_t osc_idle_connect_seq_write(struct file *f,
-                                         const char __user *buffer,
-                                         size_t count, loff_t *off)
+static ssize_t idle_connect_store(struct kobject *kobj, struct attribute *attr,
+                                 const char *buffer, size_t count)
 {
-       struct obd_device *dev = ((struct seq_file *)f->private_data)->private;
+       struct obd_device *dev = container_of(kobj, struct obd_device,
+                                             obd_kset.kobj);
        struct client_obd *cli = &dev->u.cli;
        struct ptlrpc_request *req;
 
        /* to initiate the connection if it's in IDLE state */
        req = ptlrpc_request_alloc(cli->cl_import, &RQF_OST_STATFS);
-       if (req != NULL)
+       if (req)
                ptlrpc_req_finished(req);
        ptlrpc_pinger_force(cli->cl_import);
 
        return count;
 }
-LPROC_SEQ_FOPS(osc_idle_connect);
+LUSTRE_WO_ATTR(idle_connect);
 
 LPROC_SEQ_FOPS_RO_TYPE(osc, connect_flags);
 LPROC_SEQ_FOPS_RO_TYPE(osc, server_uuid);
@@ -700,10 +697,6 @@ struct lprocfs_vars lprocfs_osc_obd_vars[] = {
          .fops =       &osc_pinger_recov_fops          },
        { .name =       "unstable_stats",
          .fops =       &osc_unstable_stats_fops        },
-       { .name =       "idle_timeout",
-         .fops =       &osc_idle_timeout_fops          },
-       { .name =       "idle_connect",
-         .fops =       &osc_idle_connect_fops          },
        { NULL }
 };
 
@@ -889,6 +882,8 @@ static struct attribute *osc_attrs[] = {
        &lustre_attr_resend_count.attr,
        &lustre_attr_conn_uuid.attr,
        &lustre_attr_ping.attr,
+       &lustre_attr_idle_timeout.attr,
+       &lustre_attr_idle_connect.attr,
        NULL,
 };