All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] xfs_db: identify attr dabtree field types correctly
@ 2017-06-29 19:53 Darrick J. Wong
  2017-06-29 21:19 ` Eric Sandeen
  0 siblings, 1 reply; 3+ messages in thread
From: Darrick J. Wong @ 2017-06-29 19:53 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: xfs

For whatever reason, the v5 xattr dabtree header fields are mapped to
the directory dabtree header fields, which means that the types are
wrong and hence we cannot use the 'addr' command to step through the
tree.  Since the v4 attr dabtree does this correctly, simply port the v5
fields to the attr code too.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
 db/attr.c  |   24 ++++++++++++++++++++++--
 db/attr.h  |    2 ++
 db/field.c |    6 ++++--
 db/field.h |    1 +
 4 files changed, 29 insertions(+), 4 deletions(-)

diff --git a/db/attr.c b/db/attr.c
index 6f56953..2b7b164 100644
--- a/db/attr.c
+++ b/db/attr.c
@@ -499,7 +499,7 @@ const field_t	attr3_hfld[] = {
 const field_t	attr3_flds[] = {
 	{ "hdr", FLDT_ATTR3_LEAF_HDR, OI(L3OFF(hdr)), attr3_leaf_hdr_count,
 	  FLD_COUNT, TYP_NONE },
-	{ "hdr", FLDT_DA3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
+	{ "hdr", FLDT_ATTR3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
 	  FLD_COUNT, TYP_NONE },
 	{ "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)),
 	  attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE },
@@ -512,7 +512,7 @@ const field_t	attr3_flds[] = {
 
 #define	LH3OFF(f)	bitize(offsetof(struct xfs_attr3_leaf_hdr, f))
 const field_t	attr3_leaf_hdr_flds[] = {
-	{ "info", FLDT_DA3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
+	{ "info", FLDT_ATTR3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
 	{ "count", FLDT_UINT16D, OI(LH3OFF(count)), C1, 0, TYP_NONE },
 	{ "usedbytes", FLDT_UINT16D, OI(LH3OFF(usedbytes)), C1, 0, TYP_NONE },
 	{ "firstused", FLDT_UINT16D, OI(LH3OFF(firstused)), C1, 0, TYP_NONE },
@@ -523,6 +523,26 @@ const field_t	attr3_leaf_hdr_flds[] = {
 	{ NULL }
 };
 
+#define	DB3OFF(f)	bitize(offsetof(struct xfs_da3_blkinfo, f))
+const field_t	attr3_blkinfo_flds[] = {
+	{ "hdr", FLDT_ATTR_BLKINFO, OI(DB3OFF(hdr)), C1, 0, TYP_NONE },
+	{ "crc", FLDT_CRC, OI(DB3OFF(crc)), C1, 0, TYP_NONE },
+	{ "bno", FLDT_DFSBNO, OI(DB3OFF(blkno)), C1, 0, TYP_BMAPBTD },
+	{ "lsn", FLDT_UINT64X, OI(DB3OFF(lsn)), C1, 0, TYP_NONE },
+	{ "uuid", FLDT_UUID, OI(DB3OFF(uuid)), C1, 0, TYP_NONE },
+	{ "owner", FLDT_INO, OI(DB3OFF(owner)), C1, 0, TYP_NONE },
+	{ NULL }
+};
+
+#define	H3OFF(f)	bitize(offsetof(struct xfs_da3_node_hdr, f))
+const field_t	attr3_node_hdr_flds[] = {
+	{ "info", FLDT_ATTR3_BLKINFO, OI(H3OFF(info)), C1, 0, TYP_NONE },
+	{ "count", FLDT_UINT16D, OI(H3OFF(__count)), C1, 0, TYP_NONE },
+	{ "level", FLDT_UINT16D, OI(H3OFF(__level)), C1, 0, TYP_NONE },
+	{ "pad", FLDT_UINT32D, OI(H3OFF(__pad32)), C1, 0, TYP_NONE },
+	{ NULL }
+};
+
 /*
  * Special read verifier for attribute buffers. Detect the magic number
  * appropriately and set the correct verifier and call it.
diff --git a/db/attr.h b/db/attr.h
index bc3431f..21848c1 100644
--- a/db/attr.h
+++ b/db/attr.h
@@ -30,6 +30,8 @@ extern const field_t	attr3_flds[];
 extern const field_t	attr3_hfld[];
 extern const field_t	attr3_leaf_hdr_flds[];
 extern const field_t	attr3_node_hdr_flds[];
+extern const field_t	attr3_blkinfo_flds[];
+extern const field_t	attr3_node_hdr_flds[];
 
 extern int	attr_leaf_name_size(void *obj, int startoff, int idx);
 extern int	attr_size(void *obj, int startoff, int idx);
diff --git a/db/field.c b/db/field.c
index 2a2197a..d0c8e04 100644
--- a/db/field.c
+++ b/db/field.c
@@ -91,12 +91,14 @@ const ftattr_t	ftattrtab[] = {
 /* attr3 specific fields */
 	{ FLDT_ATTR3, "attr3", NULL, (char *)attr3_flds, attr_size, FTARG_SIZE,
 	  NULL, attr3_flds },
+	{ FLDT_ATTR3_BLKINFO, "attr3_blkinfo", NULL, (char *)attr3_blkinfo_flds,
+	  SI(bitsz(struct xfs_da_blkinfo)), 0, NULL, attr3_blkinfo_flds },
 	{ FLDT_ATTR3_LEAF_HDR, "attr3_leaf_hdr", NULL,
 	  (char *)attr3_leaf_hdr_flds, SI(bitsz(struct xfs_attr3_leaf_hdr)),
 	  0, NULL, attr3_leaf_hdr_flds },
 	{ FLDT_ATTR3_NODE_HDR, "attr3_node_hdr", NULL,
-	  (char *)da3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)),
-	  0, NULL, da3_node_hdr_flds },
+	  (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)),
+	  0, NULL, attr3_node_hdr_flds },
 
 	{ FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size,
 	  FTARG_SIZE, NULL, bmapbta_flds },
diff --git a/db/field.h b/db/field.h
index 53616f1..d1a7095 100644
--- a/db/field.h
+++ b/db/field.h
@@ -44,6 +44,7 @@ typedef enum fldt	{
 
 	/* attr 3 specific fields */
 	FLDT_ATTR3,
+	FLDT_ATTR3_BLKINFO,
 	FLDT_ATTR3_LEAF_HDR,
 	FLDT_ATTR3_NODE_HDR,
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs_db: identify attr dabtree field types correctly
  2017-06-29 19:53 [PATCH] xfs_db: identify attr dabtree field types correctly Darrick J. Wong
@ 2017-06-29 21:19 ` Eric Sandeen
  2017-06-29 23:58   ` Darrick J. Wong
  0 siblings, 1 reply; 3+ messages in thread
From: Eric Sandeen @ 2017-06-29 21:19 UTC (permalink / raw)
  To: Darrick J. Wong, Eric Sandeen; +Cc: xfs

On 6/29/17 2:53 PM, Darrick J. Wong wrote:
> For whatever reason, the v5 xattr dabtree header fields are mapped to
> the directory dabtree header fields, which means that the types are
> wrong and hence we cannot use the 'addr' command to step through the
> tree.  Since the v4 attr dabtree does this correctly, simply port the v5
> fields to the attr code too.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>  db/attr.c  |   24 ++++++++++++++++++++++--
>  db/attr.h  |    2 ++
>  db/field.c |    6 ++++--
>  db/field.h |    1 +
>  4 files changed, 29 insertions(+), 4 deletions(-)
> 
> diff --git a/db/attr.c b/db/attr.c
> index 6f56953..2b7b164 100644
> --- a/db/attr.c
> +++ b/db/attr.c
> @@ -499,7 +499,7 @@ const field_t	attr3_hfld[] = {
>  const field_t	attr3_flds[] = {
>  	{ "hdr", FLDT_ATTR3_LEAF_HDR, OI(L3OFF(hdr)), attr3_leaf_hdr_count,
>  	  FLD_COUNT, TYP_NONE },
> -	{ "hdr", FLDT_DA3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
> +	{ "hdr", FLDT_ATTR3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
>  	  FLD_COUNT, TYP_NONE },
>  	{ "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)),
>  	  attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE },
> @@ -512,7 +512,7 @@ const field_t	attr3_flds[] = {
>  
>  #define	LH3OFF(f)	bitize(offsetof(struct xfs_attr3_leaf_hdr, f))
>  const field_t	attr3_leaf_hdr_flds[] = {
> -	{ "info", FLDT_DA3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
> +	{ "info", FLDT_ATTR3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
>  	{ "count", FLDT_UINT16D, OI(LH3OFF(count)), C1, 0, TYP_NONE },
>  	{ "usedbytes", FLDT_UINT16D, OI(LH3OFF(usedbytes)), C1, 0, TYP_NONE },
>  	{ "firstused", FLDT_UINT16D, OI(LH3OFF(firstused)), C1, 0, TYP_NONE },
> @@ -523,6 +523,26 @@ const field_t	attr3_leaf_hdr_flds[] = {
>  	{ NULL }
>  };
>  
> +#define	DB3OFF(f)	bitize(offsetof(struct xfs_da3_blkinfo, f))

Doesn't "D" indicate dir?  so:  "B3OFF" (matching the existing "BOFF"
for attr_blkinfo_flds I think?)

> +const field_t	attr3_blkinfo_flds[] = {
> +	{ "hdr", FLDT_ATTR_BLKINFO, OI(DB3OFF(hdr)), C1, 0, TYP_NONE },
> +	{ "crc", FLDT_CRC, OI(DB3OFF(crc)), C1, 0, TYP_NONE },
> +	{ "bno", FLDT_DFSBNO, OI(DB3OFF(blkno)), C1, 0, TYP_BMAPBTD },
> +	{ "lsn", FLDT_UINT64X, OI(DB3OFF(lsn)), C1, 0, TYP_NONE },
> +	{ "uuid", FLDT_UUID, OI(DB3OFF(uuid)), C1, 0, TYP_NONE },
> +	{ "owner", FLDT_INO, OI(DB3OFF(owner)), C1, 0, TYP_NONE },
> +	{ NULL }
> +};
> +
> +#define	H3OFF(f)	bitize(offsetof(struct xfs_da3_node_hdr, f))
> +const field_t	attr3_node_hdr_flds[] = {
> +	{ "info", FLDT_ATTR3_BLKINFO, OI(H3OFF(info)), C1, 0, TYP_NONE },
> +	{ "count", FLDT_UINT16D, OI(H3OFF(__count)), C1, 0, TYP_NONE },
> +	{ "level", FLDT_UINT16D, OI(H3OFF(__level)), C1, 0, TYP_NONE },
> +	{ "pad", FLDT_UINT32D, OI(H3OFF(__pad32)), C1, 0, TYP_NONE },
> +	{ NULL }
> +};
> +
>  /*
>   * Special read verifier for attribute buffers. Detect the magic number
>   * appropriately and set the correct verifier and call it.
> diff --git a/db/attr.h b/db/attr.h
> index bc3431f..21848c1 100644
> --- a/db/attr.h
> +++ b/db/attr.h
> @@ -30,6 +30,8 @@ extern const field_t	attr3_flds[];
>  extern const field_t	attr3_hfld[];
>  extern const field_t	attr3_leaf_hdr_flds[];
>  extern const field_t	attr3_node_hdr_flds[];
> +extern const field_t	attr3_blkinfo_flds[];
> +extern const field_t	attr3_node_hdr_flds[];
>  
>  extern int	attr_leaf_name_size(void *obj, int startoff, int idx);
>  extern int	attr_size(void *obj, int startoff, int idx);
> diff --git a/db/field.c b/db/field.c
> index 2a2197a..d0c8e04 100644
> --- a/db/field.c
> +++ b/db/field.c
> @@ -91,12 +91,14 @@ const ftattr_t	ftattrtab[] = {
>  /* attr3 specific fields */
>  	{ FLDT_ATTR3, "attr3", NULL, (char *)attr3_flds, attr_size, FTARG_SIZE,
>  	  NULL, attr3_flds },
> +	{ FLDT_ATTR3_BLKINFO, "attr3_blkinfo", NULL, (char *)attr3_blkinfo_flds,
> +	  SI(bitsz(struct xfs_da_blkinfo)), 0, NULL, attr3_blkinfo_flds },

SI(bitsz(struct xfs_da3_blkinfo)) I think?

>  	{ FLDT_ATTR3_LEAF_HDR, "attr3_leaf_hdr", NULL,
>  	  (char *)attr3_leaf_hdr_flds, SI(bitsz(struct xfs_attr3_leaf_hdr)),
>  	  0, NULL, attr3_leaf_hdr_flds },
>  	{ FLDT_ATTR3_NODE_HDR, "attr3_node_hdr", NULL,
> -	  (char *)da3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)),
> -	  0, NULL, da3_node_hdr_flds },
> +	  (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)),
> +	  0, NULL, attr3_node_hdr_flds },
>  
>  	{ FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size,
>  	  FTARG_SIZE, NULL, bmapbta_flds },
> diff --git a/db/field.h b/db/field.h
> index 53616f1..d1a7095 100644
> --- a/db/field.h
> +++ b/db/field.h
> @@ -44,6 +44,7 @@ typedef enum fldt	{
>  
>  	/* attr 3 specific fields */
>  	FLDT_ATTR3,
> +	FLDT_ATTR3_BLKINFO,
>  	FLDT_ATTR3_LEAF_HDR,
>  	FLDT_ATTR3_NODE_HDR,
>  
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] xfs_db: identify attr dabtree field types correctly
  2017-06-29 21:19 ` Eric Sandeen
