From: Oleg Drokin <[email protected]>
This patch series removes the sysctls (also under /proc) from Lustre.
/proc/sys/lnet is moved to debugfs and
/proc/sys/lustre content is moved to /sys/fs/lustre
Additionally we now have the tools that understand the new layout,
and so first few patches fix problems introduced by earlier
code moving to sysfs.
With this accepted there would be no more proc files exported by Lustre.
Please consider.
Dmitry Eremin (4):
staging/lustre/libcfs: Remove redundant enums and sysctl moduleparams
staging/lustre/libcfs: Remove unneeded lnet watchdog_ratelimit sysctl
staging/lustre/libcfs: get rid of
debugfs/lnet/console_{min,max}_delay_centisecs
staging/lustre/libcfs: remove unused portal_enter_debugger variable
Oleg Drokin (16):
staging/lustre/lov: Move target sysfs symlink removal to object
freeing
staging/lustre: make ldebugfs_remove recursive
staging/lustre/ldlm: In ldlm_pools_fini make sure there was init
first.
staging/lustre/obdclass: fix class_procfs_init error return value
staging/lustre: remove alloc_fail_rate sysctl
staging/lustre: Remove now obsolete memory tracking sysctls
staging/lustre: Remove unneeded ldlm_timeout control
staging/lustre/obdclass: move sysctl timeout to sysfs
staging/lustre/obdclass: move max_dirty_mb from sysctl to sysfs
staging/lustre/obdclass: move debug controls to sysfs
staging/lustre/obdclass: Move AT controls from sysctl to sysfs
staging/lustre: Get rid of remaining /proc/sys/lustre plumbing
staging/lustre/libcfs: move /proc/sys/lnet to debugfs
staging/lustre/libcfs: Remove redundant lnet debugfs variables
staging/lustre/libcfs: get rid of debugfs/lnet/console_backoff
staging/lustre/libcfs: get rid of debugfs/lnet/debug_mb
.../lustre/include/linux/libcfs/libcfs_debug.h | 1 -
.../lustre/include/linux/libcfs/libcfs_private.h | 28 +-
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 -
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 5 -
.../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 3 +-
drivers/staging/lustre/lnet/lnet/router_proc.c | 11 -
drivers/staging/lustre/lustre/include/obd_class.h | 3 +-
.../staging/lustre/lustre/include/obd_support.h | 16 +-
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 9 -
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 6 +-
drivers/staging/lustre/lustre/libcfs/debug.c | 146 +++++++-
drivers/staging/lustre/lustre/libcfs/module.c | 334 +++++-------------
drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 -
drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
drivers/staging/lustre/lustre/lov/lov_obd.c | 7 +-
drivers/staging/lustre/lustre/obdclass/class_obd.c | 17 +-
.../lustre/lustre/obdclass/linux/linux-module.c | 2 +-
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 374 +++++----------------
.../lustre/lustre/obdclass/lprocfs_status.c | 2 +-
.../staging/lustre/lustre/obdclass/obd_config.c | 7 +-
drivers/staging/lustre/sysfs-fs-lustre | 103 ++++++
21 files changed, 424 insertions(+), 675 deletions(-)
--
2.1.0
From: Oleg Drokin <[email protected]>
This helps to avoid use after free on unmount.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/lov/lov_obd.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/lov/lov_obd.c b/drivers/staging/lustre/lustre/lov/lov_obd.c
index 96c55ac..134b663 100644
--- a/drivers/staging/lustre/lustre/lov/lov_obd.c
+++ b/drivers/staging/lustre/lustre/lov/lov_obd.c
@@ -107,6 +107,10 @@ static void lov_putref(struct obd_device *obd)
/* Disconnect */
__lov_del_obd(obd, tgt);
}
+
+ if (lov->lov_tgts_kobj)
+ kobject_put(lov->lov_tgts_kobj);
+
} else {
mutex_unlock(&lov->lov_lock);
}
@@ -322,9 +326,6 @@ static int lov_disconnect(struct obd_export *exp)
}
}
- if (lov->lov_tgts_kobj)
- kobject_put(lov->lov_tgts_kobj);
-
obd_putref(obd);
out:
--
2.1.0
From: Oleg Drokin <[email protected]>
ldebugfs_remove is usually called on directories with files passed in
as attributes, so simple debugfs_remove failes on them as not empty
Switch to debugfs_remove_recursive.
This fixes a number of problems where a new filesystem is mounted after
being unmounted first.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/obdclass/lprocfs_status.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 17e7c18..651dd9a 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -329,7 +329,7 @@ EXPORT_SYMBOL(ldebugfs_add_vars);
void ldebugfs_remove(struct dentry **entryp)
{
- debugfs_remove(*entryp);
+ debugfs_remove_recursive(*entryp);
*entryp = NULL;
}
EXPORT_SYMBOL(ldebugfs_remove);
--
2.1.0
From: Oleg Drokin <[email protected]>
It turns out if you call ldlm_pools_fini without completing the
ldlm_pools_init, then attempt to unregister not yet registered
shrinkers makes the kernel very unhappy.
So make sure we have them registered first.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/ldlm/ldlm_pool.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
index 1605b9c..251efb7 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_pool.c
@@ -1486,8 +1486,10 @@ EXPORT_SYMBOL(ldlm_pools_init);
void ldlm_pools_fini(void)
{
- unregister_shrinker(&ldlm_pools_srv_shrinker);
- unregister_shrinker(&ldlm_pools_cli_shrinker);
+ if (ldlm_pools_thread) {
+ unregister_shrinker(&ldlm_pools_srv_shrinker);
+ unregister_shrinker(&ldlm_pools_cli_shrinker);
+ }
ldlm_pools_thread_stop();
}
EXPORT_SYMBOL(ldlm_pools_fini);
--
2.1.0
From: Oleg Drokin <[email protected]>
Dan Carpenter noticed that procfs conversion patches introduced
a bug where should kobject_create_and_add, an error is not returned
from class_procfs_init.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/obdclass/linux/linux-module.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index 84f75dc..b618c0b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -423,7 +423,7 @@ static struct attribute_group lustre_attr_group = {
int class_procfs_init(void)
{
- int rc = 0;
+ int rc = -ENOMEM;
struct dentry *file;
lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
--
2.1.0
From: Oleg Drokin <[email protected]>
It was used to control allocation failure rate, but there is
in-kernel way of doing that that's more versatile too.
This is going to remove just the sysctl, the underlying variable
will be removed once all OBD_ALLOC* macros removal patchseries land.
Signed-off-by: Oleg Drokin <[email protected]>
---
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 38 ----------------------
1 file changed, 38 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index 54f0a81..b9a7d2f 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -203,37 +203,6 @@ static int proc_max_dirty_pages_in_mb(struct ctl_table *table, int write,
return rc;
}
-static int proc_alloc_fail_rate(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- int rc = 0;
-
- if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
- }
- if (write) {
- rc = lprocfs_write_frac_helper(buffer, *lenp,
- (unsigned int *)table->data,
- OBD_ALLOC_FAIL_MULT);
- } else {
- char buf[21];
- int len;
-
- len = lprocfs_read_frac_helper(buf, 21,
- *(unsigned int *)table->data,
- OBD_ALLOC_FAIL_MULT);
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
- }
- *ppos += *lenp;
- return rc;
-}
-
static struct ctl_table obd_table[] = {
{
.procname = "timeout",
@@ -299,13 +268,6 @@ static struct ctl_table obd_table[] = {
.proc_handler = &proc_set_timeout
},
{
- .procname = "alloc_fail_rate",
- .data = &obd_alloc_fail_rate,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_alloc_fail_rate
- },
- {
.procname = "max_dirty_mb",
.data = &obd_max_dirty_pages,
.maxlen = sizeof(int),
--
2.1.0
From: Oleg Drokin <[email protected]>
In the past when Lustre did its own allocation amounts tracking
the results were shown in sysctl as current and overall max
number of bytes and pages allocated. Now that we don't
track these, remove the sysctls.
Signed-off-by: Oleg Drokin <[email protected]>
---
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 124 ---------------------
1 file changed, 124 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index b9a7d2f..e800bd6 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -66,102 +66,6 @@ static int proc_set_timeout(struct ctl_table *table, int write,
return rc;
}
-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_pages_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_pages_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;
-}
-
-static int proc_pages_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_pages_max());
- 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_max_dirty_pages_in_mb(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp, loff_t *ppos)
{
@@ -233,34 +137,6 @@ static struct ctl_table obd_table[] = {
.proc_handler = &proc_dointvec
},
{
- .procname = "memused",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_memory_alloc
- },
- {
- .procname = "pagesused",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_pages_alloc
- },
- {
- .procname = "memused_max",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_mem_max
- },
- {
- .procname = "pagesused_max",
- .data = NULL,
- .maxlen = 0,
- .mode = 0444,
- .proc_handler = &proc_pages_max
- },
- {
.procname = "ldlm_timeout",
.data = &ldlm_timeout,
.maxlen = sizeof(int),
--
2.1.0
From: Oleg Drokin <[email protected]>
ldlm_timeout is used server-side to determine AST timeouts,
so it makes no sense on the client, esp. since it's not really used
anywhere.
Remove all traces of it except from the config where make
it a noop.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/include/obd_support.h | 4 ----
drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c | 9 ---------
drivers/staging/lustre/lustre/obdclass/class_obd.c | 4 ----
drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c | 9 ---------
drivers/staging/lustre/lustre/obdclass/obd_config.c | 7 +------
5 files changed, 1 insertion(+), 32 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index 73e2d48..f6b3692 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -56,9 +56,7 @@ extern unsigned int obd_dump_on_eviction;
/* obd_timeout should only be used for recovery, not for
networking / disk / timings affected by load (use Adaptive Timeouts) */
extern unsigned int obd_timeout; /* seconds */
-extern unsigned int ldlm_timeout; /* seconds */
extern unsigned int obd_timeout_set;
-extern unsigned int ldlm_timeout_set;
extern unsigned int at_min;
extern unsigned int at_max;
extern unsigned int at_history;
@@ -105,8 +103,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
/* Timeout definitions */
#define OBD_TIMEOUT_DEFAULT 100
-#define LDLM_TIMEOUT_DEFAULT 20
-#define MDS_LDLM_TIMEOUT_DEFAULT 6
/* Time to wait for all clients to reconnect during recovery (hard limit) */
#define OBD_RECOVERY_TIME_HARD (obd_timeout * 9)
/* Time to wait for all clients to reconnect during recovery (soft limit) */
diff --git a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
index b7b6ca1..de74e1c 100644
--- a/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
+++ b/drivers/staging/lustre/lustre/ldlm/ldlm_lockd.c
@@ -76,15 +76,6 @@ inline unsigned long round_timeout(unsigned long timeout)
return cfs_time_seconds((int)cfs_duration_sec(cfs_time_sub(timeout, 0)) + 1);
}
-/* timeout for initial callback (AST) reply (bz10399) */
-static inline unsigned int ldlm_get_rq_timeout(void)
-{
- /* Non-AT value */
- unsigned int timeout = min(ldlm_timeout, obd_timeout / 3);
-
- return timeout < 1 ? 1 : timeout;
-}
-
#define ELT_STOPPED 0
#define ELT_READY 1
#define ELT_TERMINATE 2
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 1bc3756..df0063b 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -78,12 +78,8 @@ atomic_t obd_dirty_pages;
EXPORT_SYMBOL(obd_dirty_pages);
unsigned int obd_timeout = OBD_TIMEOUT_DEFAULT; /* seconds */
EXPORT_SYMBOL(obd_timeout);
-unsigned int ldlm_timeout = LDLM_TIMEOUT_DEFAULT; /* seconds */
-EXPORT_SYMBOL(ldlm_timeout);
unsigned int obd_timeout_set;
EXPORT_SYMBOL(obd_timeout_set);
-unsigned int ldlm_timeout_set;
-EXPORT_SYMBOL(ldlm_timeout_set);
/* Adaptive timeout defs here instead of ptlrpc module for /proc/sys/ access */
unsigned int at_min = 0;
EXPORT_SYMBOL(at_min);
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index e800bd6..eda5f30 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -61,8 +61,6 @@ static int proc_set_timeout(struct ctl_table *table, int write,
int rc;
rc = proc_dointvec(table, write, buffer, lenp, ppos);
- if (ldlm_timeout >= obd_timeout)
- ldlm_timeout = max(obd_timeout / 3, 1U);
return rc;
}
@@ -137,13 +135,6 @@ static struct ctl_table obd_table[] = {
.proc_handler = &proc_dointvec
},
{
- .procname = "ldlm_timeout",
- .data = &ldlm_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_set_timeout
- },
- {
.procname = "max_dirty_mb",
.data = &obd_max_dirty_pages,
.maxlen = sizeof(int),
diff --git a/drivers/staging/lustre/lustre/obdclass/obd_config.c b/drivers/staging/lustre/lustre/obdclass/obd_config.c
index fbdb748..4a32416 100644
--- a/drivers/staging/lustre/lustre/obdclass/obd_config.c
+++ b/drivers/staging/lustre/lustre/obdclass/obd_config.c
@@ -1123,12 +1123,7 @@ int class_process_config(struct lustre_cfg *lcfg)
goto out;
}
case LCFG_SET_LDLM_TIMEOUT: {
- CDEBUG(D_IOCTL, "changing lustre ldlm_timeout from %d to %d\n",
- ldlm_timeout, lcfg->lcfg_num);
- ldlm_timeout = max(lcfg->lcfg_num, 1U);
- if (ldlm_timeout >= obd_timeout)
- ldlm_timeout = max(obd_timeout / 3, 1U);
- ldlm_timeout_set = 1;
+ /* ldlm_timeout is not used on the client */
err = 0;
goto out;
}
--
2.1.0
From: Oleg Drokin <[email protected]>
This is the first step of moving lustre sysctls from
/proc/sys/lustre to /sys/fs/lustre
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/include/obd_class.h | 4 +-
drivers/staging/lustre/lustre/obdclass/class_obd.c | 6 +-
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 66 +++++++++++++++++-----
drivers/staging/lustre/sysfs-fs-lustre | 12 ++++
4 files changed, 71 insertions(+), 17 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 36ed781..7dce4ee 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -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];
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index df0063b..1f949dc 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -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;
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index eda5f30..3c8087b 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -54,16 +54,53 @@
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)
{
@@ -107,13 +144,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,
.maxlen = sizeof(int),
@@ -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)
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
index 1e302e8..6dbad26 100644
--- a/drivers/staging/lustre/sysfs-fs-lustre
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -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" <[email protected]>
+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" <[email protected]>
--
2.1.0
From: Oleg Drokin <[email protected]>
max_dirty_mb is now a parameter in /sys/fs/lustre/
Signed-off-by: Oleg Drokin <[email protected]>
---
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 74 +++++++++-------------
drivers/staging/lustre/sysfs-fs-lustre | 12 ++++
2 files changed, 43 insertions(+), 43 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index 3c8087b..bb55a07 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -100,48 +100,42 @@ static struct static_lustre_uintvalue_attr lustre_sattr_##name = \
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)
+static ssize_t max_dirty_mb_show(struct kobject *kobj, struct attribute *attr,
+ char *buf)
{
- int rc = 0;
+ return sprintf(buf, "%ul\n",
+ obd_max_dirty_pages / (1 << (20 - PAGE_CACHE_SHIFT)));
+}
+
+static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
+ const char *buffer, size_t count)
+{
+ int rc;
+ unsigned long val;
+
+ rc = kstrtoul(buffer, 10, &val);
+ if (rc)
+ return rc;
+
+ val *= 1 << (20 - PAGE_CACHE_SHIFT); /* convert to pages */
- if (!table->data || !table->maxlen || !*lenp || (*ppos && !write)) {
- *lenp = 0;
- return 0;
+ if (val > ((totalram_pages / 10) * 9)) {
+ /* Somebody wants to assign too much memory to dirty pages */
+ return -EINVAL;
}
- if (write) {
- rc = lprocfs_write_frac_helper(buffer, *lenp,
- (unsigned int *)table->data,
- 1 << (20 - PAGE_CACHE_SHIFT));
- /* Don't allow them to let dirty pages exceed 90% of system
- * memory and set a hard minimum of 4MB. */
- if (obd_max_dirty_pages > ((totalram_pages / 10) * 9)) {
- CERROR("Refusing to set max dirty pages to %u, which is more than 90%% of available RAM; setting to %lu\n",
- obd_max_dirty_pages,
- ((totalram_pages / 10) * 9));
- obd_max_dirty_pages = (totalram_pages / 10) * 9;
- } else if (obd_max_dirty_pages < 4 << (20 - PAGE_CACHE_SHIFT)) {
- obd_max_dirty_pages = 4 << (20 - PAGE_CACHE_SHIFT);
- }
- } else {
- char buf[21];
- int len;
-
- len = lprocfs_read_frac_helper(buf, sizeof(buf),
- *(unsigned int *)table->data,
- 1 << (20 - PAGE_CACHE_SHIFT));
- if (len > *lenp)
- len = *lenp;
- buf[len] = '\0';
- if (copy_to_user(buffer, buf, len))
- return -EFAULT;
- *lenp = len;
+
+ if (val < 4 << (20 - PAGE_CACHE_SHIFT)) {
+ /* Less than 4 Mb for dirty cache is also bad */
+ return -EINVAL;
}
- *ppos += *lenp;
- return rc;
+
+ obd_max_dirty_pages = val;
+
+ return count;
}
+LUSTRE_RW_ATTR(max_dirty_mb);
+#ifdef CONFIG_SYSCTL
static struct ctl_table obd_table[] = {
{
.procname = "debug_peer_on_timeout",
@@ -165,13 +159,6 @@ static struct ctl_table obd_table[] = {
.proc_handler = &proc_dointvec
},
{
- .procname = "max_dirty_mb",
- .data = &obd_max_dirty_pages,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_max_dirty_pages_in_mb
- },
- {
.procname = "at_min",
.data = &at_min,
.maxlen = sizeof(int),
@@ -223,6 +210,7 @@ static struct ctl_table parent_table[] = {
static struct attribute *lustre_attrs[] = {
&lustre_sattr_timeout.u.attr,
+ &lustre_attr_max_dirty_mb.attr,
NULL,
};
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
index 6dbad26..38d1adc 100644
--- a/drivers/staging/lustre/sysfs-fs-lustre
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -52,6 +52,18 @@ Description:
AT (adaptive timeouts).
Unit: seconds, default: 100
+What: /sys/fs/lustre/max_dirty_mb
+Date: June 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls total number of dirty cache (in megabytes) allowed
+ across all mounted lustre filesystems.
+ Since writeout of dirty pages in Lustre is somewhat expensive,
+ when you allow to many dirty pages, this might lead to
+ performance degradations as kernel tries to desperately
+ find some pages to free/writeout.
+ Default 1/2 RAM. Min value 4, max value 9/10 of RAM.
+
What: /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
Date: May 2015
Contact: "Oleg Drokin" <[email protected]>
--
2.1.0
From: Oleg Drokin <[email protected]>
debug_peer_on_timeout, dump_on_timeout and dump_on_eviction
controls from /proc/sys/lustre to /sys/fs/lustre
Signed-off-by: Oleg Drokin <[email protected]>
---
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 28 ++++++----------------
drivers/staging/lustre/sysfs-fs-lustre | 26 ++++++++++++++++++++
2 files changed, 33 insertions(+), 21 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index bb55a07..6af1cb2 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -135,30 +135,13 @@ static ssize_t max_dirty_mb_store(struct kobject *kobj, struct attribute *attr,
}
LUSTRE_RW_ATTR(max_dirty_mb);
+LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout);
+LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout);
+LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction);
+
#ifdef CONFIG_SYSCTL
static struct ctl_table obd_table[] = {
{
- .procname = "debug_peer_on_timeout",
- .data = &obd_debug_peer_on_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
- .procname = "dump_on_timeout",
- .data = &obd_dump_on_timeout,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
- .procname = "dump_on_eviction",
- .data = &obd_dump_on_eviction,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
.procname = "at_min",
.data = &at_min,
.maxlen = sizeof(int),
@@ -211,6 +194,9 @@ static struct ctl_table parent_table[] = {
static struct attribute *lustre_attrs[] = {
&lustre_sattr_timeout.u.attr,
&lustre_attr_max_dirty_mb.attr,
+ &lustre_sattr_debug_peer_on_timeout.u.attr,
+ &lustre_sattr_dump_on_timeout.u.attr,
+ &lustre_sattr_dump_on_eviction.u.attr,
NULL,
};
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
index 38d1adc..ea9982b 100644
--- a/drivers/staging/lustre/sysfs-fs-lustre
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -64,6 +64,32 @@ Description:
find some pages to free/writeout.
Default 1/2 RAM. Min value 4, max value 9/10 of RAM.
+What: /sys/fs/lustre/debug_peer_on_timeout
+Date: June 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Control if lnet debug information should be printed when
+ an RPC timeout occurs.
+ 0 disabled (default)
+ 1 enabled
+
+What: /sys/fs/lustre/dump_on_timeout
+Date: June 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls if Lustre debug log should be dumped when an RPC
+ timeout occurs. This is useful if yout debug buffer typically
+ rolls over by the time you notice RPC timeouts.
+
+What: /sys/fs/lustre/dump_on_eviction
+Date: June 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls if Lustre debug log should be dumped when an this
+ client is evicted from one of the servers.
+ This is useful if yout debug buffer typically rolls over
+ by the time you notice the eviction event.
+
What: /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
Date: May 2015
Contact: "Oleg Drokin" <[email protected]>
--
2.1.0
From: Oleg Drokin <[email protected]>
Adaptive Timeouts controls are being moved from /proc/sys/lustre
to /sys/fs/lustre
Signed-off-by: Oleg Drokin <[email protected]>
---
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 45 ++++--------------
drivers/staging/lustre/sysfs-fs-lustre | 53 ++++++++++++++++++++++
2 files changed, 63 insertions(+), 35 deletions(-)
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index 6af1cb2..82b3c39 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -138,44 +138,14 @@ LUSTRE_RW_ATTR(max_dirty_mb);
LUSTRE_STATIC_UINT_ATTR(debug_peer_on_timeout, &obd_debug_peer_on_timeout);
LUSTRE_STATIC_UINT_ATTR(dump_on_timeout, &obd_dump_on_timeout);
LUSTRE_STATIC_UINT_ATTR(dump_on_eviction, &obd_dump_on_eviction);
+LUSTRE_STATIC_UINT_ATTR(at_min, &at_min);
+LUSTRE_STATIC_UINT_ATTR(at_max, &at_max);
+LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra);
+LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin);
+LUSTRE_STATIC_UINT_ATTR(at_history, &at_history);
#ifdef CONFIG_SYSCTL
static struct ctl_table obd_table[] = {
- {
- .procname = "at_min",
- .data = &at_min,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_max",
- .data = &at_max,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_extra",
- .data = &at_extra,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_early_margin",
- .data = &at_early_margin,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
- .procname = "at_history",
- .data = &at_history,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
{}
};
@@ -197,6 +167,11 @@ static struct attribute *lustre_attrs[] = {
&lustre_sattr_debug_peer_on_timeout.u.attr,
&lustre_sattr_dump_on_timeout.u.attr,
&lustre_sattr_dump_on_eviction.u.attr,
+ &lustre_sattr_at_min.u.attr,
+ &lustre_sattr_at_max.u.attr,
+ &lustre_sattr_at_extra.u.attr,
+ &lustre_sattr_at_early_margin.u.attr,
+ &lustre_sattr_at_history.u.attr,
NULL,
};
diff --git a/drivers/staging/lustre/sysfs-fs-lustre b/drivers/staging/lustre/sysfs-fs-lustre
index ea9982b..873e2cf 100644
--- a/drivers/staging/lustre/sysfs-fs-lustre
+++ b/drivers/staging/lustre/sysfs-fs-lustre
@@ -90,6 +90,59 @@ Description:
This is useful if yout debug buffer typically rolls over
by the time you notice the eviction event.
+What: /sys/fs/lustre/at_min
+Date: July 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls minimum adaptive timeout in seconds. If you encounter
+ a case where clients timeout due to server-reported processing
+ time being too short, you might consider increasing this value.
+ One common case of this if the underlying network has
+ unpredictable long delays.
+ Default: 0
+
+What: /sys/fs/lustre/at_max
+Date: July 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls maximum adaptive timeout in seconds. If at_max timeout
+ is reached for an RPC, the RPC will time out.
+ Some genuinuely slow network hardware might warrant increasing
+ this value.
+ Setting this value to 0 disables Adaptive Timeouts
+ functionality and old-style obd_timeout value is then used.
+ Default: 600
+
+What: /sys/fs/lustre/at_extra
+Date: July 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls how much extra time to request for unfinished requests
+ in processing in seconds. Normally a server-side parameter, it
+ is also used on the client for responses to various LDLM ASTs
+ that are handled with a special server thread on the client.
+ This is a way for the servers to ask the clients not to time
+ out the request that reached current servicing time estimate
+ yet and give it some more time.
+ Default: 30
+
+What: /sys/fs/lustre/at_early_margin
+Date: July 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls when to send the early reply for requests that are
+ about to timeout as an offset to the estimated service time in
+ seconds..
+ Default: 5
+
+What: /sys/fs/lustre/at_history
+Date: July 2015
+Contact: "Oleg Drokin" <[email protected]>
+Description:
+ Controls for how many seconds to remember slowest events
+ encountered by adaptive timeouts code.
+ Default: 600
+
What: /sys/fs/lustre/llite/<fsname>-<uuid>/blocksize
Date: May 2015
Contact: "Oleg Drokin" <[email protected]>
--
2.1.0
From: Oleg Drokin <[email protected]>
Since all of the variables from /proc/sys/lustre were moved to
/sys/fs/lustre, get rid of the remaining infrastructure.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/include/obd_class.h | 1 -
drivers/staging/lustre/lustre/obdclass/class_obd.c | 1 -
.../lustre/lustre/obdclass/linux/linux-sysctl.c | 30 ----------------------
3 files changed, 32 deletions(-)
diff --git a/drivers/staging/lustre/lustre/include/obd_class.h b/drivers/staging/lustre/lustre/include/obd_class.h
index 7dce4ee..e1f8b15 100644
--- a/drivers/staging/lustre/lustre/include/obd_class.h
+++ b/drivers/staging/lustre/lustre/include/obd_class.h
@@ -1870,7 +1870,6 @@ extern int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
/* sysctl.c */
extern int obd_sysctl_init(void);
-extern void obd_sysctl_clean(void);
/* uuid.c */
typedef __u8 class_uuid_t[16];
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 1f949dc..2c5e703 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -659,7 +659,6 @@ static void cleanup_obdclass(void)
lu_global_fini();
obd_cleanup_caches();
- obd_sysctl_clean();
class_procfs_clean();
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
index 82b3c39..1515163 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-sysctl.c
@@ -50,10 +50,6 @@
#include "../../include/obd_support.h"
#include "../../include/lprocfs_status.h"
-#ifdef CONFIG_SYSCTL
-static struct ctl_table_header *obd_table_header;
-#endif
-
struct static_lustre_uintvalue_attr {
struct {
struct attribute attr;
@@ -144,23 +140,6 @@ LUSTRE_STATIC_UINT_ATTR(at_extra, &at_extra);
LUSTRE_STATIC_UINT_ATTR(at_early_margin, &at_early_margin);
LUSTRE_STATIC_UINT_ATTR(at_history, &at_history);
-#ifdef CONFIG_SYSCTL
-static struct ctl_table obd_table[] = {
- {}
-};
-
-static struct ctl_table parent_table[] = {
- {
- .procname = "lustre",
- .data = NULL,
- .maxlen = 0,
- .mode = 0555,
- .child = obd_table
- },
- {}
-};
-#endif
-
static struct attribute *lustre_attrs[] = {
&lustre_sattr_timeout.u.attr,
&lustre_attr_max_dirty_mb.attr,
@@ -181,18 +160,9 @@ static struct attribute_group lustre_attr_group = {
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)
{
-#ifdef CONFIG_SYSCTL
- if (obd_table_header)
- unregister_sysctl_table(obd_table_header);
- obd_table_header = NULL;
-#endif
}
--
2.1.0
From: Oleg Drokin <[email protected]>
Parameters in lnet sysctl are of debug quantity, so let's move them
to debugfs instead.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/libcfs/module.c | 86 +++++++++++++++++----------
1 file changed, 56 insertions(+), 30 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index e60b2e9..bffde77 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -50,6 +50,7 @@
#include <linux/list.h>
#include <linux/sysctl.h>
+#include <linux/debugfs.h>
# define DEBUG_SUBSYSTEM S_LNET
@@ -69,10 +70,10 @@ extern struct miscdevice libcfs_dev;
extern struct cfs_wi_sched *cfs_sched_rehash;
extern void libcfs_init_nidstrings(void);
-static int insert_proc(void);
-static void remove_proc(void);
+static void insert_debugfs(void);
+static void remove_debugfs(void);
-static struct ctl_table_header *lnet_table_header;
+static struct dentry *lnet_debugfs_root;
extern char lnet_upcall[1024];
/**
* The path of debug log dump upcall script.
@@ -428,17 +429,10 @@ static int init_libcfs_module(void)
goto cleanup_wi;
}
-
- rc = insert_proc();
- if (rc) {
- CERROR("insert_proc: error %d\n", rc);
- goto cleanup_crypto;
- }
+ insert_debugfs();
CDEBUG (D_OTHER, "portals setup OK\n");
return 0;
- cleanup_crypto:
- cfs_crypto_unregister();
cleanup_wi:
cfs_wi_shutdown();
cleanup_deregister:
@@ -454,7 +448,7 @@ static void exit_libcfs_module(void)
{
int rc;
- remove_proc();
+ remove_debugfs();
CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
atomic_read(&libcfs_kmemory));
@@ -935,31 +929,63 @@ static struct ctl_table lnet_table[] = {
}
};
-static struct ctl_table top_table[] = {
- {
- .procname = "lnet",
- .mode = 0555,
- .data = NULL,
- .maxlen = 0,
- .child = lnet_table,
- },
- {
- }
+static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ctl_table *table = filp->private_data;
+ int error;
+
+ error = table->proc_handler(table, 0, (void __user *)buf, &count, ppos);
+ if (!error)
+ error = count;
+
+ return error;
+}
+
+static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf,
+ size_t count, loff_t *ppos)
+{
+ struct ctl_table *table = filp->private_data;
+ int error;
+
+ error = table->proc_handler(table, 1, (void __user *)buf, &count, ppos);
+ if (!error)
+ error = count;
+
+ return error;
+}
+
+static const struct file_operations lnet_debugfs_file_operations = {
+ .open = simple_open,
+ .read = lnet_debugfs_read,
+ .write = lnet_debugfs_write,
+ .llseek = default_llseek,
};
-static int insert_proc(void)
+static void insert_debugfs(void)
{
- if (lnet_table_header == NULL)
- lnet_table_header = register_sysctl_table(top_table);
- return 0;
+ struct ctl_table *table;
+ struct dentry *entry;
+
+ if (lnet_debugfs_root == NULL)
+ lnet_debugfs_root = debugfs_create_dir("lnet", NULL);
+
+ /* Even if we cannot create, just ignore it altogether) */
+ if (IS_ERR_OR_NULL(lnet_debugfs_root))
+ return;
+
+ for (table = lnet_table; table->procname; table++)
+ entry = debugfs_create_file(table->procname, table->mode,
+ lnet_debugfs_root, table,
+ &lnet_debugfs_file_operations);
}
-static void remove_proc(void)
+static void remove_debugfs(void)
{
- if (lnet_table_header != NULL)
- unregister_sysctl_table(lnet_table_header);
+ if (lnet_debugfs_root != NULL)
+ debugfs_remove_recursive(lnet_debugfs_root);
- lnet_table_header = NULL;
+ lnet_debugfs_root = NULL;
}
MODULE_VERSION("1.0.0");
--
2.1.0
From: Oleg Drokin <[email protected]>
/proc/sys/lnet/console_ratelimit, debug_path and panic_on_lbug
are module parameters with no special magic accessible via
/sys/module/libcfs/parameters/libcfs_console_ratelimit,
/sys/module/libcfs/parameters/libcfs_debug_file_path and
/sys/module/libcfs/parameters/libcfs_panic_on_lbug respectively.
As such just replace them with corresponding symlinks
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/libcfs/module.c | 22 ----------------------
1 file changed, 22 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index bffde77..8a26446 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -803,13 +803,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_dobitmasks,
},
{
- .procname = "console_ratelimit",
- .data = &libcfs_console_ratelimit,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec
- },
- {
.procname = "console_max_delay_centisecs",
.maxlen = sizeof(int),
.mode = 0644,
@@ -829,14 +822,6 @@ static struct ctl_table lnet_table[] = {
},
{
- .procname = "debug_path",
- .data = libcfs_debug_file_path_arr,
- .maxlen = sizeof(libcfs_debug_file_path_arr),
- .mode = 0644,
- .proc_handler = &proc_dostring,
- },
-
- {
.procname = "cpu_partition_table",
.maxlen = 128,
.mode = 0444,
@@ -872,13 +857,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_dointvec,
},
{
- .procname = "panic_on_lbug",
- .data = &libcfs_panic_on_lbug,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec,
- },
- {
.procname = "dump_kernel",
.maxlen = 256,
.mode = 0200,
--
2.1.0
From: Oleg Drokin <[email protected]>
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 <[email protected]>
---
drivers/staging/lustre/lustre/libcfs/debug.c | 31 +++++++++++++-
drivers/staging/lustre/lustre/libcfs/module.c | 59 +++++++++++----------------
2 files changed, 54 insertions(+), 36 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 021c92f..147004ce 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -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);
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index 8a26446..8b9ce22 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -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)
@@ -815,13 +787,6 @@ static struct ctl_table lnet_table[] = {
.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,
.mode = 0444,
@@ -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)
--
2.1.0
From: Dmitry Eremin <[email protected]>
/proc/sys/lnet/lnet_memused
Remove memory tracking for LNet.
Remove redundant enums definition.
Signed-off-by: Dmitry Eremin <[email protected]>
---
.../lustre/include/linux/libcfs/libcfs_private.h | 28 +--------------
.../staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c | 12 -------
.../staging/lustre/lnet/klnds/socklnd/socklnd.c | 5 ---
.../staging/lustre/lnet/klnds/socklnd/socklnd_cb.c | 3 +-
drivers/staging/lustre/lnet/lnet/router_proc.c | 11 ------
.../staging/lustre/lustre/include/obd_support.h | 12 +++----
drivers/staging/lustre/lustre/libcfs/debug.c | 3 --
drivers/staging/lustre/lustre/libcfs/module.c | 41 ----------------------
drivers/staging/lustre/lustre/obdclass/class_obd.c | 6 ++--
9 files changed, 9 insertions(+), 112 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
index ed37d26..9544860 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_private.h
@@ -87,24 +87,6 @@ do { \
lbug_with_loc(&msgdata); \
} while (0)
-extern atomic_t libcfs_kmemory;
-/*
- * Memory
- */
-
-# define libcfs_kmem_inc(ptr, size) \
-do { \
- atomic_add(size, &libcfs_kmemory); \
-} while (0)
-
-# define libcfs_kmem_dec(ptr, size) \
-do { \
- atomic_sub(size, &libcfs_kmemory); \
-} while (0)
-
-# define libcfs_kmem_read() \
- atomic_read(&libcfs_kmemory)
-
#ifndef LIBCFS_VMALLOC_SIZE
#define LIBCFS_VMALLOC_SIZE (2 << PAGE_CACHE_SHIFT) /* 2 pages */
#endif
@@ -121,14 +103,9 @@ do { \
if (unlikely((ptr) == NULL)) { \
CERROR("LNET: out of memory at %s:%d (tried to alloc '" \
#ptr "' = %d)\n", __FILE__, __LINE__, (int)(size)); \
- CERROR("LNET: %d total bytes allocated by lnet\n", \
- libcfs_kmem_read()); \
} else { \
memset((ptr), 0, (size)); \
- libcfs_kmem_inc((ptr), (size)); \
- CDEBUG(D_MALLOC, "alloc '" #ptr "': %d at %p (tot %d).\n", \
- (int)(size), (ptr), libcfs_kmem_read()); \
- } \
+ } \
} while (0)
/**
@@ -180,9 +157,6 @@ do { \
"%s:%d\n", s, __FILE__, __LINE__); \
break; \
} \
- libcfs_kmem_dec((ptr), s); \
- CDEBUG(D_MALLOC, "kfreed '" #ptr "': %d at %p (tot %d).\n", \
- s, (ptr), libcfs_kmem_read()); \
if (unlikely(s > LIBCFS_VMALLOC_SIZE)) \
vfree(ptr); \
else \
diff --git a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
index 4eb24a1..f429d25 100644
--- a/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
+++ b/drivers/staging/lustre/lnet/klnds/o2iblnd/o2iblnd.c
@@ -2667,9 +2667,6 @@ static void kiblnd_base_shutdown(void)
LASSERT(list_empty(&kiblnd_data.kib_devs));
- CDEBUG(D_MALLOC, "before LND base cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
switch (kiblnd_data.kib_init) {
default:
LBUG();
@@ -2720,9 +2717,6 @@ static void kiblnd_base_shutdown(void)
if (kiblnd_data.kib_scheds != NULL)
cfs_percpt_free(kiblnd_data.kib_scheds);
- CDEBUG(D_MALLOC, "after LND base cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
kiblnd_data.kib_init = IBLND_INIT_NOTHING;
module_put(THIS_MODULE);
}
@@ -2739,9 +2733,6 @@ void kiblnd_shutdown(lnet_ni_t *ni)
if (net == NULL)
goto out;
- CDEBUG(D_MALLOC, "before LND net cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
write_lock_irqsave(g_lock, flags);
net->ibn_shutdown = 1;
write_unlock_irqrestore(g_lock, flags);
@@ -2786,9 +2777,6 @@ void kiblnd_shutdown(lnet_ni_t *ni)
break;
}
- CDEBUG(D_MALLOC, "after LND net cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
net->ibn_init = IBLND_INIT_NOTHING;
ni->ni_data = NULL;
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
index 4128a92..d8bfcad 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd.c
@@ -2252,8 +2252,6 @@ ksocknal_base_shutdown(void)
int i;
int j;
- CDEBUG(D_MALLOC, "before NAL cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
LASSERT(ksocknal_data.ksnd_nnets == 0);
switch (ksocknal_data.ksnd_init) {
@@ -2331,9 +2329,6 @@ ksocknal_base_shutdown(void)
break;
}
- CDEBUG(D_MALLOC, "after NAL cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
module_put(THIS_MODULE);
}
diff --git a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
index fe2a83a..0d5aac6 100644
--- a/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
+++ b/drivers/staging/lustre/lnet/klnds/socklnd/socklnd_cb.c
@@ -526,8 +526,7 @@ ksocknal_process_transmit (ksock_conn_t *conn, ksock_tx_t *tx)
counter++; /* exponential backoff warnings */
if ((counter & (-counter)) == counter)
- CWARN("%u ENOMEM tx %p (%u allocated)\n",
- counter, conn, atomic_read(&libcfs_kmemory));
+ CWARN("%u ENOMEM tx %p\n", counter, conn);
/* Queue on ksnd_enomem_conns for retry after a timeout */
spin_lock_bh(&ksocknal_data.ksnd_reaper_lock);
diff --git a/drivers/staging/lustre/lnet/lnet/router_proc.c b/drivers/staging/lustre/lnet/lnet/router_proc.c
index ee902dc..40f418b 100644
--- a/drivers/staging/lustre/lnet/lnet/router_proc.c
+++ b/drivers/staging/lustre/lnet/lnet/router_proc.c
@@ -32,17 +32,6 @@
static struct ctl_table_header *lnet_table_header;
-#define CTL_LNET (0x100)
-enum {
- PSDEV_LNET_STATS = 100,
- PSDEV_LNET_ROUTES,
- PSDEV_LNET_ROUTERS,
- PSDEV_LNET_PEERS,
- PSDEV_LNET_BUFFERS,
- PSDEV_LNET_NIS,
- PSDEV_LNET_PTL_ROTOR,
-};
-
#define LNET_LOFFT_BITS (sizeof(loff_t) * 8)
/*
* NB: max allowed LNET_CPT_BITS is 8 on 64-bit system and 2 on 32-bit system
diff --git a/drivers/staging/lustre/lustre/include/obd_support.h b/drivers/staging/lustre/lustre/include/obd_support.h
index f6b3692..88e1671 100644
--- a/drivers/staging/lustre/lustre/include/obd_support.h
+++ b/drivers/staging/lustre/lustre/include/obd_support.h
@@ -501,8 +501,6 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
#define OBD_FAIL_ONCE CFS_FAIL_ONCE
#define OBD_FAILED CFS_FAILED
-extern atomic_t libcfs_kmemory;
-
extern void obd_update_maxusage(void);
#define obd_memory_add(size) \
@@ -618,8 +616,8 @@ do { \
if (unlikely((ptr) == NULL)) { \
CERROR("vmalloc of '" #ptr "' (%d bytes) failed\n", \
(int)(size)); \
- CERROR("%llu total bytes allocated by Lustre, %d by LNET\n", \
- obd_memory_sum(), atomic_read(&libcfs_kmemory)); \
+ CERROR("%llu total bytes allocated by Lustre\n", \
+ obd_memory_sum()); \
} else { \
OBD_ALLOC_POST(ptr, size, "vmalloced"); \
} \
@@ -765,12 +763,10 @@ do { \
"failed\n", (int)1, \
(__u64)(1 << PAGE_CACHE_SHIFT)); \
CERROR("%llu total bytes and %llu total pages " \
- "(%llu bytes) allocated by Lustre, " \
- "%d total bytes by LNET\n", \
+ "(%llu bytes) allocated by Lustre\n", \
obd_memory_sum(), \
obd_pages_sum() << PAGE_CACHE_SHIFT, \
- obd_pages_sum(), \
- atomic_read(&libcfs_kmemory)); \
+ obd_pages_sum()); \
} else { \
obd_pages_add(0); \
CDEBUG(D_MALLOC, "alloc_pages '" #ptr "': %d page(s) / " \
diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 147004ce..9807552 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -136,9 +136,6 @@ module_param(libcfs_panic_on_lbug, uint, 0644);
MODULE_PARM_DESC(libcfs_panic_on_lbug, "Lustre kernel panic on LBUG");
EXPORT_SYMBOL(libcfs_panic_on_lbug);
-atomic_t libcfs_kmemory = ATOMIC_INIT(0);
-EXPORT_SYMBOL(libcfs_kmemory);
-
static wait_queue_head_t debug_ctlwq;
char libcfs_debug_file_path_arr[PATH_MAX] = LIBCFS_DEBUG_FILE_PATH_DEFAULT;
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index 8b9ce22..95fa846 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -80,33 +80,6 @@ extern char lnet_upcall[1024];
*/
extern char lnet_debug_log_upcall[1024];
-#define CTL_LNET (0x100)
-
-enum {
- PSDEV_DEBUG = 1, /* control debugging */
- PSDEV_SUBSYSTEM_DEBUG, /* control debugging */
- PSDEV_PRINTK, /* force all messages to console */
- PSDEV_CONSOLE_RATELIMIT, /* ratelimit console messages */
- PSDEV_CONSOLE_MAX_DELAY_CS, /* maximum delay over which we skip messages */
- PSDEV_CONSOLE_MIN_DELAY_CS, /* initial delay over which we skip messages */
- PSDEV_CONSOLE_BACKOFF, /* delay increase factor */
- PSDEV_DEBUG_PATH, /* crashdump log location */
- PSDEV_DEBUG_DUMP_PATH, /* crashdump tracelog location */
- PSDEV_CPT_TABLE, /* information about cpu partitions */
- PSDEV_LNET_UPCALL, /* User mode upcall script */
- PSDEV_LNET_MEMUSED, /* bytes currently PORTAL_ALLOCated */
- PSDEV_LNET_CATASTROPHE, /* if we have LBUGged or panic'd */
- PSDEV_LNET_PANIC_ON_LBUG, /* flag to panic on LBUG */
- PSDEV_LNET_DUMP_KERNEL, /* snapshot kernel debug buffer to file */
- PSDEV_LNET_DAEMON_FILE, /* spool kernel debug buffer to file */
- PSDEV_LNET_DEBUG_MB, /* size of debug buffer */
- PSDEV_LNET_DEBUG_LOG_UPCALL, /* debug log upcall script */
- PSDEV_LNET_WATCHDOG_RATELIMIT, /* ratelimit watchdog messages */
- PSDEV_LNET_FORCE_LBUG, /* hook to force an LBUG */
- PSDEV_LNET_FAIL_LOC, /* control test failures instrumentation */
- PSDEV_LNET_FAIL_VAL, /* userdata for fail loc */
-};
-
static void kportal_memhog_free (struct libcfs_device_userstate *ldu)
{
struct page **level0p = &ldu->ldu_memhog_root_page;
@@ -450,9 +423,6 @@ static void exit_libcfs_module(void)
remove_debugfs();
- CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
- atomic_read(&libcfs_kmemory));
-
if (cfs_sched_rehash != NULL) {
cfs_wi_sched_destroy(cfs_sched_rehash);
cfs_sched_rehash = NULL;
@@ -467,10 +437,6 @@ static void exit_libcfs_module(void)
cfs_cpu_fini();
- if (atomic_read(&libcfs_kmemory) != 0)
- CERROR("Portals memory leaked: %d bytes\n",
- atomic_read(&libcfs_kmemory));
-
rc = libcfs_debug_cleanup();
if (rc)
pr_err("LustreError: libcfs_debug_cleanup: %d\n", rc);
@@ -808,13 +774,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_dostring,
},
{
- .procname = "lnet_memused",
- .data = (int *)&libcfs_kmemory.counter,
- .maxlen = sizeof(int),
- .mode = 0444,
- .proc_handler = &proc_dointvec,
- },
- {
.procname = "catastrophe",
.data = &libcfs_catastrophe,
.maxlen = sizeof(int),
diff --git a/drivers/staging/lustre/lustre/obdclass/class_obd.c b/drivers/staging/lustre/lustre/obdclass/class_obd.c
index 2c5e703..915a4f4 100644
--- a/drivers/staging/lustre/lustre/obdclass/class_obd.c
+++ b/drivers/staging/lustre/lustre/obdclass/class_obd.c
@@ -140,11 +140,11 @@ int obd_alloc_fail(const void *ptr, const char *name, const char *type,
CERROR("%s%salloc of %s (%llu bytes) failed at %s:%d\n",
ptr ? "force " :"", type, name, (__u64)size, file,
line);
- CERROR("%llu total bytes and %llu total pages (%llu bytes) allocated by Lustre, %d total bytes by LNET\n",
+ CERROR("%llu total bytes and %llu total pages"
+ " (%llu bytes) allocated by Lustre\n",
obd_memory_sum(),
obd_pages_sum() << PAGE_CACHE_SHIFT,
- obd_pages_sum(),
- atomic_read(&libcfs_kmemory));
+ obd_pages_sum());
return 1;
}
return 0;
--
2.1.0
From: Dmitry Eremin <[email protected]>
It is no longer used anywhere.
Signed-off-by: Dmitry Eremin <[email protected]>
---
drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h | 1 -
drivers/staging/lustre/lustre/libcfs/debug.c | 3 ---
drivers/staging/lustre/lustre/libcfs/module.c | 12 ------------
3 files changed, 16 deletions(-)
diff --git a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
index 8251ac9..a3aa644 100644
--- a/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
+++ b/drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h
@@ -50,7 +50,6 @@ extern unsigned int libcfs_stack;
extern unsigned int libcfs_debug;
extern unsigned int libcfs_printk;
extern unsigned int libcfs_console_ratelimit;
-extern unsigned int libcfs_watchdog_ratelimit;
extern unsigned int libcfs_console_max_delay;
extern unsigned int libcfs_console_min_delay;
extern unsigned int libcfs_console_backoff;
diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 9807552..5ae7b65 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -128,9 +128,6 @@ EXPORT_SYMBOL(portal_enter_debugger);
unsigned int libcfs_catastrophe;
EXPORT_SYMBOL(libcfs_catastrophe);
-unsigned int libcfs_watchdog_ratelimit = 300;
-EXPORT_SYMBOL(libcfs_watchdog_ratelimit);
-
unsigned int libcfs_panic_on_lbug = 1;
module_param(libcfs_panic_on_lbug, uint, 0644);
MODULE_PARM_DESC(libcfs_panic_on_lbug, "Lustre kernel panic on LBUG");
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index 95fa846..8e228ae 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -511,9 +511,6 @@ static int proc_dobitmasks(struct ctl_table *table, int write,
__proc_dobitmasks);
}
-static int min_watchdog_ratelimit; /* disable ratelimiting */
-static int max_watchdog_ratelimit = (24*60*60); /* limit to once per day */
-
static int __proc_dump_kernel(void *data, int write,
loff_t pos, void __user *buffer, int nob)
{
@@ -798,15 +795,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_debug_mb,
},
{
- .procname = "watchdog_ratelimit",
- .data = &libcfs_watchdog_ratelimit,
- .maxlen = sizeof(int),
- .mode = 0644,
- .proc_handler = &proc_dointvec_minmax,
- .extra1 = &min_watchdog_ratelimit,
- .extra2 = &max_watchdog_ratelimit,
- },
- {
.procname = "force_lbug",
.data = NULL,
.maxlen = 0,
--
2.1.0
From: Oleg Drokin <[email protected]>
It's just a fancy libcfs_debug_mb module parameter wrapper,
so just add debug buffer size check and resizing and the same
functionality now would be accessible via
/sys/module/libcfs/parameters/libcfs_debug_mb
Also add a symlink for backwards compatibility.
Signed-off-by: Oleg Drokin <[email protected]>
---
drivers/staging/lustre/lustre/libcfs/debug.c | 37 ++++++++++++++++++++++--
drivers/staging/lustre/lustre/libcfs/module.c | 32 ++------------------
drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 --------
drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
4 files changed, 37 insertions(+), 45 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 5ae7b65..e4c7129 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -57,8 +57,39 @@ module_param(libcfs_debug, int, 0644);
MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
EXPORT_SYMBOL(libcfs_debug);
+static int libcfs_param_debug_mb_set(const char *val,
+ const struct kernel_param *kp)
+{
+ int rc;
+ unsigned num;
+
+ rc = kstrtouint(val, 0, &num);
+ if (rc == -EINVAL)
+ return -EINVAL;
+
+ if (!*((unsigned int *)kp->arg)) {
+ *((unsigned int *)kp->arg) = num;
+ return 0;
+ }
+
+ rc = cfs_trace_set_debug_mb(num);
+
+ if (!rc)
+ *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
+
+ return rc;
+}
+
+static struct kernel_param_ops param_ops_debugmb = {
+ .set = libcfs_param_debug_mb_set,
+ .get = param_get_uint,
+};
+
+#define param_check_debugmb(name, p) \
+ __param_check(name, p, unsigned int)
+
static unsigned int libcfs_debug_mb;
-module_param(libcfs_debug_mb, uint, 0644);
+module_param(libcfs_debug_mb, debugmb, 0644);
MODULE_PARM_DESC(libcfs_debug_mb, "Total debug buffer size.");
EXPORT_SYMBOL(libcfs_debug_mb);
@@ -437,8 +468,10 @@ int libcfs_debug_init(unsigned long bufsize)
}
rc = cfs_tracefile_init(max);
- if (rc == 0)
+ if (rc == 0) {
libcfs_register_panic_notifier();
+ libcfs_debug_mb = cfs_trace_get_debug_mb();
+ }
return rc;
}
diff --git a/drivers/staging/lustre/lustre/libcfs/module.c b/drivers/staging/lustre/lustre/libcfs/module.c
index 8e228ae..acfe778 100644
--- a/drivers/staging/lustre/lustre/libcfs/module.c
+++ b/drivers/staging/lustre/lustre/libcfs/module.c
@@ -550,31 +550,6 @@ static int proc_daemon_file(struct ctl_table *table, int write,
__proc_daemon_file);
}
-static int __proc_debug_mb(void *data, int write,
- loff_t pos, void __user *buffer, int nob)
-{
- if (!write) {
- char tmpstr[32];
- int len = snprintf(tmpstr, sizeof(tmpstr), "%d",
- cfs_trace_get_debug_mb());
-
- if (pos >= len)
- return 0;
-
- return cfs_trace_copyout_string(buffer, nob, tmpstr + pos,
- "\n");
- }
-
- return cfs_trace_set_debug_mb_usrstr(buffer, nob);
-}
-
-static int proc_debug_mb(struct ctl_table *table, int write,
- void __user *buffer, size_t *lenp, loff_t *ppos)
-{
- return proc_call_handler(table->data, write, ppos, buffer, lenp,
- __proc_debug_mb);
-}
-
static int proc_console_max_delay_cs(struct ctl_table *table, int write,
void __user *buffer, size_t *lenp,
loff_t *ppos)
@@ -790,11 +765,6 @@ static struct ctl_table lnet_table[] = {
.proc_handler = &proc_daemon_file,
},
{
- .procname = "debug_mb",
- .mode = 0644,
- .proc_handler = &proc_debug_mb,
- },
- {
.procname = "force_lbug",
.data = NULL,
.maxlen = 0,
@@ -833,6 +803,8 @@ struct lnet_debugfs_symlink_def lnet_debugfs_symlinks[] = {
"/sys/module/libcfs/parameters/libcfs_panic_on_lbug"},
{ "libcfs_console_backoff",
"/sys/module/libcfs/parameters/libcfs_console_backoff"},
+ { "debug_mb",
+ "/sys/module/libcfs/parameters/libcfs_debug_mb"},
{},
};
diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.c b/drivers/staging/lustre/lustre/libcfs/tracefile.c
index 6ee2adc..effa2af 100644
--- a/drivers/staging/lustre/lustre/libcfs/tracefile.c
+++ b/drivers/staging/lustre/lustre/libcfs/tracefile.c
@@ -937,18 +937,6 @@ int cfs_trace_set_debug_mb(int mb)
return 0;
}
-int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob)
-{
- char str[32];
- int rc;
-
- rc = cfs_trace_copyin_string(str, sizeof(str), usr_str, usr_str_nob);
- if (rc < 0)
- return rc;
-
- return cfs_trace_set_debug_mb(simple_strtoul(str, NULL, 0));
-}
-
int cfs_trace_get_debug_mb(void)
{
int i;
diff --git a/drivers/staging/lustre/lustre/libcfs/tracefile.h b/drivers/staging/lustre/lustre/libcfs/tracefile.h
index 0601476..8d993f4 100644
--- a/drivers/staging/lustre/lustre/libcfs/tracefile.h
+++ b/drivers/staging/lustre/lustre/libcfs/tracefile.h
@@ -77,7 +77,6 @@ int cfs_trace_dump_debug_buffer_usrstr(void __user *usr_str, int usr_str_nob);
int cfs_trace_daemon_command(char *str);
int cfs_trace_daemon_command_usrstr(void __user *usr_str, int usr_str_nob);
int cfs_trace_set_debug_mb(int mb);
-int cfs_trace_set_debug_mb_usrstr(void __user *usr_str, int usr_str_nob);
int cfs_trace_get_debug_mb(void);
extern void libcfs_debug_dumplog_internal(void *arg);
--
2.1.0
From: Dmitry Eremin <[email protected]>
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 <[email protected]>
Signed-off-by: Oleg Drokin <[email protected]>
---
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
From: Dmitry Eremin <[email protected]>
Remove portal_enter_debugger because it's not used any more.
Signed-off-by: Dmitry Eremin <[email protected]>
---
drivers/staging/lustre/lustre/libcfs/debug.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
index 07a8f5b..917d179 100644
--- a/drivers/staging/lustre/lustre/libcfs/debug.c
+++ b/drivers/staging/lustre/lustre/libcfs/debug.c
@@ -212,9 +212,6 @@ EXPORT_SYMBOL(libcfs_debug_binary);
unsigned int libcfs_stack = 3 * THREAD_SIZE / 4;
EXPORT_SYMBOL(libcfs_stack);
-static unsigned int portal_enter_debugger;
-EXPORT_SYMBOL(portal_enter_debugger);
-
unsigned int libcfs_catastrophe;
EXPORT_SYMBOL(libcfs_catastrophe);
--
2.1.0
On Mon, Jul 06, 2015 at 12:48:53PM -0400, [email protected] wrote:
> +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)
^^^
Smatch is smart enough to know that "num" can be uninitialized here on
some paths. It doesn't generate a warning yet because a lot of the
kernel has error paths where we mostly assume things won't fail.
It should probably be:
ret = kstrtouint(val, 0, &num);
if (ret)
return ret;
if (num < min || num > max)
return -EINVAL;
> + return -EINVAL;
> + *((unsigned int *)kp->arg) = num;
> + return 0;
> +}
regards,
dan carpenter
Of course, this is not a critical flaw. Don't resend. Fix it later if
you want.
regards,
dan carpenter
On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
> +static int libcfs_param_debug_mb_set(const char *val,
> + const struct kernel_param *kp)
> +{
> + int rc;
> + unsigned num;
> +
> + rc = kstrtouint(val, 0, &num);
> + if (rc == -EINVAL)
> + return -EINVAL;
Presumably, this is root only so using num uninitialized is not an
information leak.
> +
> + if (!*((unsigned int *)kp->arg)) {
> + *((unsigned int *)kp->arg) = num;
> + return 0;
> + }
> +
> + rc = cfs_trace_set_debug_mb(num);
> +
> + if (!rc)
> + *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
> +
> + return rc;
> +}
regards,
dan carpenter
On Jul 8, 2015, at 4:28 AM, Dan Carpenter wrote:
> On Mon, Jul 06, 2015 at 12:48:53PM -0400, [email protected] wrote:
>> +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)
> ^^^
> Smatch is smart enough to know that "num" can be uninitialized here on
> some paths. It doesn't generate a warning yet because a lot of the
> kernel has error paths where we mostly assume things won't fail.
>
> It should probably be:
>
> ret = kstrtouint(val, 0, &num);
> if (ret)
> return ret;
> if (num < min || num > max)
> return -EINVAL;
Hm, indeed kstrtouint can return errors other than -EINVAL.
In reality this code comes from net/sunrpc/xprtsock.c
and I failed to see the problem there while copying.
This also suggests that the type is might be enough in demand
to make it generic so that people don't reimplement it themselves?
Thanks!
Bye,
Oleg
On Wed, Jul 08, 2015 at 11:45:59AM +0300, Dan Carpenter wrote:
> On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
> > +static int libcfs_param_debug_mb_set(const char *val,
> > + const struct kernel_param *kp)
> > +{
> > + int rc;
> > + unsigned num;
> > +
> > + rc = kstrtouint(val, 0, &num);
> > + if (rc == -EINVAL)
> > + return -EINVAL;
>
> Presumably, this is root only so using num uninitialized is not an
> information leak.
But it's not good, this should be a check for rc < 0 to make sure.
Oleg, can you send a follow-on patch to fix this up?
thanks,
greg k-h
On Jul 13, 2015, at 10:43 PM, Greg Kroah-Hartman wrote:
> On Wed, Jul 08, 2015 at 11:45:59AM +0300, Dan Carpenter wrote:
>> On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
>>> +static int libcfs_param_debug_mb_set(const char *val,
>>> + const struct kernel_param *kp)
>>> +{
>>> + int rc;
>>> + unsigned num;
>>> +
>>> + rc = kstrtouint(val, 0, &num);
>>> + if (rc == -EINVAL)
>>> + return -EINVAL;
>>
>> Presumably, this is root only so using num uninitialized is not an
>> information leak.
>
> But it's not good, this should be a check for rc < 0 to make sure.
>
> Oleg, can you send a follow-on patch to fix this up?
Sure.
Do you want it now or should I wait till you merge my previous bunch?
Bye,
Oleg
On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
> From: Oleg Drokin <[email protected]>
>
> It's just a fancy libcfs_debug_mb module parameter wrapper,
> so just add debug buffer size check and resizing and the same
> functionality now would be accessible via
> /sys/module/libcfs/parameters/libcfs_debug_mb
>
> Also add a symlink for backwards compatibility.
>
> Signed-off-by: Oleg Drokin <[email protected]>
> ---
> drivers/staging/lustre/lustre/libcfs/debug.c | 37 ++++++++++++++++++++++--
> drivers/staging/lustre/lustre/libcfs/module.c | 32 ++------------------
> drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 --------
> drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
> 4 files changed, 37 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
> index 5ae7b65..e4c7129 100644
> --- a/drivers/staging/lustre/lustre/libcfs/debug.c
> +++ b/drivers/staging/lustre/lustre/libcfs/debug.c
> @@ -57,8 +57,39 @@ module_param(libcfs_debug, int, 0644);
> MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
> EXPORT_SYMBOL(libcfs_debug);
>
> +static int libcfs_param_debug_mb_set(const char *val,
> + const struct kernel_param *kp)
> +{
> + int rc;
> + unsigned num;
> +
> + rc = kstrtouint(val, 0, &num);
> + if (rc == -EINVAL)
> + return -EINVAL;
> +
> + if (!*((unsigned int *)kp->arg)) {
> + *((unsigned int *)kp->arg) = num;
> + return 0;
> + }
> +
> + rc = cfs_trace_set_debug_mb(num);
> +
> + if (!rc)
> + *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
> +
> + return rc;
> +}
> +
> +static struct kernel_param_ops param_ops_debugmb = {
> + .set = libcfs_param_debug_mb_set,
> + .get = param_get_uint,
> +};
> +
> +#define param_check_debugmb(name, p) \
> + __param_check(name, p, unsigned int)
> +
> static unsigned int libcfs_debug_mb;
> -module_param(libcfs_debug_mb, uint, 0644);
> +module_param(libcfs_debug_mb, debugmb, 0644);
module_param wants a variable type as the second option, not a variable
name, how is this working?
thanks,
greg k-h
On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
> From: Oleg Drokin <[email protected]>
>
> It's just a fancy libcfs_debug_mb module parameter wrapper,
> so just add debug buffer size check and resizing and the same
> functionality now would be accessible via
> /sys/module/libcfs/parameters/libcfs_debug_mb
>
> Also add a symlink for backwards compatibility.
>
> Signed-off-by: Oleg Drokin <[email protected]>
> ---
> drivers/staging/lustre/lustre/libcfs/debug.c | 37 ++++++++++++++++++++++--
> drivers/staging/lustre/lustre/libcfs/module.c | 32 ++------------------
> drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 --------
> drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
> 4 files changed, 37 insertions(+), 45 deletions(-)
>
> diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
> index 5ae7b65..e4c7129 100644
> --- a/drivers/staging/lustre/lustre/libcfs/debug.c
> +++ b/drivers/staging/lustre/lustre/libcfs/debug.c
> @@ -57,8 +57,39 @@ module_param(libcfs_debug, int, 0644);
> MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
> EXPORT_SYMBOL(libcfs_debug);
>
> +static int libcfs_param_debug_mb_set(const char *val,
> + const struct kernel_param *kp)
> +{
> + int rc;
> + unsigned num;
> +
> + rc = kstrtouint(val, 0, &num);
> + if (rc == -EINVAL)
> + return -EINVAL;
> +
> + if (!*((unsigned int *)kp->arg)) {
> + *((unsigned int *)kp->arg) = num;
> + return 0;
> + }
> +
> + rc = cfs_trace_set_debug_mb(num);
> +
> + if (!rc)
> + *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
> +
> + return rc;
> +}
> +
> +static struct kernel_param_ops param_ops_debugmb = {
> + .set = libcfs_param_debug_mb_set,
> + .get = param_get_uint,
> +};
> +
> +#define param_check_debugmb(name, p) \
> + __param_check(name, p, unsigned int)
> +
> static unsigned int libcfs_debug_mb;
> -module_param(libcfs_debug_mb, uint, 0644);
> +module_param(libcfs_debug_mb, debugmb, 0644);
I'll stop here in the patch series, please fix this up and resend the
remaining 3.
thanks,
greg k-h
On Jul 13, 2015, at 10:46 PM, Greg Kroah-Hartman wrote:
> On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
>> From: Oleg Drokin <[email protected]>
>>
>> It's just a fancy libcfs_debug_mb module parameter wrapper,
>> so just add debug buffer size check and resizing and the same
>> functionality now would be accessible via
>> /sys/module/libcfs/parameters/libcfs_debug_mb
>>
>> Also add a symlink for backwards compatibility.
>>
>> Signed-off-by: Oleg Drokin <[email protected]>
>> ---
>> drivers/staging/lustre/lustre/libcfs/debug.c | 37 ++++++++++++++++++++++--
>> drivers/staging/lustre/lustre/libcfs/module.c | 32 ++------------------
>> drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 --------
>> drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
>> 4 files changed, 37 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
>> index 5ae7b65..e4c7129 100644
>> --- a/drivers/staging/lustre/lustre/libcfs/debug.c
>> +++ b/drivers/staging/lustre/lustre/libcfs/debug.c
>> @@ -57,8 +57,39 @@ module_param(libcfs_debug, int, 0644);
>> MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
>> EXPORT_SYMBOL(libcfs_debug);
>>
>> +static int libcfs_param_debug_mb_set(const char *val,
>> + const struct kernel_param *kp)
>> +{
>> + int rc;
>> + unsigned num;
>> +
>> + rc = kstrtouint(val, 0, &num);
>> + if (rc == -EINVAL)
>> + return -EINVAL;
>> +
>> + if (!*((unsigned int *)kp->arg)) {
>> + *((unsigned int *)kp->arg) = num;
>> + return 0;
>> + }
>> +
>> + rc = cfs_trace_set_debug_mb(num);
>> +
>> + if (!rc)
>> + *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
>> +
>> + return rc;
>> +}
>> +
>> +static struct kernel_param_ops param_ops_debugmb = {
>> + .set = libcfs_param_debug_mb_set,
>> + .get = param_get_uint,
>> +};
>> +
>> +#define param_check_debugmb(name, p) \
>> + __param_check(name, p, unsigned int)
>> +
>> static unsigned int libcfs_debug_mb;
>> -module_param(libcfs_debug_mb, uint, 0644);
>> +module_param(libcfs_debug_mb, debugmb, 0644);
>
> module_param wants a variable type as the second option, not a variable
> name, how is this working?
debugmb IS the type, that I just declared above.
See all the param_ops_XXX and param_check_XXX thing?
On Jul 13, 2015, at 10:49 PM, Greg Kroah-Hartman wrote:
> On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
>> From: Oleg Drokin <[email protected]>
>>
>> It's just a fancy libcfs_debug_mb module parameter wrapper,
>> so just add debug buffer size check and resizing and the same
>> functionality now would be accessible via
>> /sys/module/libcfs/parameters/libcfs_debug_mb
>>
>> Also add a symlink for backwards compatibility.
>>
>> Signed-off-by: Oleg Drokin <[email protected]>
>> ---
>> drivers/staging/lustre/lustre/libcfs/debug.c | 37 ++++++++++++++++++++++--
>> drivers/staging/lustre/lustre/libcfs/module.c | 32 ++------------------
>> drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 --------
>> drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
>> 4 files changed, 37 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
>> index 5ae7b65..e4c7129 100644
>> --- a/drivers/staging/lustre/lustre/libcfs/debug.c
>> +++ b/drivers/staging/lustre/lustre/libcfs/debug.c
>> @@ -57,8 +57,39 @@ module_param(libcfs_debug, int, 0644);
>> MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
>> EXPORT_SYMBOL(libcfs_debug);
>>
>> +static int libcfs_param_debug_mb_set(const char *val,
>> + const struct kernel_param *kp)
>> +{
>> + int rc;
>> + unsigned num;
>> +
>> + rc = kstrtouint(val, 0, &num);
>> + if (rc == -EINVAL)
>> + return -EINVAL;
>> +
>> + if (!*((unsigned int *)kp->arg)) {
>> + *((unsigned int *)kp->arg) = num;
>> + return 0;
>> + }
>> +
>> + rc = cfs_trace_set_debug_mb(num);
>> +
>> + if (!rc)
>> + *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
>> +
>> + return rc;
>> +}
>> +
>> +static struct kernel_param_ops param_ops_debugmb = {
>> + .set = libcfs_param_debug_mb_set,
>> + .get = param_get_uint,
>> +};
>> +
>> +#define param_check_debugmb(name, p) \
>> + __param_check(name, p, unsigned int)
>> +
>> static unsigned int libcfs_debug_mb;
>> -module_param(libcfs_debug_mb, uint, 0644);
>> +module_param(libcfs_debug_mb, debugmb, 0644);
>
> I'll stop here in the patch series, please fix this up and resend the
> remaining 3.
I'll fix up the EINVAL comparison.
I am just trying to see wht is it you want me to fix with the debugmb type, you don't like the name? Abetter suggestion?
Bye,
Oleg-
On Mon, Jul 13, 2015 at 10:45:36PM -0400, Oleg Drokin wrote:
>
> On Jul 13, 2015, at 10:43 PM, Greg Kroah-Hartman wrote:
>
> > On Wed, Jul 08, 2015 at 11:45:59AM +0300, Dan Carpenter wrote:
> >> On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
> >>> +static int libcfs_param_debug_mb_set(const char *val,
> >>> + const struct kernel_param *kp)
> >>> +{
> >>> + int rc;
> >>> + unsigned num;
> >>> +
> >>> + rc = kstrtouint(val, 0, &num);
> >>> + if (rc == -EINVAL)
> >>> + return -EINVAL;
> >>
> >> Presumably, this is root only so using num uninitialized is not an
> >> information leak.
> >
> > But it's not good, this should be a check for rc < 0 to make sure.
> >
> > Oleg, can you send a follow-on patch to fix this up?
>
> Sure.
> Do you want it now or should I wait till you merge my previous bunch?
I already merged your previous bunch :)
On Mon, Jul 13, 2015 at 10:51:00PM -0400, Oleg Drokin wrote:
>
> On Jul 13, 2015, at 10:46 PM, Greg Kroah-Hartman wrote:
>
> > On Mon, Jul 06, 2015 at 12:48:56PM -0400, [email protected] wrote:
> >> From: Oleg Drokin <[email protected]>
> >>
> >> It's just a fancy libcfs_debug_mb module parameter wrapper,
> >> so just add debug buffer size check and resizing and the same
> >> functionality now would be accessible via
> >> /sys/module/libcfs/parameters/libcfs_debug_mb
> >>
> >> Also add a symlink for backwards compatibility.
> >>
> >> Signed-off-by: Oleg Drokin <[email protected]>
> >> ---
> >> drivers/staging/lustre/lustre/libcfs/debug.c | 37 ++++++++++++++++++++++--
> >> drivers/staging/lustre/lustre/libcfs/module.c | 32 ++------------------
> >> drivers/staging/lustre/lustre/libcfs/tracefile.c | 12 --------
> >> drivers/staging/lustre/lustre/libcfs/tracefile.h | 1 -
> >> 4 files changed, 37 insertions(+), 45 deletions(-)
> >>
> >> diff --git a/drivers/staging/lustre/lustre/libcfs/debug.c b/drivers/staging/lustre/lustre/libcfs/debug.c
> >> index 5ae7b65..e4c7129 100644
> >> --- a/drivers/staging/lustre/lustre/libcfs/debug.c
> >> +++ b/drivers/staging/lustre/lustre/libcfs/debug.c
> >> @@ -57,8 +57,39 @@ module_param(libcfs_debug, int, 0644);
> >> MODULE_PARM_DESC(libcfs_debug, "Lustre kernel debug mask");
> >> EXPORT_SYMBOL(libcfs_debug);
> >>
> >> +static int libcfs_param_debug_mb_set(const char *val,
> >> + const struct kernel_param *kp)
> >> +{
> >> + int rc;
> >> + unsigned num;
> >> +
> >> + rc = kstrtouint(val, 0, &num);
> >> + if (rc == -EINVAL)
> >> + return -EINVAL;
> >> +
> >> + if (!*((unsigned int *)kp->arg)) {
> >> + *((unsigned int *)kp->arg) = num;
> >> + return 0;
> >> + }
> >> +
> >> + rc = cfs_trace_set_debug_mb(num);
> >> +
> >> + if (!rc)
> >> + *((unsigned int *)kp->arg) = cfs_trace_get_debug_mb();
> >> +
> >> + return rc;
> >> +}
> >> +
> >> +static struct kernel_param_ops param_ops_debugmb = {
> >> + .set = libcfs_param_debug_mb_set,
> >> + .get = param_get_uint,
> >> +};
> >> +
> >> +#define param_check_debugmb(name, p) \
> >> + __param_check(name, p, unsigned int)
> >> +
> >> static unsigned int libcfs_debug_mb;
> >> -module_param(libcfs_debug_mb, uint, 0644);
> >> +module_param(libcfs_debug_mb, debugmb, 0644);
> >
> > module_param wants a variable type as the second option, not a variable
> > name, how is this working?
>
> debugmb IS the type, that I just declared above.
> See all the param_ops_XXX and param_check_XXX thing?
Ah, missed that, sorry, my fault.
Ok, I see you resent this with a better comment, thanks for that, I'll
go queue it up now.
greg k-h