Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp66703pxk; Tue, 15 Sep 2020 20:48:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx0zb+TbkpwoxU6yQBvslvmPbxcNA0JeBLdNJfIVzGQV21oZOBHz56GygHmuMDSbgTelqVr X-Received: by 2002:a17:907:64d:: with SMTP id wq13mr22850330ejb.513.1600228131687; Tue, 15 Sep 2020 20:48:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600228131; cv=none; d=google.com; s=arc-20160816; b=iJI+HL0ziCsHFcWj4E77IItgNgpAJR+/slHkIajGNMnlT0C2sMeP/ieyCeGv/p3cDa I2A/ppEkoZflT+5Q/htUpU2IcF/wjOh0Wz31zRi1xfwJhfo1zt8KwxpDw2k1ddGG41VY VxJVvxYWQH6798D8yX4h1sm7OGaGnVEVwL0ls6ZLTcHGbs8iAgMT+21hXajuRBTl5etN Q2J6kY6z2MPFXo/NtZ6M+snlNA1TH1TABVYB44lBgej4CtZ6d+CxyST7gDvqEE3zuI0s gUBBimb0ZarFVSbM7ssuOWLCxE0+b7rAlzryn35pMhGX8CyMLJvmJteLARZ0mHuQ79Dd 6o8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=5fKNeZSsXX3F75uWAvoclig0FCLwLLfStaZMUpC2Nwo=; b=LWoPR+yoqahaQrJWUHmNMCOAedO6vFCrxCsXSLSB1jkbvGd0O/5+78/FpWoiyWTfZP 9wkUvjJNDvy9539uPpwKBMFcnKKdiQM6XidIY7A4TL7HtypJKnBn6Ka7/zcX9QLP5vPN 5nD+zlOJj4FcV6zau9HbgcZewUPeQEzxCDVwMY4C41Z8VYQz/w3k6ROnM+nTQ7be4uRg X30kUpOoSbHD3CqpXRu0VRkEHmru0RuHUOx4vg0sO3Vjqo4T+TWV2rmkpQwUsD/TEGj7 KBgLxowduLvdVLywY1r4/bMaobY95BERA9uhu5Rf1BHiAYnxymC5rr+QjarBsVq4prlw 5s/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=MBMW6QMq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 t12si13037739edc.310.2020.09.15.20.48.28; Tue, 15 Sep 2020 20:48:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=MBMW6QMq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-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 S1726302AbgIPDr4 (ORCPT + 99 others); Tue, 15 Sep 2020 23:47:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45780 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbgIPDry (ORCPT ); Tue, 15 Sep 2020 23:47:54 -0400 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C689BC06174A; Tue, 15 Sep 2020 20:40:55 -0700 (PDT) Received: by mail-pj1-x1042.google.com with SMTP id v14so822306pjd.4; Tue, 15 Sep 2020 20:40:55 -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=MBMW6QMq9lCxZUAmvXVtcBYONHEPOCnbWNuKiZJWW65LC9wyrofhoWFzZBC+Y3HhOT G2pHeFDFBdqb3XeOD8673GkG54+crAqrHtMGfC5utUo7pGK0gwqJYwghKeqPJ7Fouqg9 a1EW2ZbmQ9UtrHQoYRclmzQQgmQLxWA0humcihwtRQ0n+ad/2DwL/kuWTrC6Nea//9NG aeemwFijt+vriQZye/oGtrhD1P91DO8uUR/F8z93hCnSk8VWI+zujWiEUzstQQS4eknN TNO1ZT3oZk2XH5Nrr2r2YHgtTcth54B2w+48DKMsM50qMyTGtTKbwdXs07G4MauJuaw5 cVUg== 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=cSzIoHD4b7tcnjZBHgb2hcePf3OyY0dLofN6VdcBrzXiUegOgfaGl38Wx5lmopJJ1b HcK86isTc8LANR58D0REy1utr42gpbleyQxeeljHQCr1X2hnHUW1PnNqNjRjm1fKQLF4 +bDVuapZLRJswPXqmDOGWVcthsW2TsyhZRBrIePXgR++C6odRoCRtY+HtvT+yWzjbTM2 b+o5FE9c/YGA3vBAD2o4xGdmYsilM0MAst0I4V5Nb+/z8dik1gwl7D850V7+Qif/vD1y NUC0C9L/k6HY9zlBHrbJxZYbLjcy2RZ78PNZjSdAkNsscapn2FwDSdZj/ievVVzNabFz F5uw== X-Gm-Message-State: AOAM533VcGpErlEQY1s1OoJHWdjurlSo9MQD+P7mzmNVBATI9hYZ+q2x DubZmicGYGJW5s3rtcULU/s= X-Received: by 2002:a17:902:309:b029:d1:e5e7:ca3f with SMTP id 9-20020a1709020309b02900d1e5e7ca3fmr4663933pld.43.1600227655314; Tue, 15 Sep 2020 20:40:55 -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 i20sm12856635pgk.77.2020.09.15.20.40.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Sep 2020 20:40:54 -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 Subject: [PATCH 4/9] crypto: zstd: Switch to zstd-1.4.6 API Date: Tue, 15 Sep 2020 20:42:57 -0700 Message-Id: <20200916034307.2092020-5-nickrterrell@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200916034307.2092020-1-nickrterrell@gmail.com> References: <20200916034307.2092020-1-nickrterrell@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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