lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b12254bc-7320-7170-f39d-e76afe1a7561@toxicpanda.com>
Date:   Fri, 6 Nov 2020 12:10:47 -0500
From:   Josef Bacik <josef@...icpanda.com>
To:     Nick Terrell <nickrterrell@...il.com>,
        Herbert Xu <herbert@...dor.apana.org.au>
Cc:     linux-crypto@...r.kernel.org, linux-btrfs@...r.kernel.org,
        squashfs-devel@...ts.sourceforge.net,
        linux-f2fs-devel@...ts.sourceforge.net,
        linux-kernel@...r.kernel.org, Kernel Team <Kernel-team@...com>,
        Nick Terrell <terrelln@...com>, Chris Mason <clm@...com>,
        Petr Malat <oss@...at.biz>, Johannes Weiner <jweiner@...com>,
        Niket Agarwal <niketa@...com>, Yann Collet <cyan@...com>
Subject: Re: [PATCH v5 5/9] btrfs: zstd: Switch to the zstd-1.4.6 API

On 11/3/20 1:05 AM, Nick Terrell wrote:
> From: Nick Terrell <terrelln@...com>
> 
> Move away from the compatibility wrapper to the zstd-1.4.6 API. This
> code is functionally equivalent.
> 
> Signed-off-by: Nick Terrell <terrelln@...com>
> ---
>   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

Reviewed-by: Josef Bacik <josef@...icpanda.com>

Thanks,

Josef

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