aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorNathan Scott <nathans@sgi.com>2006-03-17 01:29:02 -0500
committerNathan Scott <nathans@sgi.com>2006-03-17 01:29:02 -0500
commit6b19f2d87da9908acf1e0f48b4e79cf8bc833811 (patch)
tree532199e785a22b41a046ff6e5b2a9d99d3eb566a /fs/xfs
parent918ae424e18666249cf32f16ba2803061bf1ebb7 (diff)
[XFS] endianess annotations for xfs_attr_leaf_entry_t
SGI-PV: 943272 SGI-Modid: xfs-linux-melb:xfs-kern:25498a Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Nathan Scott <nathans@sgi.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_attr.c14
-rw-r--r--fs/xfs/xfs_attr_leaf.c133
-rw-r--r--fs/xfs/xfs_attr_leaf.h19
3 files changed, 74 insertions, 92 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 4a3f3cf6b20c..98d0f4d10602 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -1770,17 +1770,14 @@ xfs_attr_node_list(xfs_attr_list_context_t *context)
1770 break; 1770 break;
1771 case XFS_ATTR_LEAF_MAGIC: 1771 case XFS_ATTR_LEAF_MAGIC:
1772 leaf = bp->data; 1772 leaf = bp->data;
1773 if (cursor->hashval > 1773 if (cursor->hashval > be32_to_cpu(leaf->entries[
1774 INT_GET(leaf->entries[ 1774 be16_to_cpu(leaf->hdr.count)-1].hashval)) {
1775 be16_to_cpu(leaf->hdr.count)-1].hashval,
1776 ARCH_CONVERT)) {
1777 xfs_attr_trace_l_cl("wrong blk", 1775 xfs_attr_trace_l_cl("wrong blk",
1778 context, leaf); 1776 context, leaf);
1779 xfs_da_brelse(NULL, bp); 1777 xfs_da_brelse(NULL, bp);
1780 bp = NULL; 1778 bp = NULL;
1781 } else if (cursor->hashval <= 1779 } else if (cursor->hashval <=
1782 INT_GET(leaf->entries[0].hashval, 1780 be32_to_cpu(leaf->entries[0].hashval)) {
1783 ARCH_CONVERT)) {
1784 xfs_attr_trace_l_cl("maybe wrong blk", 1781 xfs_attr_trace_l_cl("maybe wrong blk",
1785 context, leaf); 1782 context, leaf);
1786 xfs_da_brelse(NULL, bp); 1783 xfs_da_brelse(NULL, bp);
@@ -2289,8 +2286,9 @@ xfs_attr_trace_l_cl(char *where, struct xfs_attr_list_context *context,
2289 (__psunsigned_t)context->dupcnt, 2286 (__psunsigned_t)context->dupcnt,
2290 (__psunsigned_t)context->flags, 2287 (__psunsigned_t)context->flags,
2291 (__psunsigned_t)be16_to_cpu(leaf->hdr.count), 2288 (__psunsigned_t)be16_to_cpu(leaf->hdr.count),
2292 (__psunsigned_t)INT_GET(leaf->entries[0].hashval, ARCH_CONVERT), 2289 (__psunsigned_t)be32_to_cpu(leaf->entries[0].hashval),
2293 (__psunsigned_t)INT_GET(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval, ARCH_CONVERT)); 2290 (__psunsigned_t)be32_to_cpu(leaf->entries[
2291 be16_to_cpu(leaf->hdr.count)-1].hashval));
2294} 2292}
2295 2293
2296/* 2294/*
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 31b55e58e2cf..319285c24e42 100644
--- a/fs/xfs/xfs_attr_leaf.c
+++ b/fs/xfs/xfs_attr_leaf.c
@@ -819,7 +819,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff)
819 nargs.namelen = name_loc->namelen; 819 nargs.namelen = name_loc->namelen;
820 nargs.value = (char *)&name_loc->nameval[nargs.namelen]; 820 nargs.value = (char *)&name_loc->nameval[nargs.namelen];
821 nargs.valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT); 821 nargs.valuelen = INT_GET(name_loc->valuelen, ARCH_CONVERT);
822 nargs.hashval = INT_GET(entry->hashval, ARCH_CONVERT); 822 nargs.hashval = be32_to_cpu(entry->hashval);
823 nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE : 823 nargs.flags = (entry->flags & XFS_ATTR_SECURE) ? ATTR_SECURE :
824 ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0); 824 ((entry->flags & XFS_ATTR_ROOT) ? ATTR_ROOT : 0);
825 xfs_attr_shortform_add(&nargs, forkoff); 825 xfs_attr_shortform_add(&nargs, forkoff);
@@ -1104,10 +1104,9 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1104 be16_add(&map->size, 1104 be16_add(&map->size,
1105 -xfs_attr_leaf_newentsize(args->namelen, args->valuelen, 1105 -xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1106 mp->m_sb.sb_blocksize, &tmp)); 1106 mp->m_sb.sb_blocksize, &tmp));
1107 INT_SET(entry->nameidx, ARCH_CONVERT, 1107 entry->nameidx = cpu_to_be16(be16_to_cpu(map->base) +
1108 be16_to_cpu(map->base) 1108 be16_to_cpu(map->size));
1109 + be16_to_cpu(map->size)); 1109 entry->hashval = cpu_to_be32(args->hashval);
1110 INT_SET(entry->hashval, ARCH_CONVERT, args->hashval);
1111 entry->flags = tmp ? XFS_ATTR_LOCAL : 0; 1110 entry->flags = tmp ? XFS_ATTR_LOCAL : 0;
1112 entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE : 1111 entry->flags |= (args->flags & ATTR_SECURE) ? XFS_ATTR_SECURE :
1113 ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0); 1112 ((args->flags & ATTR_ROOT) ? XFS_ATTR_ROOT : 0);
@@ -1120,12 +1119,10 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1120 } 1119 }
1121 xfs_da_log_buf(args->trans, bp, 1120 xfs_da_log_buf(args->trans, bp,
1122 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry))); 1121 XFS_DA_LOGRANGE(leaf, entry, sizeof(*entry)));
1123 ASSERT((args->index == 0) || (INT_GET(entry->hashval, ARCH_CONVERT) 1122 ASSERT((args->index == 0) ||
1124 >= INT_GET((entry-1)->hashval, 1123 (be32_to_cpu(entry->hashval) >= be32_to_cpu((entry-1)->hashval)));
1125 ARCH_CONVERT)));
1126 ASSERT((args->index == be16_to_cpu(hdr->count)-1) || 1124 ASSERT((args->index == be16_to_cpu(hdr->count)-1) ||
1127 (INT_GET(entry->hashval, ARCH_CONVERT) 1125 (be32_to_cpu(entry->hashval) <= be32_to_cpu((entry+1)->hashval)));
1128 <= (INT_GET((entry+1)->hashval, ARCH_CONVERT))));
1129 1126
1130 /* 1127 /*
1131 * Copy the attribute name and value into the new space. 1128 * Copy the attribute name and value into the new space.
@@ -1161,8 +1158,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex)
1161 /* 1158 /*
1162 * Update the control info for this leaf node 1159 * Update the control info for this leaf node
1163 */ 1160 */
1164 if (INT_GET(entry->nameidx, ARCH_CONVERT) 1161 if (be16_to_cpu(entry->nameidx) < be16_to_cpu(hdr->firstused)) {
1165 < be16_to_cpu(hdr->firstused)) {
1166 /* both on-disk, don't endian-flip twice */ 1162 /* both on-disk, don't endian-flip twice */
1167 hdr->firstused = entry->nameidx; 1163 hdr->firstused = entry->nameidx;
1168 } 1164 }
@@ -1364,12 +1360,10 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1,
1364 /* 1360 /*
1365 * Copy out last hashval in each block for B-tree code. 1361 * Copy out last hashval in each block for B-tree code.
1366 */ 1362 */
1367 blk1->hashval = 1363 blk1->hashval = be32_to_cpu(
1368 INT_GET(leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval, 1364 leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval);
1369 ARCH_CONVERT); 1365 blk2->hashval = be32_to_cpu(
1370 blk2->hashval = 1366 leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval);
1371 INT_GET(leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval,
1372 ARCH_CONVERT);
1373 1367
1374 /* 1368 /*
1375 * Adjust the expected index for insertion. 1369 * Adjust the expected index for insertion.
@@ -1668,9 +1662,8 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1668 ASSERT(be16_to_cpu(hdr->firstused) >= 1662 ASSERT(be16_to_cpu(hdr->firstused) >=
1669 ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr))); 1663 ((be16_to_cpu(hdr->count) * sizeof(*entry)) + sizeof(*hdr)));
1670 entry = &leaf->entries[args->index]; 1664 entry = &leaf->entries[args->index];
1671 ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) 1665 ASSERT(be16_to_cpu(entry->nameidx) >= be16_to_cpu(hdr->firstused));
1672 >= be16_to_cpu(hdr->firstused)); 1666 ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
1673 ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) < XFS_LBSIZE(mp));
1674 1667
1675 /* 1668 /*
1676 * Scan through free region table: 1669 * Scan through free region table:
@@ -1695,10 +1688,10 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1695 } 1688 }
1696 1689
1697 if ((be16_to_cpu(map->base) + be16_to_cpu(map->size)) 1690 if ((be16_to_cpu(map->base) + be16_to_cpu(map->size))
1698 == INT_GET(entry->nameidx, ARCH_CONVERT)) { 1691 == be16_to_cpu(entry->nameidx)) {
1699 before = i; 1692 before = i;
1700 } else if (be16_to_cpu(map->base) 1693 } else if (be16_to_cpu(map->base)
1701 == (INT_GET(entry->nameidx, ARCH_CONVERT) + entsize)) { 1694 == (be16_to_cpu(entry->nameidx) + entsize)) {
1702 after = i; 1695 after = i;
1703 } else if (be16_to_cpu(map->size) < tmp) { 1696 } else if (be16_to_cpu(map->size) < tmp) {
1704 tmp = be16_to_cpu(map->size); 1697 tmp = be16_to_cpu(map->size);
@@ -1733,8 +1726,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1733 */ 1726 */
1734 map = &hdr->freemap[smallest]; 1727 map = &hdr->freemap[smallest];
1735 if (be16_to_cpu(map->size) < entsize) { 1728 if (be16_to_cpu(map->size) < entsize) {
1736 map->base = cpu_to_be16( 1729 map->base = cpu_to_be16(be16_to_cpu(entry->nameidx));
1737 INT_GET(entry->nameidx, ARCH_CONVERT));
1738 map->size = cpu_to_be16(entsize); 1730 map->size = cpu_to_be16(entsize);
1739 } 1731 }
1740 } 1732 }
@@ -1742,8 +1734,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1742 /* 1734 /*
1743 * Did we remove the first entry? 1735 * Did we remove the first entry?
1744 */ 1736 */
1745 if (INT_GET(entry->nameidx, ARCH_CONVERT) 1737 if (be16_to_cpu(entry->nameidx) == be16_to_cpu(hdr->firstused))
1746 == be16_to_cpu(hdr->firstused))
1747 smallest = 1; 1738 smallest = 1;
1748 else 1739 else
1749 smallest = 0; 1740 smallest = 0;
@@ -1776,12 +1767,12 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args)
1776 tmp = XFS_LBSIZE(mp); 1767 tmp = XFS_LBSIZE(mp);
1777 entry = &leaf->entries[0]; 1768 entry = &leaf->entries[0];
1778 for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) { 1769 for (i = be16_to_cpu(hdr->count)-1; i >= 0; entry++, i--) {
1779 ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) 1770 ASSERT(be16_to_cpu(entry->nameidx) >=
1780 >= be16_to_cpu(hdr->firstused)); 1771 be16_to_cpu(hdr->firstused));
1781 ASSERT(INT_GET(entry->nameidx, ARCH_CONVERT) 1772 ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp));
1782 < XFS_LBSIZE(mp)); 1773
1783 if (INT_GET(entry->nameidx, ARCH_CONVERT) < tmp) 1774 if (be16_to_cpu(entry->nameidx) < tmp)
1784 tmp = INT_GET(entry->nameidx, ARCH_CONVERT); 1775 tmp = be16_to_cpu(entry->nameidx);
1785 } 1776 }
1786 hdr->firstused = cpu_to_be16(tmp); 1777 hdr->firstused = cpu_to_be16(tmp);
1787 if (!hdr->firstused) { 1778 if (!hdr->firstused) {
@@ -1832,9 +1823,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1832 /* 1823 /*
1833 * Save last hashval from dying block for later Btree fixup. 1824 * Save last hashval from dying block for later Btree fixup.
1834 */ 1825 */
1835 drop_blk->hashval = 1826 drop_blk->hashval = be32_to_cpu(
1836 INT_GET(drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1] 1827 drop_leaf->entries[be16_to_cpu(drop_leaf->hdr.count)-1].hashval);
1837 .hashval, ARCH_CONVERT);
1838 1828
1839 /* 1829 /*
1840 * Check if we need a temp buffer, or can we do it in place. 1830 * Check if we need a temp buffer, or can we do it in place.
@@ -1895,9 +1885,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk,
1895 /* 1885 /*
1896 * Copy out last hashval in each block for B-tree code. 1886 * Copy out last hashval in each block for B-tree code.
1897 */ 1887 */
1898 save_blk->hashval = 1888 save_blk->hashval = be32_to_cpu(
1899 INT_GET(save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1] 1889 save_leaf->entries[be16_to_cpu(save_leaf->hdr.count)-1].hashval);
1900 .hashval, ARCH_CONVERT);
1901} 1890}
1902 1891
1903/*======================================================================== 1892/*========================================================================
@@ -1940,9 +1929,9 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1940 for (entry = &leaf->entries[probe]; span > 4; 1929 for (entry = &leaf->entries[probe]; span > 4;
1941 entry = &leaf->entries[probe]) { 1930 entry = &leaf->entries[probe]) {
1942 span /= 2; 1931 span /= 2;
1943 if (INT_GET(entry->hashval, ARCH_CONVERT) < hashval) 1932 if (be32_to_cpu(entry->hashval) < hashval)
1944 probe += span; 1933 probe += span;
1945 else if (INT_GET(entry->hashval, ARCH_CONVERT) > hashval) 1934 else if (be32_to_cpu(entry->hashval) > hashval)
1946 probe -= span; 1935 probe -= span;
1947 else 1936 else
1948 break; 1937 break;
@@ -1950,25 +1939,23 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1950 ASSERT((probe >= 0) && 1939 ASSERT((probe >= 0) &&
1951 (!leaf->hdr.count 1940 (!leaf->hdr.count
1952 || (probe < be16_to_cpu(leaf->hdr.count)))); 1941 || (probe < be16_to_cpu(leaf->hdr.count))));
1953 ASSERT((span <= 4) || (INT_GET(entry->hashval, ARCH_CONVERT) 1942 ASSERT((span <= 4) || (be32_to_cpu(entry->hashval) == hashval));
1954 == hashval));
1955 1943
1956 /* 1944 /*
1957 * Since we may have duplicate hashval's, find the first matching 1945 * Since we may have duplicate hashval's, find the first matching
1958 * hashval in the leaf. 1946 * hashval in the leaf.
1959 */ 1947 */
1960 while ((probe > 0) && (INT_GET(entry->hashval, ARCH_CONVERT) 1948 while ((probe > 0) && (be32_to_cpu(entry->hashval) >= hashval)) {
1961 >= hashval)) {
1962 entry--; 1949 entry--;
1963 probe--; 1950 probe--;
1964 } 1951 }
1965 while ((probe < be16_to_cpu(leaf->hdr.count)) 1952 while ((probe < be16_to_cpu(leaf->hdr.count)) &&
1966 && (INT_GET(entry->hashval, ARCH_CONVERT) < hashval)) { 1953 (be32_to_cpu(entry->hashval) < hashval)) {
1967 entry++; 1954 entry++;
1968 probe++; 1955 probe++;
1969 } 1956 }
1970 if ((probe == be16_to_cpu(leaf->hdr.count)) 1957 if ((probe == be16_to_cpu(leaf->hdr.count)) ||
1971 || (INT_GET(entry->hashval, ARCH_CONVERT) != hashval)) { 1958 (be32_to_cpu(entry->hashval) != hashval)) {
1972 args->index = probe; 1959 args->index = probe;
1973 return(XFS_ERROR(ENOATTR)); 1960 return(XFS_ERROR(ENOATTR));
1974 } 1961 }
@@ -1976,8 +1963,8 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args)
1976 /* 1963 /*
1977 * Duplicate keys may be present, so search all of them for a match. 1964 * Duplicate keys may be present, so search all of them for a match.
1978 */ 1965 */
1979 for ( ; (probe < be16_to_cpu(leaf->hdr.count)) 1966 for ( ; (probe < be16_to_cpu(leaf->hdr.count)) &&
1980 && (INT_GET(entry->hashval, ARCH_CONVERT) == hashval); 1967 (be32_to_cpu(entry->hashval) == hashval);
1981 entry++, probe++) { 1968 entry++, probe++) {
1982/* 1969/*
1983 * GROT: Add code to remove incomplete entries. 1970 * GROT: Add code to remove incomplete entries.
@@ -2150,7 +2137,7 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2150 entry_d = &leaf_d->entries[start_d]; 2137 entry_d = &leaf_d->entries[start_d];
2151 desti = start_d; 2138 desti = start_d;
2152 for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) { 2139 for (i = 0; i < count; entry_s++, entry_d++, desti++, i++) {
2153 ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) 2140 ASSERT(be16_to_cpu(entry_s->nameidx)
2154 >= be16_to_cpu(hdr_s->firstused)); 2141 >= be16_to_cpu(hdr_s->firstused));
2155 tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i); 2142 tmp = xfs_attr_leaf_entsize(leaf_s, start_s + i);
2156#ifdef GROT 2143#ifdef GROT
@@ -2175,11 +2162,11 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s,
2175 /* both on-disk, don't endian flip twice */ 2162 /* both on-disk, don't endian flip twice */
2176 entry_d->nameidx = hdr_d->firstused; 2163 entry_d->nameidx = hdr_d->firstused;
2177 entry_d->flags = entry_s->flags; 2164 entry_d->flags = entry_s->flags;
2178 ASSERT(INT_GET(entry_d->nameidx, ARCH_CONVERT) + tmp 2165 ASSERT(be16_to_cpu(entry_d->nameidx) + tmp
2179 <= XFS_LBSIZE(mp)); 2166 <= XFS_LBSIZE(mp));
2180 memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti), 2167 memmove(XFS_ATTR_LEAF_NAME(leaf_d, desti),
2181 XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp); 2168 XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), tmp);
2182 ASSERT(INT_GET(entry_s->nameidx, ARCH_CONVERT) + tmp 2169 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
2183 <= XFS_LBSIZE(mp)); 2170 <= XFS_LBSIZE(mp));
2184 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp); 2171 memset(XFS_ATTR_LEAF_NAME(leaf_s, start_s + i), 0, tmp);
2185 be16_add(&hdr_s->usedbytes, -tmp); 2172 be16_add(&hdr_s->usedbytes, -tmp);
@@ -2252,12 +2239,12 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp)
2252 (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC)); 2239 (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC));
2253 if ((be16_to_cpu(leaf1->hdr.count) > 0) && 2240 if ((be16_to_cpu(leaf1->hdr.count) > 0) &&
2254 (be16_to_cpu(leaf2->hdr.count) > 0) && 2241 (be16_to_cpu(leaf2->hdr.count) > 0) &&
2255 ((INT_GET(leaf2->entries[0].hashval, ARCH_CONVERT) < 2242 ((be32_to_cpu(leaf2->entries[0].hashval) <
2256 INT_GET(leaf1->entries[0].hashval, ARCH_CONVERT)) || 2243 be32_to_cpu(leaf1->entries[0].hashval)) ||
2257 (INT_GET(leaf2->entries[be16_to_cpu(leaf2->hdr.count)-1].hashval, 2244 (be32_to_cpu(leaf2->entries[
2258 ARCH_CONVERT) < 2245 be16_to_cpu(leaf2->hdr.count)-1].hashval) <
2259 INT_GET(leaf1->entries[be16_to_cpu(leaf1->hdr.count)-1].hashval, 2246 be32_to_cpu(leaf1->entries[
2260 ARCH_CONVERT)))) { 2247 be16_to_cpu(leaf1->hdr.count)-1].hashval)))) {
2261 return(1); 2248 return(1);
2262 } 2249 }
2263 return(0); 2250 return(0);
@@ -2277,8 +2264,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count)
2277 *count = be16_to_cpu(leaf->hdr.count); 2264 *count = be16_to_cpu(leaf->hdr.count);
2278 if (!leaf->hdr.count) 2265 if (!leaf->hdr.count)
2279 return(0); 2266 return(0);
2280 return (INT_GET(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval, 2267 return be32_to_cpu(leaf->entries[be16_to_cpu(leaf->hdr.count)-1].hashval);
2281 ARCH_CONVERT));
2282} 2268}
2283 2269
2284/* 2270/*
@@ -2356,15 +2342,14 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2356 if (context->resynch) { 2342 if (context->resynch) {
2357 entry = &leaf->entries[0]; 2343 entry = &leaf->entries[0];
2358 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { 2344 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2359 if (INT_GET(entry->hashval, ARCH_CONVERT) 2345 if (be32_to_cpu(entry->hashval) == cursor->hashval) {
2360 == cursor->hashval) {
2361 if (cursor->offset == context->dupcnt) { 2346 if (cursor->offset == context->dupcnt) {
2362 context->dupcnt = 0; 2347 context->dupcnt = 0;
2363 break; 2348 break;
2364 } 2349 }
2365 context->dupcnt++; 2350 context->dupcnt++;
2366 } else if (INT_GET(entry->hashval, ARCH_CONVERT) 2351 } else if (be32_to_cpu(entry->hashval) >
2367 > cursor->hashval) { 2352 cursor->hashval) {
2368 context->dupcnt = 0; 2353 context->dupcnt = 0;
2369 break; 2354 break;
2370 } 2355 }
@@ -2387,8 +2372,8 @@ xfs_attr_leaf_list_int(xfs_dabuf_t *bp, xfs_attr_list_context_t *context)
2387 && (retval == 0); entry++, i++) { 2372 && (retval == 0); entry++, i++) {
2388 attrnames_t *namesp; 2373 attrnames_t *namesp;
2389 2374
2390 if (INT_GET(entry->hashval, ARCH_CONVERT) != cursor->hashval) { 2375 if (be32_to_cpu(entry->hashval) != cursor->hashval) {
2391 cursor->hashval = INT_GET(entry->hashval, ARCH_CONVERT); 2376 cursor->hashval = be32_to_cpu(entry->hashval);
2392 cursor->offset = 0; 2377 cursor->offset = 0;
2393 } 2378 }
2394 2379
@@ -2554,7 +2539,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args)
2554 namelen = name_rmt->namelen; 2539 namelen = name_rmt->namelen;
2555 name = (char *)name_rmt->name; 2540 name = (char *)name_rmt->name;
2556 } 2541 }
2557 ASSERT(INT_GET(entry->hashval, ARCH_CONVERT) == args->hashval); 2542 ASSERT(be32_to_cpu(entry->hashval) == args->hashval);
2558 ASSERT(namelen == args->namelen); 2543 ASSERT(namelen == args->namelen);
2559 ASSERT(memcmp(name, args->name, namelen) == 0); 2544 ASSERT(memcmp(name, args->name, namelen) == 0);
2560#endif /* DEBUG */ 2545#endif /* DEBUG */
@@ -2706,7 +2691,7 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args)
2706 namelen2 = name_rmt->namelen; 2691 namelen2 = name_rmt->namelen;
2707 name2 = (char *)name_rmt->name; 2692 name2 = (char *)name_rmt->name;
2708 } 2693 }
2709 ASSERT(INT_GET(entry1->hashval, ARCH_CONVERT) == INT_GET(entry2->hashval, ARCH_CONVERT)); 2694 ASSERT(be32_to_cpu(entry1->hashval) == be32_to_cpu(entry2->hashval));
2710 ASSERT(namelen1 == namelen2); 2695 ASSERT(namelen1 == namelen2);
2711 ASSERT(memcmp(name1, name2, namelen1) == 0); 2696 ASSERT(memcmp(name1, name2, namelen1) == 0);
2712#endif /* DEBUG */ 2697#endif /* DEBUG */
@@ -2934,8 +2919,8 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2934 count = 0; 2919 count = 0;
2935 entry = &leaf->entries[0]; 2920 entry = &leaf->entries[0];
2936 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { 2921 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2937 if ( INT_GET(entry->nameidx, ARCH_CONVERT) 2922 if (be16_to_cpu(entry->nameidx) &&
2938 && ((entry->flags & XFS_ATTR_LOCAL) == 0)) { 2923 ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
2939 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); 2924 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
2940 if (name_rmt->valueblk) 2925 if (name_rmt->valueblk)
2941 count++; 2926 count++;
@@ -2962,8 +2947,8 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp)
2962 lp = list; 2947 lp = list;
2963 entry = &leaf->entries[0]; 2948 entry = &leaf->entries[0];
2964 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) { 2949 for (i = 0; i < be16_to_cpu(leaf->hdr.count); entry++, i++) {
2965 if ( INT_GET(entry->nameidx, ARCH_CONVERT) 2950 if (be16_to_cpu(entry->nameidx) &&
2966 && ((entry->flags & XFS_ATTR_LOCAL) == 0)) { 2951 ((entry->flags & XFS_ATTR_LOCAL) == 0)) {
2967 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i); 2952 name_rmt = XFS_ATTR_LEAF_NAME_REMOTE(leaf, i);
2968 if (name_rmt->valueblk) { 2953 if (name_rmt->valueblk) {
2969 /* both on-disk, don't endian flip twice */ 2954 /* both on-disk, don't endian flip twice */
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 52b771052c57..7fbe4880bb83 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -89,10 +89,10 @@ typedef struct xfs_attr_leaf_hdr { /* constant-structure header block */
89} xfs_attr_leaf_hdr_t; 89} xfs_attr_leaf_hdr_t;
90 90
91typedef struct xfs_attr_leaf_entry { /* sorted on key, not name */ 91typedef struct xfs_attr_leaf_entry { /* sorted on key, not name */
92 xfs_dahash_t hashval; /* hash value of name */ 92 __be32 hashval; /* hash value of name */
93 __uint16_t nameidx; /* index into buffer of name/value */ 93 __be16 nameidx; /* index into buffer of name/value */
94 __uint8_t flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */ 94 __u8 flags; /* LOCAL/ROOT/SECURE/INCOMPLETE flag */
95 __uint8_t pad2; /* unused pad byte */ 95 __u8 pad2; /* unused pad byte */
96} xfs_attr_leaf_entry_t; 96} xfs_attr_leaf_entry_t;
97 97
98typedef struct xfs_attr_leaf_name_local { 98typedef struct xfs_attr_leaf_name_local {
@@ -143,8 +143,8 @@ typedef struct xfs_attr_leafblock {
143static inline xfs_attr_leaf_name_remote_t * 143static inline xfs_attr_leaf_name_remote_t *
144xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx) 144xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
145{ 145{
146 return (xfs_attr_leaf_name_remote_t *) &((char *) 146 return (xfs_attr_leaf_name_remote_t *)
147 (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]; 147 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
148} 148}
149 149
150#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \ 150#define XFS_ATTR_LEAF_NAME_LOCAL(leafp,idx) \
@@ -152,16 +152,15 @@ xfs_attr_leaf_name_remote(xfs_attr_leafblock_t *leafp, int idx)
152static inline xfs_attr_leaf_name_local_t * 152static inline xfs_attr_leaf_name_local_t *
153xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx) 153xfs_attr_leaf_name_local(xfs_attr_leafblock_t *leafp, int idx)
154{ 154{
155 return (xfs_attr_leaf_name_local_t *) &((char *) 155 return (xfs_attr_leaf_name_local_t *)
156 (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]; 156 &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
157} 157}
158 158
159#define XFS_ATTR_LEAF_NAME(leafp,idx) \ 159#define XFS_ATTR_LEAF_NAME(leafp,idx) \
160 xfs_attr_leaf_name(leafp,idx) 160 xfs_attr_leaf_name(leafp,idx)
161static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx) 161static inline char *xfs_attr_leaf_name(xfs_attr_leafblock_t *leafp, int idx)
162{ 162{
163 return (&((char *) 163 return &((char *)leafp)[be16_to_cpu(leafp->entries[idx].nameidx)];
164 (leafp))[INT_GET((leafp)->entries[idx].nameidx, ARCH_CONVERT)]);
165} 164}
166 165
167/* 166/*