[PATCH 16/27] xfs: avoid usage of struct xfs_dir2_block
Dave Chinner
david at fromorbit.com
Tue Jul 5 21:19:35 CDT 2011
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 at lst.de>
....
> @@ -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 at redhat.com>
--
Dave Chinner
david at fromorbit.com
More information about the xfs
mailing list