From: Johannes Thumshirn <Johannes.Thumshirn@wdc.com>
To: WenRuo Qu <wqu@suse.com>,
"linux-btrfs@vger.kernel.org" <linux-btrfs@vger.kernel.org>
Cc: "gality369@gmail.com" <gality369@gmail.com>
Subject: Re: [PATCH 1/2] btrfs: tree-checker: introduce checks for FREE_SPACE_INFO
Date: Tue, 10 Mar 2026 10:36:32 +0000 [thread overview]
Message-ID: <8a1b20e2-20fd-42dd-ae25-c2d1bf09555f@wdc.com> (raw)
In-Reply-To: <dcc4425060fb18e7dc5b45e4ea05cd8afec13f6c.1773094579.git.wqu@suse.com>
On 3/9/26 11:20 PM, Qu Wenruo wrote:
> Introduce checks for FREE_SPACE_INFO item, which include:
>
> - Key alignment check
> The objectid is the logical bytenr of the chunk/bg, and offset is the
> length of the chunk/bg, thus they should all be aligned to the fs
> block size.
>
> - Item size check
> The FREE_SPACE_INFO should a fix size.
have ~^
>
> - Flags check
> The flags member should has no other flags than
s/has/have/
[...]
> +static int check_free_space_info(struct extent_buffer *leaf, struct btrfs_key *key,
> + int slot)
> +{
> + struct btrfs_fs_info *fs_info = leaf->fs_info;
> + struct btrfs_free_space_info *fsi;
> + const u32 blocksize = fs_info->sectorsize;
> + u32 flags;
> +
> + if (unlikely(!IS_ALIGNED(key->objectid, blocksize) ||
> + !IS_ALIGNED(key->offset, blocksize))) {
> + generic_err(leaf, slot,
> + "free space info key range is not aligned to %u, has (%llu %u %llu)",
> + blocksize, key->objectid, key->type, key->offset);
> + return -EUCLEAN;
> + }
I'd split that into two if()s, one for the objectid one for the offset.
That'll help figuring out which of these two is unaligned without doing
the math again on a possible bug report.
Thanks,
Johannes
next prev parent reply other threads:[~2026-03-10 10:36 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-09 22:19 [PATCH 0/2] btrfs: add free space tree checks except for FREE_SPACE_BITMAP Qu Wenruo
2026-03-09 22:19 ` [PATCH 1/2] btrfs: tree-checker: introduce checks for FREE_SPACE_INFO Qu Wenruo
2026-03-10 10:36 ` Johannes Thumshirn [this message]
2026-03-13 19:47 ` David Sterba
2026-03-09 22:19 ` [PATCH 2/2] btrfs: tree-checker: introduce checks for FREE_SPACE_EXTENT Qu Wenruo
2026-03-10 10:41 ` Johannes Thumshirn
2026-03-10 10:42 ` [PATCH 0/2] btrfs: add free space tree checks except for FREE_SPACE_BITMAP Johannes Thumshirn
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=8a1b20e2-20fd-42dd-ae25-c2d1bf09555f@wdc.com \
--to=johannes.thumshirn@wdc.com \
--cc=gality369@gmail.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 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.