Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3924135imu; Mon, 28 Jan 2019 13:25:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN5AWNNUjLhs7Difd1Mxlvf0Yh8d5jlrDBTpKpvCAvG48/XVaZFNsSLkrH0CbjlEiuYbx7fz X-Received: by 2002:a62:5f07:: with SMTP id t7mr23322730pfb.108.1548710749631; Mon, 28 Jan 2019 13:25:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548710749; cv=none; d=google.com; s=arc-20160816; b=drg7573MA2mz3gx305QBks8QeDpeQuNhMVdthKt0bmEcwvQ0sMbvn29nYk+P9ZC7FM XQ141xmUuFZXYjD+YHnOldQc4Ic1plaSKkUo1rf+e0NsKi5xeu+9WGwb4Fm3LpO0jDY+ ItKu7gJY6r4BoCAwDY4886HMM/40687j/xUEmJHkKfKELboccaFCrL4X/MCZY0UwwVcx Cq0WJQR8AlR731k35kSHWR/Ydl/qfRTP59qYt+kuOIhsYox+VNwchAyQee/BMWcsNYkT IxLbx9s6ogMyotPKwatYV/NhBr6kgIROBPOfxa8MLDlKHtDLR6eWTpJzUdnubWvpowdD +XUg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=i95HDMYBMKJoHPehH+6R+py5+DMch2uym+tajUEb64U=; b=QuVclcf8FlypI+Vt0sYBaLQzL2+kztTBAR+0O30eubhbHlFCctbejtdHLAFmA6Xr+j IVXwUh6DgMgV26x0MHU43il4i2sEXXq5CqQTbSK/2kpToKHZNMWrBoP31urjQTFdEAF7 PVDzgni3xE67216/hgTV14JWmyj6zKHLtVYxrD0Ga0GDJEtW7tGREi9atk8t6/u+Eca3 FIFBmoi0T3SM9DbOnvYIoUT8ZYtkF0U5AgowIIkMzlxNxGuDBZzhrKU8dGLsx4XR3+Be 4WI/TEzYz1fd8XuX23Iy+rU/NIY7gGvcLsMlme6SDjq2AJFmkZFF2MNbhd8YBfav4XUT AbDA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si33348916pgj.56.2019.01.28.13.25.33; Mon, 28 Jan 2019 13:25:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728469AbfA1VZL (ORCPT + 99 others); Mon, 28 Jan 2019 16:25:11 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:38113 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728416AbfA1VY7 (ORCPT ); Mon, 28 Jan 2019 16:24:59 -0500 Received: by mail-yw1-f67.google.com with SMTP id d190so7356779ywb.5; Mon, 28 Jan 2019 13:24:59 -0800 (PST) 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; bh=i95HDMYBMKJoHPehH+6R+py5+DMch2uym+tajUEb64U=; b=cfhCLJOc45EhyGkR5uZlhot+DKHiqJVXdCjIvua9NQbk3fG8SZff/3SiM0ik4G+29i zkJRhwNyYnelUE1tmLFmtBvKvVDN+WP5effZ2mDXiAcKW9H9xQ8cvr0TStjmjEKaAhUh wzzrGXaeJt4zPqLFdJg770SH9RgcxtYBO9MrlFigo/MUouAXMmM2qXxmMGae0Vma2XU5 IrN0s8ZgJmGGBbwXgWYWAh6qJRoFrraO3rQAPmwddmYDTnSjXL5qbyAi581MC0orhRqI YYJGPiP+fPUwn9DNILJR/kBU/Jkvm9lO7jn4rJ5ZFtxIL0cSRQ7K45ZfGe2ZAthxqO6m bN3A== X-Gm-Message-State: AJcUukcfsrwWfxhf2R9WVVr8UZaI+olTInYMN0OQYW8aGhL2BBTmg1Jg 4227k7IjcMpKOVYDUhBov5o= X-Received: by 2002:a81:af0c:: with SMTP id n12mr21761482ywh.446.1548710698757; Mon, 28 Jan 2019 13:24:58 -0800 (PST) Received: from dennisz-mbp.thefacebook.com ([199.201.65.135]) by smtp.gmail.com with ESMTPSA id a7sm24170415ywb.18.2019.01.28.13.24.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 13:24:57 -0800 (PST) From: Dennis Zhou To: David Sterba , Josef Bacik , Chris Mason , Omar Sandoval , Nick Terrell Cc: kernel-team@fb.com, linux-btrfs@vger.kernel.org, linux-kernel@vger.kernel.org, Dennis Zhou Subject: [PATCH 10/11] btrfs: zstd use the passed through level instead of default Date: Mon, 28 Jan 2019 16:24:36 -0500 Message-Id: <20190128212437.11597-11-dennis@kernel.org> X-Mailer: git-send-email 2.13.5 In-Reply-To: <20190128212437.11597-1-dennis@kernel.org> References: <20190128212437.11597-1-dennis@kernel.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Zstd currently only supports the default level of compression. This patch switches to using the level passed in for btrfs zstd configuration. Zstd workspaces now keep track of the requested level as this can differ from the size of the workspace. Signed-off-by: Dennis Zhou --- fs/btrfs/zstd.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/fs/btrfs/zstd.c b/fs/btrfs/zstd.c index 43f3be755b8c..a951d4fe77f7 100644 --- a/fs/btrfs/zstd.c +++ b/fs/btrfs/zstd.c @@ -21,10 +21,10 @@ #define ZSTD_BTRFS_MAX_INPUT (1 << ZSTD_BTRFS_MAX_WINDOWLOG) #define ZSTD_BTRFS_DEFAULT_LEVEL 3 -static ZSTD_parameters zstd_get_btrfs_parameters(size_t src_len) +static ZSTD_parameters zstd_get_btrfs_parameters(unsigned int level, + size_t src_len) { - ZSTD_parameters params = ZSTD_getParams(ZSTD_BTRFS_DEFAULT_LEVEL, - src_len, 0); + ZSTD_parameters params = ZSTD_getParams(level, src_len, 0); if (params.cParams.windowLog > ZSTD_BTRFS_MAX_WINDOWLOG) params.cParams.windowLog = ZSTD_BTRFS_MAX_WINDOWLOG; @@ -36,6 +36,7 @@ struct workspace { void *mem; size_t size; char *buf; + unsigned int req_level; struct list_head list; ZSTD_inBuffer in_buf; ZSTD_outBuffer out_buf; @@ -55,7 +56,12 @@ static void zstd_cleanup_workspace_manager(void) static struct list_head *zstd_get_workspace(unsigned int level) { - return btrfs_get_workspace(&wsm, level); + struct list_head *ws = btrfs_get_workspace(&wsm, level); + struct workspace *workspace = list_entry(ws, struct workspace, list); + + workspace->req_level = level; + + return ws; } static void zstd_put_workspace(struct list_head *ws) @@ -75,7 +81,7 @@ static void zstd_free_workspace(struct list_head *ws) static struct list_head *zstd_alloc_workspace(unsigned int level) { ZSTD_parameters params = - zstd_get_btrfs_parameters(ZSTD_BTRFS_MAX_INPUT); + zstd_get_btrfs_parameters(level, ZSTD_BTRFS_MAX_INPUT); struct workspace *workspace; workspace = kzalloc(sizeof(*workspace), GFP_KERNEL); @@ -117,7 +123,8 @@ static int zstd_compress_pages(struct list_head *ws, unsigned long len = *total_out; const unsigned long nr_dest_pages = *out_pages; unsigned long max_out = nr_dest_pages * PAGE_SIZE; - ZSTD_parameters params = zstd_get_btrfs_parameters(len); + ZSTD_parameters params = zstd_get_btrfs_parameters(workspace->req_level, + len); *out_pages = 0; *total_out = 0; -- 2.17.1