All of lore.kernel.org
 help / color / mirror / Atom feed
From: Qu Wenruo <quwenruo.btrfs@gmx.com>
To: Josef Bacik <josef@toxicpanda.com>,
	linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: Re: [PATCH v2 10/12] btrfs-progs: check btrfs_super_used in lowmem check
Date: Thu, 19 Aug 2021 13:57:48 +0800	[thread overview]
Message-ID: <cd401399-791a-ae06-4934-98dc15b57610@gmx.com> (raw)
In-Reply-To: <ebeaf9c035019f2d5b210ad752caca5655c69edc.1629322156.git.josef@toxicpanda.com>



On 2021/8/19 上午5:33, Josef Bacik wrote:
> We can already fix this problem with the block accounting code, we just
> need to keep track of how much we should have used on the file system,
> and then check it against the bytes_super.  The repair just piggy backs
> on the block group used repair.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

One unrelated concern inlined below.

> ---
>   check/mode-lowmem.c | 13 ++++++++++++-
>   check/mode-lowmem.h |  1 +
>   2 files changed, 13 insertions(+), 1 deletion(-)
>
> diff --git a/check/mode-lowmem.c b/check/mode-lowmem.c
> index 14815519..dacc5445 100644
> --- a/check/mode-lowmem.c
> +++ b/check/mode-lowmem.c
> @@ -28,6 +28,7 @@
>   #include "check/mode-lowmem.h"
>
>   static u64 last_allocated_chunk;
> +static u64 total_used = 0;
>
>   static int calc_extent_flag(struct btrfs_root *root, struct extent_buffer *eb,
>   			    u64 *flags_ret)
> @@ -3654,6 +3655,8 @@ next:
>   out:
>   	btrfs_release_path(&path);
>
> +	total_used += used;
> +
>   	if (total != used) {
>   		error(
>   		"block group[%llu %llu] used %llu but extent items used %llu",
> @@ -5556,6 +5559,14 @@ next:
>   	}
>   out:
>
> +	if (total_used != btrfs_super_bytes_used(gfs_info->super_copy)) {
> +		fprintf(stderr,
> +			"super bytes used %llu mismatches actual used %llu\n",
> +			btrfs_super_bytes_used(gfs_info->super_copy),
> +			total_used);
> +		err |= SUPER_BYTES_USED_ERROR;
> +	}
> +
>   	if (repair) {
>   		ret = end_avoid_extents_overwrite();
>   		if (ret < 0)
> @@ -5568,7 +5579,7 @@ out:
>   		if (ret)
>   			err |= ret;
>   		else
> -			err &= ~BG_ACCOUNTING_ERROR;
> +			err &= ~(BG_ACCOUNTING_ERROR|SUPER_BYTES_USED_ERROR);
>   	}
>
>   	btrfs_release_path(&path);
> diff --git a/check/mode-lowmem.h b/check/mode-lowmem.h
> index da9f8600..0bcc338b 100644
> --- a/check/mode-lowmem.h
> +++ b/check/mode-lowmem.h
> @@ -48,6 +48,7 @@
>   #define DIR_ITEM_HASH_MISMATCH	(1<<24) /* Dir item hash mismatch */
>   #define INODE_MODE_ERROR	(1<<25) /* Bad inode mode */
>   #define INVALID_GENERATION	(1<<26)	/* Generation is too new */
> +#define SUPER_BYTES_USED_ERROR	(1<<27)	/* Super bytes_used is invalid */

We're reaching U32 limit now...

Thanks,
Qu
>
>   /*
>    * Error bit for low memory mode check.
>

  reply	other threads:[~2021-08-19  5:57 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-18 21:33 [PATCH v2 00/12] btrfs-progs: make check handle invalid bg items Josef Bacik
2021-08-18 21:33 ` [PATCH v2 01/12] btrfs-progs: fix running lowmem check tests Josef Bacik
2021-08-19  5:40   ` Qu Wenruo
2021-08-23 14:54   ` David Sterba
2021-08-18 21:33 ` [PATCH v2 02/12] btrfs-progs: do not infinite loop on corrupt keys with lowmem mode Josef Bacik
2021-08-19  5:42   ` Qu Wenruo
2021-08-23 15:04     ` David Sterba
2021-08-23 18:44       ` Josef Bacik
2021-08-23 23:34         ` Qu Wenruo
2021-08-18 21:33 ` [PATCH v2 03/12] btrfs-progs: propagate fs root errors in " Josef Bacik
2021-08-19  5:43   ` Qu Wenruo
2021-08-18 21:33 ` [PATCH v2 04/12] btrfs-progs: propagate extent item " Josef Bacik
2021-08-19  5:45   ` Qu Wenruo
2021-08-18 21:33 ` [PATCH v2 05/12] btrfs-progs: do not double add unaligned extent records Josef Bacik
2021-08-18 21:33 ` [PATCH v2 06/12] btrfs-progs: add the ability to corrupt block group items Josef Bacik
2021-08-18 21:33 ` [PATCH v2 07/12] btrfs-progs: add the ability to corrupt fields of the super block Josef Bacik
2021-08-23 14:59   ` David Sterba
2021-08-18 21:33 ` [PATCH v2 08/12] btrfs-progs: make check detect and fix invalid used for block groups Josef Bacik
2021-08-19  5:54   ` Qu Wenruo
2021-08-18 21:33 ` [PATCH v2 09/12] btrfs-progs: make check detect and fix problems with super_bytes_used Josef Bacik
2021-08-19  5:56   ` Qu Wenruo
2021-08-18 21:33 ` [PATCH v2 10/12] btrfs-progs: check btrfs_super_used in lowmem check Josef Bacik
2021-08-19  5:57   ` Qu Wenruo [this message]
2021-08-18 21:33 ` [PATCH v2 11/12] btrfs-progs: add a test image with a corrupt block group item Josef Bacik
2021-08-18 21:33 ` [PATCH v2 12/12] btrfs-progs: add a test image with an invalid super bytes_used Josef Bacik
2021-08-23 18:31 ` [PATCH v2 00/12] btrfs-progs: make check handle invalid bg items 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=cd401399-791a-ae06-4934-98dc15b57610@gmx.com \
    --to=quwenruo.btrfs@gmx.com \
    --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 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.