From patchwork Wed Dec 18 05:18:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299543 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 2A695139A for ; Wed, 18 Dec 2019 05:18:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 082F920733 for ; Wed, 18 Dec 2019 05:18:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="vBIJJLeI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725985AbfLRFS5 (ORCPT ); Wed, 18 Dec 2019 00:18:57 -0500 Received: from mail-pg1-f193.google.com ([209.85.215.193]:43646 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFS5 (ORCPT ); Wed, 18 Dec 2019 00:18:57 -0500 Received: by mail-pg1-f193.google.com with SMTP id k197so588044pga.10 for ; Tue, 17 Dec 2019 21:18:56 -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=53WTG0ZE2+rSr5ljxHjD5nykGS67qMrrBZtOVNwxaX4=; b=vBIJJLeI0pzMDJ1F3fQ+wnBjH402UqEy+OQ3Y3RkGwSqxMF3z2o3yQ3tSGG9yY1a2t MZ1RTNYviujoi6ESQeyHtXhQruDpeJZSQ2G+uCUELstsLO9HP7JhPxHqmf4HIVqRUeFg 5/7uULMineMrieOUSG7bStjsSQaG1P+tYgtcdQZjA4P1ptjC6UsDuQGkHI1g7M4IlCr5 MblMiV0sTjMMfRJWK1Bu2HsP7G7kYECGFWMWRQ3Wg6UTgh0K4DVunzYnOV8NxPST2N62 kioF0JPCz63aqdPQEk+FnH6B/MzGvESa3603D6GaWrpK7py4rj23U+rsdiu5GkrnaIu0 Um4Q== 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=53WTG0ZE2+rSr5ljxHjD5nykGS67qMrrBZtOVNwxaX4=; b=K0hZaEJWUxen9KfX6W83PwDMCQuggMd0SO04k6SdiQuUOtsSfg/DZLUIkWxePpf5/+ fdZbAmqgiRQzb5FMtLPKX1ICgq1sefzuApj1USYV/XejFynOMdf/TyAhtJCkm2a4MdiK ypezlywjnVBdGdFn+AAOplwqPZjC1wjpYvcUzA9GKrmLmmhIuM1j/Gubtg6DZLeClT2X 6rN7ibBkgEEdf8Id50GXXryQSG4MQ984rhGiE7iUy6P2osWPCYbBdVa7fgyecTgPUpy7 Kuhj/Gb2RzIo4XAv7NKsUkI+cbqjy5kaDmArYqr/HM7Lk/SsdZxg6htTrhWJmipsogAs kt0Q== X-Gm-Message-State: APjAAAWvWpEwNumwrOCx0IP1H/V0SJSbu6owdxEXuOz8VKjgI3YRWWqT v7nip0UswLmOThZDwF26NxC8OLy/oIE= X-Google-Smtp-Source: APXvYqw86eHVE6leaBbR5F0qYX/X6DNj01+H2vzNEKMziEpxkGeIEirOOL5XyEBVm5l5L1SiJUnZ+Q== X-Received: by 2002:a63:154d:: with SMTP id 13mr889365pgv.248.1576646336118; Tue, 17 Dec 2019 21:18:56 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.18.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:18: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 , Qu Wenruo Subject: [PATCH V2 01/10] btrfs-progs: handle error if btrfs_write_one_block_group() failed Date: Wed, 18 Dec 2019 13:18:40 +0800 Message-Id: <20191218051849.2587-2-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 Wed Dec 18 05:18:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299545 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 42A92139A for ; Wed, 18 Dec 2019 05:19:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 1FD8A20733 for ; Wed, 18 Dec 2019 05:19:00 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pehxWl8R" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726385AbfLRFS7 (ORCPT ); Wed, 18 Dec 2019 00:18:59 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:47009 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFS6 (ORCPT ); Wed, 18 Dec 2019 00:18:58 -0500 Received: by mail-pf1-f196.google.com with SMTP id y14so528535pfm.13 for ; Tue, 17 Dec 2019 21:18:58 -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=K/5Zlarazvm7rWxihrjM2Qo8yD9mwGdvuxH+eDY5RQU=; b=pehxWl8R/LZkQVPKgvK5hZiLg1h4pyP+jzc3HRyPCvQtXV5w0TL3kPhz/BfHdjBQ8R c3whRmCodfXmIS/kqsHZT2x1nCF8kb39Hyb4P8Pu+8OYV183uDjFk/dhTGcDxhWbyeCq 9vo6pTj9cEdsENY+79V/sWD0ctDAQDKDiABmphklvyHQw/BUAnBO/ZhqPl90HD6q+Q2X W26GlPjSGEoZpf7q219OYFLnfVgC6BB1tQ3nu4H03/4qM35x2fdM28kdRIJ5/GZlm2gY gp8GlQWLjdpC7yi/5J2O5F89aOGPtfS5oLD/IGAt+/ABHb4nqxn8vdStfLNqxL5b+pe3 c9/A== 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=K/5Zlarazvm7rWxihrjM2Qo8yD9mwGdvuxH+eDY5RQU=; b=GJPVbPkC5yqzEQzMXcseZ6kHr2c7mobYziEgpKbaokKpf4Dt+nRhrkUMHrQZtshkq9 1S2bOj4S/0NfKCzslZeGWIBOkzQ5fJ+jDuRfF/3MYVCRc5mz+aUJBx+GQCxkJ6B0QBmc TpdwgQ52ED2zvpbJo0LgEi71Xh1Ik6xk0Hg9MDu5EDcMXAslnDpRhgbSD26c9cbZcl7N 5H8L9rvxk7QzJNTqNuKV938yZOJJt43wwSPvbG0/qrD/idPiDzxd41+qMEWIjpOy0rQ6 9pbcGIXUBQKjqEvZj/WScKoOdkLX+lZUoSbf98+DuZMq4a3snc5P9Uig0o2/tXSfxoZL 66dw== X-Gm-Message-State: APjAAAUJhEGoW217JBX5O+LvYGqg/uQPtegIWBQN5Y1vDfIZtRzBFZJd x++dZYb0Mw7kqnd1pdEZKfhDKXlcmu8= X-Google-Smtp-Source: APXvYqxD/R11ZL+4xNBYzNmL1Ym7TQrMPbG7K5DecjKzvANaZoUEkPYBqQiHWdcZOx/7XpAKDpRWBg== X-Received: by 2002:a65:4587:: with SMTP id o7mr800173pgq.303.1576646337935; Tue, 17 Dec 2019 21:18:57 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.18.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:18:57 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue , Qu Wenruo Subject: [PATCH V2 02/10] btrfs-progs: block_group: add rb tree related memebers Date: Wed, 18 Dec 2019 13:18:41 +0800 Message-Id: <20191218051849.2587-3-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 Wed Dec 18 05:18:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299547 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 8AAF014B7 for ; Wed, 18 Dec 2019 05:19:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6970C20733 for ; Wed, 18 Dec 2019 05:19:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UlH3famR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbfLRFTB (ORCPT ); Wed, 18 Dec 2019 00:19:01 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:46703 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTB (ORCPT ); Wed, 18 Dec 2019 00:19:01 -0500 Received: by mail-pl1-f193.google.com with SMTP id y8so420186pll.13 for ; Tue, 17 Dec 2019 21:19:00 -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=1bA/z/NOjsJfR+5fv7Nl7qo6RMjl6/6d04yGOoGNSkE=; b=UlH3famRpFxj+nbtrn7re7HHYoyeMp+rJITVeGyUtZ4ENokhy8Ff+iHdeTQ0ABy6rZ cwctEZvujQKEwA2vjlRV0PVyzLw/QbAYxA1EnqKgmC2JZuAZ1BsMFX0Dsi+2dLQAjvVd ZcgaJSunHE9iLp+22xxwRhJWfskHpJR8pheuJhsCH7sGQ40+DimWWtWxOIw4KHnMLiyb owKx4rSVGq2APFvVxjgslv4ShjcS47cBcV3dZt91GeBWZc4GTLpLK7XmR5dGHt+qD1z/ eFspWHpVnyztOmNBJDKiPuHealcinFWHZWbAW3calsv5YEBTjFvt1a8fouXLM28bLbH4 HHdA== 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=1bA/z/NOjsJfR+5fv7Nl7qo6RMjl6/6d04yGOoGNSkE=; b=sXEsnQM4YLVrGFBAYjlFhkrHwsbe8Ku5Mt9v17G0BxRKl6DN2iElcLcTfryYp1Ci67 S8VUWBXhFj8bLL/Y+YIWp8IgVZKQux821oqis0FiWLeIEuOTU89fT5NqpgN9ulAf2eqF iSW+5DpULC9L/adPd195bpRSMCwxBAbkJtspLyF6Mcln4EzWmTNviTo7pk3HldCKbefL J3rJpf8lvZXkELwwC5sKaKrFikVJk3oKLqxh7KZUZrh6nKw5kXjJ5jwBOIW7tZgVlhX6 DAgVuzPGqAOe/kW2WpELx2mwagXjcSrYkOulB2n5X2wgdmRZbEjrUa4/ufK4a/KpKtb1 yZUw== X-Gm-Message-State: APjAAAWpKbc9I+UY8iyGQWBMkz9MrAo/EKBbq0B3FzqJiPruAYOwBmrY 2juA6iw4YGheQnqNm2Dw2aa/8vqM4RU= X-Google-Smtp-Source: APXvYqyaSU+up3W2XZNoPssbGDMcf8LaHfZwkN4uOOdvFR8jKcuq9H7GoBc4VgNWNMwRNMPudaPwbA== X-Received: by 2002:a17:902:aa96:: with SMTP id d22mr661104plr.218.1576646340029; Tue, 17 Dec 2019 21:19:00 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.18.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:18:59 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue , Qu Wenruo Subject: [PATCH V2 03/10] btrfs-progs: port block group cache tree insertion and lookup functions Date: Wed, 18 Dec 2019 13:18:42 +0800 Message-Id: <20191218051849.2587-4-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 Wed Dec 18 05:18:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299549 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 66E1F14B7 for ; Wed, 18 Dec 2019 05:19:04 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 4426A20733 for ; Wed, 18 Dec 2019 05:19:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="tP4R8UgY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbfLRFTD (ORCPT ); Wed, 18 Dec 2019 00:19:03 -0500 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34175 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTD (ORCPT ); Wed, 18 Dec 2019 00:19:03 -0500 Received: by mail-pg1-f194.google.com with SMTP id r11so615569pgf.1 for ; Tue, 17 Dec 2019 21:19:02 -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=CKFBRoUmGmnpd/QGnFxxXu5em8+IvZnQ3qhGfNNQGEM=; b=tP4R8UgYo75uQ+olNK/50WpRMu2I0Y03frnyZijqEWTYBtynxWehMrBPNJflgdX8Ko sFa9a3BSL0KMJRH1C1xOS0YqF+D0byp5sNhyVaOzjBxXg565GztcPvu8ruf4dYZtpaHj Iu7lgogtrnCxHLLkan8/k+uVpAfUiIcqmVpXne55A6Re3vQxwHMEwkmehBvpvHH2a4Gj ThkAGQ2kc1QAYNAeI50pC1juld/qValOSTvTbPr//X81+0gOd35wFMUPUiAUPJ5XZbkR Ja9vMQqktFH9LIwvr1pZpDLqjIrrFxiXqq/w9BzWQAHPqTinywmPtMEPynKF4CScHbjY ZhoA== 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=CKFBRoUmGmnpd/QGnFxxXu5em8+IvZnQ3qhGfNNQGEM=; b=lGzME/dS7Xz+GNdrG4j0e0OwTCyjrkka192QzMV78xZDBqyo7c5c5FhJ2qG/bMYEN3 3aA+ARpRgvBGo/VelPPJUDeMyVIYd/xMAxYPbXXchnPMCcKZ1RYq/aH4R8zRtzC8G1cV x0o7mg+b/5QEeYrW5rulCbEnX6IDtIpRnOdayNoZxdsxv/4FHcniqzFBnj/4hNxArQdE wt66gn2iJRe/t3Mp5XLXkHeDf/0etQiCL7oaZVdQFIL+Ll8ctyYDKdwB0UfYzRl2jZPn a/WHhOMB58ZdJ/pQC6hUxNqHi3NmE+4xapq+CpFxNu1HmnJR3JI8WQhAPTwOXHysFwfN L6zw== X-Gm-Message-State: APjAAAUqrjNrL3SY9YbEWaKGDeBZesxkh/NL7CFu+U3sLFj5kcbfjCCA 7rTqJysnmGiFYeGVEswk+UAu04NPcQ8= X-Google-Smtp-Source: APXvYqy1ShYpAz+jyF2YatLzHJjFEMNuI4mGxDUos5MvkZr2CHm/HMlC/yyODcpwSQTnd9So3u6/oQ== X-Received: by 2002:a63:2949:: with SMTP id p70mr827281pgp.191.1576646342051; Tue, 17 Dec 2019 21:19:02 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:01 -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 V2 04/10] btrfs-progs: reform the function block_group_cache_tree_search() Date: Wed, 18 Dec 2019 13:18:43 +0800 Message-Id: <20191218051849.2587-5-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 Change @cotnains to @next of block_group_cache_tree_search(). Now, the function will try to search the block group containing the @bytenr. If not found, return NULL if @next is zero. Or It will return the next block group. Will be used in the later commit. Signed-off-by: Su Yue Reviewed-by: Qu Wenruo --- extent-tree.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index ab576f8732a2..fdfa29a2409f 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -196,11 +196,15 @@ 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 + * This will return the block group which contains @bytenr if it exists. + * If found nothing, the return depends on @next. + * + * @next: + * if 0, return NULL if there's no block group containing the bytenr. + * if 1, return the block group which 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_fs_info *info, u64 bytenr, int next) { struct btrfs_block_group_cache *cache, *ret = NULL; struct rb_node *n; @@ -215,11 +219,11 @@ 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)) + if (next && (!ret || start < ret->key.objectid)) ret = cache; n = n->rb_left; } else if (bytenr > start) { - if (contains && bytenr <= end) { + if (bytenr <= end) { ret = cache; break; } @@ -229,6 +233,7 @@ static struct btrfs_block_group_cache *block_group_cache_tree_search( break; } } + return ret; } From patchwork Wed Dec 18 05:18:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299551 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 0311E139A for ; Wed, 18 Dec 2019 05:19:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D558620733 for ; Wed, 18 Dec 2019 05:19:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="HVY0YjTs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726609AbfLRFTG (ORCPT ); Wed, 18 Dec 2019 00:19:06 -0500 Received: from mail-pj1-f68.google.com ([209.85.216.68]:35395 "EHLO mail-pj1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbfLRFTF (ORCPT ); Wed, 18 Dec 2019 00:19:05 -0500 Received: by mail-pj1-f68.google.com with SMTP id s7so323374pjc.0 for ; Tue, 17 Dec 2019 21:19:05 -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=gXax7JZNE33dSeSAAj9Q3yDAJEhxjFi3NVywG/ZE27U=; b=HVY0YjTscWSU1U7smpamoqsrCMad9RtOsLTa6hdJjKb6LlEXNhmIWhaeNuf9WZW5WU GaT6L21nUSX4wpwoOt7lKRs3jDCRiGdq+X6DFB9v76OJmcrAT/M3h3LP1PC2fCaDH6ap OXJwNGSgA18Aa2+xybZW7GwZlaXSiQIb4vTcyrMD4vo9y+OgRgmlCf8mf5952CHLwh04 mWfoDbP4LbQXt53dn3ZjE5kRD8FabAK4Yh8fopc5t3mxzzxhWaS+n2s/XjO694maYk6P xu1YzQeuWGA9Qd1JzLLGuM/Xp2QJMDpwQe/lPJ/ET8N5QxDDhl87WxIp+prGCURXkhHu qzWQ== 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=gXax7JZNE33dSeSAAj9Q3yDAJEhxjFi3NVywG/ZE27U=; b=WU+p1ypuroo/xdwR9FS2vZCrywn6TOd/87KeYXk1cPUi7dpl9vsq0BowspFLyD7UiW kWnilaB/Fkl27X6OQzZm4SHPe/Z3iwUn+a1rnv5T8B+/8TP++BW6IiD2F34EhqSw/LPK KnlpQecP6qbLzTxC/e07QiBw6A6vC2JN0oOu+3T8KCdC3FLw4Jp0KZAk/iVzvRYs96er mT2LUgW5geXvKYZUYjocsH5siaLhRohi10dO7kQ8UfE6HeO7mPyKeuRYcrr3W7oB5HEy hYgKB3scT5eCWxPlQbx1qh85tSKYUghtdvx77ppaYr5DXYWGOFi8ct+XdtNOtBSHPmwc YoHg== X-Gm-Message-State: APjAAAUjQySSmGhOgdUIEVElKJ86IgnrxT+CudvRU0TCve/FEhNAFbUf TswEt5QBMkzm/CfA79Wa0xmY2kbUv/w= X-Google-Smtp-Source: APXvYqwRcJKAaeDQf1/efGG7hCDM127E6szCHWrnGNZjIkks6FvgChTXChajk0FBN+V3d37uSH7CSg== X-Received: by 2002:a17:90a:3243:: with SMTP id k61mr587615pjb.46.1576646344647; Tue, 17 Dec 2019 21:19:04 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:04 -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 V2 05/10] btrfs-progs: adjust ported block group lookup functions in kernel version Date: Wed, 18 Dec 2019 13:18:44 +0800 Message-Id: <20191218051849.2587-6-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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(). There are many palaces calling the lookup function include extent allocation part. It's too complicated to check and change those. It will influence many functionalities in progs. So here, just make kernel version lookup functions run likely in progs behavior. Signed-off-by: Su Yue --- extent-tree.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/extent-tree.c b/extent-tree.c index fdfa29a2409f..3f7b82dc88a2 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -238,12 +238,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, 1); } /* @@ -252,7 +253,7 @@ struct btrfs_block_group_cache *btrfs_lookup_first_block_group_kernel( 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 block_group_cache_tree_search(info, bytenr, 0); } /* From patchwork Wed Dec 18 05:18:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299553 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 819F514B7 for ; Wed, 18 Dec 2019 05:19:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5FB9F206D7 for ; Wed, 18 Dec 2019 05:19:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZRS/cYWs" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726613AbfLRFTI (ORCPT ); Wed, 18 Dec 2019 00:19:08 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:54442 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTI (ORCPT ); Wed, 18 Dec 2019 00:19:08 -0500 Received: by mail-pj1-f65.google.com with SMTP id ep17so317742pjb.4 for ; Tue, 17 Dec 2019 21:19:07 -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=TRe3/RYY3bdTs7wHuyYNDQi7diBg5D8S6FClciXCReg=; b=ZRS/cYWsDmsLlR4FVnhcEKIdroo8WPL501fSh9QwtNI6tNHv31O4PksjLUb9ejocQV McblabD0wzQrA46nkahi5eEDmQSE2DeIaH9vRIWh9cgOHSXD2kkRQcajltLbNOhFlEwO 3R+F0lY/MquYfj8om5XbwxyYUPVAI0VIhTxBVCu8ZPKYdVQdqmCm4v/AdVPsTUmPXNv/ TI1n+nzkUJm4I2ZasOyMIaw7rIvjBNOb00ZTekyW07zNUHObRT+7/SPNVEYH1t+TBisj TRfGPA0Ixtbk4KJ9rdnuIedPEwgfGLVsNLesbO3aZ+2YwSUNzMmrnBYQ2yHiMhwUdZV7 O1hA== 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=TRe3/RYY3bdTs7wHuyYNDQi7diBg5D8S6FClciXCReg=; b=OBPFciNwph2XrvLu9sOrL6cZ74QBzJQQHSic4LDxqzTkMwiAYczbQFNc99eB/QDF+a oQASHbuhs/2TZfboU/VuBpvo8llnaRaIzoIlsTCfWpcOTzpsFBEOEjOUTJar1rZAEzem J8PKX7SnJJ1aacVq1qMJFG67ykYMTtEJkp8Nhioi6yNfuLJNtUik7tsg02jDYiraJREP WqYBrynDb4clRX6bEMUCY/2mSMIAC0m5gpkim/bOtbvekcfHraw3xJPV7x68Pr844nAQ I2dMmPWDX/Rc0h9m1vo3h1nqdV8qhUSXgbekPbgiJKp5ce9/PCFe+78yns7IRkkn0Q80 g8KQ== X-Gm-Message-State: APjAAAVGEgMla/wLOoDqRvX2MWJed3aRZwaRYCVX+ImkbEZ/xGMZJCcd Qr3nW5l0N/OExqr/9oIXIFXURy32cfg= X-Google-Smtp-Source: APXvYqzfLGq80FFyhtlGZ6HFLqcLjqMTGdojYSsZDSK1hraRjyWTxgrxbS7gA3PashsOSq/18TVeUg== X-Received: by 2002:a17:90a:28a1:: with SMTP id f30mr539899pjd.77.1576646346915; Tue, 17 Dec 2019 21:19:06 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:06 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue , Qu Wenruo Subject: [PATCH V2 06/10] btrfs-progs: abstract function btrfs_add_block_group_cache() Date: Wed, 18 Dec 2019 13:18:45 +0800 Message-Id: <20191218051849.2587-7-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 3f7b82dc88a2..9e681273d4b8 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; @@ -2764,7 +2785,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; @@ -2814,11 +2834,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; } @@ -2870,9 +2886,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); @@ -2889,13 +2902,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); @@ -2945,9 +2953,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; @@ -2991,12 +2997,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 Wed Dec 18 05:18:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299555 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 1A23314B7 for ; Wed, 18 Dec 2019 05:19:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id EBF8320733 for ; Wed, 18 Dec 2019 05:19:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EJB2JqCE" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726616AbfLRFTK (ORCPT ); Wed, 18 Dec 2019 00:19:10 -0500 Received: from mail-pj1-f67.google.com ([209.85.216.67]:36233 "EHLO mail-pj1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTJ (ORCPT ); Wed, 18 Dec 2019 00:19:09 -0500 Received: by mail-pj1-f67.google.com with SMTP id n59so321346pjb.1 for ; Tue, 17 Dec 2019 21:19:09 -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=32gkv9Lz6mKKiD954RvBEHUyjFTRJxM7+xGT9a2U4a4=; b=EJB2JqCEAo+tOLHh9f1n6l1nla6rgtxQkK1W/b5dfHs36I4m04XGhzN6gFMERx6IbI 9L4e74eZxH8+rHe3kW/Wosk9szDB7U3YQfc7+rDXHQ2Xpbg/Fzn5lpEaU4JtP4NuGGp4 UG2OjaXA9YpJPJtZ22EXVTFiRMEw+Xly79uUGH4UmSMyEWKsn0h99bsOZR0pLhjVSwIW OCFmPPECua+bqx7Tb80YywLMf7KLa3m4leR0jnnQAcgGe6H0MH8hAmUSiHKLWEG4pR9c yjHnuM4qvZDjboScpqLLpQE6oN8R7ccYOLYvLdUaA1eBsmYv5BVAESwloLx2pTdtrmac kJpw== 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=32gkv9Lz6mKKiD954RvBEHUyjFTRJxM7+xGT9a2U4a4=; b=RnzRX8t1RdmTH/6PexQABHNlHH1T/S/Y/9P3kXQwO1Cm00E5XF7coHLmh0F2mcGNYt xsjvqbIsaBCfBoRReYTsRuRTZTrf+E5VX6W4udexOoJaOMGPhYMq9l/RB7mG502r1C/b 58Cyv/4Y1nXlTB0ReeXvsBurEdNqmGjXQ5ITeUvhQWBxzawZbfchHBZvAC/7vRPfwYta pR2ug8bm53PFFCZpNmUfckBzJYV3Ey6i5laVFQuZAauC1c9vmbTlOp2BpqpVz14Uvfjc VpN2dUadLVS0LK2p0yZCChKpa2yxRnfSg454hfk+ST+0IRbyqQnZdVUM/WsRDBiPF+oO cdqw== X-Gm-Message-State: APjAAAUvftisfIvO7LQ9a1s1zJGG6c5HcA/QOW1m7HrMrEMTYM/WnLvf Twr+ZSoDY/EH2d3WFMs2gcjDCb7t3mg= X-Google-Smtp-Source: APXvYqwpVHo8zOWtXC+HLowY1Ez+9T2aU3JQy4SGw1pVwQwxtjRRnJpf+2OlwubY4Pvrxq16Vq/NOA== X-Received: by 2002:a17:902:aa90:: with SMTP id d16mr521840plr.279.1576646348653; Tue, 17 Dec 2019 21:19:08 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:08 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue , Qu Wenruo Subject: [PATCH V2 07/10] block-progs: block_group: add dirty_bgs list related memebers Date: Wed, 18 Dec 2019 13:18:46 +0800 Message-Id: <20191218051849.2587-8-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 9e681273d4b8..615d823ec4de 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -2814,6 +2814,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) { @@ -2895,6 +2897,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, @@ -2992,6 +2995,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 Wed Dec 18 05:18:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299557 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 EDDB1139A for ; Wed, 18 Dec 2019 05:19:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C0D5C20733 for ; Wed, 18 Dec 2019 05:19:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nBfjRkHw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726620AbfLRFTM (ORCPT ); Wed, 18 Dec 2019 00:19:12 -0500 Received: from mail-pl1-f178.google.com ([209.85.214.178]:44918 "EHLO mail-pl1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTL (ORCPT ); Wed, 18 Dec 2019 00:19:11 -0500 Received: by mail-pl1-f178.google.com with SMTP id az3so424039plb.11 for ; Tue, 17 Dec 2019 21:19:11 -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=ziERBtOWPyPQMCfA+NWJlsksZcQBo9OK7vmILGPs8Bc=; b=nBfjRkHwQDxMjvZGI/L2p02c46lRRt2XEPKtvl7xNEQZpxKr3FWAJgwAJ0RSebr4PW 3k/GrblBEkLD87zlrhh8NS7WmE0V1grVo6DGB9bYX01tJex3fzuaCqcDCo3krvIFP7WB HZP7Wx6CpJCFjuRIVAgW9cXKOYZjPOzUIqR3D9Xecp5Sblx9SftZW08vlx1JFVRcc8im yZMeIHnGp/120BIjl1iW7k8p6I29DRnlXKlh9Hen0rrrbmHnCaClzwmmW61GsAHtmw/Y VxrnOBZm7CrFU1GPzLtJ3sVk38Zzt/gsr8iAZ7ResFnneDQKAEs2iE4FOzBR2VOkaWkh uBjQ== 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=ziERBtOWPyPQMCfA+NWJlsksZcQBo9OK7vmILGPs8Bc=; b=W7WfJNRb/lYxd536Xtv+py326TbcDmrYVMN3y3BHOdyDS5Y/xhaPJMK0YsurRI/AsE wlLHsFTUZeqWPHwhb3OSW89Jq2FCbRpPcYwPqi1LrX3ixnWrRMbRCFWaFPiL717lkiq+ ZLe3zZZNAbjytte5Sn1UfxTzPptJlwFRY2REyRMmwDM7FOYrkR9UyAds5Ioa3wBZXq13 BUTjd+mfhza2V8Q73Qmj8dP9Bm1QhUre6ltxB5vr2ftiBoI3VlW9LkJBZrMWo5OnqmTr 7hH7OA7amfZyaXKJ2c0n90pYelQC5Y+xRTHmWo9YpwAxxLU5LYCOFTxyp2NUcRVB9u+n A5Eg== X-Gm-Message-State: APjAAAVpqutpLc8bmlbaMcop1KEJ/0yTdQzA5HjknBCjg7/DyqjTdjs1 iJ7XJo2xFKd14l2hYrnWGJfkWuTyue8= X-Google-Smtp-Source: APXvYqx+t7Y/GMsKCPyfXWKrrrJOw5o5TdMQHSxpHTjtmqHSt5cC+AdusQtWSmgy2r2+5xFFaoUoMw== X-Received: by 2002:a17:902:820f:: with SMTP id x15mr638620pln.125.1576646350358; Tue, 17 Dec 2019 21:19:10 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:09 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue , Qu Wenruo Subject: [PATCH V2 08/10] btrfs-progs: pass @trans to functions touch dirty block groups Date: Wed, 18 Dec 2019 13:18:47 +0800 Message-Id: <20191218051849.2587-9-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 615d823ec4de..f50d1c8b0a77 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -1872,9 +1872,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; @@ -2237,8 +2238,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); @@ -2570,7 +2570,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) { @@ -3026,11 +3026,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); } @@ -3444,12 +3444,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; @@ -3604,7 +3604,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 Wed Dec 18 05:18:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299559 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 D49AE14B7 for ; Wed, 18 Dec 2019 05:19:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9EF6F20733 for ; Wed, 18 Dec 2019 05:19:14 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="da94BLCt" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726633AbfLRFTO (ORCPT ); Wed, 18 Dec 2019 00:19:14 -0500 Received: from mail-pj1-f65.google.com ([209.85.216.65]:40767 "EHLO mail-pj1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTN (ORCPT ); Wed, 18 Dec 2019 00:19:13 -0500 Received: by mail-pj1-f65.google.com with SMTP id n67so313374pjb.5 for ; Tue, 17 Dec 2019 21:19:13 -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=llLvqgvRX590nLHzd0G56l89vCH85CRMpmzEoS3GJ+A=; b=da94BLCtwGRzaPARWisAkkhOALqDVGnqzBy4JiUNjC2Eucw0cq6xlUSaEz2/TSdOS+ pQIZpR/eMochkxNGKsrRia/f1JfLLbdsnvcMl2qysSqmvSh1roDVxNvO7SlLN/nnBO25 sjwa+AFKHRgpSbXmms61SgtRuQmwxb6g42tLfPjeexzGnFKsk7iqt6EqOkX+MJy5Hwqy nGutT+ioVWRurS7p+cHvL28OTubrbtLTqsqCX5Xde83x0+fJLIzXqqiwniK6jBOM8JUO pgobV873eXP5kaAKi9YBk2p9xz3aRrWg0xkPuQpzOtQKp4AhTeVP9Tn+g80DGwXqfqL0 K4Cw== 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=llLvqgvRX590nLHzd0G56l89vCH85CRMpmzEoS3GJ+A=; b=AOurHubefc6owBv3NA4c/CqDWhBDHAkqE1LH8CTjbaZPviUwtg4KWYYliD0RTzt6ws U4owX33jUkInmFnphE4+ajJtN0vMyDakaeuH9vNiKa9m3gRKYuGFj4Jp0wVhoNIPBoyN P84vUA+C2NHfsfWXfLm+/5FDhxfvPoJmCdKRtxO01iCfXbYE2ENMajMYP/6BuuL4VCfe Oea22S0nwcGLgGyT8Au63oRxhhoVirPY1Wh4y830NG2L9OFbRgg2ippdtAi7Z5pnqarG tcgDZozx8DFaA1v8X273B4uHA3fFuCCQrIjBLSGX02DCqXVUImsVJberUPQDL0euB80Z 1Z3w== X-Gm-Message-State: APjAAAU69wGwLBm9bPoPPRzJb3V/Abq/4HhxH56IlqA6Z/6X1OPEZV9Q 4O0sYf2jTeocoTL8w2Xf7TyL3+8def0= X-Google-Smtp-Source: APXvYqxhbrtd37oMyvH8e8MMRx+Rl/CYrMfyHrUUeOjXg4WL4Oabhyda+vXA1nfZFEIgoSlRVSQmcg== X-Received: by 2002:a17:902:bf47:: with SMTP id u7mr533429pls.259.1576646352250; Tue, 17 Dec 2019 21:19:12 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.10 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:11 -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 V2 09/10] btrfs-progs: reform block groups caches structure Date: Wed, 18 Dec 2019 13:18:48 +0800 Message-Id: <20191218051849.2587-10-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 | 214 ++++++------------------------------ image/main.c | 5 +- transaction.c | 3 +- 4 files changed, 39 insertions(+), 187 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 f50d1c8b0a77..b7d5aa104a37 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -24,6 +24,7 @@ #include "kernel-lib/radix-tree.h" #include "ctree.h" #include "disk-io.h" +#include "kernel-lib/rbtree.h" #include "print-tree.h" #include "transaction.h" #include "crypto/crc32c.h" @@ -164,31 +165,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; @@ -262,7 +242,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, 1); @@ -271,78 +251,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, 0); } -/* - * 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; @@ -432,28 +346,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); @@ -483,16 +387,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; @@ -1676,38 +1574,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; @@ -1880,8 +1758,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); @@ -1898,11 +1774,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); @@ -2691,29 +2564,24 @@ struct extent_buffer *btrfs_alloc_free_block(struct btrfs_trans_handle *trans, int btrfs_free_block_groups(struct btrfs_fs_info *info) { struct btrfs_space_info *sinfo; - struct btrfs_block_group_cache *cache; + struct btrfs_block_group_cache *cache, *next; 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) - 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); + rbtree_postorder_for_each_entry_safe(cache, next, + &info->block_group_cache_tree, cache_node) { + 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, &start, &end, EXTENT_DIRTY); @@ -2791,7 +2659,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); @@ -2816,13 +2683,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; @@ -2836,7 +2696,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; } @@ -2886,7 +2746,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); @@ -2904,9 +2763,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); @@ -2953,7 +2810,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; @@ -2965,7 +2821,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); @@ -3001,8 +2856,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 */ @@ -3278,8 +3132,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; @@ -3412,13 +3267,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 Wed Dec 18 05:18:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Su Yue X-Patchwork-Id: 11299561 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 2C15214B7 for ; Wed, 18 Dec 2019 05:19:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0A82420733 for ; Wed, 18 Dec 2019 05:19:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C1/B3Mdc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726638AbfLRFTP (ORCPT ); Wed, 18 Dec 2019 00:19:15 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:39639 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbfLRFTP (ORCPT ); Wed, 18 Dec 2019 00:19:15 -0500 Received: by mail-pg1-f195.google.com with SMTP id b137so600287pga.6 for ; Tue, 17 Dec 2019 21:19:14 -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=yQp0+yCbYWFng8+Qfyn8OYobsCx76RYJGM6CXJnYTd8=; b=C1/B3Mdc/O3y10MpExrl+w7unCvs5/0eaxb5Mzan5GA23p164KHCjS4GeZmOPkV+bc sA9YoeQqyW19Y4vSYxQ5B/qMxgOwD7IOZrJSdmLdOAL3Id9uDh6JoXQqfeQymg3j/pem /GNo+QgsVXcmCaplhzZQxPvbFSBAET8b9nzEQeD0y/Nquj3aqp0A4+myu3A8iNdAkuRe RZ4z6+NepUrjpe9jXAo+PyC/qYToV465ap5JmGRhJlw5XMj6/x7pe3jN8ZQNn5D83sbh kcBlRUTvcvBEzxOeMuwBd/zXHyeAbXMSYH24sKl0FjIi5bBZXxp4hV4M0MvKNpTvJC1R P2DQ== 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=yQp0+yCbYWFng8+Qfyn8OYobsCx76RYJGM6CXJnYTd8=; b=j+17ncTMkrMbGVivDeJu8iooannlwejMQUCeucB2zjnH+dAWLJLokxmylWw0XVfmRl t/dWIZA6oQswwAjTf6L8ceVB1qs2Xm8drSmKf7X6m9Gg+wuAF4NhImMF+bbUxYLx1qWb c+yDa4e7rU/w+gVibVKX5itT85AdFiqAhuYaVezt5XE/couwJuBbNMDxe6pZ37eKFNWR z2UQsZIHEYH4dc0naALx78y5uiwI2UlLWfvRgJVI0szSXrid7BhXLwVnoevY50kB5MLx FURDDrmAX/Ch1wjO0qMhz7IZEoM18iDQ13UC0guD5MjS5Z+tX2DO+XsG/W4HjnHzWmgz tcCA== X-Gm-Message-State: APjAAAV9DRQX6wDPMabJdfyJgbrsnMUKurIrUQ1SVkNs/QaRkIs9dCch lLATCbl/vQSRFezk4WTaEosoM2yR2zQ= X-Google-Smtp-Source: APXvYqws8bTHUJv0a959DL7m3BDV9WlOX2t0WHSOIQE1riYSyWTtLwUtsuCLWrT+wNAM7v/Kp9NnvQ== X-Received: by 2002:a62:ed19:: with SMTP id u25mr975178pfh.173.1576646354232; Tue, 17 Dec 2019 21:19:14 -0800 (PST) Received: from p.lan (81.249.92.34.bc.googleusercontent.com. [34.92.249.81]) by smtp.gmail.com with ESMTPSA id e2sm1014781pfh.84.2019.12.17.21.19.12 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Dec 2019 21:19:13 -0800 (PST) From: damenly.su@gmail.com X-Google-Original-From: Damenly_Su@gmx.com To: linux-btrfs@vger.kernel.org Cc: Su Yue , Qu Wenruo Subject: [PATCH V2 10/10] btrfs-progs: cleanups after block group cache reform Date: Wed, 18 Dec 2019 13:18:49 +0800 Message-Id: <20191218051849.2587-11-Damenly_Su@gmx.com> X-Mailer: git-send-email 2.21.0 (Apple Git-122.2) In-Reply-To: <20191218051849.2587-1-Damenly_Su@gmx.com> References: <20191218051849.2587-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 b7d5aa104a37..11879d89d1a7 100644 --- a/extent-tree.c +++ b/extent-tree.c @@ -329,18 +329,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: