mirror of
https://github.com/AuxXxilium/linux_dsm_epyc7002.git
synced 2024-11-24 00:10:51 +07:00
f2fs: compress: support lzo-rle compress algorithm
LZO-RLE extension (run length encoding) was introduced to improve performance of LZO algorithm in scenario of data contains many zeros, zram has changed to use this extended algorithm by default, this patch adds to support this algorithm extension, to enable this extension, it needs to enable F2FS_FS_LZO and F2FS_FS_LZORLE config, and specifies "compress_algorithm=lzo-rle" mountoption. Signed-off-by: Chao Yu <yuchao0@huawei.com> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
This commit is contained in:
parent
5e6bbde959
commit
6d92b20103
@ -244,7 +244,7 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "enabl
|
||||
would be unusable can be viewed at /sys/fs/f2fs/<disk>/unusable
|
||||
This space is reclaimed once checkpoint=enable.
|
||||
compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo",
|
||||
"lz4" and "zstd" algorithm.
|
||||
"lz4", "zstd" and "lzo-rle" algorithm.
|
||||
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.
|
||||
|
@ -127,3 +127,13 @@ config F2FS_FS_ZSTD
|
||||
default y
|
||||
help
|
||||
Support ZSTD compress algorithm, if unsure, say Y.
|
||||
|
||||
config F2FS_FS_LZORLE
|
||||
bool "LZO-RLE compression support"
|
||||
depends on F2FS_FS_COMPRESSION
|
||||
depends on F2FS_FS_LZO
|
||||
select LZO_COMPRESS
|
||||
select LZO_DECOMPRESS
|
||||
default y
|
||||
help
|
||||
Support LZO-RLE compress algorithm, if unsure, say Y.
|
||||
|
@ -442,6 +442,31 @@ static const struct f2fs_compress_ops f2fs_zstd_ops = {
|
||||
};
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_F2FS_FS_LZO
|
||||
#ifdef CONFIG_F2FS_FS_LZORLE
|
||||
static int lzorle_compress_pages(struct compress_ctx *cc)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = lzorle1x_1_compress(cc->rbuf, cc->rlen, cc->cbuf->cdata,
|
||||
&cc->clen, cc->private);
|
||||
if (ret != LZO_E_OK) {
|
||||
printk_ratelimited("%sF2FS-fs (%s): lzo-rle compress failed, ret:%d\n",
|
||||
KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id, ret);
|
||||
return -EIO;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct f2fs_compress_ops f2fs_lzorle_ops = {
|
||||
.init_compress_ctx = lzo_init_compress_ctx,
|
||||
.destroy_compress_ctx = lzo_destroy_compress_ctx,
|
||||
.compress_pages = lzorle_compress_pages,
|
||||
.decompress_pages = lzo_decompress_pages,
|
||||
};
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static const struct f2fs_compress_ops *f2fs_cops[COMPRESS_MAX] = {
|
||||
#ifdef CONFIG_F2FS_FS_LZO
|
||||
&f2fs_lzo_ops,
|
||||
@ -458,6 +483,11 @@ static const struct f2fs_compress_ops *f2fs_cops[COMPRESS_MAX] = {
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
#if defined(CONFIG_F2FS_FS_LZO) && defined(CONFIG_F2FS_FS_LZORLE)
|
||||
&f2fs_lzorle_ops,
|
||||
#else
|
||||
NULL,
|
||||
#endif
|
||||
};
|
||||
|
||||
bool f2fs_is_compress_backend_ready(struct inode *inode)
|
||||
|
@ -1281,6 +1281,7 @@ enum compress_algorithm_type {
|
||||
COMPRESS_LZO,
|
||||
COMPRESS_LZ4,
|
||||
COMPRESS_ZSTD,
|
||||
COMPRESS_LZORLE,
|
||||
COMPRESS_MAX,
|
||||
};
|
||||
|
||||
|
@ -822,6 +822,9 @@ static int parse_options(struct super_block *sb, char *options)
|
||||
} else if (!strcmp(name, "zstd")) {
|
||||
F2FS_OPTION(sbi).compress_algorithm =
|
||||
COMPRESS_ZSTD;
|
||||
} else if (!strcmp(name, "lzo-rle")) {
|
||||
F2FS_OPTION(sbi).compress_algorithm =
|
||||
COMPRESS_LZORLE;
|
||||
} else {
|
||||
kfree(name);
|
||||
return -EINVAL;
|
||||
@ -1415,6 +1418,9 @@ static inline void f2fs_show_compress_options(struct seq_file *seq,
|
||||
case COMPRESS_ZSTD:
|
||||
algtype = "zstd";
|
||||
break;
|
||||
case COMPRESS_LZORLE:
|
||||
algtype = "lzo-rle";
|
||||
break;
|
||||
}
|
||||
seq_printf(seq, ",compress_algorithm=%s", algtype);
|
||||
|
||||
|
@ -154,7 +154,8 @@ TRACE_DEFINE_ENUM(CP_PAUSE);
|
||||
__print_symbolic(type, \
|
||||
{ COMPRESS_LZO, "LZO" }, \
|
||||
{ COMPRESS_LZ4, "LZ4" }, \
|
||||
{ COMPRESS_ZSTD, "ZSTD" })
|
||||
{ COMPRESS_ZSTD, "ZSTD" }, \
|
||||
{ COMPRESS_LZORLE, "LZO-RLE" })
|
||||
|
||||
struct f2fs_sb_info;
|
||||
struct f2fs_io_info;
|
||||
|
Loading…
Reference in New Issue
Block a user