@ 2017-06-29 23:58   ` Darrick J. Wong
  0 siblings, 0 replies; 3+ messages in thread
From: Darrick J. Wong @ 2017-06-29 23:58 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: Eric Sandeen, xfs

On Thu, Jun 29, 2017 at 04:19:59PM -0500, Eric Sandeen wrote:
> On 6/29/17 2:53 PM, Darrick J. Wong wrote:
> > For whatever reason, the v5 xattr dabtree header fields are mapped to
> > the directory dabtree header fields, which means that the types are
> > wrong and hence we cannot use the 'addr' command to step through the
> > tree.  Since the v4 attr dabtree does this correctly, simply port the v5
> > fields to the attr code too.
> > 
> > Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> > ---
> >  db/attr.c  |   24 ++++++++++++++++++++++--
> >  db/attr.h  |    2 ++
> >  db/field.c |    6 ++++--
> >  db/field.h |    1 +
> >  4 files changed, 29 insertions(+), 4 deletions(-)
> > 
> > diff --git a/db/attr.c b/db/attr.c
> > index 6f56953..2b7b164 100644
> > --- a/db/attr.c
> > +++ b/db/attr.c
> > @@ -499,7 +499,7 @@ const field_t	attr3_hfld[] = {
> >  const field_t	attr3_flds[] = {
> >  	{ "hdr", FLDT_ATTR3_LEAF_HDR, OI(L3OFF(hdr)), attr3_leaf_hdr_count,
> >  	  FLD_COUNT, TYP_NONE },
> > -	{ "hdr", FLDT_DA3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
> > +	{ "hdr", FLDT_ATTR3_NODE_HDR, OI(N3OFF(hdr)), attr3_node_hdr_count,
> >  	  FLD_COUNT, TYP_NONE },
> >  	{ "entries", FLDT_ATTR_LEAF_ENTRY, OI(L3OFF(entries)),
> >  	  attr3_leaf_entries_count, FLD_ARRAY|FLD_COUNT, TYP_NONE },
> > @@ -512,7 +512,7 @@ const field_t	attr3_flds[] = {
> >  
> >  #define	LH3OFF(f)	bitize(offsetof(struct xfs_attr3_leaf_hdr, f))
> >  const field_t	attr3_leaf_hdr_flds[] = {
> > -	{ "info", FLDT_DA3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
> > +	{ "info", FLDT_ATTR3_BLKINFO, OI(LH3OFF(info)), C1, 0, TYP_NONE },
> >  	{ "count", FLDT_UINT16D, OI(LH3OFF(count)), C1, 0, TYP_NONE },
> >  	{ "usedbytes", FLDT_UINT16D, OI(LH3OFF(usedbytes)), C1, 0, TYP_NONE },
> >  	{ "firstused", FLDT_UINT16D, OI(LH3OFF(firstused)), C1, 0, TYP_NONE },
> > @@ -523,6 +523,26 @@ const field_t	attr3_leaf_hdr_flds[] = {
> >  	{ NULL }
> >  };
> >  
> > +#define	DB3OFF(f)	bitize(offsetof(struct xfs_da3_blkinfo, f))
> 
> Doesn't "D" indicate dir?  so:  "B3OFF" (matching the existing "BOFF"
> for attr_blkinfo_flds I think?)

Yeah.

> > +const field_t	attr3_blkinfo_flds[] = {
> > +	{ "hdr", FLDT_ATTR_BLKINFO, OI(DB3OFF(hdr)), C1, 0, TYP_NONE },
> > +	{ "crc", FLDT_CRC, OI(DB3OFF(crc)), C1, 0, TYP_NONE },
> > +	{ "bno", FLDT_DFSBNO, OI(DB3OFF(blkno)), C1, 0, TYP_BMAPBTD },
> > +	{ "lsn", FLDT_UINT64X, OI(DB3OFF(lsn)), C1, 0, TYP_NONE },
> > +	{ "uuid", FLDT_UUID, OI(DB3OFF(uuid)), C1, 0, TYP_NONE },
> > +	{ "owner", FLDT_INO, OI(DB3OFF(owner)), C1, 0, TYP_NONE },
> > +	{ NULL }
> > +};
> > +
> > +#define	H3OFF(f)	bitize(offsetof(struct xfs_da3_node_hdr, f))
> > +const field_t	attr3_node_hdr_flds[] = {
> > +	{ "info", FLDT_ATTR3_BLKINFO, OI(H3OFF(info)), C1, 0, TYP_NONE },
> > +	{ "count", FLDT_UINT16D, OI(H3OFF(__count)), C1, 0, TYP_NONE },
> > +	{ "level", FLDT_UINT16D, OI(H3OFF(__level)), C1, 0, TYP_NONE },
> > +	{ "pad", FLDT_UINT32D, OI(H3OFF(__pad32)), C1, 0, TYP_NONE },
> > +	{ NULL }
> > +};
> > +
> >  /*
> >   * Special read verifier for attribute buffers. Detect the magic number
> >   * appropriately and set the correct verifier and call it.
> > diff --git a/db/attr.h b/db/attr.h
> > index bc3431f..21848c1 100644
> > --- a/db/attr.h
> > +++ b/db/attr.h
> > @@ -30,6 +30,8 @@ extern const field_t	attr3_flds[];
> >  extern const field_t	attr3_hfld[];
> >  extern const field_t	attr3_leaf_hdr_flds[];
> >  extern const field_t	attr3_node_hdr_flds[];
> > +extern const field_t	attr3_blkinfo_flds[];
> > +extern const field_t	attr3_node_hdr_flds[];
> >  
> >  extern int	attr_leaf_name_size(void *obj, int startoff, int idx);
> >  extern int	attr_size(void *obj, int startoff, int idx);
> > diff --git a/db/field.c b/db/field.c
> > index 2a2197a..d0c8e04 100644
> > --- a/db/field.c
> > +++ b/db/field.c
> > @@ -91,12 +91,14 @@ const ftattr_t	ftattrtab[] = {
> >  /* attr3 specific fields */
> >  	{ FLDT_ATTR3, "attr3", NULL, (char *)attr3_flds, attr_size, FTARG_SIZE,
> >  	  NULL, attr3_flds },
> > +	{ FLDT_ATTR3_BLKINFO, "attr3_blkinfo", NULL, (char *)attr3_blkinfo_flds,
> > +	  SI(bitsz(struct xfs_da_blkinfo)), 0, NULL, attr3_blkinfo_flds },
> 
> SI(bitsz(struct xfs_da3_blkinfo)) I think?

Yes.  Thanks for catching these... it's strange that btdump still worked
despite the incorrect size.  Will resend.

--D

> 
> >  	{ FLDT_ATTR3_LEAF_HDR, "attr3_leaf_hdr", NULL,
> >  	  (char *)attr3_leaf_hdr_flds, SI(bitsz(struct xfs_attr3_leaf_hdr)),
> >  	  0, NULL, attr3_leaf_hdr_flds },
> >  	{ FLDT_ATTR3_NODE_HDR, "attr3_node_hdr", NULL,
> > -	  (char *)da3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)),
> > -	  0, NULL, da3_node_hdr_flds },
> > +	  (char *)attr3_node_hdr_flds, SI(bitsz(struct xfs_da3_node_hdr)),
> > +	  0, NULL, attr3_node_hdr_flds },
> >  
> >  	{ FLDT_BMAPBTA, "bmapbta", NULL, (char *)bmapbta_flds, btblock_size,
> >  	  FTARG_SIZE, NULL, bmapbta_flds },
> > diff --git a/db/field.h b/db/field.h
> > index 53616f1..d1a7095 100644
> > --- a/db/field.h
> > +++ b/db/field.h
> > @@ -44,6 +44,7 @@ typedef enum fldt	{
> >  
> >  	/* attr 3 specific fields */
> >  	FLDT_ATTR3,
> > +	FLDT_ATTR3_BLKINFO,
> >  	FLDT_ATTR3_LEAF_HDR,
> >  	FLDT_ATTR3_NODE_HDR,
> >  
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at  http://vger.kernel.org/majordomo-info.html
> > 

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2017-06-29 23:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-29 19:53 [PATCH] xfs_db: identify attr dabtree field types correctly Darrick J. Wong
2017-06-29 21:19 ` Eric Sandeen
2017-06-29 23:58   ` Darrick J. Wong

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.