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)
return(error);
ASSERT(bp != NULL);
leaf = bp->data;
if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
!= XFS_ATTR_LEAF_MAGIC)) {
if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) {
XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW,
context->dp->i_mount, leaf);
xfs_da_brelse(NULL, bp);
......@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args)
XFS_ATTR_FORK);
if (error)
goto out;
ASSERT(INT_GET(((xfs_attr_leafblock_t *)
bp->data)->hdr.info.magic, ARCH_CONVERT)
ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *)
bp->data)->hdr.info.magic)
== XFS_ATTR_LEAF_MAGIC);
if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) {
......@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(error);
if (bp) {
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:
xfs_attr_trace_l_cn("wrong blk", context, node);
xfs_da_brelse(NULL, bp);
......@@ -1817,10 +1816,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
return(XFS_ERROR(EFSCORRUPTED));
}
node = bp->data;
if (INT_GET(node->hdr.info.magic, ARCH_CONVERT)
if (be16_to_cpu(node->hdr.info.magic)
== XFS_ATTR_LEAF_MAGIC)
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_CORRUPTION_ERROR("xfs_attr_node_list(3)",
XFS_ERRLEVEL_LOW,
......@@ -1858,7 +1857,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
*/
for (;;) {
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_CORRUPTION_ERROR("xfs_attr_node_list(4)",
XFS_ERRLEVEL_LOW,
......@@ -1869,7 +1868,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
error = xfs_attr_leaf_list_int(bp, context);
if (error || !leaf->hdr.info.forw)
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);
error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1,
&bp, XFS_ATTR_FORK);
......
This diff is collapsed.
This diff is collapsed.
......@@ -45,10 +45,10 @@ struct zone;
(XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC)
typedef struct xfs_da_blkinfo {
xfs_dablk_t forw; /* previous block in list */
xfs_dablk_t back; /* following block in list */
__uint16_t magic; /* validity check on block */
__uint16_t pad; /* unused */
__be32 forw; /* previous block in list */
__be32 back; /* following block in list */
__be16 magic; /* validity check on block */
__be16 pad; /* unused */
} xfs_da_blkinfo_t;
/*
......
......@@ -634,7 +634,7 @@ xfs_dir_leaf_removename(xfs_da_args_t *args, int *count, int *totallen)
return(retval);
ASSERT(bp != NULL);
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);
if (retval == EEXIST) {
(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,
return(error);
if (bp)
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",
dp, uio, bno);
xfs_da_brelse(trans, bp);
......@@ -949,7 +949,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
if (bp == NULL)
return(XFS_ERROR(EFSCORRUPTED));
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;
btree = &node->btree[0];
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,
*/
for (;;) {
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_da_brelse(trans, bp);
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,
return XFS_ERROR(EFSCORRUPTED);
}
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,
XFS_DATA_FORK);
} else
......@@ -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 & 0xFFFFFFFF)),
(void *)(unsigned long)uio->uio_resid,
(void *)(unsigned long)
INT_GET(node->hdr.info.forw, ARCH_CONVERT),
(void *)(unsigned long)be32_to_cpu(node->hdr.info.forw),
(void *)(unsigned long)
INT_GET(node->hdr.count, ARCH_CONVERT),
(void *)(unsigned long)
......@@ -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 & 0xFFFFFFFF)),
(void *)(unsigned long)uio->uio_resid,
(void *)(unsigned long)
INT_GET(leaf->hdr.info.forw, ARCH_CONVERT),
(void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw),
(void *)(unsigned long)
INT_GET(leaf->hdr.count, ARCH_CONVERT),
(void *)(unsigned long)
......
......@@ -905,7 +905,7 @@ xfs_dir2_leaf_to_block(
tp = args->trans;
mp = dp->i_mount;
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);
/*
* If there are data blocks other than the first one, take this
......
......@@ -564,7 +564,7 @@ xfs_dir2_leaf_check(
leaf = bp->data;
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.
* Should factor in the size of the bests table as well.
......@@ -1172,7 +1172,7 @@ xfs_dir2_leaf_init(
/*
* 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.back = 0;
leaf->hdr.count = 0;
......@@ -1208,7 +1208,7 @@ xfs_dir2_leaf_log_bests(
xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
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);
firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first;
lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last;
......@@ -1231,8 +1231,8 @@ xfs_dir2_leaf_log_ents(
xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC ||
INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
firstlep = &leaf->ents[first];
lastlep = &leaf->ents[last];
xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf),
......@@ -1250,8 +1250,8 @@ xfs_dir2_leaf_log_header(
xfs_dir2_leaf_t *leaf; /* leaf structure */
leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC ||
INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC ||
be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf),
(uint)(sizeof(leaf->hdr) - 1));
}
......@@ -1270,7 +1270,7 @@ xfs_dir2_leaf_log_tail(
mp = tp->t_mountp;
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);
xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
(uint)(mp->m_dirblksize - 1));
......@@ -1806,7 +1806,7 @@ xfs_dir2_node_to_leaf(
return 0;
lbp = state->path.blk[0].bp;
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.
*/
......@@ -1837,7 +1837,7 @@ xfs_dir2_node_to_leaf(
xfs_dir2_leaf_compact(args, lbp);
else
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.
*/
......
......@@ -164,7 +164,7 @@ xfs_dir2_leaf_to_node(
*to = cpu_to_be16(off);
}
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.
*/
......@@ -353,7 +353,7 @@ xfs_dir2_leafn_check(
leaf = bp->data;
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));
for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
......@@ -379,7 +379,7 @@ xfs_dir2_leafn_lasthash(
xfs_dir2_leaf_t *leaf; /* leaf structure */
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)
*count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count)
......@@ -420,7 +420,7 @@ xfs_dir2_leafn_lookup_int(
tp = args->trans;
mp = dp->i_mount;
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__
ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
#endif
......@@ -720,8 +720,8 @@ xfs_dir2_leafn_order(
leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC);
if (be16_to_cpu(leaf1->hdr.count) > 0 &&
be16_to_cpu(leaf2->hdr.count) > 0 &&
(be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) ||
......@@ -868,7 +868,7 @@ xfs_dir2_leafn_remove(
tp = args->trans;
mp = dp->i_mount;
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.
*/
......@@ -1139,7 +1139,7 @@ xfs_dir2_leafn_toosmall(
*/
blk = &state->path.blk[state->path.active - 1];
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;
count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]);
......@@ -1161,7 +1161,7 @@ xfs_dir2_leafn_toosmall(
* Make altpath point to the block we want to keep and
* 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));
error = xfs_da_path_shift(state, &state->altpath, forward, 0,
&rval);
......@@ -1177,9 +1177,9 @@ xfs_dir2_leafn_toosmall(
* We prefer coalescing with the lower numbered sibling so as
* 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++) {
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)
continue;
/*
......@@ -1198,7 +1198,7 @@ xfs_dir2_leafn_toosmall(
count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale);
bytes = state->blocksize - (state->blocksize >> 2);
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);
bytes -= count * (uint)sizeof(leaf->ents[0]);
/*
......@@ -1257,8 +1257,8 @@ xfs_dir2_leafn_unbalance(
ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC);
drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data;
ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == 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
* to purge them.
......
......@@ -644,7 +644,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
ASSERT(bp != NULL);
memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
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));
/*
......@@ -742,7 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args)
}
node = bp1->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));
xfs_da_buf_done(bp2);
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)
leaf = bp->data;
memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount));
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));
if (!hdr->firstused)
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)
int tablesize, entsize, sum, i, tmp, error;
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)));
hdr = &leaf->hdr;
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,
int tmp, i;
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;
ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE));
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,
ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC);
leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == 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.
......@@ -1325,7 +1325,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action)
*/
blk = &state->path.blk[ state->path.active-1 ];
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;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) +
......@@ -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
* 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));
error = xfs_da_path_shift(state, &state->altpath, forward,
0, &retval);
......@@ -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
* 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++) {
if (forward)
blkno = INT_GET(info->forw, ARCH_CONVERT);
blkno = be32_to_cpu(info->forw);
else
blkno = INT_GET(info->back, ARCH_CONVERT);
blkno = be32_to_cpu(info->back);
if (blkno == 0)
continue;
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)
bytes = state->blocksize - (state->blocksize>>2);
bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
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);
bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT);
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)
xfs_mount_t *mp;
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;
mp = trans->t_mountp;
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,
ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC);
drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data;
ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
drop_hdr = &drop_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)
xfs_dahash_t hashval;
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));
/*
......@@ -1782,8 +1782,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s,
/*
* Set up environment.
*/
ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
hdr_s = &leaf_s->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)));
......@@ -1883,8 +1883,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
leaf1 = leaf1_bp->data;
leaf2 = leaf2_bp->data;
ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) &&
(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC));
ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == 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) &&
((INT_GET(leaf2->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)
xfs_dir_leafblock_t *leaf;
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)
*count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
if (!leaf->hdr.count)
......@@ -1940,7 +1940,7 @@ xfs_dir_leaf_getdents_int(
mp = dp->i_mount;
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;
return XFS_ERROR(ENOENT); /* XXX wrong code */
}
......@@ -1992,7 +1992,7 @@ xfs_dir_leaf_getdents_int(
if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) {
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 =
XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH);
/*
......@@ -2047,8 +2047,7 @@ xfs_dir_leaf_getdents_int(
xfs_dir_trace_g_duc("leaf: middle cookie ",
dp, uio, p.cook.o);
} else if ((thishash = INT_GET(leaf->hdr.info.forw,
ARCH_CONVERT))) {
} else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) {
xfs_dabuf_t *bp2;
xfs_dir_leafblock_t *leaf2;
......@@ -2064,9 +2063,9 @@ xfs_dir_leaf_getdents_int(
leaf2 = bp2->data;
if (unlikely(
(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
(be16_to_cpu(leaf2->hdr.info.magic)
!= XFS_DIR_LEAF_MAGIC)
|| (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT)
|| (be32_to_cpu(leaf2->hdr.info.back)
!= bno))) { /* GROT */
XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)",
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