From: Yufen Yu <yuyufen@huawei.com>
To: <jaegeuk@kernel.org>, <chao@kernel.org>
Cc: <linux-kernel@vger.kernel.org>,
<linux-f2fs-devel@lists.sourceforge.net>, <yuyufen@huawei.com>
Subject: [PATCH 1/5] f2fs: extract f2fs root debugfs to init_f2fs_fs
Date: Fri, 1 Apr 2022 15:19:05 +0800 [thread overview]
Message-ID: <20220401071909.505086-2-yuyufen@huawei.com> (raw)
In-Reply-To: <20220401071909.505086-1-yuyufen@huawei.com>
Then, we don't need to depend on CONFIG_F2FS_STAT_FS to create
f2fs root debugfs directory /sys/kernel/debug/f2fs.
This patch is prepared for following f2fs fault injection,
which will create sub directory 'fault_inject' into f2fs root debugfs.
Signed-off-by: Yufen Yu <yuyufen@huawei.com>
---
fs/f2fs/debug.c | 19 ++-----------------
fs/f2fs/f2fs.h | 4 ++--
fs/f2fs/super.c | 22 ++++++++++++++++++++--
3 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index fcdf253cd211..15b3567cd208 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -22,9 +22,6 @@
static LIST_HEAD(f2fs_stat_list);
static DEFINE_RAW_SPINLOCK(f2fs_stat_lock);
-#ifdef CONFIG_DEBUG_FS
-static struct dentry *f2fs_debugfs_root;
-#endif
/*
* This function calculates BDF of every segments
@@ -648,18 +645,6 @@ void f2fs_destroy_stats(struct f2fs_sb_info *sbi)
void __init f2fs_create_root_stats(void)
{
-#ifdef CONFIG_DEBUG_FS
- f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL);
-
- debugfs_create_file("status", 0444, f2fs_debugfs_root, NULL,
- &stat_fops);
-#endif
-}
-
-void f2fs_destroy_root_stats(void)
-{
-#ifdef CONFIG_DEBUG_FS
- debugfs_remove_recursive(f2fs_debugfs_root);
- f2fs_debugfs_root = NULL;
-#endif
+ if (f2fs_debugfs_root)
+ debugfs_create_file("status", 0444, f2fs_debugfs_root, NULL, &stat_fops);
}
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index cd1e65bcf0b0..be3014029a4e 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -62,6 +62,8 @@ enum {
FAULT_MAX,
};
+extern struct dentry *f2fs_debugfs_root;
+
#ifdef CONFIG_F2FS_FAULT_INJECTION
#define F2FS_ALL_FAULT_TYPE ((1 << FAULT_MAX) - 1)
@@ -3994,7 +3996,6 @@ static inline struct f2fs_stat_info *F2FS_STAT(struct f2fs_sb_info *sbi)
int f2fs_build_stats(struct f2fs_sb_info *sbi);
void f2fs_destroy_stats(struct f2fs_sb_info *sbi);
void __init f2fs_create_root_stats(void);
-void f2fs_destroy_root_stats(void);
void f2fs_update_sit_info(struct f2fs_sb_info *sbi);
#else
#define stat_inc_cp_count(si) do { } while (0)
@@ -4035,7 +4036,6 @@ void f2fs_update_sit_info(struct f2fs_sb_info *sbi);
static inline int f2fs_build_stats(struct f2fs_sb_info *sbi) { return 0; }
static inline void f2fs_destroy_stats(struct f2fs_sb_info *sbi) { }
static inline void __init f2fs_create_root_stats(void) { }
-static inline void f2fs_destroy_root_stats(void) { }
static inline void f2fs_update_sit_info(struct f2fs_sb_info *sbi) {}
#endif
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index ea939db18f88..04e41360303c 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -27,6 +27,7 @@
#include <linux/part_stat.h>
#include <linux/zstd.h>
#include <linux/lz4.h>
+#include <linux/debugfs.h>
#include "f2fs.h"
#include "node.h"
@@ -39,6 +40,7 @@
#include <trace/events/f2fs.h>
static struct kmem_cache *f2fs_inode_cachep;
+struct dentry *f2fs_debugfs_root;
#ifdef CONFIG_F2FS_FAULT_INJECTION
@@ -4575,6 +4577,21 @@ static void destroy_inodecache(void)
kmem_cache_destroy(f2fs_inode_cachep);
}
+static void f2fs_create_debugfs(void)
+{
+#ifdef CONFIG_DEBUG_FS
+ f2fs_debugfs_root = debugfs_create_dir("f2fs", NULL);
+#endif
+}
+
+static void f2fs_destroy_debugfs(void)
+{
+#ifdef CONFIG_DEBUG_FS
+ debugfs_remove_recursive(f2fs_debugfs_root);
+ f2fs_debugfs_root = NULL;
+#endif
+}
+
static int __init init_f2fs_fs(void)
{
int err;
@@ -4615,6 +4632,7 @@ static int __init init_f2fs_fs(void)
err = register_filesystem(&f2fs_fs_type);
if (err)
goto free_shrinker;
+ f2fs_create_debugfs();
f2fs_create_root_stats();
err = f2fs_init_post_read_processing();
if (err)
@@ -4651,7 +4669,7 @@ static int __init init_f2fs_fs(void)
free_post_read:
f2fs_destroy_post_read_processing();
free_root_stats:
- f2fs_destroy_root_stats();
+ f2fs_destroy_debugfs();
unregister_filesystem(&f2fs_fs_type);
free_shrinker:
unregister_shrinker(&f2fs_shrinker_info);
@@ -4684,7 +4702,7 @@ static void __exit exit_f2fs_fs(void)
f2fs_destroy_bio_entry_cache();
f2fs_destroy_iostat_processing();
f2fs_destroy_post_read_processing();
- f2fs_destroy_root_stats();
+ f2fs_destroy_debugfs();
unregister_filesystem(&f2fs_fs_type);
unregister_shrinker(&f2fs_shrinker_info);
f2fs_exit_sysfs();
--
2.31.1
next prev parent reply other threads:[~2022-04-01 7:04 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-01 7:19 [PATCH 0/5] f2fs: try to use common fault injection framework Yufen Yu
2022-04-01 7:19 ` Yufen Yu [this message]
2022-04-01 7:19 ` [PATCH 2/5] f2fs: use common fault injection frmework Yufen Yu
2022-04-01 7:19 ` [PATCH 3/5] f2fs: replace function time_to_inject by f2fs_should_fail Yufen Yu
2022-04-01 7:19 ` [PATCH 4/5] f2fs: get rid of stale fault injection code Yufen Yu
2022-04-01 8:28 ` [f2fs-dev] " Chao Yu
2022-04-06 3:01 ` Yufen Yu
2022-04-11 10:04 ` Chao Yu
2022-04-11 21:20 ` Jaegeuk Kim
2022-04-12 11:04 ` Yufen Yu
2022-04-19 2:56 ` Chao Yu
2022-04-01 7:19 ` [PATCH 5/5] f2fs: update doc for f2fs fault injection Yufen Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220401071909.505086-2-yuyufen@huawei.com \
--to=yuyufen@huawei.com \
--cc=chao@kernel.org \
--cc=jaegeuk@kernel.org \
--cc=linux-f2fs-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome