staging/lustre/libcfs: get rid of debugfs/lnet/console_backoff
authorOleg Drokin <green@linuxhacker.ru>
Mon, 6 Jul 2015 16:48:53 +0000 (12:48 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Tue, 14 Jul 2015 02:47:20 +0000 (19:47 -0700)
module parameter libcfs_console_backoff accessible through
/sys/module/libcfs/parameters/libcfs_console_backoff would
do the same thing, just add a special "uintpos" parameter
type to disallow 0 values too.
Also add a symlink to the module parameter variable for
backwards compatibility

Signed-off-by: Oleg Drokin <green@linuxhacker.ru>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/libcfs/debug.c
drivers/staging/lustre/lustre/libcfs/module.c

index 021c92fa0333f2cd92c91b10762fcbceac7ed723..147004cef3914fa0a21bb3437a235bb62941afc7 100644 (file)
@@ -82,8 +82,37 @@ module_param(libcfs_console_min_delay, uint, 0644);
 MODULE_PARM_DESC(libcfs_console_min_delay, "Lustre kernel debug console min delay (jiffies)");
 EXPORT_SYMBOL(libcfs_console_min_delay);
 
+static int param_set_uint_minmax(const char *val,
+                                const struct kernel_param *kp,
+                                unsigned int min, unsigned int max)
+{
+       unsigned int num;
+       int ret;
+
+       if (!val)
+               return -EINVAL;
+       ret = kstrtouint(val, 0, &num);
+       if (ret == -EINVAL || num < min || num > max)
+               return -EINVAL;
+       *((unsigned int *)kp->arg) = num;
+       return 0;
+}
+
+static int param_set_uintpos(const char *val, const struct kernel_param *kp)
+{
+       return param_set_uint_minmax(val, kp, 1, -1);
+}
+
+static struct kernel_param_ops param_ops_uintpos = {
+       .set = param_set_uintpos,
+       .get = param_get_uint,
+};
+
+#define param_check_uintpos(name, p) \
+               __param_check(name, p, unsigned int)
+
 unsigned int libcfs_console_backoff = CDEBUG_DEFAULT_BACKOFF;
-module_param(libcfs_console_backoff, uint, 0644);
+module_param(libcfs_console_backoff, uintpos, 0644);
 MODULE_PARM_DESC(libcfs_console_backoff, "Lustre kernel debug console backoff factor");
 EXPORT_SYMBOL(libcfs_console_backoff);
 
index 8a2644600d3eb550e02efd66ece8b1d7d111a15c..8b9ce223fc6fd6cb1c8f8eae0a9d8671ede20475 100644 (file)
@@ -678,34 +678,6 @@ static int proc_console_min_delay_cs(struct ctl_table *table, int write,
        return rc;
 }
 
-static int proc_console_backoff(struct ctl_table *table, int write,
-                               void __user *buffer, size_t *lenp, loff_t *ppos)
-{
-       int rc, backoff;
-       struct ctl_table dummy = *table;
-
-       dummy.data = &backoff;
-       dummy.proc_handler = &proc_dointvec;
-
-       if (!write) { /* read */
-               backoff = libcfs_console_backoff;
-               rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-               return rc;
-       }
-
-       /* write */
-       backoff = 0;
-       rc = proc_dointvec(&dummy, write, buffer, lenp, ppos);
-       if (rc < 0)
-               return rc;
-       if (backoff <= 0)
-               return -EINVAL;
-
-       libcfs_console_backoff = backoff;
-
-       return rc;
-}
-
 static int libcfs_force_lbug(struct ctl_table *table, int write,
                             void __user *buffer,
                             size_t *lenp, loff_t *ppos)
@@ -814,13 +786,6 @@ static struct ctl_table lnet_table[] = {
                .mode     = 0644,
                .proc_handler = &proc_console_min_delay_cs
        },
-       {
-               .procname = "console_backoff",
-               .maxlen   = sizeof(int),
-               .mode     = 0644,
-               .proc_handler = &proc_console_backoff
-       },
-
        {
                .procname = "cpu_partition_table",
                .maxlen   = 128,
@@ -907,6 +872,23 @@ static struct ctl_table lnet_table[] = {
        }
 };
 
+struct lnet_debugfs_symlink_def {
+       char *name;
+       char *target;
+};
+
+struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
+       { "console_ratelimit",
+         "/sys/module/libcfs/parameters/libcfs_console_ratelimit"},
+       { "debug_path",
+         "/sys/module/libcfs/parameters/libcfs_debug_file_path"},
+       { "panic_on_lbug",
+         "/sys/module/libcfs/parameters/libcfs_panic_on_lbug"},
+       { "libcfs_console_backoff",
+         "/sys/module/libcfs/parameters/libcfs_console_backoff"},
+       {},
+};
+
 static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
                                 size_t count, loff_t *ppos)
 {
@@ -944,6 +926,7 @@ static void insert_debugfs(void)
 {
        struct ctl_table *table;
        struct dentry *entry;
+       struct lnet_debugfs_symlink_def *symlinks;
 
        if (lnet_debugfs_root == NULL)
                lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
@@ -956,6 +939,12 @@ static void insert_debugfs(void)
                entry = debugfs_create_file(table->procname, table->mode,
                                            lnet_debugfs_root, table,
                                            &lnet_debugfs_file_operations);
+
+       for (symlinks = lnet_debugfs_symlinks; symlinks->name; symlinks++)
+               entry = debugfs_create_symlink(symlinks->name,
+                                              lnet_debugfs_root,
+                                              symlinks->target);
+
 }
 
 static void remove_debugfs(void)