f2fs: compress: support compress level
Subsystems (2)
PATCH v8 1/1 f2fs: compress: support compress level
Expand 'compress_algorithm' mount option to accept parameter as format of <algorithm>:<level>, by this way, it gives a way to allow user to do more specified config on lz4 and zstd compression level, then f2fs compression can provide higher compress ratio.
In order to set compress level for lz4 algorithm, it needs to set CONFIG_LZ4HC_COMPRESS and CONFIG_F2FS_FS_LZ4HC config to enable lz4hc compress algorithm.
CR and performance number on lz4/lz4hc algorithm:
dd if=enwik9 of=compressed_file conv=fsync
Original blocks: 244382
lz4 lz4hc-9
compressed blocks 170647 163270
compress ratio 69.8% 66.8%
speed 16.4207 s, 60.9 MB/s 26.7299 s, 37.4 MB/s
compress ratio = after / before
---
v8:
- rebase on dev branch.
- cover LZ4HC_MEM_COMPRESS with CONFIG_F2FS_FS_LZ4HC
Documentation/filesystems/f2fs.rst | 5 +++ fs/f2fs/Kconfig | 10 +++++ fs/f2fs/compress.c | 41 +++++++++++++++-- fs/f2fs/f2fs.h | 9 ++++ fs/f2fs/super.c | 71 +++++++++++++++++++++++++++++- include/linux/f2fs_fs.h | 3 ++ 6 files changed, 134 insertions(+), 5 deletions(-)
Documentation/filesystems/f2fs.rst +5 -0
@@ -249,6 +249,11 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "enabl This space is reclaimed once checkpoint=enable. compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo", "lz4", "zstd" and "lzo-rle" algorithm. +compress_algorithm=%s:%d Control compress algorithm and its compress level, now, only + "lz4" and "zstd" support compress level config. + algorithm level range + lz4 3 - 16 + zstd 1 - 22 compress_log_size=%u Support configuring compress cluster size, the size will be 4KB * (1 << %u), 16KB is minimum size, also it's default size.
fs/f2fs/Kconfig +10 -0
@@ -119,6 +119,16 @@ config F2FS_FS_LZ4 help Support LZ4 compress algorithm, if unsure, say Y. +config F2FS_FS_LZ4HC + bool "LZ4HC compression support" + depends on F2FS_FS_COMPRESSION + depends on F2FS_FS_LZ4 + select LZ4HC_COMPRESS + default y + help + Support LZ4HC compress algorithm, LZ4HC has compatible on-disk + layout with LZ4, if unsure, say Y. + config F2FS_FS_ZSTD bool "ZSTD compression support" depends on F2FS_FS_COMPRESSION
fs/f2fs/compress.c +38 -3
64 lines not on this page · raw message
fs/f2fs/f2fs.h +9 -0
@@ -147,6 +147,7 @@ struct f2fs_mount_info {/* For compression */ unsigned char compress_algorithm;/* algorithm type */ unsigned char compress_log_size;/* cluster log size */ +unsigned char compress_level;/* compress level */ bool compress_chksum;/* compressed data chksum */ unsigned char compress_ext_cnt;/* extension count */ int compress_mode;/* compression mode */
@@ -734,6 +735,7 @@ struct f2fs_inode_info {atomic_t i_compr_blocks;/* # of compressed blocks */ unsigned char i_compress_algorithm;/* algorithm type */ unsigned char i_log_cluster_size;/* log of cluster size */ +unsigned char i_compress_level;/* compress level (lz4hc,zstd) */ unsigned short i_compress_flag;/* compress flag */ unsigned int i_cluster_size;/* cluster size */ };
@@ -1312,6 +1314,8 @@ struct compress_data {#define F2FS_COMPRESSED_PAGE_MAGIC 0xF5F2C000 +#define COMPRESS_LEVEL_OFFSET 8 +/* compress context */ struct compress_ctx {struct inode *inode;/* inode the context belong to */
@@ -3963,6 +3967,11 @@ static inline void set_compress_context(struct inode *inode) 1 << COMPRESS_CHKSUM : 0;F2FS_I (inode)->i_cluster_size =1 <<F2FS_I (inode)->i_log_cluster_size; +if (F2FS_I (inode)->i_compress_algorithm ==COMPRESS_LZ4 && +F2FS_OPTION (sbi).compress_level) +F2FS_I (inode)->i_compress_flag |= +F2FS_OPTION (sbi).compress_level << +COMPRESS_LEVEL_OFFSET ;F2FS_I (inode)->i_flags |=F2FS_COMPR_FL ;set_inode_flag (inode,FI_COMPRESSED_FILE );stat_inc_compr_inode (inode);
fs/f2fs/super.c +69 -2
97 lines not on this page · raw message
include/linux/f2fs_fs.h +3 -0
@@ -275,6 +275,9 @@ struct f2fs_inode {__u8 i_compress_algorithm;/* compress algorithm */ __u8 i_log_cluster_size;/* log of cluster size */ __le16 i_compress_flag;/* compress flag */ +/* 0 bit: chksum flag +* [10,15] bits: compress level +*/ __le32 i_extra_end[0 ];/* for attribute size calculation */ } __packed;__le32 i_addr[DEF_ADDRS_PER_INODE ];/* Pointers to data blocks */
Signature · 8 lines
2.29.2 _______________________________________________ Linux-f2fs-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel