btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree
PATCH 1/2 btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree
So when searching for BTRFS_DEV_ITEMS_OBJECTID it hits. Albeit it is defined same as BTRFS_ROOT_TREE_OBJECTID.
--- print-tree.c | 1 + 1 file changed, 1 insertion(+)
print-tree.c +1 -0
@@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type) }switch (objectid) { +/* BTRFS_DEV_ITEMS_OBJECTID */ case BTRFS_ROOT_TREE_OBJECTID :if (type ==BTRFS_DEV_ITEM_KEY )fprintf (stream,"DEV_ITEMS" );
Signature · 1 line
2.21.0 (Apple Git-120)
PATCH 2/2 btrfs-progs: print-tree add missing DEV_STATS
Add missing BTRFS_DEV_STATS_OBJECTID into the print-tree.
before:
item 0 key (0 PERSISTENT_ITEM 1) itemoff 16243 itemsize 40
persistent item objectid 0 offset 1
after:
item 0 key (DEV_STATS PERSISTENT_ITEM 1) itemoff 16243 itemsize 40
persistent item objectid DEV_STATS offset 1
--- print-tree.c | 6 ++++++ 1 file changed, 6 insertions(+)
print-tree.c +6 -0
@@ -689,6 +689,12 @@ void print_key_type(FILE *stream, u64 objectid, u8 type)void print_objectid (FILE *stream,u64 objectid,u8 type) {switch (type) { +case BTRFS_PERSISTENT_ITEM_KEY : +if (objectid ==BTRFS_DEV_STATS_OBJECTID ) +fprintf (stream,"DEV_STATS" ); +else +fprintf (stream,"%llu" , (unsigned long long )objectid); +return ;case BTRFS_DEV_EXTENT_KEY :/* device id */ fprintf (stream,"%llu" , (unsigned long long )objectid);
Signature · 1 line
2.21.0 (Apple Git-120)
Quoted 13 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTIDit hits. Albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>--- print-tree.c | 1 + 1 file changed, 1 insertion(+)print-tree.c +0
-0
print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 707
Quoted 4 lines
print-tree.c +1
-0@@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type) }switch (objectid) { +/* BTRFS_DEV_ITEMS_OBJECTID */
That comment looks really cryptic to someone just looking at the code. Adding case BTRFS_DEV_ITEMS_OBJECTID: is better.
Quoted 4 lines
print-tree.c +0
-0case BTRFS_ROOT_TREE_OBJECTID :if (type ==BTRFS_DEV_ITEM_KEY )fprintf (stream,"DEV_ITEMS" );
Quoted 18 lines · Nikolay Borisov
Quoted 15 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTIDit hits. Albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>--- print-tree.c | 1 + 1 file changed, 1 insertion(+)print-tree.c +0
-0@@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type) }
Quoted 7 lines
print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 707
Quoted 2 lines
print-tree.c +1
-0switch (objectid) { +/* BTRFS_DEV_ITEMS_OBJECTID */ That comment looks really cryptic to someone just looking at the code. Adding case
BTRFS_DEV_ITEMS_OBJECTID: is better.Quoted 1 line
print-tree.c +0
-0case BTRFS_ROOT_TREE_OBJECTID :
Both constants have the same value so they can't be in one switch, but yeah the comment should be a bit more verbose, just the constant name is bringing more questions than answers.
Quoted 29 lines · David Sterba
Quoted 23 lines · Nikolay Borisov
Quoted 13 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTIDit hits. Albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>---
print-tree.c| 1 +1 file changed, 1 insertion(+)print-tree.c +0
-0print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 707
Quoted 4 lines
print-tree.c +1
-0@@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type) }switch (objectid) { +/* BTRFS_DEV_ITEMS_OBJECTID */ That comment looks really cryptic to someone just looking at the code. Adding case
BTRFS_DEV_ITEMS_OBJECTID: is better.
Quoted 5 lines
Quoted 1 line
print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 708
Quoted 1 line
print-tree.c +0
-0case BTRFS_ROOT_TREE_OBJECTID :Both constants have the same value so they can't be in one switch, but yeah the comment should be a bit more verbose, just the constant name is bringing more questions than answers.
Oh. Hmm. Let me try.
Thanks, Anand
Quoted 22 lines · Nikolay Borisov
Quoted 15 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTIDit hits. Albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>---
print-tree.c| 1 +1 file changed, 1 insertion(+)print-tree.c +0
-0@@ -704,6 +704,7 @@ void print_objectid(FILE *stream, u64 objectid, u8 type) }
Quoted 6 lines
print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 707
Quoted 2 lines
print-tree.c +1
-0switch (objectid) { +/* BTRFS_DEV_ITEMS_OBJECTID */ That comment looks really cryptic to someone just looking at the code. Adding case
BTRFS_DEV_ITEMS_OBJECTID: is better.
Both of them defined with the same value (we find which object by type). So only one of it can be in the case.
#define BTRFS_DEV_ITEMS_OBJECTID 1ULL
::
#define BTRFS_ROOT_TREE_OBJECTID 1ULL
Thanks, Anand
Quoted 4 lines
Quoted 4 lines
print-tree.c +0
-0case BTRFS_ROOT_TREE_OBJECTID :if (type ==BTRFS_DEV_ITEM_KEY )fprintf (stream,"DEV_ITEMS" );
PATCH v2 1/2 btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree
In reply to Anand JainSo when searching for BTRFS_DEV_ITEMS_OBJECTID, it hits, albeit it is defined same as BTRFS_ROOT_TREE_OBJECTID.
---v1->v2: Improve comment.
print-tree.c | 5 +++++ 1 file changed, 5 insertions(+)
print-tree.c +5 -0
@@ -705,6 +705,11 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)switch (objectid) {case BTRFS_ROOT_TREE_OBJECTID : +/* +* BTRFS_ROOT_TREE_OBJECTID and BTRFS_DEV_ITEMS_OBJECTID are +* defined with the same value of 1ULL, distinguish them by +* checking the type. +*/ if (type ==BTRFS_DEV_ITEM_KEY )fprintf (stream,"DEV_ITEMS" );else
Signature · 1 line
2.21.0 (Apple Git-120)
Quoted 4 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTID, it hits, albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>
Quoted 11 lines
---
v1->v2: Improve comment.print-tree.c | 5 +++++ 1 file changed, 5 insertions(+)print-tree.c +0
-0
print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 712
Quoted 8 lines
print-tree.c +5
-0@@ -705,6 +705,11 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)switch (objectid) {case BTRFS_ROOT_TREE_OBJECTID : +/* +* BTRFS_ROOT_TREE_OBJECTID and BTRFS_DEV_ITEMS_OBJECTID are +* defined with the same value of 1ULL, distinguish them by +* checking the type. +*/
Oh, some bad design from the very beginning of btrfs.
Any other duplicated objectid?
Thanks,
Qu
Quoted 4 lines
print-tree.c +0
-0if (type ==BTRFS_DEV_ITEM_KEY )fprintf (stream,"DEV_ITEMS" );else
Quoted 22 lines · Qu Wenruo
Quoted 4 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTID, it hits, albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>Reviewed-by Qu Wenruo <[email protected]>Quoted 12 lines
---
v1->v2: Improve comment.print-tree.c | 5 +++++ 1 file changed, 5 insertions(+)print-tree.c +0
-0@@ -705,6 +705,11 @@ void print_objectid(FILE *stream, u64 objectid, u8 type)
Quoted 9 lines
print-tree.c void print_objectid(FILE *stream, u64 objectid, u8 type) · line 712
Quoted 7 lines
print-tree.c +5
-0switch (objectid) {case BTRFS_ROOT_TREE_OBJECTID : +/* +* BTRFS_ROOT_TREE_OBJECTID and BTRFS_DEV_ITEMS_OBJECTID are +* defined with the same value of 1ULL, distinguish them by +* checking the type. +*/ Oh, some bad design from the very beginning of btrfs.
No, why bad design? Objectids need to be unique inside one group, like tree ids, but are otherwise independent and must be interpreted together with the key type. Which is exactly what print_objectid does.
Quoted 4 lines · Anand Jain
So when searching for
BTRFS_DEV_ITEMS_OBJECTIDit hits. Albeit it is defined same asBTRFS_ROOT_TREE_OBJECTID.Signed-off-by Anand Jain <[email protected]>
1-2 applied, thanks.