Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp758154pxk; Wed, 23 Sep 2020 15:40:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw1Xw2AGKxCUCU7yTQVpT0ykSo1uOrSH8gz6XRcZG9gj7qJA0ctCifHpCdhdkvA8vtVw0GX X-Received: by 2002:aa7:da0f:: with SMTP id r15mr1524567eds.321.1600900812651; Wed, 23 Sep 2020 15:40:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600900812; cv=none; d=google.com; s=arc-20160816; b=e5pZbKhtSXMRydvileiYghMlVXmyYY3ATO6KBBFaPwZk7rtkyh/Kg92m0x6Ogw7duy UunAssEU80YfYfBxrYWPd6lr+LPxokZeuCA8Zi3cFAGpWHiAdSBzdyziMsg8yuf0S9g4 ogafnOJXoJ6cgkyszcoWCH2QVGC4y/nzauOLeKuLh3hq2AtgDgA3jn2LYi91J2HIfBVw RNaZWDbUXwfrYNNgndm5AtRQCqBpX54cdeI+UMdDU7RkdHuQ493d2fWOi6DbEUFJPEXK vWOKnZm2jdrEUhd7r3LrMlboLNtHwCDEa9umPNLNn8yt/RToBNuid1lsqWfhXHDdqIeR Iu1w== 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=G0jgedmM7yBijz3DK/wZ7wNRvJqhFYtbZOD2TcNLtGGdVYbsAzkAxJ3RUtmt/tBu8I aPI9X3A2mCXWVUqWoUBMnTzV8ikkt6h99mWRijUVIe/au88DGunPUyd+uVOEAqXq2NcO QbnzgnKsL3Dg7cni6SS3Yt/u53VGhGHmG7mwuOt81rA+EdizYuKjIxgsHM2GHcE9vn8Q ty6ltk9SGK0iyWUJCcYaUxbKVBwUNe0QB2ltln4h6wZyaw1dMiIezGgBLk+5uZDg7crB nM84NlcY2sIByc3G168SS0EU5LTNGdHhkOEBJ9Yuc3Ajz7YkDqgXCumyydlLEkM8qUXT qqMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=VH6EOPQm; 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 ci27si1055061ejc.373.2020.09.23.15.39.48; Wed, 23 Sep 2020 15:40: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=VH6EOPQm; 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 S1726681AbgIWWjH (ORCPT + 99 others); Wed, 23 Sep 2020 18:39:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52586 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726199AbgIWWjG (ORCPT ); Wed, 23 Sep 2020 18:39:06 -0400 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0972C0613CE; Wed, 23 Sep 2020 15:39:05 -0700 (PDT) Received: by mail-pj1-x1041.google.com with SMTP id t7so514778pjd.3; Wed, 23 Sep 2020 15:39:05 -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=VH6EOPQmKosAZfOq6MnV38EH2WAOAT2/ct907J+IN6F1/UzyBRymrfg8mu4toh/gHz dnCfW0Gwac94AqG3iX63bDY9gwaVeHHo1ws/CLHJtn8lqdccOMUGUAoO060nthG/xJFH ibtLlKqnHKZJrfnLzTVVGSCcnmd1Zey12yJOntQMEkyY8iQykMy73rFgZhMJ0Z844Oi0 8C+RV0grr4N556T9lwPBbDMKtHQTX81iI9NawFSPBMSgHbxghwQyQbO38ko45bl9G61N mFNKN8Cm1lQRlg1NbJqz5u9DNc7Jc6EIJGu54UlJqThrXQkXc6wHz8e0PlIGQrGgR/uM idBQ== 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=HQNvdaxtB7cy+nEVEkcn9kZaA8wHsjIWxWBjTDI7aRzxpBDQuXw6xx9bMg+WIjtAqc vkXNQuRIzcprky3TyP0sanbdIpzfSCxhE/VR9Tr340fyahR6c9SxWq5CYlMjkirx172N wUYXhapKNuUUj3ut9y5svFmuMWWoxlib2dREbFZmLm3zaRu3gRCm/4zFd2+VtKKz3UuY 1/GCkD78ZYfuMjn1WVsKXE3JahO49d59b3ZvuheNDoBBLEo8LxDDoTmwPcSFBfL0Wk6o 3wiKarlkWQvUfwjBz19q4aHJlKRjQDP2rIZm2zbFXIm4MlywNRnOhXYU5wLIJKOVqz3N bUXA== X-Gm-Message-State: AOAM531aE6OEgChcnHk0fNFqlwsiDYjQR/2oFizARmigEHFJHzzdDRau eXrQxdmRfSHqBdAgm2ObrNOYYEucFpc= X-Received: by 2002:a17:90a:6903:: with SMTP id r3mr1241734pjj.169.1600900745341; Wed, 23 Sep 2020 15:39:05 -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.39.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Sep 2020 15:39:04 -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 5/9] btrfs: zstd: Switch to the zstd-1.4.6 API Date: Wed, 23 Sep 2020 15:42:02 -0700 Message-Id: <20200923224206.68968-6-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 --- 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