Commit 1d8daf06 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Nathan Scott

[XFS] endianess annotations for xfs_dir_leaf_entry_t

SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25808a
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Signed-off-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarNathan Scott <nathans@sgi.com>
parent 8034fff3
...@@ -1785,8 +1785,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, ...@@ -1785,8 +1785,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop,
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 = be32_to_cpu(dead_leaf->entries[
INT_GET(dead_leaf->entries[be16_to_cpu(dead_leaf->hdr.count) - 1].hashval, ARCH_CONVERT); be16_to_cpu(dead_leaf->hdr.count) - 1].hashval);
} else if (be16_to_cpu(dead_info->magic) == 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;
......
...@@ -710,7 +710,7 @@ xfs_dir_leaf_replace(xfs_da_args_t *args) ...@@ -710,7 +710,7 @@ xfs_dir_leaf_replace(xfs_da_args_t *args)
if (retval == EEXIST) { if (retval == EEXIST) {
leaf = bp->data; leaf = bp->data;
entry = &leaf->entries[index]; entry = &leaf->entries[index];
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
/* XXX - replace assert? */ /* XXX - replace assert? */
XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber); XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber);
xfs_da_log_buf(args->trans, bp, xfs_da_log_buf(args->trans, bp,
...@@ -918,14 +918,14 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, ...@@ -918,14 +918,14 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio,
xfs_da_brelse(trans, bp); xfs_da_brelse(trans, bp);
bp = NULL; bp = NULL;
} }
if (bp && INT_GET(leaf->entries[0].hashval, ARCH_CONVERT) > cookhash) { if (bp && be32_to_cpu(leaf->entries[0].hashval) > cookhash) {
xfs_dir_trace_g_dub("node: leaf hash too large", xfs_dir_trace_g_dub("node: leaf hash too large",
dp, uio, bno); dp, uio, bno);
xfs_da_brelse(trans, bp); xfs_da_brelse(trans, bp);
bp = NULL; bp = NULL;
} }
if (bp && if (bp && cookhash > be32_to_cpu(leaf->entries[
cookhash > INT_GET(leaf->entries[be16_to_cpu(leaf->hdr.count) - 1].hashval, ARCH_CONVERT)) { be16_to_cpu(leaf->hdr.count) - 1].hashval)) {
xfs_dir_trace_g_dub("node: leaf hash too small", xfs_dir_trace_g_dub("node: leaf hash too small",
dp, uio, bno); dp, uio, bno);
xfs_da_brelse(trans, bp); xfs_da_brelse(trans, bp);
...@@ -1059,7 +1059,7 @@ xfs_dir_node_replace(xfs_da_args_t *args) ...@@ -1059,7 +1059,7 @@ xfs_dir_node_replace(xfs_da_args_t *args)
bp = blk->bp; bp = blk->bp;
leaf = bp->data; leaf = bp->data;
entry = &leaf->entries[blk->index]; entry = &leaf->entries[blk->index];
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
/* XXX - replace assert ? */ /* XXX - replace assert ? */
XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber); XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber);
xfs_da_log_buf(args->trans, bp, xfs_da_log_buf(args->trans, bp,
...@@ -1151,10 +1151,8 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio, ...@@ -1151,10 +1151,8 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio,
(void *)(unsigned long)uio->uio_resid, (void *)(unsigned long)uio->uio_resid,
(void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw), (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw),
(void *)(unsigned long)be16_to_cpu(leaf->hdr.count), (void *)(unsigned long)be16_to_cpu(leaf->hdr.count),
(void *)(unsigned long) (void *)(unsigned long)be32_to_cpu(leaf->entries[0].hashval),
INT_GET(leaf->entries[0].hashval, ARCH_CONVERT), (void *)(unsigned long)be32_to_cpu(leaf->entries[last].hashval),
(void *)(unsigned long)
INT_GET(leaf->entries[last].hashval, ARCH_CONVERT),
NULL, NULL, NULL); NULL, NULL, NULL);
} }
...@@ -1170,8 +1168,7 @@ xfs_dir_trace_g_due(char *where, xfs_inode_t *dp, uio_t *uio, ...@@ -1170,8 +1168,7 @@ xfs_dir_trace_g_due(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(entry->hashval),
INT_GET(entry->hashval, ARCH_CONVERT),
NULL, NULL, NULL, NULL, NULL, NULL); NULL, NULL, NULL, NULL, NULL, NULL);
} }
......
...@@ -652,7 +652,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) ...@@ -652,7 +652,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
hdr = &leaf->hdr; hdr = &leaf->hdr;
entry = &leaf->entries[0]; entry = &leaf->entries[0];
for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) {
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
if ((entry->namelen == 2) && if ((entry->namelen == 2) &&
(namest->name[0] == '.') && (namest->name[0] == '.') &&
(namest->name[1] == '.')) { (namest->name[1] == '.')) {
...@@ -684,10 +684,10 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) ...@@ -684,10 +684,10 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs)
for (i = 0; i < be16_to_cpu(hdr->count); entry++, i++) { for (i = 0; i < be16_to_cpu(hdr->count); entry++, i++) {
if (!entry->nameidx) if (!entry->nameidx)
continue; continue;
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
args.name = (char *)(namest->name); args.name = (char *)(namest->name);
args.namelen = entry->namelen; args.namelen = entry->namelen;
args.hashval = INT_GET(entry->hashval, ARCH_CONVERT); args.hashval = be32_to_cpu(entry->hashval);
XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args.inumber); XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args.inumber);
xfs_dir_shortform_addname(&args); xfs_dir_shortform_addname(&args);
} }
...@@ -742,9 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) ...@@ -742,9 +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(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC);
node->btree[0].hashval = cpu_to_be32( node->btree[0].hashval = leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval;
INT_GET(leaf->entries[
be16_to_cpu(leaf->hdr.count)-1].hashval, ARCH_CONVERT));
xfs_da_buf_done(bp2); xfs_da_buf_done(bp2);
node->btree[0].before = cpu_to_be32(blkno); node->btree[0].before = cpu_to_be32(blkno);
node->hdr.count = cpu_to_be16(1); node->hdr.count = cpu_to_be16(1);
...@@ -970,8 +968,9 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, ...@@ -970,8 +968,9 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index,
ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp));
be16_add(&map->size, -(XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen))); be16_add(&map->size, -(XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen)));
INT_SET(entry->nameidx, ARCH_CONVERT, be16_to_cpu(map->base) + be16_to_cpu(map->size)); entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) +
INT_SET(entry->hashval, ARCH_CONVERT, args->hashval); be16_to_cpu(map->size));
entry->hashval = cpu_to_be32(args->hashval);
entry->namelen = args->namelen; entry->namelen = args->namelen;
xfs_da_log_buf(args->trans, bp, xfs_da_log_buf(args->trans, bp,
XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
...@@ -979,7 +978,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, ...@@ -979,7 +978,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index,
/* /*
* Copy the string and inode number into the new space. * Copy the string and inode number into the new space.
*/ */
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
XFS_DIR_SF_PUT_DIRINO(&args->inumber, &namest->inumber); XFS_DIR_SF_PUT_DIRINO(&args->inumber, &namest->inumber);
memcpy(namest->name, args->name, args->namelen); memcpy(namest->name, args->name, args->namelen);
xfs_da_log_buf(args->trans, bp, xfs_da_log_buf(args->trans, bp,
...@@ -988,7 +987,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, ...@@ -988,7 +987,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index,
/* /*
* Update the control info for this leaf node * Update the control info for this leaf node
*/ */
if (INT_GET(entry->nameidx, ARCH_CONVERT) < be16_to_cpu(hdr->firstused)) if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused))
hdr->firstused = entry->nameidx; hdr->firstused = entry->nameidx;
ASSERT(be16_to_cpu(hdr->firstused) >= ASSERT(be16_to_cpu(hdr->firstused) >=
((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr))); ((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr)));
...@@ -1198,8 +1197,10 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, ...@@ -1198,8 +1197,10 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
/* /*
* Copy out last hashval in each block for B-tree code. * Copy out last hashval in each block for B-tree code.
*/ */
blk1->hashval = INT_GET(leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval, ARCH_CONVERT); blk1->hashval = be32_to_cpu(leaf1->entries[
blk2->hashval = INT_GET(leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval, ARCH_CONVERT); be16_to_cpu(leaf1->hdr.count)-1].hashval);
blk2->hashval = be32_to_cpu(leaf2->entries[
be16_to_cpu(leaf2->hdr.count)-1].hashval);
/* /*
* Adjust the expected index for insertion. * Adjust the expected index for insertion.
...@@ -1462,8 +1463,8 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) ...@@ -1462,8 +1463,8 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
ASSERT(be16_to_cpu(hdr->firstused) >= ASSERT(be16_to_cpu(hdr->firstused) >=
((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr))); ((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr)));
entry = &leaf->entries[index]; entry = &leaf->entries[index];
ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) >= be16_to_cpu(hdr->firstused)); ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused));
ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp)); ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
/* /*
* Scan through free region table: * Scan through free region table:
...@@ -1487,9 +1488,11 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) ...@@ -1487,9 +1488,11 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
be16_add(&map->size, entry_size); be16_add(&map->size, entry_size);
} }
if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) == INT_GET(entry->nameidx, ARCH_CONVERT)) { if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) ==
be16_to_cpu(entry->nameidx)) {
before = i; before = i;
} else if (be16_to_cpu(map->base) == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) { } else if (be16_to_cpu(map->base) ==
(be16_to_cpu(entry->nameidx) + entsize)) {
after = i; after = i;
} else if (be16_to_cpu(map->size) < tmp) { } else if (be16_to_cpu(map->size) < tmp) {
tmp = be16_to_cpu(map->size); tmp = be16_to_cpu(map->size);
...@@ -1530,7 +1533,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) ...@@ -1530,7 +1533,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
/* /*
* Did we remove the first entry? * Did we remove the first entry?
*/ */
if (INT_GET(entry->nameidx, ARCH_CONVERT) == be16_to_cpu(hdr->firstused)) if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused))
smallest = 1; smallest = 1;
else else
smallest = 0; smallest = 0;
...@@ -1538,7 +1541,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) ...@@ -1538,7 +1541,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
/* /*
* Compress the remaining entries and zero out the removed stuff. * Compress the remaining entries and zero out the removed stuff.
*/ */
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
memset((char *)namest, 0, entsize); memset((char *)namest, 0, entsize);
xfs_da_log_buf(trans, bp, XFS_DA_LOGRANGE(leaf, namest, entsize)); xfs_da_log_buf(trans, bp, XFS_DA_LOGRANGE(leaf, namest, entsize));
...@@ -1561,11 +1564,11 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) ...@@ -1561,11 +1564,11 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index)
tmp = XFS_LBSIZE(mp); tmp = XFS_LBSIZE(mp);
entry = &leaf->entries[0]; entry = &leaf->entries[0];
for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) {
ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) >= ASSERT(be16_to_cpu(entry->nameidx) >=
be16_to_cpu(hdr->firstused)); be16_to_cpu(hdr->firstused));
ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp)); ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp) if (be16_to_cpu(entry->nameidx) < tmp)
tmp = INT_GET(entry->nameidx, ARCH_CONVERT); tmp = be16_to_cpu(entry->nameidx);
} }
hdr->firstused = cpu_to_be16(tmp); hdr->firstused = cpu_to_be16(tmp);
if (!hdr->firstused) if (!hdr->firstused)
...@@ -1617,7 +1620,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1617,7 +1620,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
/* /*
* Save last hashval from dying block for later Btree fixup. * Save last hashval from dying block for later Btree fixup.
*/ */
drop_blk->hashval = INT_GET(drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval, ARCH_CONVERT); drop_blk->hashval = be32_to_cpu(drop_leaf->entries[
be16_to_cpu(drop_leaf->hdr.count)-1].hashval);
/* /*
* Check if we need a temp buffer, or can we do it in place. * Check if we need a temp buffer, or can we do it in place.
...@@ -1676,7 +1680,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, ...@@ -1676,7 +1680,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
/* /*
* Copy out last hashval in each block for B-tree code. * Copy out last hashval in each block for B-tree code.
*/ */
save_blk->hashval = INT_GET(save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1 ].hashval, ARCH_CONVERT); save_blk->hashval = be32_to_cpu(save_leaf->entries[
be16_to_cpu(save_leaf->hdr.count)-1].hashval);
} }
/*======================================================================== /*========================================================================
...@@ -1716,30 +1721,32 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) ...@@ -1716,30 +1721,32 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
for (entry = &leaf->entries[probe]; span > 4; for (entry = &leaf->entries[probe]; span > 4;
entry = &leaf->entries[probe]) { entry = &leaf->entries[probe]) {
span /= 2; span /= 2;
if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval) if (be32_to_cpu(entry->hashval) < hashval)
probe += span; probe += span;
else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval) else if (be32_to_cpu(entry->hashval) > hashval)
probe -= span; probe -= span;
else else
break; break;
} }
ASSERT((probe >= 0) && \ ASSERT((probe >= 0) && \
((!leaf->hdr.count) || (probe < be16_to_cpu(leaf->hdr.count)))); ((!leaf->hdr.count) || (probe < be16_to_cpu(leaf->hdr.count))));
ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT) == hashval)); ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval));
/* /*
* Since we may have duplicate hashval's, find the first matching * Since we may have duplicate hashval's, find the first matching
* hashval in the leaf. * hashval in the leaf.
*/ */
while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT) >= hashval)) { while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) {
entry--; entry--;
probe--; probe--;
} }
while ((probe < be16_to_cpu(leaf->hdr.count)) && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) { while ((probe < be16_to_cpu(leaf->hdr.count)) &&
(be32_to_cpu(entry->hashval) < hashval)) {
entry++; entry++;
probe++; probe++;
} }
if ((probe == be16_to_cpu(leaf->hdr.count)) || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { if ((probe == be16_to_cpu(leaf->hdr.count)) ||
(be32_to_cpu(entry->hashval) != hashval)) {
*index = probe; *index = probe;
ASSERT(args->oknoent); ASSERT(args->oknoent);
return XFS_ERROR(ENOENT); return XFS_ERROR(ENOENT);
...@@ -1748,8 +1755,9 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) ...@@ -1748,8 +1755,9 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index)
/* /*
* Duplicate keys may be present, so search all of them for a match. * Duplicate keys may be present, so search all of them for a match.
*/ */
while ((probe < be16_to_cpu(leaf->hdr.count)) && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval)) { while ((probe < be16_to_cpu(leaf->hdr.count)) &&
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); (be32_to_cpu(entry->hashval) == hashval)) {
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx));
if (entry->namelen == args->namelen && if (entry->namelen == args->namelen &&
namest->name[0] == args->name[0] && namest->name[0] == args->name[0] &&
memcmp(args->name, namest->name, args->namelen) == 0) { memcmp(args->name, namest->name, args->namelen) == 0) {
...@@ -1825,19 +1833,19 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s, ...@@ -1825,19 +1833,19 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s,
entry_s = &leaf_s->entries[start_s]; entry_s = &leaf_s->entries[start_s];
entry_d = &leaf_d->entries[start_d]; entry_d = &leaf_d->entries[start_d];
for (i = 0; i < count; entry_s++, entry_d++, i++) { for (i = 0; i < count; entry_s++, entry_d++, i++) {
ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) >= ASSERT(be16_to_cpu(entry_s->nameidx) >=
be16_to_cpu(hdr_s->firstused)); be16_to_cpu(hdr_s->firstused));
tmp = XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry_s); tmp = XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry_s);
be16_add(&hdr_d->firstused, -(tmp)); be16_add(&hdr_d->firstused, -(tmp));
entry_d->hashval = entry_s->hashval; entry_d->hashval = entry_s->hashval;
entry_d->nameidx = hdr_d->firstused; entry_d->nameidx = hdr_d->firstused;
entry_d->namelen = entry_s->namelen; entry_d->namelen = entry_s->namelen;
ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp <= XFS_LBSIZE(mp)); ASSERT(be16_to_cpu(entry_d->nameidx) + tmp <= XFS_LBSIZE(mp));
memcpy(XFS_DIR_LEAF_NAMESTRUCT(leaf_d, INT_GET(entry_d->nameidx, ARCH_CONVERT)), memcpy(XFS_DIR_LEAF_NAMESTRUCT(leaf_d, be16_to_cpu(entry_d->nameidx)),
XFS_DIR_LEAF_NAMESTRUCT(leaf_s, INT_GET(entry_s->nameidx, ARCH_CONVERT)), tmp); XFS_DIR_LEAF_NAMESTRUCT(leaf_s, be16_to_cpu(entry_s->nameidx)), tmp);
ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp <= XFS_LBSIZE(mp)); ASSERT(be16_to_cpu(entry_s->nameidx) + tmp <= XFS_LBSIZE(mp));
memset((char *)XFS_DIR_LEAF_NAMESTRUCT(leaf_s, INT_GET(entry_s->nameidx, ARCH_CONVERT)), memset((char *)XFS_DIR_LEAF_NAMESTRUCT(leaf_s,
0, tmp); be16_to_cpu(entry_s->nameidx)), 0, tmp);
be16_add(&hdr_s->namebytes, -(entry_d->namelen)); be16_add(&hdr_s->namebytes, -(entry_d->namelen));
be16_add(&hdr_d->namebytes, entry_d->namelen); be16_add(&hdr_d->namebytes, entry_d->namelen);
be16_add(&hdr_s->count, -1); be16_add(&hdr_s->count, -1);
...@@ -1900,10 +1908,12 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) ...@@ -1900,10 +1908,12 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == 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)); (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC));
if (leaf1->hdr.count && leaf2->hdr.count && if (leaf1->hdr.count && leaf2->hdr.count &&
((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < ((be32_to_cpu(leaf2->entries[0].hashval) <
INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || be32_to_cpu(leaf1->entries[0 ].hashval)) ||
(INT_GET(leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval, ARCH_CONVERT) < (be32_to_cpu(leaf2->entries[
INT_GET(leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval, ARCH_CONVERT)))) { be16_to_cpu(leaf2->hdr.count)-1].hashval) <
be32_to_cpu(leaf1->entries[
be16_to_cpu(leaf1->hdr.count)-1].hashval)))) {
return 1; return 1;
} }
return 0; return 0;
...@@ -1923,7 +1933,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) ...@@ -1923,7 +1933,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count)
*count = be16_to_cpu(leaf->hdr.count); *count = be16_to_cpu(leaf->hdr.count);
if (!leaf->hdr.count) if (!leaf->hdr.count)
return(0); return(0);
return(INT_GET(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval, ARCH_CONVERT)); return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval);
} }
/* /*
...@@ -1972,7 +1982,7 @@ xfs_dir_leaf_getdents_int( ...@@ -1972,7 +1982,7 @@ xfs_dir_leaf_getdents_int(
i < be16_to_cpu(leaf->hdr.count); entry++, i++) { i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, namest = XFS_DIR_LEAF_NAMESTRUCT(leaf,
INT_GET(entry->nameidx, ARCH_CONVERT)); be16_to_cpu(entry->nameidx));
if (unlikely( if (unlikely(
((char *)namest < (char *)leaf) || ((char *)namest < (char *)leaf) ||
...@@ -1982,19 +1992,16 @@ xfs_dir_leaf_getdents_int( ...@@ -1982,19 +1992,16 @@ xfs_dir_leaf_getdents_int(
xfs_dir_trace_g_du("leaf: corrupted", dp, uio); xfs_dir_trace_g_du("leaf: corrupted", dp, uio);
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
if (INT_GET(entry->hashval, ARCH_CONVERT) >= cookhash) { if (be32_to_cpu(entry->hashval) >= cookhash) {
if ( entno < want_entno if (entno < want_entno &&
&& INT_GET(entry->hashval, ARCH_CONVERT) be32_to_cpu(entry->hashval) == cookhash) {
== cookhash) {
/* /*
* Trying to get to a particular offset in a * Trying to get to a particular offset in a
* run of equal-hashval entries. * run of equal-hashval entries.
*/ */
entno++; entno++;
} else if ( want_entno > 0 } else if (want_entno > 0 && entno == want_entno &&
&& entno == want_entno be32_to_cpu(entry->hashval) == cookhash) {
&& INT_GET(entry->hashval, ARCH_CONVERT)
== cookhash) {
break; break;
} else { } else {
entno = 0; entno = 0;
...@@ -2035,7 +2042,7 @@ xfs_dir_leaf_getdents_int( ...@@ -2035,7 +2042,7 @@ xfs_dir_leaf_getdents_int(
* the inode number from this entry. * the inode number from this entry.
*/ */
namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, namest = XFS_DIR_LEAF_NAMESTRUCT(leaf,
INT_GET(entry->nameidx, ARCH_CONVERT)); be16_to_cpu(entry->nameidx));
if (unlikely( if (unlikely(
((char *)namest < (char *)leaf) || ((char *)namest < (char *)leaf) ||
...@@ -2050,9 +2057,9 @@ xfs_dir_leaf_getdents_int( ...@@ -2050,9 +2057,9 @@ xfs_dir_leaf_getdents_int(
dp, uio, p.cook.o); dp, uio, p.cook.o);
if (i < (be16_to_cpu(leaf->hdr.count) - 1)) { if (i < (be16_to_cpu(leaf->hdr.count) - 1)) {
nexthash = INT_GET(entry[1].hashval, ARCH_CONVERT); nexthash = be32_to_cpu(entry[1].hashval);
if (nexthash == INT_GET(entry->hashval, ARCH_CONVERT)) if (nexthash == be32_to_cpu(entry->hashval))
nextentno = entno + 1; nextentno = entno + 1;
else else
nextentno = 0; nextentno = 0;
...@@ -2088,8 +2095,7 @@ xfs_dir_leaf_getdents_int( ...@@ -2088,8 +2095,7 @@ xfs_dir_leaf_getdents_int(
return XFS_ERROR(EFSCORRUPTED); return XFS_ERROR(EFSCORRUPTED);
} }
nexthash = INT_GET(leaf2->entries[0].hashval, nexthash = be32_to_cpu(leaf2->entries[0].hashval);
ARCH_CONVERT);
nextentno = -1; nextentno = -1;
XFS_PUT_COOKIE(p.cook, mp, thishash, 0, nexthash); XFS_PUT_COOKIE(p.cook, mp, thishash, 0, nexthash);
xfs_da_brelse(dp->i_transp, bp2); xfs_da_brelse(dp->i_transp, bp2);
...@@ -2113,9 +2119,9 @@ xfs_dir_leaf_getdents_int( ...@@ -2113,9 +2119,9 @@ xfs_dir_leaf_getdents_int(
* that share the same hashval. Hopefully the buffer * that share the same hashval. Hopefully the buffer
* provided is big enough to handle it (see pv763517). * provided is big enough to handle it (see pv763517).
*/ */
thishash = be32_to_cpu(entry->hashval);
#if (BITS_PER_LONG == 32) #if (BITS_PER_LONG == 32)
if ((thishash = INT_GET(entry->hashval, ARCH_CONVERT)) if (thishash != lasthash) {
!= lasthash) {
XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash); XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash);
lastresid = uio->uio_resid; lastresid = uio->uio_resid;
lasthash = thishash; lasthash = thishash;
...@@ -2124,7 +2130,6 @@ xfs_dir_leaf_getdents_int( ...@@ -2124,7 +2130,6 @@ xfs_dir_leaf_getdents_int(
dp, uio, p.cook.o); dp, uio, p.cook.o);
} }
#else #else
thishash = INT_GET(entry->hashval, ARCH_CONVERT);
XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash); XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash);
lastresid = uio->uio_resid; lastresid = uio->uio_resid;
#endif /* BITS_PER_LONG == 32 */ #endif /* BITS_PER_LONG == 32 */
......
...@@ -83,10 +83,10 @@ typedef struct xfs_dir_leaf_hdr { /* constant-structure header block */ ...@@ -83,10 +83,10 @@ typedef struct xfs_dir_leaf_hdr { /* constant-structure header block */
} xfs_dir_leaf_hdr_t; } xfs_dir_leaf_hdr_t;
typedef struct xfs_dir_leaf_entry { /* sorted on key, not name */ typedef struct xfs_dir_leaf_entry { /* sorted on key, not name */
xfs_dahash_t hashval; /* hash value of name */ __be32 hashval; /* hash value of name */
__uint16_t nameidx; /* index into buffer of name */ __be16 nameidx; /* index into buffer of name */
__uint8_t namelen; /* length of name string */ __u8 namelen; /* length of name string */
__uint8_t pad2; __u8 pad2;
} xfs_dir_leaf_entry_t; } xfs_dir_leaf_entry_t;
typedef struct xfs_dir_leaf_name { typedef struct xfs_dir_leaf_name {
......
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