From abe676530d3d04887b251c97ba21be8ae063b5e6 Mon Sep 17 00:00:00 2001 From: James Simmons Date: Sun, 1 Jan 2017 14:42:27 -0500 Subject: [PATCH] LU-8066 obdclass: move lustre server sysctl to sysfs A few of the lustre sysctl are server side so lets move those as well to sysfs. Both memused ane memused_max are missing upstream but we need to keep them around for now. Signed-off-by: James Simmons Change-Id: Ie2fd2408d79aede4e40272a86f63f1e55311d1b9 Reviewed-on: https://review.whamcloud.com/24033 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: Dmitry Eremin Reviewed-by: Niu Yawei Reviewed-by: Oleg Drokin --- lustre/obdclass/linux/linux-sysctl.c | 94 +++++++----------------------------- 1 file changed, 18 insertions(+), 76 deletions(-) diff --git a/lustre/obdclass/linux/linux-sysctl.c b/lustre/obdclass/linux/linux-sysctl.c index c066b0c..7307dfe 100644 --- a/lustre/obdclass/linux/linux-sysctl.c +++ b/lustre/obdclass/linux/linux-sysctl.c @@ -100,58 +100,6 @@ static struct static_lustre_uintvalue_attr lustre_sattr_##name = \ LUSTRE_STATIC_UINT_ATTR(timeout, &obd_timeout); -#ifdef CONFIG_SYSCTL -static int -proc_memory_alloc(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - char buf[22]; - int len; - - if (!*lenp || (*ppos && !write)) { - *lenp = 0; - return 0; - } - if (write) - return -EINVAL; - - len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_sum()); - if (len > *lenp) - len = *lenp; - buf[len] = '\0'; - if (copy_to_user(buffer, buf, len)) - return -EFAULT; - *lenp = len; - *ppos += *lenp; - return 0; -} - -static int -proc_mem_max(struct ctl_table *table, int write, void __user *buffer, - size_t *lenp, loff_t *ppos) -{ - char buf[22]; - int len; - - if (!*lenp || (*ppos && !write)) { - *lenp = 0; - return 0; - } - if (write) - return -EINVAL; - - len = snprintf(buf, sizeof(buf), "%llu\n", obd_memory_max()); - if (len > *lenp) - len = *lenp; - buf[len] = '\0'; - if (copy_to_user(buffer, buf, len)) - return -EFAULT; - *lenp = len; - *ppos += *lenp; - return 0; -} -#endif /* CONFIG_SYSCTL */ - static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr, char *buf) { @@ -198,34 +146,25 @@ LUSTRE_STATIC_UINT_ATTR(at_history, &at_history); #ifdef HAVE_SERVER_SUPPORT LUSTRE_STATIC_UINT_ATTR(ldlm_timeout, &ldlm_timeout); +LUSTRE_STATIC_UINT_ATTR(bulk_timeout, &bulk_timeout); #endif +static ssize_t memused_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + return sprintf(buf, "%llu\n", obd_memory_sum()); +} +LUSTRE_RO_ATTR(memused); + +static ssize_t memused_max_show(struct kobject *kobj, struct attribute *attr, + char *buf) +{ + return sprintf(buf, "%llu\n", obd_memory_max()); +} +LUSTRE_RO_ATTR(memused_max); + #ifdef CONFIG_SYSCTL static struct ctl_table obd_table[] = { - { - INIT_CTL_NAME - .procname = "memused", - .data = NULL, - .maxlen = 0, - .mode = 0444, - .proc_handler = &proc_memory_alloc - }, - { - INIT_CTL_NAME - .procname = "memused_max", - .data = NULL, - .maxlen = 0, - .mode = 0444, - .proc_handler = &proc_mem_max - }, - { - INIT_CTL_NAME - .procname = "bulk_timeout", - .data = &bulk_timeout, - .maxlen = sizeof(int), - .mode = 0644, - .proc_handler = &proc_dointvec - }, { 0 } }; @@ -253,8 +192,11 @@ static struct attribute *lustre_attrs[] = { &lustre_sattr_at_extra.u.attr, &lustre_sattr_at_early_margin.u.attr, &lustre_sattr_at_history.u.attr, + &lustre_attr_memused_max.attr, + &lustre_attr_memused.attr, #ifdef HAVE_SERVER_SUPPORT &lustre_sattr_ldlm_timeout.u.attr, + &lustre_sattr_bulk_timeout.u.attr, #endif NULL, }; -- 1.8.3.1