From: Anand Jain <anand.jain@oracle.com>
To: Qu Wenruo <wqu@suse.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH] btrfs: tree-checker: add btrfs dev extent checks
Date: Thu, 15 Aug 2024 13:17:00 +0800 [thread overview]
Message-ID: <209d5658-01bd-4c06-ad2b-c7fc281a0c0f@oracle.com> (raw)
In-Reply-To: <eb543cde2378cc111b0b8359ef94ff0dbd51ee58.1723355397.git.wqu@suse.com>
On 11/8/24 1:50 pm, Qu Wenruo wrote:
> [REPORT]
> There is a corruption report that btrfs refuse to mount a fs that has
> overlapping dev extents:
>
> BTRFS error (device sdc): dev extent devid 4 physical offset
> 14263979671552 overlap with previous dev extent end 14263980982272
> BTRFS error (device sdc): failed to verify dev extents against chunks: -117
> BTRFS error (device sdc): open_ctree failed
>
> [CAUSE]
> The cause is very obvious, there is a bad dev extent item with incorrect
> length.
> Although we are not 100% sure of the cause before getting the dev tree
> dump, I'm already surprised that we do not have any checks on dev tree.
>
> Currently we only do the dev-extent verification at mount time, but if the
> corruption is caused by memory bitflip, we really want to catch it before
> writing the corruption to the storage.
>
> Furthermore the dev extent items has the following key definition:
>
> (<device id> DEV_EXTENT <physical offset>)
>
> Thus we can not just rely on the generic key order check to make sure
> there is no overlapping.
>
> [ENHANCEMENT]
> Introduce dedicated dev extent checks, including:
>
> - Fixed member checks
> * chunk_tree should always be BTRFS_CHUNK_TREE_OBJECTID (3)
> * chunk_objectid should always be
> BTRFS_FIRST_CHUNK_CHUNK_TREE_OBJECTID (256)
>
> - Alignment checks
> * chunk_offset should be aligned to sectorsize
> * length should be aligned to sectorsize
> * key.offset should be aligned to sectorsize
>
> - Overlap checks
> If the previous key is also a dev-extent item, with the same
> device id, make sure we do not overlap with the previous dev extent.
>
> Reported: Stefan N <stefannnau@gmail.com>
> Link: https://lore.kernel.org/linux-btrfs/CA+W5K0rSO3koYTo=nzxxTm1-Pdu1HYgVxEpgJ=aGc7d=E8mGEg@mail.gmail.com/
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Looks good.
Reviewed-by: Anand Jain <anand.jain@oracle.com>
Thx.
next prev parent reply other threads:[~2024-08-15 5:17 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-11 5:50 [PATCH] btrfs: tree-checker: add btrfs dev extent checks Qu Wenruo
2024-08-13 23:11 ` David Sterba
2024-08-13 23:17 ` Qu Wenruo
2024-08-13 23:32 ` David Sterba
2024-08-15 5:17 ` Anand Jain [this message]
2024-08-15 12:25 ` 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=209d5658-01bd-4c06-ad2b-c7fc281a0c0f@oracle.com \
--to=anand.jain@oracle.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=wqu@suse.com \
/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