2023-03-08 14:08:34

by 李扬韬

[permalink] [raw]
Subject: [PATCH v2] f2fs: convert to MAX_SBI_FLAG instead of 32 in stat_show()

BIW reduce the s_flag array size and make s_flag constant.

Signed-off-by: Yangtao Li <[email protected]>
---
v2:
-make s_flag constant
fs/f2fs/debug.c | 36 ++++++++++++++++++------------------
fs/f2fs/f2fs.h | 6 +++++-
2 files changed, 23 insertions(+), 19 deletions(-)

diff --git a/fs/f2fs/debug.c b/fs/f2fs/debug.c
index 30a77936e3c5..99c7fc832ec7 100644
--- a/fs/f2fs/debug.c
+++ b/fs/f2fs/debug.c
@@ -336,22 +336,22 @@ static void update_mem_info(struct f2fs_sb_info *sbi)
#endif
}

-static char *s_flag[] = {
- [SBI_IS_DIRTY] = " fs_dirty",
- [SBI_IS_CLOSE] = " closing",
- [SBI_NEED_FSCK] = " need_fsck",
- [SBI_POR_DOING] = " recovering",
- [SBI_NEED_SB_WRITE] = " sb_dirty",
- [SBI_NEED_CP] = " need_cp",
- [SBI_IS_SHUTDOWN] = " shutdown",
- [SBI_IS_RECOVERED] = " recovered",
- [SBI_CP_DISABLED] = " cp_disabled",
- [SBI_CP_DISABLED_QUICK] = " cp_disabled_quick",
- [SBI_QUOTA_NEED_FLUSH] = " quota_need_flush",
- [SBI_QUOTA_SKIP_FLUSH] = " quota_skip_flush",
- [SBI_QUOTA_NEED_REPAIR] = " quota_need_repair",
- [SBI_IS_RESIZEFS] = " resizefs",
- [SBI_IS_FREEZING] = " freezefs",
+static const char *s_flag[MAX_SBI_FLAG] = {
+ [SBI_IS_DIRTY] = "fs_dirty",
+ [SBI_IS_CLOSE] = "closing",
+ [SBI_NEED_FSCK] = "need_fsck",
+ [SBI_POR_DOING] = "recovering",
+ [SBI_NEED_SB_WRITE] = "sb_dirty",
+ [SBI_NEED_CP] = "need_cp",
+ [SBI_IS_SHUTDOWN] = "shutdown",
+ [SBI_IS_RECOVERED] = "recovered",
+ [SBI_CP_DISABLED] = "cp_disabled",
+ [SBI_CP_DISABLED_QUICK] = "cp_disabled_quick",
+ [SBI_QUOTA_NEED_FLUSH] = "quota_need_flush",
+ [SBI_QUOTA_SKIP_FLUSH] = "quota_skip_flush",
+ [SBI_QUOTA_NEED_REPAIR] = "quota_need_repair",
+ [SBI_IS_RESIZEFS] = "resizefs",
+ [SBI_IS_FREEZING] = "freezefs",
};

static const char *ipu_mode_names[F2FS_IPU_MAX] = {
@@ -384,8 +384,8 @@ static int stat_show(struct seq_file *s, void *v)
"Disabled" : (f2fs_cp_error(sbi) ? "Error" : "Good"));
if (sbi->s_flag) {
seq_puts(s, "[SBI:");
- for_each_set_bit(j, &sbi->s_flag, 32)
- seq_puts(s, s_flag[j]);
+ for_each_set_bit(j, &sbi->s_flag, MAX_SBI_FLAG)
+ seq_printf(s, " %s", s_flag[j]);
seq_puts(s, "]\n");
}
seq_printf(s, "[SB: 1] [CP: 2] [SIT: %d] [NAT: %d] ",
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 199b1ca6b9e4..407cb35ac06f 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1293,7 +1293,10 @@ struct f2fs_gc_control {
unsigned int nr_free_secs; /* # of free sections to do GC */
};

-/* For s_flag in struct f2fs_sb_info */
+/*
+ * For s_flag in struct f2fs_sb_info
+ * Modification on enum should be synchronized with s_flag array
+ */
enum {
SBI_IS_DIRTY, /* dirty flag for checkpoint */
SBI_IS_CLOSE, /* specify unmounting */
@@ -1310,6 +1313,7 @@ enum {
SBI_QUOTA_NEED_REPAIR, /* quota file may be corrupted */
SBI_IS_RESIZEFS, /* resizefs is in process */
SBI_IS_FREEZING, /* freezefs is in process */
+ MAX_SBI_FLAG,
};

enum {
--
2.25.1



2023-03-21 16:40:38

by patchwork-bot+f2fs

[permalink] [raw]
Subject: Re: [f2fs-dev] [PATCH v2] f2fs: convert to MAX_SBI_FLAG instead of 32 in stat_show()

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <[email protected]>:

On Wed, 8 Mar 2023 22:06:23 +0800 you wrote:
> BIW reduce the s_flag array size and make s_flag constant.
>
> Signed-off-by: Yangtao Li <[email protected]>
> ---
> v2:
> -make s_flag constant
> fs/f2fs/debug.c | 36 ++++++++++++++++++------------------
> fs/f2fs/f2fs.h | 6 +++++-
> 2 files changed, 23 insertions(+), 19 deletions(-)

Here is the summary with links:
- [f2fs-dev,v2] f2fs: convert to MAX_SBI_FLAG instead of 32 in stat_show()
https://git.kernel.org/jaegeuk/f2fs/c/e17992cc090b

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



2023-03-23 15:23:59

by Chao Yu

[permalink] [raw]
Subject: Re: [PATCH v2] f2fs: convert to MAX_SBI_FLAG instead of 32 in stat_show()

On 2023/3/8 22:06, Yangtao Li wrote:
> BIW reduce the s_flag array size and make s_flag constant.
>
> Signed-off-by: Yangtao Li <[email protected]>

Reviewed-by: Chao Yu <[email protected]>

Thanks,