Skip to contentSkip to conversation

btrfs-progs: dump-tree: allow -b multiple times

PATCH In review Qu Wenruo 3 participants 5 messages Jun 1, 2018 – Mar 5, 2019

Subsystems (2)
lore
Share & tools
lore

Qu Wenruo

author
#0 lore raw

cover btrfs-progs: dump-tree: allow -b multiple times

Although just one patch, it needs the extent buffer cleanup code as basis, so please fetch it from my github repo:
https://github.com/adam900710/btrfs-progs/tree/dump_tree_multi_blocks

It's based on David's devel branch, with HEAD as:
commit ffc7e4f730bd5ec49ba14ae3a13576311d57d4a6 (david/devel)

Author: Axel Burri <[email protected]>
Date:   Tue May 15 17:22:14 2018 +0200

btrfs-progs: fix regression preventing send -p with subvolumes mounted on "/"

This patch allow -b to be specified multiple times, and add extra basic check for them.
For later enhancement (Issue: #113) it needs extra work to handle special roots.

Qu Wenruo (1):
btrfs-progs: inspect-dump-tree: Allow '-b|--block' to be specified
multiple times

 Documentation/btrfs-inspect-internal.asciidoc |   2 +-
 cmds-inspect-dump-tree.c                      | 109 +++++++++++++++---
 2 files changed, 91 insertions(+), 20 deletions(-)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/1 btrfs-progs: inspect-dump-tree: Allow '-b|--block' to be specified multiple times

Reuse extent-cache facility to record multiple bytenr so '-b|--block' can be specified multiple times.

Despite that, add a sector size alignment check before we try to print a tree block.
(Please note that, nodesize alignment check is not suitable here as meta chunk start bytenr could be unaligned to nodesize)

---
 Documentation/btrfs-inspect-internal.asciidoc |   2 +-
 cmds-inspect-dump-tree.c                      | 109 +++++++++++++++---
 2 files changed, 91 insertions(+), 20 deletions(-)
Documentation/btrfs-inspect-internal.asciidoc +1 -1
index e2db64660b9a..ba8529f57660 100644
@@ -86,7 +86,7 @@ the respective tree root block offset
 -u|--uuid::::
 print only the uuid tree information, empty output if the tree does not exist
 -b <block_num>::::
-print info of the specified block only
+print info of the specified block only, can be specified multiple times.
 --follow::::
 use with '-b', print all children tree blocks of '<block_num>'
 -t <tree_id>::::
cmds-inspect-dump-tree.c +90 -19

151 lines not on this page · raw message

Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#2 lore raw

Re: [PATCH REBASED 1/1] btrfs-progs: inspect-dump-tree: Allow '-b|--block' to be specified multiple times

Quoted 9 lines · Qu Wenruo

Reuse extent-cache facility to record multiple bytenr so '-b|--block' can be specified multiple times.

Despite that, add a sector size alignment check before we try to print a tree block.
(Please note that, nodesize alignment check is not suitable here as meta chunk start bytenr could be unaligned to nodesize)

Just one minor misspell but otherwise LGTM:

Quoted 23 lines
---
 Documentation/btrfs-inspect-internal.asciidoc |   2 +-
 cmds-inspect-dump-tree.c                      | 109 +++++++++++++++---
 2 files changed, 91 insertions(+), 20 deletions(-)
Documentation/btrfs-inspect-internal.asciidoc +1 -1
index e2db64660b9a..ba8529f57660 100644
@@ -86,7 +86,7 @@ the respective tree root block offset
 -u|--uuid::::
 print only the uuid tree information, empty output if the tree does not exist
 -b <block_num>::::
-print info of the specified block only
+print info of the specified block only, can be specified multiple times.
 --follow::::
 use with '-b', print all children tree blocks of '<block_num>'
 -t <tree_id>::::
cmds-inspect-dump-tree.c +0 -0
index 92a2a45b267e..abb9a2bcc7cb 100644

cmds-inspect-dump-tree.c const char * const cmd_inspect_dump_tree_usage[] = { · line 201

Quoted 4 lines
cmds-inspect-dump-tree.c +1 -0
@@ -198,11 +198,92 @@ const char * const cmd_inspect_dump_tree_usage[] = {
 	"-R|--backups           same as --roots plus print backup root info",
 	"-u|--uuid              print only the uuid tree",
 	"-b|--block <block_num> print info from the specified block only",
+	"                       can be specified multile times",

nit: s/multile/multiple

author
#3 lore raw

PATCH 1/1 btrfs-progs: inspect-dump-tree: Allow '-b|--block' to be specified multiple times

In reply to Qu Wenruo

Reuse extent-cache facility to record multiple bytenr so '-b|--block' can be specified multiple times.

Despite that, add a sector size alignment check before we try to print a tree block.
(Please note that, nodesize alignment check is not suitable here as meta chunk start bytenr could be unaligned to nodesize)

---
 Documentation/btrfs-inspect-internal.asciidoc |   2 +-
 cmds-inspect-dump-tree.c                      | 109 +++++++++++++++---
 2 files changed, 91 insertions(+), 20 deletions(-)
Documentation/btrfs-inspect-internal.asciidoc +1 -1
index e2db64660b9a..ba8529f57660 100644
@@ -86,7 +86,7 @@ the respective tree root block offset
 -u|--uuid::::
 print only the uuid tree information, empty output if the tree does not exist
 -b <block_num>::::
-print info of the specified block only
+print info of the specified block only, can be specified multiple times.
 --follow::::
 use with '-b', print all children tree blocks of '<block_num>'
 -t <tree_id>::::
cmds-inspect-dump-tree.c +90 -19

151 lines not on this page · raw message

Signature · 1 line
2.17.1
#4 lore raw

Re: [PATCH v1.1] btrfs-progs: inspect-dump-tree: Allow '-b|--block' to be specified multiple times

Quoted 9 lines · Qu Wenruo

Reuse extent-cache facility to record multiple bytenr so '-b|--block' can be specified multiple times.

Despite that, add a sector size alignment check before we try to print a tree block.
(Please note that, nodesize alignment check is not suitable here as meta chunk start bytenr could be unaligned to nodesize)

I'm going to add this patch to devel, but there's a crash when there's not valid block on the offset, eg. 'btrfs inspect dump-tree -b 8192 /dev/'

$ ./btrfs inspect dump-tree -b 1024 -b 2048 -b 4096 -b 8192 zimg
btrfs-progs v4.20.2 
ERROR: tree block bytenr 1024 is not aligned to sectorsize 4096
ERROR: tree block bytenr 2048 is not aligned to sectorsize 4096
Couldn't map the block 4096
Invalid mapping for 4096-20480, got 13631488-22020096
Couldn't map the block 4096
bad tree block 4096, bytenr mismatch, want=4096, have=0
ERROR: failed to read tree block 4096
extent_io.c:665: free_extent_buffer_internal: BUG_ON `eb->refs < 0`
triggered, value 1
./btrfs[0x426e57]
./btrfs(free_extent_buffer+0xe)[0x427701]
./btrfs(alloc_extent_buffer+0x3f)[0x427872]
./btrfs(btrfs_find_create_tree_block+0xf)[0x415b3c]
./btrfs(read_tree_block+0x5c)[0x4171b5]
./btrfs(cmd_inspect_dump_tree+0x587)[0x46fb75]
./btrfs(handle_command_group+0x44)[0x40df89]
./btrfs(cmd_inspect+0x15)[0x44b569]
./btrfs(main+0x8b)[0x40e032]
/lib64/libc.so.6(__libc_start_main+0xeb)[0x7f2001a54b7b]
./btrfs(_start+0x2a)[0x40dd1a]
Aborted (core dumped)

I think the fix will be simple so I'll fold it in, otherwise the multiple block offsets work and using the cache is ok.