public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
From: David Sterba <dsterba@suse.cz>
To: Josef Bacik <josef@toxicpanda.com>
Cc: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH 1/7] btrfs-progs: check: fix check_global_roots_uptodate
Date: Tue, 8 Mar 2022 18:16:59 +0100	[thread overview]
Message-ID: <20220308171659.GP12643@twin.jikos.cz> (raw)
In-Reply-To: <d62401f4e8b5294e589cd8be1ecac0082ccac56b.1645567860.git.josef@toxicpanda.com>

On Tue, Feb 22, 2022 at 05:22:36PM -0500, Josef Bacik wrote:
> While running make test on other patches I noticed we are now
> segfaulting on the fuzz tests.  This is because when I converted us to a
> rb tree for the global roots we lost the ability to catch that there's
> no extent root at all.  Before we'd populate a dummy
> fs_info->extent_root with a not uptodate node, but now you simply don't
> get an extent root in the rb_tree.  Fix the check_global_roots_uptodate
> helper to count how many roots we find and make sure it matches the
> number we expect.  If it doesn't then we can return -EIO.
> 
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
>  check/main.c | 34 +++++++++++++++++++++++++++++++++-
>  1 file changed, 33 insertions(+), 1 deletion(-)
> 
> diff --git a/check/main.c b/check/main.c
> index 8ccba447..abe208df 100644
> --- a/check/main.c
> +++ b/check/main.c
> @@ -10207,6 +10207,8 @@ static int check_global_roots_uptodate(void)
>  {
>  	struct btrfs_root *root;
>  	struct rb_node *n;
> +	int found_csum = 0, found_extent = 0, found_fst = 0;
> +	int ret = 0;
>  
>  	for (n = rb_first(&gfs_info->global_roots_tree); n; n = rb_next(n)) {
>  		root = rb_entry(n, struct btrfs_root, rb_node);
> @@ -10215,9 +10217,39 @@ static int check_global_roots_uptodate(void)
>  			      root->root_key.objectid, root->root_key.offset);
>  			return -EIO;
>  		}
> +		switch(root->root_key.objectid) {
> +		case BTRFS_EXTENT_TREE_OBJECTID:
> +			found_extent++;
> +			break;
> +		case BTRFS_CSUM_TREE_OBJECTID:
> +			found_csum++;
> +			break;
> +		case BTRFS_FREE_SPACE_TREE_OBJECTID:
> +			found_fst++;
> +			break;
> +		default:
> +			break;
> +		}
>  	}
>  
> -	return 0;
> +	if (found_extent != gfs_info->nr_global_roots) {
> +		error("found %d extent roots, expected %llu\n", found_extent,

Reminder for the future, the strings for error() a warning() helpers do
not need the trailing \n.

  reply	other threads:[~2022-03-08 17:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-22 22:22 [PATCH 0/7] btrfs-progs: various regression fixes Josef Bacik
2022-02-22 22:22 ` [PATCH 1/7] btrfs-progs: check: fix check_global_roots_uptodate Josef Bacik
2022-03-08 17:16   ` David Sterba [this message]
2022-02-22 22:22 ` [PATCH 2/7] btrfs-progs: fuzz-tests: use --force for --init-csum-tree Josef Bacik
2022-02-22 22:22 ` [PATCH 3/7] btrfs-progs: repair: bail if we find an unaligned extent Josef Bacik
2022-02-22 22:22 ` [PATCH 4/7] btrfs-progs: properly populate missing trees Josef Bacik
2022-03-04 22:18   ` David Sterba
2022-03-08 17:26     ` David Sterba
2022-02-22 22:22 ` [PATCH 5/7] btrfs-progs: don't check skip_csum_check if there's no fs_info Josef Bacik
2022-02-22 22:22 ` [PATCH 6/7] btrfs-progs: do not try to load the free space tree if it's not enabled Josef Bacik
2022-02-22 22:22 ` [PATCH 7/7] btrfs-progs: inspect-tree-stats: initialize the key properly Josef Bacik
2022-03-08 17:39 ` [PATCH 0/7] btrfs-progs: various regression fixes David Sterba

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=20220308171659.GP12643@twin.jikos.cz \
    --to=dsterba@suse.cz \
    --cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox