linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: qixiaoyu1 <qxy65535@gmail.com>
To: Jaegeuk Kim <jaegeuk@kernel.org>, Chao Yu <chao@kernel.org>
Cc: linux-kernel@vger.kernel.org,
	linux-f2fs-devel@lists.sourceforge.net,
	qixiaoyu1 <qixiaoyu1@xiaomi.com>,
	xiongping1 <xiongping1@xiaomi.com>
Subject: [PATCH 3/5] f2fs: add age_extent_cache mount option
Date: Mon, 28 Nov 2022 16:58:57 +0800	[thread overview]
Message-ID: <20221128085859.5295-4-qixiaoyu1@xiaomi.com> (raw)
In-Reply-To: <20221128085859.5295-1-qixiaoyu1@xiaomi.com>

From: xiongping1 <xiongping1@xiaomi.com>

enable data block seperation feature only when
age_extent_cache mount option is on

Signed-off-by: xiongping1 <xiongping1@xiaomi.com>
Signed-off-by: qixiaoyu1 <qixiaoyu1@xiaomi.com>
---
 Documentation/filesystems/f2fs.rst |  4 ++++
 fs/f2fs/block_age.c                |  3 +++
 fs/f2fs/f2fs.h                     |  1 +
 fs/f2fs/super.c                    | 27 +++++++++++++++++++++++++++
 4 files changed, 35 insertions(+)

diff --git a/Documentation/filesystems/f2fs.rst b/Documentation/filesystems/f2fs.rst
index 17df9a02ccff..f4e8943f649d 100644
--- a/Documentation/filesystems/f2fs.rst
+++ b/Documentation/filesystems/f2fs.rst
@@ -340,6 +340,10 @@ memory=%s		 Control memory mode. This supports "normal" and "low" modes.
 			 Because of the nature of low memory devices, in this mode, f2fs
 			 will try to save memory sometimes by sacrificing performance.
 			 "normal" mode is the default mode and same as before.
+age_extent_cache	 Enable an age extent cache based on rb-tree, it can record
+			 data block update frequency of the extent per inode, in
+			 order to indicate better temperature info for data block
+			 allocation.
 ======================== ============================================================
 
 Debugfs Entries
diff --git a/fs/f2fs/block_age.c b/fs/f2fs/block_age.c
index c8e8fbe51d8e..bc009616adfb 100644
--- a/fs/f2fs/block_age.c
+++ b/fs/f2fs/block_age.c
@@ -37,6 +37,9 @@ static inline bool f2fs_may_age_extent_tree(struct inode *inode)
 	if (list_empty(&sbi->s_list))
 		return false;
 
+	if (!test_opt(sbi, AGE_EXTENT_CACHE))
+		return false;
+
 	/* don't cache block age info for cold file */
 	if (is_inode_flag_set(inode, FI_COMPRESSED_FILE) ||
 			file_is_cold(inode))
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 5cc516228407..428cc560b721 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -106,6 +106,7 @@ extern const char *f2fs_fault_name[FAULT_MAX];
 #define F2FS_MOUNT_MERGE_CHECKPOINT	0x10000000
 #define	F2FS_MOUNT_GC_MERGE		0x20000000
 #define F2FS_MOUNT_COMPRESS_CACHE	0x40000000
+#define F2FS_MOUNT_AGE_EXTENT_CACHE	0x80000000
 
 #define F2FS_OPTION(sbi)	((sbi)->mount_opt)
 #define clear_opt(sbi, option)	(F2FS_OPTION(sbi).opt &= ~F2FS_MOUNT_##option)
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 91d3c9d0425d..dcb5905c7264 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -161,6 +161,9 @@ enum {
 	Opt_nogc_merge,
 	Opt_discard_unit,
 	Opt_memory_mode,
+#ifdef CONFIG_F2FS_FS_DATA_SEPARATION
+	Opt_age_extent_cache,
+#endif
 	Opt_err,
 };
 
