* Re: [PATCH] btrfs: print-tree: print header owner as signed
2026-06-21 9:11 ` [PATCH] btrfs: print-tree: print header owner as signed Qu Wenruo
@ 2026-06-22 11:17 ` Filipe Manana
2026-06-22 12:00 ` sun k
2026-06-22 22:55 ` Qu Wenruo
2 siblings, 0 replies; 9+ messages in thread
From: Filipe Manana @ 2026-06-22 11:17 UTC (permalink / raw)
To: Qu Wenruo; +Cc: linux-btrfs
On Sun, Jun 21, 2026 at 10:12 AM Qu Wenruo <wqu@suse.com> wrote:
>
> When dumpping a tree block, btrfs_header::owner is printed as
> unsigned, which can result in numbers that are hard to read, e.g:
>
> BTRFS info (device loop0): leaf 8908800 gen 16 total ptrs 28 free space 1676 owner 18446744073709551607
>
> For the above output, 18446744073709551607 is (s64)-9, the root id of data
> reloc tree.
>
> Despite those pre-defined root ids that are already negative, existing
> subvolume trees will not have any negative values, as subvolume trees can
> only utilize the lower 48 bits, so there will be no output change for
> existing subvolumes, thus no extra confusion.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Thanks.
> ---
> fs/btrfs/print-tree.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
> index 87e60a2d4bd8..53e726119ca7 100644
> --- a/fs/btrfs/print-tree.c
> +++ b/fs/btrfs/print-tree.c
> @@ -449,9 +449,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
> nr = btrfs_header_nritems(l);
>
> btrfs_info(fs_info,
> - "leaf %llu gen %llu total ptrs %d free space %d owner %llu",
> + "leaf %llu gen %llu total ptrs %d free space %d owner %lld",
> btrfs_header_bytenr(l), btrfs_header_generation(l), nr,
> - btrfs_leaf_free_space(l), btrfs_header_owner(l));
> + btrfs_leaf_free_space(l), (s64)btrfs_header_owner(l));
> print_eb_refs_lock(l);
> for (i = 0 ; i < nr ; i++) {
> char key_buf[KEY_TYPE_BUF_SIZE];
> @@ -600,10 +600,10 @@ void btrfs_print_tree(const struct extent_buffer *c, bool follow)
> return;
> }
> btrfs_info(fs_info,
> - "node %llu level %d gen %llu total ptrs %d free spc %u owner %llu",
> + "node %llu level %d gen %llu total ptrs %d free spc %u owner %lld",
> btrfs_header_bytenr(c), level, btrfs_header_generation(c),
> nr, (u32)BTRFS_NODEPTRS_PER_BLOCK(fs_info) - nr,
> - btrfs_header_owner(c));
> + (s64)btrfs_header_owner(c));
> print_eb_refs_lock(c);
> for (i = 0; i < nr; i++) {
> btrfs_node_key_to_cpu(c, &key, i);
> --
> 2.54.0
>
>
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] btrfs: print-tree: print header owner as signed
2026-06-21 9:11 ` [PATCH] btrfs: print-tree: print header owner as signed Qu Wenruo
2026-06-22 11:17 ` Filipe Manana
@ 2026-06-22 12:00 ` sun k
2026-06-23 0:07 ` David Sterba
2026-06-22 22:55 ` Qu Wenruo
2 siblings, 1 reply; 9+ messages in thread
From: sun k @ 2026-06-22 12:00 UTC (permalink / raw)
To: Qu Wenruo, linux-btrfs
Looks good.
Reviewed-by: Sun YangKai <sunk67188@gmail.com>
BTW, this reminds me the print-tree result of dir items that points to a
subvol, which currently looks like this:
item 4 key (256 DIR_ITEM 224155391) itemoff 15967 itemsize 48
location key (43123 ROOT_ITEM 18446744073709551615) type DIR
transid 896627 data_len 0 name_len 18
name: home.20260621T2000
And I wonder if we can also print the location key's offset field as s64
to make it easier to read.
Thanks,
Sun YangKai
On 2026/6/21 17:11, Qu Wenruo wrote:
> When dumpping a tree block, btrfs_header::owner is printed as
> unsigned, which can result in numbers that are hard to read, e.g:
>
> BTRFS info (device loop0): leaf 8908800 gen 16 total ptrs 28 free space 1676 owner 18446744073709551607
>
> For the above output, 18446744073709551607 is (s64)-9, the root id of data
> reloc tree.
>
> Despite those pre-defined root ids that are already negative, existing
> subvolume trees will not have any negative values, as subvolume trees can
> only utilize the lower 48 bits, so there will be no output change for
> existing subvolumes, thus no extra confusion.
>
> Signed-off-by: Qu Wenruo <wqu@suse.com>
> ---
> fs/btrfs/print-tree.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
> index 87e60a2d4bd8..53e726119ca7 100644
> --- a/fs/btrfs/print-tree.c
> +++ b/fs/btrfs/print-tree.c
> @@ -449,9 +449,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
> nr = btrfs_header_nritems(l);
>
> btrfs_info(fs_info,
> - "leaf %llu gen %llu total ptrs %d free space %d owner %llu",
> + "leaf %llu gen %llu total ptrs %d free space %d owner %lld",
> btrfs_header_bytenr(l), btrfs_header_generation(l), nr,
> - btrfs_leaf_free_space(l), btrfs_header_owner(l));
> + btrfs_leaf_free_space(l), (s64)btrfs_header_owner(l));
> print_eb_refs_lock(l);
> for (i = 0 ; i < nr ; i++) {
> char key_buf[KEY_TYPE_BUF_SIZE];
> @@ -600,10 +600,10 @@ void btrfs_print_tree(const struct extent_buffer *c, bool follow)
> return;
> }
> btrfs_info(fs_info,
> - "node %llu level %d gen %llu total ptrs %d free spc %u owner %llu",
> + "node %llu level %d gen %llu total ptrs %d free spc %u owner %lld",
> btrfs_header_bytenr(c), level, btrfs_header_generation(c),
> nr, (u32)BTRFS_NODEPTRS_PER_BLOCK(fs_info) - nr,
> - btrfs_header_owner(c));
> + (s64)btrfs_header_owner(c));
> print_eb_refs_lock(c);
> for (i = 0; i < nr; i++) {
> btrfs_node_key_to_cpu(c, &key, i);
^ permalink raw reply [flat|nested] 9+ messages in thread* Re: [PATCH] btrfs: print-tree: print header owner as signed
2026-06-22 12:00 ` sun k
@ 2026-06-23 0:07 ` David Sterba
2026-06-23 3:21 ` sun k
0 siblings, 1 reply; 9+ messages in thread
From: David Sterba @ 2026-06-23 0:07 UTC (permalink / raw)
To: sun k; +Cc: Qu Wenruo, linux-btrfs
On Mon, Jun 22, 2026 at 08:00:06PM +0800, sun k wrote:
> Looks good.
>
> Reviewed-by: Sun YangKai <sunk67188@gmail.com>
>
> BTW, this reminds me the print-tree result of dir items that points to a
> subvol, which currently looks like this:
>
> item 4 key (256 DIR_ITEM 224155391) itemoff 15967 itemsize 48
> location key (43123 ROOT_ITEM 18446744073709551615) type DIR
> transid 896627 data_len 0 name_len 18
> name: home.20260621T2000
>
> And I wonder if we can also print the location key's offset field as s64
> to make it easier to read.
It should be consistent for the ROOT_ITEM and references and we can
actually print the name of the tree, as is done in dump-tree output.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] btrfs: print-tree: print header owner as signed
2026-06-23 0:07 ` David Sterba
@ 2026-06-23 3:21 ` sun k
0 siblings, 0 replies; 9+ messages in thread
From: sun k @ 2026-06-23 3:21 UTC (permalink / raw)
To: dsterba; +Cc: Qu Wenruo, linux-btrfs
On Tue, Jun 23, 2026 at 8:08 AM David Sterba <dsterba@suse.cz> wrote:
>
> On Mon, Jun 22, 2026 at 08:00:06PM +0800, sun k wrote:
> > Looks good.
> >
> > Reviewed-by: Sun YangKai <sunk67188@gmail.com>
> >
> > BTW, this reminds me the print-tree result of dir items that points to a
> > subvol, which currently looks like this:
> >
> > item 4 key (256 DIR_ITEM 224155391) itemoff 15967 itemsize 48
> > location key (43123 ROOT_ITEM 18446744073709551615) type DIR
> > transid 896627 data_len 0 name_len 18
> > name: home.20260621T2000
> >
> > And I wonder if we can also print the location key's offset field as s64
> > to make it easier to read.
>
> It should be consistent for the ROOT_ITEM and references and we can
> actually print the name of the tree, as is done in dump-tree output.
Hi David,
I'm not sure if I follow you here. The offset field of a dir item
which points to a subvol is
a little special. Its offset field will always be `0` for subvolume or
`-1` for snapshot instead
of other values. While in root tree, the offset field will always be
`0` for subvol and `generation`
for snapshot. So take this as an example, when location key is (43123
ROOT_ITEM -1) in dir item,
there's no such an item in root tree, but something like (43123
ROOT_ITEM 8750971) instead.
8750971 is the generation when the snapshot is created. So I'm not
sure what is `the name of the tree`.
BTW, it might be a little off-topic: IMO this design is used to search
the last snapshot when the
object ids of multiple snapshots of the same subvol, which are created
in different generations,
is shared. But we never allow this and always allocate a new object id
for snapshots in reality.
I wonder if we can use this to make snapshots really snapshots instead
of a read-only subvol.
Thanks,
Sun YangKai
^ permalink raw reply [flat|nested] 9+ messages in thread
* [PATCH] btrfs: print-tree: print header owner as signed
2026-06-21 9:11 ` [PATCH] btrfs: print-tree: print header owner as signed Qu Wenruo
2026-06-22 11:17 ` Filipe Manana
2026-06-22 12:00 ` sun k
@ 2026-06-22 22:55 ` Qu Wenruo
2 siblings, 0 replies; 9+ messages in thread
From: Qu Wenruo @ 2026-06-22 22:55 UTC (permalink / raw)
To: linux-btrfs
When dumpping a tree block, btrfs_header::owner is printed as
unsigned, which can result in numbers that are hard to read, e.g:
BTRFS info (device loop0): leaf 8908800 gen 16 total ptrs 28 free space 1676 owner 18446744073709551607
For the above output, 18446744073709551607 is (s64)-9, the root id of data
reloc tree.
Despite those pre-defined root ids that are already negative, existing
subvolume trees will not have any negative values, as subvolume trees can
only utilize the lower 48 bits, so there will be no output change for
existing subvolumes, thus no extra confusion.
Signed-off-by: Qu Wenruo <wqu@suse.com>
---
fs/btrfs/print-tree.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/fs/btrfs/print-tree.c b/fs/btrfs/print-tree.c
index 87e60a2d4bd8..53e726119ca7 100644
--- a/fs/btrfs/print-tree.c
+++ b/fs/btrfs/print-tree.c
@@ -449,9 +449,9 @@ void btrfs_print_leaf(const struct extent_buffer *l)
nr = btrfs_header_nritems(l);
btrfs_info(fs_info,
- "leaf %llu gen %llu total ptrs %d free space %d owner %llu",
+ "leaf %llu gen %llu total ptrs %d free space %d owner %lld",
btrfs_header_bytenr(l), btrfs_header_generation(l), nr,
- btrfs_leaf_free_space(l), btrfs_header_owner(l));
+ btrfs_leaf_free_space(l), (s64)btrfs_header_owner(l));
print_eb_refs_lock(l);
for (i = 0 ; i < nr ; i++) {
char key_buf[KEY_TYPE_BUF_SIZE];
@@ -600,10 +600,10 @@ void btrfs_print_tree(const struct extent_buffer *c, bool follow)
return;
}
btrfs_info(fs_info,
- "node %llu level %d gen %llu total ptrs %d free spc %u owner %llu",
+ "node %llu level %d gen %llu total ptrs %d free spc %u owner %lld",
btrfs_header_bytenr(c), level, btrfs_header_generation(c),
nr, (u32)BTRFS_NODEPTRS_PER_BLOCK(fs_info) - nr,
- btrfs_header_owner(c));
+ (s64)btrfs_header_owner(c));
print_eb_refs_lock(c);
for (i = 0; i < nr; i++) {
btrfs_node_key_to_cpu(c, &key, i);
--
2.54.0
^ permalink raw reply related [flat|nested] 9+ messages in thread