Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4343970pxk; Tue, 29 Sep 2020 23:51:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzqLAQL85IlTJeMSTRhIC1WcmuyYpTLdoObUZsbQe5PCijL7IGed9F/g+PmmmkJW2f3KS0U X-Received: by 2002:a17:906:2752:: with SMTP id a18mr1324752ejd.350.1601448672745; Tue, 29 Sep 2020 23:51:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601448672; cv=none; d=google.com; s=arc-20160816; b=S21udrFAD7zw8lgoauRpxv03lSbDGDzuWF1hyNT5YHySL5St6kW2bKg2MscSlPoLBL n6UZVhj2D5L3tAy5dxmrB4LDYGbXVmkTfu4u/eyyM6loC2aBzePqrCkv4RmXrCunywX0 Z6FJNKFVHgRO9XRqm+YFd7RftzkPodayPhEug4OGVEKj26naZRi8TaY05aYeL1Vwp/I0 sUMfKrZIM5jCJE3zE3iOhFvh7b4/ReVGtS86smQbQbkm6o8IYi9+Etx0l5mrgTXqoQFC tt+oT1n9fMuLX5m+tqbaNqNecu4rfEU6BsSb8si7XMlAgPMVbQCzGjGoXaE1ID21bvzR GPZA== 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=dRVHakt5IHEG09rXAyX7TenbhPXxVrNKMeZ8GeU4GuAUfp75FU2wzqUq4+P5a6s0Wj bHP8upaRa0q6EwBjZZbFThAAmCPpsfjvz4j4il6Wzm9JMwAArXshKmGkTB4nJ4bZKuo4 0FgF/vbuJGrRaSiZPCDiuC+G+iXfYiLW4Ttjg50R1FGxzml69ihPmUCrN3RpW64ll6eH OJNz6VqGn0QKG/ns3O2uz1KEdoPp53sUq2QtCZaPbR5ZIDlD7vdUkdGFqkQu9wsBSqAv Tcd0Cnm+OQB9WHsaYC8F3GTGNAyaxpBEJGNVqlidEro7jCLhN+YzGsD1WXfxCrmxqUWY 2Euw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VxTo6zF2; 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 m14si361404eds.454.2020.09.29.23.50.48; Tue, 29 Sep 2020 23:51:12 -0700 (PDT) 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=VxTo6zF2; 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 S1728386AbgI3GuD (ORCPT + 99 others); Wed, 30 Sep 2020 02:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725798AbgI3GuC (ORCPT ); Wed, 30 Sep 2020 02:50:02 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89529C061755; Tue, 29 Sep 2020 23:50:02 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id n14so501318pff.6; Tue, 29 Sep 2020 23:50:02 -0700 (PDT) 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=VxTo6zF2fu49RsmnYgmpKorcmYpqhYfxCs9DGycyfzzCy4r9Q0EROtwrw52m0lEZtI Q2fnlRz+iD4eabk1O+A7K1LY/NKIC/HD+atXxRHukStTStxRg44QUL8omwHsDVY3XAMI O0Pe5arLJpYedWmsDLBpFsXU5gooUm9USrNMsjvO6KM1dOIQSk0eFyCe5X+HGAJzntOz gKsZyHNhLrytVKF2rA0ipBadNOSVnQxiWIYt4FRFfq7S5FRKJQOIRuswiqZTYHfpc6fI UiDeaAZTiq5cZt+QNCr7y4YDBxnLKMF2tdZonPB7AqgqhkFk4G44lA+5y78k8Y0gT6dh +K9A== 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=f9HgkUp0EQsr3DCVkQZxzKoMEi4K3s8m3RGgOpjkfUs/1rPbAr9FgobbPzWYKF+4T1 bwat2RqCBS5LfF+bzfl1ceT522OhQ3y0pg1wi4MY07JSt1kxPt3wwAyqU3sb/qEWlziM qx+jHj1KWc7DjJnmlZ6qNjjT3GCgJ5g3IGYhZHfvQ1xB54aE7zDyFCq5ZoplmRVAsbok UcVMxNMqOogix7r9N/00GT5Y4GLZoeM16bm0kuePH/mLikAoSDDCMoWc/0xFsFfqeX8t CA+tIPqRzsUkcIcy5pHkcwcNnE142imXBrgXnc+FUCHsp8DlvOkab1/zq2JFz3xL15SN tVxw== X-Gm-Message-State: AOAM5327imZukXhjtMvoo3sFkRnerogZBChP3LSRhZ12zkqVQL1q5RZJ S/+xwaXWluNvvhI0Aj4oBpc3uzBpQ3M= X-Received: by 2002:a62:7b94:0:b029:142:2501:35e4 with SMTP id w142-20020a627b940000b0290142250135e4mr1387276pfc.68.1601448602040; Tue, 29 Sep 2020 23:50:02 -0700 (PDT) Received: from nickserv.localdomain (c-98-33-101-203.hsd1.ca.comcast.net. [98.33.101.203]) by smtp.gmail.com with ESMTPSA id 190sm1100865pfy.22.2020.09.29.23.50.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 29 Sep 2020 23:50:01 -0700 (PDT) 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 , Christoph Hellwig Subject: [PATCH v4 4/9] crypto: zstd: Switch to zstd-1.4.6 API Date: Tue, 29 Sep 2020 23:53:13 -0700 Message-Id: <20200930065318.3326526-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200930065318.3326526-1-nickrterrell@gmail.com> References: <20200930065318.3326526-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