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: <55C56F7A-4CF9-44DB-AA61-A5D9F5C61FE0@fb.com>
Date:   Fri, 6 Nov 2020 18:36:40 +0000
From:   Nick Terrell <terrelln@...com>
To:     Josef Bacik <josef@...icpanda.com>
CC:     Nick Terrell <nickrterrell@...il.com>,
        Herbert Xu <herbert@...dor.apana.org.au>,
        "linux-crypto@...r.kernel.org" <linux-crypto@...r.kernel.org>,
        "linux-btrfs@...r.kernel.org" <linux-btrfs@...r.kernel.org>,
        "squashfs-devel@...ts.sourceforge.net" 
        <squashfs-devel@...ts.sourceforge.net>,
        "linux-f2fs-devel@...ts.sourceforge.net" 
        <linux-f2fs-devel@...ts.sourceforge.net>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Kernel Team <Kernel-team@...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 Nov 6, 2020, at 9:10 AM, Josef Bacik <josef@...icpanda.com> wrote:
> 
> 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

Thanks for the review, I’ll make that change!

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