diff options
author | Christoph Hellwig <hch@lst.de> | 2006-06-09 00:50:37 -0400 |
---|---|---|
committer | Nathan Scott <nathans@sgi.com> | 2006-06-09 00:50:37 -0400 |
commit | 1d8daf06f67c8920a640eb61b30c3176ecc52405 (patch) | |
tree | b5ee131d524177d05d7f5cacdfd662f65246ca7c /fs | |
parent | 8034fff39bb9430d807375ec7a04097efba42cd2 (diff) |
[XFS] endianess annotations for xfs_dir_leaf_entry_t
SGI-PV: 943272
SGI-Modid: xfs-linux-melb:xfs-kern:25808a
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 4 | ||||
-rw-r--r-- | fs/xfs/xfs_dir.c | 19 | ||||
-rw-r--r-- | fs/xfs/xfs_dir_leaf.c | 127 | ||||
-rw-r--r-- | fs/xfs/xfs_dir_leaf.h | 8 |
4 files changed, 80 insertions, 78 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 296aa525ac42..260c3d770c02 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -1785,8 +1785,8 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1785 | ASSERT(XFS_DIR_IS_V1(mp)); | 1785 | ASSERT(XFS_DIR_IS_V1(mp)); |
1786 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; | 1786 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; |
1787 | dead_level = 0; | 1787 | dead_level = 0; |
1788 | dead_hash = | 1788 | dead_hash = be32_to_cpu(dead_leaf->entries[ |
1789 | INT_GET(dead_leaf->entries[be16_to_cpu(dead_leaf->hdr.count) - 1].hashval, ARCH_CONVERT); | 1789 | be16_to_cpu(dead_leaf->hdr.count) - 1].hashval); |
1790 | } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { | 1790 | } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1791 | ASSERT(XFS_DIR_IS_V2(mp)); | 1791 | ASSERT(XFS_DIR_IS_V2(mp)); |
1792 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; | 1792 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; |
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c index a3b0e97dbf96..3cd8657a81f6 100644 --- a/fs/xfs/xfs_dir.c +++ b/fs/xfs/xfs_dir.c | |||
@@ -710,7 +710,7 @@ xfs_dir_leaf_replace(xfs_da_args_t *args) | |||
710 | if (retval == EEXIST) { | 710 | if (retval == EEXIST) { |
711 | leaf = bp->data; | 711 | leaf = bp->data; |
712 | entry = &leaf->entries[index]; | 712 | entry = &leaf->entries[index]; |
713 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 713 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); |
714 | /* XXX - replace assert? */ | 714 | /* XXX - replace assert? */ |
715 | XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber); | 715 | XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber); |
716 | xfs_da_log_buf(args->trans, bp, | 716 | 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 | xfs_da_brelse(trans, bp); | 918 | xfs_da_brelse(trans, bp); |
919 | bp = NULL; | 919 | bp = NULL; |
920 | } | 920 | } |
921 | if (bp && INT_GET(leaf->entries[0].hashval, ARCH_CONVERT) > cookhash) { | 921 | if (bp && be32_to_cpu(leaf->entries[0].hashval) > cookhash) { |
922 | xfs_dir_trace_g_dub("node: leaf hash too large", | 922 | xfs_dir_trace_g_dub("node: leaf hash too large", |
923 | dp, uio, bno); | 923 | dp, uio, bno); |
924 | xfs_da_brelse(trans, bp); | 924 | xfs_da_brelse(trans, bp); |
925 | bp = NULL; | 925 | bp = NULL; |
926 | } | 926 | } |
927 | if (bp && | 927 | if (bp && cookhash > be32_to_cpu(leaf->entries[ |
928 | cookhash > INT_GET(leaf->entries[be16_to_cpu(leaf->hdr.count) - 1].hashval, ARCH_CONVERT)) { | 928 | be16_to_cpu(leaf->hdr.count) - 1].hashval)) { |
929 | xfs_dir_trace_g_dub("node: leaf hash too small", | 929 | xfs_dir_trace_g_dub("node: leaf hash too small", |
930 | dp, uio, bno); | 930 | dp, uio, bno); |
931 | xfs_da_brelse(trans, bp); | 931 | xfs_da_brelse(trans, bp); |
@@ -1059,7 +1059,7 @@ xfs_dir_node_replace(xfs_da_args_t *args) | |||
1059 | bp = blk->bp; | 1059 | bp = blk->bp; |
1060 | leaf = bp->data; | 1060 | leaf = bp->data; |
1061 | entry = &leaf->entries[blk->index]; | 1061 | entry = &leaf->entries[blk->index]; |
1062 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 1062 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); |
1063 | /* XXX - replace assert ? */ | 1063 | /* XXX - replace assert ? */ |
1064 | XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber); | 1064 | XFS_DIR_SF_PUT_DIRINO(&inum, &namest->inumber); |
1065 | xfs_da_log_buf(args->trans, bp, | 1065 | 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 | (void *)(unsigned long)uio->uio_resid, | 1151 | (void *)(unsigned long)uio->uio_resid, |
1152 | (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw), | 1152 | (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw), |
1153 | (void *)(unsigned long)be16_to_cpu(leaf->hdr.count), | 1153 | (void *)(unsigned long)be16_to_cpu(leaf->hdr.count), |
1154 | (void *)(unsigned long) | 1154 | (void *)(unsigned long)be32_to_cpu(leaf->entries[0].hashval), |
1155 | INT_GET(leaf->entries[0].hashval, ARCH_CONVERT), | 1155 | (void *)(unsigned long)be32_to_cpu(leaf->entries[last].hashval), |
1156 | (void *)(unsigned long) | ||
1157 | INT_GET(leaf->entries[last].hashval, ARCH_CONVERT), | ||
1158 | NULL, NULL, NULL); | 1156 | NULL, NULL, NULL); |
1159 | } | 1157 | } |
1160 | 1158 | ||
@@ -1170,8 +1168,7 @@ xfs_dir_trace_g_due(char *where, xfs_inode_t *dp, uio_t *uio, | |||
1170 | (void *)((unsigned long)(uio->uio_offset >> 32)), | 1168 | (void *)((unsigned long)(uio->uio_offset >> 32)), |
1171 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), | 1169 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), |
1172 | (void *)(unsigned long)uio->uio_resid, | 1170 | (void *)(unsigned long)uio->uio_resid, |
1173 | (void *)(unsigned long) | 1171 | (void *)(unsigned long)be32_to_cpu(entry->hashval), |
1174 | INT_GET(entry->hashval, ARCH_CONVERT), | ||
1175 | NULL, NULL, NULL, NULL, NULL, NULL); | 1172 | NULL, NULL, NULL, NULL, NULL, NULL); |
1176 | } | 1173 | } |
1177 | 1174 | ||
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c index 6a4d8caaba7b..e7121040cd9d 100644 --- a/fs/xfs/xfs_dir_leaf.c +++ b/fs/xfs/xfs_dir_leaf.c | |||
@@ -652,7 +652,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) | |||
652 | hdr = &leaf->hdr; | 652 | hdr = &leaf->hdr; |
653 | entry = &leaf->entries[0]; | 653 | entry = &leaf->entries[0]; |
654 | for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { | 654 | for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { |
655 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 655 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); |
656 | if ((entry->namelen == 2) && | 656 | if ((entry->namelen == 2) && |
657 | (namest->name[0] == '.') && | 657 | (namest->name[0] == '.') && |
658 | (namest->name[1] == '.')) { | 658 | (namest->name[1] == '.')) { |
@@ -684,10 +684,10 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) | |||
684 | for (i = 0; i < be16_to_cpu(hdr->count); entry++, i++) { | 684 | for (i = 0; i < be16_to_cpu(hdr->count); entry++, i++) { |
685 | if (!entry->nameidx) | 685 | if (!entry->nameidx) |
686 | continue; | 686 | continue; |
687 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 687 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); |
688 | args.name = (char *)(namest->name); | 688 | args.name = (char *)(namest->name); |
689 | args.namelen = entry->namelen; | 689 | args.namelen = entry->namelen; |
690 | args.hashval = INT_GET(entry->hashval, ARCH_CONVERT); | 690 | args.hashval = be32_to_cpu(entry->hashval); |
691 | XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args.inumber); | 691 | XFS_DIR_SF_GET_DIRINO(&namest->inumber, &args.inumber); |
692 | xfs_dir_shortform_addname(&args); | 692 | xfs_dir_shortform_addname(&args); |
693 | } | 693 | } |
@@ -742,9 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) | |||
742 | node = bp1->data; | 742 | node = bp1->data; |
743 | leaf = bp2->data; | 743 | leaf = bp2->data; |
744 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); | 744 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
745 | node->btree[0].hashval = cpu_to_be32( | 745 | node->btree[0].hashval = leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval; |
746 | INT_GET(leaf->entries[ | ||
747 | be16_to_cpu(leaf->hdr.count)-1].hashval, ARCH_CONVERT)); | ||
748 | xfs_da_buf_done(bp2); | 746 | xfs_da_buf_done(bp2); |
749 | node->btree[0].before = cpu_to_be32(blkno); | 747 | node->btree[0].before = cpu_to_be32(blkno); |
750 | node->hdr.count = cpu_to_be16(1); | 748 | 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 | ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); | 968 | ASSERT(be16_to_cpu(map->size) < XFS_LBSIZE(mp)); |
971 | 969 | ||
972 | be16_add(&map->size, -(XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen))); | 970 | be16_add(&map->size, -(XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen))); |
973 | INT_SET(entry->nameidx, ARCH_CONVERT, be16_to_cpu(map->base) + be16_to_cpu(map->size)); | 971 | entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) + |
974 | INT_SET(entry->hashval, ARCH_CONVERT, args->hashval); | 972 | be16_to_cpu(map->size)); |
973 | entry->hashval = cpu_to_be32(args->hashval); | ||
975 | entry->namelen = args->namelen; | 974 | entry->namelen = args->namelen; |
976 | xfs_da_log_buf(args->trans, bp, | 975 | xfs_da_log_buf(args->trans, bp, |
977 | XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); | 976 | 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 | /* | 978 | /* |
980 | * Copy the string and inode number into the new space. | 979 | * Copy the string and inode number into the new space. |
981 | */ | 980 | */ |
982 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 981 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); |
983 | XFS_DIR_SF_PUT_DIRINO(&args->inumber, &namest->inumber); | 982 | XFS_DIR_SF_PUT_DIRINO(&args->inumber, &namest->inumber); |
984 | memcpy(namest->name, args->name, args->namelen); | 983 | memcpy(namest->name, args->name, args->namelen); |
985 | xfs_da_log_buf(args->trans, bp, | 984 | 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 | /* | 987 | /* |
989 | * Update the control info for this leaf node | 988 | * Update the control info for this leaf node |
990 | */ | 989 | */ |
991 | if (INT_GET(entry->nameidx, ARCH_CONVERT) < be16_to_cpu(hdr->firstused)) | 990 | if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused)) |
992 | hdr->firstused = entry->nameidx; | 991 | hdr->firstused = entry->nameidx; |
993 | ASSERT(be16_to_cpu(hdr->firstused) >= | 992 | ASSERT(be16_to_cpu(hdr->firstused) >= |
994 | ((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr))); | 993 | ((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 | /* | 1197 | /* |
1199 | * Copy out last hashval in each block for B-tree code. | 1198 | * Copy out last hashval in each block for B-tree code. |
1200 | */ | 1199 | */ |
1201 | blk1->hashval = INT_GET(leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval, ARCH_CONVERT); | 1200 | blk1->hashval = be32_to_cpu(leaf1->entries[ |
1202 | blk2->hashval = INT_GET(leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval, ARCH_CONVERT); | 1201 | be16_to_cpu(leaf1->hdr.count)-1].hashval); |
1202 | blk2->hashval = be32_to_cpu(leaf2->entries[ | ||
1203 | be16_to_cpu(leaf2->hdr.count)-1].hashval); | ||
1203 | 1204 | ||
1204 | /* | 1205 | /* |
1205 | * Adjust the expected index for insertion. | 1206 | * 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 | ASSERT(be16_to_cpu(hdr->firstused) >= | 1463 | ASSERT(be16_to_cpu(hdr->firstused) >= |
1463 | ((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr))); | 1464 | ((be16_to_cpu(hdr->count)*sizeof(*entry))+sizeof(*hdr))); |
1464 | entry = &leaf->entries[index]; | 1465 | entry = &leaf->entries[index]; |
1465 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) >= be16_to_cpu(hdr->firstused)); | 1466 | ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused)); |
1466 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1467 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); |
1467 | 1468 | ||
1468 | /* | 1469 | /* |
1469 | * Scan through free region table: | 1470 | * Scan through free region table: |
@@ -1487,9 +1488,11 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) | |||
1487 | be16_add(&map->size, entry_size); | 1488 | be16_add(&map->size, entry_size); |
1488 | } | 1489 | } |
1489 | 1490 | ||
1490 | if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) == INT_GET(entry->nameidx, ARCH_CONVERT)) { | 1491 | if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) == |
1492 | be16_to_cpu(entry->nameidx)) { | ||
1491 | before = i; | 1493 | before = i; |
1492 | } else if (be16_to_cpu(map->base) == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) { | 1494 | } else if (be16_to_cpu(map->base) == |
1495 | (be16_to_cpu(entry->nameidx) + entsize)) { | ||
1493 | after = i; | 1496 | after = i; |
1494 | } else if (be16_to_cpu(map->size) < tmp) { | 1497 | } else if (be16_to_cpu(map->size) < tmp) { |
1495 | tmp = be16_to_cpu(map->size); | 1498 | 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 | /* | 1533 | /* |
1531 | * Did we remove the first entry? | 1534 | * Did we remove the first entry? |
1532 | */ | 1535 | */ |
1533 | if (INT_GET(entry->nameidx, ARCH_CONVERT) == be16_to_cpu(hdr->firstused)) | 1536 | if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused)) |
1534 | smallest = 1; | 1537 | smallest = 1; |
1535 | else | 1538 | else |
1536 | smallest = 0; | 1539 | smallest = 0; |
@@ -1538,7 +1541,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) | |||
1538 | /* | 1541 | /* |
1539 | * Compress the remaining entries and zero out the removed stuff. | 1542 | * Compress the remaining entries and zero out the removed stuff. |
1540 | */ | 1543 | */ |
1541 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 1544 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); |
1542 | memset((char *)namest, 0, entsize); | 1545 | memset((char *)namest, 0, entsize); |
1543 | xfs_da_log_buf(trans, bp, XFS_DA_LOGRANGE(leaf, namest, entsize)); | 1546 | xfs_da_log_buf(trans, bp, XFS_DA_LOGRANGE(leaf, namest, entsize)); |
1544 | 1547 | ||
@@ -1561,11 +1564,11 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) | |||
1561 | tmp = XFS_LBSIZE(mp); | 1564 | tmp = XFS_LBSIZE(mp); |
1562 | entry = &leaf->entries[0]; | 1565 | entry = &leaf->entries[0]; |
1563 | for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { | 1566 | for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { |
1564 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) >= | 1567 | ASSERT(be16_to_cpu(entry->nameidx) >= |
1565 | be16_to_cpu(hdr->firstused)); | 1568 | be16_to_cpu(hdr->firstused)); |
1566 | ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp)); | 1569 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); |
1567 | if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp) | 1570 | if (be16_to_cpu(entry->nameidx) < tmp) |
1568 | tmp = INT_GET(entry->nameidx, ARCH_CONVERT); | 1571 | tmp = be16_to_cpu(entry->nameidx); |
1569 | } | 1572 | } |
1570 | hdr->firstused = cpu_to_be16(tmp); | 1573 | hdr->firstused = cpu_to_be16(tmp); |
1571 | if (!hdr->firstused) | 1574 | if (!hdr->firstused) |
@@ -1617,7 +1620,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1617 | /* | 1620 | /* |
1618 | * Save last hashval from dying block for later Btree fixup. | 1621 | * Save last hashval from dying block for later Btree fixup. |
1619 | */ | 1622 | */ |
1620 | drop_blk->hashval = INT_GET(drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval, ARCH_CONVERT); | 1623 | drop_blk->hashval = be32_to_cpu(drop_leaf->entries[ |
1624 | be16_to_cpu(drop_leaf->hdr.count)-1].hashval); | ||
1621 | 1625 | ||
1622 | /* | 1626 | /* |
1623 | * Check if we need a temp buffer, or can we do it in place. | 1627 | * 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 | /* | 1680 | /* |
1677 | * Copy out last hashval in each block for B-tree code. | 1681 | * Copy out last hashval in each block for B-tree code. |
1678 | */ | 1682 | */ |
1679 | save_blk->hashval = INT_GET(save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1 ].hashval, ARCH_CONVERT); | 1683 | save_blk->hashval = be32_to_cpu(save_leaf->entries[ |
1684 | be16_to_cpu(save_leaf->hdr.count)-1].hashval); | ||
1680 | } | 1685 | } |
1681 | 1686 | ||
1682 | /*======================================================================== | 1687 | /*======================================================================== |
@@ -1716,30 +1721,32 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) | |||
1716 | for (entry = &leaf->entries[probe]; span > 4; | 1721 | for (entry = &leaf->entries[probe]; span > 4; |
1717 | entry = &leaf->entries[probe]) { | 1722 | entry = &leaf->entries[probe]) { |
1718 | span /= 2; | 1723 | span /= 2; |
1719 | if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval) | 1724 | if (be32_to_cpu(entry->hashval) < hashval) |
1720 | probe += span; | 1725 | probe += span; |
1721 | else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval) | 1726 | else if (be32_to_cpu(entry->hashval) > hashval) |
1722 | probe -= span; | 1727 | probe -= span; |
1723 | else | 1728 | else |
1724 | break; | 1729 | break; |
1725 | } | 1730 | } |
1726 | ASSERT((probe >= 0) && \ | 1731 | ASSERT((probe >= 0) && \ |
1727 | ((!leaf->hdr.count) || (probe < be16_to_cpu(leaf->hdr.count)))); | 1732 | ((!leaf->hdr.count) || (probe < be16_to_cpu(leaf->hdr.count)))); |
1728 | ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT) == hashval)); | 1733 | ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval)); |
1729 | 1734 | ||
1730 | /* | 1735 | /* |
1731 | * Since we may have duplicate hashval's, find the first matching | 1736 | * Since we may have duplicate hashval's, find the first matching |
1732 | * hashval in the leaf. | 1737 | * hashval in the leaf. |
1733 | */ | 1738 | */ |
1734 | while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT) >= hashval)) { | 1739 | while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) { |
1735 | entry--; | 1740 | entry--; |
1736 | probe--; | 1741 | probe--; |
1737 | } | 1742 | } |
1738 | while ((probe < be16_to_cpu(leaf->hdr.count)) && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) { | 1743 | while ((probe < be16_to_cpu(leaf->hdr.count)) && |
1744 | (be32_to_cpu(entry->hashval) < hashval)) { | ||
1739 | entry++; | 1745 | entry++; |
1740 | probe++; | 1746 | probe++; |
1741 | } | 1747 | } |
1742 | if ((probe == be16_to_cpu(leaf->hdr.count)) || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { | 1748 | if ((probe == be16_to_cpu(leaf->hdr.count)) || |
1749 | (be32_to_cpu(entry->hashval) != hashval)) { | ||
1743 | *index = probe; | 1750 | *index = probe; |
1744 | ASSERT(args->oknoent); | 1751 | ASSERT(args->oknoent); |
1745 | return XFS_ERROR(ENOENT); | 1752 | 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 | /* | 1755 | /* |
1749 | * Duplicate keys may be present, so search all of them for a match. | 1756 | * Duplicate keys may be present, so search all of them for a match. |
1750 | */ | 1757 | */ |
1751 | while ((probe < be16_to_cpu(leaf->hdr.count)) && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval)) { | 1758 | while ((probe < be16_to_cpu(leaf->hdr.count)) && |
1752 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, INT_GET(entry->nameidx, ARCH_CONVERT)); | 1759 | (be32_to_cpu(entry->hashval) == hashval)) { |
1760 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, be16_to_cpu(entry->nameidx)); | ||
1753 | if (entry->namelen == args->namelen && | 1761 | if (entry->namelen == args->namelen && |
1754 | namest->name[0] == args->name[0] && | 1762 | namest->name[0] == args->name[0] && |
1755 | memcmp(args->name, namest->name, args->namelen) == 0) { | 1763 | 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 | entry_s = &leaf_s->entries[start_s]; | 1833 | entry_s = &leaf_s->entries[start_s]; |
1826 | entry_d = &leaf_d->entries[start_d]; | 1834 | entry_d = &leaf_d->entries[start_d]; |
1827 | for (i = 0; i < count; entry_s++, entry_d++, i++) { | 1835 | for (i = 0; i < count; entry_s++, entry_d++, i++) { |
1828 | ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) >= | 1836 | ASSERT(be16_to_cpu(entry_s->nameidx) >= |
1829 | be16_to_cpu(hdr_s->firstused)); | 1837 | be16_to_cpu(hdr_s->firstused)); |
1830 | tmp = XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry_s); | 1838 | tmp = XFS_DIR_LEAF_ENTSIZE_BYENTRY(entry_s); |
1831 | be16_add(&hdr_d->firstused, -(tmp)); | 1839 | be16_add(&hdr_d->firstused, -(tmp)); |
1832 | entry_d->hashval = entry_s->hashval; | 1840 | entry_d->hashval = entry_s->hashval; |
1833 | entry_d->nameidx = hdr_d->firstused; | 1841 | entry_d->nameidx = hdr_d->firstused; |
1834 | entry_d->namelen = entry_s->namelen; | 1842 | entry_d->namelen = entry_s->namelen; |
1835 | ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp <= XFS_LBSIZE(mp)); | 1843 | ASSERT(be16_to_cpu(entry_d->nameidx) + tmp <= XFS_LBSIZE(mp)); |
1836 | memcpy(XFS_DIR_LEAF_NAMESTRUCT(leaf_d, INT_GET(entry_d->nameidx, ARCH_CONVERT)), | 1844 | memcpy(XFS_DIR_LEAF_NAMESTRUCT(leaf_d, be16_to_cpu(entry_d->nameidx)), |
1837 | XFS_DIR_LEAF_NAMESTRUCT(leaf_s, INT_GET(entry_s->nameidx, ARCH_CONVERT)), tmp); | 1845 | XFS_DIR_LEAF_NAMESTRUCT(leaf_s, be16_to_cpu(entry_s->nameidx)), tmp); |
1838 | ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp <= XFS_LBSIZE(mp)); | 1846 | ASSERT(be16_to_cpu(entry_s->nameidx) + tmp <= XFS_LBSIZE(mp)); |
1839 | memset((char *)XFS_DIR_LEAF_NAMESTRUCT(leaf_s, INT_GET(entry_s->nameidx, ARCH_CONVERT)), | 1847 | memset((char *)XFS_DIR_LEAF_NAMESTRUCT(leaf_s, |
1840 | 0, tmp); | 1848 | be16_to_cpu(entry_s->nameidx)), 0, tmp); |
1841 | be16_add(&hdr_s->namebytes, -(entry_d->namelen)); | 1849 | be16_add(&hdr_s->namebytes, -(entry_d->namelen)); |
1842 | be16_add(&hdr_d->namebytes, entry_d->namelen); | 1850 | be16_add(&hdr_d->namebytes, entry_d->namelen); |
1843 | be16_add(&hdr_s->count, -1); | 1851 | 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 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) && | 1908 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) && |
1901 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC)); | 1909 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC)); |
1902 | if (leaf1->hdr.count && leaf2->hdr.count && | 1910 | if (leaf1->hdr.count && leaf2->hdr.count && |
1903 | ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < | 1911 | ((be32_to_cpu(leaf2->entries[0].hashval) < |
1904 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || | 1912 | be32_to_cpu(leaf1->entries[0 ].hashval)) || |
1905 | (INT_GET(leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval, ARCH_CONVERT) < | 1913 | (be32_to_cpu(leaf2->entries[ |
1906 | INT_GET(leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval, ARCH_CONVERT)))) { | 1914 | be16_to_cpu(leaf2->hdr.count)-1].hashval) < |
1915 | be32_to_cpu(leaf1->entries[ | ||
1916 | be16_to_cpu(leaf1->hdr.count)-1].hashval)))) { | ||
1907 | return 1; | 1917 | return 1; |
1908 | } | 1918 | } |
1909 | return 0; | 1919 | return 0; |
@@ -1923,7 +1933,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
1923 | *count = be16_to_cpu(leaf->hdr.count); | 1933 | *count = be16_to_cpu(leaf->hdr.count); |
1924 | if (!leaf->hdr.count) | 1934 | if (!leaf->hdr.count) |
1925 | return(0); | 1935 | return(0); |
1926 | return(INT_GET(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval, ARCH_CONVERT)); | 1936 | return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval); |
1927 | } | 1937 | } |
1928 | 1938 | ||
1929 | /* | 1939 | /* |
@@ -1972,7 +1982,7 @@ xfs_dir_leaf_getdents_int( | |||
1972 | i < be16_to_cpu(leaf->hdr.count); entry++, i++) { | 1982 | i < be16_to_cpu(leaf->hdr.count); entry++, i++) { |
1973 | 1983 | ||
1974 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, | 1984 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, |
1975 | INT_GET(entry->nameidx, ARCH_CONVERT)); | 1985 | be16_to_cpu(entry->nameidx)); |
1976 | 1986 | ||
1977 | if (unlikely( | 1987 | if (unlikely( |
1978 | ((char *)namest < (char *)leaf) || | 1988 | ((char *)namest < (char *)leaf) || |
@@ -1982,19 +1992,16 @@ xfs_dir_leaf_getdents_int( | |||
1982 | xfs_dir_trace_g_du("leaf: corrupted", dp, uio); | 1992 | xfs_dir_trace_g_du("leaf: corrupted", dp, uio); |
1983 | return XFS_ERROR(EFSCORRUPTED); | 1993 | return XFS_ERROR(EFSCORRUPTED); |
1984 | } | 1994 | } |
1985 | if (INT_GET(entry->hashval, ARCH_CONVERT) >= cookhash) { | 1995 | if (be32_to_cpu(entry->hashval) >= cookhash) { |
1986 | if ( entno < want_entno | 1996 | if (entno < want_entno && |
1987 | && INT_GET(entry->hashval, ARCH_CONVERT) | 1997 | be32_to_cpu(entry->hashval) == cookhash) { |
1988 | == cookhash) { | ||
1989 | /* | 1998 | /* |
1990 | * Trying to get to a particular offset in a | 1999 | * Trying to get to a particular offset in a |
1991 | * run of equal-hashval entries. | 2000 | * run of equal-hashval entries. |
1992 | */ | 2001 | */ |
1993 | entno++; | 2002 | entno++; |
1994 | } else if ( want_entno > 0 | 2003 | } else if (want_entno > 0 && entno == want_entno && |
1995 | && entno == want_entno | 2004 | be32_to_cpu(entry->hashval) == cookhash) { |
1996 | && INT_GET(entry->hashval, ARCH_CONVERT) | ||
1997 | == cookhash) { | ||
1998 | break; | 2005 | break; |
1999 | } else { | 2006 | } else { |
2000 | entno = 0; | 2007 | entno = 0; |
@@ -2035,7 +2042,7 @@ xfs_dir_leaf_getdents_int( | |||
2035 | * the inode number from this entry. | 2042 | * the inode number from this entry. |
2036 | */ | 2043 | */ |
2037 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, | 2044 | namest = XFS_DIR_LEAF_NAMESTRUCT(leaf, |
2038 | INT_GET(entry->nameidx, ARCH_CONVERT)); | 2045 | be16_to_cpu(entry->nameidx)); |
2039 | 2046 | ||
2040 | if (unlikely( | 2047 | if (unlikely( |
2041 | ((char *)namest < (char *)leaf) || | 2048 | ((char *)namest < (char *)leaf) || |
@@ -2050,9 +2057,9 @@ xfs_dir_leaf_getdents_int( | |||
2050 | dp, uio, p.cook.o); | 2057 | dp, uio, p.cook.o); |
2051 | 2058 | ||
2052 | if (i < (be16_to_cpu(leaf->hdr.count) - 1)) { | 2059 | if (i < (be16_to_cpu(leaf->hdr.count) - 1)) { |
2053 | nexthash = INT_GET(entry[1].hashval, ARCH_CONVERT); | 2060 | nexthash = be32_to_cpu(entry[1].hashval); |
2054 | 2061 | ||
2055 | if (nexthash == INT_GET(entry->hashval, ARCH_CONVERT)) | 2062 | if (nexthash == be32_to_cpu(entry->hashval)) |
2056 | nextentno = entno + 1; | 2063 | nextentno = entno + 1; |
2057 | else | 2064 | else |
2058 | nextentno = 0; | 2065 | nextentno = 0; |
@@ -2088,8 +2095,7 @@ xfs_dir_leaf_getdents_int( | |||
2088 | return XFS_ERROR(EFSCORRUPTED); | 2095 | return XFS_ERROR(EFSCORRUPTED); |
2089 | } | 2096 | } |
2090 | 2097 | ||
2091 | nexthash = INT_GET(leaf2->entries[0].hashval, | 2098 | nexthash = be32_to_cpu(leaf2->entries[0].hashval); |
2092 | ARCH_CONVERT); | ||
2093 | nextentno = -1; | 2099 | nextentno = -1; |
2094 | XFS_PUT_COOKIE(p.cook, mp, thishash, 0, nexthash); | 2100 | XFS_PUT_COOKIE(p.cook, mp, thishash, 0, nexthash); |
2095 | xfs_da_brelse(dp->i_transp, bp2); | 2101 | xfs_da_brelse(dp->i_transp, bp2); |
@@ -2113,9 +2119,9 @@ xfs_dir_leaf_getdents_int( | |||
2113 | * that share the same hashval. Hopefully the buffer | 2119 | * that share the same hashval. Hopefully the buffer |
2114 | * provided is big enough to handle it (see pv763517). | 2120 | * provided is big enough to handle it (see pv763517). |
2115 | */ | 2121 | */ |
2122 | thishash = be32_to_cpu(entry->hashval); | ||
2116 | #if (BITS_PER_LONG == 32) | 2123 | #if (BITS_PER_LONG == 32) |
2117 | if ((thishash = INT_GET(entry->hashval, ARCH_CONVERT)) | 2124 | if (thishash != lasthash) { |
2118 | != lasthash) { | ||
2119 | XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash); | 2125 | XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash); |
2120 | lastresid = uio->uio_resid; | 2126 | lastresid = uio->uio_resid; |
2121 | lasthash = thishash; | 2127 | lasthash = thishash; |
@@ -2124,7 +2130,6 @@ xfs_dir_leaf_getdents_int( | |||
2124 | dp, uio, p.cook.o); | 2130 | dp, uio, p.cook.o); |
2125 | } | 2131 | } |
2126 | #else | 2132 | #else |
2127 | thishash = INT_GET(entry->hashval, ARCH_CONVERT); | ||
2128 | XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash); | 2133 | XFS_PUT_COOKIE(lastoffset, mp, bno, entno, thishash); |
2129 | lastresid = uio->uio_resid; | 2134 | lastresid = uio->uio_resid; |
2130 | #endif /* BITS_PER_LONG == 32 */ | 2135 | #endif /* BITS_PER_LONG == 32 */ |
diff --git a/fs/xfs/xfs_dir_leaf.h b/fs/xfs/xfs_dir_leaf.h index c6979ab829cb..7ca5845195d5 100644 --- a/fs/xfs/xfs_dir_leaf.h +++ b/fs/xfs/xfs_dir_leaf.h | |||
@@ -83,10 +83,10 @@ typedef struct xfs_dir_leaf_hdr { /* constant-structure header block */ | |||
83 | } xfs_dir_leaf_hdr_t; | 83 | } xfs_dir_leaf_hdr_t; |
84 | 84 | ||
85 | typedef struct xfs_dir_leaf_entry { /* sorted on key, not name */ | 85 | typedef struct xfs_dir_leaf_entry { /* sorted on key, not name */ |
86 | xfs_dahash_t hashval; /* hash value of name */ | 86 | __be32 hashval; /* hash value of name */ |
87 | __uint16_t nameidx; /* index into buffer of name */ | 87 | __be16 nameidx; /* index into buffer of name */ |
88 | __uint8_t namelen; /* length of name string */ | 88 | __u8 namelen; /* length of name string */ |
89 | __uint8_t pad2; | 89 | __u8 pad2; |
90 | } xfs_dir_leaf_entry_t; | 90 | } xfs_dir_leaf_entry_t; |
91 | 91 | ||
92 | typedef struct xfs_dir_leaf_name { | 92 | typedef struct xfs_dir_leaf_name { |