diff options
| author | Alex Elder <aelder@sgi.com> | 2011-07-18 14:14:09 -0400 |
|---|---|---|
| committer | Alex Elder <aelder@sgi.com> | 2011-07-26 23:05:34 -0400 |
| commit | 1c4f33296e8e79a6bbfffc8457d547ffc31d5dee (patch) | |
| tree | 67934ff868c5a9fb54841fc866adaf741868f9dc | |
| parent | b0189cd087aa82bd23277cb5c8960ab030e13e5c (diff) | |
xfs: encapsulate a block of debug code
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>
Reviewed-by: Christoph Hellwig <hch@infradead.org>
| -rw-r--r-- | fs/xfs/xfs_da_btree.c | 32 |
1 files changed, 21 insertions, 11 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 2925726529f8..5bfcb8779f9f 100644 --- 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) | |||
| 692 | return(error); | 692 | return(error); |
| 693 | } | 693 | } |
| 694 | 694 | ||
| 695 | #ifdef DEBUG | ||
| 696 | static void | ||
| 697 | xfs_da_blkinfo_onlychild_validate(struct xfs_da_blkinfo *blkinfo, __u16 level) | ||
| 698 | { | ||
| 699 | __be16 magic = blkinfo->magic; | ||
| 700 | |||
| 701 | if (level == 1) { | ||
| 702 | ASSERT(magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || | ||
| 703 | magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); | ||
| 704 | } else | ||
| 705 | ASSERT(magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); | ||
| 706 | ASSERT(!blkinfo->forw); | ||
| 707 | ASSERT(!blkinfo->back); | ||
| 708 | } | ||
| 709 | #else /* !DEBUG */ | ||
| 710 | #define xfs_da_blkinfo_onlychild_validate(blkinfo, level) | ||
| 711 | #endif /* !DEBUG */ | ||
| 712 | |||
| 695 | /* | 713 | /* |
| 696 | * We have only one entry in the root. Copy the only remaining child of | 714 | * We have only one entry in the root. Copy the only remaining child of |
| 697 | * the old root to block 0 as the new root node. | 715 | * the old root to block 0 as the new root node. |
| @@ -700,8 +718,6 @@ STATIC int | |||
| 700 | xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | 718 | xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) |
| 701 | { | 719 | { |
| 702 | xfs_da_intnode_t *oldroot; | 720 | xfs_da_intnode_t *oldroot; |
| 703 | /* REFERENCED */ | ||
| 704 | xfs_da_blkinfo_t *blkinfo; | ||
| 705 | xfs_da_args_t *args; | 721 | xfs_da_args_t *args; |
| 706 | xfs_dablk_t child; | 722 | xfs_dablk_t child; |
| 707 | xfs_dabuf_t *bp; | 723 | xfs_dabuf_t *bp; |
| @@ -732,15 +748,9 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | |||
| 732 | if (error) | 748 | if (error) |
| 733 | return(error); | 749 | return(error); |
| 734 | ASSERT(bp != NULL); | 750 | ASSERT(bp != NULL); |
| 735 | blkinfo = bp->data; | 751 | xfs_da_blkinfo_onlychild_validate(bp->data, |
| 736 | if (be16_to_cpu(oldroot->hdr.level) == 1) { | 752 | be16_to_cpu(oldroot->hdr.level)); |
| 737 | ASSERT(blkinfo->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || | 753 | |
| 738 | blkinfo->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)); | ||
| 739 | } else { | ||
| 740 | ASSERT(blkinfo->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)); | ||
| 741 | } | ||
| 742 | ASSERT(!blkinfo->forw); | ||
| 743 | ASSERT(!blkinfo->back); | ||
| 744 | memcpy(root_blk->bp->data, bp->data, state->blocksize); | 754 | memcpy(root_blk->bp->data, bp->data, state->blocksize); |
| 745 | xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); | 755 | xfs_da_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); |
| 746 | error = xfs_da_shrink_inode(args, child, bp); | 756 | error = xfs_da_shrink_inode(args, child, bp); |
