Commit 89da0544 authored by Nathan Scott's avatar Nathan Scott

[XFS] endianess annotations for xfs_da_blkinfo_t

SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25495a
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent 3d693c6e
...@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) ...@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context)
return(error); return(error);
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) {
!= 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);
...@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args) ...@@ -1541,8 +1540,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(INT_GET(((xfs_attr_leafblock_t *) ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *)
bp->data)->hdr.info.magic, ARCH_CONVERT) bp->data)->hdr.info.magic)
== XFS_ATTR_LEAF_MAGIC); == XFS_ATTR_LEAF_MAGIC);
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
...@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(error); return(error);
if (bp) { if (bp) {
node = bp->data; node = bp->data;
switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) { switch (be16_to_cpu(node->hdr.info.magic)) {
case XFS_DA_NODE_MAGIC: case XFS_DA_NODE_MAGIC:
xfs_attr_trace_l_cn("wrong blk", context, node); xfs_attr_trace_l_cn("wrong blk", context, node);
xfs_da_brelse(NULL, bp); xfs_da_brelse(NULL, bp);
...@@ -1817,10 +1816,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -1817,10 +1816,10 @@ 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 (INT_GET(node->hdr.info.magic, ARCH_CONVERT) if (be16_to_cpu(node->hdr.info.magic)
== XFS_ATTR_LEAF_MAGIC) == XFS_ATTR_LEAF_MAGIC)
break; break;
if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT) if (unlikely(be16_to_cpu(node->hdr.info.magic)
!= XFS_DA_NODE_MAGIC)) { != 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,
...@@ -1858,7 +1857,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -1858,7 +1857,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
*/ */
for (;;) { for (;;) {
leaf = bp->data; leaf = bp->data;
if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) if (unlikely(be16_to_cpu(leaf->hdr.info.magic)
!= XFS_ATTR_LEAF_MAGIC)) { != 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,
...@@ -1869,7 +1868,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) ...@@ -1869,7 +1868,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
error = xfs_attr_leaf_list_int(bp, context); error = xfs_attr_leaf_list_int(bp, context);
if (error || !leaf->hdr.info.forw) if (error || !leaf->hdr.info.forw)
break; /* not really an error, buffer full or EOF */ break; /* not really an error, buffer full or EOF */
cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT); cursor->blkno = be32_to_cpu(leaf->hdr.info.forw);
xfs_da_brelse(NULL, bp); xfs_da_brelse(NULL, bp);
error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
&bp, XFS_ATTR_FORK); &bp, XFS_ATTR_FORK);
......
...@@ -720,8 +720,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) ...@@ -720,8 +720,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== 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);
...@@ -766,8 +765,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) ...@@ -766,8 +765,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
/* /*
...@@ -875,8 +873,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args) ...@@ -875,8 +873,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== 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[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval; leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval;
...@@ -920,7 +917,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) ...@@ -920,7 +917,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
leaf = bp->data; leaf = bp->data;
memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
hdr = &leaf->hdr; hdr = &leaf->hdr;
INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC); hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC);
INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
if (!hdr->firstused) { if (!hdr->firstused) {
INT_SET(hdr->firstused, ARCH_CONVERT, INT_SET(hdr->firstused, ARCH_CONVERT,
...@@ -1004,8 +1001,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -1004,8 +1001,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT((args->index >= 0) ASSERT((args->index >= 0)
&& (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
hdr = &leaf->hdr; hdr = &leaf->hdr;
...@@ -1079,8 +1075,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) ...@@ -1079,8 +1075,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== 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) ASSERT((args->index >= 0)
...@@ -1279,10 +1274,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -1279,10 +1274,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(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
args = state->args; args = state->args;
/* /*
...@@ -1566,7 +1559,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1566,7 +1559,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(INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
leaf = (xfs_attr_leafblock_t *)info; leaf = (xfs_attr_leafblock_t *)info;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT); count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes = sizeof(xfs_attr_leaf_hdr_t) + bytes = sizeof(xfs_attr_leaf_hdr_t) +
...@@ -1588,7 +1581,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1588,7 +1581,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
* Make altpath point to the block we want to keep and * Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one). * path point to the block we want to drop (this one).
*/ */
forward = info->forw; forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path)); memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward, error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval); 0, &retval);
...@@ -1610,13 +1603,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1610,13 +1603,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
* to shrink an attribute list over time. * to shrink an attribute list over time.
*/ */
/* start with smaller blk num */ /* start with smaller blk num */
forward = (INT_GET(info->forw, ARCH_CONVERT) forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back));
< INT_GET(info->back, ARCH_CONVERT));
for (i = 0; i < 2; forward = !forward, i++) { for (i = 0; i < 2; forward = !forward, i++) {
if (forward) if (forward)
blkno = INT_GET(info->forw, ARCH_CONVERT); blkno = be32_to_cpu(info->forw);
else else
blkno = INT_GET(info->back, ARCH_CONVERT); blkno = be32_to_cpu(info->back);
if (blkno == 0) if (blkno == 0)
continue; continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp, error = xfs_da_read_buf(state->args->trans, state->args->dp,
...@@ -1630,8 +1622,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1630,8 +1622,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 -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
count += INT_GET(leaf->hdr.count, ARCH_CONVERT); count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
bytes -= count * sizeof(xfs_attr_leaf_entry_t); bytes -= count * sizeof(xfs_attr_leaf_entry_t);
...@@ -1685,8 +1676,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -1685,8 +1676,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
hdr = &leaf->hdr; hdr = &leaf->hdr;
mp = args->trans->t_mountp; mp = args->trans->t_mountp;
ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0)
...@@ -1859,10 +1849,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1859,10 +1849,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(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC); ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
drop_hdr = &drop_leaf->hdr; drop_hdr = &drop_leaf->hdr;
save_hdr = &save_leaf->hdr; save_hdr = &save_leaf->hdr;
...@@ -1972,8 +1960,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -1972,8 +1960,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
< (XFS_LBSIZE(args->dp->i_mount)/8)); < (XFS_LBSIZE(args->dp->i_mount)/8));
...@@ -2090,8 +2077,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) ...@@ -2090,8 +2077,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
< (XFS_LBSIZE(args->dp->i_mount)/8)); < (XFS_LBSIZE(args->dp->i_mount)/8));
ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT))); ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT)));
...@@ -2159,10 +2145,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, ...@@ -2159,10 +2145,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
/* /*
* Set up environment. * Set up environment.
*/ */
ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT)
== 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((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0)
...@@ -2301,10 +2285,8 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) ...@@ -2301,10 +2285,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((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) &&
== XFS_ATTR_LEAF_MAGIC) && (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC));
(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC));
if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0)
&& (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0)
&& ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < && ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) <
...@@ -2327,8 +2309,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) ...@@ -2327,8 +2309,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
if (count) if (count)
*count = INT_GET(leaf->hdr.count, ARCH_CONVERT); *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
if (!leaf->hdr.count) if (!leaf->hdr.count)
...@@ -2348,8 +2329,7 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) ...@@ -2348,8 +2329,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== 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,
...@@ -2596,8 +2576,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) ...@@ -2596,8 +2576,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
ASSERT(args->index >= 0); ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ]; entry = &leaf->entries[ args->index ];
...@@ -2663,8 +2642,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args) ...@@ -2663,8 +2642,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
ASSERT(args->index >= 0); ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ]; entry = &leaf->entries[ args->index ];
...@@ -2736,15 +2714,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) ...@@ -2736,15 +2714,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
} }
leaf1 = bp1->data; leaf1 = bp1->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT)); ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT));
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(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT)); ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT));
ASSERT(args->index2 >= 0); ASSERT(args->index2 >= 0);
entry2 = &leaf2->entries[ args->index2 ]; entry2 = &leaf2->entries[ args->index2 ];
...@@ -2842,9 +2818,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp) ...@@ -2842,9 +2818,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 (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) {
error = xfs_attr_node_inactive(trans, dp, bp, 1); error = xfs_attr_node_inactive(trans, dp, bp, 1);
} else if (INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { } else if (be16_to_cpu(info->magic) == 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);
...@@ -2892,8 +2868,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, ...@@ -2892,8 +2868,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
} }
node = bp->data; node = bp->data;
ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
== 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 = INT_GET(node->hdr.count, ARCH_CONVERT); count = INT_GET(node->hdr.count, ARCH_CONVERT);
if (!count) { if (!count) {
...@@ -2927,12 +2902,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, ...@@ -2927,12 +2902,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 (INT_GET(info->magic, ARCH_CONVERT) if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) {
== 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 (INT_GET(info->magic, ARCH_CONVERT) } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) {
== XFS_ATTR_LEAF_MAGIC) {
error = xfs_attr_leaf_inactive(trans, dp, error = xfs_attr_leaf_inactive(trans, dp,
child_bp); child_bp);
} else { } else {
...@@ -2991,8 +2964,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) ...@@ -2991,8 +2964,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
== XFS_ATTR_LEAF_MAGIC);
/* /*
* Count the number of "remote" value extents. * Count the number of "remote" value extents.
......
...@@ -126,7 +126,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, ...@@ -126,7 +126,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level,
node = bp->data; node = bp->data;
node->hdr.info.forw = 0; node->hdr.info.forw = 0;
node->hdr.info.back = 0; node->hdr.info.back = 0;
INT_SET(node->hdr.info.magic, ARCH_CONVERT, XFS_DA_NODE_MAGIC); node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC);
node->hdr.info.pad = 0; node->hdr.info.pad = 0;
node->hdr.count = 0; node->hdr.count = 0;
INT_SET(node->hdr.level, ARCH_CONVERT, level); INT_SET(node->hdr.level, ARCH_CONVERT, level);
...@@ -290,28 +290,28 @@ xfs_da_split(xfs_da_state_t *state) ...@@ -290,28 +290,28 @@ xfs_da_split(xfs_da_state_t *state)
node = oldblk->bp->data; node = oldblk->bp->data;
if (node->hdr.info.forw) { if (node->hdr.info.forw) {
if (INT_GET(node->hdr.info.forw, ARCH_CONVERT) == addblk->blkno) { if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) {
bp = addblk->bp; bp = addblk->bp;
} else { } else {
ASSERT(state->extravalid); ASSERT(state->extravalid);
bp = state->extrablk.bp; bp = state->extrablk.bp;
} }
node = bp->data; node = bp->data;
INT_SET(node->hdr.info.back, ARCH_CONVERT, oldblk->blkno); node->hdr.info.back = cpu_to_be32(oldblk->blkno);
xfs_da_log_buf(state->args->trans, bp, xfs_da_log_buf(state->args->trans, bp,
XFS_DA_LOGRANGE(node, &node->hdr.info, XFS_DA_LOGRANGE(node, &node->hdr.info,
sizeof(node->hdr.info))); sizeof(node->hdr.info)));
} }
node = oldblk->bp->data; node = oldblk->bp->data;
if (INT_GET(node->hdr.info.back, ARCH_CONVERT)) { if (node->hdr.info.back) {
if (INT_GET(node->hdr.info.back, ARCH_CONVERT) == addblk->blkno) { if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) {
bp = addblk->bp; bp = addblk->bp;
} else { } else {
ASSERT(state->extravalid); ASSERT(state->extravalid);
bp = state->extrablk.bp; bp = state->extrablk.bp;
} }
node = bp->data; node = bp->data;
INT_SET(node->hdr.info.forw, ARCH_CONVERT, oldblk->blkno); node->hdr.info.forw = cpu_to_be32(oldblk->blkno);
xfs_da_log_buf(state->args->trans, bp, xfs_da_log_buf(state->args->trans, bp,
XFS_DA_LOGRANGE(node, &node->hdr.info, XFS_DA_LOGRANGE(node, &node->hdr.info,
sizeof(node->hdr.info))); sizeof(node->hdr.info)));
...@@ -359,12 +359,12 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -359,12 +359,12 @@ 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 (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) {
size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] - size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] -
(char *)oldroot); (char *)oldroot);
} else { } else {
ASSERT(XFS_DIR_IS_V2(mp)); ASSERT(XFS_DIR_IS_V2(mp));
ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == 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);
...@@ -392,7 +392,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -392,7 +392,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
INT_SET(node->hdr.count, ARCH_CONVERT, 2); INT_SET(node->hdr.count, ARCH_CONVERT, 2);
#ifdef DEBUG #ifdef DEBUG
if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { if (be16_to_cpu(oldroot->hdr.info.magic) == 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 &&
...@@ -424,7 +424,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, ...@@ -424,7 +424,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(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
/* /*
* With V2 the extra block is data or freespace. * With V2 the extra block is data or freespace.
...@@ -524,8 +524,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -524,8 +524,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(INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC);
ASSERT(INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC);
count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2; count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2;
if (count == 0) if (count == 0)
return; return;
...@@ -622,7 +622,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, ...@@ -622,7 +622,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk,
node = oldblk->bp->data; node = oldblk->bp->data;
mp = state->mp; mp = state->mp;
ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT))); ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT)));
ASSERT(newblk->blkno != 0); ASSERT(newblk->blkno != 0);
if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp))
...@@ -768,7 +768,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) ...@@ -768,7 +768,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(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC);
ASSERT(!oldroot->hdr.info.forw); ASSERT(!oldroot->hdr.info.forw);
ASSERT(!oldroot->hdr.info.back); ASSERT(!oldroot->hdr.info.back);
...@@ -791,10 +791,10 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) ...@@ -791,10 +791,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 (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) { if (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) {
ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC);
} else { } else {
ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC);
} }
ASSERT(!blkinfo->forw); ASSERT(!blkinfo->forw);
ASSERT(!blkinfo->back); ASSERT(!blkinfo->back);
...@@ -830,7 +830,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) ...@@ -830,7 +830,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(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC);
node = (xfs_da_intnode_t *)info; node = (xfs_da_intnode_t *)info;
count = INT_GET(node->hdr.count, ARCH_CONVERT); count = INT_GET(node->hdr.count, ARCH_CONVERT);
if (count > (state->node_ents >> 1)) { if (count > (state->node_ents >> 1)) {
...@@ -849,7 +849,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) ...@@ -849,7 +849,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
* Make altpath point to the block we want to keep and * Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one). * path point to the block we want to drop (this one).
*/ */
forward = info->forw; forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path)); memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward, error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval); 0, &retval);
...@@ -871,13 +871,12 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) ...@@ -871,13 +871,12 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
* to shrink a directory over time. * to shrink a directory over time.
*/ */
/* start with smaller blk num */ /* start with smaller blk num */
forward = (INT_GET(info->forw, ARCH_CONVERT) forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back));
< INT_GET(info->back, ARCH_CONVERT));
for (i = 0; i < 2; forward = !forward, i++) { for (i = 0; i < 2; forward = !forward, i++) {
if (forward) if (forward)
blkno = INT_GET(info->forw, ARCH_CONVERT); blkno = be32_to_cpu(info->forw);
else else
blkno = INT_GET(info->back, ARCH_CONVERT); blkno = be32_to_cpu(info->back);
if (blkno == 0) if (blkno == 0)
continue; continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp, error = xfs_da_read_buf(state->args->trans, state->args->dp,
...@@ -891,7 +890,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) ...@@ -891,7 +890,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action)
count -= state->node_ents >> 2; count -= state->node_ents >> 2;
count -= INT_GET(node->hdr.count, ARCH_CONVERT); count -= INT_GET(node->hdr.count, ARCH_CONVERT);
node = bp->data; node = bp->data;
ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
count -= INT_GET(node->hdr.count, ARCH_CONVERT); count -= INT_GET(node->hdr.count, ARCH_CONVERT);
xfs_da_brelse(state->args->trans, bp); xfs_da_brelse(state->args->trans, bp);
if (count >= 0) if (count >= 0)
...@@ -973,7 +972,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) ...@@ -973,7 +972,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(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
btree = &node->btree[ blk->index ]; btree = &node->btree[ blk->index ];
if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash) if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash)
break; break;
...@@ -1041,8 +1040,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1041,8 +1040,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(INT_GET(drop_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(drop_node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
ASSERT(INT_GET(save_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(save_node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
tp = state->args->trans; tp = state->args->trans;
/* /*
...@@ -1138,15 +1137,15 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) ...@@ -1138,15 +1137,15 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
return(error); return(error);
} }
curr = blk->bp->data; curr = blk->bp->data;
ASSERT(INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC ||
INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC);
/* /*
* Search an intermediate node for a match. * Search an intermediate node for a match.
*/ */
blk->magic = INT_GET(curr->magic, ARCH_CONVERT); blk->magic = be16_to_cpu(curr->magic);
if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { if (blk->magic == XFS_DA_NODE_MAGIC) {
node = blk->bp->data; node = blk->bp->data;
blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
...@@ -1193,15 +1192,15 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) ...@@ -1193,15 +1192,15 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result)
blkno = INT_GET(btree->before, ARCH_CONVERT); blkno = INT_GET(btree->before, ARCH_CONVERT);
} }
} }
else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) {
blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL);
break; break;
} }
else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) {
blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL);
break; break;
} }
else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) {
blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL);
break; break;
} }
...@@ -1274,8 +1273,8 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, ...@@ -1274,8 +1273,8 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC ||
old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
old_blk->magic == XFS_ATTR_LEAF_MAGIC); old_blk->magic == XFS_ATTR_LEAF_MAGIC);
ASSERT(old_blk->magic == INT_GET(old_info->magic, ARCH_CONVERT)); ASSERT(old_blk->magic == be16_to_cpu(old_info->magic));
ASSERT(new_blk->magic == INT_GET(new_info->magic, ARCH_CONVERT)); ASSERT(new_blk->magic == be16_to_cpu(new_info->magic));
ASSERT(old_blk->magic == new_blk->magic); ASSERT(old_blk->magic == new_blk->magic);
switch (old_blk->magic) { switch (old_blk->magic) {
...@@ -1302,47 +1301,44 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, ...@@ -1302,47 +1301,44 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk,
/* /*
* Link new block in before existing block. * Link new block in before existing block.
*/ */
INT_SET(new_info->forw, ARCH_CONVERT, old_blk->blkno); new_info->forw = cpu_to_be32(old_blk->blkno);
new_info->back = old_info->back; /* INT_: direct copy */ new_info->back = old_info->back;
if (INT_GET(old_info->back, ARCH_CONVERT)) { if (old_info->back) {
error = xfs_da_read_buf(args->trans, args->dp, error = xfs_da_read_buf(args->trans, args->dp,
INT_GET(old_info->back, be32_to_cpu(old_info->back),
ARCH_CONVERT), -1, &bp, -1, &bp, args->whichfork);
args->whichfork);
if (error) if (error)
return(error); return(error);
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->data; tmp_info = bp->data;
ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(old_info->magic, ARCH_CONVERT)); ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic));
ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == old_blk->blkno); ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno);
INT_SET(tmp_info->forw, ARCH_CONVERT, new_blk->blkno); tmp_info->forw = cpu_to_be32(new_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
xfs_da_buf_done(bp); xfs_da_buf_done(bp);
} }
INT_SET(old_info->back, ARCH_CONVERT, new_blk->blkno); old_info->back = cpu_to_be32(new_blk->blkno);
} else { } else {
/* /*
* Link new block in after existing block. * Link new block in after existing block.
*/ */
new_info->forw = old_info->forw; /* INT_: direct copy */ new_info->forw = old_info->forw;
INT_SET(new_info->back, ARCH_CONVERT, old_blk->blkno); new_info->back = cpu_to_be32(old_blk->blkno);
if (INT_GET(old_info->forw, ARCH_CONVERT)) { if (old_info->forw) {
error = xfs_da_read_buf(args->trans, args->dp, error = xfs_da_read_buf(args->trans, args->dp,
INT_GET(old_info->forw, ARCH_CONVERT), -1, &bp, be32_to_cpu(old_info->forw),
args->whichfork); -1, &bp, args->whichfork);
if (error) if (error)
return(error); return(error);
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->data; tmp_info = bp->data;
ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) ASSERT(tmp_info->magic == old_info->magic);
== INT_GET(old_info->magic, ARCH_CONVERT)); ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno);
ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) tmp_info->back = cpu_to_be32(new_blk->blkno);
== old_blk->blkno);
INT_SET(tmp_info->back, ARCH_CONVERT, new_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1);
xfs_da_buf_done(bp); xfs_da_buf_done(bp);
} }
INT_SET(old_info->forw, ARCH_CONVERT, new_blk->blkno); old_info->forw = cpu_to_be32(new_blk->blkno);
} }
xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1);
...@@ -1360,8 +1356,8 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp) ...@@ -1360,8 +1356,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((INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) && ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) &&
(INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC)); (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC));
if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) &&
((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) <
INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) ||
...@@ -1381,7 +1377,7 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) ...@@ -1381,7 +1377,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(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
if (count) if (count)
*count = INT_GET(node->hdr.count, ARCH_CONVERT); *count = INT_GET(node->hdr.count, ARCH_CONVERT);
if (!node->hdr.count) if (!node->hdr.count)
...@@ -1411,50 +1407,47 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1411,50 +1407,47 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC ||
save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) ||
save_blk->magic == XFS_ATTR_LEAF_MAGIC); save_blk->magic == XFS_ATTR_LEAF_MAGIC);
ASSERT(save_blk->magic == INT_GET(save_info->magic, ARCH_CONVERT)); ASSERT(save_blk->magic == be16_to_cpu(save_info->magic));
ASSERT(drop_blk->magic == INT_GET(drop_info->magic, ARCH_CONVERT)); ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic));
ASSERT(save_blk->magic == drop_blk->magic); ASSERT(save_blk->magic == drop_blk->magic);
ASSERT((INT_GET(save_info->forw, ARCH_CONVERT) == drop_blk->blkno) || ASSERT((be32_to_cpu(save_info->forw) == drop_blk->blkno) ||
(INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno)); (be32_to_cpu(save_info->back) == drop_blk->blkno));
ASSERT((INT_GET(drop_info->forw, ARCH_CONVERT) == save_blk->blkno) || ASSERT((be32_to_cpu(drop_info->forw) == save_blk->blkno) ||
(INT_GET(drop_info->back, ARCH_CONVERT) == save_blk->blkno)); (be32_to_cpu(drop_info->back) == save_blk->blkno));
/* /*
* Unlink the leaf block from the doubly linked chain of leaves. * Unlink the leaf block from the doubly linked chain of leaves.
*/ */
if (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno) { if (be32_to_cpu(save_info->back) == drop_blk->blkno) {
save_info->back = drop_info->back; /* INT_: direct copy */ save_info->back = drop_info->back;
if (INT_GET(drop_info->back, ARCH_CONVERT)) { if (drop_info->back) {
error = xfs_da_read_buf(args->trans, args->dp, error = xfs_da_read_buf(args->trans, args->dp,
INT_GET(drop_info->back, be32_to_cpu(drop_info->back),
ARCH_CONVERT), -1, &bp, -1, &bp, args->whichfork);
args->whichfork);
if (error) if (error)
return(error); return(error);
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->data; tmp_info = bp->data;
ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(save_info->magic, ARCH_CONVERT)); ASSERT(tmp_info->magic == save_info->magic);
ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == drop_blk->blkno); ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno);
INT_SET(tmp_info->forw, ARCH_CONVERT, save_blk->blkno); tmp_info->forw = cpu_to_be32(save_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0, xfs_da_log_buf(args->trans, bp, 0,
sizeof(*tmp_info) - 1); sizeof(*tmp_info) - 1);
xfs_da_buf_done(bp); xfs_da_buf_done(bp);
} }
} else { } else {
save_info->forw = drop_info->forw; /* INT_: direct copy */ save_info->forw = drop_info->forw;
if (INT_GET(drop_info->forw, ARCH_CONVERT)) { if (drop_info->forw) {
error = xfs_da_read_buf(args->trans, args->dp, error = xfs_da_read_buf(args->trans, args->dp,
INT_GET(drop_info->forw, ARCH_CONVERT), -1, &bp, be32_to_cpu(drop_info->forw),
args->whichfork); -1, &bp, args->whichfork);
if (error) if (error)
return(error); return(error);
ASSERT(bp != NULL); ASSERT(bp != NULL);
tmp_info = bp->data; tmp_info = bp->data;
ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) ASSERT(tmp_info->magic == save_info->magic);
== INT_GET(save_info->magic, ARCH_CONVERT)); ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno);
ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) tmp_info->back = cpu_to_be32(save_blk->blkno);
== drop_blk->blkno);
INT_SET(tmp_info->back, ARCH_CONVERT, save_blk->blkno);
xfs_da_log_buf(args->trans, bp, 0, xfs_da_log_buf(args->trans, bp, 0,
sizeof(*tmp_info) - 1); sizeof(*tmp_info) - 1);
xfs_da_buf_done(bp); xfs_da_buf_done(bp);
...@@ -1497,7 +1490,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, ...@@ -1497,7 +1490,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(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC);
if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) {
blk->index++; blk->index++;
blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT);
...@@ -1536,11 +1529,11 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, ...@@ -1536,11 +1529,11 @@ 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(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC ||
INT_GET(info->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) ||
INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
blk->magic = INT_GET(info->magic, ARCH_CONVERT); blk->magic = be16_to_cpu(info->magic);
if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { if (blk->magic == XFS_DA_NODE_MAGIC) {
node = (xfs_da_intnode_t *)info; node = (xfs_da_intnode_t *)info;
blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT);
if (forward) if (forward)
...@@ -1788,19 +1781,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1788,19 +1781,19 @@ 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 (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) {
ASSERT(XFS_DIR_IS_V1(mp)); ASSERT(XFS_DIR_IS_V1(mp));
dead_leaf = (xfs_dir_leafblock_t *)dead_info; dead_leaf = (xfs_dir_leafblock_t *)dead_info;
dead_level = 0; dead_level = 0;
dead_hash = dead_hash =
INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
} else if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) {
ASSERT(XFS_DIR_IS_V2(mp)); ASSERT(XFS_DIR_IS_V2(mp));
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(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC);
dead_node = (xfs_da_intnode_t *)dead_info; dead_node = (xfs_da_intnode_t *)dead_info;
dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT); dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT);
dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT);
...@@ -1809,19 +1802,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1809,19 +1802,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
/* /*
* If the moved block has a left sibling, fix up the pointers. * If the moved block has a left sibling, fix up the pointers.
*/ */
if ((sib_blkno = INT_GET(dead_info->back, ARCH_CONVERT))) { if ((sib_blkno = be32_to_cpu(dead_info->back))) {
if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
goto done; goto done;
sib_info = sib_buf->data; sib_info = sib_buf->data;
if (unlikely( if (unlikely(
INT_GET(sib_info->forw, ARCH_CONVERT) != last_blkno || be32_to_cpu(sib_info->forw) != last_blkno ||
INT_GET(sib_info->magic, ARCH_CONVERT) != INT_GET(dead_info->magic, ARCH_CONVERT))) { sib_info->magic != dead_info->magic)) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = XFS_ERROR(EFSCORRUPTED);
goto done; goto done;
} }
INT_SET(sib_info->forw, ARCH_CONVERT, dead_blkno); sib_info->forw = cpu_to_be32(dead_blkno);
xfs_da_log_buf(tp, sib_buf, xfs_da_log_buf(tp, sib_buf,
XFS_DA_LOGRANGE(sib_info, &sib_info->forw, XFS_DA_LOGRANGE(sib_info, &sib_info->forw,
sizeof(sib_info->forw))); sizeof(sib_info->forw)));
...@@ -1831,20 +1824,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1831,20 +1824,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
/* /*
* If the moved block has a right sibling, fix up the pointers. * If the moved block has a right sibling, fix up the pointers.
*/ */
if ((sib_blkno = INT_GET(dead_info->forw, ARCH_CONVERT))) { if ((sib_blkno = be32_to_cpu(dead_info->forw))) {
if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w)))
goto done; goto done;
sib_info = sib_buf->data; sib_info = sib_buf->data;
if (unlikely( if (unlikely(
INT_GET(sib_info->back, ARCH_CONVERT) != last_blkno be32_to_cpu(sib_info->back) != last_blkno ||
|| INT_GET(sib_info->magic, ARCH_CONVERT) sib_info->magic != dead_info->magic)) {
!= INT_GET(dead_info->magic, ARCH_CONVERT))) {
XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)",
XFS_ERRLEVEL_LOW, mp); XFS_ERRLEVEL_LOW, mp);
error = XFS_ERROR(EFSCORRUPTED); error = XFS_ERROR(EFSCORRUPTED);
goto done; goto done;
} }
INT_SET(sib_info->back, ARCH_CONVERT, dead_blkno); sib_info->back = cpu_to_be32(dead_blkno);
xfs_da_log_buf(tp, sib_buf, xfs_da_log_buf(tp, sib_buf,
XFS_DA_LOGRANGE(sib_info, &sib_info->back, XFS_DA_LOGRANGE(sib_info, &sib_info->back,
sizeof(sib_info->back))); sizeof(sib_info->back)));
...@@ -1861,7 +1853,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1861,7 +1853,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
goto done; goto done;
par_node = par_buf->data; par_node = par_buf->data;
if (unlikely( if (unlikely(
INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC || be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC ||
(level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) { (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 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);
...@@ -1898,7 +1890,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1898,7 +1890,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
continue; continue;
if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT)) if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT))
break; break;
par_blkno = INT_GET(par_node->hdr.info.forw, ARCH_CONVERT); par_blkno = be32_to_cpu(par_node->hdr.info.forw);
xfs_da_brelse(tp, par_buf); xfs_da_brelse(tp, par_buf);
par_buf = NULL; par_buf = NULL;
if (unlikely(par_blkno == 0)) { if (unlikely(par_blkno == 0)) {
...@@ -1912,7 +1904,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1912,7 +1904,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(
INT_GET(par_node->hdr.level, ARCH_CONVERT) != level || INT_GET(par_node->hdr.level, ARCH_CONVERT) != level ||
INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)) { be16_to_cpu(par_node->hdr.info.magic) != 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);
...@@ -2203,7 +2195,7 @@ xfs_da_do_buf( ...@@ -2203,7 +2195,7 @@ xfs_da_do_buf(
info = rbp->data; info = rbp->data;
data = rbp->data; data = rbp->data;
free = rbp->data; free = rbp->data;
magic = INT_GET(info->magic, ARCH_CONVERT); magic = be16_to_cpu(info->magic);
magic1 = be32_to_cpu(data->hdr.magic); magic1 = be32_to_cpu(data->hdr.magic);
if (unlikely( if (unlikely(
XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) &&
......
...@@ -45,10 +45,10 @@ struct zone; ...@@ -45,10 +45,10 @@ struct zone;
(XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC) (XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC)
typedef struct xfs_da_blkinfo { typedef struct xfs_da_blkinfo {
xfs_dablk_t forw; /* previous block in list */ __be32 forw; /* previous block in list */
xfs_dablk_t back; /* following block in list */ __be32 back; /* following block in list */
__uint16_t magic; /* validity check on block */ __be16 magic; /* validity check on block */
__uint16_t pad; /* unused */ __be16 pad; /* unused */
} xfs_da_blkinfo_t; } xfs_da_blkinfo_t;
/* /*
......
...@@ -634,7 +634,7 @@ xfs_dir_leaf_removename(xfs_da_args_t *args, int *count, int *totallen) ...@@ -634,7 +634,7 @@ xfs_dir_leaf_removename(xfs_da_args_t *args, int *count, int *totallen)
return(retval); return(retval);
ASSERT(bp != NULL); ASSERT(bp != NULL);
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
retval = xfs_dir_leaf_lookup_int(bp, args, &index); retval = xfs_dir_leaf_lookup_int(bp, args, &index);
if (retval == EEXIST) { if (retval == EEXIST) {
(void)xfs_dir_leaf_remove(args->trans, bp, index); (void)xfs_dir_leaf_remove(args->trans, bp, index);
...@@ -912,7 +912,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, ...@@ -912,7 +912,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
return(error); return(error);
if (bp) if (bp)
leaf = bp->data; leaf = bp->data;
if (bp && INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { if (bp && be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) {
xfs_dir_trace_g_dub("node: block not a leaf", xfs_dir_trace_g_dub("node: block not a leaf",
dp, uio, bno); dp, uio, bno);
xfs_da_brelse(trans, bp); xfs_da_brelse(trans, bp);
...@@ -949,7 +949,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, ...@@ -949,7 +949,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
if (bp == NULL) if (bp == NULL)
return(XFS_ERROR(EFSCORRUPTED)); return(XFS_ERROR(EFSCORRUPTED));
node = bp->data; node = bp->data;
if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC) if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC)
break; break;
btree = &node->btree[0]; btree = &node->btree[0];
xfs_dir_trace_g_dun("node: node detail", dp, uio, node); xfs_dir_trace_g_dun("node: node detail", dp, uio, node);
...@@ -982,7 +982,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, ...@@ -982,7 +982,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
*/ */
for (;;) { for (;;) {
leaf = bp->data; leaf = bp->data;
if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC)) { if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC)) {
xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf); xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf);
xfs_da_brelse(trans, bp); xfs_da_brelse(trans, bp);
XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)", XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)",
...@@ -990,7 +990,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, ...@@ -990,7 +990,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf); xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf);
if ((nextbno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT))) { if ((nextbno = be32_to_cpu(leaf->hdr.info.forw))) {
nextda = xfs_da_reada_buf(trans, dp, nextbno, nextda = xfs_da_reada_buf(trans, dp, nextbno,
XFS_DATA_FORK); XFS_DATA_FORK);
} else } else
...@@ -1125,8 +1125,7 @@ xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio, ...@@ -1125,8 +1125,7 @@ xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio,
(void *)((unsigned long)(uio->uio_offset >> 32)), (void *)((unsigned long)(uio->uio_offset >> 32)),
(void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
(void *)(unsigned long)uio->uio_resid, (void *)(unsigned long)uio->uio_resid,
(void *)(unsigned long) (void *)(unsigned long)be32_to_cpu(node->hdr.info.forw),
INT_GET(node->hdr.info.forw, ARCH_CONVERT),
(void *)(unsigned long) (void *)(unsigned long)
INT_GET(node->hdr.count, ARCH_CONVERT), INT_GET(node->hdr.count, ARCH_CONVERT),
(void *)(unsigned long) (void *)(unsigned long)
...@@ -1150,8 +1149,7 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio, ...@@ -1150,8 +1149,7 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio,
(void *)((unsigned long)(uio->uio_offset >> 32)), (void *)((unsigned long)(uio->uio_offset >> 32)),
(void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)),
(void *)(unsigned long)uio->uio_resid, (void *)(unsigned long)uio->uio_resid,
(void *)(unsigned long) (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw),
INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
(void *)(unsigned long) (void *)(unsigned long)
INT_GET(leaf->hdr.count, ARCH_CONVERT), INT_GET(leaf->hdr.count, ARCH_CONVERT),
(void *)(unsigned long) (void *)(unsigned long)
......
...@@ -905,7 +905,7 @@ xfs_dir2_leaf_to_block( ...@@ -905,7 +905,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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
......
...@@ -564,7 +564,7 @@ xfs_dir2_leaf_check( ...@@ -564,7 +564,7 @@ xfs_dir2_leaf_check(
leaf = bp->data; leaf = bp->data;
mp = dp->i_mount; mp = dp->i_mount;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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.
...@@ -1172,7 +1172,7 @@ xfs_dir2_leaf_init( ...@@ -1172,7 +1172,7 @@ xfs_dir2_leaf_init(
/* /*
* Initialize the header. * Initialize the header.
*/ */
INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, magic); leaf->hdr.info.magic = cpu_to_be16(magic);
leaf->hdr.info.forw = 0; leaf->hdr.info.forw = 0;
leaf->hdr.info.back = 0; leaf->hdr.info.back = 0;
leaf->hdr.count = 0; leaf->hdr.count = 0;
...@@ -1208,7 +1208,7 @@ xfs_dir2_leaf_log_bests( ...@@ -1208,7 +1208,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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;
...@@ -1231,8 +1231,8 @@ xfs_dir2_leaf_log_ents( ...@@ -1231,8 +1231,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); be16_to_cpu(leaf->hdr.info.magic) == 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),
...@@ -1250,8 +1250,8 @@ xfs_dir2_leaf_log_header( ...@@ -1250,8 +1250,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); be16_to_cpu(leaf->hdr.info.magic) == 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));
} }
...@@ -1270,7 +1270,7 @@ xfs_dir2_leaf_log_tail( ...@@ -1270,7 +1270,7 @@ xfs_dir2_leaf_log_tail(
mp = tp->t_mountp; mp = tp->t_mountp;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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));
...@@ -1806,7 +1806,7 @@ xfs_dir2_node_to_leaf( ...@@ -1806,7 +1806,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
/* /*
* Read the freespace block. * Read the freespace block.
*/ */
...@@ -1837,7 +1837,7 @@ xfs_dir2_node_to_leaf( ...@@ -1837,7 +1837,7 @@ xfs_dir2_node_to_leaf(
xfs_dir2_leaf_compact(args, lbp); xfs_dir2_leaf_compact(args, lbp);
else else
xfs_dir2_leaf_log_header(tp, lbp); xfs_dir2_leaf_log_header(tp, lbp);
INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAF1_MAGIC); leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC);
/* /*
* Set up the leaf tail from the freespace block. * Set up the leaf tail from the freespace block.
*/ */
......
...@@ -164,7 +164,7 @@ xfs_dir2_leaf_to_node( ...@@ -164,7 +164,7 @@ xfs_dir2_leaf_to_node(
*to = cpu_to_be16(off); *to = cpu_to_be16(off);
} }
free->hdr.nused = cpu_to_be32(n); free->hdr.nused = cpu_to_be32(n);
INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAFN_MAGIC); leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC);
/* /*
* Log everything. * Log everything.
*/ */
...@@ -353,7 +353,7 @@ xfs_dir2_leafn_check( ...@@ -353,7 +353,7 @@ xfs_dir2_leafn_check(
leaf = bp->data; leaf = bp->data;
mp = dp->i_mount; mp = dp->i_mount;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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)) {
...@@ -379,7 +379,7 @@ xfs_dir2_leafn_lasthash( ...@@ -379,7 +379,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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)
...@@ -420,7 +420,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -420,7 +420,7 @@ xfs_dir2_leafn_lookup_int(
tp = args->trans; tp = args->trans;
mp = dp->i_mount; mp = dp->i_mount;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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
...@@ -720,8 +720,8 @@ xfs_dir2_leafn_order( ...@@ -720,8 +720,8 @@ xfs_dir2_leafn_order(
leaf1 = leaf1_bp->data; leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data; leaf2 = leaf2_bp->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == 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) ||
...@@ -868,7 +868,7 @@ xfs_dir2_leafn_remove( ...@@ -868,7 +868,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
/* /*
* Point to the entry we're removing. * Point to the entry we're removing.
*/ */
...@@ -1139,7 +1139,7 @@ xfs_dir2_leafn_toosmall( ...@@ -1139,7 +1139,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(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(info->magic) == 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]);
...@@ -1161,7 +1161,7 @@ xfs_dir2_leafn_toosmall( ...@@ -1161,7 +1161,7 @@ xfs_dir2_leafn_toosmall(
* Make altpath point to the block we want to keep and * Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one). * path point to the block we want to drop (this one).
*/ */
forward = info->forw; forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path)); memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward, 0, error = xfs_da_path_shift(state, &state->altpath, forward, 0,
&rval); &rval);
...@@ -1177,9 +1177,9 @@ xfs_dir2_leafn_toosmall( ...@@ -1177,9 +1177,9 @@ xfs_dir2_leafn_toosmall(
* We prefer coalescing with the lower numbered sibling so as * We prefer coalescing with the lower numbered sibling so as
* to shrink a directory over time. * to shrink a directory over time.
*/ */
forward = INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT); forward = be32_to_cpu(info->forw) < be32_to_cpu(info->back);
for (i = 0, bp = NULL; i < 2; forward = !forward, i++) { for (i = 0, bp = NULL; i < 2; forward = !forward, i++) {
blkno = forward ?INT_GET( info->forw, ARCH_CONVERT) : INT_GET(info->back, ARCH_CONVERT); blkno = forward ? be32_to_cpu(info->forw) : be32_to_cpu(info->back);
if (blkno == 0) if (blkno == 0)
continue; continue;
/* /*
...@@ -1198,7 +1198,7 @@ xfs_dir2_leafn_toosmall( ...@@ -1198,7 +1198,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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == 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]);
/* /*
...@@ -1257,8 +1257,8 @@ xfs_dir2_leafn_unbalance( ...@@ -1257,8 +1257,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(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == 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.
......
...@@ -644,7 +644,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) ...@@ -644,7 +644,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
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_dir_leafblock_t *)tmpbuffer; leaf = (xfs_dir_leafblock_t *)tmpbuffer;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));
/* /*
...@@ -742,7 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) ...@@ -742,7 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
} }
node = bp1->data; node = bp1->data;
leaf = bp2->data; leaf = bp2->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT));
xfs_da_buf_done(bp2); xfs_da_buf_done(bp2);
INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); INT_SET(node->btree[0].before, ARCH_CONVERT, blkno);
...@@ -781,7 +781,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) ...@@ -781,7 +781,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp)
leaf = bp->data; leaf = bp->data;
memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
hdr = &leaf->hdr; hdr = &leaf->hdr;
INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_DIR_LEAF_MAGIC); hdr->info.magic = cpu_to_be16(XFS_DIR_LEAF_MAGIC);
INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
if (!hdr->firstused) if (!hdr->firstused)
INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1);
...@@ -860,7 +860,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) ...@@ -860,7 +860,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index)
int tablesize, entsize, sum, i, tmp, error; int tablesize, entsize, sum, i, tmp, error;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
hdr = &leaf->hdr; hdr = &leaf->hdr;
entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen);
...@@ -940,7 +940,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, ...@@ -940,7 +940,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index,
int tmp, i; int tmp, i;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr = &leaf->hdr; hdr = &leaf->hdr;
ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE));
ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT)));
...@@ -1097,8 +1097,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -1097,8 +1097,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC);
leaf1 = blk1->bp->data; leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data; leaf2 = blk2->bp->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
/* /*
* Check ordering of blocks, reverse if it makes things simpler. * Check ordering of blocks, reverse if it makes things simpler.
...@@ -1325,7 +1325,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1325,7 +1325,7 @@ xfs_dir_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(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(info->magic) == XFS_DIR_LEAF_MAGIC);
leaf = (xfs_dir_leafblock_t *)info; leaf = (xfs_dir_leafblock_t *)info;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT); count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) +
...@@ -1348,7 +1348,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1348,7 +1348,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
* Make altpath point to the block we want to keep and * Make altpath point to the block we want to keep and
* path point to the block we want to drop (this one). * path point to the block we want to drop (this one).
*/ */
forward = info->forw; forward = (info->forw != 0);
memcpy(&state->altpath, &state->path, sizeof(state->path)); memcpy(&state->altpath, &state->path, sizeof(state->path));
error = xfs_da_path_shift(state, &state->altpath, forward, error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval); 0, &retval);
...@@ -1369,12 +1369,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1369,12 +1369,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
* We prefer coalescing with the lower numbered sibling so as * We prefer coalescing with the lower numbered sibling so as
* to shrink a directory over time. * to shrink a directory over time.
*/ */
forward = (INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT)); /* start with smaller blk num */ forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); /* start with smaller blk num */
for (i = 0; i < 2; forward = !forward, i++) { for (i = 0; i < 2; forward = !forward, i++) {
if (forward) if (forward)
blkno = INT_GET(info->forw, ARCH_CONVERT); blkno = be32_to_cpu(info->forw);
else else
blkno = INT_GET(info->back, ARCH_CONVERT); blkno = be32_to_cpu(info->back);
if (blkno == 0) if (blkno == 0)
continue; continue;
error = xfs_da_read_buf(state->args->trans, state->args->dp, error = xfs_da_read_buf(state->args->trans, state->args->dp,
...@@ -1389,7 +1389,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) ...@@ -1389,7 +1389,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
bytes = state->blocksize - (state->blocksize>>2); bytes = state->blocksize - (state->blocksize>>2);
bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
count += INT_GET(leaf->hdr.count, ARCH_CONVERT); count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1);
...@@ -1447,7 +1447,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) ...@@ -1447,7 +1447,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
xfs_mount_t *mp; xfs_mount_t *mp;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr = &leaf->hdr; hdr = &leaf->hdr;
mp = trans->t_mountp; mp = trans->t_mountp;
ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
...@@ -1599,8 +1599,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1599,8 +1599,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); ASSERT(save_blk->magic == XFS_DIR_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(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
drop_hdr = &drop_leaf->hdr; drop_hdr = &drop_leaf->hdr;
save_hdr = &save_leaf->hdr; save_hdr = &save_leaf->hdr;
...@@ -1695,7 +1695,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) ...@@ -1695,7 +1695,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
xfs_dahash_t hashval; xfs_dahash_t hashval;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8));
/* /*
...@@ -1782,8 +1782,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s, ...@@ -1782,8 +1782,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s,
/* /*
* Set up environment. * Set up environment.
*/ */
ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr_s = &leaf_s->hdr; hdr_s = &leaf_s->hdr;
hdr_d = &leaf_d->hdr; hdr_d = &leaf_d->hdr;
ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8)));
...@@ -1883,8 +1883,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) ...@@ -1883,8 +1883,8 @@ xfs_dir_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((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) && ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) &&
(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC)); (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC));
if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) &&
((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) <
INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) ||
...@@ -1904,7 +1904,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) ...@@ -1904,7 +1904,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count)
xfs_dir_leafblock_t *leaf; xfs_dir_leafblock_t *leaf;
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
if (count) if (count)
*count = INT_GET(leaf->hdr.count, ARCH_CONVERT); *count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
if (!leaf->hdr.count) if (!leaf->hdr.count)
...@@ -1940,7 +1940,7 @@ xfs_dir_leaf_getdents_int( ...@@ -1940,7 +1940,7 @@ xfs_dir_leaf_getdents_int(
mp = dp->i_mount; mp = dp->i_mount;
leaf = bp->data; leaf = bp->data;
if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) {
*eobp = 1; *eobp = 1;
return XFS_ERROR(ENOENT); /* XXX wrong code */ return XFS_ERROR(ENOENT); /* XXX wrong code */
} }
...@@ -1992,7 +1992,7 @@ xfs_dir_leaf_getdents_int( ...@@ -1992,7 +1992,7 @@ xfs_dir_leaf_getdents_int(
if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
xfs_dir_trace_g_du("leaf: hash not found", dp, uio); xfs_dir_trace_g_du("leaf: hash not found", dp, uio);
if (!INT_GET(leaf->hdr.info.forw, ARCH_CONVERT)) if (!leaf->hdr.info.forw)
uio->uio_offset = uio->uio_offset =
XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH);
/* /*
...@@ -2047,8 +2047,7 @@ xfs_dir_leaf_getdents_int( ...@@ -2047,8 +2047,7 @@ xfs_dir_leaf_getdents_int(
xfs_dir_trace_g_duc("leaf: middle cookie ", xfs_dir_trace_g_duc("leaf: middle cookie ",
dp, uio, p.cook.o); dp, uio, p.cook.o);
} else if ((thishash = INT_GET(leaf->hdr.info.forw, } else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) {
ARCH_CONVERT))) {
xfs_dabuf_t *bp2; xfs_dabuf_t *bp2;
xfs_dir_leafblock_t *leaf2; xfs_dir_leafblock_t *leaf2;
...@@ -2064,9 +2063,9 @@ xfs_dir_leaf_getdents_int( ...@@ -2064,9 +2063,9 @@ xfs_dir_leaf_getdents_int(
leaf2 = bp2->data; leaf2 = bp2->data;
if (unlikely( if (unlikely(
(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) (be16_to_cpu(leaf2->hdr.info.magic)
!= XFS_DIR_LEAF_MAGIC) != XFS_DIR_LEAF_MAGIC)
|| (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT) || (be32_to_cpu(leaf2->hdr.info.back)
!= bno))) { /* GROT */ != bno))) { /* GROT */
XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)",
XFS_ERRLEVEL_LOW, mp, XFS_ERRLEVEL_LOW, mp,
......
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