diff mbox

[2/2] btrfs-progs: print-tree: Print offset as tree objectid

Message ID 20171031060758.531-2-wqu@suse.com (mailing list archive)
State New, archived
Headers show

Commit Message

Qu Wenruo Oct. 31, 2017, 6:07 a.m. UTC
For case like tree reloc trees and subvolume trees, their key offset is
the tree id.

For case like tree treloc tree for data reloc tree,
The key will be outputted as:
(TREE_RELOC ROOT_ITEM 18446744073709551607)

The minus number is long and even guys with real engineer brains can't
easily get the meaning.

This patch will change the output format to:
(TREE_RELOC ROOT_ITEM DATA_RELOC_TREE)

While for special offset value like 0 or (u64)-1, it's still shown as
is.

Signed-off-by: Qu Wenruo <wqu@suse.com>
---
 print-tree.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

Comments

David Sterba Nov. 9, 2017, 5:07 p.m. UTC | #1
On Tue, Oct 31, 2017 at 02:07:58PM +0800, Qu Wenruo wrote:
> For case like tree reloc trees and subvolume trees, their key offset is
> the tree id.
> 
> For case like tree treloc tree for data reloc tree,
> The key will be outputted as:
> (TREE_RELOC ROOT_ITEM 18446744073709551607)
> 
> The minus number is long and even guys with real engineer brains can't
> easily get the meaning.
> 
> This patch will change the output format to:
> (TREE_RELOC ROOT_ITEM DATA_RELOC_TREE)
> 
> While for special offset value like 0 or (u64)-1, it's still shown as
> is.
> 
> Signed-off-by: Qu Wenruo <wqu@suse.com>

Applied, thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-btrfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/print-tree.c b/print-tree.c
index 687f871db302..326fafcea763 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -794,6 +794,18 @@  void btrfs_print_key(struct btrfs_disk_key *disk_key)
 	case BTRFS_UUID_KEY_RECEIVED_SUBVOL:
 		printf(" 0x%016llx)", (unsigned long long)offset);
 		break;
+
+	/*
+	 * For those key offset, they are points to tree id, print them
+	 * in human readable format other than tree id.
+	 * Especially useful for trees like data/tree reloc tree, whose
+	 * tree id can be minus.
+	 */
+	case BTRFS_ROOT_ITEM_KEY:
+		printf(" ");
+		print_objectid(stdout, offset, type);
+		printf(")");
+		break;
 	default:
 		if (offset == (u64)-1)
 			printf(" -1)");