Re: [PATCH 19/25] xfs: add xfs_da_node verification

Phil White
2012-10-30T17:56:08Z

On Thu, Oct 25, 2012 at 05:34:08PM +1100, Dave Chinner wrote:
> From: Dave Chinner <dchinner@redhat.com>
>
> Signed-off-by: Dave Chinner <dchinner@redhat.com>
> ---
> fs/xfs/xfs_attr.c | 22 ++++------
> fs/xfs/xfs_attr_leaf.c | 12 +++---
> fs/xfs/xfs_attr_leaf.h | 8 ++--
> fs/xfs/xfs_da_btree.c | 108 ++++++++++++++++++++++++++++++++++++------------
> fs/xfs/xfs_da_btree.h | 3 ++
> fs/xfs/xfs_dir2_leaf.c | 2 +-
> fs/xfs/xfs_dir2_priv.h | 1 +
> 7 files changed, 106 insertions(+), 50 deletions(-)

Reviewed-by: Phil White <pwhite@sgi.com>

One minor comment:

> diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
> index a46035b..e950192 100644
> --- a/fs/xfs/xfs_da_btree.c
> +++ b/fs/xfs/xfs_da_btree.c
> @@ -91,6 +91,67 @@ STATIC int xfs_da_blk_unlink(xfs_da_state_t *state,
> xfs_da_state_blk_t *save_blk);
> STATIC void xfs_da_state_kill_altpath(xfs_da_state_t *state);
>
> +static void
> +__xfs_da_node_verify(
> + struct xfs_buf *bp)
> +{
> + struct xfs_mount *mp = bp->b_target->bt_mount;
> + struct xfs_da_node_hdr *hdr = bp->b_addr;
> + int block_ok = 0;
> +
> + block_ok = hdr->info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC);
> + block_ok |= hdr->level > 0;
> + block_ok |= hdr->count > 0;

This particular assignment seemed a little inconsistent, compared to
other usages. Functionally, it's fine though.

-Phil