> On Nov 6, 2020, at 9:10 AM, Josef Bacik <josef@xxxxxxxxxxxxxx> wrote: > > On 11/3/20 1:05 AM, Nick Terrell wrote: >> 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/btrfs/zstd.c | 48 ++++++++++++++++++++++++++++-------------------- >> 1 file changed, 28 insertions(+), 20 deletions(-) >> diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c >> index a7367ff573d4..6b466e090cd7 100644 >> --- a/fs/btrfs/zstd.c >> +++ b/fs/btrfs/zstd.c >> @@ -16,7 +16,7 @@ >> #include <linux/refcount.h> >> #include <linux/sched.h> >> #include <linux/slab.h> >> -#include <linux/zstd_compat.h> >> +#include <linux/zstd.h> >> #include "misc.h" >> #include "compression.h" >> #include "ctree.h" >> @@ -159,8 +159,8 @@ static void zstd_calc_ws_mem_sizes(void) >> zstd_get_btrfs_parameters(level, ZSTD_BTRFS_MAX_INPUT); >> size_t level_size = >> max_t(size_t, >> - ZSTD_CStreamWorkspaceBound(params.cParams), >> - ZSTD_DStreamWorkspaceBound(ZSTD_BTRFS_MAX_INPUT)); >> + ZSTD_estimateCStreamSize_usingCParams(params.cParams), >> + ZSTD_estimateDStreamSize(ZSTD_BTRFS_MAX_INPUT)); >> max_size = max_t(size_t, max_size, level_size); >> zstd_ws_mem_sizes[level - 1] = max_size; >> @@ -389,13 +389,23 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping, >> *total_in = 0; >> /* Initialize the stream */ >> - stream = ZSTD_initCStream(params, len, workspace->mem, >> - workspace->size); >> + stream = ZSTD_initStaticCStream(workspace->mem, workspace->size); >> if (!stream) { >> - pr_warn("BTRFS: ZSTD_initCStream failed\n"); >> + pr_warn("BTRFS: ZSTD_initStaticCStream failed\n"); >> ret = -EIO; >> goto out; >> } >> + { >> + size_t ret2; >> + >> + ret2 = ZSTD_initCStream_advanced(stream, NULL, 0, params, len); >> + if (ZSTD_isError(ret2)) { >> + pr_warn("BTRFS: ZSTD_initCStream_advanced returned %s\n", >> + ZSTD_getErrorName(ret2)); >> + ret = -EIO; >> + goto out; >> + } >> + } > > Please don't do this, you can just add size_t ret2 at the top and not put this in a block. Other than that the code looks fine, once you fix that you can add Thanks for the review, I’ll make that change! > Reviewed-by: Josef Bacik <josef@xxxxxxxxxxxxxx> > > Thanks, > > Josef