From patchwork Thu Dec 5 04:29:12 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274171 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2C781109A for ; Thu, 5 Dec 2019 04:29:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A54F2245C for ; Thu, 5 Dec 2019 04:29:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="VV0EgKFk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728560AbfLEE3d (ORCPT ); Wed, 4 Dec 2019 23:29:33 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:40064 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3d (ORCPT ); Wed, 4 Dec 2019 23:29:33 -0500 Received: by mail-lf1-f67.google.com with SMTP id y5so1374390lfy.7 for ; Wed, 04 Dec 2019 20:29:31 -0800 (PST) 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=ef5rNQy/9R2qhyIXv8LAgVHiMMgU/UWmJrYPihoKTNk=; b=VV0EgKFk+KO7ukEQrA1kvfK4VLBUvgI7RX0AXD67K4NkuAlmO1th8Vog5PLTeHt/0H JkSvHciR3I0rcJFGLZM4BUiogo7mkSekGkh+BtxK5PRRY31FTbiSCfzlKPuLtDOBuBCJ +eZD0qJ8NPEry+cFfbrVzn/NLehTb0TUPlwS+Y+Sw7JFt5T3XE6CJCX5/fjpjonlPWsx klZtswN7Uv2WfIFo241MLSR9EmDxn5JbT4TPnOdOd7DVH8JmC+0CYAYaFHvVSJXRco2e wOFlfukvb7KtCggLQHGSDMX8X9GWN7iq/nDoCzBkQVLatTNn5twdv7fiG3UAcW8WMJ3o 7aVQ== 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=ef5rNQy/9R2qhyIXv8LAgVHiMMgU/UWmJrYPihoKTNk=; b=lVckkVIKRqibadQ8CaKKY+L+e5ZexSayjbBu0s9tDOxXv9qvJEgAPWhvzAK2UHa7tr QFkRRFrOlb2OjG+ZbBTiF5JPfRh9nnbQb9BjFj+VTXm/tqBCesQu8fqusEdtLcDuspQc 7EMCW5OwmdjFFfU33Q/WJ7riY5wVtqthajUsGEgtAK1kOGjE+IVIk7aYjtyuBT+8a7gS 87IYXYQBj1MxdMuS9BL/99K8Zrq7jqsrMl1S2bj05Pd1JZkiiuatu9HrgcthCp9UkAF+ +AOIYhWliQcCcphZnxh/HRhfIswIUVOMI0YV996eR3paEJRjTu+0ctZqWB0BihTMFdde AeYA== X-Gm-Message-State: APjAAAVzUHmhNNxlYyxB1NuRYFrlsB3X9uEo0oARp1zgUVCRnJuR51j3 sjnAaVaI0EIhU6Am92Y5I4hXSek95Bc= X-Google-Smtp-Source: APXvYqx0BihXIS9wkmbo3lRlAsxjpB2HDmlTE7hgERSf0ebrLi6yh7TyXO5BgPBDSLVBA+UCqZOstg== X-Received: by 2002:ac2:485c:: with SMTP id 28mr4054211lfy.118.1575520170837; Wed, 04 Dec 2019 20:29:30 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:30 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 01/10] btrfs-progs: handle error if btrfs_write_one_block_group() failed Date: Thu, 5 Dec 2019 12:29:12 +0800 Message-Id: <20191205042921.25316-2-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue Just break loop and return the error code if failed. Functions in the call chain are able to handle it. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- extent-tree.c | 4 +++- transaction.c | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index 53be4f4c7369..4a3db029e811 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -1596,9 +1596,11 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans) cache = (struct btrfs_block_group_cache *)(unsigned long)ptr; ret = write_one_cache_group(trans, path, cache); + if (ret) + break; } btrfs_free_path(path); - return 0; + return ret; } static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info, diff --git a/transaction.c b/transaction.c index 45bb9e1f9de6..c9035c765a74 100644 --- a/transaction.c +++ b/transaction.c @@ -77,7 +77,9 @@ static int update_cowonly_root(struct btrfs_trans_handle *trans, &root->root_item); if (ret < 0) return ret; - btrfs_write_dirty_block_groups(trans); + ret = btrfs_write_dirty_block_groups(trans); + if (ret) + return ret; } return 0; } From patchwork Thu Dec 5 04:29:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274173 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 044E4109A for ; Thu, 5 Dec 2019 04:29:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D77112245C for ; Thu, 5 Dec 2019 04:29:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="R8DjRi52" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728776AbfLEE3g (ORCPT ); Wed, 4 Dec 2019 23:29:36 -0500 Received: from mail-lj1-f193.google.com ([209.85.208.193]:40581 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3g (ORCPT ); Wed, 4 Dec 2019 23:29:36 -0500 Received: by mail-lj1-f193.google.com with SMTP id s22so1876803ljs.7 for ; Wed, 04 Dec 2019 20:29:34 -0800 (PST) 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=fEkU+lExaC8aMF1om9LYbS9c3bG5vp2JC6PTWezjjGo=; b=R8DjRi52qQ6und8wkAeshRBm9UnEh6JkA5XzMawm27NrHuqC7yEV1YXgCWi2l/hvip Y+YwT/qkh86dOSzJg8UgOmbXLz0loP6lFrc42MQ1dkzEfmX4y3WBwhgNqK5AHupa4NCA Wgo/nHSdL1zuJIesSd5t+xS2Zi87MpKvLlBmmefKmzCoNnlJqZQFLWk93qJXY3iVrp+c VOxXVUQKO84cS9IBUxS/ZFeaFxNMJh6ezGycEg/HHp/dsPI4sb4vyINwwiN+MxAb08vt dw3KwxoLLcviEsLpS7Bvam/P0jOMW+2QzNQHIg02vxmQK1GscxG97QY9hoPNGzkYgVxG OV+g== 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=fEkU+lExaC8aMF1om9LYbS9c3bG5vp2JC6PTWezjjGo=; b=IvrLfcid5YdFUUeM67qHw2RClTFCDYIo2ZczR+BVSOufZdJs+QmS74VY1XMRsYFhmD /rvaEQH3+gnsivPIkvBbad91xblmNmgE7AUJUetglMW4/sM00ct/UqTRaEdRuCUEGzee z09jEcgsqbhRlSeGvaNeSZUvqJmXouVIkHjED3RSoU4+BVibHynOL7OgwHMC5Qp4N1G3 MCmJ/jnwPvMSx6iR2wyqQ1G2xNWWt7MvFGH1MjPaPZIF4MWkSRF6Id9jW1uv3t2A+MU4 2pU+Ye17YgMtXlP1GbuwWM6oFxhrKgjg44wp0zhoxR+Yu2MGL9euoLTwQE73nlXhoLYD 1nfg== X-Gm-Message-State: APjAAAXxFhIh18tEXmGLNE0gdZNRvt212XESjTYcj7Z3Dd4giNWBp4KP QWqOmX2Yng4cSAYJbGwjxIv/vpBFHNo= X-Google-Smtp-Source: APXvYqzftnHPnlXmL85e+Ic++jjL5n/erFtMU2n2aTHtThMXQQnjsQiKz5fPJ1yOEngBMsUU0WAbdA== X-Received: by 2002:a2e:7d0c:: with SMTP id y12mr4088519ljc.39.1575520173629; Wed, 04 Dec 2019 20:29:33 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:33 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 02/10] btrfs-progs: block_group: add rb tree related memebers Date: Thu, 5 Dec 2019 12:29:13 +0800 Message-Id: <20191205042921.25316-3-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue To convert from existed extent_cache to plain rb_tree, add btrfs_block_group_cache::cache_node and btrfs_fs_info::block_group_ cache_tree. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- ctree.h | 21 ++++++++++++--------- disk-io.c | 2 ++ 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/ctree.h b/ctree.h index 3e50d0863bde..f3f5f52f2559 100644 --- a/ctree.h +++ b/ctree.h @@ -1107,16 +1107,18 @@ struct btrfs_block_group_cache { int cached; int ro; /* - * If the free space extent count exceeds this number, convert the block - * group to bitmaps. - */ - u32 bitmap_high_thresh; - /* - * If the free space extent count drops below this number, convert the - * block group back to extents. - */ - u32 bitmap_low_thresh; + * If the free space extent count exceeds this number, convert the block + * group to bitmaps. + */ + u32 bitmap_high_thresh; + /* + * If the free space extent count drops below this number, convert the + * block group back to extents. + */ + u32 bitmap_low_thresh; + /* Block group cache stuff */ + struct rb_node cache_node; }; struct btrfs_device; @@ -1146,6 +1148,7 @@ struct btrfs_fs_info { struct extent_io_tree extent_ins; struct extent_io_tree *excluded_extents; + struct rb_root block_group_cache_tree; /* logical->physical extent mapping */ struct btrfs_mapping_tree mapping_tree; diff --git a/disk-io.c b/disk-io.c index 659f8b93a7ca..b7ae72a99f59 100644 --- a/disk-io.c +++ b/disk-io.c @@ -797,6 +797,8 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr) extent_io_tree_init(&fs_info->block_group_cache); extent_io_tree_init(&fs_info->pinned_extents); extent_io_tree_init(&fs_info->extent_ins); + + fs_info->block_group_cache_tree = RB_ROOT; fs_info->excluded_extents = NULL; fs_info->fs_root_tree = RB_ROOT; From patchwork Thu Dec 5 04:29:14 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274175 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 71C91112B for ; Thu, 5 Dec 2019 04:29:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4FDBC206DB for ; Thu, 5 Dec 2019 04:29:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C2V79rct" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728847AbfLEE3i (ORCPT ); Wed, 4 Dec 2019 23:29:38 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44879 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3i (ORCPT ); Wed, 4 Dec 2019 23:29:38 -0500 Received: by mail-lj1-f194.google.com with SMTP id c19so1844352lji.11 for ; Wed, 04 Dec 2019 20:29:37 -0800 (PST) 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=IieLt4RY+lRPoXEcpgZM30llPw+0ObXerqajWE+Ds24=; b=C2V79rctCBwqb8OMkZISLlFg1eNg48aOBsk+j7CKj9w9R37Cfr/cK6+1BmLSJ5LrrY kP3XydR58eTVdvqaEVn75vK/3DjAi1hq1o2aQfhRutBrVoQGUIUPAMEg9dmnOALw7TGV 4M0SXkwS6rW4Bmezd3PuUyo1TuAIHxb+v7zuBHVfkIlwR43HxBW5LK5oBpJegGuWQukA empGrtLa0rDX2vxeMJaxrg0TDPtCGoTkdexjDhIpSzlmxJUYKNPTT27Jpn646eAc49BK x6jP3RpkQlCoWL46hwgFGhTQT8fsqGaAfRVmBz7Yk7UAI95CasziSMiQ6AP6i2hnRvbW Z8PA== 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=IieLt4RY+lRPoXEcpgZM30llPw+0ObXerqajWE+Ds24=; b=AUTSrk9ORzXUQFITnG4KLrkMezWYUCHJ+iw92RrVI7eVprpQXH0u9f0263huw6DUUR s798t+1wsO7HPLb06IJM/gRT8seGFV4EyWw2kt3+owjIQtBRqubOZgRysghiuePKxC/D tn48EBpcaK+Ea295Z0+VqGodUtoWysVkYq7yC1QlZZ1Zu02k8P7wtlsv145sFAR+RdzL Rv4PmOfyWTkiVv95JadCquJWGtEblH3+EKg397hlxr39jwUwk7vHk9x+Aicek2vKd9z6 ikxLFZdMS0TLeXFRTOL2IktixJU8gF6qv3TtdtG3LygfxeMV1uhVtPp6LVb9zuEFwWlP Z6qQ== X-Gm-Message-State: APjAAAVaik/eJun5xJ7Dm/ePaLw/pICkWpS5y5VaHSSsi25/mUj56w8O h5UgB8duLY8nM3wieBr5xBrGhoOwcIs= X-Google-Smtp-Source: APXvYqy8iEkT/nYc5xZg5tVNZU/h22VTXqBgvSoyPkfUFCP/fy58NvhzsWLw+v90gWtwp5b2qqTwKw== X-Received: by 2002:a2e:2418:: with SMTP id k24mr4257513ljk.49.1575520176509; Wed, 04 Dec 2019 20:29:36 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:36 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 03/10] btrfs-progs: port block group cache tree insertion and lookup functions Date: Thu, 5 Dec 2019 12:29:14 +0800 Message-Id: <20191205042921.25316-4-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue Simple copy and paste codes, remove useless lock operantions in progs. Th new coming lookup functions are named with suffix _kernel in temporary. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- extent-tree.c | 86 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) diff --git a/extent-tree.c b/extent-tree.c index 4a3db029e811..ab576f8732a2 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -164,6 +164,92 @@ err: return 0; } +/* + * This adds the block group to the fs_info rb tree for the block group cache + */ +static int btrfs_add_block_group_cache(struct btrfs_fs_info *info, + struct btrfs_block_group_cache *block_group) +{ + struct rb_node **p; + struct rb_node *parent = NULL; + struct btrfs_block_group_cache *cache; + + p = &info->block_group_cache_tree.rb_node; + + while (*p) { + parent = *p; + cache = rb_entry(parent, struct btrfs_block_group_cache, + cache_node); + if (block_group->key.objectid < cache->key.objectid) + p = &(*p)->rb_left; + else if (block_group->key.objectid > cache->key.objectid) + p = &(*p)->rb_right; + else + return -EEXIST; + } + + rb_link_node(&block_group->cache_node, parent, p); + rb_insert_color(&block_group->cache_node, + &info->block_group_cache_tree); + + return 0; +} + +/* + * This will return the block group at or after bytenr if contains is 0, else + * it will return the block group that contains the bytenr + */ +static struct btrfs_block_group_cache *block_group_cache_tree_search( + struct btrfs_fs_info *info, u64 bytenr, int contains) +{ + struct btrfs_block_group_cache *cache, *ret = NULL; + struct rb_node *n; + u64 end, start; + + n = info->block_group_cache_tree.rb_node; + + while (n) { + cache = rb_entry(n, struct btrfs_block_group_cache, + cache_node); + end = cache->key.objectid + cache->key.offset - 1; + start = cache->key.objectid; + + if (bytenr < start) { + if (!contains && (!ret || start < ret->key.objectid)) + ret = cache; + n = n->rb_left; + } else if (bytenr > start) { + if (contains && bytenr <= end) { + ret = cache; + break; + } + n = n->rb_right; + } else { + ret = cache; + break; + } + } + return ret; +} + +/* + * Return the block group that starts at or after bytenr + */ +struct btrfs_block_group_cache *btrfs_lookup_first_block_group_kernel( + struct btrfs_fs_info *info, u64 bytenr) +{ + return block_group_cache_tree_search(info, bytenr, 0); +} + +/* + * Return the block group that contains the given bytenr + */ +struct btrfs_block_group_cache *btrfs_lookup_block_group_kernel( + struct btrfs_fs_info *info, u64 bytenr) +{ + return block_group_cache_tree_search(info, bytenr, 1); +} + /* * Return the block group that contains @bytenr, otherwise return the next one * that starts after @bytenr From patchwork Thu Dec 5 04:29:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274177 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 82C01112B for ; Thu, 5 Dec 2019 04:29:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 611D72245C for ; Thu, 5 Dec 2019 04:29:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YTAGnmFP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728879AbfLEE3l (ORCPT ); Wed, 4 Dec 2019 23:29:41 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:32810 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3l (ORCPT ); Wed, 4 Dec 2019 23:29:41 -0500 Received: by mail-lj1-f195.google.com with SMTP id 21so1929235ljr.0 for ; Wed, 04 Dec 2019 20:29:40 -0800 (PST) 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=KkE9f8o4C1OrIuAl7+lxsirTVlWroGkSzZA9s/nYbMg=; b=YTAGnmFPYDtPZnweQr9+bhbv4ZT13TK6QuJqsMWNaxaUlasJZilaxZiRFUjngeza9/ 7HloN3u7Oq3jou4coAfCsrwQuK5HelzYi+I128/ndU/gmAEGplzc+x1dZvqEWBkQ2mFb jN323d3p7MPCdeMTb4mJSX9vVo6R9I0vHOB56BerC9EFUGbxQkoGtcWguETUMzW3zvm+ 9ZDuAZ0vLOqMitDV5krl5qYNGRvuvkaX/wCDJX5TT6YxoAVFXQRyItEf+gOnUlMzuMlr RtMj5u+YCa97m19JpyCYDekgHdbIov71UqzmWTuUPksWYfjCPg9SWmNWAG7GJpajsycI To6A== 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=KkE9f8o4C1OrIuAl7+lxsirTVlWroGkSzZA9s/nYbMg=; b=flrjbywcwOBhRtoxitsgssTauflVi4K23aufz7LypB7gf7N/rCrd5r0n8wN6ZFjasd TAMOsw0dxseGb/UHRzjLNSoC1e3m9Cy2ixsqjzjohuJJ/qWb1yx0JEyM2jiIqUsQpXl+ gitvLaYPhhR96ce2tebpJHQG4RXbyxungnw21ikkBwohEqZhUsqcqggv89KQhBWAAJUL ZsJdxugY9ntB3KLqLYEXZ6B8Wv6GoCebU2S2iWnjpBgJespCLi/WWUoMem5Rix5J9XhP vjkMastpSzb0UOMOSXU3VbZpCaSgtlFFkLG2eoJz0XBAxCqZpAzX8nyx1M0vrZPz2Y6z yRvg== X-Gm-Message-State: APjAAAWm/LNdzcaNYfHMZHiy70lOMQ/wd6bmqzNnP4sKsC9NJ7NyG47E dvbuc6abloEhrL7bwPfntX4hB/UGZ9Q= X-Google-Smtp-Source: APXvYqyDjioQcKAoQ1fVHuN9PeJ5CaXRqir7J+IwKhfIeUURPi/QUdc/pCk4iDcqPdPMgd3RcVRsYA== X-Received: by 2002:a2e:9755:: with SMTP id f21mr4158873ljj.23.1575520179197; Wed, 04 Dec 2019 20:29:39 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:38 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 04/10] btrfs-progs: reform the function block_group_cache_tree_search() Date: Thu, 5 Dec 2019 12:29:15 +0800 Message-Id: <20191205042921.25316-5-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue Add the new value 2 of @contains in block_group_cache_tree_search(). The new values means the function will return the block group that contains bytenr, otherwise return the next one that starts after @bytenr. Will be used in later commit. Signed-off-by: Su Yue --- extent-tree.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index ab576f8732a2..1d8535049eaf 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -196,13 +196,16 @@ static int btrfs_add_block_group_cache(struct btrfs_fs_info *info, } /* - * This will return the block group at or after bytenr if contains is 0, else - * it will return the block group that contains the bytenr + * @contains: + * if 0, return the block group at or after bytenr if contains is 0. + * if 1, return the block group that contains the bytenr. + * if 2, return the block group that contains bytenr, otherwise return the + * next one that starts after @bytenr. */ static struct btrfs_block_group_cache *block_group_cache_tree_search( struct btrfs_fs_info *info, u64 bytenr, int contains) { - struct btrfs_block_group_cache *cache, *ret = NULL; + struct btrfs_block_group_cache *cache, *ret = NULL, *tmp = NULL; struct rb_node *n; u64 end, start; @@ -215,8 +218,8 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search( start = cache->key.objectid; if (bytenr < start) { - if (!contains && (!ret || start < ret->key.objectid)) - ret = cache; + if (!tmp || start < tmp->key.objectid) + tmp = cache; n = n->rb_left; } else if (bytenr > start) { if (contains && bytenr <= end) { @@ -229,6 +232,13 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search( break; } } + + /* + * If ret is NULL, means not found any block group cotanins @bytenr. + * So just except the case that cotanins equals 1. + */ + if (!ret && contains != 1) + ret = tmp; return ret; } From patchwork Thu Dec 5 04:29:16 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274179 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EB1B109A for ; Thu, 5 Dec 2019 04:29:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0D5B92245C for ; Thu, 5 Dec 2019 04:29:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QyngdsTe" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728905AbfLEE3o (ORCPT ); Wed, 4 Dec 2019 23:29:44 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:38804 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3o (ORCPT ); Wed, 4 Dec 2019 23:29:44 -0500 Received: by mail-lf1-f66.google.com with SMTP id r14so1389461lfm.5 for ; Wed, 04 Dec 2019 20:29:42 -0800 (PST) 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=plN9bZ8l10NAXFz0goFOvDFv7yREYJtRK02ru4ZZBS8=; b=QyngdsTeEmlxPpLufe4z51Gakq9AJprmd/wnFjiI8JcxtpkRxbGd7UzWbXHNW4HDng fhK+FaCIhxy1eL17ziC5qzrO92dIjKcydI28Sy/8hL+Zx6yj/M+cEBuqZjDoKizRLjZ/ fB+k50KPAN4HI/83Ppf+BQFv/DF+eD9xvRen2MBEZ7Ys+0HRORR0hNhq8LjkCfUcq5BT F8tkXS3tcegL5f5kCdcaAdYp4xaNkYQh38UB2OLhrNd+k5JjcnIFwS9FMXLiTjZn4I8F 2ZD+WSZZHdlp5sfd7jpAk3Wwb6HiBo14f536Am7btNV7PzTiX/6Pk0120DfxzviLR1kh l1UA== 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=plN9bZ8l10NAXFz0goFOvDFv7yREYJtRK02ru4ZZBS8=; b=cheQxJdgIye5FPWp/k0gJY+9kWZqAiwJ4Fd1vI+u7xi0+F32sxKOog74zA8XtVPNwQ ec2hFpvlNPBmMI9PQavQwG4fSUMFhl5K6SO4oIogihDGCtUqXyV27xqSkAw2QosAaFK8 zxaXrrIVXro/f+bp3lVJHEOvtBKez9d6fNThycY/EP5yYql/8QKX5OrqJoRJyPlnty5x oMN1dle7fFWGxV18UWqE/mGLoUkZ94/qx+lhT39i1U4FTcr9vfYRo861/zVUGj3oWdFQ 8bX2rp2VNRLC9ALjEiVwYGBdyjtYFJdKg9EtL/BZr+RMFQSk9uxOENQMREVevB6h5pwG 04oA== X-Gm-Message-State: APjAAAVTjQNHl0DDMKHJQ/NcsmUXFETE7Gq50IU+Q4QPybFi08SzJ23R w1Bg1RNqK83P8pQQXifU0tUQG1qNFbs= X-Google-Smtp-Source: APXvYqw/QKPQyVyvVK5OXwmmgKonlhlYPsdq/QUPH8HZsiXhPsIjWRstlW6dKtAAlJfOJ+5z5ZVCtw== X-Received: by 2002:a19:6e43:: with SMTP id q3mr3742661lfk.152.1575520181865; Wed, 04 Dec 2019 20:29:41 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:41 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 05/10] btrfs-progs: adjust function btrfs_lookup_first_block_group_kernel Date: Thu, 5 Dec 2019 12:29:16 +0800 Message-Id: <20191205042921.25316-6-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue The are different behavior of btrfs_lookup_first_block_group() and btrfs_lookup_first_block_group_kernel(). Unify the latter' behavior. Signed-off-by: Su Yue --- extent-tree.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index 1d8535049eaf..274dfe540b1f 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -243,12 +243,13 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search( } /* - * Return the block group that starts at or after bytenr + * Return the block group that contains @bytenr, otherwise return the next one + * that starts after @bytenr */ struct btrfs_block_group_cache *btrfs_lookup_first_block_group_kernel( struct btrfs_fs_info *info, u64 bytenr) { - return block_group_cache_tree_search(info, bytenr, 0); + return block_group_cache_tree_search(info, bytenr, 2); } /* From patchwork Thu Dec 5 04:29:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274181 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 07FDE112B for ; Thu, 5 Dec 2019 04:29:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id DB55F2245C for ; Thu, 5 Dec 2019 04:29:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q2xzbae+" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728921AbfLEE3s (ORCPT ); Wed, 4 Dec 2019 23:29:48 -0500 Received: from mail-lf1-f66.google.com ([209.85.167.66]:45798 "EHLO mail-lf1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3s (ORCPT ); Wed, 4 Dec 2019 23:29:48 -0500 Received: by mail-lf1-f66.google.com with SMTP id 203so1347255lfa.12 for ; Wed, 04 Dec 2019 20:29:46 -0800 (PST) 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=HvpCphNZyP2oaaPtjxVrPwL1Z76XALw4LzvC5hkUvSk=; b=Q2xzbae+RKliQcIimgQe9nDMjWfNw30lX/SPPM1MJ1GI9Qj3c9eajXybw7IVutLHdF NasPSqYyC5MJKvJ320iA0a7PPe24t3JmMcR3HX47UBysW2u62GyEfc/lAc9AzF3+/qxW OAyeV0BH4fGy4HSzskgCwGTkMwXPc9i+p5Ir3CD1rZm+hxxwB7SU3EScCmVnzc8YN4nI 8AezXw8SAiGVXicRkAiUv15+TecQIykmkwbPGyKVUBcUbig2BauZos0vF25Dd1XsH0t0 o2RB2HEsAYm6cFhZjjs7Or7vh/1gnBPOX8XwQoGnE2r08sKx/p5wPsv/BCUFMN5k8D/h ox9Q== 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=HvpCphNZyP2oaaPtjxVrPwL1Z76XALw4LzvC5hkUvSk=; b=fsNj0cQFKRwMxE9n2sL47t+p7Qs9ccVFlXD7EYqhbJxYsNMqRl73cvPN0p2LRvxmAC Y1bYEKx8fj3OgCrG+3zFZDw+aLDfv9Ic3TbcfIrLSGe1l8DJ8+1Uvl22YKTdyHJ2dpGI szH151GR0EDpA9IcAVEVxqRirVax2oqhAd3vgIaJRKwFaI3opxslQjHdMo41FRznq11Q oNGnSWzXfy5N5N1MnkgjIlR3guJBFvOMVmfUlFx8a2CNxVclzxCsaKGMeeLLLuJCM5yT N8StKq+HUg1g1TtSfR+BavhJJO+HsxBWhdSe1jJrFG4z8ud2cGOoSU0265yH6j4fNWN7 qKxA== X-Gm-Message-State: APjAAAUpxcaKkyCy1f7LHreBGmqsnEtcTkE78IjXR83aOaIhwh7HiBKR ELAZOkmCQ8QrQHChMS5JwiyRybjK4Do= X-Google-Smtp-Source: APXvYqztvediDqiAauRG99aDIFWQ+2CP5qzxRAR+SvZJKZTmB8ha0acDja9beB360KgRXspcf01v7w== X-Received: by 2002:ac2:51a6:: with SMTP id f6mr3940153lfk.174.1575520185193; Wed, 04 Dec 2019 20:29:45 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:44 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 06/10] btrfs-progs: abstract function btrfs_add_block_group_cache() Date: Thu, 5 Dec 2019 12:29:17 +0800 Message-Id: <20191205042921.25316-7-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue The new function btrfs_add_block_group_cache() abstracts the old set_extent_bits and set_state_private operations. Rename the rb tree version to btrfs_add_block_group_cache_kernel(). Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- extent-tree.c | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index 274dfe540b1f..ff3db5ca2e0c 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -164,10 +164,31 @@ err: return 0; } +static int btrfs_add_block_group_cache(struct btrfs_fs_info *info, + struct btrfs_block_group_cache *cache, + int bits) +{ + int ret; + + ret = set_extent_bits(&info->block_group_cache, cache->key.objectid, + cache->key.objectid + cache->key.offset - 1, + bits); + if (ret) + return ret; + + ret = set_state_private(&info->block_group_cache, cache->key.objectid, + (unsigned long)cache); + if (ret) + clear_extent_bits(&info->block_group_cache, cache->key.objectid, + cache->key.objectid + cache->key.offset - 1, + bits); + return ret; +} + /* * This adds the block group to the fs_info rb tree for the block group cache */ -static int btrfs_add_block_group_cache(struct btrfs_fs_info *info, +static int btrfs_add_block_group_cache_kernel(struct btrfs_fs_info *info, struct btrfs_block_group_cache *block_group) { struct rb_node **p; @@ -2769,7 +2790,6 @@ error: static int read_one_block_group(struct btrfs_fs_info *fs_info, struct btrfs_path *path) { - struct extent_io_tree *block_group_cache = &fs_info->block_group_cache; struct extent_buffer *leaf = path->nodes[0]; struct btrfs_space_info *space_info; struct btrfs_block_group_cache *cache; @@ -2819,11 +2839,7 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info, } cache->space_info = space_info; - set_extent_bits(block_group_cache, cache->key.objectid, - cache->key.objectid + cache->key.offset - 1, - bit | EXTENT_LOCKED); - set_state_private(block_group_cache, cache->key.objectid, - (unsigned long)cache); + btrfs_add_block_group_cache(fs_info, cache, bit | EXTENT_LOCKED); return 0; } @@ -2875,9 +2891,6 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, int ret; int bit = 0; struct btrfs_block_group_cache *cache; - struct extent_io_tree *block_group_cache; - - block_group_cache = &fs_info->block_group_cache; cache = kzalloc(sizeof(*cache), GFP_NOFS); BUG_ON(!cache); @@ -2894,13 +2907,8 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, BUG_ON(ret); bit = block_group_state_bits(type); - ret = set_extent_bits(block_group_cache, chunk_offset, - chunk_offset + size - 1, - bit | EXTENT_LOCKED); - BUG_ON(ret); - ret = set_state_private(block_group_cache, chunk_offset, - (unsigned long)cache); + ret = btrfs_add_block_group_cache(fs_info, cache, bit | EXTENT_LOCKED); BUG_ON(ret); set_avail_alloc_bits(fs_info, type); @@ -2950,9 +2958,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, int bit; struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_block_group_cache *cache; - struct extent_io_tree *block_group_cache; - block_group_cache = &fs_info->block_group_cache; total_bytes = btrfs_super_total_bytes(fs_info->super_copy); group_align = 64 * fs_info->sectorsize; @@ -2996,12 +3002,8 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, 0, &cache->space_info); BUG_ON(ret); set_avail_alloc_bits(fs_info, group_type); - - set_extent_bits(block_group_cache, cur_start, - cur_start + group_size - 1, - bit | EXTENT_LOCKED); - set_state_private(block_group_cache, cur_start, - (unsigned long)cache); + btrfs_add_block_group_cache(fs_info, cache, + bit | EXTENT_LOCKED); cur_start += group_size; } /* then insert all the items */ From patchwork Thu Dec 5 04:29:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274183 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BDF2D112B for ; Thu, 5 Dec 2019 04:29:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9B9B3206DB for ; Thu, 5 Dec 2019 04:29:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZvdVyLg7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728941AbfLEE3u (ORCPT ); Wed, 4 Dec 2019 23:29:50 -0500 Received: from mail-lj1-f194.google.com ([209.85.208.194]:44904 "EHLO mail-lj1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3u (ORCPT ); Wed, 4 Dec 2019 23:29:50 -0500 Received: by mail-lj1-f194.google.com with SMTP id c19so1844742lji.11 for ; Wed, 04 Dec 2019 20:29:49 -0800 (PST) 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=CzGXAo6NWlDbJoJnmBn9VK8wJ79E6fS2CoAtW1V63aI=; b=ZvdVyLg7Au8pX78OpbzIRxV7ls/5ETfZS2k4coy0BHyjn0OjeaoWe/pmGjhFlAus6K /ZnE7rU5XUX9d+97h5Cf/SdPXeSyksS6uFNzRGPSi3YSoOJgwZuOQRayQl31DZP9NnPN JnV7VI4bJLnT84nIGdUdRENWKhsplcq4KnhFU6n7kkNtz0M8g/nEDD27xsmXrqy/4eWt KAOOQd1qvPsNmPSI10xYA8rO8pX7zIjOs08K7yoMzaGjXxwqM0CLLxLBbUaQFA8rFpnD HT7b61J2e7Vo6vuskDO+CM7RwxDTquoT9uK8SQ1qXyDRzAPCBuMKpw83n6Ur7vR45kn4 jFsw== 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=CzGXAo6NWlDbJoJnmBn9VK8wJ79E6fS2CoAtW1V63aI=; b=EpZr4D3SFyDLFVbvWOWQ6yuxUOBnvqI6JoH0PZeUlVg/IyHvlqaPStO8C/z2NFkt/E r0OTVJ5zbMkWE88HhpvXcTjKHJLAPmBf7XhuQKeW8RJE5h1xVqu154CJ7FzvjdzBE8b5 tXIKSHGGm8IQpLVuLudeeC/tFl+H2LkIq7v1nj2gNgJQZhLssgKPhXMBauYIrVF0ktCP Ye3TTfkmhfX+dtkT7YZ/4bS29go8tAfWzLDzOlG1aQz14rZtdPMLYFVw/IoDpPIldPA6 v3Bu9IqaRWAiLfsR9IppLNE8I7rh6rayMXufVclHalwH9l6rU+WjmhLb62B/SuMQ9Ux8 EAxw== X-Gm-Message-State: APjAAAXE7HhfX62DoE6foNFS3zqLc4u6F028XXFPQOQazazCk5NBboB0 MrZuN95s+/GL0TEJ7TeCJ6zuwhKL82k= X-Google-Smtp-Source: APXvYqxNkTeh/s6ab5Urxx8VZZHDsoTg+9oiAEPojR4K2fcPjkH/qsgt30kgX47XNBnsGdVTNfnECw== X-Received: by 2002:a2e:58c:: with SMTP id 134mr4197136ljf.12.1575520188149; Wed, 04 Dec 2019 20:29:48 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:47 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 07/10] block-progs: block_group: add dirty_bgs list related memebers Date: Thu, 5 Dec 2019 12:29:18 +0800 Message-Id: <20191205042921.25316-8-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue The old style uses extent bit BLOCK_GROUP_DIRTY to mark dirty block groups in extent cache. To replace it, add btrfs_trans_handle::dirty_bgs and btrfs_block_group_cache::dirty_list. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- ctree.h | 3 +++ extent-tree.c | 4 ++++ transaction.c | 1 + transaction.h | 3 ++- 4 files changed, 10 insertions(+), 1 deletion(-) diff --git a/ctree.h b/ctree.h index f3f5f52f2559..61ce53c46302 100644 --- a/ctree.h +++ b/ctree.h @@ -1119,6 +1119,9 @@ struct btrfs_block_group_cache { /* Block group cache stuff */ struct rb_node cache_node; + + /* For dirty block groups */ + struct list_head dirty_list; }; struct btrfs_device; diff --git a/extent-tree.c b/extent-tree.c index ff3db5ca2e0c..981622e37ab7 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -2819,6 +2819,8 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info, cache->pinned = 0; cache->flags = btrfs_block_group_flags(&bgi); cache->used = btrfs_block_group_used(&bgi); + INIT_LIST_HEAD(&cache->dirty_list); + if (cache->flags & BTRFS_BLOCK_GROUP_DATA) { bit = BLOCK_GROUP_DATA; } else if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) { @@ -2900,6 +2902,7 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; cache->used = bytes_used; cache->flags = type; + INIT_LIST_HEAD(&cache->dirty_list); exclude_super_stripes(fs_info, cache); ret = update_space_info(fs_info, cache->flags, size, bytes_used, @@ -2997,6 +3000,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, cache->key.type = BTRFS_BLOCK_GROUP_ITEM_KEY; cache->used = 0; cache->flags = group_type; + INIT_LIST_HEAD(&cache->dirty_list); ret = update_space_info(fs_info, group_type, group_size, 0, &cache->space_info); diff --git a/transaction.c b/transaction.c index c9035c765a74..269e52c01d29 100644 --- a/transaction.c +++ b/transaction.c @@ -52,6 +52,7 @@ struct btrfs_trans_handle* btrfs_start_transaction(struct btrfs_root *root, root->last_trans = h->transid; root->commit_root = root->node; extent_buffer_get(root->node); + INIT_LIST_HEAD(&h->dirty_bgs); return h; } diff --git a/transaction.h b/transaction.h index 750f456b3cc0..8fa65508fa8d 100644 --- a/transaction.h +++ b/transaction.h @@ -22,6 +22,7 @@ #include "kerncompat.h" #include "ctree.h" #include "delayed-ref.h" +#include "kernel-lib/list.h" struct btrfs_trans_handle { struct btrfs_fs_info *fs_info; @@ -35,7 +36,7 @@ struct btrfs_trans_handle { unsigned long blocks_used; struct btrfs_block_group_cache *block_group; struct btrfs_delayed_ref_root delayed_refs; - + struct list_head dirty_bgs; }; struct btrfs_trans_handle* btrfs_start_transaction(struct btrfs_root *root, From patchwork Thu Dec 5 04:29:19 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274185 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4F049109A for ; Thu, 5 Dec 2019 04:29:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 237302245C for ; Thu, 5 Dec 2019 04:29:55 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="D1cbf8yQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728953AbfLEE3y (ORCPT ); Wed, 4 Dec 2019 23:29:54 -0500 Received: from mail-lj1-f175.google.com ([209.85.208.175]:40673 "EHLO mail-lj1-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE3y (ORCPT ); Wed, 4 Dec 2019 23:29:54 -0500 Received: by mail-lj1-f175.google.com with SMTP id s22so1877405ljs.7 for ; Wed, 04 Dec 2019 20:29:51 -0800 (PST) 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=aqN/reM2FdnsWrwmKgOP0wEi0Ji2L+JRUBIFXRT3UXQ=; b=D1cbf8yQkg+0kvTrcNrUlj2l/S2BsQxB45uDBI3HdYKykGxAMcLfuvJQlN6N5z6mLJ HfqJTtsNUO1ul3VcKAEPI8N2LxplEhPSkXi7Dxtqmj2dJk0O1s0Q3ESKS6lejnuhifwj F6BYKPBalV5hI5kX12lrIBMSVGbFVLYRN1ayDzi73dUdqI6ZGTnJanJOPiQMTT9OfD46 Sc0moL+Ho45W97LEn2/Ip5u3+80wAZ2gB3MbfdE1yvtVxXl4SdsherIuBwxgPpXqYoJT g8caj/cgXpRCTpAR8pj2cvvVGI5/Jc5jCfMhqwrFJjrnG/rcOxZpc/nf/Pv98nTQwOX4 SWJQ== 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=aqN/reM2FdnsWrwmKgOP0wEi0Ji2L+JRUBIFXRT3UXQ=; b=gt+SBioQOZnWIgr2EhZcQCD4N75tU8XDSt8b63azq9RFObbJ88aer3Xk5ipoImAq6c 657xjGt4N5JtiBlLl5RpG/MLPdiSy1Sn+GJ2/pG/mkW+ns9dg8k/XawoRS5nvkTX2uuK /2wOHBPM33OMBMC0L8U1vt/9Tyi9v03mfItbBTOzvjBOiVR5HADXIXcKaVLwfW69kLXe tuZXEVd8d5PkaHuyk0hDtDBcdw7ljkvE6jZ9mNcX9qo6uviliVuSpfHClkbRHxPcVzF7 LFSdRbwlkUr2YPJ5vSFjG4svtBMYxMcc/M/Sc71l9tf69hHOBLX4lnFnG+jkVUiL5VOj zs/w== X-Gm-Message-State: APjAAAXK4mFBWb9CFYcvllKq0uAaeZsm39Fbkyg9ltu1MgV+9NLH0JxY YkL1ZvSElZF62/xHl+rtNs9fBJzsUEY= X-Google-Smtp-Source: APXvYqwy1rOZuI3SgXy7Qt4hyDAEijWK6PTTLbmnT7ODHFwyjhp86BpOviMyNu2K30rfvswQrwjOFQ== X-Received: by 2002:a2e:9f4c:: with SMTP id v12mr3558973ljk.167.1575520190856; Wed, 04 Dec 2019 20:29:50 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:50 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 08/10] btrfs-progs: pass @trans to functions touch dirty block groups Date: Thu, 5 Dec 2019 12:29:19 +0800 Message-Id: <20191205042921.25316-9-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue We are going to touch dirty_bgs in trans directly, so every call chain should pass paramemter @trans to end functions. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- check/main.c | 6 +++--- check/mode-lowmem.c | 6 +++--- cmds/rescue-chunk-recover.c | 6 +++--- ctree.h | 4 ++-- extent-tree.c | 18 +++++++++--------- image/main.c | 5 +++-- 6 files changed, 23 insertions(+), 22 deletions(-) diff --git a/check/main.c b/check/main.c index 08dc9e66d013..7d797750e6d6 100644 --- a/check/main.c +++ b/check/main.c @@ -6651,8 +6651,8 @@ static int delete_extent_records(struct btrfs_trans_handle *trans, u64 bytes = (found_key.type == BTRFS_EXTENT_ITEM_KEY) ? found_key.offset : fs_info->nodesize; - ret = btrfs_update_block_group(fs_info->extent_root, - bytenr, bytes, 0, 0); + ret = btrfs_update_block_group(trans, bytenr, bytes, + 0, 0); if (ret) break; } @@ -6730,7 +6730,7 @@ static int record_extent(struct btrfs_trans_handle *trans, } btrfs_mark_buffer_dirty(leaf); - ret = btrfs_update_block_group(extent_root, rec->start, + ret = btrfs_update_block_group(trans, rec->start, rec->max_size, 1, 0); if (ret) goto fail; diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c index f53a0c39e86e..74c60368ca01 100644 --- a/check/mode-lowmem.c +++ b/check/mode-lowmem.c @@ -735,7 +735,7 @@ static int repair_tree_block_ref(struct btrfs_root *root, } btrfs_mark_buffer_dirty(eb); printf("Added an extent item [%llu %u]\n", bytenr, node_size); - btrfs_update_block_group(extent_root, bytenr, node_size, 1, 0); + btrfs_update_block_group(trans, bytenr, node_size, 1, 0); nrefs->refs[level] = 0; nrefs->full_backref[level] = @@ -3292,8 +3292,8 @@ static int repair_extent_data_item(struct btrfs_root *root, btrfs_set_extent_flags(eb, ei, BTRFS_EXTENT_FLAG_DATA); btrfs_mark_buffer_dirty(eb); - ret = btrfs_update_block_group(extent_root, disk_bytenr, - num_bytes, 1, 0); + ret = btrfs_update_block_group(trans, disk_bytenr, num_bytes, + 1, 0); btrfs_release_path(&path); } diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c index 171b4d07ecf9..461b66c6e13b 100644 --- a/cmds/rescue-chunk-recover.c +++ b/cmds/rescue-chunk-recover.c @@ -1084,7 +1084,7 @@ err: return ret; } -static int block_group_free_all_extent(struct btrfs_root *root, +static int block_group_free_all_extent(struct btrfs_trans_handle *trans, struct block_group_record *bg) { struct btrfs_block_group_cache *cache; @@ -1092,7 +1092,7 @@ static int block_group_free_all_extent(struct btrfs_root *root, u64 start; u64 end; - info = root->fs_info; + info = trans->fs_info; cache = btrfs_lookup_block_group(info, bg->objectid); if (!cache) return -ENOENT; @@ -1124,7 +1124,7 @@ static int remove_chunk_extent_item(struct btrfs_trans_handle *trans, if (ret) return ret; - ret = block_group_free_all_extent(root, chunk->bg_rec); + ret = block_group_free_all_extent(trans, chunk->bg_rec); if (ret) return ret; } diff --git a/ctree.h b/ctree.h index 61ce53c46302..53882d04ac03 100644 --- a/ctree.h +++ b/ctree.h @@ -2568,8 +2568,8 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans, u64 type, u64 chunk_offset, u64 size); int btrfs_make_block_groups(struct btrfs_trans_handle *trans, struct btrfs_fs_info *fs_info); -int btrfs_update_block_group(struct btrfs_root *root, u64 bytenr, u64 num, - int alloc, int mark_free); +int btrfs_update_block_group(struct btrfs_trans_handle *trans, u64 bytenr, + u64 num, int alloc, int mark_free); int btrfs_record_file_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root, u64 objectid, struct btrfs_inode_item *inode, diff --git a/extent-tree.c b/extent-tree.c index 981622e37ab7..f012fd5bf6b6 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -1877,9 +1877,10 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans, return 0; } -static int update_block_group(struct btrfs_fs_info *info, u64 bytenr, +static int update_block_group(struct btrfs_trans_handle *trans, u64 bytenr, u64 num_bytes, int alloc, int mark_free) { + struct btrfs_fs_info *info = trans->fs_info; struct btrfs_block_group_cache *cache; u64 total = num_bytes; u64 old_val; @@ -2242,8 +2243,7 @@ static int __free_extent(struct btrfs_trans_handle *trans, goto fail; } - update_block_group(trans->fs_info, bytenr, num_bytes, 0, - mark_free); + update_block_group(trans, bytenr, num_bytes, 0, mark_free); } fail: btrfs_free_path(path); @@ -2575,7 +2575,7 @@ static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, if (ret) return ret; - ret = update_block_group(fs_info, ins.objectid, fs_info->nodesize, 1, + ret = update_block_group(trans, ins.objectid, fs_info->nodesize, 1, 0); if (sinfo) { if (fs_info->nodesize > sinfo->bytes_reserved) { @@ -3031,11 +3031,11 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, return 0; } -int btrfs_update_block_group(struct btrfs_root *root, +int btrfs_update_block_group(struct btrfs_trans_handle *trans, u64 bytenr, u64 num_bytes, int alloc, int mark_free) { - return update_block_group(root->fs_info, bytenr, num_bytes, + return update_block_group(trans, bytenr, num_bytes, alloc, mark_free); } @@ -3449,12 +3449,12 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans) btrfs_item_key_to_cpu(leaf, &key, slot); if (key.type == BTRFS_EXTENT_ITEM_KEY) { bytes_used += key.offset; - ret = btrfs_update_block_group(root, + ret = btrfs_update_block_group(trans, key.objectid, key.offset, 1, 0); BUG_ON(ret); } else if (key.type == BTRFS_METADATA_ITEM_KEY) { bytes_used += fs_info->nodesize; - ret = btrfs_update_block_group(root, + ret = btrfs_update_block_group(trans, key.objectid, fs_info->nodesize, 1, 0); if (ret) goto out; @@ -3609,7 +3609,7 @@ static int __btrfs_record_file_extent(struct btrfs_trans_handle *trans, BTRFS_EXTENT_FLAG_DATA); btrfs_mark_buffer_dirty(leaf); - ret = btrfs_update_block_group(root, disk_bytenr, + ret = btrfs_update_block_group(trans, disk_bytenr, num_bytes, 1, 0); if (ret) goto fail; diff --git a/image/main.c b/image/main.c index bddb49720f0a..f88ffb16bafe 100644 --- a/image/main.c +++ b/image/main.c @@ -2338,8 +2338,9 @@ again: return 0; } -static void fixup_block_groups(struct btrfs_fs_info *fs_info) +static void fixup_block_groups(struct btrfs_trans_handle *trans) { + struct btrfs_fs_info *fs_info = trans->fs_info; struct btrfs_block_group_cache *bg; struct btrfs_mapping_tree *map_tree = &fs_info->mapping_tree; struct cache_extent *ce; @@ -2499,7 +2500,7 @@ static int fixup_chunks_and_devices(struct btrfs_fs_info *fs_info, return PTR_ERR(trans); } - fixup_block_groups(fs_info); + fixup_block_groups(trans); ret = fixup_dev_extents(trans); if (ret < 0) goto error; From patchwork Thu Dec 5 04:29:20 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274187 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D56A1109A for ; Thu, 5 Dec 2019 04:29:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A9444206DB for ; Thu, 5 Dec 2019 04:29:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="J5DzMRGI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728968AbfLEE36 (ORCPT ); Wed, 4 Dec 2019 23:29:58 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42398 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728374AbfLEE36 (ORCPT ); Wed, 4 Dec 2019 23:29:58 -0500 Received: by mail-lj1-f196.google.com with SMTP id e28so1860944ljo.9 for ; Wed, 04 Dec 2019 20:29:54 -0800 (PST) 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=0Avc27aOeg+ZzuTSnDAeZo9DepxGHXQTs4ne2eOmewo=; b=J5DzMRGIYUhEJbzZ3SHRt5kyE7Xj0dYC2ozicxfb+s667H/zl65VD96wnTwQP1qBO5 0Ry1cJnN9NugtmFTU0XWKVeqdVKPLpoOTz0WejnMRwQPiKHq00N5e/HgkC45IA7aMGF2 M4wkgQpGD21oswXJbxPdqXILKUONTYoUyB763ffJtGjQRBsNmBJANRw5m4o3qdUZWHGF KxRl9VFY7duUqw2FD0fPDcbAp6lITlPZ7T/oZCHY8EKMSea4q/8WH10PAYSch4GhCf67 wp/dKcxPpyCpaKvAJAtyA78ej+INsG/mXSyggPdKxWWiVd7xR/OHTQhkCdqnEDMXcptl Y4/g== 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=0Avc27aOeg+ZzuTSnDAeZo9DepxGHXQTs4ne2eOmewo=; b=nB8/HTQRvKXq6BTfe+LHNUvhztWHsbvQKA5H4hrqNRbSN7p/P6/RFmlgE6seXCA3kN NGvK9ciSwF7sxCvdAgBtgYDiNMl76Y1c8QVOvK0iaNKWxxP8AGMQlWBImPzeJFosNUiF Vd2RwpTOkVO6Q9ZXEpO+zApSN83T1B+PmgLzoewMOiIo2cclkSqxO5blVlT/CbPsqx+r tOT6KKsoOyHHGh8Kv6/Lmklt5xW3MvddssO6OxC+fBv95EwMeBytC7vthNnkrHfKA9aT r4WeMwgW3UvM+gFOIxn5gMSb+XpYeATqqtcKj8M7C7pgRPQoZi0oac6+CF/HTipfHMqX gj3A== X-Gm-Message-State: APjAAAVjkkB0I6xLuaMvpf/9xoQRomnfSPxI4BIgaxi5hH019WfPTfu1 GNjKB56uCC4kTrG/kQN9ujxI4QZTXw4= X-Google-Smtp-Source: APXvYqwAuoJ8EN03ZtsqGLAqvmHSCH87HU37s3H1Dn/h0O/Etf7xTPgDRUhnwa0jlGQaQD+Jp0O1vA== X-Received: by 2002:a05:651c:2011:: with SMTP id s17mr3907238ljo.43.1575520193693; Wed, 04 Dec 2019 20:29:53 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:53 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 09/10] btrfs-progs: refrom block groups caches structure Date: Thu, 5 Dec 2019 12:29:20 +0800 Message-Id: <20191205042921.25316-10-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue This commit organises block groups cache in btrfs_fs_info::block_group_cache_tree. And any dirty block groups are linked in transaction_handle::dirty_bgs. To keep coherence of bisect, it does almost replace in place: 1. Replace the old btrfs group lookup functions with new functions introduced in former commits. 2. set_extent_bits(..., BLOCK_GROUP_DIRYT) things are replaced by linking the block group cache into trans::dirty_bgs. Checking and clearing bits are transformed too. 3. set_extent_bits(..., bit | EXTENT_LOCKED) things are replaced by new the btrfs_add_block_group_cache() which inserts caches into btrfs_fs_info::block_group_cache_tree directly. Other operations are converted to tree operations. Signed-off-by: Su Yue --- cmds/rescue-chunk-recover.c | 4 +- extent-tree.c | 211 ++++++------------------------------ image/main.c | 5 +- transaction.c | 3 +- 4 files changed, 38 insertions(+), 185 deletions(-) diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c index 461b66c6e13b..a13acc015d11 100644 --- a/cmds/rescue-chunk-recover.c +++ b/cmds/rescue-chunk-recover.c @@ -1100,8 +1100,8 @@ static int block_group_free_all_extent(struct btrfs_trans_handle *trans, start = cache->key.objectid; end = start + cache->key.offset - 1; - set_extent_bits(&info->block_group_cache, start, end, - BLOCK_GROUP_DIRTY); + if (list_empty(&cache->dirty_list)) + list_add_tail(&cache->dirty_list, &trans->dirty_bgs); set_extent_dirty(&info->free_space_cache, start, end); cache->used = 0; diff --git a/extent-tree.c b/extent-tree.c index f012fd5bf6b6..e227c4db51cf 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -164,31 +164,10 @@ err: return 0; } -static int btrfs_add_block_group_cache(struct btrfs_fs_info *info, - struct btrfs_block_group_cache *cache, - int bits) -{ - int ret; - - ret = set_extent_bits(&info->block_group_cache, cache->key.objectid, - cache->key.objectid + cache->key.offset - 1, - bits); - if (ret) - return ret; - - ret = set_state_private(&info->block_group_cache, cache->key.objectid, - (unsigned long)cache); - if (ret) - clear_extent_bits(&info->block_group_cache, cache->key.objectid, - cache->key.objectid + cache->key.offset - 1, - bits); - return ret; -} - /* * This adds the block group to the fs_info rb tree for the block group cache */ -static int btrfs_add_block_group_cache_kernel(struct btrfs_fs_info *info, +static int btrfs_add_block_group_cache(struct btrfs_fs_info *info, struct btrfs_block_group_cache *block_group) { struct rb_node **p; @@ -267,7 +246,7 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search( * Return the block group that contains @bytenr, otherwise return the next one * that starts after @bytenr */ -struct btrfs_block_group_cache *btrfs_lookup_first_block_group_kernel( +struct btrfs_block_group_cache *btrfs_lookup_first_block_group( struct btrfs_fs_info *info, u64 bytenr) { return block_group_cache_tree_search(info, bytenr, 2); @@ -276,78 +255,12 @@ struct btrfs_block_group_cache *btrfs_lookup_first_block_group_kernel( /* * Return the block group that contains the given bytenr */ -struct btrfs_block_group_cache *btrfs_lookup_block_group_kernel( +struct btrfs_block_group_cache *btrfs_lookup_block_group( struct btrfs_fs_info *info, u64 bytenr) { return block_group_cache_tree_search(info, bytenr, 1); } -/* - * Return the block group that contains @bytenr, otherwise return the next one - * that starts after @bytenr - */ -struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct - btrfs_fs_info *info, - u64 bytenr) -{ - struct extent_io_tree *block_group_cache; - struct btrfs_block_group_cache *block_group = NULL; - u64 ptr; - u64 start; - u64 end; - int ret; - - bytenr = max_t(u64, bytenr, - BTRFS_SUPER_INFO_OFFSET + BTRFS_SUPER_INFO_SIZE); - block_group_cache = &info->block_group_cache; - ret = find_first_extent_bit(block_group_cache, - bytenr, &start, &end, - BLOCK_GROUP_DATA | BLOCK_GROUP_METADATA | - BLOCK_GROUP_SYSTEM); - if (ret) { - return NULL; - } - ret = get_state_private(block_group_cache, start, &ptr); - if (ret) - return NULL; - - block_group = (struct btrfs_block_group_cache *)(unsigned long)ptr; - return block_group; -} - -/* - * Return the block group that contains the given @bytenr - */ -struct btrfs_block_group_cache *btrfs_lookup_block_group(struct - btrfs_fs_info *info, - u64 bytenr) -{ - struct extent_io_tree *block_group_cache; - struct btrfs_block_group_cache *block_group = NULL; - u64 ptr; - u64 start; - u64 end; - int ret; - - block_group_cache = &info->block_group_cache; - ret = find_first_extent_bit(block_group_cache, - bytenr, &start, &end, - BLOCK_GROUP_DATA | BLOCK_GROUP_METADATA | - BLOCK_GROUP_SYSTEM); - if (ret) { - return NULL; - } - ret = get_state_private(block_group_cache, start, &ptr); - if (ret) - return NULL; - - block_group = (struct btrfs_block_group_cache *)(unsigned long)ptr; - if (block_group->key.objectid <= bytenr && bytenr < - block_group->key.objectid + block_group->key.offset) - return block_group; - return NULL; -} - static int block_group_bits(struct btrfs_block_group_cache *cache, u64 bits) { return (cache->flags & bits) == bits; @@ -437,28 +350,18 @@ btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache *hint, u64 search_start, int data, int owner) { struct btrfs_block_group_cache *cache; - struct extent_io_tree *block_group_cache; struct btrfs_block_group_cache *found_group = NULL; struct btrfs_fs_info *info = root->fs_info; u64 used; u64 last = 0; u64 hint_last; - u64 start; - u64 end; u64 free_check; - u64 ptr; - int bit; - int ret; int full_search = 0; int factor = 10; - block_group_cache = &info->block_group_cache; - if (!owner) factor = 10; - bit = block_group_state_bits(data); - if (search_start) { struct btrfs_block_group_cache *shint; shint = btrfs_lookup_block_group(info, search_start); @@ -488,16 +391,10 @@ btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache } again: while(1) { - ret = find_first_extent_bit(block_group_cache, last, - &start, &end, bit); - if (ret) - break; - - ret = get_state_private(block_group_cache, start, &ptr); - if (ret) + cache = btrfs_lookup_first_block_group(info, last); + if (!cache) break; - cache = (struct btrfs_block_group_cache *)(unsigned long)ptr; last = cache->key.objectid + cache->key.offset; used = cache->used; @@ -1681,38 +1578,18 @@ fail: int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans) { - struct extent_io_tree *block_group_cache; struct btrfs_block_group_cache *cache; - int ret; struct btrfs_path *path; - u64 last = 0; - u64 start; - u64 end; - u64 ptr; + int ret; - block_group_cache = &trans->fs_info->block_group_cache; path = btrfs_alloc_path(); if (!path) return -ENOMEM; - while(1) { - ret = find_first_extent_bit(block_group_cache, last, - &start, &end, BLOCK_GROUP_DIRTY); - if (ret) { - if (last == 0) - break; - last = 0; - continue; - } - - last = end + 1; - ret = get_state_private(block_group_cache, start, &ptr); - BUG_ON(ret); - - clear_extent_bits(block_group_cache, start, end, - BLOCK_GROUP_DIRTY); - - cache = (struct btrfs_block_group_cache *)(unsigned long)ptr; + while (!list_empty(&trans->dirty_bgs)) { + cache = list_first_entry(&trans->dirty_bgs, + struct btrfs_block_group_cache, dirty_list); + list_del_init(&cache->dirty_list); ret = write_one_cache_group(trans, path, cache); if (ret) break; @@ -1885,8 +1762,6 @@ static int update_block_group(struct btrfs_trans_handle *trans, u64 bytenr, u64 total = num_bytes; u64 old_val; u64 byte_in_group; - u64 start; - u64 end; /* block accounting for super block */ old_val = btrfs_super_bytes_used(info->super_copy); @@ -1903,11 +1778,8 @@ static int update_block_group(struct btrfs_trans_handle *trans, u64 bytenr, } byte_in_group = bytenr - cache->key.objectid; WARN_ON(byte_in_group > cache->key.offset); - start = cache->key.objectid; - end = start + cache->key.offset - 1; - set_extent_bits(&info->block_group_cache, start, end, - BLOCK_GROUP_DIRTY); - + if (list_empty(&cache->dirty_list)) + list_add_tail(&cache->dirty_list, &trans->dirty_bgs); old_val = cache->used; num_bytes = min(total, cache->key.offset - byte_in_group); @@ -2699,25 +2571,22 @@ int btrfs_free_block_groups(struct btrfs_fs_info *info) struct btrfs_block_group_cache *cache; u64 start; u64 end; - u64 ptr; int ret; - while(1) { - ret = find_first_extent_bit(&info->block_group_cache, 0, - &start, &end, (unsigned int)-1); - if (ret) + while (rb_first(&info->block_group_cache_tree)) { + cache = btrfs_lookup_first_block_group(info, 0); + if (!cache) break; - ret = get_state_private(&info->block_group_cache, start, &ptr); - if (!ret) { - cache = u64_to_ptr(ptr); - if (cache->free_space_ctl) { - btrfs_remove_free_space_cache(cache); - kfree(cache->free_space_ctl); - } - kfree(cache); + + if (!list_empty(&cache->dirty_list)) + list_del_init(&cache->dirty_list); + rb_erase(&cache->cache_node, &info->block_group_cache_tree); + RB_CLEAR_NODE(&cache->cache_node); + if (cache->free_space_ctl) { + btrfs_remove_free_space_cache(cache); + kfree(cache->free_space_ctl); } - clear_extent_bits(&info->block_group_cache, start, - end, (unsigned int)-1); + kfree(cache); } while(1) { ret = find_first_extent_bit(&info->free_space_cache, 0, @@ -2796,7 +2665,6 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info, struct btrfs_block_group_item bgi; struct btrfs_key key; int slot = path->slots[0]; - int bit = 0; int ret; btrfs_item_key_to_cpu(leaf, &key, slot); @@ -2821,13 +2689,6 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info, cache->used = btrfs_block_group_used(&bgi); INIT_LIST_HEAD(&cache->dirty_list); - if (cache->flags & BTRFS_BLOCK_GROUP_DATA) { - bit = BLOCK_GROUP_DATA; - } else if (cache->flags & BTRFS_BLOCK_GROUP_SYSTEM) { - bit = BLOCK_GROUP_SYSTEM; - } else if (cache->flags & BTRFS_BLOCK_GROUP_METADATA) { - bit = BLOCK_GROUP_METADATA; - } set_avail_alloc_bits(fs_info, cache->flags); if (btrfs_chunk_readonly(fs_info, cache->key.objectid)) cache->ro = 1; @@ -2841,7 +2702,7 @@ static int read_one_block_group(struct btrfs_fs_info *fs_info, } cache->space_info = space_info; - btrfs_add_block_group_cache(fs_info, cache, bit | EXTENT_LOCKED); + btrfs_add_block_group_cache(fs_info, cache); return 0; } @@ -2891,7 +2752,6 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, u64 chunk_offset, u64 size) { int ret; - int bit = 0; struct btrfs_block_group_cache *cache; cache = kzalloc(sizeof(*cache), GFP_NOFS); @@ -2909,9 +2769,7 @@ btrfs_add_block_group(struct btrfs_fs_info *fs_info, u64 bytes_used, u64 type, &cache->space_info); BUG_ON(ret); - bit = block_group_state_bits(type); - - ret = btrfs_add_block_group_cache(fs_info, cache, bit | EXTENT_LOCKED); + ret = btrfs_add_block_group_cache(fs_info, cache); BUG_ON(ret); set_avail_alloc_bits(fs_info, type); @@ -2958,7 +2816,6 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, u64 total_data = 0; u64 total_metadata = 0; int ret; - int bit; struct btrfs_root *extent_root = fs_info->extent_root; struct btrfs_block_group_cache *cache; @@ -2970,7 +2827,6 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, group_size = total_bytes / 12; group_size = min_t(u64, group_size, total_bytes - cur_start); if (cur_start == 0) { - bit = BLOCK_GROUP_SYSTEM; group_type = BTRFS_BLOCK_GROUP_SYSTEM; group_size /= 4; group_size &= ~(group_align - 1); @@ -3006,8 +2862,7 @@ int btrfs_make_block_groups(struct btrfs_trans_handle *trans, 0, &cache->space_info); BUG_ON(ret); set_avail_alloc_bits(fs_info, group_type); - btrfs_add_block_group_cache(fs_info, cache, - bit | EXTENT_LOCKED); + btrfs_add_block_group_cache(fs_info, cache); cur_start += group_size; } /* then insert all the items */ @@ -3283,8 +3138,9 @@ static int free_block_group_cache(struct btrfs_trans_handle *trans, btrfs_remove_free_space_cache(cache); kfree(cache->free_space_ctl); } - clear_extent_bits(&fs_info->block_group_cache, bytenr, bytenr + len - 1, - (unsigned int)-1); + if (!list_empty(&cache->dirty_list)) + list_del(&cache->dirty_list); + rb_erase(&cache->cache_node, &fs_info->block_group_cache_tree); ret = free_space_info(fs_info, flags, len, 0, NULL); if (ret < 0) goto out; @@ -3417,13 +3273,12 @@ int btrfs_fix_block_accounting(struct btrfs_trans_handle *trans) cache = btrfs_lookup_first_block_group(fs_info, start); if (!cache) break; + start = cache->key.objectid + cache->key.offset; cache->used = 0; cache->space_info->bytes_used = 0; - set_extent_bits(&root->fs_info->block_group_cache, - cache->key.objectid, - cache->key.objectid + cache->key.offset -1, - BLOCK_GROUP_DIRTY); + if (list_empty(&cache->dirty_list)) + list_add_tail(&cache->dirty_list, &trans->dirty_bgs); } btrfs_init_path(&path); diff --git a/image/main.c b/image/main.c index f88ffb16bafe..95eb3cc3d4de 100644 --- a/image/main.c +++ b/image/main.c @@ -2365,9 +2365,8 @@ static void fixup_block_groups(struct btrfs_trans_handle *trans) /* Update the block group item and mark the bg dirty */ bg->flags = map->type; - set_extent_bits(&fs_info->block_group_cache, ce->start, - ce->start + ce->size - 1, BLOCK_GROUP_DIRTY); - + if (list_empty(&bg->dirty_list)) + list_add_tail(&bg->dirty_list, &trans->dirty_bgs); /* * Chunk and bg flags can be different, changing bg flags * without update avail_data/meta_alloc_bits will lead to diff --git a/transaction.c b/transaction.c index 269e52c01d29..b6b81b2178c8 100644 --- a/transaction.c +++ b/transaction.c @@ -203,8 +203,7 @@ commit_tree: * again, we need to exhause both dirty blocks and delayed refs */ while (!RB_EMPTY_ROOT(&trans->delayed_refs.href_root) || - test_range_bit(&fs_info->block_group_cache, 0, (u64)-1, - BLOCK_GROUP_DIRTY, 0)) { + !list_empty(&trans->dirty_bgs)) { ret = btrfs_write_dirty_block_groups(trans); if (ret < 0) goto error; From patchwork Thu Dec 5 04:29:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11274189 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 4B6691593 for ; Thu, 5 Dec 2019 04:30:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 29E7E2245C for ; Thu, 5 Dec 2019 04:30:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="W9RKvPzh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728974AbfLEE37 (ORCPT ); Wed, 4 Dec 2019 23:29:59 -0500 Received: from mail-lj1-f196.google.com ([209.85.208.196]:42401 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728955AbfLEE36 (ORCPT ); Wed, 4 Dec 2019 23:29:58 -0500 Received: by mail-lj1-f196.google.com with SMTP id e28so1861013ljo.9 for ; Wed, 04 Dec 2019 20:29:57 -0800 (PST) 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=/nFPcahWz6Jkwg8oyCwSBtdB1weTJRg2TrMh+XqmgyI=; b=W9RKvPzhnl5caJHte14VbnNPJK1piY1+SwxuCZf9gysYMc+rzaQ3qXhWbxuvHd6WiJ 8f7i7bQjKb0yF5c/byCGoFmJwRZZRrvzZEj2ImtH5oOLUt/3E3QfhJyoF+lltphV0JRy e4v3OMcw67/j+B1BSWoBRaoN45MOfbcBiQLSnmnl84XlJGLxtXxW6bmN1HfwM2w6gR5X KPIngkL+rce+rXdd8MSVS359rDgBgPoFnNoorttNF/oWaaIUfihM8+aiB0W5l9Oy6ToK ZaIwZK/182cr/M0mzUTrmFvA/7EM+e2EHE6Zygzogdt1V0PUm73T1xsYYLgRmp0koEjY dQlg== 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=/nFPcahWz6Jkwg8oyCwSBtdB1weTJRg2TrMh+XqmgyI=; b=n7zbU+c2DDwm1kZXKTkDnMRPuuMUgJO7TSw8cDyCAgyzyQ981w/IZoijcIOdLvXxC2 HN+ntbO/jIdQVZlDbDqz6+pGGJdMHn/f+e3UF6Je7GjOMHHUaXWfHhqfCScOrhCKH8L+ iDWdWB/WjJCUyvVx4I5yg4QhH/uvs1bzppV38bRAVYCsPF4fYxwCaQ6icO0eajbqXNGn w92J/+3WZ2ycK0Fql/OcHFVYxjFALvSUa7NwN4fMtv4xRg4d3tnpp4AloXuXuhg2GGds eIF5baoAcyIvYMRmVZyzussV9UDD1vD6QJQV1BsKReT0bjaOHb6tNLoqV6L05kHnrFMc lrqQ== X-Gm-Message-State: APjAAAWfpw5OA27LnXHbn/47m7AEMZGWVDli4jYPRzCgNx/cm3cvNnKI 5IX6jVq+yWZvia34m8yWT7gxnBbKcZ4= X-Google-Smtp-Source: APXvYqzgS4aYsnJUCyqwl+j6Cdq4EC7mJbl5YHlScU9Ezrzetv84mfHz+AUJeE1XgaHfnVGFG4Gypw== X-Received: by 2002:a2e:a0ce:: with SMTP id f14mr3882363ljm.55.1575520196419; Wed, 04 Dec 2019 20:29:56 -0800 (PST) Received: from p.lan (95.246.92.34.bc.googleusercontent.com. [34.92.246.95]) by smtp.gmail.com with ESMTPSA id c23sm4170865ljj.78.2019.12.04.20.29.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Dec 2019 20:29:55 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue Subject: [PATCH 10/10] btrfs-progs: cleanups after block group cache reform Date: Thu, 5 Dec 2019 12:29:21 +0800 Message-Id: <20191205042921.25316-11-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191205042921.25316-1-Damenly_Su@gmx.com> References: <20191205042921.25316-1-Damenly_Su@gmx.com> MIME-Version: 1.0 Sender: linux-btrfs-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-btrfs@vger.kernel.org From: Su Yue btrfs_fs_info::block_group_cache and the bit BLOCK_GROUP_DIRY are useless. So is the block_group_state_bits(). Remove them. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- ctree.h | 1 - disk-io.c | 2 -- extent-tree.c | 12 ------------ extent_io.h | 2 -- 4 files changed, 17 deletions(-) diff --git a/ctree.h b/ctree.h index 53882d04ac03..6d2fad6406d7 100644 --- a/ctree.h +++ b/ctree.h @@ -1146,7 +1146,6 @@ struct btrfs_fs_info { struct extent_io_tree extent_cache; struct extent_io_tree free_space_cache; - struct extent_io_tree block_group_cache; struct extent_io_tree pinned_extents; struct extent_io_tree extent_ins; struct extent_io_tree *excluded_extents; diff --git a/disk-io.c b/disk-io.c index b7ae72a99f59..95958d9706da 100644 --- a/disk-io.c +++ b/disk-io.c @@ -794,7 +794,6 @@ struct btrfs_fs_info *btrfs_new_fs_info(int writable, u64 sb_bytenr) extent_io_tree_init(&fs_info->extent_cache); extent_io_tree_init(&fs_info->free_space_cache); - extent_io_tree_init(&fs_info->block_group_cache); extent_io_tree_init(&fs_info->pinned_extents); extent_io_tree_init(&fs_info->extent_ins); @@ -1069,7 +1068,6 @@ void btrfs_cleanup_all_caches(struct btrfs_fs_info *fs_info) free_mapping_cache_tree(&fs_info->mapping_tree.cache_tree); extent_io_tree_cleanup(&fs_info->extent_cache); extent_io_tree_cleanup(&fs_info->free_space_cache); - extent_io_tree_cleanup(&fs_info->block_group_cache); extent_io_tree_cleanup(&fs_info->pinned_extents); extent_io_tree_cleanup(&fs_info->extent_ins); } diff --git a/extent-tree.c b/extent-tree.c index e227c4db51cf..2815888b6cc5 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -333,18 +333,6 @@ wrapped: goto again; } -static int block_group_state_bits(u64 flags) -{ - int bits = 0; - if (flags & BTRFS_BLOCK_GROUP_DATA) - bits |= BLOCK_GROUP_DATA; - if (flags & BTRFS_BLOCK_GROUP_METADATA) - bits |= BLOCK_GROUP_METADATA; - if (flags & BTRFS_BLOCK_GROUP_SYSTEM) - bits |= BLOCK_GROUP_SYSTEM; - return bits; -} - static struct btrfs_block_group_cache * btrfs_find_block_group(struct btrfs_root *root, struct btrfs_block_group_cache *hint, u64 search_start, int data, int owner) diff --git a/extent_io.h b/extent_io.h index 1715acc60708..7f88e3f8a305 100644 --- a/extent_io.h +++ b/extent_io.h @@ -47,8 +47,6 @@ #define BLOCK_GROUP_METADATA (1U << 2) #define BLOCK_GROUP_SYSTEM (1U << 4) -#define BLOCK_GROUP_DIRTY (1U) - /* * The extent buffer bitmap operations are done with byte granularity instead of * word granularity for two reasons: