f2fs: change default compression algorithm
PATCH 1/5 f2fs: change default compression algorithm
Use LZ4 as default compression algorithm, as compared to LZO, it shows almost the same compression ratio and much better decompression speed.
--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/super.c +1 -1
@@ -1577,7 +1577,7 @@ static void default_options(struct f2fs_sb_info *sbi)F2FS_OPTION (sbi).test_dummy_encryption = false;F2FS_OPTION (sbi).s_resuid =make_kuid (&init_user_ns,F2FS_DEF_RESUID );F2FS_OPTION (sbi).s_resgid =make_kgid (&init_user_ns,F2FS_DEF_RESGID ); -F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; +F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZ4 ;F2FS_OPTION (sbi).compress_log_size =MIN_COMPRESS_LOG_SIZE ;F2FS_OPTION (sbi).compress_ext_cnt =0 ;F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_ON ;
Signature · 8 lines
2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 2/5 f2fs: force compressed data into warm area
Generally, data shows better continuity in warm data area as its default allocation direction is right, in order to enhance sequential read/write performance of compress inode, let's force compress data into warm area.
--- fs/f2fs/segment.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
fs/f2fs/segment.c +3 -2
@@ -3037,9 +3037,10 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)if (fio->type ==DATA ) {struct inode *inode = fio->page->mapping->host; -if (is_cold_data (fio->page) ||file_is_cold (inode) || -f2fs_compressed_file (inode)) +if (is_cold_data (fio->page) ||file_is_cold (inode))return CURSEG_COLD_DATA ; +if (f2fs_compressed_file (inode)) +return CURSEG_WARM_DATA ; if (file_is_hot(inode) || is_inode_flag_set(inode, FI_HOT_DATA) || f2fs_is_atomic_file(inode) ||
Signature · 1 line
2.18.0.rc1
Jaegeuk Kim
maintainerRe: [PATCH 2/5] f2fs: force compressed data into warm area
Quoted 4 lines · Chao Yu
Generally, data shows better continuity in warm data area as its default allocation direction is right, in order to enhance sequential read/write performance of compress inode, let's force compress data into warm area.
Not quite sure tho, compressed blocks are logically cold, no?
Quoted 25 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/segment.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/f2fs/segment.c +3
-2@@ -3037,9 +3037,10 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)if (fio->type ==DATA ) {struct inode *inode = fio->page->mapping->host; -if (is_cold_data (fio->page) ||file_is_cold (inode) || -f2fs_compressed_file (inode)) +if (is_cold_data (fio->page) ||file_is_cold (inode))return CURSEG_COLD_DATA ; +if (f2fs_compressed_file (inode)) +return CURSEG_WARM_DATA ; if (file_is_hot(inode) || is_inode_flag_set(inode, FI_HOT_DATA) || f2fs_is_atomic_file(inode) ||Signature · 1 line
2.18.0.rc1
Re: [PATCH 2/5] f2fs: force compressed data into warm area
Quoted 5 lines · Jaegeuk Kim
Quoted 4 lines · Chao Yu
Generally, data shows better continuity in warm data area as its default allocation direction is right, in order to enhance sequential read/write performance of compress inode, let's force compress data into warm area.
It looks cold data's allocation direction is right as well, I missed to notice that previously due to I tested in small-sized image, and f2fs_tuning_parameters() enables ALLOC_MODE_REUSE, then cold data allocation always searchs free segment from segno #0, it breaks continuity of physical blocks.
Quoted 2 lines
Not quite sure tho, compressed blocks are logically cold, no?
Correct.
Please ignore this patch. :P
Thanks,
Quoted 28 lines
Quoted 26 lines
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/segment.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)fs/f2fs/segment.c +3
-2@@ -3037,9 +3037,10 @@ static int __get_segment_type_6(struct f2fs_io_info *fio)if (fio->type ==DATA ) {struct inode *inode = fio->page->mapping->host; -if (is_cold_data (fio->page) ||file_is_cold (inode) || -f2fs_compressed_file (inode)) +if (is_cold_data (fio->page) ||file_is_cold (inode))return CURSEG_COLD_DATA ; +if (f2fs_compressed_file (inode)) +return CURSEG_WARM_DATA ; if (file_is_hot(inode) || is_inode_flag_set(inode, FI_HOT_DATA) || f2fs_is_atomic_file(inode) ||Signature · 1 line
2.18.0.rc1.
PATCH 3/5 f2fs: fix to account compressed inode correctly
In reply to Chao Yustat_inc_compr_inode() needs to check FI_COMPRESSED_FILE flag, so in f2fs_disable_compressed_file(), we should call stat_dec_compr_inode() before clearing FI_COMPRESSED_FILE flag.
--- fs/f2fs/f2fs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fs/f2fs/f2fs.h +1 -1
@@ -3858,8 +3858,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)return fi->i_compr_blocks; fi->i_flags &= ~F2FS_COMPR_FL ; -clear_inode_flag (inode,FI_COMPRESSED_FILE );stat_dec_compr_inode (inode); +clear_inode_flag (inode,FI_COMPRESSED_FILE );return 0 ; }
Signature · 8 lines
2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 4/5 f2fs: fix to check dirty pages during compressed inode conversion
In reply to Chao YuCompressed cluster can be generated during dirty data writeback, if there is dirty pages on compressed inode, it needs to disable converting compressed inode to non-compressed one.
--- fs/f2fs/f2fs.h | 2 ++ 1 file changed, 2 insertions(+)
fs/f2fs/f2fs.h +2 -0
@@ -3854,6 +3854,8 @@ static inline u64 f2fs_disable_compressed_file(struct inode *inode)if (!f2fs_compressed_file (inode))return 0 ; +if (get_dirty_pages (inode)) +return 1 ;if (fi->i_compr_blocks)return fi->i_compr_blocks;
Signature · 8 lines
2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
PATCH 5/5 f2fs: allow to clear F2FS_COMPR_FL flag
In reply to Chao YuIf regular inode has no compressed cluster, allow using 'chattr -c' to remove its compress flag, recovering it to a non-compressed file.
--- fs/f2fs/file.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
fs/f2fs/file.c +4 -4
@@ -1822,10 +1822,10 @@ static int f2fs_setflags_common(struct inode *inode, u32 iflags, u32 mask) }if ((iflags ^ masked_flags) &F2FS_COMPR_FL ) { -if (S_ISREG (inode->i_mode) && - (masked_flags &F2FS_COMPR_FL ||i_size_read (inode) || -F2FS_HAS_BLOCKS (inode))) -return -EINVAL ; +if (S_ISREG (inode->i_mode) && (masked_flags &F2FS_COMPR_FL )) { +if (f2fs_disable_compressed_file (inode)) +return -EINVAL ; + }if (iflags &F2FS_NOCOMP_FL )return -EINVAL ;if (iflags &F2FS_COMPR_FL ) {
Signature · 8 lines
2.18.0.rc1 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
Quoted 13 lines · Chao Yu
Use LZ4 as default compression algorithm, as compared to LZO, it shows almost the same compression ratio and much better decompression speed.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/super.c +0
-0
fs/f2fs/super.c static void default_options(struct f2fs_sb_info *sbi) · line 1583
Quoted 8 lines
fs/f2fs/super.c +1
-1@@ -1577,7 +1577,7 @@ static void default_options(struct f2fs_sb_info *sbi)F2FS_OPTION (sbi).test_dummy_encryption = false;F2FS_OPTION (sbi).s_resuid =make_kuid (&init_user_ns,F2FS_DEF_RESUID );F2FS_OPTION (sbi).s_resgid =make_kgid (&init_user_ns,F2FS_DEF_RESGID ); -F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; +F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZ4 ;F2FS_OPTION (sbi).compress_log_size =MIN_COMPRESS_LOG_SIZE ;F2FS_OPTION (sbi).compress_ext_cnt =0 ;F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_ON ;
This makes sense, but it's unclear to me why comparing the different compression algorithms is happening just now, after support for both LZO and LZ4 was already merged into mainline and now has to be supported forever. During review months ago, multiple people suggested that LZ4 is better than LZO, so there's not much reason to support LZO at all.
- Eric
Quoted 20 lines · Eric Biggers
Quoted 19 lines · Chao Yu
Use LZ4 as default compression algorithm, as compared to LZO, it shows almost the same compression ratio and much better decompression speed.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/super.c +1
-1@@ -1577,7 +1577,7 @@ static void default_options(struct f2fs_sb_info *sbi)F2FS_OPTION (sbi).test_dummy_encryption = false;F2FS_OPTION (sbi).s_resuid =make_kuid (&init_user_ns,F2FS_DEF_RESUID );F2FS_OPTION (sbi).s_resgid =make_kgid (&init_user_ns,F2FS_DEF_RESGID ); -F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; +F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZ4 ;F2FS_OPTION (sbi).compress_log_size =MIN_COMPRESS_LOG_SIZE ;
Quoted 8 lines
fs/f2fs/super.c static void default_options(struct f2fs_sb_info *sbi) · line 1583
Quoted 2 lines
fs/f2fs/super.c +0
-0F2FS_OPTION (sbi).compress_ext_cnt =0 ;F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_ON ;This makes sense, but it's unclear to me why comparing the different compression algorithms is happening just now, after support for both LZO and LZ4 was already merged into mainline and now has to be supported forever. During review months ago, multiple people suggested that LZ4 is better than LZO, so there's not much reason to support LZO at all.
Agreed,
Jaegeuk, thoughts?
Let me remove lzo if you have no objection on this.
Thanks,
Quoted 4 lines
- Eric
.
Jaegeuk Kim
maintainerQuoted 30 lines · Chao Yu
Quoted 20 lines · Eric Biggers
Quoted 19 lines · Chao Yu
Use LZ4 as default compression algorithm, as compared to LZO, it shows almost the same compression ratio and much better decompression speed.
Signed-off-by Chao Yu <[email protected]>--- fs/f2fs/super.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)fs/f2fs/super.c +1
-1@@ -1577,7 +1577,7 @@ static void default_options(struct f2fs_sb_info *sbi)F2FS_OPTION (sbi).test_dummy_encryption = false;F2FS_OPTION (sbi).s_resuid =make_kuid (&init_user_ns,F2FS_DEF_RESUID );F2FS_OPTION (sbi).s_resgid =make_kgid (&init_user_ns,F2FS_DEF_RESGID ); -F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZO ; +F2FS_OPTION (sbi).compress_algorithm =COMPRESS_LZ4 ;F2FS_OPTION (sbi).compress_log_size =MIN_COMPRESS_LOG_SIZE ;Quoted 8 lines
fs/f2fs/super.c static void default_options(struct f2fs_sb_info *sbi) · line 1583
Quoted 2 lines
fs/f2fs/super.c +0
-0F2FS_OPTION (sbi).compress_ext_cnt =0 ;F2FS_OPTION (sbi).bggc_mode =BGGC_MODE_ON ;This makes sense, but it's unclear to me why comparing the different compression algorithms is happening just now, after support for both LZO and LZ4 was already merged into mainline and now has to be supported forever. During review months ago, multiple people suggested that LZ4 is better than LZO, so there's not much reason to support LZO at all.
Quoted 3 lines
Agreed,
Jaegeuk, thoughts?
Supporting LZO or whatever algorithms looks fine to me as long as kernel supports without huge maintenance effort. I think it'd be good to provide a way for users to compare several algorithms in whatever their ways.
And, unfortunately, I don't think we can remove LZO at this point, even for -rc.
Thanks,
Quoted 9 lines
Let me remove lzo if you have no objection on this.
Thanks,
Quoted 4 lines
- Eric
.