Add debugfs interface support, preparing to introduce fault injection
facility.
Signed-off-by: Zhang Yi <[email protected]>
---
fs/ext4/ext4.h | 1 +
fs/ext4/sysfs.c | 10 +++++++++-
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 8d5453852f98..53099ffe307f 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -1551,6 +1551,7 @@ struct ext4_sb_info {
struct percpu_counter s_sra_exceeded_retry_limit;
struct blockgroup_lock *s_blockgroup_lock;
struct proc_dir_entry *s_proc;
+ struct dentry *s_debug;
struct kobject s_kobj;
struct completion s_kobj_unregister;
struct super_block *s_sb;
diff --git a/fs/ext4/sysfs.c b/fs/ext4/sysfs.c
index d233c24ea342..f3e4049ec50e 100644
--- a/fs/ext4/sysfs.c
+++ b/fs/ext4/sysfs.c
@@ -14,6 +14,7 @@
#include <linux/slab.h>
#include <linux/proc_fs.h>
#include <linux/part_stat.h>
+#include <linux/debugfs.h>
#include "ext4.h"
#include "ext4_jbd2.h"
@@ -59,6 +60,8 @@ struct ext4_attr {
} u;
};
+static struct dentry *ext4_debugfs_root;
+
static ssize_t session_write_kbytes_show(struct ext4_sb_info *sbi, char *buf)
{
struct super_block *sb = sbi->s_buddy_cache->i_sb;
@@ -548,6 +551,8 @@ int ext4_register_sysfs(struct super_block *sb)
proc_create_seq_data("mb_structs_summary", 0444, sbi->s_proc,
&ext4_mb_seq_structs_summary_ops, sb);
}
+ if (ext4_debugfs_root)
+ sbi->s_debug = debugfs_create_dir(sb->s_id, ext4_debugfs_root);
return 0;
}
@@ -555,6 +560,7 @@ void ext4_unregister_sysfs(struct super_block *sb)
{
struct ext4_sb_info *sbi = EXT4_SB(sb);
+ debugfs_remove_recursive(sbi->s_debug);
if (sbi->s_proc)
remove_proc_subtree(sb->s_id, ext4_proc_root);
kobject_del(&sbi->s_kobj);
@@ -580,6 +586,7 @@ int __init ext4_init_sysfs(void)
goto feat_err;
ext4_proc_root = proc_mkdir(proc_dirname, NULL);
+ ext4_debugfs_root = debugfs_create_dir("ext4", NULL);
return ret;
feat_err:
@@ -599,5 +606,6 @@ void ext4_exit_sysfs(void)
ext4_root = NULL;
remove_proc_entry(proc_dirname, NULL);
ext4_proc_root = NULL;
+ debugfs_remove_recursive(ext4_debugfs_root);
+ ext4_debugfs_root = NULL;
}
-
--
2.31.1