Linux Btrfs filesystem development
 help / color / mirror / Atom feed
* [PATCH 0/2] btrfs-progs: fix the overly strict chunk type check on dump-tree
@ 2026-05-29  9:36 Qu Wenruo
  2026-05-29  9:36 ` [PATCH 1/2] btrfs-progs: dump-tree: fix the chunk type check for system chunks Qu Wenruo
  2026-05-29  9:36 ` [PATCH 2/2] btrfs-progs: misc-tests: add a regression test case for dump tree Qu Wenruo
  0 siblings, 2 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-05-29  9:36 UTC (permalink / raw)
  To: linux-btrfs

Commit 408e45feb325 ("btrfs-progs: dump-tree: add extra chunk type
checks") introduced a chunk type check before dumping the tree.

However it's too strict as I'm a total idiot, and forgot to we still
need to dump chunk tree blocks.

Fix it and add a regression test.

Qu Wenruo (2):
  btrfs-progs: dump-tree: fix the chunk type check for system chunks
  btrfs-progs: misc-tests: add a regression test case for dump tree

 cmds/inspect-dump-tree.c                      |  5 ++--
 .../072-dump-tree-chunk-bytenr/test.sh        | 25 +++++++++++++++++++
 2 files changed, 28 insertions(+), 2 deletions(-)
 create mode 100755 tests/misc-tests/072-dump-tree-chunk-bytenr/test.sh

--
2.54.0


^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH 1/2] btrfs-progs: dump-tree: fix the chunk type check for system chunks
  2026-05-29  9:36 [PATCH 0/2] btrfs-progs: fix the overly strict chunk type check on dump-tree Qu Wenruo
@ 2026-05-29  9:36 ` Qu Wenruo
  2026-05-29  9:36 ` [PATCH 2/2] btrfs-progs: misc-tests: add a regression test case for dump tree Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-05-29  9:36 UTC (permalink / raw)
  To: linux-btrfs

[BUG]
Commit 408e45feb325 ("btrfs-progs: dump-tree: add extra chunk type
checks") introduced one extra check on when using "btrfs ins dump-tree
-b <bytenr>" option, to prevent end users from passing logical address
belonging to data chunks.

However that check forget that we also have metadata in system chunks,
thus will cause the following false alerts:

 # mkfs.btrfs -f $dev
 # btrfs ins dump-tree -t chunk $dev | grep "owner CHUNK_TREE"
 leaf 22036480 items 4 free space 15781 generation 8 owner CHUNK_TREE
 ^^^ This means we can still print the chunk tree

 # btrfs ins dump-tree -b 22036480 $dev
 btrfs-progs v6.19.1
 ERROR: logical 22036480 is not in a metadata chunk, found chunk 22020096 len 8388608 flags 0x22

[CAUSE]
I'm an idiot and forgot to check system chunks.

[FIX]
Add system chunk type into the check.

Fixes: 408e45feb325 ("btrfs-progs: dump-tree: add extra chunk type checks")
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 cmds/inspect-dump-tree.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/cmds/inspect-dump-tree.c b/cmds/inspect-dump-tree.c
index 8f384d3561c9..0d58e398f636 100644
--- a/cmds/inspect-dump-tree.c
+++ b/cmds/inspect-dump-tree.c
@@ -206,8 +206,9 @@ static int check_metadata_logical(struct btrfs_fs_info *fs_info, u64 logical)
 		return -ENOENT;
 	}
 	map = container_of(ce, struct map_lookup, ce);
-	if (!(map->type & BTRFS_BLOCK_GROUP_METADATA)) {
-		error("logical %llu is not in a metadata chunk, found chunk %llu len %llu flags 0x%llx",
+	if (!(map->type & (BTRFS_BLOCK_GROUP_METADATA |
+			   BTRFS_BLOCK_GROUP_SYSTEM))) {
+		error("logical %llu is not in a metadata/system chunk, found chunk %llu len %llu flags 0x%llx",
 		      logical, ce->start, ce->size, map->type);
 		return -EINVAL;
 	}
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [PATCH 2/2] btrfs-progs: misc-tests: add a regression test case for dump tree
  2026-05-29  9:36 [PATCH 0/2] btrfs-progs: fix the overly strict chunk type check on dump-tree Qu Wenruo
  2026-05-29  9:36 ` [PATCH 1/2] btrfs-progs: dump-tree: fix the chunk type check for system chunks Qu Wenruo
@ 2026-05-29  9:36 ` Qu Wenruo
  1 sibling, 0 replies; 3+ messages in thread
From: Qu Wenruo @ 2026-05-29  9:36 UTC (permalink / raw)
  To: linux-btrfs

The new test case will:

- Create an empty btrfs
- Grab the chunk tree root bytenr
- Pass that bytenr into "btrfs ins dump-tree -b <bytenr>"
  That must success.

This is for the regression introduced by commit 408e45feb325
("btrfs-progs: dump-tree: add extra chunk type checks").

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 .../072-dump-tree-chunk-bytenr/test.sh        | 25 +++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100755 tests/misc-tests/072-dump-tree-chunk-bytenr/test.sh

diff --git a/tests/misc-tests/072-dump-tree-chunk-bytenr/test.sh b/tests/misc-tests/072-dump-tree-chunk-bytenr/test.sh
new file mode 100755
index 000000000000..ef4fc4659e4f
--- /dev/null
+++ b/tests/misc-tests/072-dump-tree-chunk-bytenr/test.sh
@@ -0,0 +1,25 @@
+#!/bin/bash
+# Test "btrfs ins dump-tree -b <bytenr>" when the bytenr belongs to a chunk
+# tree block.
+#
+# This is a regression test for commit 408e45feb325 ("btrfs-progs:
+# dump-tree: add extra chunk type checks"), which is too strict and
+# rejects chunk tree blocks.
+
+source "$TEST_TOP/common" || exit
+source "$TEST_TOP/common.convert" || exit
+
+check_prereq mkfs.btrfs
+check_prereq btrfs
+
+setup_root_helper
+prepare_test_dev
+
+run_check_mkfs_test_dev
+chunk_root=$(run_check_stdout "$TOP/btrfs" inspect-internal dump-tree -t chunk "$TEST_DEV" |\
+	     grep "owner CHUNK_TREE" | cut -f 2 -d\ )
+if [ -z "$chunk_root" ]; then
+	_fail "unable to get the chunk root bytenr"
+fi
+
+run_check "$TOP/btrfs" inspect-internal dump-tree -b "$chunk_root" "$TEST_DEV"
-- 
2.54.0


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-05-29  9:36 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-29  9:36 [PATCH 0/2] btrfs-progs: fix the overly strict chunk type check on dump-tree Qu Wenruo
2026-05-29  9:36 ` [PATCH 1/2] btrfs-progs: dump-tree: fix the chunk type check for system chunks Qu Wenruo
2026-05-29  9:36 ` [PATCH 2/2] btrfs-progs: misc-tests: add a regression test case for dump tree Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox