* [PATCH] btrfs: check remap-tree flags in btrfs_check_chunk_valid()
@ 2026-03-23 17:27 Mark Harmstone
2026-03-23 19:44 ` David Sterba
0 siblings, 1 reply; 2+ messages in thread
From: Mark Harmstone @ 2026-03-23 17:27 UTC (permalink / raw)
To: linux-btrfs; +Cc: Mark Harmstone
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-03-23 19:44 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-23 17:27 [PATCH] btrfs: check remap-tree flags in btrfs_check_chunk_valid() Mark Harmstone
2026-03-23 19:44 ` David Sterba
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox