[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20230425174350.80714-1-frank.li@vivo.com>
Date: Wed, 26 Apr 2023 01:43:50 +0800
From: Yangtao Li <frank.li@...o.com>
To: Jaegeuk Kim <jaegeuk@...nel.org>, Chao Yu <chao@...nel.org>
Cc: Yangtao Li <frank.li@...o.com>,
linux-f2fs-devel@...ts.sourceforge.net,
linux-kernel@...r.kernel.org
Subject: [PATCH] f2fs: introduce bggc_mode related api
This patch introduces bggc_mode related api and uses it in code.
Signed-off-by: Yangtao Li <frank.li@...o.com>
---
fs/f2fs/f2fs.h | 15 +++++++++++++++
fs/f2fs/gc.c | 2 +-
fs/f2fs/super.c | 13 ++++++-------
3 files changed, 22 insertions(+), 8 deletions(-)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index d211ee89c158..e507033756f9 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -4547,6 +4547,21 @@ static inline bool f2fs_is_readonly(struct f2fs_sb_info *sbi)
return f2fs_sb_has_readonly(sbi) || f2fs_readonly(sbi->sb);
}
+static inline bool bggc_on_mode(struct f2fs_sb_info *sbi)
+{
+ return F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_ON;
+}
+
+static inline bool bggc_off_mode(struct f2fs_sb_info *sbi)
+{
+ return F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF;
+}
+
+static inline bool bggc_sync_mode(struct f2fs_sb_info *sbi)
+{
+ return F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC;
+}
+
#define EFSBADCRC EBADMSG /* Bad CRC detected */
#define EFSCORRUPTED EUCLEAN /* Filesystem is corrupted */
diff --git a/fs/f2fs/gc.c b/fs/f2fs/gc.c
index 61c5f9d26018..7a35e188c7d4 100644
--- a/fs/f2fs/gc.c
+++ b/fs/f2fs/gc.c
@@ -124,7 +124,7 @@ static int gc_thread_func(void *data)
if (!foreground)
stat_inc_bggc_count(sbi->stat_info);
- sync_mode = F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC;
+ sync_mode = bggc_sync_mode(sbi);
/* foreground GC was been triggered via f2fs_balance_fs() */
if (foreground)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9f15b03037db..9bdf4d703ad3 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -1897,11 +1897,11 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
{
struct f2fs_sb_info *sbi = F2FS_SB(root->d_sb);
- if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_SYNC)
+ if (bggc_sync_mode(sbi))
seq_printf(seq, ",background_gc=%s", "sync");
- else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_ON)
+ else if (bggc_on_mode(sbi))
seq_printf(seq, ",background_gc=%s", "on");
- else if (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF)
+ else if (bggc_off_mode(sbi))
seq_printf(seq, ",background_gc=%s", "off");
if (test_opt(sbi, GC_MERGE))
@@ -2366,8 +2366,7 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
* option. Also sync the filesystem.
*/
if ((*flags & SB_RDONLY) ||
- (F2FS_OPTION(sbi).bggc_mode == BGGC_MODE_OFF &&
- !test_opt(sbi, GC_MERGE))) {
+ (bggc_off_mode(sbi) && !test_opt(sbi, GC_MERGE))) {
if (sbi->gc_thread) {
f2fs_stop_gc_thread(sbi);
need_restart_gc = true;
@@ -4547,8 +4546,8 @@ static int f2fs_fill_super(struct super_block *sb, void *data, int silent)
* If filesystem is not mounted as read-only then
* do start the gc_thread.
*/
- if ((F2FS_OPTION(sbi).bggc_mode != BGGC_MODE_OFF ||
- test_opt(sbi, GC_MERGE)) && !f2fs_readonly(sb)) {
+ if ((!bggc_off_mode(sbi) || test_opt(sbi, GC_MERGE)) &&
+ !f2fs_readonly(sb)) {
/* After POR, we can run background GC thread.*/
err = f2fs_start_gc_thread(sbi);
if (err)
--
2.39.0
Powered by blists - more mailing lists