Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755380AbbGFQts (ORCPT ); Mon, 6 Jul 2015 12:49:48 -0400 Received: from linuxhacker.ru ([217.76.32.60]:53291 "EHLO fiona.linuxhacker.ru" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1755006AbbGFQtm (ORCPT ); Mon, 6 Jul 2015 12:49:42 -0400 From: green@linuxhacker.ru To: Greg Kroah-Hartman , devel@driverdev.osuosl.org, Andreas Dilger Cc: Linux Kernel Mailing List , Dmitry Eremin , Oleg Drokin Subject: [PATCH 19/20] staging/lustre/libcfs: get rid of debugfs/lnet/console_{min,max}_delay_centisecs Date: Mon, 6 Jul 2015 12:48:57 -0400 Message-Id: <1436201338-14263-20-git-send-email-green@linuxhacker.ru> X-Mailer: git-send-email 2.1.0 In-Reply-To: <1436201338-14263-1-git-send-email-green@linuxhacker.ru> References: <1436201338-14263-1-git-send-email-green@linuxhacker.ru> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 6568 Lines: 215 From: Dmitry Eremin They are just fancy module parameters wrappers, so just the same functionality now would be accessible via /sys/module/libcfs/parameters/libcfs_console_{min,max}_delay Also install compatibility symlinks Signed-off-by: Dmitry Eremin Signed-off-by: Oleg Drokin --- drivers/staging/lustre/lustre/libcfs/debug.c | 69 ++++++++++++++++++++-- drivers/staging/lustre/lustre/libcfs/module.c | 82 ++------------------------- 2 files changed, 68 insertions(+), 83 deletions(-) diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c index e4c7129..07a8f5b 100644 --- a/drivers/staging/lustre/lustre/libcfs/debug.c +++ b/drivers/staging/lustre/lustre/libcfs/debug.c @@ -103,16 +103,75 @@ module_param(libcfs_console_ratelimit, uint, 0644); MODULE_PARM_DESC(libcfs_console_ratelimit, "Lustre kernel debug console ratelimit (0 to disable)"); EXPORT_SYMBOL(libcfs_console_ratelimit); +static int param_set_delay_minmax(const char *val, + const struct kernel_param *kp, + long min, long max) +{ + long d; + int sec; + int rc; + + rc = kstrtoint(val, 0, &sec); + if (rc) + return -EINVAL; + + d = cfs_time_seconds(sec) / 100; + if (d < min || d > max) + return -EINVAL; + + *((unsigned int *)kp->arg) = d; + + return 0; +} + +static int param_get_delay(char *buffer, const struct kernel_param *kp) +{ + unsigned int d = *(unsigned int *)kp->arg; + + return sprintf(buffer, "%u", (unsigned int)cfs_duration_sec(d * 100)); +} + unsigned int libcfs_console_max_delay; -module_param(libcfs_console_max_delay, uint, 0644); -MODULE_PARM_DESC(libcfs_console_max_delay, "Lustre kernel debug console max delay (jiffies)"); EXPORT_SYMBOL(libcfs_console_max_delay); - unsigned int libcfs_console_min_delay; -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_console_max_delay(const char *val, + const struct kernel_param *kp) +{ + return param_set_delay_minmax(val, kp, + libcfs_console_min_delay, INT_MAX); +} + +static struct kernel_param_ops param_ops_console_max_delay = { + .set = param_set_console_max_delay, + .get = param_get_delay, +}; + +#define param_check_console_max_delay(name, p) \ + __param_check(name, p, unsigned int) + +module_param(libcfs_console_max_delay, console_max_delay, 0644); +MODULE_PARM_DESC(libcfs_console_max_delay, "Lustre kernel debug console max delay (jiffies)"); + +static int param_set_console_min_delay(const char *val, + const struct kernel_param *kp) +{ + return param_set_delay_minmax(val, kp, + 1, libcfs_console_max_delay); +} + +static struct kernel_param_ops param_ops_console_min_delay = { + .set = param_set_console_min_delay, + .get = param_get_delay, +}; + +#define param_check_console_min_delay(name, p) \ + __param_check(name, p, unsigned int) + +module_param(libcfs_console_min_delay, console_min_delay, 0644); +MODULE_PARM_DESC(libcfs_console_min_delay, "Lustre kernel debug console min delay (jiffies)"); + static int param_set_uint_minmax(const char *val, const struct kernel_param *kp, unsigned int min, unsigned int max) diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c index acfe778..0ed2658 100644 --- a/drivers/staging/lustre/lustre/libcfs/module.c +++ b/drivers/staging/lustre/lustre/libcfs/module.c @@ -550,72 +550,6 @@ static int proc_daemon_file(struct ctl_table *table, int write, __proc_daemon_file); } -static int proc_console_max_delay_cs(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, - loff_t *ppos) -{ - int rc, max_delay_cs; - struct ctl_table dummy = *table; - long d; - - dummy.data = &max_delay_cs; - dummy.proc_handler = &proc_dointvec; - - if (!write) { /* read */ - max_delay_cs = cfs_duration_sec(libcfs_console_max_delay * 100); - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - return rc; - } - - /* write */ - max_delay_cs = 0; - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - if (rc < 0) - return rc; - if (max_delay_cs <= 0) - return -EINVAL; - - d = cfs_time_seconds(max_delay_cs) / 100; - if (d == 0 || d < libcfs_console_min_delay) - return -EINVAL; - libcfs_console_max_delay = d; - - return rc; -} - -static int proc_console_min_delay_cs(struct ctl_table *table, int write, - void __user *buffer, size_t *lenp, - loff_t *ppos) -{ - int rc, min_delay_cs; - struct ctl_table dummy = *table; - long d; - - dummy.data = &min_delay_cs; - dummy.proc_handler = &proc_dointvec; - - if (!write) { /* read */ - min_delay_cs = cfs_duration_sec(libcfs_console_min_delay * 100); - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - return rc; - } - - /* write */ - min_delay_cs = 0; - rc = proc_dointvec(&dummy, write, buffer, lenp, ppos); - if (rc < 0) - return rc; - if (min_delay_cs <= 0) - return -EINVAL; - - d = cfs_time_seconds(min_delay_cs) / 100; - if (d == 0 || d > libcfs_console_max_delay) - return -EINVAL; - libcfs_console_min_delay = d; - - return rc; -} - static int libcfs_force_lbug(struct ctl_table *table, int write, void __user *buffer, size_t *lenp, loff_t *ppos) @@ -713,18 +647,6 @@ static struct ctl_table lnet_table[] = { .proc_handler = &proc_dobitmasks, }, { - .procname = "console_max_delay_centisecs", - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_console_max_delay_cs - }, - { - .procname = "console_min_delay_centisecs", - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_console_min_delay_cs - }, - { .procname = "cpu_partition_table", .maxlen = 128, .mode = 0444, @@ -805,6 +727,10 @@ struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = { "/sys/module/libcfs/parameters/libcfs_console_backoff"}, { "debug_mb", "/sys/module/libcfs/parameters/libcfs_debug_mb"}, + { "console_min_delay_centisecs", + "/sys/module/libcfs/parameters/libcfs_console_min_delay"}, + { "console_max_delay_centisecs", + "/sys/module/libcfs/parameters/libcfs_console_max_delay"}, {}, }; -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/