Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp758011pxk; Wed, 23 Sep 2020 15:39:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzwYUvwb9+68ry8Ghw5r9ezOgAycW+8aFv0sKrDsRAj4ac/QioWa3KrjWA1JDWiRdAlkyFE X-Received: by 2002:a05:6402:176e:: with SMTP id da14mr1576504edb.349.1600900793294; Wed, 23 Sep 2020 15:39:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600900793; cv=none; d=google.com; s=arc-20160816; b=GCu0pz6MrE/47lSHeunoMWeCcLEm2kYAhgjb73EgJrNVTBj4NVBupfcmxNLxGdqFVR vJb2vx1xi+CEkxbxFp32OWixXSav17khHuaTiuzgLJw5wPjeKs7lQwEUMsrkiKAyrzZ1 NLFOiR9lkfz8LTrWybZ0lxelo4tFziLOhcsYZTHXn1d/MWTxTfdBEVh8oZE60G25dCWd lSWLqZwDwligXMfeZeaF7vGOaaITGBb6qUhWyk4n0Nt6n0YmPXQX26hiiBT4NctqQOdE VRv1jX4RZfl+ZKXZVZfV5iCV+TTZRsE9AdWBeb/OqShWhNRJ76jXQN2FznoZ0pnUzprh 5xjA== 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=dxdX9aBwqNrXzjMM5eD9ZkP9v2BKLBrxbKJvZMJNnWGD5q1NvCCxb2AvW4sPNlfPfV APu6oPBqWpNoW5rkvU3lcn7b00xpX2AO5aDquuUxGwpc04yK7prsbow3cK2++zaG7yVS k89KxFmR3491HCMMYY/loJmi3Rz6tlbOYOnR/WJQdYhQBFJqq86XrjRu3pQzh/7QNlM2 FkK66EynhCiW5DLpCLXqvJU05Ro2iwFNqbKdMvKVLgynE4cfI1MFNK6Ku362O7Vz5XEN kBxMrpCgsr3Yvm2X4/sH1+SPUyAYCUB+VfD74HO4EWt11vZ/bMfLGUeHgOVd+WDoYW2e +8Ag== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="L/LdQyjz"; 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 h10si846076eje.414.2020.09.23.15.39.29; Wed, 23 Sep 2020 15:39:53 -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="L/LdQyjz"; 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 S1726381AbgIWWjB (ORCPT + 99 others); Wed, 23 Sep 2020 18:39:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52570 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbgIWWjA (ORCPT ); Wed, 23 Sep 2020 18:39:00 -0400 Received: from mail-pg1-x541.google.com (mail-pg1-x541.google.com [IPv6:2607:f8b0:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4E9FC0613CE; Wed, 23 Sep 2020 15:38:59 -0700 (PDT) Received: by mail-pg1-x541.google.com with SMTP id l71so621516pge.4; Wed, 23 Sep 2020 15:38:59 -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=L/LdQyjzq62pxCUFbrhai8paJYXWa/hCIBBf3FIGQg/nxYqf4U8g3Zd3ISUbyQt3jb +nSC/4hR+jxAR+XqGzL782nH6W65V7wHlpi8JLQCiD2DIiDJXH9snofqwdz55I6W8mBv KuX942RrIiTQ/OifNm1WKkQgcHSZmNK09CEU6TVeyKQqQ9tZgbi6Z7+UjtFnoI0MDhUy uP5sZH2BFf7TrYJJZKODGOvrfs7/1zIFNCKbV/ZVFyeWo4iTUYS8CvCHv0G6vaM8fkzN LIS5znkAIDPH+5kFwdRONnP0QcSnzFo+cZbMi5UwHxFHyTZCOn6rhFTrW3d3RP95bgTE wBTQ== 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=rb95FvtVqpdpY6CaUGu79E9WhGpXLBmG5+qunN/E5sJZPfMC5vFqnMWr4rWo7dfj4i e2Nz7m5z1KiDCzzFjxvmLCgV15sOYzopyonf55q0YINI1XaPGybduO82qNsvw+n0rJPF MsAY5YqbE8OedEqYkZ5WoJYnArE5DfazeKOGgzS9epZSQOfKO2Ccot+dWk0f8ArWFhkz 17bxbm0BphGeGSRTj/b82EVhI9T8vsztET62l1Arqb7HFoDa5QoEFj7IbMwFbZnzjSQA pJBZyebgAwv94s5NU+yt3SyqZResY0ILhPkQyNwAl5F7SGRqJJVFs340FOTqZGTsvJUC LTtA== X-Gm-Message-State: AOAM531QVCOGmYBF0yxxgg2LYpTnDF26doNhtDMqrdtYHMLmz7pQqWt9 x9n+mL3Zf/IsFRwebByQhpc= X-Received: by 2002:a65:4b86:: with SMTP id t6mr1471722pgq.81.1600900739314; Wed, 23 Sep 2020 15:38:59 -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 d20sm417964pjv.39.2020.09.23.15.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 15:38:58 -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 v3 4/9] crypto: zstd: Switch to zstd-1.4.6 API Date: Wed, 23 Sep 2020 15:42:01 -0700 Message-Id: <20200923224206.68968-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200923224206.68968-1-nickrterrell@gmail.com> References: <20200923224206.68968-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