Commit 70e73f59 authored by Nathan Scott's avatar Nathan Scott

[XFS] endianess annotations for xfs_dir2_data_hdr structure.

SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25484a
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent 9cea2364
...@@ -2204,7 +2204,7 @@ xfs_da_do_buf( ...@@ -2204,7 +2204,7 @@ xfs_da_do_buf(
data = rbp->data; data = rbp->data;
free = rbp->data; free = rbp->data;
magic = INT_GET(info->magic, ARCH_CONVERT); magic = INT_GET(info->magic, ARCH_CONVERT);
magic1 = INT_GET(data->hdr.magic, ARCH_CONVERT); 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) &&
(magic != XFS_DIR_LEAF_MAGIC) && (magic != XFS_DIR_LEAF_MAGIC) &&
......
...@@ -100,8 +100,7 @@ xfs_dir2_block_addname( ...@@ -100,8 +100,7 @@ xfs_dir2_block_addname(
/* /*
* Check the magic number, corrupted if wrong. * Check the magic number, corrupted if wrong.
*/ */
if (unlikely(INT_GET(block->hdr.magic, ARCH_CONVERT) if (unlikely(be32_to_cpu(block->hdr.magic) != XFS_DIR2_BLOCK_MAGIC)) {
!= XFS_DIR2_BLOCK_MAGIC)) {
XFS_CORRUPTION_ERROR("xfs_dir2_block_addname", XFS_CORRUPTION_ERROR("xfs_dir2_block_addname",
XFS_ERRLEVEL_LOW, mp, block); XFS_ERRLEVEL_LOW, mp, block);
xfs_da_brelse(tp, bp); xfs_da_brelse(tp, bp);
...@@ -138,7 +137,7 @@ xfs_dir2_block_addname( ...@@ -138,7 +137,7 @@ xfs_dir2_block_addname(
*/ */
else { else {
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); ((char *)block + be16_to_cpu(bf[0].offset));
if (dup == enddup) { if (dup == enddup) {
/* /*
* It is the biggest freespace, is it too small * It is the biggest freespace, is it too small
...@@ -149,10 +148,10 @@ xfs_dir2_block_addname( ...@@ -149,10 +148,10 @@ xfs_dir2_block_addname(
* Yes, we use the second-largest * Yes, we use the second-largest
* entry instead if it works. * entry instead if it works.
*/ */
if (INT_GET(bf[1].length, ARCH_CONVERT) >= len) if (be16_to_cpu(bf[1].length) >= len)
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)block + ((char *)block +
INT_GET(bf[1].offset, ARCH_CONVERT)); be16_to_cpu(bf[1].offset));
else else
dup = NULL; dup = NULL;
} }
...@@ -172,9 +171,9 @@ xfs_dir2_block_addname( ...@@ -172,9 +171,9 @@ xfs_dir2_block_addname(
* If there are stale entries we'll use one for the leaf. * If there are stale entries we'll use one for the leaf.
* Is the biggest entry enough to avoid compaction? * Is the biggest entry enough to avoid compaction?
*/ */
else if (INT_GET(bf[0].length, ARCH_CONVERT) >= len) { else if (be16_to_cpu(bf[0].length) >= len) {
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)block + INT_GET(bf[0].offset, ARCH_CONVERT)); ((char *)block + be16_to_cpu(bf[0].offset));
compact = 0; compact = 0;
} }
/* /*
...@@ -935,7 +934,7 @@ xfs_dir2_leaf_to_block( ...@@ -935,7 +934,7 @@ xfs_dir2_leaf_to_block(
goto out; goto out;
} }
block = dbp->data; block = dbp->data;
ASSERT(INT_GET(block->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); ASSERT(be32_to_cpu(block->hdr.magic) == XFS_DIR2_DATA_MAGIC);
/* /*
* Size of the "leaf" area in the block. * Size of the "leaf" area in the block.
*/ */
...@@ -956,7 +955,7 @@ xfs_dir2_leaf_to_block( ...@@ -956,7 +955,7 @@ xfs_dir2_leaf_to_block(
/* /*
* Start converting it to block form. * Start converting it to block form.
*/ */
INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
needlog = 1; needlog = 1;
needscan = 0; needscan = 0;
/* /*
...@@ -1095,7 +1094,7 @@ xfs_dir2_sf_to_block( ...@@ -1095,7 +1094,7 @@ xfs_dir2_sf_to_block(
return error; return error;
} }
block = bp->data; block = bp->data;
INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_BLOCK_MAGIC); block->hdr.magic = cpu_to_be32(XFS_DIR2_BLOCK_MAGIC);
/* /*
* Compute size of block "tail" area. * Compute size of block "tail" area.
*/ */
......
This diff is collapsed.
...@@ -65,8 +65,8 @@ struct xfs_trans; ...@@ -65,8 +65,8 @@ struct xfs_trans;
* The freespace will be formatted as a xfs_dir2_data_unused_t. * The freespace will be formatted as a xfs_dir2_data_unused_t.
*/ */
typedef struct xfs_dir2_data_free { typedef struct xfs_dir2_data_free {
xfs_dir2_data_off_t offset; /* start of freespace */ __be16 offset; /* start of freespace */
xfs_dir2_data_off_t length; /* length of freespace */ __be16 length; /* length of freespace */
} xfs_dir2_data_free_t; } xfs_dir2_data_free_t;
/* /*
...@@ -75,7 +75,7 @@ typedef struct xfs_dir2_data_free { ...@@ -75,7 +75,7 @@ typedef struct xfs_dir2_data_free {
* The code knows that XFS_DIR2_DATA_FD_COUNT is 3. * The code knows that XFS_DIR2_DATA_FD_COUNT is 3.
*/ */
typedef struct xfs_dir2_data_hdr { typedef struct xfs_dir2_data_hdr {
__uint32_t magic; /* XFS_DIR2_DATA_MAGIC */ __be32 magic; /* XFS_DIR2_DATA_MAGIC */
/* or XFS_DIR2_BLOCK_MAGIC */ /* or XFS_DIR2_BLOCK_MAGIC */
xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT]; xfs_dir2_data_free_t bestfree[XFS_DIR2_DATA_FD_COUNT];
} xfs_dir2_data_hdr_t; } xfs_dir2_data_hdr_t;
......
...@@ -133,7 +133,7 @@ xfs_dir2_block_to_leaf( ...@@ -133,7 +133,7 @@ xfs_dir2_block_to_leaf(
/* /*
* Fix up the block header, make it a data block. * Fix up the block header, make it a data block.
*/ */
INT_SET(block->hdr.magic, ARCH_CONVERT, XFS_DIR2_DATA_MAGIC); block->hdr.magic = cpu_to_be32(XFS_DIR2_DATA_MAGIC);
if (needscan) if (needscan)
xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog, xfs_dir2_data_freescan(mp, (xfs_dir2_data_t *)block, &needlog,
NULL); NULL);
...@@ -143,7 +143,7 @@ xfs_dir2_block_to_leaf( ...@@ -143,7 +143,7 @@ xfs_dir2_block_to_leaf(
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
INT_SET(ltp->bestcount, ARCH_CONVERT, 1); INT_SET(ltp->bestcount, ARCH_CONVERT, 1);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
INT_COPY(bestsp[0], block->hdr.bestfree[0].length, ARCH_CONVERT); bestsp[0] = block->hdr.bestfree[0].length;
/* /*
* Log the data header and leaf bests table. * Log the data header and leaf bests table.
*/ */
...@@ -372,7 +372,7 @@ xfs_dir2_leaf_addname( ...@@ -372,7 +372,7 @@ xfs_dir2_leaf_addname(
else else
xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
data = dbp->data; data = dbp->data;
INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); bestsp[use_block] = data->hdr.bestfree[0].length;
grown = 1; grown = 1;
} }
/* /*
...@@ -394,7 +394,7 @@ xfs_dir2_leaf_addname( ...@@ -394,7 +394,7 @@ xfs_dir2_leaf_addname(
* Point to the biggest freespace in our data block. * Point to the biggest freespace in our data block.
*/ */
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length); ASSERT(INT_GET(dup->length, ARCH_CONVERT) >= length);
needscan = needlog = 0; needscan = needlog = 0;
/* /*
...@@ -427,8 +427,8 @@ xfs_dir2_leaf_addname( ...@@ -427,8 +427,8 @@ xfs_dir2_leaf_addname(
* If the bests table needs to be changed, do it. * If the bests table needs to be changed, do it.
* Log the change unless we've already done that. * Log the change unless we've already done that.
*/ */
if (INT_GET(bestsp[use_block], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { if (INT_GET(bestsp[use_block], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) {
INT_COPY(bestsp[use_block], data->hdr.bestfree[0].length, ARCH_CONVERT); bestsp[use_block] = data->hdr.bestfree[0].length;
if (!grown) if (!grown)
xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block); xfs_dir2_leaf_log_bests(tp, lbp, use_block, use_block);
} }
...@@ -1477,7 +1477,7 @@ xfs_dir2_leaf_removename( ...@@ -1477,7 +1477,7 @@ xfs_dir2_leaf_removename(
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT))); ((char *)data + XFS_DIR2_DATAPTR_TO_OFF(mp, INT_GET(lep->address, ARCH_CONVERT)));
needscan = needlog = 0; needscan = needlog = 0;
oldbest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); oldbest = be16_to_cpu(data->hdr.bestfree[0].length);
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
bestsp = XFS_DIR2_LEAF_BESTS_P(ltp); bestsp = XFS_DIR2_LEAF_BESTS_P(ltp);
ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest); ASSERT(INT_GET(bestsp[db], ARCH_CONVERT) == oldbest);
...@@ -1506,15 +1506,15 @@ xfs_dir2_leaf_removename( ...@@ -1506,15 +1506,15 @@ xfs_dir2_leaf_removename(
* If the longest freespace in the data block has changed, * If the longest freespace in the data block has changed,
* put the new value in the bests table and log that. * put the new value in the bests table and log that.
*/ */
if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) != oldbest) { if (be16_to_cpu(data->hdr.bestfree[0].length) != oldbest) {
INT_COPY(bestsp[db], data->hdr.bestfree[0].length, ARCH_CONVERT); bestsp[db] = data->hdr.bestfree[0].length;
xfs_dir2_leaf_log_bests(tp, lbp, db, db); xfs_dir2_leaf_log_bests(tp, lbp, db, db);
} }
xfs_dir2_data_check(dp, dbp); xfs_dir2_data_check(dp, dbp);
/* /*
* If the data block is now empty then get rid of the data block. * If the data block is now empty then get rid of the data block.
*/ */
if (INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == if (be16_to_cpu(data->hdr.bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr)) { mp->m_dirblksize - (uint)sizeof(data->hdr)) {
ASSERT(db != mp->m_dirdatablk); ASSERT(db != mp->m_dirdatablk);
if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
...@@ -1708,7 +1708,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1708,7 +1708,7 @@ xfs_dir2_leaf_trim_data(
} }
#ifdef DEBUG #ifdef DEBUG
data = dbp->data; data = dbp->data;
ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
#endif #endif
/* this seems to be an error /* this seems to be an error
* data is only valid if DEBUG is defined? * data is only valid if DEBUG is defined?
...@@ -1717,7 +1717,7 @@ xfs_dir2_leaf_trim_data( ...@@ -1717,7 +1717,7 @@ xfs_dir2_leaf_trim_data(
leaf = lbp->data; leaf = lbp->data;
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) == ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) ==
mp->m_dirblksize - (uint)sizeof(data->hdr)); mp->m_dirblksize - (uint)sizeof(data->hdr));
ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1); ASSERT(db == INT_GET(ltp->bestcount, ARCH_CONVERT) - 1);
/* /*
......
...@@ -894,7 +894,7 @@ xfs_dir2_leafn_remove( ...@@ -894,7 +894,7 @@ xfs_dir2_leafn_remove(
dbp = dblk->bp; dbp = dblk->bp;
data = dbp->data; data = dbp->data;
dep = (xfs_dir2_data_entry_t *)((char *)data + off); dep = (xfs_dir2_data_entry_t *)((char *)data + off);
longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); longest = be16_to_cpu(data->hdr.bestfree[0].length);
needlog = needscan = 0; needlog = needscan = 0;
xfs_dir2_data_make_free(tp, dbp, off, xfs_dir2_data_make_free(tp, dbp, off,
XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan); XFS_DIR2_DATA_ENTSIZE(dep->namelen), &needlog, &needscan);
...@@ -911,7 +911,7 @@ xfs_dir2_leafn_remove( ...@@ -911,7 +911,7 @@ xfs_dir2_leafn_remove(
* If the longest data block freespace changes, need to update * If the longest data block freespace changes, need to update
* the corresponding freeblock entry. * the corresponding freeblock entry.
*/ */
if (longest < INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { if (longest < be16_to_cpu(data->hdr.bestfree[0].length)) {
int error; /* error return value */ int error; /* error return value */
xfs_dabuf_t *fbp; /* freeblock buffer */ xfs_dabuf_t *fbp; /* freeblock buffer */
xfs_dir2_db_t fdb; /* freeblock block number */ xfs_dir2_db_t fdb; /* freeblock block number */
...@@ -937,7 +937,7 @@ xfs_dir2_leafn_remove( ...@@ -937,7 +937,7 @@ xfs_dir2_leafn_remove(
* Calculate which entry we need to fix. * Calculate which entry we need to fix.
*/ */
findex = XFS_DIR2_DB_TO_FDINDEX(mp, db); findex = XFS_DIR2_DB_TO_FDINDEX(mp, db);
longest = INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT); longest = be16_to_cpu(data->hdr.bestfree[0].length);
/* /*
* If the data block is now empty we can get rid of it * If the data block is now empty we can get rid of it
* (usually). * (usually).
...@@ -1649,7 +1649,7 @@ xfs_dir2_node_addname_int( ...@@ -1649,7 +1649,7 @@ xfs_dir2_node_addname_int(
* change again. * change again.
*/ */
data = dbp->data; data = dbp->data;
INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); free->bests[findex] = data->hdr.bestfree[0].length;
logfree = 1; logfree = 1;
} }
/* /*
...@@ -1677,12 +1677,12 @@ xfs_dir2_node_addname_int( ...@@ -1677,12 +1677,12 @@ xfs_dir2_node_addname_int(
data = dbp->data; data = dbp->data;
logfree = 0; logfree = 0;
} }
ASSERT(INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT) >= length); ASSERT(be16_to_cpu(data->hdr.bestfree[0].length) >= length);
/* /*
* Point to the existing unused space. * Point to the existing unused space.
*/ */
dup = (xfs_dir2_data_unused_t *) dup = (xfs_dir2_data_unused_t *)
((char *)data + INT_GET(data->hdr.bestfree[0].offset, ARCH_CONVERT)); ((char *)data + be16_to_cpu(data->hdr.bestfree[0].offset));
needscan = needlog = 0; needscan = needlog = 0;
/* /*
* Mark the first part of the unused space, inuse for us. * Mark the first part of the unused space, inuse for us.
...@@ -1713,8 +1713,8 @@ xfs_dir2_node_addname_int( ...@@ -1713,8 +1713,8 @@ xfs_dir2_node_addname_int(
/* /*
* If the freespace entry is now wrong, update it. * If the freespace entry is now wrong, update it.
*/ */
if (INT_GET(free->bests[findex], ARCH_CONVERT) != INT_GET(data->hdr.bestfree[0].length, ARCH_CONVERT)) { if (INT_GET(free->bests[findex], ARCH_CONVERT) != be16_to_cpu(data->hdr.bestfree[0].length)) {
INT_COPY(free->bests[findex], data->hdr.bestfree[0].length, ARCH_CONVERT); free->bests[findex] = data->hdr.bestfree[0].length;
logfree = 1; logfree = 1;
} }
/* /*
...@@ -1900,7 +1900,7 @@ xfs_dir2_node_replace( ...@@ -1900,7 +1900,7 @@ xfs_dir2_node_replace(
* Point to the data entry. * Point to the data entry.
*/ */
data = state->extrablk.bp->data; data = state->extrablk.bp->data;
ASSERT(INT_GET(data->hdr.magic, ARCH_CONVERT) == XFS_DIR2_DATA_MAGIC); ASSERT(be32_to_cpu(data->hdr.magic) == XFS_DIR2_DATA_MAGIC);
dep = (xfs_dir2_data_entry_t *) dep = (xfs_dir2_data_entry_t *)
((char *)data + ((char *)data +
XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT))); XFS_DIR2_DATAPTR_TO_OFF(state->mp, INT_GET(lep->address, ARCH_CONVERT)));
......
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