From: Leo Martins <loemra.dev@gmail.com>
To: linux-btrfs@vger.kernel.org, kernel-team@fb.com
Subject: [PATCH v3 2/3] btrfs-progs: check free space maps to block group
Date: Mon, 7 Oct 2024 17:27:47 -0700 [thread overview]
Message-ID: <fe95778b1f5e29c035720ca7c02946fde25dcbb2.1728346056.git.loemra.dev@gmail.com> (raw)
In-Reply-To: <cover.1728346056.git.loemra.dev@gmail.com>
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;
}
--
2.43.5
next prev parent reply other threads:[~2024-10-08 0:28 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 ` Leo Martins [this message]
2025-07-21 9:15 ` [PATCH v3 2/3] btrfs-progs: check free space maps to block group Mark Harmstone
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=fe95778b1f5e29c035720ca7c02946fde25dcbb2.1728346056.git.loemra.dev@gmail.com \
--to=loemra.dev@gmail.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).