From: Mark Harmstone <mark@harmstone.com>
To: Leo Martins <loemra.dev@gmail.com>, linux-btrfs@vger.kernel.org
Subject: Re: [PATCH v3 2/3] btrfs-progs: check free space maps to block group
Date: Mon, 21 Jul 2025 10:15:15 +0100 [thread overview]
Message-ID: <9a96e97b-84c5-4750-ad31-346fb816e960@harmstone.com> (raw)
In-Reply-To: <fe95778b1f5e29c035720ca7c02946fde25dcbb2.1728346056.git.loemra.dev@gmail.com>
Replying to this, as I've just run into this problem myself, and these patches
weren't accepted.
Patch 1 is fine.
For patch 2, there's an easier way of doing this: replace btrfs_lookup_first_block_group()
with btrfs_lookup_block_group(), which almost certainly was what was meant in
the first place.
But... doing this will cause pretty much all of the existing tests to fail,
so you'll have to fix them all in the same patch. I suspect this was the
reason that the patches didn't get accepted.
For patch 3, I wouldn't bother. I know there's some inevitable drift between
kernel-shared and the actual kernel, but adding a tree-checker to one and not
the other seems a bit too far. And if you were to add it to the kernel, that'd
add a runtime overhead for something harmless.
I suggest that when you resubmit these patches, you do it via a GitHub PR.
That way you won't have megabytes and megabytes of fixed tests sent to the
mailing list, the CI will run the tests for you automatically, and it's
less likely that it'll get forgotten about.
Mark
On 08/10/2024 1.27 am, Leo Martins wrote:
> Check that the block-group that is found matches the objectid and offset
> of the free-space-info. Without this the check only verifies that there
> is some block-group that exists with objectid >= free-space-info's
> objectid.
>
> I have softened the language of the warning and included instructions on
> how to fix the problem. This can be done in a couple of ways:
> - btrfs check --repair
> - btrfs rescue clear-space-cache v2
>
> I chose to include btrfs rescue as it is more targeted.
>
> Signed-off-by: Leo Martins <loemra.dev@gmail.com>
> ---
> CHANGELOG:
> v3:
> - softened the warning and added instructions
> ---
> common/clear-cache.c | 11 +++++++++--
> 1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/common/clear-cache.c b/common/clear-cache.c
> index 6493866d..6b362f64 100644
> --- a/common/clear-cache.c
> +++ b/common/clear-cache.c
> @@ -165,9 +165,16 @@ static int check_free_space_tree(struct btrfs_root *root)
> }
>
> bg = btrfs_lookup_first_block_group(fs_info, key.objectid);
> - if (!bg) {
> + if (!bg || key.objectid != bg->start ||
> + key.offset != bg->length) {
> fprintf(stderr,
> - "We have a space info key for a block group that doesn't exist\n");
> + "We have a space info key [%llu %u %llu] for a block group that "
> + "doesn't exist.\n",
> + key.objectid, key.type, key.offset);
> + fprintf(stderr,
> + "This is likely due to a minor bug in mkfs.btrfs that doesn't properly\n"
> + "cleanup free spaces and can be fixed using btrfs rescue "
> + "clear-space-cache v2\n");
> ret = -EINVAL;
> goto out;
> }
next prev parent reply other threads:[~2025-07-21 9:15 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 0:27 [PATCH v3 0/3] btrfs-progs: mkfs free-space-info bug Leo Martins
2024-10-08 0:27 ` [PATCH v3 1/3] btrfs-progs: remove block group free space Leo Martins
2024-10-08 0:27 ` [PATCH v3 2/3] btrfs-progs: check free space maps to block group Leo Martins
2025-07-21 9:15 ` Mark Harmstone [this message]
2024-10-08 0:27 ` [PATCH v3 3/3] btrfs-progs: free-space-info tree-checker Leo Martins
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=9a96e97b-84c5-4750-ad31-346fb816e960@harmstone.com \
--to=mark@harmstone.com \
--cc=linux-btrfs@vger.kernel.org \
--cc=loemra.dev@gmail.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;
as well as URLs for NNTP newsgroup(s).