staging/lustre/libcfs: move /proc/sys/lnet to debugfs
Parameters in lnet sysctl are of debug quantity, so let's move them to debugfs instead. Signed-off-by: Oleg Drokin <green@linuxhacker.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
8952aad1cf
commit
0871d551af
1 changed files with 58 additions and 32 deletions
|
@ -50,6 +50,7 @@
|
||||||
#include <linux/list.h>
|
#include <linux/list.h>
|
||||||
|
|
||||||
#include <linux/sysctl.h>
|
#include <linux/sysctl.h>
|
||||||
|
#include <linux/debugfs.h>
|
||||||
|
|
||||||
# define DEBUG_SUBSYSTEM S_LNET
|
# define DEBUG_SUBSYSTEM S_LNET
|
||||||
|
|
||||||
|
@ -69,10 +70,10 @@ extern struct miscdevice libcfs_dev;
|
||||||
extern struct cfs_wi_sched *cfs_sched_rehash;
|
extern struct cfs_wi_sched *cfs_sched_rehash;
|
||||||
extern void libcfs_init_nidstrings(void);
|
extern void libcfs_init_nidstrings(void);
|
||||||
|
|
||||||
static int insert_proc(void);
|
static void insert_debugfs(void);
|
||||||
static void remove_proc(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];
|
extern char lnet_upcall[1024];
|
||||||
/**
|
/**
|
||||||
* The path of debug log dump upcall script.
|
* The path of debug log dump upcall script.
|
||||||
|
@ -428,17 +429,10 @@ static int init_libcfs_module(void)
|
||||||
goto cleanup_wi;
|
goto cleanup_wi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
insert_debugfs();
|
||||||
rc = insert_proc();
|
|
||||||
if (rc) {
|
|
||||||
CERROR("insert_proc: error %d\n", rc);
|
|
||||||
goto cleanup_crypto;
|
|
||||||
}
|
|
||||||
|
|
||||||
CDEBUG (D_OTHER, "portals setup OK\n");
|
CDEBUG (D_OTHER, "portals setup OK\n");
|
||||||
return 0;
|
return 0;
|
||||||
cleanup_crypto:
|
|
||||||
cfs_crypto_unregister();
|
|
||||||
cleanup_wi:
|
cleanup_wi:
|
||||||
cfs_wi_shutdown();
|
cfs_wi_shutdown();
|
||||||
cleanup_deregister:
|
cleanup_deregister:
|
||||||
|
@ -454,7 +448,7 @@ static void exit_libcfs_module(void)
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
remove_proc();
|
remove_debugfs();
|
||||||
|
|
||||||
CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
|
CDEBUG(D_MALLOC, "before Portals cleanup: kmem %d\n",
|
||||||
atomic_read(&libcfs_kmemory));
|
atomic_read(&libcfs_kmemory));
|
||||||
|
@ -935,31 +929,63 @@ static struct ctl_table lnet_table[] = {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct ctl_table top_table[] = {
|
static ssize_t lnet_debugfs_read(struct file *filp, char __user *buf,
|
||||||
{
|
size_t count, loff_t *ppos)
|
||||||
.procname = "lnet",
|
|
||||||
.mode = 0555,
|
|
||||||
.data = NULL,
|
|
||||||
.maxlen = 0,
|
|
||||||
.child = lnet_table,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
static int insert_proc(void)
|
|
||||||
{
|
{
|
||||||
if (lnet_table_header == NULL)
|
struct ctl_table *table = filp->private_data;
|
||||||
lnet_table_header = register_sysctl_table(top_table);
|
int error;
|
||||||
return 0;
|
|
||||||
|
error = table->proc_handler(table, 0, (void __user *)buf, &count, ppos);
|
||||||
|
if (!error)
|
||||||
|
error = count;
|
||||||
|
|
||||||
|
return error;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void remove_proc(void)
|
static ssize_t lnet_debugfs_write(struct file *filp, const char __user *buf,
|
||||||
|
size_t count, loff_t *ppos)
|
||||||
{
|
{
|
||||||
if (lnet_table_header != NULL)
|
struct ctl_table *table = filp->private_data;
|
||||||
unregister_sysctl_table(lnet_table_header);
|
int error;
|
||||||
|
|
||||||
lnet_table_header = NULL;
|
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 void insert_debugfs(void)
|
||||||
|
{
|
||||||
|
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_debugfs(void)
|
||||||
|
{
|
||||||
|
if (lnet_debugfs_root != NULL)
|
||||||
|
debugfs_remove_recursive(lnet_debugfs_root);
|
||||||
|
|
||||||
|
lnet_debugfs_root = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
MODULE_VERSION("1.0.0");
|
MODULE_VERSION("1.0.0");
|
||||||
|
|
Loading…
Add table
Reference in a new issue