Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3925230imu; Mon, 28 Jan 2019 13:27:13 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ZtOxmz3lLGM1luWclTF935c3PaEiQ/wgjTcQZJzpjHVUnPfWLKpkiQQNX7zmBHgre9Wrg X-Received: by 2002:a17:902:b592:: with SMTP id a18mr23409958pls.293.1548710833381; Mon, 28 Jan 2019 13:27:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548710833; cv=none; d=google.com; s=arc-20160816; b=eVBNvci6eZEzGQxCFNm/EX8/hGThgl/2EYtLrYKndMzHWSI+pCCupau3liby8vKxE8 dHstj1sR7BsvcH41VCMjxLGixEAa+n2jpVGI9gQRreD2/p4ybOu+w/178AWLRVx/Zc6i t92E237jnu6x8731k2LZxF17ycBSe1WTsbpnP2FO+RE46Mdczsu0zhM1ihZ7IHDt+Zk1 I4Zpcv26vWCTRLjjepDML5ZEp6AKnhhyyTTJMuLYVxJ1o5lgjrkHn4KUknHM9hsUd7CD CRrQbzzaa7EAkj/PWaZpsyRH2o3K/h2A5Omfiqi2fLlTkAG+NSXOpYsKycZB+w1Iy+3f G3hw== 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=V9/6QDtWudym7hvxLzXEVyuXETxb6FE0Jk6cpZNUt5M=; b=nJTubRBdp5YHqtmX4hzlGhtCrby78jydVG3J2AiS81J2lP7apkd/Tmzo3mTRpDPR3u BczHFvuOKG2Rw5cFerOAtHPKc6J8rPyHx6XSeRV3C5J1ETWjHinVokJeLcdU7RAS6jqB W/ExO6+i+rJYwpTMPWKDWW3ulKWqvMcXdVrkPA/KOeyIZbC+/8cLW5Wz/lCFmfxS6rCG mGrCyigiPh2H87vV6jlNfYtMTCs0IeOHo2B4X0+GuyfX+1JPDFK+QAuz9MHfyMOTaUYN 7MSbM4sG0RjdfzUA1Na7mxI+5zmTZHVYvy85PVXJH6LhXiLfj9+8eUdNREAAVFT2muuT NzIg== 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 10si7409336pfy.206.2019.01.28.13.26.57; Mon, 28 Jan 2019 13:27:13 -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 S1728562AbfA1VZo (ORCPT + 99 others); Mon, 28 Jan 2019 16:25:44 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:45459 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728111AbfA1VYv (ORCPT ); Mon, 28 Jan 2019 16:24:51 -0500 Received: by mail-yb1-f195.google.com with SMTP id t11so2165190ybi.12; Mon, 28 Jan 2019 13:24:50 -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=V9/6QDtWudym7hvxLzXEVyuXETxb6FE0Jk6cpZNUt5M=; b=jSe29YILpeXOWAC91sVqt35NDpDGKkW+KThhEl3Aqxz9xOS5X8MAPcXC9wN0F/W32+ qt4Cr0Sxjhkinci3HY9onNEGd52V8jEPaH+u22k0Be37egQDD73RKLsv/Ke1+M0HMrGW tyMbKKiMMfMs7ohh6DDpMdYjHmGUJrk1M1yiOgvDuNBRNxHmF6m6FVkRlGeQfwU2VKYs s7HZVgmmwVFCD8ZU4WBrpKnZKdWCKGpWj2gwg6tKoGPDxzP/9X6moZwPXHoEjiLeAttp UuSrdf0ncDqY4h3cWQVshvhBywWRYArP3ZEFQEe09FmY3Q0Njw4cqJ0VUNgE+INWCbP5 uO2A== X-Gm-Message-State: AJcUukclGPK6bMksn6Dk2n0GQK6nYF6ZBT9eOJZY02kjylAkeKdibBSn 3A5eX869mGVnrqjqnYJfYac= X-Received: by 2002:a25:2f92:: with SMTP id v140mr22633996ybv.257.1548710690360; Mon, 28 Jan 2019 13:24:50 -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.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 28 Jan 2019 13:24:49 -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 04/11] btrfs: unify compression ops with workspace_manager Date: Mon, 28 Jan 2019 16:24:30 -0500 Message-Id: <20190128212437.11597-5-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 Make the workspace_manager own the interface operations rather than managing index-paired arrays for the workspace_manager and compression operations. Signed-off-by: Dennis Zhou --- fs/btrfs/compression.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/fs/btrfs/compression.c b/fs/btrfs/compression.c index bda7e8d2cbc7..b7e986e16640 100644 --- a/fs/btrfs/compression.c +++ b/fs/btrfs/compression.c @@ -777,6 +777,7 @@ const struct btrfs_compress_op btrfs_heuristic_compress = { }; struct workspace_manager { + const struct btrfs_compress_op *ops; struct list_head idle_ws; spinlock_t ws_lock; /* Number of free workspaces */ @@ -802,6 +803,8 @@ void __init btrfs_init_compress(void) int i; for (i = 0; i < BTRFS_COMPRESS_TYPES; i++) { + wsm[i].ops = btrfs_compress_op[i]; + INIT_LIST_HEAD(&wsm[i].idle_ws); spin_lock_init(&wsm[i].ws_lock); atomic_set(&wsm[i].total_ws, 0); @@ -811,7 +814,7 @@ void __init btrfs_init_compress(void) * Preallocate one workspace for each compression type so * we can guarantee forward progress in the worst case */ - workspace = btrfs_compress_op[i]->alloc_workspace(); + workspace = wsm[i].ops->alloc_workspace(); if (IS_ERR(workspace)) { pr_warn("BTRFS: cannot preallocate compression workspace, will try later\n"); } else { @@ -874,7 +877,7 @@ static struct list_head *find_workspace(int type) * context of btrfs_compress_bio/btrfs_compress_pages */ nofs_flag = memalloc_nofs_save(); - workspace = btrfs_compress_op[type]->alloc_workspace(); + workspace = wsm[type].ops->alloc_workspace(); memalloc_nofs_restore(nofs_flag); if (IS_ERR(workspace)) { @@ -932,7 +935,7 @@ static void free_workspace(int type, struct list_head *workspace) } spin_unlock(ws_lock); - btrfs_compress_op[type]->free_workspace(workspace); + wsm[type].ops->free_workspace(workspace); atomic_dec(total_ws); wake: cond_wake_up(ws_wait); @@ -950,7 +953,7 @@ static void free_workspaces(void) while (!list_empty(&wsm[i].idle_ws)) { workspace = wsm[i].idle_ws.next; list_del(workspace); - btrfs_compress_op[i]->free_workspace(workspace); + wsm[i].ops->free_workspace(workspace); atomic_dec(&wsm[i].total_ws); } } -- 2.17.1