[PATCH v2 7/9] squashfs: zstd: Switch to the zstd-1.4.6 API

From: Nick Terrell
Date: Tue Sep 22 2020 - 17:06:55 EST


From: Nick Terrell <terrelln@xxxxxx>

Move away from the compatibility wrapper to the zstd-1.4.6 API. This
code is functionally equivalent.

Signed-off-by: Nick Terrell <terrelln@xxxxxx>
---
fs/squashfs/zstd_wrapper.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/fs/squashfs/zstd_wrapper.c b/fs/squashfs/zstd_wrapper.c
index f8c512a6204e..add582409866 100644
--- a/fs/squashfs/zstd_wrapper.c
+++ b/fs/squashfs/zstd_wrapper.c
@@ -11,7 +11,7 @@
#include <linux/mutex.h>
#include <linux/bio.h>
#include <linux/slab.h>
-#include <linux/zstd_compat.h>
+#include <linux/zstd.h>
#include <linux/vmalloc.h>

#include "squashfs_fs.h"
@@ -34,7 +34,7 @@ static void *zstd_init(struct squashfs_sb_info *msblk, void *buff)
goto failed;
wksp->window_size = max_t(size_t,
msblk->block_size, SQUASHFS_METADATA_SIZE);
- wksp->mem_size = ZSTD_DStreamWorkspaceBound(wksp->window_size);
+ wksp->mem_size = ZSTD_estimateDStreamSize(wksp->window_size);
wksp->mem = vmalloc(wksp->mem_size);
if (wksp->mem == NULL)
goto failed;
@@ -71,7 +71,7 @@ static int zstd_uncompress(struct squashfs_sb_info *msblk, void *strm,
struct bvec_iter_all iter_all = {};
struct bio_vec *bvec = bvec_init_iter_all(&iter_all);

- stream = ZSTD_initDStream(wksp->window_size, wksp->mem, wksp->mem_size);
+ stream = ZSTD_initStaticDStream(wksp->mem, wksp->mem_size);

if (!stream) {
ERROR("Failed to initialize zstd decompressor\n");
@@ -122,8 +122,7 @@ static int zstd_uncompress(struct squashfs_sb_info *msblk, void *strm,
break;

if (ZSTD_isError(zstd_err)) {
- ERROR("zstd decompression error: %d\n",
- (int)ZSTD_getErrorCode(zstd_err));
+ ERROR("zstd decompression error: %s\n", ZSTD_getErrorName(zstd_err));
error = -EIO;
break;
}
--
2.28.0