xfs
[Top] [All Lists]

Re: [PATCH 16/27] xfs: avoid usage of struct xfs_dir2_block

To: Christoph Hellwig <hch@xxxxxxxxxxxxx>
Subject: Re: [PATCH 16/27] xfs: avoid usage of struct xfs_dir2_block
From: Dave Chinner <david@xxxxxxxxxxxxx>
Date: Wed, 6 Jul 2011 12:19:35 +1000
Cc: xfs@xxxxxxxxxxx
In-reply-to: <20110701094605.621819832@xxxxxxxxxxxxxxxxxxxxxx>
References: <20110701094321.936534538@xxxxxxxxxxxxxxxxxxxxxx> <20110701094605.621819832@xxxxxxxxxxxxxxxxxxxxxx>
User-agent: Mutt/1.5.20 (2009-06-14)
On Fri, Jul 01, 2011 at 05:43:37AM -0400, Christoph Hellwig wrote:
> In most places we can simply pass around and use the struct xfs_dir2_data_hdr,
> which is the first and most important member of struct xfs_dir2_block instead
> of the full structure.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>
....
> @@ -105,13 +105,13 @@ xfs_dir2_block_addname(
>               return error;
>       }
>       ASSERT(bp != NULL);
> -     block = bp->data;
> +     hdr = bp->data;
>       /*
>        * Check the magic number, corrupted if wrong.
>        */
> -     if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) {
> +     if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) {

Took me a moment to realise what this does - turns the byte swap
into a compile-time operation rather than a runtime operation.
Nice.

Perhaps we should do that same optimisation in other magic number
checks around the place?

Looks good.

Reviewed-by: Dave Chinner <dchinner@xxxxxxxxxx>
-- 
Dave Chinner
david@xxxxxxxxxxxxx

<Prev in Thread] Current Thread [Next in Thread>