Commit a818e5de authored by Nathan Scott's avatar Nathan Scott

[XFS] endianess annotations for xfs_dir2_leaf_hdr_t

SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25492a
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent e922fffa
...@@ -366,7 +366,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -366,7 +366,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
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(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
leaf = (xfs_dir2_leaf_t *)oldroot; leaf = (xfs_dir2_leaf_t *)oldroot;
size = (int)((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] - size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] -
(char *)leaf); (char *)leaf);
} }
memcpy(node, oldroot, size); memcpy(node, oldroot, size);
...@@ -1798,7 +1798,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1798,7 +1798,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
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 = INT_GET(dead_leaf2->ents[INT_GET(dead_leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); dead_hash = INT_GET(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval, ARCH_CONVERT);
} else { } else {
ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC);
dead_node = (xfs_da_intnode_t *)dead_info; dead_node = (xfs_da_intnode_t *)dead_info;
......
...@@ -939,7 +939,7 @@ xfs_dir2_leaf_to_block( ...@@ -939,7 +939,7 @@ xfs_dir2_leaf_to_block(
* Size of the "leaf" area in the block. * Size of the "leaf" area in the block.
*/ */
size = (uint)sizeof(block->tail) + size = (uint)sizeof(block->tail) +
(uint)sizeof(*lep) * (INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); (uint)sizeof(*lep) * (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
/* /*
* Look at the last data entry. * Look at the last data entry.
*/ */
...@@ -968,14 +968,14 @@ xfs_dir2_leaf_to_block( ...@@ -968,14 +968,14 @@ xfs_dir2_leaf_to_block(
* Initialize the block tail. * Initialize the block tail.
*/ */
btp = XFS_DIR2_BLOCK_TAIL_P(mp, block); btp = XFS_DIR2_BLOCK_TAIL_P(mp, block);
btp->count = cpu_to_be32(INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)); btp->count = cpu_to_be32(be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale));
btp->stale = 0; btp->stale = 0;
xfs_dir2_block_log_tail(tp, dbp); xfs_dir2_block_log_tail(tp, dbp);
/* /*
* Initialize the block leaf area. We compact out stale entries. * Initialize the block leaf area. We compact out stale entries.
*/ */
lep = XFS_DIR2_BLOCK_LEAF_P(btp); lep = XFS_DIR2_BLOCK_LEAF_P(btp);
for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
continue; continue;
lep[to++] = leaf->ents[from]; lep[to++] = leaf->ents[from];
......
...@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf( ...@@ -111,14 +111,14 @@ xfs_dir2_block_to_leaf(
/* /*
* Set the counts in the leaf header. * Set the counts in the leaf header.
*/ */
leaf->hdr.count = btp->count; leaf->hdr.count = cpu_to_be16(be32_to_cpu(btp->count));
leaf->hdr.stale = btp->stale; leaf->hdr.stale = cpu_to_be16(be32_to_cpu(btp->stale));
/* /*
* Could compact these but I think we always do the conversion * Could compact these but I think we always do the conversion
* after squeezing out stale entries. * after squeezing out stale entries.
*/ */
memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); memcpy(leaf->ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
xfs_dir2_leaf_log_ents(tp, lbp, 0, INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1); xfs_dir2_leaf_log_ents(tp, lbp, 0, be16_to_cpu(leaf->hdr.count) - 1);
needscan = 0; needscan = 0;
needlog = 1; needlog = 1;
/* /*
...@@ -222,7 +222,7 @@ xfs_dir2_leaf_addname( ...@@ -222,7 +222,7 @@ xfs_dir2_leaf_addname(
* in a data block, improving the lookup of those entries. * in a data block, improving the lookup of those entries.
*/ */
for (use_block = -1, lep = &leaf->ents[index]; for (use_block = -1, lep = &leaf->ents[index];
index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
index++, lep++) { index++, lep++) {
if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) if (INT_GET(lep->address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
continue; continue;
...@@ -266,15 +266,15 @@ xfs_dir2_leaf_addname( ...@@ -266,15 +266,15 @@ xfs_dir2_leaf_addname(
* If we don't have enough free bytes but we can make enough * If we don't have enough free bytes but we can make enough
* by compacting out stale entries, we'll do that. * by compacting out stale entries, we'll do that.
*/ */
if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < needbytes && if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] < needbytes &&
INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1) { be16_to_cpu(leaf->hdr.stale) > 1) {
compact = 1; compact = 1;
} }
/* /*
* Otherwise if we don't have enough free bytes we need to * Otherwise if we don't have enough free bytes we need to
* convert to node form. * convert to node form.
*/ */
else if ((char *)bestsp - (char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] < else if ((char *)bestsp - (char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <
needbytes) { needbytes) {
/* /*
* Just checking or no space reservation, give up. * Just checking or no space reservation, give up.
...@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname( ...@@ -330,8 +330,8 @@ xfs_dir2_leaf_addname(
* There are stale entries, so we'll need log-low and log-high * There are stale entries, so we'll need log-low and log-high
* impossibly bad values later. * impossibly bad values later.
*/ */
else if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) { else if (be16_to_cpu(leaf->hdr.stale)) {
lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); lfloglow = be16_to_cpu(leaf->hdr.count);
lfloghigh = -1; lfloghigh = -1;
} }
/* /*
...@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname( ...@@ -440,15 +440,15 @@ xfs_dir2_leaf_addname(
/* /*
* lep is still good as the index leaf entry. * lep is still good as the index leaf entry.
*/ */
if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) if (index < be16_to_cpu(leaf->hdr.count))
memmove(lep + 1, lep, memmove(lep + 1, lep,
(INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
/* /*
* Record low and high logging indices for the leaf. * Record low and high logging indices for the leaf.
*/ */
lfloglow = index; lfloglow = index;
lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); lfloghigh = be16_to_cpu(leaf->hdr.count);
INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); be16_add(&leaf->hdr.count, 1);
} }
/* /*
* There are stale entries. * There are stale entries.
...@@ -478,7 +478,7 @@ xfs_dir2_leaf_addname( ...@@ -478,7 +478,7 @@ xfs_dir2_leaf_addname(
* lowstale entry would be better. * lowstale entry would be better.
*/ */
for (highstale = index; for (highstale = index;
highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && highstale < be16_to_cpu(leaf->hdr.count) &&
INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
XFS_DIR2_NULL_DATAPTR && XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 || (lowstale < 0 ||
...@@ -490,7 +490,7 @@ xfs_dir2_leaf_addname( ...@@ -490,7 +490,7 @@ xfs_dir2_leaf_addname(
* If the low one is better, use it. * If the low one is better, use it.
*/ */
if (lowstale >= 0 && if (lowstale >= 0 &&
(highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale - 1 < highstale - index)) { index - lowstale - 1 < highstale - index)) {
ASSERT(index - lowstale - 1 >= 0); ASSERT(index - lowstale - 1 >= 0);
ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
...@@ -526,7 +526,7 @@ xfs_dir2_leaf_addname( ...@@ -526,7 +526,7 @@ xfs_dir2_leaf_addname(
lfloglow = MIN(index, lfloglow); lfloglow = MIN(index, lfloglow);
lfloghigh = MAX(highstale, lfloghigh); lfloghigh = MAX(highstale, lfloghigh);
} }
INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); be16_add(&leaf->hdr.stale, -1);
} }
/* /*
* Fill in the new leaf entry. * Fill in the new leaf entry.
...@@ -569,24 +569,24 @@ xfs_dir2_leaf_check( ...@@ -569,24 +569,24 @@ xfs_dir2_leaf_check(
* Should factor in the size of the bests table as well. * Should factor in the size of the bests table as well.
* We can deduce a value for that from di_size. * We can deduce a value for that from di_size.
*/ */
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf);
/* /*
* Leaves and bests don't overlap. * Leaves and bests don't overlap.
*/ */
ASSERT((char *)&leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT)] <= ASSERT((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] <=
(char *)XFS_DIR2_LEAF_BESTS_P(ltp)); (char *)XFS_DIR2_LEAF_BESTS_P(ltp));
/* /*
* Check hash value order, count stale entries. * Check hash value order, count stale entries.
*/ */
for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) if (i + 1 < be16_to_cpu(leaf->hdr.count))
ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
stale++; stale++;
} }
ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
} }
#endif /* DEBUG */ #endif /* DEBUG */
...@@ -611,7 +611,7 @@ xfs_dir2_leaf_compact( ...@@ -611,7 +611,7 @@ xfs_dir2_leaf_compact(
/* /*
* Compress out the stale entries in place. * Compress out the stale entries in place.
*/ */
for (from = to = 0, loglow = -1; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { for (from = to = 0, loglow = -1; from < be16_to_cpu(leaf->hdr.count); from++) {
if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) if (INT_GET(leaf->ents[from].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
continue; continue;
/* /*
...@@ -627,8 +627,8 @@ xfs_dir2_leaf_compact( ...@@ -627,8 +627,8 @@ xfs_dir2_leaf_compact(
/* /*
* Update and log the header, log the leaf entries. * Update and log the header, log the leaf entries.
*/ */
ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == from - to); ASSERT(be16_to_cpu(leaf->hdr.stale) == from - to);
INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(INT_GET(leaf->hdr.stale, ARCH_CONVERT))); be16_add(&leaf->hdr.count, -(be16_to_cpu(leaf->hdr.stale)));
leaf->hdr.stale = 0; leaf->hdr.stale = 0;
xfs_dir2_leaf_log_header(args->trans, bp); xfs_dir2_leaf_log_header(args->trans, bp);
if (loglow != -1) if (loglow != -1)
...@@ -662,7 +662,7 @@ xfs_dir2_leaf_compact_x1( ...@@ -662,7 +662,7 @@ xfs_dir2_leaf_compact_x1(
int to; /* destination copy index */ int to; /* destination copy index */
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1); ASSERT(be16_to_cpu(leaf->hdr.stale) > 1);
index = *indexp; index = *indexp;
/* /*
* Find the first stale entry before our index, if any. * Find the first stale entry before our index, if any.
...@@ -677,7 +677,7 @@ xfs_dir2_leaf_compact_x1( ...@@ -677,7 +677,7 @@ xfs_dir2_leaf_compact_x1(
* Stop if the answer would be worse than lowstale. * Stop if the answer would be worse than lowstale.
*/ */
for (highstale = index; for (highstale = index;
highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && highstale < be16_to_cpu(leaf->hdr.count) &&
INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR && INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 || index - lowstale > highstale - index); (lowstale < 0 || index - lowstale > highstale - index);
highstale++) highstale++)
...@@ -686,7 +686,7 @@ xfs_dir2_leaf_compact_x1( ...@@ -686,7 +686,7 @@ xfs_dir2_leaf_compact_x1(
* Pick the better of lowstale and highstale. * Pick the better of lowstale and highstale.
*/ */
if (lowstale >= 0 && if (lowstale >= 0 &&
(highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale <= highstale - index)) index - lowstale <= highstale - index))
keepstale = lowstale; keepstale = lowstale;
else else
...@@ -695,7 +695,7 @@ xfs_dir2_leaf_compact_x1( ...@@ -695,7 +695,7 @@ xfs_dir2_leaf_compact_x1(
* Copy the entries in place, removing all the stale entries * Copy the entries in place, removing all the stale entries
* except keepstale. * except keepstale.
*/ */
for (from = to = 0; from < INT_GET(leaf->hdr.count, ARCH_CONVERT); from++) { for (from = to = 0; from < be16_to_cpu(leaf->hdr.count); from++) {
/* /*
* Notice the new value of index. * Notice the new value of index.
*/ */
...@@ -730,8 +730,8 @@ xfs_dir2_leaf_compact_x1( ...@@ -730,8 +730,8 @@ xfs_dir2_leaf_compact_x1(
/* /*
* Adjust the leaf header values. * Adjust the leaf header values.
*/ */
INT_MOD(leaf->hdr.count, ARCH_CONVERT, -(from - to)); be16_add(&leaf->hdr.count, -(from - to));
INT_SET(leaf->hdr.stale, ARCH_CONVERT, 1); leaf->hdr.stale = cpu_to_be16(1);
/* /*
* Remember the low/high stale value only in the "right" * Remember the low/high stale value only in the "right"
* direction. * direction.
...@@ -739,8 +739,8 @@ xfs_dir2_leaf_compact_x1( ...@@ -739,8 +739,8 @@ xfs_dir2_leaf_compact_x1(
if (lowstale >= newindex) if (lowstale >= newindex)
lowstale = -1; lowstale = -1;
else else
highstale = INT_GET(leaf->hdr.count, ARCH_CONVERT); highstale = be16_to_cpu(leaf->hdr.count);
*highlogp = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1; *highlogp = be16_to_cpu(leaf->hdr.count) - 1;
*lowstalep = lowstale; *lowstalep = lowstale;
*highstalep = highstale; *highstalep = highstale;
} }
...@@ -1373,7 +1373,7 @@ xfs_dir2_leaf_lookup_int( ...@@ -1373,7 +1373,7 @@ xfs_dir2_leaf_lookup_int(
* looking to match the name. * looking to match the name.
*/ */
for (lep = &leaf->ents[index], dbp = NULL, curdb = -1; for (lep = &leaf->ents[index], dbp = NULL, curdb = -1;
index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
lep++, index++) { lep++, index++) {
/* /*
* Skip over stale leaf entries. * Skip over stale leaf entries.
...@@ -1488,7 +1488,7 @@ xfs_dir2_leaf_removename( ...@@ -1488,7 +1488,7 @@ xfs_dir2_leaf_removename(
/* /*
* We just mark the leaf entry stale by putting a null in it. * We just mark the leaf entry stale by putting a null in it.
*/ */
INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); be16_add(&leaf->hdr.stale, 1);
xfs_dir2_leaf_log_header(tp, lbp); xfs_dir2_leaf_log_header(tp, lbp);
INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
xfs_dir2_leaf_log_ents(tp, lbp, index, index); xfs_dir2_leaf_log_ents(tp, lbp, index, index);
...@@ -1645,7 +1645,7 @@ xfs_dir2_leaf_search_hash( ...@@ -1645,7 +1645,7 @@ xfs_dir2_leaf_search_hash(
* Note, the table cannot be empty, so we have to go through the loop. * Note, the table cannot be empty, so we have to go through the loop.
* Binary search the leaf entries looking for our hash value. * Binary search the leaf entries looking for our hash value.
*/ */
for (lep = leaf->ents, low = 0, high = INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1, for (lep = leaf->ents, low = 0, high = be16_to_cpu(leaf->hdr.count) - 1,
hashwant = args->hashval; hashwant = args->hashval;
low <= high; ) { low <= high; ) {
mid = (low + high) >> 1; mid = (low + high) >> 1;
...@@ -1821,7 +1821,7 @@ xfs_dir2_node_to_leaf( ...@@ -1821,7 +1821,7 @@ xfs_dir2_node_to_leaf(
* If not, release the buffer and give up. * If not, release the buffer and give up.
*/ */
if ((uint)sizeof(leaf->hdr) + if ((uint)sizeof(leaf->hdr) +
(INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT)) * (uint)sizeof(leaf->ents[0]) + (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale)) * (uint)sizeof(leaf->ents[0]) +
be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) + be32_to_cpu(free->hdr.nvalid) * (uint)sizeof(leaf->bests[0]) +
(uint)sizeof(leaf->tail) > (uint)sizeof(leaf->tail) >
mp->m_dirblksize) { mp->m_dirblksize) {
...@@ -1832,7 +1832,7 @@ xfs_dir2_node_to_leaf( ...@@ -1832,7 +1832,7 @@ xfs_dir2_node_to_leaf(
* If the leaf has any stale entries in it, compress them out. * If the leaf has any stale entries in it, compress them out.
* The compact routine will log the header. * The compact routine will log the header.
*/ */
if (INT_GET(leaf->hdr.stale, ARCH_CONVERT)) if (be16_to_cpu(leaf->hdr.stale))
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);
......
...@@ -46,8 +46,8 @@ typedef __uint32_t xfs_dir2_dataptr_t; ...@@ -46,8 +46,8 @@ typedef __uint32_t xfs_dir2_dataptr_t;
*/ */
typedef struct xfs_dir2_leaf_hdr { typedef struct xfs_dir2_leaf_hdr {
xfs_da_blkinfo_t info; /* header for da routines */ xfs_da_blkinfo_t info; /* header for da routines */
__uint16_t count; /* count of entries */ __be16 count; /* count of entries */
__uint16_t stale; /* count of stale entries */ __be16 stale; /* count of stale entries */
} xfs_dir2_leaf_hdr_t; } xfs_dir2_leaf_hdr_t;
/* /*
......
...@@ -217,14 +217,14 @@ xfs_dir2_leafn_add( ...@@ -217,14 +217,14 @@ xfs_dir2_leafn_add(
* a compact. * a compact.
*/ */
if (INT_GET(leaf->hdr.count, ARCH_CONVERT) == XFS_DIR2_MAX_LEAF_ENTS(mp)) { if (be16_to_cpu(leaf->hdr.count) == XFS_DIR2_MAX_LEAF_ENTS(mp)) {
if (!leaf->hdr.stale) if (!leaf->hdr.stale)
return XFS_ERROR(ENOSPC); return XFS_ERROR(ENOSPC);
compact = INT_GET(leaf->hdr.stale, ARCH_CONVERT) > 1; compact = be16_to_cpu(leaf->hdr.stale) > 1;
} else } else
compact = 0; compact = 0;
ASSERT(index == 0 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval); ASSERT(index == 0 || INT_GET(leaf->ents[index - 1].hashval, ARCH_CONVERT) <= args->hashval);
ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || ASSERT(index == be16_to_cpu(leaf->hdr.count) ||
INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval); INT_GET(leaf->ents[index].hashval, ARCH_CONVERT) >= args->hashval);
if (args->justcheck) if (args->justcheck)
...@@ -242,7 +242,7 @@ xfs_dir2_leafn_add( ...@@ -242,7 +242,7 @@ xfs_dir2_leafn_add(
* Set impossible logging indices for this case. * Set impossible logging indices for this case.
*/ */
else if (leaf->hdr.stale) { else if (leaf->hdr.stale) {
lfloglow = INT_GET(leaf->hdr.count, ARCH_CONVERT); lfloglow = be16_to_cpu(leaf->hdr.count);
lfloghigh = -1; lfloghigh = -1;
} }
/* /*
...@@ -250,12 +250,12 @@ xfs_dir2_leafn_add( ...@@ -250,12 +250,12 @@ xfs_dir2_leafn_add(
*/ */
if (!leaf->hdr.stale) { if (!leaf->hdr.stale) {
lep = &leaf->ents[index]; lep = &leaf->ents[index];
if (index < INT_GET(leaf->hdr.count, ARCH_CONVERT)) if (index < be16_to_cpu(leaf->hdr.count))
memmove(lep + 1, lep, memmove(lep + 1, lep,
(INT_GET(leaf->hdr.count, ARCH_CONVERT) - index) * sizeof(*lep)); (be16_to_cpu(leaf->hdr.count) - index) * sizeof(*lep));
lfloglow = index; lfloglow = index;
lfloghigh = INT_GET(leaf->hdr.count, ARCH_CONVERT); lfloghigh = be16_to_cpu(leaf->hdr.count);
INT_MOD(leaf->hdr.count, ARCH_CONVERT, +1); be16_add(&leaf->hdr.count, 1);
} }
/* /*
* There are stale entries. We'll use one for the new entry. * There are stale entries. We'll use one for the new entry.
...@@ -281,7 +281,7 @@ xfs_dir2_leafn_add( ...@@ -281,7 +281,7 @@ xfs_dir2_leafn_add(
* lowstale already found. * lowstale already found.
*/ */
for (highstale = index; for (highstale = index;
highstale < INT_GET(leaf->hdr.count, ARCH_CONVERT) && highstale < be16_to_cpu(leaf->hdr.count) &&
INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) != INT_GET(leaf->ents[highstale].address, ARCH_CONVERT) !=
XFS_DIR2_NULL_DATAPTR && XFS_DIR2_NULL_DATAPTR &&
(lowstale < 0 || (lowstale < 0 ||
...@@ -294,7 +294,7 @@ xfs_dir2_leafn_add( ...@@ -294,7 +294,7 @@ xfs_dir2_leafn_add(
* Shift entries up toward the stale slot. * Shift entries up toward the stale slot.
*/ */
if (lowstale >= 0 && if (lowstale >= 0 &&
(highstale == INT_GET(leaf->hdr.count, ARCH_CONVERT) || (highstale == be16_to_cpu(leaf->hdr.count) ||
index - lowstale - 1 < highstale - index)) { index - lowstale - 1 < highstale - index)) {
ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) == ASSERT(INT_GET(leaf->ents[lowstale].address, ARCH_CONVERT) ==
XFS_DIR2_NULL_DATAPTR); XFS_DIR2_NULL_DATAPTR);
...@@ -323,7 +323,7 @@ xfs_dir2_leafn_add( ...@@ -323,7 +323,7 @@ xfs_dir2_leafn_add(
lfloglow = MIN(index, lfloglow); lfloglow = MIN(index, lfloglow);
lfloghigh = MAX(highstale, lfloghigh); lfloghigh = MAX(highstale, lfloghigh);
} }
INT_MOD(leaf->hdr.stale, ARCH_CONVERT, -1); be16_add(&leaf->hdr.stale, -1);
} }
/* /*
* Insert the new entry, log everything. * Insert the new entry, log everything.
...@@ -353,16 +353,16 @@ xfs_dir2_leafn_check( ...@@ -353,16 +353,16 @@ 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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp));
for (i = stale = 0; i < INT_GET(leaf->hdr.count, ARCH_CONVERT); i++) { for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) {
if (i + 1 < INT_GET(leaf->hdr.count, ARCH_CONVERT)) { if (i + 1 < be16_to_cpu(leaf->hdr.count)) {
ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <= ASSERT(INT_GET(leaf->ents[i].hashval, ARCH_CONVERT) <=
INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT)); INT_GET(leaf->ents[i + 1].hashval, ARCH_CONVERT));
} }
if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR) if (INT_GET(leaf->ents[i].address, ARCH_CONVERT) == XFS_DIR2_NULL_DATAPTR)
stale++; stale++;
} }
ASSERT(INT_GET(leaf->hdr.stale, ARCH_CONVERT) == stale); ASSERT(be16_to_cpu(leaf->hdr.stale) == stale);
} }
#endif /* DEBUG */ #endif /* DEBUG */
...@@ -380,10 +380,10 @@ xfs_dir2_leafn_lasthash( ...@@ -380,10 +380,10 @@ xfs_dir2_leafn_lasthash(
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
if (count) if (count)
*count = INT_GET(leaf->hdr.count, ARCH_CONVERT); *count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count) if (!leaf->hdr.count)
return 0; return 0;
return INT_GET(leaf->ents[INT_GET(leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); return INT_GET(leaf->ents[be16_to_cpu(leaf->hdr.count) - 1].hashval, ARCH_CONVERT);
} }
/* /*
...@@ -421,7 +421,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -421,7 +421,7 @@ xfs_dir2_leafn_lookup_int(
leaf = bp->data; leaf = bp->data;
ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
#ifdef __KERNEL__ #ifdef __KERNEL__
ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) > 0); ASSERT(be16_to_cpu(leaf->hdr.count) > 0);
#endif #endif
xfs_dir2_leafn_check(dp, bp); xfs_dir2_leafn_check(dp, bp);
/* /*
...@@ -456,7 +456,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -456,7 +456,7 @@ xfs_dir2_leafn_lookup_int(
* Loop over leaf entries with the right hash value. * Loop over leaf entries with the right hash value.
*/ */
for (lep = &leaf->ents[index]; for (lep = &leaf->ents[index];
index < INT_GET(leaf->hdr.count, ARCH_CONVERT) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval; index < be16_to_cpu(leaf->hdr.count) && INT_GET(lep->hashval, ARCH_CONVERT) == args->hashval;
lep++, index++) { lep++, index++) {
/* /*
* Skip stale leaf entries. * Skip stale leaf entries.
...@@ -619,7 +619,7 @@ xfs_dir2_leafn_lookup_int( ...@@ -619,7 +619,7 @@ xfs_dir2_leafn_lookup_int(
* Return the final index, that will be the insertion point. * Return the final index, that will be the insertion point.
*/ */
*indexp = index; *indexp = index;
ASSERT(index == INT_GET(leaf->hdr.count, ARCH_CONVERT) || args->oknoent); ASSERT(index == be16_to_cpu(leaf->hdr.count) || args->oknoent);
return XFS_ERROR(ENOENT); return XFS_ERROR(ENOENT);
} }
...@@ -657,12 +657,12 @@ xfs_dir2_leafn_moveents( ...@@ -657,12 +657,12 @@ xfs_dir2_leafn_moveents(
* destination leaf entries, open up a hole in the destination * destination leaf entries, open up a hole in the destination
* to hold the new entries. * to hold the new entries.
*/ */
if (start_d < INT_GET(leaf_d->hdr.count, ARCH_CONVERT)) { if (start_d < be16_to_cpu(leaf_d->hdr.count)) {
memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d], memmove(&leaf_d->ents[start_d + count], &leaf_d->ents[start_d],
(INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - start_d) * (be16_to_cpu(leaf_d->hdr.count) - start_d) *
sizeof(xfs_dir2_leaf_entry_t)); sizeof(xfs_dir2_leaf_entry_t));
xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count, xfs_dir2_leaf_log_ents(tp, bp_d, start_d + count,
count + INT_GET(leaf_d->hdr.count, ARCH_CONVERT) - 1); count + be16_to_cpu(leaf_d->hdr.count) - 1);
} }
/* /*
* If the source has stale leaves, count the ones in the copy range * If the source has stale leaves, count the ones in the copy range
...@@ -687,7 +687,7 @@ xfs_dir2_leafn_moveents( ...@@ -687,7 +687,7 @@ xfs_dir2_leafn_moveents(
* If there are source entries after the ones we copied, * If there are source entries after the ones we copied,
* delete the ones we copied by sliding the next ones down. * delete the ones we copied by sliding the next ones down.
*/ */
if (start_s + count < INT_GET(leaf_s->hdr.count, ARCH_CONVERT)) { if (start_s + count < be16_to_cpu(leaf_s->hdr.count)) {
memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count], memmove(&leaf_s->ents[start_s], &leaf_s->ents[start_s + count],
count * sizeof(xfs_dir2_leaf_entry_t)); count * sizeof(xfs_dir2_leaf_entry_t));
xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1); xfs_dir2_leaf_log_ents(tp, bp_s, start_s, start_s + count - 1);
...@@ -695,10 +695,10 @@ xfs_dir2_leafn_moveents( ...@@ -695,10 +695,10 @@ xfs_dir2_leafn_moveents(
/* /*
* Update the headers and log them. * Update the headers and log them.
*/ */
INT_MOD(leaf_s->hdr.count, ARCH_CONVERT, -(count)); be16_add(&leaf_s->hdr.count, -(count));
INT_MOD(leaf_s->hdr.stale, ARCH_CONVERT, -(stale)); be16_add(&leaf_s->hdr.stale, -(stale));
INT_MOD(leaf_d->hdr.count, ARCH_CONVERT, count); be16_add(&leaf_d->hdr.count, count);
INT_MOD(leaf_d->hdr.stale, ARCH_CONVERT, stale); be16_add(&leaf_d->hdr.stale, stale);
xfs_dir2_leaf_log_header(tp, bp_s); xfs_dir2_leaf_log_header(tp, bp_s);
xfs_dir2_leaf_log_header(tp, bp_d); xfs_dir2_leaf_log_header(tp, bp_d);
xfs_dir2_leafn_check(args->dp, bp_s); xfs_dir2_leafn_check(args->dp, bp_s);
...@@ -721,11 +721,11 @@ xfs_dir2_leafn_order( ...@@ -721,11 +721,11 @@ xfs_dir2_leafn_order(
leaf2 = leaf2_bp->data; leaf2 = leaf2_bp->data;
ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); 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(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0 && if (be16_to_cpu(leaf1->hdr.count) > 0 &&
INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0 && be16_to_cpu(leaf2->hdr.count) > 0 &&
(INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) || (INT_GET(leaf2->ents[0].hashval, ARCH_CONVERT) < INT_GET(leaf1->ents[0].hashval, ARCH_CONVERT) ||
INT_GET(leaf2->ents[INT_GET(leaf2->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT) < INT_GET(leaf2->ents[be16_to_cpu(leaf2->hdr.count) - 1].hashval, ARCH_CONVERT) <
INT_GET(leaf1->ents[INT_GET(leaf1->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT))) INT_GET(leaf1->ents[be16_to_cpu(leaf1->hdr.count) - 1].hashval, ARCH_CONVERT)))
return 1; return 1;
return 0; return 0;
} }
...@@ -768,9 +768,9 @@ xfs_dir2_leafn_rebalance( ...@@ -768,9 +768,9 @@ xfs_dir2_leafn_rebalance(
} }
leaf1 = blk1->bp->data; leaf1 = blk1->bp->data;
leaf2 = blk2->bp->data; leaf2 = blk2->bp->data;
oldsum = INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT); oldsum = be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count);
#ifdef DEBUG #ifdef DEBUG
oldstale = INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT); oldstale = be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale);
#endif #endif
mid = oldsum >> 1; mid = oldsum >> 1;
/* /*
...@@ -780,8 +780,8 @@ xfs_dir2_leafn_rebalance( ...@@ -780,8 +780,8 @@ xfs_dir2_leafn_rebalance(
if (oldsum & 1) { if (oldsum & 1) {
xfs_dahash_t midhash; /* middle entry hash value */ xfs_dahash_t midhash; /* middle entry hash value */
if (mid >= INT_GET(leaf1->hdr.count, ARCH_CONVERT)) if (mid >= be16_to_cpu(leaf1->hdr.count))
midhash = INT_GET(leaf2->ents[mid - INT_GET(leaf1->hdr.count, ARCH_CONVERT)].hashval, ARCH_CONVERT); midhash = INT_GET(leaf2->ents[mid - be16_to_cpu(leaf1->hdr.count)].hashval, ARCH_CONVERT);
else else
midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT); midhash = INT_GET(leaf1->ents[mid].hashval, ARCH_CONVERT);
isleft = args->hashval <= midhash; isleft = args->hashval <= midhash;
...@@ -797,30 +797,30 @@ xfs_dir2_leafn_rebalance( ...@@ -797,30 +797,30 @@ xfs_dir2_leafn_rebalance(
* Calculate moved entry count. Positive means left-to-right, * Calculate moved entry count. Positive means left-to-right,
* negative means right-to-left. Then move the entries. * negative means right-to-left. Then move the entries.
*/ */
count = INT_GET(leaf1->hdr.count, ARCH_CONVERT) - mid + (isleft == 0); count = be16_to_cpu(leaf1->hdr.count) - mid + (isleft == 0);
if (count > 0) if (count > 0)
xfs_dir2_leafn_moveents(args, blk1->bp, xfs_dir2_leafn_moveents(args, blk1->bp,
INT_GET(leaf1->hdr.count, ARCH_CONVERT) - count, blk2->bp, 0, count); be16_to_cpu(leaf1->hdr.count) - count, blk2->bp, 0, count);
else if (count < 0) else if (count < 0)
xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp, xfs_dir2_leafn_moveents(args, blk2->bp, 0, blk1->bp,
INT_GET(leaf1->hdr.count, ARCH_CONVERT), count); be16_to_cpu(leaf1->hdr.count), count);
ASSERT(INT_GET(leaf1->hdr.count, ARCH_CONVERT) + INT_GET(leaf2->hdr.count, ARCH_CONVERT) == oldsum); ASSERT(be16_to_cpu(leaf1->hdr.count) + be16_to_cpu(leaf2->hdr.count) == oldsum);
ASSERT(INT_GET(leaf1->hdr.stale, ARCH_CONVERT) + INT_GET(leaf2->hdr.stale, ARCH_CONVERT) == oldstale); ASSERT(be16_to_cpu(leaf1->hdr.stale) + be16_to_cpu(leaf2->hdr.stale) == oldstale);
/* /*
* Mark whether we're inserting into the old or new leaf. * Mark whether we're inserting into the old or new leaf.
*/ */
if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) < INT_GET(leaf2->hdr.count, ARCH_CONVERT)) if (be16_to_cpu(leaf1->hdr.count) < be16_to_cpu(leaf2->hdr.count))
state->inleaf = swap; state->inleaf = swap;
else if (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > INT_GET(leaf2->hdr.count, ARCH_CONVERT)) else if (be16_to_cpu(leaf1->hdr.count) > be16_to_cpu(leaf2->hdr.count))
state->inleaf = !swap; state->inleaf = !swap;
else else
state->inleaf = state->inleaf =
swap ^ (blk1->index <= INT_GET(leaf1->hdr.count, ARCH_CONVERT)); swap ^ (blk1->index <= be16_to_cpu(leaf1->hdr.count));
/* /*
* Adjust the expected index for insertion. * Adjust the expected index for insertion.
*/ */
if (!state->inleaf) if (!state->inleaf)
blk2->index = blk1->index - INT_GET(leaf1->hdr.count, ARCH_CONVERT); blk2->index = blk1->index - be16_to_cpu(leaf1->hdr.count);
/* /*
* Finally sanity check just to make sure we are not returning a negative index * Finally sanity check just to make sure we are not returning a negative index
...@@ -883,7 +883,7 @@ xfs_dir2_leafn_remove( ...@@ -883,7 +883,7 @@ xfs_dir2_leafn_remove(
* Kill the leaf entry by marking it stale. * Kill the leaf entry by marking it stale.
* Log the leaf block changes. * Log the leaf block changes.
*/ */
INT_MOD(leaf->hdr.stale, ARCH_CONVERT, +1); be16_add(&leaf->hdr.stale, 1);
xfs_dir2_leaf_log_header(tp, bp); xfs_dir2_leaf_log_header(tp, bp);
INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR); INT_SET(lep->address, ARCH_CONVERT, XFS_DIR2_NULL_DATAPTR);
xfs_dir2_leaf_log_ents(tp, bp, index, index); xfs_dir2_leaf_log_ents(tp, bp, index, index);
...@@ -1039,7 +1039,7 @@ xfs_dir2_leafn_remove( ...@@ -1039,7 +1039,7 @@ xfs_dir2_leafn_remove(
*rval = *rval =
((uint)sizeof(leaf->hdr) + ((uint)sizeof(leaf->hdr) +
(uint)sizeof(leaf->ents[0]) * (uint)sizeof(leaf->ents[0]) *
(INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT))) < (be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale))) <
mp->m_dir_magicpct; mp->m_dir_magicpct;
return 0; return 0;
} }
...@@ -1140,7 +1140,7 @@ xfs_dir2_leafn_toosmall( ...@@ -1140,7 +1140,7 @@ xfs_dir2_leafn_toosmall(
info = blk->bp->data; info = blk->bp->data;
ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
leaf = (xfs_dir2_leaf_t *)info; leaf = (xfs_dir2_leaf_t *)info;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 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]);
if (bytes > (state->blocksize >> 1)) { if (bytes > (state->blocksize >> 1)) {
/* /*
...@@ -1194,11 +1194,11 @@ xfs_dir2_leafn_toosmall( ...@@ -1194,11 +1194,11 @@ xfs_dir2_leafn_toosmall(
* Count bytes in the two blocks combined. * Count bytes in the two blocks combined.
*/ */
leaf = (xfs_dir2_leaf_t *)info; leaf = (xfs_dir2_leaf_t *)info;
count = INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 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(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC);
count += INT_GET(leaf->hdr.count, ARCH_CONVERT) - INT_GET(leaf->hdr.stale, ARCH_CONVERT); 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]);
/* /*
* Fits with at least 25% to spare. * Fits with at least 25% to spare.
...@@ -1262,21 +1262,21 @@ xfs_dir2_leafn_unbalance( ...@@ -1262,21 +1262,21 @@ xfs_dir2_leafn_unbalance(
* 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.
*/ */
if (INT_GET(drop_leaf->hdr.stale, ARCH_CONVERT)) if (drop_leaf->hdr.stale)
xfs_dir2_leaf_compact(args, drop_blk->bp); xfs_dir2_leaf_compact(args, drop_blk->bp);
if (INT_GET(save_leaf->hdr.stale, ARCH_CONVERT)) if (save_leaf->hdr.stale)
xfs_dir2_leaf_compact(args, save_blk->bp); xfs_dir2_leaf_compact(args, save_blk->bp);
/* /*
* Move the entries from drop to the appropriate end of save. * Move the entries from drop to the appropriate end of save.
*/ */
drop_blk->hashval = INT_GET(drop_leaf->ents[INT_GET(drop_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); drop_blk->hashval = INT_GET(drop_leaf->ents[be16_to_cpu(drop_leaf->hdr.count) - 1].hashval, ARCH_CONVERT);
if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp)) if (xfs_dir2_leafn_order(save_blk->bp, drop_blk->bp))
xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0, xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, 0,
INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); be16_to_cpu(drop_leaf->hdr.count));
else else
xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp, xfs_dir2_leafn_moveents(args, drop_blk->bp, 0, save_blk->bp,
INT_GET(save_leaf->hdr.count, ARCH_CONVERT), INT_GET(drop_leaf->hdr.count, ARCH_CONVERT)); be16_to_cpu(save_leaf->hdr.count), be16_to_cpu(drop_leaf->hdr.count));
save_blk->hashval = INT_GET(save_leaf->ents[INT_GET(save_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); save_blk->hashval = INT_GET(save_leaf->ents[be16_to_cpu(save_leaf->hdr.count) - 1].hashval, ARCH_CONVERT);
xfs_dir2_leafn_check(args->dp, save_blk->bp); xfs_dir2_leafn_check(args->dp, save_blk->bp);
} }
......
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