@@ -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
@@ -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))
@@ -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)
@@ -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");