BACKPORT: f2fs: introduce memory mode
Introduce memory mode to supports "normal" and "low" memory modes. "low" mode is to support low memory devices. 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. Bug: 232003054 Bug: 267580491 Signed-off-by: Daeho Jeong <daehojeong@google.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org> (cherry picked from commit 60f60d1fd86a) Change-Id: I7cb719b18f0002d7af47f7a18e8ec2f4c534bdd9
This commit is contained in:

committed by
Treehugger Robot

parent
246a996565
commit
ce72626280
@@ -300,6 +300,11 @@ inlinecrypt When possible, encrypt/decrypt the contents of encrypted
|
|||||||
Documentation/block/inline-encryption.rst.
|
Documentation/block/inline-encryption.rst.
|
||||||
atgc Enable age-threshold garbage collection, it provides high
|
atgc Enable age-threshold garbage collection, it provides high
|
||||||
effectiveness and efficiency on background GC.
|
effectiveness and efficiency on background GC.
|
||||||
|
memory=%s Control memory mode. This supports "normal" and "low" modes.
|
||||||
|
"low" mode is introduced to support low memory devices.
|
||||||
|
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 records
|
age_extent_cache Enable an age extent cache based on rb-tree. It records
|
||||||
data block update frequency of the extent per inode, in
|
data block update frequency of the extent per inode, in
|
||||||
order to provide better temperature hints for data block
|
order to provide better temperature hints for data block
|
||||||
|
@@ -152,6 +152,7 @@ struct f2fs_mount_info {
|
|||||||
int fsync_mode; /* fsync policy */
|
int fsync_mode; /* fsync policy */
|
||||||
int fs_mode; /* fs mode: LFS or ADAPTIVE */
|
int fs_mode; /* fs mode: LFS or ADAPTIVE */
|
||||||
int bggc_mode; /* bggc mode: off, on or sync */
|
int bggc_mode; /* bggc mode: off, on or sync */
|
||||||
|
int memory_mode; /* memory mode */
|
||||||
struct fscrypt_dummy_policy dummy_enc_policy; /* test dummy encryption */
|
struct fscrypt_dummy_policy dummy_enc_policy; /* test dummy encryption */
|
||||||
block_t unusable_cap_perc; /* percentage for cap */
|
block_t unusable_cap_perc; /* percentage for cap */
|
||||||
block_t unusable_cap; /* Amount of space allowed to be
|
block_t unusable_cap; /* Amount of space allowed to be
|
||||||
@@ -1331,6 +1332,11 @@ enum {
|
|||||||
*/
|
*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
MEMORY_MODE_NORMAL, /* memory mode for normal devices */
|
||||||
|
MEMORY_MODE_LOW, /* memory mode for low memry devices */
|
||||||
|
};
|
||||||
|
|
||||||
static inline int f2fs_test_bit(unsigned int nr, char *addr);
|
static inline int f2fs_test_bit(unsigned int nr, char *addr);
|
||||||
static inline void f2fs_set_bit(unsigned int nr, char *addr);
|
static inline void f2fs_set_bit(unsigned int nr, char *addr);
|
||||||
static inline void f2fs_clear_bit(unsigned int nr, char *addr);
|
static inline void f2fs_clear_bit(unsigned int nr, char *addr);
|
||||||
@@ -4403,6 +4409,11 @@ static inline bool f2fs_lfs_mode(struct f2fs_sb_info *sbi)
|
|||||||
return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
|
return F2FS_OPTION(sbi).fs_mode == FS_MODE_LFS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline bool f2fs_low_mem_mode(struct f2fs_sb_info *sbi)
|
||||||
|
{
|
||||||
|
return F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW;
|
||||||
|
}
|
||||||
|
|
||||||
static inline bool f2fs_may_compress(struct inode *inode)
|
static inline bool f2fs_may_compress(struct inode *inode)
|
||||||
{
|
{
|
||||||
if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) ||
|
if (IS_SWAPFILE(inode) || f2fs_is_pinned_file(inode) ||
|
||||||
|
@@ -154,6 +154,7 @@ enum {
|
|||||||
Opt_atgc,
|
Opt_atgc,
|
||||||
Opt_gc_merge,
|
Opt_gc_merge,
|
||||||
Opt_nogc_merge,
|
Opt_nogc_merge,
|
||||||
|
Opt_memory_mode,
|
||||||
Opt_age_extent_cache,
|
Opt_age_extent_cache,
|
||||||
Opt_err,
|
Opt_err,
|
||||||
};
|
};
|
||||||
@@ -230,6 +231,7 @@ static match_table_t f2fs_tokens = {
|
|||||||
{Opt_atgc, "atgc"},
|
{Opt_atgc, "atgc"},
|
||||||
{Opt_gc_merge, "gc_merge"},
|
{Opt_gc_merge, "gc_merge"},
|
||||||
{Opt_nogc_merge, "nogc_merge"},
|
{Opt_nogc_merge, "nogc_merge"},
|
||||||
|
{Opt_memory_mode, "memory=%s"},
|
||||||
{Opt_age_extent_cache, "age_extent_cache"},
|
{Opt_age_extent_cache, "age_extent_cache"},
|
||||||
{Opt_err, NULL},
|
{Opt_err, NULL},
|
||||||
};
|
};
|
||||||
@@ -1153,6 +1155,22 @@ static int parse_options(struct super_block *sb, char *options, bool is_remount)
|
|||||||
case Opt_age_extent_cache:
|
case Opt_age_extent_cache:
|
||||||
set_opt(sbi, AGE_EXTENT_CACHE);
|
set_opt(sbi, AGE_EXTENT_CACHE);
|
||||||
break;
|
break;
|
||||||
|
case Opt_memory_mode:
|
||||||
|
name = match_strdup(&args[0]);
|
||||||
|
if (!name)
|
||||||
|
return -ENOMEM;
|
||||||
|
if (!strcmp(name, "normal")) {
|
||||||
|
F2FS_OPTION(sbi).memory_mode =
|
||||||
|
MEMORY_MODE_NORMAL;
|
||||||
|
} else if (!strcmp(name, "low")) {
|
||||||
|
F2FS_OPTION(sbi).memory_mode =
|
||||||
|
MEMORY_MODE_LOW;
|
||||||
|
} else {
|
||||||
|
kfree(name);
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
kfree(name);
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
|
f2fs_err(sbi, "Unrecognized mount option \"%s\" or missing value",
|
||||||
p);
|
p);
|
||||||
@@ -1901,6 +1919,12 @@ static int f2fs_show_options(struct seq_file *seq, struct dentry *root)
|
|||||||
|
|
||||||
if (test_opt(sbi, ATGC))
|
if (test_opt(sbi, ATGC))
|
||||||
seq_puts(seq, ",atgc");
|
seq_puts(seq, ",atgc");
|
||||||
|
|
||||||
|
if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_NORMAL)
|
||||||
|
seq_printf(seq, ",memory=%s", "normal");
|
||||||
|
else if (F2FS_OPTION(sbi).memory_mode == MEMORY_MODE_LOW)
|
||||||
|
seq_printf(seq, ",memory=%s", "low");
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1923,6 +1947,7 @@ static void default_options(struct f2fs_sb_info *sbi)
|
|||||||
F2FS_OPTION(sbi).compress_ext_cnt = 0;
|
F2FS_OPTION(sbi).compress_ext_cnt = 0;
|
||||||
F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
|
F2FS_OPTION(sbi).compress_mode = COMPR_MODE_FS;
|
||||||
F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
|
F2FS_OPTION(sbi).bggc_mode = BGGC_MODE_ON;
|
||||||
|
F2FS_OPTION(sbi).memory_mode = MEMORY_MODE_NORMAL;
|
||||||
|
|
||||||
sbi->sb->s_flags &= ~SB_INLINECRYPT;
|
sbi->sb->s_flags &= ~SB_INLINECRYPT;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user