* [PATCH v2] f2fs: compress: support zstd compress algorithm
@ 2020-03-03 9:46 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2020-03-03 9:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao, Chao Yu
Add zstd compress algorithm support, use "compress_algorithm=zstd"
mountoption to enable it.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
v2:
- avoid accessing invalid address
- introduce .{init,destroy}_{,de}compress_ctx callback functions.
Documentation/filesystems/f2fs.txt | 4 +-
fs/f2fs/Kconfig | 9 ++
fs/f2fs/compress.c | 167 +++++++++++++++++++++++++++++
fs/f2fs/f2fs.h | 5 +
fs/f2fs/super.c | 7 ++
include/trace/events/f2fs.h | 3 +-
6 files changed, 192 insertions(+), 3 deletions(-)
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
index 4eb3e2ddd00e..b1a66cf0e967 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -235,8 +235,8 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "en
hide up to all remaining free space. The actual space that
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"
- and "lz4" algorithm.
+compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo",
+ "lz4" and "zstd" 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.
diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig
index f0faada30f30..bb68d21e1f8c 100644
--- a/fs/f2fs/Kconfig
+++ b/fs/f2fs/Kconfig
@@ -118,3 +118,12 @@ config F2FS_FS_LZ4
default y
help
Support LZ4 compress algorithm, if unsure, say Y.
+
+config F2FS_FS_ZSTD
+ bool "ZSTD compression support"
+ depends on F2FS_FS_COMPRESSION
+ select ZSTD_COMPRESS
+ select ZSTD_DECOMPRESS
+ default y
+ help
+ Support ZSTD compress algorithm, if unsure, say Y.
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 6688fe091281..8a9691a1d1d5 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -11,6 +11,7 @@
#include <linux/backing-dev.h>
#include <linux/lzo.h>
#include <linux/lz4.h>
+#include <linux/zstd.h>
#include "f2fs.h"
#include "node.h"
@@ -293,6 +294,167 @@ static const struct f2fs_compress_ops f2fs_lz4_ops = {
};
#endif
+#ifdef CONFIG_F2FS_FS_ZSTD
+#define F2FS_ZSTD_DEFAULT_CLEVEL 1
+
+static int zstd_init_compress_ctx(struct compress_ctx *cc)
+{
+ ZSTD_parameters params;
+ ZSTD_CStream *stream;
+ void *workspace;
+ unsigned int workspace_size;
+
+ params = ZSTD_getParams(F2FS_ZSTD_DEFAULT_CLEVEL, cc->rlen, 0);
+ workspace_size = ZSTD_CStreamWorkspaceBound(params.cParams);
+
+ workspace = f2fs_kvmalloc(F2FS_I_SB(cc->inode),
+ workspace_size, GFP_NOFS);
+ if (!workspace)
+ return -ENOMEM;
+
+ stream = ZSTD_initCStream(params, 0, workspace, workspace_size);
+ if (!stream) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_initCStream failed\n",
+ KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
+ __func__);
+ kvfree(workspace);
+ return -EIO;
+ }
+
+ cc->private = workspace;
+ cc->private2 = stream;
+
+ cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE;
+ return 0;
+}
+
+static void zstd_destroy_compress_ctx(struct compress_ctx *cc)
+{
+ kvfree(cc->private);
+ cc->private = NULL;
+ cc->private2 = NULL;
+}
+
+static int zstd_compress_pages(struct compress_ctx *cc)
+{
+ ZSTD_CStream *stream = cc->private2;
+ ZSTD_inBuffer inbuf;
+ ZSTD_outBuffer outbuf;
+ int src_size = cc->rlen;
+ int dst_size = src_size - PAGE_SIZE - COMPRESS_HEADER_SIZE;
+ int ret;
+
+ inbuf.pos = 0;
+ inbuf.src = cc->rbuf;
+ inbuf.size = src_size;
+
+ outbuf.pos = 0;
+ outbuf.dst = cc->cbuf->cdata;
+ outbuf.size = dst_size;
+
+ ret = ZSTD_compressStream(stream, &outbuf, &inbuf);
+ if (ZSTD_isError(ret)) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_compressStream failed, ret: %d\n",
+ KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
+ __func__, ZSTD_getErrorCode(ret));
+ return -EIO;
+ }
+
+ ret = ZSTD_endStream(stream, &outbuf);
+ if (ZSTD_isError(ret)) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_endStream returned %d\n",
+ KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
+ __func__, ZSTD_getErrorCode(ret));
+ return -EIO;
+ }
+
+ cc->clen = outbuf.pos;
+ return 0;
+}
+
+static int zstd_init_decompress_ctx(struct decompress_io_ctx *dic)
+{
+ ZSTD_parameters params;
+ ZSTD_DStream *stream;
+ void *workspace;
+ unsigned int workspace_size;
+
+ params = ZSTD_getParams(F2FS_ZSTD_DEFAULT_CLEVEL, dic->clen, 0);
+ workspace_size = ZSTD_DStreamWorkspaceBound(MAX_COMPRESS_WINDOW_SIZE);
+
+ workspace = f2fs_kvmalloc(F2FS_I_SB(dic->inode),
+ workspace_size, GFP_NOFS);
+ if (!workspace)
+ return -ENOMEM;
+
+ stream = ZSTD_initDStream(MAX_COMPRESS_WINDOW_SIZE,
+ workspace, workspace_size);
+ if (!stream) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_initDStream failed\n",
+ KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id,
+ __func__);
+ kvfree(workspace);
+ return -EIO;
+ }
+
+ dic->private = workspace;
+ dic->private2 = stream;
+
+ return 0;
+}
+
+static void zstd_destroy_decompress_ctx(struct decompress_io_ctx *dic)
+{
+ kvfree(dic->private);
+ dic->private = NULL;
+ dic->private2 = NULL;
+}
+
+static int zstd_decompress_pages(struct decompress_io_ctx *dic)
+{
+ ZSTD_DStream *stream = dic->private2;
+ ZSTD_inBuffer inbuf;
+ ZSTD_outBuffer outbuf;
+ int ret;
+
+ inbuf.pos = 0;
+ inbuf.src = dic->cbuf->cdata;
+ inbuf.size = dic->clen;
+
+ outbuf.pos = 0;
+ outbuf.dst = dic->rbuf;
+ outbuf.size = dic->rlen;
+
+ ret = ZSTD_decompressStream(stream, &outbuf, &inbuf);
+ if (ZSTD_isError(ret)) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_compressStream failed, ret: %d\n",
+ KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id,
+ __func__, ZSTD_getErrorCode(ret));
+ return -EIO;
+ }
+
+ if (dic->rlen != outbuf.pos) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD invalid rlen:%zu, "
+ "expected:%lu\n", KERN_ERR,
+ F2FS_I_SB(dic->inode)->sb->s_id,
+ __func__, dic->rlen,
+ PAGE_SIZE << dic->log_cluster_size);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static const struct f2fs_compress_ops f2fs_zstd_ops = {
+ .init_compress_ctx = zstd_init_compress_ctx,
+ .destroy_compress_ctx = zstd_destroy_compress_ctx,
+ .compress_pages = zstd_compress_pages,
+ .init_decompress_ctx = zstd_init_decompress_ctx,
+ .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
+ .decompress_pages = zstd_decompress_pages,
+};
+#endif
+
static const struct f2fs_compress_ops *f2fs_cops[COMPRESS_MAX] = {
#ifdef CONFIG_F2FS_FS_LZO
&f2fs_lzo_ops,
@@ -304,6 +466,11 @@ static const struct f2fs_compress_ops *f2fs_cops[COMPRESS_MAX] = {
#else
NULL,
#endif
+#ifdef CONFIG_F2FS_FS_ZSTD
+ &f2fs_zstd_ops,
+#else
+ NULL,
+#endif
};
bool f2fs_is_compress_backend_ready(struct inode *inode)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 73fd5c97d504..09270854cce8 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1231,6 +1231,7 @@ enum fsync_mode {
enum compress_algorithm_type {
COMPRESS_LZO,
COMPRESS_LZ4,
+ COMPRESS_ZSTD,
COMPRESS_MAX,
};
@@ -1260,6 +1261,7 @@ struct compress_ctx {
size_t rlen; /* valid data length in rbuf */
size_t clen; /* valid data length in cbuf */
void *private; /* payload buffer for specified compression algorithm */
+ void *private2; /* extra payload buffer */
};
/* compress context for write IO path */
@@ -1289,11 +1291,14 @@ struct decompress_io_ctx {
size_t clen; /* valid data length in cbuf */
refcount_t ref; /* referrence count of compressed page */
bool failed; /* indicate IO error during decompression */
+ void *private; /* payload buffer for specified decompression algorithm */
+ void *private2; /* extra payload buffer */
};
#define NULL_CLUSTER ((unsigned int)(~0))
#define MIN_COMPRESS_LOG_SIZE 2
#define MAX_COMPRESS_LOG_SIZE 8
+#define MAX_COMPRESS_WINDOW_SIZE ((PAGE_SIZE) << MAX_COMPRESS_LOG_SIZE)
struct f2fs_sb_info {
struct super_block *sb; /* pointer to VFS super block */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9f435191f1e5..db3a63f7c769 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -829,6 +829,10 @@ static int parse_options(struct super_block *sb, char *options)
!strcmp(name, "lz4")) {
F2FS_OPTION(sbi).compress_algorithm =
COMPRESS_LZ4;
+ } else if (strlen(name) == 4 &&
+ !strcmp(name, "zstd")) {
+ F2FS_OPTION(sbi).compress_algorithm =
+ COMPRESS_ZSTD;
} else {
kfree(name);
return -EINVAL;
@@ -1419,6 +1423,9 @@ static inline void f2fs_show_compress_options(struct seq_file *seq,
case COMPRESS_LZ4:
algtype = "lz4";
break;
+ case COMPRESS_ZSTD:
+ algtype = "zstd";
+ break;
}
seq_printf(seq, ",compress_algorithm=%s", algtype);
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 67a97838c2a0..d97adfc327f0 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -153,7 +153,8 @@ TRACE_DEFINE_ENUM(CP_PAUSE);
#define show_compress_algorithm(type) \
__print_symbolic(type, \
{ COMPRESS_LZO, "LZO" }, \
- { COMPRESS_LZ4, "LZ4" })
+ { COMPRESS_LZ4, "LZ4" }, \
+ { COMPRESS_ZSTD, "ZSTD" })
struct f2fs_sb_info;
struct f2fs_io_info;
--
2.18.0.rc1
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [f2fs-dev] [PATCH v2] f2fs: compress: support zstd compress algorithm
@ 2020-03-03 9:46 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2020-03-03 9:46 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
Add zstd compress algorithm support, use "compress_algorithm=zstd"
mountoption to enable it.
Signed-off-by: Chao Yu <yuchao0@huawei.com>
---
v2:
- avoid accessing invalid address
- introduce .{init,destroy}_{,de}compress_ctx callback functions.
Documentation/filesystems/f2fs.txt | 4 +-
fs/f2fs/Kconfig | 9 ++
fs/f2fs/compress.c | 167 +++++++++++++++++++++++++++++
fs/f2fs/f2fs.h | 5 +
fs/f2fs/super.c | 7 ++
include/trace/events/f2fs.h | 3 +-
6 files changed, 192 insertions(+), 3 deletions(-)
diff --git a/Documentation/filesystems/f2fs.txt b/Documentation/filesystems/f2fs.txt
index 4eb3e2ddd00e..b1a66cf0e967 100644
--- a/Documentation/filesystems/f2fs.txt
+++ b/Documentation/filesystems/f2fs.txt
@@ -235,8 +235,8 @@ checkpoint=%s[:%u[%]] Set to "disable" to turn off checkpointing. Set to "en
hide up to all remaining free space. The actual space that
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"
- and "lz4" algorithm.
+compress_algorithm=%s Control compress algorithm, currently f2fs supports "lzo",
+ "lz4" and "zstd" 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.
diff --git a/fs/f2fs/Kconfig b/fs/f2fs/Kconfig
index f0faada30f30..bb68d21e1f8c 100644
--- a/fs/f2fs/Kconfig
+++ b/fs/f2fs/Kconfig
@@ -118,3 +118,12 @@ config F2FS_FS_LZ4
default y
help
Support LZ4 compress algorithm, if unsure, say Y.
+
+config F2FS_FS_ZSTD
+ bool "ZSTD compression support"
+ depends on F2FS_FS_COMPRESSION
+ select ZSTD_COMPRESS
+ select ZSTD_DECOMPRESS
+ default y
+ help
+ Support ZSTD compress algorithm, if unsure, say Y.
diff --git a/fs/f2fs/compress.c b/fs/f2fs/compress.c
index 6688fe091281..8a9691a1d1d5 100644
--- a/fs/f2fs/compress.c
+++ b/fs/f2fs/compress.c
@@ -11,6 +11,7 @@
#include <linux/backing-dev.h>
#include <linux/lzo.h>
#include <linux/lz4.h>
+#include <linux/zstd.h>
#include "f2fs.h"
#include "node.h"
@@ -293,6 +294,167 @@ static const struct f2fs_compress_ops f2fs_lz4_ops = {
};
#endif
+#ifdef CONFIG_F2FS_FS_ZSTD
+#define F2FS_ZSTD_DEFAULT_CLEVEL 1
+
+static int zstd_init_compress_ctx(struct compress_ctx *cc)
+{
+ ZSTD_parameters params;
+ ZSTD_CStream *stream;
+ void *workspace;
+ unsigned int workspace_size;
+
+ params = ZSTD_getParams(F2FS_ZSTD_DEFAULT_CLEVEL, cc->rlen, 0);
+ workspace_size = ZSTD_CStreamWorkspaceBound(params.cParams);
+
+ workspace = f2fs_kvmalloc(F2FS_I_SB(cc->inode),
+ workspace_size, GFP_NOFS);
+ if (!workspace)
+ return -ENOMEM;
+
+ stream = ZSTD_initCStream(params, 0, workspace, workspace_size);
+ if (!stream) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_initCStream failed\n",
+ KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
+ __func__);
+ kvfree(workspace);
+ return -EIO;
+ }
+
+ cc->private = workspace;
+ cc->private2 = stream;
+
+ cc->clen = cc->rlen - PAGE_SIZE - COMPRESS_HEADER_SIZE;
+ return 0;
+}
+
+static void zstd_destroy_compress_ctx(struct compress_ctx *cc)
+{
+ kvfree(cc->private);
+ cc->private = NULL;
+ cc->private2 = NULL;
+}
+
+static int zstd_compress_pages(struct compress_ctx *cc)
+{
+ ZSTD_CStream *stream = cc->private2;
+ ZSTD_inBuffer inbuf;
+ ZSTD_outBuffer outbuf;
+ int src_size = cc->rlen;
+ int dst_size = src_size - PAGE_SIZE - COMPRESS_HEADER_SIZE;
+ int ret;
+
+ inbuf.pos = 0;
+ inbuf.src = cc->rbuf;
+ inbuf.size = src_size;
+
+ outbuf.pos = 0;
+ outbuf.dst = cc->cbuf->cdata;
+ outbuf.size = dst_size;
+
+ ret = ZSTD_compressStream(stream, &outbuf, &inbuf);
+ if (ZSTD_isError(ret)) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_compressStream failed, ret: %d\n",
+ KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
+ __func__, ZSTD_getErrorCode(ret));
+ return -EIO;
+ }
+
+ ret = ZSTD_endStream(stream, &outbuf);
+ if (ZSTD_isError(ret)) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_endStream returned %d\n",
+ KERN_ERR, F2FS_I_SB(cc->inode)->sb->s_id,
+ __func__, ZSTD_getErrorCode(ret));
+ return -EIO;
+ }
+
+ cc->clen = outbuf.pos;
+ return 0;
+}
+
+static int zstd_init_decompress_ctx(struct decompress_io_ctx *dic)
+{
+ ZSTD_parameters params;
+ ZSTD_DStream *stream;
+ void *workspace;
+ unsigned int workspace_size;
+
+ params = ZSTD_getParams(F2FS_ZSTD_DEFAULT_CLEVEL, dic->clen, 0);
+ workspace_size = ZSTD_DStreamWorkspaceBound(MAX_COMPRESS_WINDOW_SIZE);
+
+ workspace = f2fs_kvmalloc(F2FS_I_SB(dic->inode),
+ workspace_size, GFP_NOFS);
+ if (!workspace)
+ return -ENOMEM;
+
+ stream = ZSTD_initDStream(MAX_COMPRESS_WINDOW_SIZE,
+ workspace, workspace_size);
+ if (!stream) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_initDStream failed\n",
+ KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id,
+ __func__);
+ kvfree(workspace);
+ return -EIO;
+ }
+
+ dic->private = workspace;
+ dic->private2 = stream;
+
+ return 0;
+}
+
+static void zstd_destroy_decompress_ctx(struct decompress_io_ctx *dic)
+{
+ kvfree(dic->private);
+ dic->private = NULL;
+ dic->private2 = NULL;
+}
+
+static int zstd_decompress_pages(struct decompress_io_ctx *dic)
+{
+ ZSTD_DStream *stream = dic->private2;
+ ZSTD_inBuffer inbuf;
+ ZSTD_outBuffer outbuf;
+ int ret;
+
+ inbuf.pos = 0;
+ inbuf.src = dic->cbuf->cdata;
+ inbuf.size = dic->clen;
+
+ outbuf.pos = 0;
+ outbuf.dst = dic->rbuf;
+ outbuf.size = dic->rlen;
+
+ ret = ZSTD_decompressStream(stream, &outbuf, &inbuf);
+ if (ZSTD_isError(ret)) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD_compressStream failed, ret: %d\n",
+ KERN_ERR, F2FS_I_SB(dic->inode)->sb->s_id,
+ __func__, ZSTD_getErrorCode(ret));
+ return -EIO;
+ }
+
+ if (dic->rlen != outbuf.pos) {
+ printk_ratelimited("%sF2FS-fs (%s): %s ZSTD invalid rlen:%zu, "
+ "expected:%lu\n", KERN_ERR,
+ F2FS_I_SB(dic->inode)->sb->s_id,
+ __func__, dic->rlen,
+ PAGE_SIZE << dic->log_cluster_size);
+ return -EIO;
+ }
+
+ return 0;
+}
+
+static const struct f2fs_compress_ops f2fs_zstd_ops = {
+ .init_compress_ctx = zstd_init_compress_ctx,
+ .destroy_compress_ctx = zstd_destroy_compress_ctx,
+ .compress_pages = zstd_compress_pages,
+ .init_decompress_ctx = zstd_init_decompress_ctx,
+ .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
+ .decompress_pages = zstd_decompress_pages,
+};
+#endif
+
static const struct f2fs_compress_ops *f2fs_cops[COMPRESS_MAX] = {
#ifdef CONFIG_F2FS_FS_LZO
&f2fs_lzo_ops,
@@ -304,6 +466,11 @@ static const struct f2fs_compress_ops *f2fs_cops[COMPRESS_MAX] = {
#else
NULL,
#endif
+#ifdef CONFIG_F2FS_FS_ZSTD
+ &f2fs_zstd_ops,
+#else
+ NULL,
+#endif
};
bool f2fs_is_compress_backend_ready(struct inode *inode)
diff --git a/fs/f2fs/f2fs.h b/fs/f2fs/f2fs.h
index 73fd5c97d504..09270854cce8 100644
--- a/fs/f2fs/f2fs.h
+++ b/fs/f2fs/f2fs.h
@@ -1231,6 +1231,7 @@ enum fsync_mode {
enum compress_algorithm_type {
COMPRESS_LZO,
COMPRESS_LZ4,
+ COMPRESS_ZSTD,
COMPRESS_MAX,
};
@@ -1260,6 +1261,7 @@ struct compress_ctx {
size_t rlen; /* valid data length in rbuf */
size_t clen; /* valid data length in cbuf */
void *private; /* payload buffer for specified compression algorithm */
+ void *private2; /* extra payload buffer */
};
/* compress context for write IO path */
@@ -1289,11 +1291,14 @@ struct decompress_io_ctx {
size_t clen; /* valid data length in cbuf */
refcount_t ref; /* referrence count of compressed page */
bool failed; /* indicate IO error during decompression */
+ void *private; /* payload buffer for specified decompression algorithm */
+ void *private2; /* extra payload buffer */
};
#define NULL_CLUSTER ((unsigned int)(~0))
#define MIN_COMPRESS_LOG_SIZE 2
#define MAX_COMPRESS_LOG_SIZE 8
+#define MAX_COMPRESS_WINDOW_SIZE ((PAGE_SIZE) << MAX_COMPRESS_LOG_SIZE)
struct f2fs_sb_info {
struct super_block *sb; /* pointer to VFS super block */
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c
index 9f435191f1e5..db3a63f7c769 100644
--- a/fs/f2fs/super.c
+++ b/fs/f2fs/super.c
@@ -829,6 +829,10 @@ static int parse_options(struct super_block *sb, char *options)
!strcmp(name, "lz4")) {
F2FS_OPTION(sbi).compress_algorithm =
COMPRESS_LZ4;
+ } else if (strlen(name) == 4 &&
+ !strcmp(name, "zstd")) {
+ F2FS_OPTION(sbi).compress_algorithm =
+ COMPRESS_ZSTD;
} else {
kfree(name);
return -EINVAL;
@@ -1419,6 +1423,9 @@ static inline void f2fs_show_compress_options(struct seq_file *seq,
case COMPRESS_LZ4:
algtype = "lz4";
break;
+ case COMPRESS_ZSTD:
+ algtype = "zstd";
+ break;
}
seq_printf(seq, ",compress_algorithm=%s", algtype);
diff --git a/include/trace/events/f2fs.h b/include/trace/events/f2fs.h
index 67a97838c2a0..d97adfc327f0 100644
--- a/include/trace/events/f2fs.h
+++ b/include/trace/events/f2fs.h
@@ -153,7 +153,8 @@ TRACE_DEFINE_ENUM(CP_PAUSE);
#define show_compress_algorithm(type) \
__print_symbolic(type, \
{ COMPRESS_LZO, "LZO" }, \
- { COMPRESS_LZ4, "LZ4" })
+ { COMPRESS_LZ4, "LZ4" }, \
+ { COMPRESS_ZSTD, "ZSTD" })
struct f2fs_sb_info;
struct f2fs_io_info;
--
2.18.0.rc1
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH v2] f2fs: compress: support zstd compress algorithm
2020-03-03 9:46 ` [f2fs-dev] " Chao Yu
(?)
@ 2020-03-03 21:10 ` kbuild test robot
-1 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2020-03-03 21:10 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3240 bytes --]
Hi Chao,
I love your patch! Yet something to improve:
[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on v5.6-rc4 next-20200303]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Chao-Yu/f2fs-compress-support-zstd-compress-algorithm/20200304-020312
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-randconfig-s1-20200303 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
fs/f2fs/compress.c:450:3: error: 'const struct f2fs_compress_ops' has no member named 'init_decompress_ctx'; did you mean 'init_compress_ctx'?
.init_decompress_ctx = zstd_init_decompress_ctx,
^~~~~~~~~~~~~~~~~~~
init_compress_ctx
>> fs/f2fs/compress.c:450:25: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
.init_decompress_ctx = zstd_init_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/compress.c:450:25: note: (near initialization for 'f2fs_zstd_ops')
fs/f2fs/compress.c:450:25: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
fs/f2fs/compress.c:450:25: note: (near initialization for 'f2fs_zstd_ops.destroy_compress_ctx')
fs/f2fs/compress.c:451:3: error: 'const struct f2fs_compress_ops' has no member named 'destroy_decompress_ctx'; did you mean 'destroy_compress_ctx'?
.destroy_decompress_ctx = zstd_destroy_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~
destroy_compress_ctx
fs/f2fs/compress.c:451:28: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
.destroy_decompress_ctx = zstd_destroy_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/f2fs/compress.c:451:28: note: (near initialization for 'f2fs_zstd_ops')
fs/f2fs/compress.c:451:28: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
fs/f2fs/compress.c:451:28: note: (near initialization for 'f2fs_zstd_ops.decompress_pages')
cc1: some warnings being treated as errors
vim +450 fs/f2fs/compress.c
445
446 static const struct f2fs_compress_ops f2fs_zstd_ops = {
447 .init_compress_ctx = zstd_init_compress_ctx,
448 .destroy_compress_ctx = zstd_destroy_compress_ctx,
449 .compress_pages = zstd_compress_pages,
> 450 .init_decompress_ctx = zstd_init_decompress_ctx,
451 .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
452 .decompress_pages = zstd_decompress_pages,
453 };
454 #endif
455
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 46606 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] f2fs: compress: support zstd compress algorithm
2020-03-03 9:46 ` [f2fs-dev] " Chao Yu
(?)
(?)
@ 2020-03-03 21:31 ` kbuild test robot
-1 siblings, 0 replies; 10+ messages in thread
From: kbuild test robot @ 2020-03-03 21:31 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3190 bytes --]
Hi Chao,
I love your patch! Yet something to improve:
[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on v5.6-rc4 next-20200303]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Chao-Yu/f2fs-compress-support-zstd-compress-algorithm/20200304-020312
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-randconfig-g003-20200303 (attached as .config)
compiler: gcc-7 (Debian 7.5.0-5) 7.5.0
reproduce:
# save the attached .config to linux build tree
make ARCH=x86_64
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
fs//f2fs/compress.c:450:3: error: 'const struct f2fs_compress_ops' has no member named 'init_decompress_ctx'; did you mean 'init_compress_ctx'?
.init_decompress_ctx = zstd_init_decompress_ctx,
^~~~~~~~~~~~~~~~~~~
init_compress_ctx
fs//f2fs/compress.c:450:25: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
.init_decompress_ctx = zstd_init_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~~~
fs//f2fs/compress.c:450:25: note: (near initialization for 'f2fs_zstd_ops')
>> fs//f2fs/compress.c:450:25: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
fs//f2fs/compress.c:450:25: note: (near initialization for 'f2fs_zstd_ops.init_compress_ctx')
fs//f2fs/compress.c:451:3: error: 'const struct f2fs_compress_ops' has no member named 'destroy_decompress_ctx'; did you mean 'destroy_compress_ctx'?
.destroy_decompress_ctx = zstd_destroy_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~
destroy_compress_ctx
fs//f2fs/compress.c:451:28: error: positional initialization of field in 'struct' declared with 'designated_init' attribute [-Werror=designated-init]
.destroy_decompress_ctx = zstd_destroy_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
fs//f2fs/compress.c:451:28: note: (near initialization for 'f2fs_zstd_ops')
fs//f2fs/compress.c:451:28: warning: excess elements in struct initializer
fs//f2fs/compress.c:451:28: note: (near initialization for 'f2fs_zstd_ops')
cc1: some warnings being treated as errors
vim +450 fs//f2fs/compress.c
445
446 static const struct f2fs_compress_ops f2fs_zstd_ops = {
447 .init_compress_ctx = zstd_init_compress_ctx,
448 .destroy_compress_ctx = zstd_destroy_compress_ctx,
449 .compress_pages = zstd_compress_pages,
> 450 .init_decompress_ctx = zstd_init_decompress_ctx,
451 .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
452 .decompress_pages = zstd_decompress_pages,
453 };
454 #endif
455
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38246 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] f2fs: compress: support zstd compress algorithm
2020-03-03 9:46 ` [f2fs-dev] " Chao Yu
` (2 preceding siblings ...)
(?)
@ 2020-03-04 1:00 ` kbuild test robot
2020-03-04 3:08 ` Chao Yu
-1 siblings, 1 reply; 10+ messages in thread
From: kbuild test robot @ 2020-03-04 1:00 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3258 bytes --]
Hi Chao,
I love your patch! Yet something to improve:
[auto build test ERROR on f2fs/dev-test]
[also build test ERROR on v5.6-rc4 next-20200303]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
url: https://github.com/0day-ci/linux/commits/Chao-Yu/f2fs-compress-support-zstd-compress-algorithm/20200304-020312
base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
config: x86_64-allyesconfig (attached as .config)
compiler: clang version 11.0.0 (git://gitmirror/llvm_project 211fb91f1067ecdf7c0b8a019bcf76554d813129)
reproduce:
# FIXME the reproduce steps for clang is not ready yet
If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>
All errors (new ones prefixed by >>):
>> fs/f2fs/compress.c:450:3: error: field designator 'init_decompress_ctx' does not refer to any field in type 'const struct f2fs_compress_ops'; did you mean 'init_compress_ctx'?
.init_decompress_ctx = zstd_init_decompress_ctx,
^~~~~~~~~~~~~~~~~~~
init_compress_ctx
fs/f2fs/compress.c:21:8: note: 'init_compress_ctx' declared here
int (*init_compress_ctx)(struct compress_ctx *cc);
^
>> fs/f2fs/compress.c:450:25: error: incompatible function pointer types initializing 'int (*)(struct compress_ctx *)' with an expression of type 'int (struct decompress_io_ctx *)' [-Werror,-Wincompatible-function-pointer-types]
.init_decompress_ctx = zstd_init_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~~~
>> fs/f2fs/compress.c:451:3: error: field designator 'destroy_decompress_ctx' does not refer to any field in type 'const struct f2fs_compress_ops'; did you mean 'destroy_compress_ctx'?
.destroy_decompress_ctx = zstd_destroy_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~
destroy_compress_ctx
fs/f2fs/compress.c:22:9: note: 'destroy_compress_ctx' declared here
void (*destroy_compress_ctx)(struct compress_ctx *cc);
^
>> fs/f2fs/compress.c:451:28: error: incompatible function pointer types initializing 'void (*)(struct compress_ctx *)' with an expression of type 'void (struct decompress_io_ctx *)' [-Werror,-Wincompatible-function-pointer-types]
.destroy_decompress_ctx = zstd_destroy_decompress_ctx,
^~~~~~~~~~~~~~~~~~~~~~~~~~~
4 errors generated.
vim +450 fs/f2fs/compress.c
445
446 static const struct f2fs_compress_ops f2fs_zstd_ops = {
447 .init_compress_ctx = zstd_init_compress_ctx,
448 .destroy_compress_ctx = zstd_destroy_compress_ctx,
449 .compress_pages = zstd_compress_pages,
> 450 .init_decompress_ctx = zstd_init_decompress_ctx,
> 451 .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
452 .decompress_pages = zstd_decompress_pages,
453 };
454 #endif
455
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 72235 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] f2fs: compress: support zstd compress algorithm
2020-03-04 1:00 ` kbuild test robot
@ 2020-03-04 3:08 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2020-03-04 3:08 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3651 bytes --]
Hi,
Thanks for the report.
I guess we need to apply below patches first:
[PATCH 1/2] f2fs: compress: fix to call missing destroy_compress_ctx()
[PATCH 2/2] f2fs: compress: add .{init,destroy}_decompress_ctx callback
On 2020/3/4 9:00, kbuild test robot wrote:
> Hi Chao,
>
> I love your patch! Yet something to improve:
>
> [auto build test ERROR on f2fs/dev-test]
> [also build test ERROR on v5.6-rc4 next-20200303]
> [if your patch is applied to the wrong git tree, please drop us a note to help
> improve the system. BTW, we also suggest to use '--base' option to specify the
> base tree in git format-patch, please see https://stackoverflow.com/a/37406982]
>
> url: https://github.com/0day-ci/linux/commits/Chao-Yu/f2fs-compress-support-zstd-compress-algorithm/20200304-020312
> base: https://git.kernel.org/pub/scm/linux/kernel/git/jaegeuk/f2fs.git dev-test
> config: x86_64-allyesconfig (attached as .config)
> compiler: clang version 11.0.0 (git://gitmirror/llvm_project 211fb91f1067ecdf7c0b8a019bcf76554d813129)
> reproduce:
> # FIXME the reproduce steps for clang is not ready yet
>
> If you fix the issue, kindly add following tag
> Reported-by: kbuild test robot <lkp@intel.com>
>
> All errors (new ones prefixed by >>):
>
>>> fs/f2fs/compress.c:450:3: error: field designator 'init_decompress_ctx' does not refer to any field in type 'const struct f2fs_compress_ops'; did you mean 'init_compress_ctx'?
> .init_decompress_ctx = zstd_init_decompress_ctx,
> ^~~~~~~~~~~~~~~~~~~
> init_compress_ctx
> fs/f2fs/compress.c:21:8: note: 'init_compress_ctx' declared here
> int (*init_compress_ctx)(struct compress_ctx *cc);
> ^
>>> fs/f2fs/compress.c:450:25: error: incompatible function pointer types initializing 'int (*)(struct compress_ctx *)' with an expression of type 'int (struct decompress_io_ctx *)' [-Werror,-Wincompatible-function-pointer-types]
> .init_decompress_ctx = zstd_init_decompress_ctx,
> ^~~~~~~~~~~~~~~~~~~~~~~~
>>> fs/f2fs/compress.c:451:3: error: field designator 'destroy_decompress_ctx' does not refer to any field in type 'const struct f2fs_compress_ops'; did you mean 'destroy_compress_ctx'?
> .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
> ^~~~~~~~~~~~~~~~~~~~~~
> destroy_compress_ctx
> fs/f2fs/compress.c:22:9: note: 'destroy_compress_ctx' declared here
> void (*destroy_compress_ctx)(struct compress_ctx *cc);
> ^
>>> fs/f2fs/compress.c:451:28: error: incompatible function pointer types initializing 'void (*)(struct compress_ctx *)' with an expression of type 'void (struct decompress_io_ctx *)' [-Werror,-Wincompatible-function-pointer-types]
> .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
> ^~~~~~~~~~~~~~~~~~~~~~~~~~~
> 4 errors generated.
>
> vim +450 fs/f2fs/compress.c
>
> 445
> 446 static const struct f2fs_compress_ops f2fs_zstd_ops = {
> 447 .init_compress_ctx = zstd_init_compress_ctx,
> 448 .destroy_compress_ctx = zstd_destroy_compress_ctx,
> 449 .compress_pages = zstd_compress_pages,
> > 450 .init_decompress_ctx = zstd_init_decompress_ctx,
> > 451 .destroy_decompress_ctx = zstd_destroy_decompress_ctx,
> 452 .decompress_pages = zstd_decompress_pages,
> 453 };
> 454 #endif
> 455
>
> ---
> 0-DAY CI Kernel Test Service, Intel Corporation
> https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] f2fs: compress: support zstd compress algorithm
2020-03-03 9:46 ` [f2fs-dev] " Chao Yu
@ 2020-03-24 9:49 ` Chao Yu
-1 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2020-03-24 9:49 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-f2fs-devel, linux-kernel, chao
Hi Jaegeuk,
On 2020/3/3 17:46, Chao Yu wrote:
> Add zstd compress algorithm support, use "compress_algorithm=zstd"
> mountoption to enable it.
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> v2:
> - avoid accessing invalid address
> - introduce .{init,destroy}_{,de}compress_ctx callback functions.
I guess we merged related patches with wrong sequence as this patch
depends on ("f2fs: compress: add .{init,destroy}_decompress_ctx callback").
Thanks,
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: compress: support zstd compress algorithm
@ 2020-03-24 9:49 ` Chao Yu
0 siblings, 0 replies; 10+ messages in thread
From: Chao Yu @ 2020-03-24 9:49 UTC (permalink / raw)
To: jaegeuk; +Cc: linux-kernel, linux-f2fs-devel
Hi Jaegeuk,
On 2020/3/3 17:46, Chao Yu wrote:
> Add zstd compress algorithm support, use "compress_algorithm=zstd"
> mountoption to enable it.
>
> Signed-off-by: Chao Yu <yuchao0@huawei.com>
> ---
> v2:
> - avoid accessing invalid address
> - introduce .{init,destroy}_{,de}compress_ctx callback functions.
I guess we merged related patches with wrong sequence as this patch
depends on ("f2fs: compress: add .{init,destroy}_decompress_ctx callback").
Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH v2] f2fs: compress: support zstd compress algorithm
2020-03-24 9:49 ` [f2fs-dev] " Chao Yu
@ 2020-03-24 15:39 ` Jaegeuk Kim
-1 siblings, 0 replies; 10+ messages in thread
From: Jaegeuk Kim @ 2020-03-24 15:39 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-f2fs-devel, linux-kernel, chao
On 03/24, Chao Yu wrote:
> Hi Jaegeuk,
>
> On 2020/3/3 17:46, Chao Yu wrote:
> > Add zstd compress algorithm support, use "compress_algorithm=zstd"
> > mountoption to enable it.
> >
> > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > ---
> > v2:
> > - avoid accessing invalid address
> > - introduce .{init,destroy}_{,de}compress_ctx callback functions.
>
> I guess we merged related patches with wrong sequence as this patch
> depends on ("f2fs: compress: add .{init,destroy}_decompress_ctx callback").
Done.
>
> Thanks,
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: compress: support zstd compress algorithm
@ 2020-03-24 15:39 ` Jaegeuk Kim
0 siblings, 0 replies; 10+ messages in thread
From: Jaegeuk Kim @ 2020-03-24 15:39 UTC (permalink / raw)
To: Chao Yu; +Cc: linux-kernel, linux-f2fs-devel
On 03/24, Chao Yu wrote:
> Hi Jaegeuk,
>
> On 2020/3/3 17:46, Chao Yu wrote:
> > Add zstd compress algorithm support, use "compress_algorithm=zstd"
> > mountoption to enable it.
> >
> > Signed-off-by: Chao Yu <yuchao0@huawei.com>
> > ---
> > v2:
> > - avoid accessing invalid address
> > - introduce .{init,destroy}_{,de}compress_ctx callback functions.
>
> I guess we merged related patches with wrong sequence as this patch
> depends on ("f2fs: compress: add .{init,destroy}_decompress_ctx callback").
Done.
>
> Thanks,
_______________________________________________
Linux-f2fs-devel mailing list
Linux-f2fs-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-f2fs-devel
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-03-24 15:40 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-03 9:46 [PATCH v2] f2fs: compress: support zstd compress algorithm Chao Yu
2020-03-03 9:46 ` [f2fs-dev] " Chao Yu
2020-03-03 21:10 ` kbuild test robot
2020-03-03 21:31 ` kbuild test robot
2020-03-04 1:00 ` kbuild test robot
2020-03-04 3:08 ` Chao Yu
2020-03-24 9:49 ` Chao Yu
2020-03-24 9:49 ` [f2fs-dev] " Chao Yu
2020-03-24 15:39 ` Jaegeuk Kim
2020-03-24 15:39 ` [f2fs-dev] " Jaegeuk Kim
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.