diff mbox series

[v2,1/2] btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree

Message ID 20190828140605.20790-1-anand.jain@oracle.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/2] btrfs-progs: add BTRFS_DEV_ITEMS_OBJECTID in comment in print-tree | expand

Commit Message

Anand Jain Aug. 28, 2019, 2:06 p.m. UTC
So when searching for BTRFS_DEV_ITEMS_OBJECTID, it hits, albeit it is
defined same as BTRFS_ROOT_TREE_OBJECTID.

Signed-off-by: Anand Jain <anand.jain@oracle.com>
---
v1->v2: Improve comment.

 print-tree.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Qu Wenruo Aug. 28, 2019, 2:27 p.m. UTC | #1
On 2019/8/28 下午10:06, Anand Jain wrote:
> So when searching for BTRFS_DEV_ITEMS_OBJECTID, it hits, albeit it is
> defined same as BTRFS_ROOT_TREE_OBJECTID.
> 
> Signed-off-by: Anand Jain <anand.jain@oracle.com>

Reviewed-by: Qu Wenruo <wqu@suse.com>

> ---
> v1->v2: Improve comment.
> 
>  print-tree.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/print-tree.c b/print-tree.c
> index b31e515f8989..b1c59d776547 100644
> --- a/print-tree.c
> +++ b/print-tree.c
> @@ -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

>  		if (type == BTRFS_DEV_ITEM_KEY)
>  			fprintf(stream, "DEV_ITEMS");
>  		else
>
David Sterba Aug. 28, 2019, 4:37 p.m. UTC | #2
On Wed, Aug 28, 2019 at 10:27:41PM +0800, Qu Wenruo wrote:
> 
> 
> On 2019/8/28 下午10:06, Anand Jain wrote:
> > So when searching for BTRFS_DEV_ITEMS_OBJECTID, it hits, albeit it is
> > defined same as BTRFS_ROOT_TREE_OBJECTID.
> > 
> > Signed-off-by: Anand Jain <anand.jain@oracle.com>
> 
> Reviewed-by: Qu Wenruo <wqu@suse.com>
> 
> > ---
> > v1->v2: Improve comment.
> > 
> >  print-tree.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> > 
> > diff --git a/print-tree.c b/print-tree.c
> > index b31e515f8989..b1c59d776547 100644
> > --- a/print-tree.c
> > +++ b/print-tree.c
> > @@ -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.

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.
diff mbox series

Patch

diff --git a/print-tree.c b/print-tree.c
index b31e515f8989..b1c59d776547 100644
--- a/print-tree.c
+++ b/print-tree.c
@@ -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