All of lore.kernel.org
 help / color / mirror / Atom feed
From: Josef Bacik <josef@toxicpanda.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH 10/22] btrfs-progs: check: add block group tree support
Date: Fri,  5 Nov 2021 16:40:36 -0400	[thread overview]
Message-ID: <13b95fc146d37942685812ed8b8a911d2e01a379.1636144275.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1636144275.git.josef@toxicpanda.com>

This makes the appropriate changes to enable the block group tree
checking for both lowmem and normal check modes.  This is relatively
straightforward, simply need to use the helper to get the right root for
dealing with block groups.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/main.c        | 21 ++++++++++++++++++++-
 check/mode-lowmem.c |  4 ++--
 2 files changed, 22 insertions(+), 3 deletions(-)

diff --git a/check/main.c b/check/main.c
index 7735cce1..46d08040 100644
--- a/check/main.c
+++ b/check/main.c
@@ -6229,10 +6229,17 @@ static int check_type_with_root(u64 rootid, u8 key_type)
 		break;
 	case BTRFS_EXTENT_ITEM_KEY:
 	case BTRFS_METADATA_ITEM_KEY:
-	case BTRFS_BLOCK_GROUP_ITEM_KEY:
 		if (rootid != BTRFS_EXTENT_TREE_OBJECTID)
 			goto err;
 		break;
+	case BTRFS_BLOCK_GROUP_ITEM_KEY:
+		if (btrfs_fs_incompat(gfs_info, EXTENT_TREE_V2)) {
+			if (rootid != BTRFS_BLOCK_GROUP_TREE_OBJECTID)
+				goto err;
+		} else if (rootid != BTRFS_EXTENT_TREE_OBJECTID) {
+			goto err;
+		}
+		break;
 	case BTRFS_ROOT_ITEM_KEY:
 		if (rootid != BTRFS_ROOT_TREE_OBJECTID)
 			goto err;
@@ -9453,6 +9460,18 @@ again:
 		return ret;
 	}
 
+	/*
+	 * If we are extent tree v2 then we can reint the block group root as
+	 * well.
+	 */
+	if (btrfs_fs_incompat(gfs_info, EXTENT_TREE_V2)) {
+		ret = btrfs_fsck_reinit_root(trans, gfs_info->block_group_root);
+		if (ret) {
+			fprintf(stderr, "block group initialization failed\n");
+			return ret;
+		}
+	}
+
 	/*
 	 * Now we have all the in-memory block groups setup so we can make
 	 * allocations properly, and the metadata we care about is safe since we
diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
index 263b56d1..7be12e6b 100644
--- a/check/mode-lowmem.c
+++ b/check/mode-lowmem.c
@@ -5530,7 +5530,7 @@ int check_chunks_and_extents_lowmem(void)
 	key.offset = 0;
 	key.type = BTRFS_ROOT_ITEM_KEY;
 
-	ret = btrfs_search_slot(NULL, root, &key, &path, 0, 0);
+	ret = btrfs_search_slot(NULL, gfs_info->tree_root, &key, &path, 0, 0);
 	if (ret) {
 		error("cannot find extent tree in tree_root");
 		goto out;
@@ -5565,7 +5565,7 @@ int check_chunks_and_extents_lowmem(void)
 		if (ret)
 			goto out;
 next:
-		ret = btrfs_next_item(root, &path);
+		ret = btrfs_next_item(gfs_info->tree_root, &path);
 		if (ret)
 			goto out;
 	}
-- 
2.26.3


  parent reply	other threads:[~2021-11-05 20:41 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-05 20:40 [PATCH 00/22] btrfs-progs: extent tree v2 support, global roots Josef Bacik
2021-11-05 20:40 ` [PATCH 01/22] btrfs-progs: common: allow users to select extent-tree-v2 option Josef Bacik
2021-11-05 20:40 ` [PATCH 02/22] btrfs-progs: add definitions for the block group tree Josef Bacik
2021-11-05 20:40 ` [PATCH 03/22] btrfs-progs: add on disk pointers to global tree ids Josef Bacik
2021-11-05 20:40 ` [PATCH 04/22] btrfs-progs: add support for loading the block group root Josef Bacik
2021-11-30 18:14   ` David Sterba
2021-11-05 20:40 ` [PATCH 05/22] btrfs-progs: add print support for the block group tree Josef Bacik
2021-11-05 20:40 ` [PATCH 06/22] btrfs-progs: mkfs: use the btrfs_block_group_root helper Josef Bacik
2021-11-05 20:40 ` [PATCH 07/22] btrfs-progs: check-lowmem: " Josef Bacik
2021-11-05 20:40 ` [PATCH 08/22] btrfs-progs: handle no bg item in extent tree for free space tree Josef Bacik
2021-11-05 20:40 ` [PATCH 09/22] btrfs-progs: mkfs: add support for the block group tree Josef Bacik
2021-11-05 20:40 ` Josef Bacik [this message]
2021-11-05 20:40 ` [PATCH 11/22] btrfs-progs: qgroup-verify: scan extents based on block groups Josef Bacik
2021-11-05 20:40 ` [PATCH 12/22] btrfs-progs: check: make free space tree validation extent tree v2 aware Josef Bacik
2021-11-05 20:40 ` [PATCH 13/22] btrfs-progs: check: add helper to reinit the root based on a key Josef Bacik
2021-11-05 20:40 ` [PATCH 14/22] btrfs-progs: check: handle the block group tree properly Josef Bacik
2021-11-05 20:40 ` [PATCH 15/22] btrfs-progs: load the number of global roots into the fs_info Josef Bacik
2021-11-05 20:40 ` [PATCH 16/22] btrfs-progs: handle the per-block group global root id Josef Bacik
2021-11-05 20:40 ` [PATCH 17/22] btrfs-progs: add a btrfs_delete_and_free_root helper Josef Bacik
2021-11-05 20:40 ` [PATCH 18/22] btrfs-progs: make btrfs_clear_free_space_tree extent tree v2 aware Josef Bacik
2021-11-05 20:40 ` [PATCH 19/22] btrfs-progs: make btrfs_create_tree take a key for the root key Josef Bacik
2021-11-05 20:40 ` [PATCH 20/22] btrfs-progs: mkfs: set chunk_item_objectid properly for extent tree v2 Josef Bacik
2021-11-05 20:40 ` [PATCH 21/22] btrfs-progs: mkfs: create the global root's Josef Bacik
2021-11-05 20:40 ` [PATCH 22/22] btrfs-progs: check: don't do the root item check for extent tree v2 Josef Bacik

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=13b95fc146d37942685812ed8b8a911d2e01a379.1636144275.git.josef@toxicpanda.com \
    --to=josef@toxicpanda.com \
    --cc=kernel-team@fb.com \
    --cc=linux-btrfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.