@@ -238,6 +241,9 @@ static match_table_t f2fs_tokens = {
 	{Opt_nogc_merge, "nogc_merge"},
 	{Opt_discard_unit, "discard_unit=%s"},
 	{Opt_memory_mode, "memory=%s"},
+#ifdef CONFIG_F2FS_FS_DATA_SEPARATION
+	{Opt_age_extent_cache, "age_extent_cache"},
+#endif
 	{Opt_err, NULL},
 };
 
@@ -1253,6 +1259,11 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
 			}
 			kfree(name);
 			break;
+#ifdef CONFIG_F2FS_FS_DATA_SEPARATION
+		case Opt_age_extent_cache:
+			set_opt(sbi, AGE_EXTENT_CACHE);
+			break;
+#endif
 		default:
 			f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
 				 p);
@@ -2035,6 +2046,10 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
 	else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW)
 		seq_printf(seq, ",memory=%s", "low");
 
+#ifdef CONFIG_F2FS_FS_DATA_SEPARATION
+	if (test_opt(sbi, AGE_EXTENT_CACHE))
+		seq_puts(seq, ",age_extent_cache");
+#endif
 	return 0;
 }
 
@@ -2206,6 +2221,9 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 	bool need_restart_discard = false, need_stop_discard = false;
 	bool no_extent_cache = !test_opt(sbi, EXTENT_CACHE);
 	bool enable_checkpoint = !test_opt(sbi, DISABLE_CHECKPOINT);
+#ifdef CONFIG_F2FS_FS_DATA_SEPARATION
+	bool no_age_extent_cache = !test_opt(sbi, AGE_EXTENT_CACHE);
+#endif
 	bool no_io_align = !F2FS_IO_ALIGNED(sbi);
 	bool no_atgc = !test_opt(sbi, ATGC);
 	bool no_discard = !test_opt(sbi, DISCARD);
@@ -2300,6 +2318,15 @@ static int f2fs_remount(struct super_block *sb, int *flags, char *data)
 		goto restore_opts;
 	}
 
+#ifdef CONFIG_F2FS_FS_DATA_SEPARATION
+	/* disallow enable/disable age extent_cache dynamically */
+	if (no_age_extent_cache == !!test_opt(sbi, AGE_EXTENT_CACHE)) {
+		err = -EINVAL;
+		f2fs_warn(sbi, "switch age_extent_cache option is not allowed");
+		goto restore_opts;
+	}
+#endif
+
 	if (no_io_align == !!F2FS_IO_ALIGNED(sbi)) {
 		err = -EINVAL;
 		f2fs_warn(sbi, "switch io_bits option is not allowed");
-- 
2.36.1


  parent reply	other threads:[~2022-11-28  9:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-28  8:58 [PATCH 0/5] Support enhanced hot/cold data separation for f2fs qixiaoyu1
2022-11-28  8:58 ` [PATCH 1/5] f2fs: record total data blocks allocated since mount qixiaoyu1
2022-11-29  2:51   ` Jaegeuk Kim
2022-12-05 19:04     ` [f2fs-dev] " Jaegeuk Kim
2022-11-28  8:58 ` [PATCH 2/5] f2fs: implement cache to manager block update frequency per inode qixiaoyu1
2022-11-28 10:44   ` kernel test robot
2022-11-28  8:58 ` qixiaoyu1 [this message]
2022-11-28  8:58 ` [PATCH 4/5] f2fs: update block age info during out of place update qixiaoyu1
2022-11-28 11:14   ` kernel test robot
2022-12-12  3:04   ` kernel test robot
2022-11-28  8:58 ` [PATCH 5/5] f2fs: implement data block seperation with block update frequency qixiaoyu1
2022-11-29  7:49 ` [PATCH] f2fs: Support enhanced hot/cold data separation for f2fs Yangtao Li

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=20221128085859.5295-4-qixiaoyu1@xiaomi.com \
    --to=qxy65535@gmail.com \
    --cc=chao@kernel.org \
    --cc=jaegeuk@kernel.org \
    --cc=linux-f2fs-devel@lists.sourceforge.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=qixiaoyu1@xiaomi.com \
    --cc=xiongping1@xiaomi.com \
    /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;
as well as URLs for NNTP newsgroup(s).