Skip to content

Commit

Permalink
[XFS] endianess annotations for xfs_da_blkinfo_t
Browse files Browse the repository at this point in the history
SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25495a

Signed-off-by: Christoph Hellwig <[email protected]>
Signed-off-by: Nathan Scott <[email protected]>
  • Loading branch information
natoscott committed Mar 17, 2006
1 parent 3d693c6 commit 89da054
Show file tree
Hide file tree
Showing 9 changed files with 205 additions and 245 deletions.
17 changes: 8 additions & 9 deletions fs/xfs/xfs_attr.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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))) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand All @@ -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);
Expand Down
98 changes: 35 additions & 63 deletions fs/xfs/xfs_attr_leaf.c
Original file line number Diff line number Diff line change
Expand Up @@ -720,8 +720,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp)
int bytes, i;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);

entry = &leaf->entries[0];
bytes = sizeof(struct xfs_attr_sf_hdr);
Expand Down Expand Up @@ -766,8 +765,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
ASSERT(bp != NULL);
memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount));
leaf = (xfs_attr_leafblock_t *)tmpbuffer;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
memset(bp->data, 0, XFS_LBSIZE(dp->i_mount));

/*
Expand Down Expand Up @@ -875,8 +873,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args)
goto out;
node = bp1->data;
leaf = bp2->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
/* both on-disk, don't endian-flip twice */
node->btree[0].hashval =
leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval;
Expand Down Expand Up @@ -920,7 +917,7 @@ xfs_attr_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_ATTR_LEAF_MAGIC);
hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC);
INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount));
if (!hdr->firstused) {
INT_SET(hdr->firstused, ARCH_CONVERT,
Expand Down Expand Up @@ -1004,8 +1001,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args)
int tablesize, entsize, sum, tmp, i;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT((args->index >= 0)
&& (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT)));
hdr = &leaf->hdr;
Expand Down Expand Up @@ -1079,8 +1075,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
int tmp, i;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
hdr = &leaf->hdr;
ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE));
ASSERT((args->index >= 0)
Expand Down Expand Up @@ -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);
leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
args = state->args;

/*
Expand Down Expand Up @@ -1566,7 +1559,7 @@ xfs_attr_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_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC);
leaf = (xfs_attr_leafblock_t *)info;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes = sizeof(xfs_attr_leaf_hdr_t) +
Expand All @@ -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
* 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);
Expand All @@ -1610,13 +1603,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
* to shrink an attribute list over time.
*/
/* start with smaller blk num */
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; 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,
Expand All @@ -1630,8 +1622,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action)
bytes = state->blocksize - (state->blocksize>>2);
bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
count += INT_GET(leaf->hdr.count, ARCH_CONVERT);
bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT);
bytes -= count * sizeof(xfs_attr_leaf_entry_t);
Expand Down Expand Up @@ -1685,8 +1676,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_mount_t *mp;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
hdr = &leaf->hdr;
mp = args->trans->t_mountp;
ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0)
Expand Down Expand Up @@ -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);
drop_leaf = drop_blk->bp->data;
save_leaf = save_blk->bp->data;
ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
drop_hdr = &drop_leaf->hdr;
save_hdr = &save_leaf->hdr;

Expand Down Expand Up @@ -1972,8 +1960,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
xfs_dahash_t hashval;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
< (XFS_LBSIZE(args->dp->i_mount)/8));

Expand Down Expand Up @@ -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;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT)
< (XFS_LBSIZE(args->dp->i_mount)/8));
ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT)));
Expand Down Expand Up @@ -2159,10 +2145,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
/*
* Set up environment.
*/
ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
hdr_s = &leaf_s->hdr;
hdr_d = &leaf_d->hdr;
ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0)
Expand Down Expand Up @@ -2301,10 +2285,8 @@ xfs_attr_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_ATTR_LEAF_MAGIC) &&
(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC));
ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) &&
(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_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) <
Expand All @@ -2327,8 +2309,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count)
xfs_attr_leafblock_t *leaf;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
if (count)
*count = INT_GET(leaf->hdr.count, ARCH_CONVERT);
if (!leaf->hdr.count)
Expand All @@ -2348,8 +2329,7 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
xfs_attr_leaf_name_remote_t *name_rmt;
int size;

ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
if (leaf->entries[index].flags & XFS_ATTR_LOCAL) {
name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index);
size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen,
Expand Down Expand Up @@ -2596,8 +2576,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
ASSERT(bp != NULL);

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ];
Expand Down Expand Up @@ -2663,8 +2642,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args)
ASSERT(bp != NULL);

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT));
ASSERT(args->index >= 0);
entry = &leaf->entries[ args->index ];
Expand Down Expand Up @@ -2736,15 +2714,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
}

leaf1 = bp1->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT));
ASSERT(args->index >= 0);
entry1 = &leaf1->entries[ args->index ];

leaf2 = bp2->data;
ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);
ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT));
ASSERT(args->index2 >= 0);
entry2 = &leaf2->entries[ args->index2 ];
Expand Down Expand Up @@ -2842,9 +2818,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp)
* This is a depth-first traversal!
*/
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);
} 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);
} else {
error = XFS_ERROR(EIO);
Expand Down Expand Up @@ -2892,8 +2868,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp,
}

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);
parent_blkno = xfs_da_blkno(bp); /* save for re-read later */
count = INT_GET(node->hdr.count, ARCH_CONVERT);
if (!count) {
Expand Down Expand Up @@ -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.
*/
info = child_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,
child_bp, level+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,
child_bp);
} else {
Expand Down Expand Up @@ -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;

leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT)
== XFS_ATTR_LEAF_MAGIC);
ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC);

/*
* Count the number of "remote" value extents.
Expand Down
Loading

0 comments on commit 89da054

Please sign in to comment.