Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp274292pxb; Mon, 2 Nov 2020 22:03:19 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKhdKGhcB7BXHbhuP4zJAIAQG31h9QxQAn+CqrgSC/1X9TpWbYl4xEw64FqTy5ibMD84+Z X-Received: by 2002:a05:6402:1004:: with SMTP id c4mr20179322edu.149.1604383399262; Mon, 02 Nov 2020 22:03:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604383399; cv=none; d=google.com; s=arc-20160816; b=rbhn/X9uu1SUalc1nvZF0xiRjoRnZyrQy9gBSd2z6s2+dxmMCcI25M7Awj1lkWzrqJ nRjPQY5rhbauOybespynFP+Ua26DpianMNbM0bYgC41WtPYMjdfqpLIPGIFgXH3wWtnp w07kAtrmykpP1XJmrX3aktygSfgPCoHwD6ntB4noqBO4tsz7h7k9XGIk2Gm0GbevcRvZ vm8Xnjwe1zuKj+JagHWkVtRQdURI+yDVXYUSn0k9spPcUoUDQION+9+579yCQj11iFbV Lc76CI1g7cQCWauZVC1+0x2fnL3h3jwyFLOx6xkGuk/xqOMKVVESgLVfBBaM+QvrXONh U2QA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5fKNeZSsXX3F75uWAvoclig0FCLwLLfStaZMUpC2Nwo=; b=biCmgTLu8dDU3x8MlYAxkt7gOvNp8yIPGcJK6Ln/HeVdaAufV5bORnlPt+yH5G90bf z2U/J0C31hhc6slaQHBma/EnM1NnbJHBfBHtVUQLKVb0yP+PWVRJg02qGE4CwZeMjb5e uh6HQ3KaEGg3KzmA1t5EDXpUhjrF4jmf+HNRfTZijuBaat5sCRxIBV85XIgvuTDB1R2h 2G1EqwLOm5c5NuHiNpjKurRGpPNoH+RpcxCVIZko2abtfBGpYm3H9N3D5t3kKrt6GPH6 DSTG1ep57jQazm4A/82C5DAns0UulABB7cOhBUXKolE+MJo/+XtMOjpMBM0txeisiD/b vA8w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GSRu5L2P; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j62si11202389edd.159.2020.11.02.22.02.56; Mon, 02 Nov 2020 22:03:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=GSRu5L2P; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725958AbgKCGCT (ORCPT + 99 others); Tue, 3 Nov 2020 01:02:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52798 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727497AbgKCGCO (ORCPT ); Tue, 3 Nov 2020 01:02:14 -0500 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E97FC0617A6; Mon, 2 Nov 2020 22:02:14 -0800 (PST) Received: by mail-pg1-x544.google.com with SMTP id z24so12854388pgk.3; Mon, 02 Nov 2020 22:02:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5fKNeZSsXX3F75uWAvoclig0FCLwLLfStaZMUpC2Nwo=; b=GSRu5L2PQk84FeCeKEGbNFwcDIBC6ksTVwVMkVAwC2zdttpARRdY3h/s02DkFGdSf3 U4YQHvfYMojAb/457zl23L8sA37nL6Yqn5R3z0ncxLK/N7++XALuwmkNb7ElqwXGCAP2 r2fh/EEUiGZWmoaA/+dcWcsgN1dtNlGnBrUUTW4y9WHccgqneHCy0J5DL3FOQutjw0Ka f4xtF2vwzCiAST4tV0jiyRWkzymUmtgoL75rmdrjwpBHkXQfHDTMUPWcMIgyhBxoJmD7 J7NTYfM1tOsWVBzHQ6RSyLnDdYIacl8FDoad984Ey8Q3T3r66tnozU+RsMOLOenx1hiL YDeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5fKNeZSsXX3F75uWAvoclig0FCLwLLfStaZMUpC2Nwo=; b=GVZAzRsInAWuDvB7ABhzm4G3LZcsdYZLaYx/8lfgwTqrXaBWtzapdsygVht+Ng/L/Z N6RU2hMEepafWutf4ItlM+6BMTZxQwxmbIYTrG5twdKYXST+29ei1IWajMvXjXWzPx8N r9+eXDXKzee175HPwe8rFogWphwo1c0rHXSJzHd/pAgPvtvCMAjgZQIPN/0KYIohaEvN OfDYYMIaixY9q8AqSx+/qkSnXmbs1u2H4vHRNRQemVT65mI1iVfkh1WEHSeefyWLHlhj kvMabaNwMLmlXqz0RLef0LJgOYRjgul9kVwFhEMI3SbhMCTltsW2ULeMFOGYTT3oXMSN 8ioQ== X-Gm-Message-State: AOAM531PlobBUvRVtLmg34nLhbs7lTdf02gOxlXzbrtF5mZFqEtzssXu HSm37OCG7TE63FepA+UdPic= X-Received: by 2002:a63:174a:: with SMTP id 10mr16371117pgx.212.1604383333550; Mon, 02 Nov 2020 22:02:13 -0800 (PST) Received: from nickserv.localdomain (c-98-33-101-203.hsd1.ca.comcast.net. [98.33.101.203]) by smtp.gmail.com with ESMTPSA id b16sm15647269pfp.195.2020.11.02.22.02.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Nov 2020 22:02:12 -0800 (PST) From: Nick Terrell To: Herbert Xu Cc: linux-crypto@vger.kernel.org, linux-btrfs@vger.kernel.org, squashfs-devel@lists.sourceforge.net, linux-f2fs-devel@lists.sourceforge.net, linux-kernel@vger.kernel.org, Kernel Team , Nick Terrell , Nick Terrell , Chris Mason , Petr Malat , Johannes Weiner , Niket Agarwal , Yann Collet Subject: [PATCH v5 4/9] crypto: zstd: Switch to zstd-1.4.6 API Date: Mon, 2 Nov 2020 22:05:30 -0800 Message-Id: <20201103060535.8460-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201103060535.8460-1-nickrterrell@gmail.com> References: <20201103060535.8460-1-nickrterrell@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Nick Terrell Move away from the compatibility wrapper to the zstd-1.4.6 API. This code is functionally equivalent. Signed-off-by: Nick Terrell --- crypto/zstd.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/crypto/zstd.c b/crypto/zstd.c index dcda3cad3b5c..767fe2fbe009 100644 --- a/crypto/zstd.c +++ b/crypto/zstd.c @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include @@ -24,16 +24,15 @@ struct zstd_ctx { void *dwksp; }; -static ZSTD_parameters zstd_params(void) -{ - return ZSTD_getParams(ZSTD_DEF_LEVEL, 0, 0); -} - static int zstd_comp_init(struct zstd_ctx *ctx) { int ret = 0; - const ZSTD_parameters params = zstd_params(); - const size_t wksp_size = ZSTD_CCtxWorkspaceBound(params.cParams); + const size_t wksp_size = ZSTD_estimateCCtxSize(ZSTD_DEF_LEVEL); + + if (ZSTD_isError(wksp_size)) { + ret = -EINVAL; + goto out_free; + } ctx->cwksp = vzalloc(wksp_size); if (!ctx->cwksp) { @@ -41,7 +40,7 @@ static int zstd_comp_init(struct zstd_ctx *ctx) goto out; } - ctx->cctx = ZSTD_initCCtx(ctx->cwksp, wksp_size); + ctx->cctx = ZSTD_initStaticCCtx(ctx->cwksp, wksp_size); if (!ctx->cctx) { ret = -EINVAL; goto out_free; @@ -56,7 +55,7 @@ static int zstd_comp_init(struct zstd_ctx *ctx) static int zstd_decomp_init(struct zstd_ctx *ctx) { int ret = 0; - const size_t wksp_size = ZSTD_DCtxWorkspaceBound(); + const size_t wksp_size = ZSTD_estimateDCtxSize(); ctx->dwksp = vzalloc(wksp_size); if (!ctx->dwksp) { @@ -64,7 +63,7 @@ static int zstd_decomp_init(struct zstd_ctx *ctx) goto out; } - ctx->dctx = ZSTD_initDCtx(ctx->dwksp, wksp_size); + ctx->dctx = ZSTD_initStaticDCtx(ctx->dwksp, wksp_size); if (!ctx->dctx) { ret = -EINVAL; goto out_free; @@ -152,9 +151,8 @@ static int __zstd_compress(const u8 *src, unsigned int slen, { size_t out_len; struct zstd_ctx *zctx = ctx; - const ZSTD_parameters params = zstd_params(); - out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, params); + out_len = ZSTD_compressCCtx(zctx->cctx, dst, *dlen, src, slen, ZSTD_DEF_LEVEL); if (ZSTD_isError(out_len)) return -EINVAL; *dlen = out_len; -- 2.28.0