Commit 69ef921b authored by Christoph Hellwig's avatar Christoph Hellwig

xfs: byteswap constants instead of variables

Micro-optimize various comparisms by always byteswapping the constant
instead of the variable, which allows to do the swap at compile instead
of runtime.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarAlex Elder <aelder@sgi.com>
Reviewed-by: default avatarDave Chinner <dchinner@redhat.com>
parent 218106a1
...@@ -2127,7 +2127,7 @@ xfs_read_agf( ...@@ -2127,7 +2127,7 @@ xfs_read_agf(
* Validate the magic number of the agf block. * Validate the magic number of the agf block.
*/ */
agf_ok = agf_ok =
be32_to_cpu(agf->agf_magicnum) == XFS_AGF_MAGIC && agf->agf_magicnum == cpu_to_be32(XFS_AGF_MAGIC) &&
XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) && XFS_AGF_GOOD_VERSION(be32_to_cpu(agf->agf_versionnum)) &&
be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) && be32_to_cpu(agf->agf_freeblks) <= be32_to_cpu(agf->agf_length) &&
be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) && be32_to_cpu(agf->agf_flfirst) < XFS_AGFL_SIZE(mp) &&
......
...@@ -1203,7 +1203,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) ...@@ -1203,7 +1203,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
return XFS_ERROR(error); return XFS_ERROR(error);
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) { if (unlikely(leaf->hdr.info.magic != cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
context->dp->i_mount, leaf); context->dp->i_mount, leaf);
xfs_da_brelse(NULL, bp); xfs_da_brelse(NULL, bp);
...@@ -1610,9 +1610,8 @@ xfs_attr_node_removename(xfs_da_args_t *args) ...@@ -1610,9 +1610,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
XFS_ATTR_FORK); XFS_ATTR_FORK);
if (error) if (error)
goto out; goto out;
ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *) ASSERT((((xfs_attr_leafblock_t *)bp->data)->hdr.info.magic) ==
bp->data)->hdr.info.magic) cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
== XFS_ATTR_LEAF_MAGIC);
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
xfs_bmap_init(args->flist, args->firstblock); xfs_bmap_init(args->flist, args->firstblock);
...@@ -1877,11 +1876,11 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -1877,11 +1876,11 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(XFS_ERROR(EFSCORRUPTED)); return(XFS_ERROR(EFSCORRUPTED));
} }
node = bp->data; node = bp->data;
if (be16_to_cpu(node->hdr.info.magic) if (node->hdr.info.magic ==
== XFS_ATTR_LEAF_MAGIC) cpu_to_be16(XFS_ATTR_LEAF_MAGIC))
break; break;
if (unlikely(be16_to_cpu(node->hdr.info.magic) if (unlikely(node->hdr.info.magic !=
!= XFS_DA_NODE_MAGIC)) { cpu_to_be16(XFS_DA_NODE_MAGIC))) {
XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)",
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
context->dp->i_mount, context->dp->i_mount,
...@@ -1916,8 +1915,8 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -1916,8 +1915,8 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
*/ */
for (;;) { for (;;) {
leaf = bp->data; leaf = bp->data;
if (unlikely(be16_to_cpu(leaf->hdr.info.magic) if (unlikely(leaf->hdr.info.magic !=
!= XFS_ATTR_LEAF_MAGIC)) { cpu_to_be16(XFS_ATTR_LEAF_MAGIC))) {
XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)",
XFS_ERRLEVEL_LOW, XFS_ERRLEVEL_LOW,
context->dp->i_mount, leaf); context->dp->i_mount, leaf);
......
...@@ -731,7 +731,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) ...@@ -731,7 +731,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
int bytes, i; int bytes, i;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
entry = &leaf->entries[0]; entry = &leaf->entries[0];
bytes = sizeof(struct xfs_attr_sf_hdr); bytes = sizeof(struct xfs_attr_sf_hdr);
...@@ -777,7 +777,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) ...@@ -777,7 +777,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
ASSERT(bp != NULL); ASSERT(bp != NULL);
memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
leaf = (xfs_attr_leafblock_t *)tmpbuffer; leaf = (xfs_attr_leafblock_t *)tmpbuffer;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
/* /*
...@@ -872,7 +872,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args) ...@@ -872,7 +872,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
goto out; goto out;
node = bp1->data; node = bp1->data;
leaf = bp2->data; leaf = bp2->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
/* both on-disk, don't endian-flip twice */ /* both on-disk, don't endian-flip twice */
node->btree[0].hashval = node->btree[0].hashval =
leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval; leaf->entries[be16_to_cpu(leaf->hdr.count)-1 ].hashval;
...@@ -997,7 +997,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -997,7 +997,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
int tablesize, entsize, sum, tmp, i; int tablesize, entsize, sum, tmp, i;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT((args->index >= 0) ASSERT((args->index >= 0)
&& (args->index <= be16_to_cpu(leaf->hdr.count))); && (args->index <= be16_to_cpu(leaf->hdr.count)));
hdr = &leaf->hdr; hdr = &leaf->hdr;
...@@ -1070,7 +1070,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) ...@@ -1070,7 +1070,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
int tmp, i; int tmp, i;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
hdr = &leaf->hdr; hdr = &leaf->hdr;
ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE));
ASSERT((args->index >= 0) && (args->index <= be16_to_cpu(hdr->count))); ASSERT((args->index >= 0) && (args->index <= be16_to_cpu(hdr->count)));
...@@ -1256,8 +1256,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -1256,8 +1256,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC);
leaf1 = blk1->bp->data; leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data; leaf2 = blk2->bp->data;
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
args = state->args; args = state->args;
/* /*
...@@ -1533,7 +1533,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1533,7 +1533,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
*/ */
blk = &state->path.blk[ state->path.active-1 ]; blk = &state->path.blk[ state->path.active-1 ];
info = blk->bp->data; info = blk->bp->data;
ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
leaf = (xfs_attr_leafblock_t *)info; leaf = (xfs_attr_leafblock_t *)info;
count = be16_to_cpu(leaf->hdr.count); count = be16_to_cpu(leaf->hdr.count);
bytes = sizeof(xfs_attr_leaf_hdr_t) + bytes = sizeof(xfs_attr_leaf_hdr_t) +
...@@ -1596,7 +1596,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1596,7 +1596,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
bytes = state->blocksize - (state->blocksize>>2); bytes = state->blocksize - (state->blocksize>>2);
bytes -= be16_to_cpu(leaf->hdr.usedbytes); bytes -= be16_to_cpu(leaf->hdr.usedbytes);
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
count += be16_to_cpu(leaf->hdr.count); count += be16_to_cpu(leaf->hdr.count);
bytes -= be16_to_cpu(leaf->hdr.usedbytes); bytes -= be16_to_cpu(leaf->hdr.usedbytes);
bytes -= count * sizeof(xfs_attr_leaf_entry_t); bytes -= count * sizeof(xfs_attr_leaf_entry_t);
...@@ -1650,7 +1650,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -1650,7 +1650,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_mount_t *mp; xfs_mount_t *mp;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
hdr = &leaf->hdr; hdr = &leaf->hdr;
mp = args->trans->t_mountp; mp = args->trans->t_mountp;
ASSERT((be16_to_cpu(hdr->count) > 0) ASSERT((be16_to_cpu(hdr->count) > 0)
...@@ -1813,8 +1813,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1813,8 +1813,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC);
drop_leaf = drop_blk->bp->data; drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data; save_leaf = save_blk->bp->data;
ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
drop_hdr = &drop_leaf->hdr; drop_hdr = &drop_leaf->hdr;
save_hdr = &save_leaf->hdr; save_hdr = &save_leaf->hdr;
...@@ -1915,7 +1915,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -1915,7 +1915,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_dahash_t hashval; xfs_dahash_t hashval;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(be16_to_cpu(leaf->hdr.count) ASSERT(be16_to_cpu(leaf->hdr.count)
< (XFS_LBSIZE(args->dp->i_mount)/8)); < (XFS_LBSIZE(args->dp->i_mount)/8));
...@@ -2019,7 +2019,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -2019,7 +2019,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_attr_leaf_name_remote_t *name_rmt; xfs_attr_leaf_name_remote_t *name_rmt;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(be16_to_cpu(leaf->hdr.count) ASSERT(be16_to_cpu(leaf->hdr.count)
< (XFS_LBSIZE(args->dp->i_mount)/8)); < (XFS_LBSIZE(args->dp->i_mount)/8));
ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
...@@ -2087,8 +2087,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, ...@@ -2087,8 +2087,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
/* /*
* Set up environment. * Set up environment.
*/ */
ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf_s->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf_d->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
hdr_s = &leaf_s->hdr; hdr_s = &leaf_s->hdr;
hdr_d = &leaf_d->hdr; hdr_d = &leaf_d->hdr;
ASSERT((be16_to_cpu(hdr_s->count) > 0) && ASSERT((be16_to_cpu(hdr_s->count) > 0) &&
...@@ -2222,8 +2222,8 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) ...@@ -2222,8 +2222,8 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
leaf1 = leaf1_bp->data; leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data; leaf2 = leaf2_bp->data;
ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) && ASSERT((leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) &&
(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC)); (leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)));
if ((be16_to_cpu(leaf1->hdr.count) > 0) && if ((be16_to_cpu(leaf1->hdr.count) > 0) &&
(be16_to_cpu(leaf2->hdr.count) > 0) && (be16_to_cpu(leaf2->hdr.count) > 0) &&
((be32_to_cpu(leaf2->entries[0].hashval) < ((be32_to_cpu(leaf2->entries[0].hashval) <
...@@ -2246,7 +2246,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) ...@@ -2246,7 +2246,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count)
xfs_attr_leafblock_t *leaf; xfs_attr_leafblock_t *leaf;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
if (count) if (count)
*count = be16_to_cpu(leaf->hdr.count); *count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count) if (!leaf->hdr.count)
...@@ -2265,7 +2265,7 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) ...@@ -2265,7 +2265,7 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
xfs_attr_leaf_name_remote_t *name_rmt; xfs_attr_leaf_name_remote_t *name_rmt;
int size; int size;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { if (leaf->entries[index].flags & XFS_ATTR_LOCAL) {
name_loc = xfs_attr_leaf_name_local(leaf, index); name_loc = xfs_attr_leaf_name_local(leaf, index);
size = xfs_attr_leaf_entsize_local(name_loc->namelen, size = xfs_attr_leaf_entsize_local(name_loc->namelen,
...@@ -2451,7 +2451,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) ...@@ -2451,7 +2451,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
ASSERT(args->index >= 0); ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ]; entry = &leaf->entries[ args->index ];
...@@ -2515,7 +2515,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args) ...@@ -2515,7 +2515,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(args->index < be16_to_cpu(leaf->hdr.count)); ASSERT(args->index < be16_to_cpu(leaf->hdr.count));
ASSERT(args->index >= 0); ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ]; entry = &leaf->entries[ args->index ];
...@@ -2585,13 +2585,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) ...@@ -2585,13 +2585,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
} }
leaf1 = bp1->data; leaf1 = bp1->data;
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(args->index < be16_to_cpu(leaf1->hdr.count)); ASSERT(args->index < be16_to_cpu(leaf1->hdr.count));
ASSERT(args->index >= 0); ASSERT(args->index >= 0);
entry1 = &leaf1->entries[ args->index ]; entry1 = &leaf1->entries[ args->index ];
leaf2 = bp2->data; leaf2 = bp2->data;
ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count)); ASSERT(args->index2 < be16_to_cpu(leaf2->hdr.count));
ASSERT(args->index2 >= 0); ASSERT(args->index2 >= 0);
entry2 = &leaf2->entries[ args->index2 ]; entry2 = &leaf2->entries[ args->index2 ];
...@@ -2689,9 +2689,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp) ...@@ -2689,9 +2689,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
* This is a depth-first traversal! * This is a depth-first traversal!
*/ */
info = bp->data; info = bp->data;
if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
error = xfs_attr_node_inactive(trans, dp, bp, 1); error = xfs_attr_node_inactive(trans, dp, bp, 1);
} else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { } else if (info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) {
error = xfs_attr_leaf_inactive(trans, dp, bp); error = xfs_attr_leaf_inactive(trans, dp, bp);
} else { } else {
error = XFS_ERROR(EIO); error = XFS_ERROR(EIO);
...@@ -2739,7 +2739,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, ...@@ -2739,7 +2739,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
} }
node = bp->data; node = bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ parent_blkno = xfs_da_blkno(bp); /* save for re-read later */
count = be16_to_cpu(node->hdr.count); count = be16_to_cpu(node->hdr.count);
if (!count) { if (!count) {
...@@ -2773,10 +2773,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, ...@@ -2773,10 +2773,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
* Invalidate the subtree, however we have to. * Invalidate the subtree, however we have to.
*/ */
info = child_bp->data; info = child_bp->data;
if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { if (info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
error = xfs_attr_node_inactive(trans, dp, error = xfs_attr_node_inactive(trans, dp,
child_bp, level+1); child_bp, level+1);
} else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { } else if (info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC)) {
error = xfs_attr_leaf_inactive(trans, dp, error = xfs_attr_leaf_inactive(trans, dp,
child_bp); child_bp);
} else { } else {
...@@ -2836,7 +2836,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) ...@@ -2836,7 +2836,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
int error, count, size, tmp, i; int error, count, size, tmp, i;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
/* /*
* Count the number of "remote" value extents. * Count the number of "remote" value extents.
......
...@@ -4083,7 +4083,7 @@ xfs_bmap_sanity_check( ...@@ -4083,7 +4083,7 @@ xfs_bmap_sanity_check(
{ {
struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp); struct xfs_btree_block *block = XFS_BUF_TO_BLOCK(bp);
if (be32_to_cpu(block->bb_magic) != XFS_BMAP_MAGIC || if (block->bb_magic != cpu_to_be32(XFS_BMAP_MAGIC) ||
be16_to_cpu(block->bb_level) != level || be16_to_cpu(block->bb_level) != level ||
be16_to_cpu(block->bb_numrecs) == 0 || be16_to_cpu(block->bb_numrecs) == 0 ||
be16_to_cpu(block->bb_numrecs) > mp->m_bmap_dmxr[level != 0]) be16_to_cpu(block->bb_numrecs) > mp->m_bmap_dmxr[level != 0])
......
...@@ -425,10 +425,10 @@ xfs_bmbt_to_bmdr( ...@@ -425,10 +425,10 @@ xfs_bmbt_to_bmdr(
xfs_bmbt_key_t *tkp; xfs_bmbt_key_t *tkp;
__be64 *tpp; __be64 *tpp;
ASSERT(be32_to_cpu(rblock->bb_magic) == XFS_BMAP_MAGIC); ASSERT(rblock->bb_magic == cpu_to_be32(XFS_BMAP_MAGIC));
ASSERT(be64_to_cpu(rblock->bb_u.l.bb_leftsib) == NULLDFSBNO); ASSERT(rblock->bb_u.l.bb_leftsib == cpu_to_be64(NULLDFSBNO));
ASSERT(be64_to_cpu(rblock->bb_u.l.bb_rightsib) == NULLDFSBNO); ASSERT(rblock->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO));
ASSERT(be16_to_cpu(rblock->bb_level) > 0); ASSERT(rblock->bb_level != 0);
dblock->bb_level = rblock->bb_level; dblock->bb_level = rblock->bb_level;
dblock->bb_numrecs = rblock->bb_numrecs; dblock->bb_numrecs = rblock->bb_numrecs;
dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0); dmxr = xfs_bmdr_maxrecs(mp, dblocklen, 0);
......
...@@ -66,11 +66,11 @@ xfs_btree_check_lblock( ...@@ -66,11 +66,11 @@ xfs_btree_check_lblock(
be16_to_cpu(block->bb_numrecs) <= be16_to_cpu(block->bb_numrecs) <=
cur->bc_ops->get_maxrecs(cur, level) && cur->bc_ops->get_maxrecs(cur, level) &&
block->bb_u.l.bb_leftsib && block->bb_u.l.bb_leftsib &&
(be64_to_cpu(block->bb_u.l.bb_leftsib) == NULLDFSBNO || (block->bb_u.l.bb_leftsib == cpu_to_be64(NULLDFSBNO) ||
XFS_FSB_SANITY_CHECK(mp, XFS_FSB_SANITY_CHECK(mp,
be64_to_cpu(block->bb_u.l.bb_leftsib))) && be64_to_cpu(block->bb_u.l.bb_leftsib))) &&
block->bb_u.l.bb_rightsib && block->bb_u.l.bb_rightsib &&
(be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO || (block->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO) ||
XFS_FSB_SANITY_CHECK(mp, XFS_FSB_SANITY_CHECK(mp,
be64_to_cpu(block->bb_u.l.bb_rightsib))); be64_to_cpu(block->bb_u.l.bb_rightsib)));
if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp, if (unlikely(XFS_TEST_ERROR(!lblock_ok, mp,
...@@ -105,10 +105,10 @@ xfs_btree_check_sblock( ...@@ -105,10 +105,10 @@ xfs_btree_check_sblock(
be16_to_cpu(block->bb_level) == level && be16_to_cpu(block->bb_level) == level &&
be16_to_cpu(block->bb_numrecs) <= be16_to_cpu(block->bb_numrecs) <=
cur->bc_ops->get_maxrecs(cur, level) && cur->bc_ops->get_maxrecs(cur, level) &&
(be32_to_cpu(block->bb_u.s.bb_leftsib) == NULLAGBLOCK || (block->bb_u.s.bb_leftsib == cpu_to_be32(NULLAGBLOCK) ||
be32_to_cpu(block->bb_u.s.bb_leftsib) < agflen) && be32_to_cpu(block->bb_u.s.bb_leftsib) < agflen) &&
block->bb_u.s.bb_leftsib && block->bb_u.s.bb_leftsib &&
(be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK || (block->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK) ||
be32_to_cpu(block->bb_u.s.bb_rightsib) < agflen) && be32_to_cpu(block->bb_u.s.bb_rightsib) < agflen) &&
block->bb_u.s.bb_rightsib; block->bb_u.s.bb_rightsib;
if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp, if (unlikely(XFS_TEST_ERROR(!sblock_ok, cur->bc_mp,
...@@ -511,9 +511,9 @@ xfs_btree_islastblock( ...@@ -511,9 +511,9 @@ xfs_btree_islastblock(
block = xfs_btree_get_block(cur, level, &bp); block = xfs_btree_get_block(cur, level, &bp);
xfs_btree_check_block(cur, block, level, bp); xfs_btree_check_block(cur, block, level, bp);
if (cur->bc_flags & XFS_BTREE_LONG_PTRS) if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
return be64_to_cpu(block->bb_u.l.bb_rightsib) == NULLDFSBNO; return block->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO);
else else
return be32_to_cpu(block->bb_u.s.bb_rightsib) == NULLAGBLOCK; return block->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK);
} }
/* /*
...@@ -777,14 +777,14 @@ xfs_btree_setbuf( ...@@ -777,14 +777,14 @@ xfs_btree_setbuf(
b = XFS_BUF_TO_BLOCK(bp); b = XFS_BUF_TO_BLOCK(bp);
if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
if (be64_to_cpu(b->bb_u.l.bb_leftsib) == NULLDFSBNO) if (b->bb_u.l.bb_leftsib == cpu_to_be64(NULLDFSBNO))
cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
if (be64_to_cpu(b->bb_u.l.bb_rightsib) == NULLDFSBNO) if (b->bb_u.l.bb_rightsib == cpu_to_be64(NULLDFSBNO))
cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
} else { } else {
if (be32_to_cpu(b->bb_u.s.bb_leftsib) == NULLAGBLOCK) if (b->bb_u.s.bb_leftsib == cpu_to_be32(NULLAGBLOCK))
cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA; cur->bc_ra[lev] |= XFS_BTCUR_LEFTRA;
if (be32_to_cpu(b->bb_u.s.bb_rightsib) == NULLAGBLOCK) if (b->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK))
cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA; cur->bc_ra[lev] |= XFS_BTCUR_RIGHTRA;
} }
} }
...@@ -795,9 +795,9 @@ xfs_btree_ptr_is_null( ...@@ -795,9 +795,9 @@ xfs_btree_ptr_is_null(
union xfs_btree_ptr *ptr) union xfs_btree_ptr *ptr)
{ {
if (cur->bc_flags & XFS_BTREE_LONG_PTRS) if (cur->bc_flags & XFS_BTREE_LONG_PTRS)
return be64_to_cpu(ptr->l) == NULLDFSBNO; return ptr->l == cpu_to_be64(NULLDFSBNO);
else else
return be32_to_cpu(ptr->s) == NULLAGBLOCK; return ptr->s == cpu_to_be32(NULLAGBLOCK);
} }
STATIC void STATIC void
...@@ -923,12 +923,12 @@ xfs_btree_ptr_to_daddr( ...@@ -923,12 +923,12 @@ xfs_btree_ptr_to_daddr(
union xfs_btree_ptr *ptr) union xfs_btree_ptr *ptr)
{ {
if (cur->bc_flags & XFS_BTREE_LONG_PTRS) { if (cur->bc_flags & XFS_BTREE_LONG_PTRS) {
ASSERT(be64_to_cpu(ptr->l) != NULLDFSBNO); ASSERT(ptr->l != cpu_to_be64(NULLDFSBNO));
return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l)); return XFS_FSB_TO_DADDR(cur->bc_mp, be64_to_cpu(ptr->l));
} else { } else {
ASSERT(cur->bc_private.a.agno != NULLAGNUMBER); ASSERT(cur->bc_private.a.agno != NULLAGNUMBER);
ASSERT(be32_to_cpu(ptr->s) != NULLAGBLOCK); ASSERT(ptr->s != cpu_to_be32(NULLAGBLOCK));
return XFS_AGB_TO_DADDR(cur->bc_mp, cur->bc_private.a.agno, return XFS_AGB_TO_DADDR(cur->bc_mp, cur->bc_private.a.agno,
be32_to_cpu(ptr->s)); be32_to_cpu(ptr->s));
......
...@@ -321,11 +321,11 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -321,11 +321,11 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
ASSERT(bp != NULL); ASSERT(bp != NULL);
node = bp->data; node = bp->data;
oldroot = blk1->bp->data; oldroot = blk1->bp->data;
if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) { if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC)) {
size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] - size = (int)((char *)&oldroot->btree[be16_to_cpu(oldroot->hdr.count)] -
(char *)oldroot); (char *)oldroot);
} else { } else {
ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
leaf = (xfs_dir2_leaf_t *)oldroot; leaf = (xfs_dir2_leaf_t *)oldroot;
size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] - size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] -
(char *)leaf); (char *)leaf);
...@@ -352,7 +352,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -352,7 +352,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
node->hdr.count = cpu_to_be16(2); node->hdr.count = cpu_to_be16(2);
#ifdef DEBUG #ifdef DEBUG
if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) { if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)) {
ASSERT(blk1->blkno >= mp->m_dirleafblk && ASSERT(blk1->blkno >= mp->m_dirleafblk &&
blk1->blkno < mp->m_dirfreeblk); blk1->blkno < mp->m_dirfreeblk);
ASSERT(blk2->blkno >= mp->m_dirleafblk && ASSERT(blk2->blkno >= mp->m_dirleafblk &&
...@@ -384,7 +384,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, ...@@ -384,7 +384,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
int useextra; int useextra;
node = oldblk->bp->data; node = oldblk->bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
/* /*
* With V2 dirs the extra block is data or freespace. * With V2 dirs the extra block is data or freespace.
...@@ -483,8 +483,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -483,8 +483,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
node1 = node2; node1 = node2;
node2 = tmpnode; node2 = tmpnode;
} }
ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node1->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node2->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
count = (be16_to_cpu(node1->hdr.count) - be16_to_cpu(node2->hdr.count)) / 2; count = (be16_to_cpu(node1->hdr.count) - be16_to_cpu(node2->hdr.count)) / 2;
if (count == 0) if (count == 0)
return; return;
...@@ -578,7 +578,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, ...@@ -578,7 +578,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
int tmp; int tmp;
node = oldblk->bp->data; node = oldblk->bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count))); ASSERT((oldblk->index >= 0) && (oldblk->index <= be16_to_cpu(node->hdr.count)));
ASSERT(newblk->blkno != 0); ASSERT(newblk->blkno != 0);
if (state->args->whichfork == XFS_DATA_FORK) if (state->args->whichfork == XFS_DATA_FORK)
...@@ -714,7 +714,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) ...@@ -714,7 +714,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
ASSERT(args != NULL); ASSERT(args != NULL);
ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC);
oldroot = root_blk->bp->data; oldroot = root_blk->bp->data;
ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(oldroot->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
ASSERT(!oldroot->hdr.info.forw); ASSERT(!oldroot->hdr.info.forw);
ASSERT(!oldroot->hdr.info.back); ASSERT(!oldroot->hdr.info.back);
...@@ -737,10 +737,10 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) ...@@ -737,10 +737,10 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk)
ASSERT(bp != NULL); ASSERT(bp != NULL);
blkinfo = bp->data; blkinfo = bp->data;
if (be16_to_cpu(oldroot->hdr.level) == 1) { if (be16_to_cpu(oldroot->hdr.level) == 1) {
ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIR2_LEAFN_MAGIC || ASSERT(blkinfo->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC); blkinfo->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
} else { } else {
ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC); ASSERT(blkinfo->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
} }
ASSERT(!blkinfo->forw); ASSERT(!blkinfo->forw);
ASSERT(!blkinfo->back); ASSERT(!blkinfo->back);
...@@ -776,7 +776,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) ...@@ -776,7 +776,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
*/ */
blk = &state->path.blk[ state->path.active-1 ]; blk = &state->path.blk[ state->path.active-1 ];
info = blk->bp->data; info = blk->bp->data;
ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC); ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
node = (xfs_da_intnode_t *)info; node = (xfs_da_intnode_t *)info;
count = be16_to_cpu(node->hdr.count); count = be16_to_cpu(node->hdr.count);
if (count > (state->node_ents >> 1)) { if (count > (state->node_ents >> 1)) {
...@@ -836,7 +836,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) ...@@ -836,7 +836,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
count -= state->node_ents >> 2; count -= state->node_ents >> 2;
count -= be16_to_cpu(node->hdr.count); count -= be16_to_cpu(node->hdr.count);
node = bp->data; node = bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
count -= be16_to_cpu(node->hdr.count); count -= be16_to_cpu(node->hdr.count);
xfs_da_brelse(state->args->trans, bp); xfs_da_brelse(state->args->trans, bp);
if (count >= 0) if (count >= 0)
...@@ -911,7 +911,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) ...@@ -911,7 +911,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path)
} }
for (blk--, level--; level >= 0; blk--, level--) { for (blk--, level--; level >= 0; blk--, level--) {
node = blk->bp->data; node = blk->bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
btree = &node->btree[ blk->index ]; btree = &node->btree[ blk->index ];
if (be32_to_cpu(btree->hashval) == lasthash) if (be32_to_cpu(btree->hashval) == lasthash)
break; break;
...@@ -979,8 +979,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -979,8 +979,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
drop_node = drop_blk->bp->data; drop_node = drop_blk->bp->data;
save_node = save_blk->bp->data; save_node = save_blk->bp->data;
ASSERT(be16_to_cpu(drop_node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(drop_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
ASSERT(be16_to_cpu(save_node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(save_node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
tp = state->args->trans; tp = state->args->trans;
/* /*
...@@ -1278,8 +1278,8 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp) ...@@ -1278,8 +1278,8 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp)
node1 = node1_bp->data; node1 = node1_bp->data;
node2 = node2_bp->data; node2 = node2_bp->data;
ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) && ASSERT(node1->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC) &&
(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC)); node2->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) && if ((be16_to_cpu(node1->hdr.count) > 0) && (be16_to_cpu(node2->hdr.count) > 0) &&
((be32_to_cpu(node2->btree[0].hashval) < ((be32_to_cpu(node2->btree[0].hashval) <
be32_to_cpu(node1->btree[0].hashval)) || be32_to_cpu(node1->btree[0].hashval)) ||
...@@ -1299,7 +1299,7 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) ...@@ -1299,7 +1299,7 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count)
xfs_da_intnode_t *node; xfs_da_intnode_t *node;
node = bp->data; node = bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
if (count) if (count)
*count = be16_to_cpu(node->hdr.count); *count = be16_to_cpu(node->hdr.count);
if (!node->hdr.count) if (!node->hdr.count)
...@@ -1412,7 +1412,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, ...@@ -1412,7 +1412,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
for (blk = &path->blk[level]; level >= 0; blk--, level--) { for (blk = &path->blk[level]; level >= 0; blk--, level--) {
ASSERT(blk->bp != NULL); ASSERT(blk->bp != NULL);
node = blk->bp->data; node = blk->bp->data;
ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); ASSERT(node->hdr.info.magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) { if (forward && (blk->index < be16_to_cpu(node->hdr.count)-1)) {
blk->index++; blk->index++;
blkno = be32_to_cpu(node->btree[blk->index].before); blkno = be32_to_cpu(node->btree[blk->index].before);
...@@ -1451,9 +1451,9 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, ...@@ -1451,9 +1451,9 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path,
return(error); return(error);
ASSERT(blk->bp != NULL); ASSERT(blk->bp != NULL);
info = blk->bp->data; info = blk->bp->data;
ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC || ASSERT(info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC) ||
be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC || info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); info->magic == cpu_to_be16(XFS_ATTR_LEAF_MAGIC));
blk->magic = be16_to_cpu(info->magic); blk->magic = be16_to_cpu(info->magic);
if (blk->magic == XFS_DA_NODE_MAGIC) { if (blk->magic == XFS_DA_NODE_MAGIC) {
node = (xfs_da_intnode_t *)info; node = (xfs_da_intnode_t *)info;
...@@ -1704,12 +1704,12 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1704,12 +1704,12 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
/* /*
* Get values from the moved block. * Get values from the moved block.
*/ */
if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { if (dead_info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC)) {
dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; dead_leaf2 = (xfs_dir2_leaf_t *)dead_info;
dead_level = 0; dead_level = 0;
dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval); dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval);
} else { } else {
ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC); ASSERT(dead_info->magic == cpu_to_be16(XFS_DA_NODE_MAGIC));
dead_node = (xfs_da_intnode_t *)dead_info; dead_node = (xfs_da_intnode_t *)dead_info;
dead_level = be16_to_cpu(dead_node->hdr.level); dead_level = be16_to_cpu(dead_node->hdr.level);
dead_hash = be32_to_cpu(dead_node->btree[be16_to_cpu(dead_node->hdr.count) - 1].hashval); dead_hash = be32_to_cpu(dead_node->btree[be16_to_cpu(dead_node->hdr.count) - 1].hashval);
...@@ -1768,8 +1768,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1768,8 +1768,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w))) if ((error = xfs_da_read_buf(tp, ip, par_blkno, -1, &par_buf, w)))
goto done; goto done;
par_node = par_buf->data; par_node = par_buf->data;
if (unlikely( if (unlikely(par_node->hdr.info.magic !=
be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC || cpu_to_be16(XFS_DA_NODE_MAGIC) ||
(level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) { (level >= 0 && level != be16_to_cpu(par_node->hdr.level) + 1))) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
...@@ -1820,7 +1820,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1820,7 +1820,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
par_node = par_buf->data; par_node = par_buf->data;
if (unlikely( if (unlikely(
be16_to_cpu(par_node->hdr.level) != level || be16_to_cpu(par_node->hdr.level) != level ||
be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) { par_node->hdr.info.magic != cpu_to_be16(XFS_DA_NODE_MAGIC))) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = XFS_ERROR(EFSCORRUPTED);
...@@ -2093,7 +2093,7 @@ xfs_da_do_buf( ...@@ -2093,7 +2093,7 @@ xfs_da_do_buf(
(magic != XFS_DIR2_LEAFN_MAGIC) && (magic != XFS_DIR2_LEAFN_MAGIC) &&
(magic1 != XFS_DIR2_BLOCK_MAGIC) && (magic1 != XFS_DIR2_BLOCK_MAGIC) &&
(magic1 != XFS_DIR2_DATA_MAGIC) && (magic1 != XFS_DIR2_DATA_MAGIC) &&
(be32_to_cpu(free->hdr.magic) != XFS_DIR2_FREE_MAGIC), (free->hdr.magic != cpu_to_be32(XFS_DIR2_FREE_MAGIC)),
mp, XFS_ERRTAG_DA_READ_BUF, mp, XFS_ERRTAG_DA_READ_BUF,
XFS_RANDOM_DA_READ_BUF))) { XFS_RANDOM_DA_READ_BUF))) {
trace_xfs_da_btree_corrupt(rbp->bps[0], _RET_IP_); trace_xfs_da_btree_corrupt(rbp->bps[0], _RET_IP_);
......
...@@ -109,7 +109,7 @@ xfs_dir2_block_addname( ...@@ -109,7 +109,7 @@ xfs_dir2_block_addname(
/* /*
* Check the magic number, corrupted if wrong. * Check the magic number, corrupted if wrong.
*/ */
if (unlikely(be32_to_cpu(hdr->magic) != XFS_DIR2_BLOCK_MAGIC)) { if (unlikely(hdr->magic != cpu_to_be32(XFS_DIR2_BLOCK_MAGIC))) {
XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", XFS_CORRUPTION_ERROR("xfs_dir2_block_addname",
XFS_ERRLEVEL_LOW, mp, hdr); XFS_ERRLEVEL_LOW, mp, hdr);
xfs_da_brelse(tp, bp); xfs_da_brelse(tp, bp);
...@@ -255,7 +255,8 @@ xfs_dir2_block_addname( ...@@ -255,7 +255,8 @@ xfs_dir2_block_addname(
highstale = lfloghigh = -1; highstale = lfloghigh = -1;
fromidx >= 0; fromidx >= 0;
fromidx--) { fromidx--) {
if (be32_to_cpu(blp[fromidx].address) == XFS_DIR2_NULL_DATAPTR) { if (blp[fromidx].address ==
cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) {
if (highstale == -1) if (highstale == -1)
highstale = toidx; highstale = toidx;
else { else {
...@@ -352,12 +353,14 @@ xfs_dir2_block_addname( ...@@ -352,12 +353,14 @@ xfs_dir2_block_addname(
else { else {
for (lowstale = mid; for (lowstale = mid;
lowstale >= 0 && lowstale >= 0 &&
be32_to_cpu(blp[lowstale].address) != XFS_DIR2_NULL_DATAPTR; blp[lowstale].address !=
cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
lowstale--) lowstale--)
continue; continue;
for (highstale = mid + 1; for (highstale = mid + 1;
highstale < be32_to_cpu(btp->count) && highstale < be32_to_cpu(btp->count) &&
be32_to_cpu(blp[highstale].address) != XFS_DIR2_NULL_DATAPTR && blp[highstale].address !=
cpu_to_be32(XFS_DIR2_NULL_DATAPTR) &&
(lowstale < 0 || mid - lowstale > highstale - mid); (lowstale < 0 || mid - lowstale > highstale - mid);
highstale++) highstale++)
continue; continue;
...@@ -899,7 +902,7 @@ xfs_dir2_leaf_to_block( ...@@ -899,7 +902,7 @@ xfs_dir2_leaf_to_block(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
leaf = lbp->data; leaf = lbp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
/* /*
* If there are data blocks other than the first one, take this * If there are data blocks other than the first one, take this
...@@ -929,7 +932,7 @@ xfs_dir2_leaf_to_block( ...@@ -929,7 +932,7 @@ xfs_dir2_leaf_to_block(
goto out; goto out;
} }
hdr = dbp->data; hdr = dbp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
/* /*
* Size of the "leaf" area in the block. * Size of the "leaf" area in the block.
*/ */
...@@ -971,7 +974,8 @@ xfs_dir2_leaf_to_block( ...@@ -971,7 +974,8 @@ xfs_dir2_leaf_to_block(
*/ */
lep = xfs_dir2_block_leaf_p(btp); lep = xfs_dir2_block_leaf_p(btp);
for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) { for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) if (leaf->ents[from].address ==
cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
continue; continue;
lep[to++] = leaf->ents[from]; lep[to++] = leaf->ents[from];
} }
......
...@@ -73,7 +73,7 @@ xfs_dir2_data_check( ...@@ -73,7 +73,7 @@ xfs_dir2_data_check(
bf = hdr->bestfree; bf = hdr->bestfree;
p = (char *)(hdr + 1); p = (char *)(hdr + 1);
if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) {
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(mp, hdr);
lep = xfs_dir2_block_leaf_p(btp); lep = xfs_dir2_block_leaf_p(btp);
endp = (char *)lep; endp = (char *)lep;
...@@ -140,7 +140,7 @@ xfs_dir2_data_check( ...@@ -140,7 +140,7 @@ xfs_dir2_data_check(
(char *)dep - (char *)hdr); (char *)dep - (char *)hdr);
count++; count++;
lastfree = 0; lastfree = 0;
if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) {
addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk,
(xfs_dir2_data_aoff_t) (xfs_dir2_data_aoff_t)
((char *)dep - (char *)hdr)); ((char *)dep - (char *)hdr));
...@@ -160,9 +160,10 @@ xfs_dir2_data_check( ...@@ -160,9 +160,10 @@ xfs_dir2_data_check(
* Need to have seen all the entries and all the bestfree slots. * Need to have seen all the entries and all the bestfree slots.
*/ */
ASSERT(freeseen == 7); ASSERT(freeseen == 7);
if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) {
for (i = stale = 0; i < be32_to_cpu(btp->count); i++) { for (i = stale = 0; i < be32_to_cpu(btp->count); i++) {
if (be32_to_cpu(lep[i].address) == XFS_DIR2_NULL_DATAPTR) if (lep[i].address ==
cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
stale++; stale++;
if (i > 0) if (i > 0)
ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval)); ASSERT(be32_to_cpu(lep[i].hashval) >= be32_to_cpu(lep[i - 1].hashval));
...@@ -196,8 +197,8 @@ xfs_dir2_data_freefind( ...@@ -196,8 +197,8 @@ xfs_dir2_data_freefind(
* Check order, non-overlapping entries, and if we find the * Check order, non-overlapping entries, and if we find the
* one we're looking for it has to be exact. * one we're looking for it has to be exact.
*/ */
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
for (dfp = &hdr->bestfree[0], seenzero = matched = 0; for (dfp = &hdr->bestfree[0], seenzero = matched = 0;
dfp < &hdr->bestfree[XFS_DIR2_DATA_FD_COUNT]; dfp < &hdr->bestfree[XFS_DIR2_DATA_FD_COUNT];
dfp++) { dfp++) {
...@@ -256,8 +257,8 @@ xfs_dir2_data_freeinsert( ...@@ -256,8 +257,8 @@ xfs_dir2_data_freeinsert(
xfs_dir2_data_free_t new; /* new bestfree entry */ xfs_dir2_data_free_t new; /* new bestfree entry */
#ifdef __KERNEL__ #ifdef __KERNEL__
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
#endif #endif
dfp = hdr->bestfree; dfp = hdr->bestfree;
new.length = dup->length; new.length = dup->length;
...@@ -297,8 +298,8 @@ xfs_dir2_data_freeremove( ...@@ -297,8 +298,8 @@ xfs_dir2_data_freeremove(
int *loghead) /* out: log data header */ int *loghead) /* out: log data header */
{ {
#ifdef __KERNEL__ #ifdef __KERNEL__
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
#endif #endif
/* /*
* It's the first entry, slide the next 2 up. * It's the first entry, slide the next 2 up.
...@@ -341,8 +342,8 @@ xfs_dir2_data_freescan( ...@@ -341,8 +342,8 @@ xfs_dir2_data_freescan(
char *p; /* current entry pointer */ char *p; /* current entry pointer */
#ifdef __KERNEL__ #ifdef __KERNEL__
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
#endif #endif
/* /*
* Start by clearing the table. * Start by clearing the table.
...@@ -353,7 +354,7 @@ xfs_dir2_data_freescan( ...@@ -353,7 +354,7 @@ xfs_dir2_data_freescan(
* Set up pointers. * Set up pointers.
*/ */
p = (char *)(hdr + 1); p = (char *)(hdr + 1);
if (be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC) { if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC)) {
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(mp, hdr);
endp = (char *)xfs_dir2_block_leaf_p(btp); endp = (char *)xfs_dir2_block_leaf_p(btp);
} else } else
...@@ -458,8 +459,8 @@ xfs_dir2_data_log_entry( ...@@ -458,8 +459,8 @@ xfs_dir2_data_log_entry(
{ {
xfs_dir2_data_hdr_t *hdr = bp->data; xfs_dir2_data_hdr_t *hdr = bp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), xfs_da_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr),
(uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) - (uint)((char *)(xfs_dir2_data_entry_tag_p(dep) + 1) -
...@@ -476,8 +477,8 @@ xfs_dir2_data_log_header( ...@@ -476,8 +477,8 @@ xfs_dir2_data_log_header(
{ {
xfs_dir2_data_hdr_t *hdr = bp->data; xfs_dir2_data_hdr_t *hdr = bp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1); xfs_da_log_buf(tp, bp, 0, sizeof(*hdr) - 1);
} }
...@@ -493,8 +494,8 @@ xfs_dir2_data_log_unused( ...@@ -493,8 +494,8 @@ xfs_dir2_data_log_unused(
{ {
xfs_dir2_data_hdr_t *hdr = bp->data; xfs_dir2_data_hdr_t *hdr = bp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
/* /*
* Log the first part of the unused entry. * Log the first part of the unused entry.
...@@ -539,12 +540,12 @@ xfs_dir2_data_make_free( ...@@ -539,12 +540,12 @@ xfs_dir2_data_make_free(
/* /*
* Figure out where the end of the data area is. * Figure out where the end of the data area is.
*/ */
if (be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC) if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC))
endptr = (char *)hdr + mp->m_dirblksize; endptr = (char *)hdr + mp->m_dirblksize;
else { else {
xfs_dir2_block_tail_t *btp; /* block tail */ xfs_dir2_block_tail_t *btp; /* block tail */
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
btp = xfs_dir2_block_tail_p(mp, hdr); btp = xfs_dir2_block_tail_p(mp, hdr);
endptr = (char *)xfs_dir2_block_leaf_p(btp); endptr = (char *)xfs_dir2_block_leaf_p(btp);
} }
...@@ -717,8 +718,8 @@ xfs_dir2_data_use_free( ...@@ -717,8 +718,8 @@ xfs_dir2_data_use_free(
int oldlen; /* old unused entry's length */ int oldlen; /* old unused entry's length */
hdr = bp->data; hdr = bp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC || ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
be32_to_cpu(hdr->magic) == XFS_DIR2_BLOCK_MAGIC); hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC));
ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG); ASSERT(be16_to_cpu(dup->freetag) == XFS_DIR2_DATA_FREE_TAG);
ASSERT(offset >= (char *)dup - (char *)hdr); ASSERT(offset >= (char *)dup - (char *)hdr);
ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)hdr); ASSERT(offset + len <= (char *)dup + be16_to_cpu(dup->length) - (char *)hdr);
......
...@@ -201,8 +201,8 @@ xfs_dir2_leaf_find_entry( ...@@ -201,8 +201,8 @@ xfs_dir2_leaf_find_entry(
*/ */
for (lowstale = index - 1; for (lowstale = index - 1;
lowstale >= 0 && lowstale >= 0 &&
be32_to_cpu(leaf->ents[lowstale].address) != leaf->ents[lowstale].address !=
XFS_DIR2_NULL_DATAPTR; cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
lowstale--) lowstale--)
continue; continue;
...@@ -213,8 +213,8 @@ xfs_dir2_leaf_find_entry( ...@@ -213,8 +213,8 @@ xfs_dir2_leaf_find_entry(
*/ */
for (highstale = index; for (highstale = index;
highstale < be16_to_cpu(leaf->hdr.count) && highstale < be16_to_cpu(leaf->hdr.count) &&
be32_to_cpu(leaf->ents[highstale].address) != leaf->ents[highstale].address !=
XFS_DIR2_NULL_DATAPTR && cpu_to_be32(XFS_DIR2_NULL_DATAPTR) &&
(lowstale < 0 || (lowstale < 0 ||
index - lowstale - 1 >= highstale - index); index - lowstale - 1 >= highstale - index);
highstale++) highstale++)
...@@ -228,8 +228,8 @@ xfs_dir2_leaf_find_entry( ...@@ -228,8 +228,8 @@ xfs_dir2_leaf_find_entry(
(highstale == be16_to_cpu(leaf->hdr.count) || (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale - 1 < highstale - index)) { index - lowstale - 1 < highstale - index)) {
ASSERT(index - lowstale - 1 >= 0); ASSERT(index - lowstale - 1 >= 0);
ASSERT(be32_to_cpu(leaf->ents[lowstale].address) == ASSERT(leaf->ents[lowstale].address ==
XFS_DIR2_NULL_DATAPTR); cpu_to_be32(XFS_DIR2_NULL_DATAPTR));
/* /*
* Copy entries up to cover the stale entry and make room * Copy entries up to cover the stale entry and make room
...@@ -251,8 +251,8 @@ xfs_dir2_leaf_find_entry( ...@@ -251,8 +251,8 @@ xfs_dir2_leaf_find_entry(
* The high one is better, so use that one. * The high one is better, so use that one.
*/ */
ASSERT(highstale - index >= 0); ASSERT(highstale - index >= 0);
ASSERT(be32_to_cpu(leaf->ents[highstale].address) == ASSERT(leaf->ents[highstale].address ==
XFS_DIR2_NULL_DATAPTR); cpu_to_be32(XFS_DIR2_NULL_DATAPTR));
/* /*
* Copy entries down to cover the stale entry and make room for the * Copy entries down to cover the stale entry and make room for the
...@@ -342,7 +342,7 @@ xfs_dir2_leaf_addname( ...@@ -342,7 +342,7 @@ xfs_dir2_leaf_addname(
continue; continue;
i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address));
ASSERT(i < be32_to_cpu(ltp->bestcount)); ASSERT(i < be32_to_cpu(ltp->bestcount));
ASSERT(be16_to_cpu(bestsp[i]) != NULLDATAOFF); ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF));
if (be16_to_cpu(bestsp[i]) >= length) { if (be16_to_cpu(bestsp[i]) >= length) {
use_block = i; use_block = i;
break; break;
...@@ -356,7 +356,8 @@ xfs_dir2_leaf_addname( ...@@ -356,7 +356,8 @@ xfs_dir2_leaf_addname(
/* /*
* Remember a block we see that's missing. * Remember a block we see that's missing.
*/ */
if (be16_to_cpu(bestsp[i]) == NULLDATAOFF && use_block == -1) if (bestsp[i] == cpu_to_be16(NULLDATAOFF) &&
use_block == -1)
use_block = i; use_block = i;
else if (be16_to_cpu(bestsp[i]) >= length) { else if (be16_to_cpu(bestsp[i]) >= length) {
use_block = i; use_block = i;
...@@ -377,7 +378,7 @@ xfs_dir2_leaf_addname( ...@@ -377,7 +378,7 @@ xfs_dir2_leaf_addname(
* Now kill use_block if it refers to a missing block, so we * Now kill use_block if it refers to a missing block, so we
* can use it as an indication of allocation needed. * can use it as an indication of allocation needed.
*/ */
if (use_block != -1 && be16_to_cpu(bestsp[use_block]) == NULLDATAOFF) if (use_block != -1 && bestsp[use_block] == cpu_to_be16(NULLDATAOFF))
use_block = -1; use_block = -1;
/* /*
* If we don't have enough free bytes but we can make enough * If we don't have enough free bytes but we can make enough
...@@ -590,7 +591,7 @@ xfs_dir2_leaf_check( ...@@ -590,7 +591,7 @@ xfs_dir2_leaf_check(
leaf = bp->data; leaf = bp->data;
mp = dp->i_mount; mp = dp->i_mount;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
/* /*
* This value is not restrictive enough. * This value is not restrictive enough.
* Should factor in the size of the bests table as well. * Should factor in the size of the bests table as well.
...@@ -610,7 +611,7 @@ xfs_dir2_leaf_check( ...@@ -610,7 +611,7 @@ xfs_dir2_leaf_check(
if (i + 1 < be16_to_cpu(leaf->hdr.count)) if (i + 1 < be16_to_cpu(leaf->hdr.count))
ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
be32_to_cpu(leaf->ents[i + 1].hashval)); be32_to_cpu(leaf->ents[i + 1].hashval));
if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) if (leaf->ents[i].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
stale++; stale++;
} }
ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
...@@ -639,7 +640,8 @@ xfs_dir2_leaf_compact( ...@@ -639,7 +640,8 @@ xfs_dir2_leaf_compact(
* Compress out the stale entries in place. * Compress out the stale entries in place.
*/ */
for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) { for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) {
if (be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) if (leaf->ents[from].address ==
cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
continue; continue;
/* /*
* Only actually copy the entries that are different. * Only actually copy the entries that are different.
...@@ -696,7 +698,8 @@ xfs_dir2_leaf_compact_x1( ...@@ -696,7 +698,8 @@ xfs_dir2_leaf_compact_x1(
*/ */
for (lowstale = index - 1; for (lowstale = index - 1;
lowstale >= 0 && lowstale >= 0 &&
be32_to_cpu(leaf->ents[lowstale].address) != XFS_DIR2_NULL_DATAPTR; leaf->ents[lowstale].address !=
cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
lowstale--) lowstale--)
continue; continue;
/* /*
...@@ -705,7 +708,8 @@ xfs_dir2_leaf_compact_x1( ...@@ -705,7 +708,8 @@ xfs_dir2_leaf_compact_x1(
*/ */
for (highstale = index; for (highstale = index;
highstale < be16_to_cpu(leaf->hdr.count) && highstale < be16_to_cpu(leaf->hdr.count) &&
be32_to_cpu(leaf->ents[highstale].address) != XFS_DIR2_NULL_DATAPTR && leaf->ents[highstale].address !=
cpu_to_be32(XFS_DIR2_NULL_DATAPTR) &&
(lowstale < 0 || index - lowstale > highstale - index); (lowstale < 0 || index - lowstale > highstale - index);
highstale++) highstale++)
continue; continue;
...@@ -729,7 +733,8 @@ xfs_dir2_leaf_compact_x1( ...@@ -729,7 +733,8 @@ xfs_dir2_leaf_compact_x1(
if (index == from) if (index == from)
newindex = to; newindex = to;
if (from != keepstale && if (from != keepstale &&
be32_to_cpu(leaf->ents[from].address) == XFS_DIR2_NULL_DATAPTR) { leaf->ents[from].address ==
cpu_to_be32(XFS_DIR2_NULL_DATAPTR)) {
if (from == to) if (from == to)
*lowlogp = to; *lowlogp = to;
continue; continue;
...@@ -1207,7 +1212,7 @@ xfs_dir2_leaf_log_bests( ...@@ -1207,7 +1212,7 @@ xfs_dir2_leaf_log_bests(
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf); ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf);
firstb = xfs_dir2_leaf_bests_p(ltp) + first; firstb = xfs_dir2_leaf_bests_p(ltp) + first;
lastb = xfs_dir2_leaf_bests_p(ltp) + last; lastb = xfs_dir2_leaf_bests_p(ltp) + last;
...@@ -1230,8 +1235,8 @@ xfs_dir2_leaf_log_ents( ...@@ -1230,8 +1235,8 @@ xfs_dir2_leaf_log_ents(
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
firstlep = &leaf->ents[first]; firstlep = &leaf->ents[first];
lastlep = &leaf->ents[last]; lastlep = &leaf->ents[last];
xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
...@@ -1249,8 +1254,8 @@ xfs_dir2_leaf_log_header( ...@@ -1249,8 +1254,8 @@ xfs_dir2_leaf_log_header(
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
(uint)(sizeof(leaf->hdr) - 1)); (uint)(sizeof(leaf->hdr) - 1));
} }
...@@ -1269,7 +1274,7 @@ xfs_dir2_leaf_log_tail( ...@@ -1269,7 +1274,7 @@ xfs_dir2_leaf_log_tail(
mp = tp->t_mountp; mp = tp->t_mountp;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC));
ltp = xfs_dir2_leaf_tail_p(mp, leaf); ltp = xfs_dir2_leaf_tail_p(mp, leaf);
xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
(uint)(mp->m_dirblksize - 1)); (uint)(mp->m_dirblksize - 1));
...@@ -1570,7 +1575,7 @@ xfs_dir2_leaf_removename( ...@@ -1570,7 +1575,7 @@ xfs_dir2_leaf_removename(
* Look for the last active entry (i). * Look for the last active entry (i).
*/ */
for (i = db - 1; i > 0; i--) { for (i = db - 1; i > 0; i--) {
if (be16_to_cpu(bestsp[i]) != NULLDATAOFF) if (bestsp[i] != cpu_to_be16(NULLDATAOFF))
break; break;
} }
/* /*
...@@ -1740,7 +1745,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1740,7 +1745,7 @@ xfs_dir2_leaf_trim_data(
{ {
struct xfs_dir2_data_hdr *hdr = dbp->data; struct xfs_dir2_data_hdr *hdr = dbp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
ASSERT(be16_to_cpu(hdr->bestfree[0].length) == ASSERT(be16_to_cpu(hdr->bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(*hdr)); mp->m_dirblksize - (uint)sizeof(*hdr));
ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
...@@ -1850,7 +1855,7 @@ xfs_dir2_node_to_leaf( ...@@ -1850,7 +1855,7 @@ xfs_dir2_node_to_leaf(
return 0; return 0;
lbp = state->path.blk[0].bp; lbp = state->path.blk[0].bp;
leaf = lbp->data; leaf = lbp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
/* /*
* Read the freespace block. * Read the freespace block.
*/ */
...@@ -1859,7 +1864,7 @@ xfs_dir2_node_to_leaf( ...@@ -1859,7 +1864,7 @@ xfs_dir2_node_to_leaf(
return error; return error;
} }
free = fbp->data; free = fbp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
ASSERT(!free->hdr.firstdb); ASSERT(!free->hdr.firstdb);
/* /*
......
...@@ -73,7 +73,7 @@ xfs_dir2_free_log_bests( ...@@ -73,7 +73,7 @@ xfs_dir2_free_log_bests(
xfs_dir2_free_t *free; /* freespace structure */ xfs_dir2_free_t *free; /* freespace structure */
free = bp->data; free = bp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
xfs_da_log_buf(tp, bp, xfs_da_log_buf(tp, bp,
(uint)((char *)&free->bests[first] - (char *)free), (uint)((char *)&free->bests[first] - (char *)free),
(uint)((char *)&free->bests[last] - (char *)free + (uint)((char *)&free->bests[last] - (char *)free +
...@@ -91,7 +91,7 @@ xfs_dir2_free_log_header( ...@@ -91,7 +91,7 @@ xfs_dir2_free_log_header(
xfs_dir2_free_t *free; /* freespace structure */ xfs_dir2_free_t *free; /* freespace structure */
free = bp->data; free = bp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free), xfs_da_log_buf(tp, bp, (uint)((char *)&free->hdr - (char *)free),
(uint)(sizeof(xfs_dir2_free_hdr_t) - 1)); (uint)(sizeof(xfs_dir2_free_hdr_t) - 1));
} }
...@@ -276,14 +276,14 @@ xfs_dir2_leafn_check( ...@@ -276,14 +276,14 @@ xfs_dir2_leafn_check(
leaf = bp->data; leaf = bp->data;
mp = dp->i_mount; mp = dp->i_mount;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp)); ASSERT(be16_to_cpu(leaf->hdr.count) <= xfs_dir2_max_leaf_ents(mp));
for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
if (i + 1 < be16_to_cpu(leaf->hdr.count)) { if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
ASSERT(be32_to_cpu(leaf->ents[i].hashval) <= ASSERT(be32_to_cpu(leaf->ents[i].hashval) <=
be32_to_cpu(leaf->ents[i + 1].hashval)); be32_to_cpu(leaf->ents[i + 1].hashval));
} }
if (be32_to_cpu(leaf->ents[i].address) == XFS_DIR2_NULL_DATAPTR) if (leaf->ents[i].address == cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
stale++; stale++;
} }
ASSERT(be16_to_cpu(leaf->hdr.stale) == stale); ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
...@@ -302,7 +302,7 @@ xfs_dir2_leafn_lasthash( ...@@ -302,7 +302,7 @@ xfs_dir2_leafn_lasthash(
xfs_dir2_leaf_t *leaf; /* leaf structure */ xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
if (count) if (count)
*count = be16_to_cpu(leaf->hdr.count); *count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count) if (!leaf->hdr.count)
...@@ -341,7 +341,7 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -341,7 +341,7 @@ xfs_dir2_leafn_lookup_for_addname(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
#ifdef __KERNEL__ #ifdef __KERNEL__
ASSERT(be16_to_cpu(leaf->hdr.count) > 0); ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
#endif #endif
...@@ -358,7 +358,7 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -358,7 +358,7 @@ xfs_dir2_leafn_lookup_for_addname(
curbp = state->extrablk.bp; curbp = state->extrablk.bp;
curfdb = state->extrablk.blkno; curfdb = state->extrablk.blkno;
free = curbp->data; free = curbp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
} }
length = xfs_dir2_data_entsize(args->namelen); length = xfs_dir2_data_entsize(args->namelen);
/* /*
...@@ -424,7 +424,8 @@ xfs_dir2_leafn_lookup_for_addname( ...@@ -424,7 +424,8 @@ xfs_dir2_leafn_lookup_for_addname(
/* /*
* If it has room, return it. * If it has room, return it.
*/ */
if (unlikely(be16_to_cpu(free->bests[fi]) == NULLDATAOFF)) { if (unlikely(free->bests[fi] ==
cpu_to_be16(NULLDATAOFF))) {
XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int", XFS_ERROR_REPORT("xfs_dir2_leafn_lookup_int",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
if (curfdb != newfdb) if (curfdb != newfdb)
...@@ -485,7 +486,7 @@ xfs_dir2_leafn_lookup_for_entry( ...@@ -485,7 +486,7 @@ xfs_dir2_leafn_lookup_for_entry(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
#ifdef __KERNEL__ #ifdef __KERNEL__
ASSERT(be16_to_cpu(leaf->hdr.count) > 0); ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
#endif #endif
...@@ -666,7 +667,8 @@ xfs_dir2_leafn_moveents( ...@@ -666,7 +667,8 @@ xfs_dir2_leafn_moveents(
int i; /* temp leaf index */ int i; /* temp leaf index */
for (i = start_s, stale = 0; i < start_s + count; i++) { for (i = start_s, stale = 0; i < start_s + count; i++) {
if (be32_to_cpu(leaf_s->ents[i].address) == XFS_DIR2_NULL_DATAPTR) if (leaf_s->ents[i].address ==
cpu_to_be32(XFS_DIR2_NULL_DATAPTR))
stale++; stale++;
} }
} else } else
...@@ -713,8 +715,8 @@ xfs_dir2_leafn_order( ...@@ -713,8 +715,8 @@ xfs_dir2_leafn_order(
leaf1 = leaf1_bp->data; leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data; leaf2 = leaf2_bp->data;
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf1->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf2->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
if (be16_to_cpu(leaf1->hdr.count) > 0 && if (be16_to_cpu(leaf1->hdr.count) > 0 &&
be16_to_cpu(leaf2->hdr.count) > 0 && be16_to_cpu(leaf2->hdr.count) > 0 &&
(be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) || (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) ||
...@@ -862,7 +864,7 @@ xfs_dir2_leafn_remove( ...@@ -862,7 +864,7 @@ xfs_dir2_leafn_remove(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
/* /*
* Point to the entry we're removing. * Point to the entry we're removing.
*/ */
...@@ -924,7 +926,7 @@ xfs_dir2_leafn_remove( ...@@ -924,7 +926,7 @@ xfs_dir2_leafn_remove(
return error; return error;
} }
free = fbp->data; free = fbp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
ASSERT(be32_to_cpu(free->hdr.firstdb) == ASSERT(be32_to_cpu(free->hdr.firstdb) ==
XFS_DIR2_MAX_FREE_BESTS(mp) * XFS_DIR2_MAX_FREE_BESTS(mp) *
(fdb - XFS_DIR2_FREE_FIRSTDB(mp))); (fdb - XFS_DIR2_FREE_FIRSTDB(mp)));
...@@ -976,7 +978,8 @@ xfs_dir2_leafn_remove( ...@@ -976,7 +978,8 @@ xfs_dir2_leafn_remove(
int i; /* free entry index */ int i; /* free entry index */
for (i = findex - 1; for (i = findex - 1;
i >= 0 && be16_to_cpu(free->bests[i]) == NULLDATAOFF; i >= 0 &&
free->bests[i] == cpu_to_be16(NULLDATAOFF);
i--) i--)
continue; continue;
free->hdr.nvalid = cpu_to_be32(i + 1); free->hdr.nvalid = cpu_to_be32(i + 1);
...@@ -1133,7 +1136,7 @@ xfs_dir2_leafn_toosmall( ...@@ -1133,7 +1136,7 @@ xfs_dir2_leafn_toosmall(
*/ */
blk = &state->path.blk[state->path.active - 1]; blk = &state->path.blk[state->path.active - 1];
info = blk->bp->data; info = blk->bp->data;
ASSERT(be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(info->magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
leaf = (xfs_dir2_leaf_t *)info; leaf = (xfs_dir2_leaf_t *)info;
count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]);
...@@ -1192,7 +1195,7 @@ xfs_dir2_leafn_toosmall( ...@@ -1192,7 +1195,7 @@ xfs_dir2_leafn_toosmall(
count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes = state->blocksize - (state->blocksize >> 2); bytes = state->blocksize - (state->blocksize >> 2);
leaf = bp->data; leaf = bp->data;
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes -= count * (uint)sizeof(leaf->ents[0]); bytes -= count * (uint)sizeof(leaf->ents[0]);
/* /*
...@@ -1251,8 +1254,8 @@ xfs_dir2_leafn_unbalance( ...@@ -1251,8 +1254,8 @@ xfs_dir2_leafn_unbalance(
ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
drop_leaf = drop_blk->bp->data; drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data; save_leaf = save_blk->bp->data;
ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(drop_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); ASSERT(save_leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC));
/* /*
* If there are any stale leaf entries, take this opportunity * If there are any stale leaf entries, take this opportunity
* to purge them. * to purge them.
...@@ -1393,7 +1396,7 @@ xfs_dir2_node_addname_int( ...@@ -1393,7 +1396,7 @@ xfs_dir2_node_addname_int(
*/ */
ifbno = fblk->blkno; ifbno = fblk->blkno;
free = fbp->data; free = fbp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
findex = fblk->index; findex = fblk->index;
/* /*
* This means the free entry showed that the data block had * This means the free entry showed that the data block had
...@@ -1477,7 +1480,7 @@ xfs_dir2_node_addname_int( ...@@ -1477,7 +1480,7 @@ xfs_dir2_node_addname_int(
continue; continue;
} }
free = fbp->data; free = fbp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
findex = 0; findex = 0;
} }
/* /*
...@@ -1609,7 +1612,7 @@ xfs_dir2_node_addname_int( ...@@ -1609,7 +1612,7 @@ xfs_dir2_node_addname_int(
free->hdr.nused = 0; free->hdr.nused = 0;
} else { } else {
free = fbp->data; free = fbp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
} }
/* /*
...@@ -1632,7 +1635,7 @@ xfs_dir2_node_addname_int( ...@@ -1632,7 +1635,7 @@ xfs_dir2_node_addname_int(
* If this entry was for an empty data block * If this entry was for an empty data block
* (this should always be true) then update the header. * (this should always be true) then update the header.
*/ */
if (be16_to_cpu(free->bests[findex]) == NULLDATAOFF) { if (free->bests[findex] == cpu_to_be16(NULLDATAOFF)) {
be32_add_cpu(&free->hdr.nused, 1); be32_add_cpu(&free->hdr.nused, 1);
xfs_dir2_free_log_header(tp, fbp); xfs_dir2_free_log_header(tp, fbp);
} }
...@@ -1902,7 +1905,7 @@ xfs_dir2_node_replace( ...@@ -1902,7 +1905,7 @@ xfs_dir2_node_replace(
* Point to the data entry. * Point to the data entry.
*/ */
hdr = state->extrablk.bp->data; hdr = state->extrablk.bp->data;
ASSERT(be32_to_cpu(hdr->magic) == XFS_DIR2_DATA_MAGIC); ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC));
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)hdr + ((char *)hdr +
xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address)));
...@@ -1968,7 +1971,7 @@ xfs_dir2_node_trim_free( ...@@ -1968,7 +1971,7 @@ xfs_dir2_node_trim_free(
return 0; return 0;
} }
free = bp->data; free = bp->data;
ASSERT(be32_to_cpu(free->hdr.magic) == XFS_DIR2_FREE_MAGIC); ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC));
/* /*
* If there are used entries, there's nothing to do. * If there are used entries, there's nothing to do.
*/ */
......
...@@ -683,7 +683,7 @@ xfs_dialloc( ...@@ -683,7 +683,7 @@ xfs_dialloc(
return 0; return 0;
} }
agi = XFS_BUF_TO_AGI(agbp); agi = XFS_BUF_TO_AGI(agbp);
ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
} else { } else {
/* /*
* Continue where we left off before. In this case, we * Continue where we left off before. In this case, we
...@@ -691,7 +691,7 @@ xfs_dialloc( ...@@ -691,7 +691,7 @@ xfs_dialloc(
*/ */
agbp = *IO_agbp; agbp = *IO_agbp;
agi = XFS_BUF_TO_AGI(agbp); agi = XFS_BUF_TO_AGI(agbp);
ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
ASSERT(be32_to_cpu(agi->agi_freecount) > 0); ASSERT(be32_to_cpu(agi->agi_freecount) > 0);
} }
mp = tp->t_mountp; mp = tp->t_mountp;
...@@ -775,7 +775,7 @@ xfs_dialloc( ...@@ -775,7 +775,7 @@ xfs_dialloc(
if (error) if (error)
goto nextag; goto nextag;
agi = XFS_BUF_TO_AGI(agbp); agi = XFS_BUF_TO_AGI(agbp);
ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
} }
/* /*
* Here with an allocation group that has a free inode. * Here with an allocation group that has a free inode.
...@@ -944,7 +944,7 @@ xfs_dialloc( ...@@ -944,7 +944,7 @@ xfs_dialloc(
* See if the most recently allocated block has any free. * See if the most recently allocated block has any free.
*/ */
newino: newino:
if (be32_to_cpu(agi->agi_newino) != NULLAGINO) { if (agi->agi_newino != cpu_to_be32(NULLAGINO)) {
error = xfs_inobt_lookup(cur, be32_to_cpu(agi->agi_newino), error = xfs_inobt_lookup(cur, be32_to_cpu(agi->agi_newino),
XFS_LOOKUP_EQ, &i); XFS_LOOKUP_EQ, &i);
if (error) if (error)
...@@ -1085,7 +1085,7 @@ xfs_difree( ...@@ -1085,7 +1085,7 @@ xfs_difree(
return error; return error;
} }
agi = XFS_BUF_TO_AGI(agbp); agi = XFS_BUF_TO_AGI(agbp);
ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
ASSERT(agbno < be32_to_cpu(agi->agi_length)); ASSERT(agbno < be32_to_cpu(agi->agi_length));
/* /*
* Initialize the cursor. * Initialize the cursor.
...@@ -1438,7 +1438,7 @@ xfs_ialloc_log_agi( ...@@ -1438,7 +1438,7 @@ xfs_ialloc_log_agi(
xfs_agi_t *agi; /* allocation group header */ xfs_agi_t *agi; /* allocation group header */
agi = XFS_BUF_TO_AGI(bp); agi = XFS_BUF_TO_AGI(bp);
ASSERT(be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC); ASSERT(agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC));
#endif #endif
/* /*
* Compute byte offsets for the first and last fields. * Compute byte offsets for the first and last fields.
...@@ -1492,7 +1492,7 @@ xfs_read_agi( ...@@ -1492,7 +1492,7 @@ xfs_read_agi(
/* /*
* Validate the magic number of the agi block. * Validate the magic number of the agi block.
*/ */
agi_ok = be32_to_cpu(agi->agi_magicnum) == XFS_AGI_MAGIC && agi_ok = agi->agi_magicnum == cpu_to_be32(XFS_AGI_MAGIC) &&
XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)) && XFS_AGI_GOOD_VERSION(be32_to_cpu(agi->agi_versionnum)) &&
be32_to_cpu(agi->agi_seqno) == agno; be32_to_cpu(agi->agi_seqno) == agno;
if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI, if (unlikely(XFS_TEST_ERROR(!agi_ok, mp, XFS_ERRTAG_IALLOC_READ_AGI,
......
...@@ -167,7 +167,7 @@ xfs_imap_to_bp( ...@@ -167,7 +167,7 @@ xfs_imap_to_bp(
dip = (xfs_dinode_t *)xfs_buf_offset(bp, dip = (xfs_dinode_t *)xfs_buf_offset(bp,
(i << mp->m_sb.sb_inodelog)); (i << mp->m_sb.sb_inodelog));
di_ok = be16_to_cpu(dip->di_magic) == XFS_DINODE_MAGIC && di_ok = dip->di_magic == cpu_to_be16(XFS_DINODE_MAGIC) &&
XFS_DINODE_GOOD_VERSION(dip->di_version); XFS_DINODE_GOOD_VERSION(dip->di_version);
if (unlikely(XFS_TEST_ERROR(!di_ok, mp, if (unlikely(XFS_TEST_ERROR(!di_ok, mp,
XFS_ERRTAG_ITOBP_INOTOBP, XFS_ERRTAG_ITOBP_INOTOBP,
...@@ -802,7 +802,7 @@ xfs_iread( ...@@ -802,7 +802,7 @@ xfs_iread(
* If we got something that isn't an inode it means someone * If we got something that isn't an inode it means someone
* (nfs or dmi) has a stale handle. * (nfs or dmi) has a stale handle.
*/ */
if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC) { if (dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC)) {
#ifdef DEBUG #ifdef DEBUG
xfs_alert(mp, xfs_alert(mp,
"%s: dip->di_magic (0x%x) != XFS_DINODE_MAGIC (0x%x)", "%s: dip->di_magic (0x%x) != XFS_DINODE_MAGIC (0x%x)",
...@@ -1457,7 +1457,7 @@ xfs_iunlink( ...@@ -1457,7 +1457,7 @@ xfs_iunlink(
ASSERT(agi->agi_unlinked[bucket_index]); ASSERT(agi->agi_unlinked[bucket_index]);
ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino); ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != agino);
if (be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO) { if (agi->agi_unlinked[bucket_index] != cpu_to_be32(NULLAGINO)) {
/* /*
* There is already another inode in the bucket we need * There is already another inode in the bucket we need
* to add ourselves to. Add us at the front of the list. * to add ourselves to. Add us at the front of the list.
...@@ -1468,8 +1468,7 @@ xfs_iunlink( ...@@ -1468,8 +1468,7 @@ xfs_iunlink(
if (error) if (error)
return error; return error;
ASSERT(be32_to_cpu(dip->di_next_unlinked) == NULLAGINO); ASSERT(dip->di_next_unlinked == cpu_to_be32(NULLAGINO));
/* both on-disk, don't endian flip twice */
dip->di_next_unlinked = agi->agi_unlinked[bucket_index]; dip->di_next_unlinked = agi->agi_unlinked[bucket_index];
offset = ip->i_imap.im_boffset + offset = ip->i_imap.im_boffset +
offsetof(xfs_dinode_t, di_next_unlinked); offsetof(xfs_dinode_t, di_next_unlinked);
...@@ -1534,7 +1533,7 @@ xfs_iunlink_remove( ...@@ -1534,7 +1533,7 @@ xfs_iunlink_remove(
agino = XFS_INO_TO_AGINO(mp, ip->i_ino); agino = XFS_INO_TO_AGINO(mp, ip->i_ino);
ASSERT(agino != 0); ASSERT(agino != 0);
bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS; bucket_index = agino % XFS_AGI_UNLINKED_BUCKETS;
ASSERT(be32_to_cpu(agi->agi_unlinked[bucket_index]) != NULLAGINO); ASSERT(agi->agi_unlinked[bucket_index] != cpu_to_be32(NULLAGINO));
ASSERT(agi->agi_unlinked[bucket_index]); ASSERT(agi->agi_unlinked[bucket_index]);
if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) { if (be32_to_cpu(agi->agi_unlinked[bucket_index]) == agino) {
...@@ -2659,7 +2658,7 @@ xfs_iflush_int( ...@@ -2659,7 +2658,7 @@ xfs_iflush_int(
*/ */
xfs_synchronize_times(ip); xfs_synchronize_times(ip);
if (XFS_TEST_ERROR(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC, if (XFS_TEST_ERROR(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC),
mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) { mp, XFS_ERRTAG_IFLUSH_1, XFS_RANDOM_IFLUSH_1)) {
xfs_alert_tag(mp, XFS_PTAG_IFLUSH, xfs_alert_tag(mp, XFS_PTAG_IFLUSH,
"%s: Bad inode %Lu magic number 0x%x, ptr 0x%p", "%s: Bad inode %Lu magic number 0x%x, ptr 0x%p",
......
...@@ -3521,13 +3521,13 @@ xlog_verify_iclog(xlog_t *log, ...@@ -3521,13 +3521,13 @@ xlog_verify_iclog(xlog_t *log,
spin_unlock(&log->l_icloglock); spin_unlock(&log->l_icloglock);
/* check log magic numbers */ /* check log magic numbers */
if (be32_to_cpu(iclog->ic_header.h_magicno) != XLOG_HEADER_MAGIC_NUM) if (iclog->ic_header.h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))
xfs_emerg(log->l_mp, "%s: invalid magic num", __func__); xfs_emerg(log->l_mp, "%s: invalid magic num", __func__);
ptr = (xfs_caddr_t) &iclog->ic_header; ptr = (xfs_caddr_t) &iclog->ic_header;
for (ptr += BBSIZE; ptr < ((xfs_caddr_t)&iclog->ic_header) + count; for (ptr += BBSIZE; ptr < ((xfs_caddr_t)&iclog->ic_header) + count;
ptr += BBSIZE) { ptr += BBSIZE) {
if (be32_to_cpu(*(__be32 *)ptr) == XLOG_HEADER_MAGIC_NUM) if (*(__be32 *)ptr == cpu_to_be32(XLOG_HEADER_MAGIC_NUM))
xfs_emerg(log->l_mp, "%s: unexpected magic num", xfs_emerg(log->l_mp, "%s: unexpected magic num",
__func__); __func__);
} }
......
...@@ -300,14 +300,14 @@ xlog_header_check_recover( ...@@ -300,14 +300,14 @@ xlog_header_check_recover(
xfs_mount_t *mp, xfs_mount_t *mp,
xlog_rec_header_t *head) xlog_rec_header_t *head)
{ {
ASSERT(be32_to_cpu(head->h_magicno) == XLOG_HEADER_MAGIC_NUM); ASSERT(head->h_magicno == cpu_to_be32(XLOG_HEADER_MAGIC_NUM));
/* /*
* IRIX doesn't write the h_fmt field and leaves it zeroed * IRIX doesn't write the h_fmt field and leaves it zeroed
* (XLOG_FMT_UNKNOWN). This stops us from trying to recover * (XLOG_FMT_UNKNOWN). This stops us from trying to recover
* a dirty log created in IRIX. * a dirty log created in IRIX.
*/ */
if (unlikely(be32_to_cpu(head->h_fmt) != XLOG_FMT)) { if (unlikely(head->h_fmt != cpu_to_be32(XLOG_FMT))) {
xfs_warn(mp, xfs_warn(mp,
"dirty log written in incompatible format - can't recover"); "dirty log written in incompatible format - can't recover");
xlog_header_check_dump(mp, head); xlog_header_check_dump(mp, head);
...@@ -333,7 +333,7 @@ xlog_header_check_mount( ...@@ -333,7 +333,7 @@ xlog_header_check_mount(
xfs_mount_t *mp, xfs_mount_t *mp,
xlog_rec_header_t *head) xlog_rec_header_t *head)
{ {
ASSERT(be32_to_cpu(head->h_magicno) == XLOG_HEADER_MAGIC_NUM); ASSERT(head->h_magicno == cpu_to_be32(XLOG_HEADER_MAGIC_NUM));
if (uuid_is_nil(&head->h_fs_uuid)) { if (uuid_is_nil(&head->h_fs_uuid)) {
/* /*
...@@ -534,7 +534,7 @@ xlog_find_verify_log_record( ...@@ -534,7 +534,7 @@ xlog_find_verify_log_record(
head = (xlog_rec_header_t *)offset; head = (xlog_rec_header_t *)offset;
if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(head->h_magicno)) if (head->h_magicno == cpu_to_be32(XLOG_HEADER_MAGIC_NUM))
break; break;
if (!smallmem) if (!smallmem)
...@@ -916,7 +916,7 @@ xlog_find_tail( ...@@ -916,7 +916,7 @@ xlog_find_tail(
if (error) if (error)
goto done; goto done;
if (XLOG_HEADER_MAGIC_NUM == be32_to_cpu(*(__be32 *)offset)) { if (*(__be32 *)offset == cpu_to_be32(XLOG_HEADER_MAGIC_NUM)) {
found = 1; found = 1;
break; break;
} }
...@@ -933,8 +933,8 @@ xlog_find_tail( ...@@ -933,8 +933,8 @@ xlog_find_tail(
if (error) if (error)
goto done; goto done;
if (XLOG_HEADER_MAGIC_NUM == if (*(__be32 *)offset ==
be32_to_cpu(*(__be32 *)offset)) { cpu_to_be32(XLOG_HEADER_MAGIC_NUM)) {
found = 2; found = 2;
break; break;
} }
...@@ -1947,7 +1947,7 @@ xfs_qm_dqcheck( ...@@ -1947,7 +1947,7 @@ xfs_qm_dqcheck(
* This is all fine; things are still consistent, and we haven't lost * This is all fine; things are still consistent, and we haven't lost
* any quota information. Just don't complain about bad dquot blks. * any quota information. Just don't complain about bad dquot blks.
*/ */
if (be16_to_cpu(ddq->d_magic) != XFS_DQUOT_MAGIC) { if (ddq->d_magic != cpu_to_be16(XFS_DQUOT_MAGIC)) {
if (flags & XFS_QMOPT_DOWARN) if (flags & XFS_QMOPT_DOWARN)
xfs_alert(mp, xfs_alert(mp,
"%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x", "%s : XFS dquot ID 0x%x, magic 0x%x != 0x%x",
...@@ -2238,7 +2238,7 @@ xlog_recover_inode_pass2( ...@@ -2238,7 +2238,7 @@ xlog_recover_inode_pass2(
* Make sure the place we're flushing out to really looks * Make sure the place we're flushing out to really looks
* like an inode! * like an inode!
*/ */
if (unlikely(be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC)) { if (unlikely(dip->di_magic != cpu_to_be16(XFS_DINODE_MAGIC))) {
xfs_buf_relse(bp); xfs_buf_relse(bp);
xfs_alert(mp, xfs_alert(mp,
"%s: Bad inode magic number, dip = 0x%p, dino bp = 0x%p, ino = %Ld", "%s: Bad inode magic number, dip = 0x%p, dino bp = 0x%p, ino = %Ld",
...@@ -3295,7 +3295,7 @@ xlog_valid_rec_header( ...@@ -3295,7 +3295,7 @@ xlog_valid_rec_header(
{ {
int hlen; int hlen;
if (unlikely(be32_to_cpu(rhead->h_magicno) != XLOG_HEADER_MAGIC_NUM)) { if (unlikely(rhead->h_magicno != cpu_to_be32(XLOG_HEADER_MAGIC_NUM))) {
XFS_ERROR_REPORT("xlog_valid_rec_header(1)", XFS_ERROR_REPORT("xlog_valid_rec_header(1)",
XFS_ERRLEVEL_LOW, log->l_mp); XFS_ERRLEVEL_LOW, log->l_mp);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment