* xfs: encapsulate a block of debug code
@ 2011-07-18 18:14 Alex Elder
2011-07-19 17:10 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Alex Elder @ 2011-07-18 18:14 UTC (permalink / raw)
To: xfs
Pull into a helper function some debug-only code that validates a
xfs_da_blkinfo structure that's been read from disk.
Signed-off-by: Alex Elder <aelder@sgi.com>
---
fs/xfs/xfs_da_btree.c | 31 ++++++++++++++++++++-----------
1 file changed, 20 insertions(+), 11 deletions(-)
Index: b/fs/xfs/xfs_da_btree.c
===================================================================
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -692,6 +692,24 @@ xfs_da_join(xfs_da_state_t *state)
return(error);
}
+#ifdef DEBUG
+static void
+xfs_da_blkinfo_validate(struct xfs_da_blkinfo *blkinfo, __u16 level)
+{
+ __be16 magic = blkinfo->magic;
+
+ if (level == 1) {
+ ASSERT(magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
+ magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
+ } else
+ ASSERT(magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
+ ASSERT(!blkinfo->forw);
+ ASSERT(!blkinfo->back);
+}
+#else /* !DEBUG */
+#define xfs_da_blkinfo_validate(blkinfo, level)
+#endif /* !DEBUG */
+
/*
* We have only one entry in the root. Copy the only remaining child of
* the old root to block 0 as the new root node.
@@ -700,8 +718,6 @@ STATIC int
xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
{
xfs_da_intnode_t *oldroot;
- /* REFERENCED */
- xfs_da_blkinfo_t *blkinfo;
xfs_da_args_t *args;
xfs_dablk_t child;
xfs_dabuf_t *bp;
@@ -732,15 +748,8 @@ xfs_da_root_join(xfs_da_state_t *state,
if (error)
return(error);
ASSERT(bp != NULL);
- blkinfo = bp->data;
- if (be16_to_cpu(oldroot->hdr.level) == 1) {
- ASSERT(blkinfo->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
- blkinfo->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
- } else {
- ASSERT(blkinfo->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
- }
- ASSERT(!blkinfo->forw);
- ASSERT(!blkinfo->back);
+ xfs_da_blkinfo_validate(bp->data, be16_to_cpu(oldroot->hdr.level));
+
memcpy(root_blk->bp->data, bp->data, state->blocksize);
xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1);
error = xfs_da_shrink_inode(args, child, bp);
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: xfs: encapsulate a block of debug code
2011-07-18 18:14 xfs: encapsulate a block of debug code Alex Elder
@ 2011-07-19 17:10 ` Christoph Hellwig
2011-07-19 19:49 ` Alex Elder
0 siblings, 1 reply; 4+ messages in thread
From: Christoph Hellwig @ 2011-07-19 17:10 UTC (permalink / raw)
To: Alex Elder; +Cc: xfs
On Mon, Jul 18, 2011 at 01:14:09PM -0500, Alex Elder wrote:
> Pull into a helper function some debug-only code that validates a
> xfs_da_blkinfo structure that's been read from disk.
>
> Signed-off-by: Alex Elder <aelder@sgi.com>
>
> ---
> fs/xfs/xfs_da_btree.c | 31 ++++++++++++++++++++-----------
> 1 file changed, 20 insertions(+), 11 deletions(-)
>
> Index: b/fs/xfs/xfs_da_btree.c
> ===================================================================
> --- a/fs/xfs/xfs_da_btree.c
> +++ b/fs/xfs/xfs_da_btree.c
> @@ -692,6 +692,24 @@ xfs_da_join(xfs_da_state_t *state)
> return(error);
> }
>
> +#ifdef DEBUG
> +static void
> +xfs_da_blkinfo_validate(struct xfs_da_blkinfo *blkinfo, __u16 level)
I'm not sure the name is a good one. E.g. the forw/backw pointers
really rely on this node not having any siblings. Which they shoudn't
have here, but that's not generally true of any blkinfo.
Otherwise looks fine.
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: xfs: encapsulate a block of debug code
2011-07-19 17:10 ` Christoph Hellwig
@ 2011-07-19 19:49 ` Alex Elder
2011-07-24 11:30 ` Christoph Hellwig
0 siblings, 1 reply; 4+ messages in thread
From: Alex Elder @ 2011-07-19 19:49 UTC (permalink / raw)
To: Christoph Hellwig; +Cc: xfs
On Tue, 2011-07-19 at 13:10 -0400, Christoph Hellwig wrote:
> On Mon, Jul 18, 2011 at 01:14:09PM -0500, Alex Elder wrote:
> > Pull into a helper function some debug-only code that validates a
> > xfs_da_blkinfo structure that's been read from disk.
> >
> > Signed-off-by: Alex Elder <aelder@sgi.com>
> >
> > ---
> > fs/xfs/xfs_da_btree.c | 31 ++++++++++++++++++++-----------
> > 1 file changed, 20 insertions(+), 11 deletions(-)
> >
> > Index: b/fs/xfs/xfs_da_btree.c
> > ===================================================================
> > --- a/fs/xfs/xfs_da_btree.c
> > +++ b/fs/xfs/xfs_da_btree.c
> > @@ -692,6 +692,24 @@ xfs_da_join(xfs_da_state_t *state)
> > return(error);
> > }
> >
> > +#ifdef DEBUG
> > +static void
> > +xfs_da_blkinfo_validate(struct xfs_da_blkinfo *blkinfo, __u16 level)
>
> I'm not sure the name is a good one. E.g. the forw/backw pointers
> really rely on this node not having any siblings. Which they shoudn't
> have here, but that's not generally true of any blkinfo.
>
> Otherwise looks fine.
>
What about xfs_da_blkinfo_onlychild_validate()?
It's pushing the limits of acceptable name length
as far as I'm concerned though. Let me know if
this is good enough, or if you have another idea.
Thanks.
-Alex
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-24 11:30 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-18 18:14 xfs: encapsulate a block of debug code Alex Elder
2011-07-19 17:10 ` Christoph Hellwig
2011-07-19 19:49 ` Alex Elder
2011-07-24 11:30 ` Christoph Hellwig
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox