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 v2 07/12] btrfs-progs: add the ability to corrupt fields of the super block
Date: Mon, 23 Aug 2021 16:59:27 +0200 [thread overview]
Message-ID: <20210823145927.GC5047@twin.jikos.cz> (raw)
In-Reply-To: <7c5a5c52f3cf9ba6b0188b5509e39de93f6bb662.1629322156.git.josef@toxicpanda.com>
On Wed, Aug 18, 2021 at 05:33:19PM -0400, Josef Bacik wrote:
> Doing the extent tree v2 work I generated an invalid super block with
> the wrong bytes_used set, and only noticed because it affected the block
> groups as well. Neither modes of fsck check for a valid bytes_used, so
> add the ability to corrupt this field so I can generate a testcase for
> fsck.
>
> Signed-off-by: Josef Bacik <josef@toxicpanda.com>
> ---
> btrfs-corrupt-block.c | 66 ++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 65 insertions(+), 1 deletion(-)
>
> diff --git a/btrfs-corrupt-block.c b/btrfs-corrupt-block.c
> index 80622f29..7e576897 100644
> --- a/btrfs-corrupt-block.c
> +++ b/btrfs-corrupt-block.c
> @@ -355,6 +355,24 @@ enum btrfs_block_group_field {
> BTRFS_BLOCK_GROUP_ITEM_BAD,
> };
>
> +enum btrfs_super_field {
> + BTRFS_SUPER_FIELD_FLAGS,
> + BTRFS_SUPER_FIELD_TOTAL_BYTES,
> + BTRFS_SUPER_FIELD_BYTES_USED,
> + BTRFS_SUPER_FIELD_BAD,
> +};
> +
> +static enum btrfs_super_field convert_super_field(char *field)
> +{
> + if (!strncmp(field, "flags", FIELD_BUF_LEN))
> + return BTRFS_SUPER_FIELD_FLAGS;
> + if (!strncmp(field, "total_bytes", FIELD_BUF_LEN))
> + return BTRFS_SUPER_FIELD_TOTAL_BYTES;
> + if (!strncmp(field, "bytes_used", FIELD_BUF_LEN))
> + return BTRFS_SUPER_FIELD_BYTES_USED;
> + return BTRFS_SUPER_FIELD_BAD;
There's a more feature-complete utility to modify super block fields
btrfs-sb-mod, this would be duplicated in corrupt-block.
next prev parent reply other threads:[~2021-08-23 15:02 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 [this message]
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
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=20210823145927.GC5047@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;
as well as URLs for NNTP newsgroup(s).