summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Drokin <green@linuxhacker.ru>2015-05-21 15:32:06 -0400
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2015-05-31 10:59:23 +0900
commit5c8c82f63a11c07a0687d2c71411166017012689 (patch)
treee9e106b309678f8d744463a4e5c10fedd65006a0
parent24b8c88a7122df35ce6a413cd76e9581411eab8f (diff)
downloadop-kernel-dev-5c8c82f63a11c07a0687d2c71411166017012689.zip
op-kernel-dev-5c8c82f63a11c07a0687d2c71411166017012689.tar.gz
staging/lustre: Add debugfs root
This is just plumbing for migrating remaining procfs to debugfs support Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com> Signed-off-by: Oleg Drokin <oleg.drokin@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/lustre/lustre/include/lprocfs_status.h25
-rw-r--r--drivers/staging/lustre/lustre/obdclass/linux/linux-module.c32
-rw-r--r--drivers/staging/lustre/lustre/obdclass/lprocfs_status.c103
3 files changed, 153 insertions, 7 deletions
diff --git a/drivers/staging/lustre/lustre/include/lprocfs_status.h b/drivers/staging/lustre/lustre/include/lprocfs_status.h
index b46cd54..313f394 100644
--- a/drivers/staging/lustre/lustre/include/lprocfs_status.h
+++ b/drivers/staging/lustre/lustre/include/lprocfs_status.h
@@ -43,6 +43,7 @@
#define _LPROCFS_SNMP_H
#include <linux/proc_fs.h>
+#include <linux/debugfs.h>
#include <linux/seq_file.h>
#include <linux/spinlock.h>
#include <linux/types.h>
@@ -349,7 +350,7 @@ enum {
#define EXTRA_FIRST_OPC LDLM_GLIMPSE_ENQUEUE
/* class_obd.c */
extern struct proc_dir_entry *proc_lustre_root;
-
+extern struct dentry *debugfs_lustre_root;
extern struct kobject *lustre_kobj;
struct obd_device;
@@ -577,19 +578,30 @@ lprocfs_nid_stats_clear_write(struct file *file, const char *buffer,
unsigned long count, void *data);
extern int lprocfs_nid_stats_clear_read(struct seq_file *m, void *data);
+extern int ldebugfs_register_stats(struct dentry *parent,
+ const char *name,
+ struct lprocfs_stats *stats);
extern int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
struct lprocfs_stats *stats);
/* lprocfs_status.c */
+extern int ldebugfs_add_vars(struct dentry *parent,
+ struct lprocfs_vars *var,
+ void *data);
extern int lprocfs_add_vars(struct proc_dir_entry *root,
struct lprocfs_vars *var,
void *data);
+extern struct dentry *ldebugfs_register(const char *name,
+ struct dentry *parent,
+ struct lprocfs_vars *list,
+ void *data);
extern struct proc_dir_entry *lprocfs_register(const char *name,
struct proc_dir_entry *parent,
struct lprocfs_vars *list,
void *data);
+extern void ldebugfs_remove(struct dentry **entryp);
extern void lprocfs_remove(struct proc_dir_entry **root);
extern void lprocfs_remove_proc_entry(const char *name,
struct proc_dir_entry *parent);
@@ -597,6 +609,11 @@ extern void lprocfs_remove_proc_entry(const char *name,
extern int lprocfs_obd_setup(struct obd_device *obd, struct lprocfs_vars *list);
extern int lprocfs_obd_cleanup(struct obd_device *obd);
+extern int ldebugfs_seq_create(struct dentry *parent,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data);
extern int lprocfs_seq_create(struct proc_dir_entry *parent, const char *name,
umode_t mode,
const struct file_operations *seq_fops,
@@ -691,7 +708,8 @@ extern int lprocfs_seq_release(struct inode *, struct file *);
#define __LPROC_SEQ_FOPS(name, custom_seq_write) \
static int name##_single_open(struct inode *inode, struct file *file) \
{ \
- return single_open(file, name##_seq_show, PDE_DATA(inode)); \
+ return single_open(file, name##_seq_show, \
+ inode->i_private ?: PDE_DATA(inode)); \
} \
static struct file_operations name##_fops = { \
.owner = THIS_MODULE, \
@@ -736,7 +754,8 @@ static struct file_operations name##_fops = { \
} \
static int name##_##type##_open(struct inode *inode, struct file *file) \
{ \
- return single_open(file, NULL, PDE_DATA(inode)); \
+ return single_open(file, NULL, \
+ inode->i_private ?: PDE_DATA(inode));\
} \
static struct file_operations name##_##type##_fops = { \
.open = name##_##type##_open, \
diff --git a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
index df3aa8f..72113a9 100644
--- a/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
+++ b/drivers/staging/lustre/lustre/obdclass/linux/linux-module.c
@@ -318,6 +318,10 @@ static ssize_t jobid_name_store(struct kobject *kobj, struct attribute *attr,
return count;
}
+/* Root for /sys/kernel/debug/lustre */
+struct dentry *debugfs_lustre_root;
+EXPORT_SYMBOL_GPL(debugfs_lustre_root);
+
#if defined(CONFIG_PROC_FS)
/* Root for /proc/fs/lustre */
struct proc_dir_entry *proc_lustre_root = NULL;
@@ -426,6 +430,7 @@ static struct attribute_group lustre_attr_group = {
int class_procfs_init(void)
{
int rc = 0;
+ struct dentry *file;
lustre_kobj = kobject_create_and_add("lustre", fs_kobj);
if (lustre_kobj == NULL)
@@ -438,8 +443,24 @@ int class_procfs_init(void)
goto out;
}
- proc_lustre_root = lprocfs_register("fs/lustre", NULL,
- NULL, NULL);
+ debugfs_lustre_root = debugfs_create_dir("lustre", NULL);
+ if (IS_ERR_OR_NULL(debugfs_lustre_root)) {
+ rc = debugfs_lustre_root ? PTR_ERR(debugfs_lustre_root)
+ : -ENOMEM;
+ debugfs_lustre_root = NULL;
+ kobject_put(lustre_kobj);
+ goto out;
+ }
+
+ file = debugfs_create_file("devices", 0444, debugfs_lustre_root, NULL,
+ &obd_device_list_fops);
+ if (IS_ERR_OR_NULL(file)) {
+ rc = file ? PTR_ERR(file) : -ENOMEM;
+ kobject_put(lustre_kobj);
+ goto out;
+ }
+
+ proc_lustre_root = lprocfs_register("fs/lustre", NULL, NULL, NULL);
if (IS_ERR(proc_lustre_root)) {
rc = PTR_ERR(proc_lustre_root);
proc_lustre_root = NULL;
@@ -452,11 +473,16 @@ int class_procfs_init(void)
out:
if (rc)
CERROR("error adding /proc/fs/lustre/devices file\n");
- return 0;
+ return rc;
}
int class_procfs_clean(void)
{
+ if (debugfs_lustre_root != NULL)
+ debugfs_remove_recursive(debugfs_lustre_root);
+
+ debugfs_lustre_root = NULL;
+
if (proc_lustre_root) {
lprocfs_remove(&proc_lustre_root);
}
diff --git a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
index 916d060..000e874 100644
--- a/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
+++ b/drivers/staging/lustre/lustre/obdclass/lprocfs_status.c
@@ -296,6 +296,37 @@ EXPORT_SYMBOL(lprocfs_add_symlink);
static struct file_operations lprocfs_generic_fops = { };
+int ldebugfs_add_vars(struct dentry *parent,
+ struct lprocfs_vars *list,
+ void *data)
+{
+ if (IS_ERR_OR_NULL(parent) || IS_ERR_OR_NULL(list))
+ return -EINVAL;
+
+ while (list->name != NULL) {
+ struct dentry *entry;
+ umode_t mode = 0;
+
+ if (list->proc_mode != 0000) {
+ mode = list->proc_mode;
+ } else if (list->fops) {
+ if (list->fops->read)
+ mode = 0444;
+ if (list->fops->write)
+ mode |= 0200;
+ }
+ entry = debugfs_create_file(list->name, mode, parent,
+ list->data ?: data,
+ list->fops ?: &lprocfs_generic_fops
+ );
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
+ list++;
+ }
+ return 0;
+}
+EXPORT_SYMBOL(ldebugfs_add_vars);
+
/**
* Add /proc entries.
*
@@ -336,6 +367,13 @@ int lprocfs_add_vars(struct proc_dir_entry *root, struct lprocfs_vars *list,
}
EXPORT_SYMBOL(lprocfs_add_vars);
+void ldebugfs_remove(struct dentry **entryp)
+{
+ debugfs_remove(*entryp);
+ *entryp = NULL;
+}
+EXPORT_SYMBOL(ldebugfs_remove);
+
void lprocfs_remove(struct proc_dir_entry **rooth)
{
proc_remove(*rooth);
@@ -350,6 +388,32 @@ void lprocfs_remove_proc_entry(const char *name, struct proc_dir_entry *parent)
}
EXPORT_SYMBOL(lprocfs_remove_proc_entry);
+struct dentry *ldebugfs_register(const char *name,
+ struct dentry *parent,
+ struct lprocfs_vars *list, void *data)
+{
+ struct dentry *entry;
+
+ entry = debugfs_create_dir(name, parent);
+ if (IS_ERR_OR_NULL(entry)) {
+ entry = entry ?: ERR_PTR(-ENOMEM);
+ goto out;
+ }
+
+ if (!IS_ERR_OR_NULL(list)) {
+ int rc;
+
+ rc = ldebugfs_add_vars(entry, list, data);
+ if (rc != 0) {
+ debugfs_remove(entry);
+ entry = ERR_PTR(rc);
+ }
+ }
+out:
+ return entry;
+}
+EXPORT_SYMBOL(ldebugfs_register);
+
struct proc_dir_entry *lprocfs_register(const char *name,
struct proc_dir_entry *parent,
struct lprocfs_vars *list, void *data)
@@ -1257,8 +1321,10 @@ static int lprocfs_stats_seq_open(struct inode *inode, struct file *file)
rc = seq_open(file, &lprocfs_stats_seq_sops);
if (rc)
return rc;
+
seq = file->private_data;
- seq->private = PDE_DATA(inode);
+ seq->private = inode->i_private ?: PDE_DATA(inode);
+
return 0;
}
@@ -1271,6 +1337,22 @@ struct file_operations lprocfs_stats_seq_fops = {
.release = lprocfs_seq_release,
};
+int ldebugfs_register_stats(struct dentry *parent, const char *name,
+ struct lprocfs_stats *stats)
+{
+ struct dentry *entry;
+
+ LASSERT(!IS_ERR_OR_NULL(parent));
+
+ entry = debugfs_create_file(name, 0644, parent, stats,
+ &lprocfs_stats_seq_fops);
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
+
+ return 0;
+}
+EXPORT_SYMBOL(ldebugfs_register_stats);
+
int lprocfs_register_stats(struct proc_dir_entry *root, const char *name,
struct lprocfs_stats *stats)
{
@@ -1971,6 +2053,25 @@ char *lprocfs_find_named_value(const char *buffer, const char *name,
}
EXPORT_SYMBOL(lprocfs_find_named_value);
+int ldebugfs_seq_create(struct dentry *parent,
+ const char *name,
+ umode_t mode,
+ const struct file_operations *seq_fops,
+ void *data)
+{
+ struct dentry *entry;
+
+ /* Disallow secretly (un)writable entries. */
+ LASSERT((seq_fops->write == NULL) == ((mode & 0222) == 0));
+
+ entry = debugfs_create_file(name, mode, parent, data, seq_fops);
+ if (IS_ERR_OR_NULL(entry))
+ return entry ? PTR_ERR(entry) : -ENOMEM;
+
+ return 0;
+}
+EXPORT_SYMBOL(ldebugfs_seq_create);
+
int lprocfs_seq_create(struct proc_dir_entry *parent,
const char *name,
umode_t mode,
OpenPOWER on IntegriCloud