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 v3 6/8] btrfs-progs: check: check all of the csum roots
Date: Wed,  1 Dec 2021 13:15:08 -0500	[thread overview]
Message-ID: <db97009631aae850e0e243348ff5441606cc2555.1638382443.git.josef@toxicpanda.com> (raw)
In-Reply-To: <cover.1638382443.git.josef@toxicpanda.com>

Use the global roots tree to find all of the csum roots in the system
and check all of them as appropriate.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 check/main.c | 26 +++++++++++++++++++++++---
 1 file changed, 23 insertions(+), 3 deletions(-)

diff --git a/check/main.c b/check/main.c
index f873de09..337ab82f 100644
--- a/check/main.c
+++ b/check/main.c
@@ -5977,7 +5977,7 @@ out:
 	return ret;
 }
 
-static int check_csums(struct btrfs_root *root)
+static int check_csum_root(struct btrfs_root *root)
 {
 	struct btrfs_path path;
 	struct extent_buffer *leaf;
@@ -5995,7 +5995,6 @@ static int check_csums(struct btrfs_root *root)
 	max_entries = ((BTRFS_LEAF_DATA_SIZE(gfs_info) -
 			(sizeof(struct btrfs_item) * 2)) / csum_size) - 1;
 
-	root = btrfs_csum_root(gfs_info, 0);
 	if (!extent_buffer_uptodate(root->node)) {
 		fprintf(stderr, "No valid csum tree found\n");
 		return -ENOENT;
@@ -6100,6 +6099,27 @@ skip_csum_check:
 	return errors;
 }
 
+static int check_csums(void)
+{
+	struct rb_node *n;
+	struct btrfs_root *root;
+	int ret;
+
+	root = btrfs_csum_root(gfs_info, 0);
+	while (1) {
+		ret = check_csum_root(root);
+		if (ret)
+			break;
+		n = rb_next(&root->rb_node);
+		if (!n)
+			break;
+		root = rb_entry(n, struct btrfs_root, rb_node);
+		if (root->root_key.objectid != BTRFS_CSUM_TREE_OBJECTID)
+			break;
+	}
+	return ret;
+}
+
 static int is_dropped_key(struct btrfs_key *key,
 			  struct btrfs_key *drop_key)
 {
@@ -10912,7 +10932,7 @@ static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
 		task_start(ctx.info, &ctx.start_time, &ctx.item_count);
 	}
 
-	ret = check_csums(root);
+	ret = check_csums();
 	task_stop(ctx.info);
 	/*
 	 * Data csum error is not fatal, and it may indicate more serious
-- 
2.26.3


  parent reply	other threads:[~2021-12-01 18:15 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-01 18:15 [PATCH v3 0/8] btrfs-progs: extent tree v2 global root support prep work Josef Bacik
2021-12-01 18:15 ` [PATCH v3 1/8] btrfs-progs: stop accessing ->extent_root directly Josef Bacik
2021-12-01 18:15 ` [PATCH v3 2/8] btrfs-progs: stop accessing ->free_space_root directly Josef Bacik
2021-12-01 18:15 ` [PATCH v3 3/8] btrfs-progs: track csum, extent, and free space trees in a rb tree Josef Bacik
2021-12-01 18:15 ` [PATCH v3 4/8] btrfs-progs: check: make reinit work per found root item Josef Bacik
2021-12-01 18:15 ` [PATCH v3 5/8] btrfs-progs: check: check the global roots for uptodate root nodes Josef Bacik
2021-12-01 18:15 ` Josef Bacik [this message]
2021-12-01 18:15 ` [PATCH v3 7/8] btrfs-progs: check: fill csum root from all extent roots Josef Bacik
2021-12-01 18:15 ` [PATCH v3 8/8] btrfs-progs: common: search all extent roots for marking used space 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=db97009631aae850e0e243348ff5441606cc2555.1638382443.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.