From: Mark Harmstone <mark@harmstone.com>
To: linux-btrfs@vger.kernel.org
Cc: Mark Harmstone <mark@harmstone.com>
Subject: [PATCH] btrfs: check remap-tree flags in btrfs_check_chunk_valid()
Date: Mon, 23 Mar 2026 17:27:23 +0000 [thread overview]
Message-ID: <20260323172729.152556-1-mark@harmstone.com> (raw)
Add a check to btrfs_check_chunk_valid() that the METADATA_REMAP and
REMAPPED flags are only set if the REMAP_TREE incompat flag is also set.
Signed-off-by: Mark Harmstone <mark@harmstone.com>
---
fs/btrfs/tree-checker.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c
index 495d1dd61e66c2..f0152ccf95f680 100644
--- a/fs/btrfs/tree-checker.c
+++ b/fs/btrfs/tree-checker.c
@@ -999,6 +999,20 @@ int btrfs_check_chunk_valid(const struct btrfs_fs_info *fs_info,
}
}
+ if (unlikely((type & BTRFS_BLOCK_GROUP_METADATA_REMAP) &&
+ !(features & BTRFS_FEATURE_INCOMPAT_REMAP_TREE))) {
+ chunk_err(fs_info, leaf, chunk, logical,
+ "METADATA_REMAP chunk type without REMAP_TREE incompat bit");
+ return -EUCLEAN;
+ }
+
+ if (unlikely(remapped &&
+ !(features & BTRFS_FEATURE_INCOMPAT_REMAP_TREE))) {
+ chunk_err(fs_info, leaf, chunk, logical,
+ "REMAPPED chunk flag without REMAP_TREE incompat bit");
+ return -EUCLEAN;
+ }
+
if (!remapped &&
!valid_stripe_count(type & BTRFS_BLOCK_GROUP_PROFILE_MASK,
num_stripes, sub_stripes)) {
--
2.52.0
next reply other threads:[~2026-03-23 17:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-23 17:27 Mark Harmstone [this message]
2026-03-23 19:44 ` [PATCH] btrfs: check remap-tree flags in btrfs_check_chunk_valid() 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=20260323172729.152556-1-mark@harmstone.com \
--to=mark@harmstone.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