staging/lustre/obdclass: move sysctl timeout to sysfs
authorOleg Drokin <green@linuxhacker.ru>
Mon, 6 Jul 2015 16:48:46 +0000 (12:48 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:47:20 +0000 (19:47 -0700)
This is the first step of moving lustre sysctls from
/proc/sys/lustre to /sys/fs/lustre

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/include/obd_class.h
drivers/staging/lustre/lustre/obdclass/class_obd.c
drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
drivers/staging/lustre/sysfs-fs-lustre

index 36ed78127830b001d574baad59f9da04e5d12b28..7dce4eea85750a68ac8263dc1ac222a12fc7ba7b 100644 (file)
@@ -1869,8 +1869,8 @@ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 /* obd_mount.c */
 
 /* sysctl.c */
-extern void obd_sysctl_init (void);
-extern void obd_sysctl_clean (void);
+extern int obd_sysctl_init(void);
+extern void obd_sysctl_clean(void);
 
 /* uuid.c  */
 typedef __u8 class_uuid_t[16];
index 34b16c044df8f79857d3b853765ece46510f4aa2..2e42d1a637f1704a145823f827a5c71f5ccaa353 100644 (file)
@@ -567,12 +567,14 @@ static int __init init_obdclass(void)
        if (err)
                return err;
 
-       obd_sysctl_init();
-
        err = class_procfs_init();
        if (err)
                return err;
 
+       err = obd_sysctl_init();
+       if (err)
+               return err;
+
        err = lu_global_init();
        if (err)
                return err;
index eda5f30e8f30c9b7bc2dcc5a51784b879c6302ea..3c8087b5cf4b87aa1fa437a4df6912fcc6170b79 100644 (file)
 static struct ctl_table_header *obd_table_header;
 #endif
 
-#ifdef CONFIG_SYSCTL
-static int proc_set_timeout(struct ctl_table *table, int write,
-                       void __user *buffer, size_t *lenp, loff_t *ppos)
+struct static_lustre_uintvalue_attr {
+       struct {
+               struct attribute attr;
+               ssize_t (*show)(struct kobject *kobj, struct attribute *attr,
+                               char *buf);
+               ssize_t (*store)(struct kobject *kobj, struct attribute *attr,
+                                const char *buf, size_t len);
+       } u;
+       int *value;
+};
+
+static ssize_t static_uintvalue_show(struct kobject *kobj,
+                                   struct attribute *attr,
+                                   char *buf)
 {
+       struct static_lustre_uintvalue_attr *lattr = (void *)attr;
+
+       return sprintf(buf, "%d\n", *lattr->value);
+}
+
+static ssize_t static_uintvalue_store(struct kobject *kobj,
+                                    struct attribute *attr,
+                                    const char *buffer, size_t count)
+{
+       struct static_lustre_uintvalue_attr *lattr  = (void *)attr;
        int rc;
+       unsigned int val;
 
-       rc = proc_dointvec(table, write, buffer, lenp, ppos);
-       return rc;
+       rc = kstrtouint(buffer, 10, &val);
+       if (rc)
+               return rc;
+
+       *lattr->value = val;
+
+       return count;
 }
 
+#define LUSTRE_STATIC_UINT_ATTR(name, value) \
+static struct static_lustre_uintvalue_attr lustre_sattr_##name =       \
+                                       {__ATTR(name, 0644,             \
+                                               static_uintvalue_show,  \
+                                               static_uintvalue_store),\
+                                         value }
+
+LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout);
+
+#ifdef CONFIG_SYSCTL
 static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
                               void __user *buffer, size_t *lenp, loff_t *ppos)
 {
@@ -106,13 +143,6 @@ static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
 }
 
 static struct ctl_table obd_table[] = {
-       {
-               .procname = "timeout",
-               .data     = &obd_timeout,
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_set_timeout
-       },
        {
                .procname = "debug_peer_on_timeout",
                .data     = &obd_debug_peer_on_timeout,
@@ -191,12 +221,22 @@ static struct ctl_table parent_table[] = {
 };
 #endif
 
-void obd_sysctl_init(void)
+static struct attribute *lustre_attrs[] = {
+       &lustre_sattr_timeout.u.attr,
+       NULL,
+};
+
+static struct attribute_group lustre_attr_group = {
+       .attrs = lustre_attrs,
+};
+
+int obd_sysctl_init(void)
 {
 #ifdef CONFIG_SYSCTL
        if (!obd_table_header)
                obd_table_header = register_sysctl_table(parent_table);
 #endif
+       return sysfs_create_group(lustre_kobj, &lustre_attr_group);
 }
 
 void obd_sysctl_clean(void)
index 1e302e8516ce55ed57a7900d0ba2f2275ffe4d70..6dbad260fa7d78e14a292a015101aec54e0ba35d 100644 (file)
@@ -40,6 +40,18 @@ Description:
                               e.g. dd.1253
                nodelocal - use jobid_name value from above.
 
+What:          /sys/fs/lustre/timeout
+Date:          June 2015
+Contact:       "Oleg Drokin" <oleg.drokin@intel.com>
+Description:
+               Controls "lustre timeout" variable, also known as obd_timeout
+               in some old manual. In the past obd_timeout was of paramount
+               importance as the timeout value used everywhere and where
+               other timeouts were derived from. These days it's much less
+               important as network timeouts are mostly determined by
+               AT (adaptive timeouts).
+               Unit: seconds, default: 100
+
 What:          /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
 Date:          May 2015
 Contact:       "Oleg Drokin" <oleg.drokin@intel.com>