Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp4238587pxk; Tue, 22 Sep 2020 14:07:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz8KRf1saKNpWFoD7s6AmZz+8T7VDYosDJHP3i26eIl0sJEMW7+KgBAs21daxgb+U31bxoa X-Received: by 2002:a50:93e2:: with SMTP id o89mr6104277eda.378.1600808860221; Tue, 22 Sep 2020 14:07:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600808860; cv=none; d=google.com; s=arc-20160816; b=BgG9lgmFfZ1mSyp70XvF6oDDeE9F3nqLHoT5atOvQffCXuPe37UAIDN6yZgEeSf/Kh hZ0Rn7uyipx7K9MecZewHFlnwEu91KoZ1imC9KkzuiOSGLx0UOm0AHZTVziVxoVuEb4Q Yh3+Pk6hgXrYRNpzS9bLCdv1gKcCtkUJs1Mgi/zF8PjQtkgbZcyTvmLHIhvY3XzFvFbR GMD9TBszDT3bLEgjYhFra01ou7zuWXZEn+07KNIn1oIJLbTcMjMFUVRWxOnyQz0YvWRa SswldODbzQWtT5V9sgKMg2NSFrRfegXOorOW9BhSYdo9SyQjlznYtQXJ+eqeaDipq8L7 V6lw== 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=2E/IwoJzArQOI0tLeIWcAV63W6gwJ92+ohjyeEw8pg8=; b=eHhqkcDWObtKQI0dJX5cn1nLfB5KRylqYPotFVBLpdo0G9tr/e/ZzqnWtqh6lWWVBQ j8okOKzb3fkBrUJsdesmzfX/9NmVGItX0Nw6Io8J9ZF1zv8/6KYdG73OG0WbQKyUDVQl sZ/lECSlnc+apOP5FfexHSDWt9WkRUvo+Eu+beDR8YrW69Q3k+CUCiizwFu9icNWWNBW Z419vh3Yjr46nIttETsYXF9gbivwe2qnM2WoT0ZNg8Ji94JnEe8A8+wliLvcVvwAgtRB ZYtddUNWLXzym5K5bplqBeIDVsF6wbzrjpaaJ6lgwk8yI0ZAw03jkpAqefXVjZwoIHqP cROA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=OxNT+QNu; 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 c23si12016539edn.110.2020.09.22.14.07.16; Tue, 22 Sep 2020 14:07:40 -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=OxNT+QNu; 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 S1726865AbgIVVGg (ORCPT + 99 others); Tue, 22 Sep 2020 17:06:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726583AbgIVVGg (ORCPT ); Tue, 22 Sep 2020 17:06:36 -0400 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 586B7C061755; Tue, 22 Sep 2020 14:06:36 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id jw11so2041668pjb.0; Tue, 22 Sep 2020 14:06:36 -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=2E/IwoJzArQOI0tLeIWcAV63W6gwJ92+ohjyeEw8pg8=; b=OxNT+QNuKonqqEDoLxfT0evE2G9xxahxWfwna/whIy+Phh4fehxfZzuzQiKaY/3E7L P738gfvMJiE3Ef+6MWIXCrtMiimEOApRHUa4Rx0mkRYuKy+Te16Gn0Ort9Cjy4JUA3YS n0WiF+RrFhlWK3g+M1cMPsUXXk6hGfjK7HwyCL15KfhH2feuz3DZD/Mof0shnhpIRLL7 pH4yytxKasaTPWLiNPtcuwWerS/VpC5eWYpXKiebPEAmNfsTmahh+lUsyHtqJ04mMVMR sDef/8wqxfLSzNX0nkp5zeKChnGxYmXTk2HQOQ5ge1b1U38uDEneRtMrrNuHrEf1UT+H hSrw== 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=2E/IwoJzArQOI0tLeIWcAV63W6gwJ92+ohjyeEw8pg8=; b=fkG3jwroza4Rf+iYQ4vWep8eRkM5IF0TCsjvKfmy/h9VhHx3woh/w6LieOqsB6mRnQ Ux+yS73ovKyO4gbgkMhxZlhOeNZ4RIYOrbvAEVx4UGNI+xMYBs5wMoNIyWHa5tStNrRr A9OPmcIupyUrg1h/89sA8a2jbqibTUboDRsZCjv+g1qFTAlSsQXaUdqpQn09FbnhPP6r LaqNtBF4pMahbzN6Ju/P3bvh7ZW40R16mlqMpavEKLaReMMISL2CsPsAKEvB10TIui3V u811hDO0puj9hFhwT1I3wITvH193MBt6iuLCuC4V46aJRse87yeQ7mWKrN8jbfSYRcwF 5AtA== X-Gm-Message-State: AOAM53180ECZxTFE5z97TNAe5gZqzyewhVkBhYsklWdG3Hh2oO0nmvSb s2h8JCcZIgUM+Daf9QIcmMA= X-Received: by 2002:a17:90b:4ac4:: with SMTP id mh4mr5502426pjb.224.1600808795872; Tue, 22 Sep 2020 14:06:35 -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 i15sm16118945pfk.145.2020.09.22.14.06.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Sep 2020 14:06:35 -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 v2 5/9] btrfs: zstd: Switch to the zstd-1.4.6 API Date: Tue, 22 Sep 2020 14:09:20 -0700 Message-Id: <20200922210924.1725-6-nickrterrell@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200922210924.1725-1-nickrterrell@gmail.com> References: <20200922210924.1725-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 --- 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 #include #include -#include +#include #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; + } + } /* map in the first page of input data */ in_page = find_get_page(mapping, start >> PAGE_SHIFT); @@ -421,8 +431,8 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping, ret2 = ZSTD_compressStream(stream, &workspace->out_buf, &workspace->in_buf); if (ZSTD_isError(ret2)) { - pr_debug("BTRFS: ZSTD_compressStream returned %d\n", - ZSTD_getErrorCode(ret2)); + pr_debug("BTRFS: ZSTD_compressStream returned %s\n", + ZSTD_getErrorName(ret2)); ret = -EIO; goto out; } @@ -489,8 +499,8 @@ int zstd_compress_pages(struct list_head *ws, struct address_space *mapping, ret2 = ZSTD_endStream(stream, &workspace->out_buf); if (ZSTD_isError(ret2)) { - pr_debug("BTRFS: ZSTD_endStream returned %d\n", - ZSTD_getErrorCode(ret2)); + pr_debug("BTRFS: ZSTD_endStream returned %s\n", + ZSTD_getErrorName(ret2)); ret = -EIO; goto out; } @@ -557,10 +567,9 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb) unsigned long buf_start; unsigned long total_out = 0; - stream = ZSTD_initDStream( - ZSTD_BTRFS_MAX_INPUT, workspace->mem, workspace->size); + stream = ZSTD_initStaticDStream(workspace->mem, workspace->size); if (!stream) { - pr_debug("BTRFS: ZSTD_initDStream failed\n"); + pr_debug("BTRFS: ZSTD_initStaticDStream failed\n"); ret = -EIO; goto done; } @@ -579,8 +588,8 @@ int zstd_decompress_bio(struct list_head *ws, struct compressed_bio *cb) ret2 = ZSTD_decompressStream(stream, &workspace->out_buf, &workspace->in_buf); if (ZSTD_isError(ret2)) { - pr_debug("BTRFS: ZSTD_decompressStream returned %d\n", - ZSTD_getErrorCode(ret2)); + pr_debug("BTRFS: ZSTD_decompressStream returned %s\n", + ZSTD_getErrorName(ret2)); ret = -EIO; goto done; } @@ -633,10 +642,9 @@ int zstd_decompress(struct list_head *ws, unsigned char *data_in, unsigned long pg_offset = 0; char *kaddr; - stream = ZSTD_initDStream( - ZSTD_BTRFS_MAX_INPUT, workspace->mem, workspace->size); + stream = ZSTD_initStaticDStream(workspace->mem, workspace->size); if (!stream) { - pr_warn("BTRFS: ZSTD_initDStream failed\n"); + pr_warn("BTRFS: ZSTD_initStaticDStream failed\n"); ret = -EIO; goto finish; } @@ -667,8 +675,8 @@ int zstd_decompress(struct list_head *ws, unsigned char *data_in, ret2 = ZSTD_decompressStream(stream, &workspace->out_buf, &workspace->in_buf); if (ZSTD_isError(ret2)) { - pr_debug("BTRFS: ZSTD_decompressStream returned %d\n", - ZSTD_getErrorCode(ret2)); + pr_debug("BTRFS: ZSTD_decompressStream returned %s\n", + ZSTD_getErrorName(ret2)); ret = -EIO; goto finish; } -- 2.28.0