diff options
-rw-r--r-- | fs/xfs/xfs_attr.c | 17 | ||||
-rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 98 | ||||
-rw-r--r-- | fs/xfs/xfs_da_btree.c | 206 | ||||
-rw-r--r-- | fs/xfs/xfs_da_btree.h | 8 | ||||
-rw-r--r-- | fs/xfs/xfs_dir.c | 16 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_block.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_leaf.c | 20 | ||||
-rw-r--r-- | fs/xfs/xfs_dir2_node.c | 28 | ||||
-rw-r--r-- | fs/xfs/xfs_dir_leaf.c | 55 |
9 files changed, 205 insertions, 245 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c index acf1b7c9f1db..36b120d859af 100644 --- a/fs/xfs/xfs_attr.c +++ b/fs/xfs/xfs_attr.c | |||
@@ -1127,8 +1127,7 @@ xfs_attr_leaf_list(xfs_attr_list_context_t *context) | |||
1127 | return(error); | 1127 | return(error); |
1128 | ASSERT(bp != NULL); | 1128 | ASSERT(bp != NULL); |
1129 | leaf = bp->data; | 1129 | leaf = bp->data; |
1130 | if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1130 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_ATTR_LEAF_MAGIC)) { |
1131 | != XFS_ATTR_LEAF_MAGIC)) { | ||
1132 | XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, | 1131 | XFS_CORRUPTION_ERROR("xfs_attr_leaf_list", XFS_ERRLEVEL_LOW, |
1133 | context->dp->i_mount, leaf); | 1132 | context->dp->i_mount, leaf); |
1134 | xfs_da_brelse(NULL, bp); | 1133 | xfs_da_brelse(NULL, bp); |
@@ -1541,8 +1540,8 @@ xfs_attr_node_removename(xfs_da_args_t *args) | |||
1541 | XFS_ATTR_FORK); | 1540 | XFS_ATTR_FORK); |
1542 | if (error) | 1541 | if (error) |
1543 | goto out; | 1542 | goto out; |
1544 | ASSERT(INT_GET(((xfs_attr_leafblock_t *) | 1543 | ASSERT(be16_to_cpu(((xfs_attr_leafblock_t *) |
1545 | bp->data)->hdr.info.magic, ARCH_CONVERT) | 1544 | bp->data)->hdr.info.magic) |
1546 | == XFS_ATTR_LEAF_MAGIC); | 1545 | == XFS_ATTR_LEAF_MAGIC); |
1547 | 1546 | ||
1548 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { | 1547 | if ((forkoff = xfs_attr_shortform_allfit(bp, dp))) { |
@@ -1763,7 +1762,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1763 | return(error); | 1762 | return(error); |
1764 | if (bp) { | 1763 | if (bp) { |
1765 | node = bp->data; | 1764 | node = bp->data; |
1766 | switch (INT_GET(node->hdr.info.magic, ARCH_CONVERT)) { | 1765 | switch (be16_to_cpu(node->hdr.info.magic)) { |
1767 | case XFS_DA_NODE_MAGIC: | 1766 | case XFS_DA_NODE_MAGIC: |
1768 | xfs_attr_trace_l_cn("wrong blk", context, node); | 1767 | xfs_attr_trace_l_cn("wrong blk", context, node); |
1769 | xfs_da_brelse(NULL, bp); | 1768 | xfs_da_brelse(NULL, bp); |
@@ -1817,10 +1816,10 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1817 | return(XFS_ERROR(EFSCORRUPTED)); | 1816 | return(XFS_ERROR(EFSCORRUPTED)); |
1818 | } | 1817 | } |
1819 | node = bp->data; | 1818 | node = bp->data; |
1820 | if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 1819 | if (be16_to_cpu(node->hdr.info.magic) |
1821 | == XFS_ATTR_LEAF_MAGIC) | 1820 | == XFS_ATTR_LEAF_MAGIC) |
1822 | break; | 1821 | break; |
1823 | if (unlikely(INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 1822 | if (unlikely(be16_to_cpu(node->hdr.info.magic) |
1824 | != XFS_DA_NODE_MAGIC)) { | 1823 | != XFS_DA_NODE_MAGIC)) { |
1825 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", | 1824 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(3)", |
1826 | XFS_ERRLEVEL_LOW, | 1825 | XFS_ERRLEVEL_LOW, |
@@ -1858,7 +1857,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1858 | */ | 1857 | */ |
1859 | for (;;) { | 1858 | for (;;) { |
1860 | leaf = bp->data; | 1859 | leaf = bp->data; |
1861 | if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1860 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) |
1862 | != XFS_ATTR_LEAF_MAGIC)) { | 1861 | != XFS_ATTR_LEAF_MAGIC)) { |
1863 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", | 1862 | XFS_CORRUPTION_ERROR("xfs_attr_node_list(4)", |
1864 | XFS_ERRLEVEL_LOW, | 1863 | XFS_ERRLEVEL_LOW, |
@@ -1869,7 +1868,7 @@ xfs_attr_node_list(xfs_attr_list_context_t *context) | |||
1869 | error = xfs_attr_leaf_list_int(bp, context); | 1868 | error = xfs_attr_leaf_list_int(bp, context); |
1870 | if (error || !leaf->hdr.info.forw) | 1869 | if (error || !leaf->hdr.info.forw) |
1871 | break; /* not really an error, buffer full or EOF */ | 1870 | break; /* not really an error, buffer full or EOF */ |
1872 | cursor->blkno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT); | 1871 | cursor->blkno = be32_to_cpu(leaf->hdr.info.forw); |
1873 | xfs_da_brelse(NULL, bp); | 1872 | xfs_da_brelse(NULL, bp); |
1874 | error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, | 1873 | error = xfs_da_read_buf(NULL, context->dp, cursor->blkno, -1, |
1875 | &bp, XFS_ATTR_FORK); | 1874 | &bp, XFS_ATTR_FORK); |
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index fe91eac4e2a7..d279d944e03d 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -720,8 +720,7 @@ xfs_attr_shortform_allfit(xfs_dabuf_t *bp, xfs_inode_t *dp) | |||
720 | int bytes, i; | 720 | int bytes, i; |
721 | 721 | ||
722 | leaf = bp->data; | 722 | leaf = bp->data; |
723 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 723 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
724 | == XFS_ATTR_LEAF_MAGIC); | ||
725 | 724 | ||
726 | entry = &leaf->entries[0]; | 725 | entry = &leaf->entries[0]; |
727 | bytes = sizeof(struct xfs_attr_sf_hdr); | 726 | bytes = sizeof(struct xfs_attr_sf_hdr); |
@@ -766,8 +765,7 @@ xfs_attr_leaf_to_shortform(xfs_dabuf_t *bp, xfs_da_args_t *args, int forkoff) | |||
766 | ASSERT(bp != NULL); | 765 | ASSERT(bp != NULL); |
767 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); | 766 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); |
768 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; | 767 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; |
769 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 768 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
770 | == XFS_ATTR_LEAF_MAGIC); | ||
771 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); | 769 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); |
772 | 770 | ||
773 | /* | 771 | /* |
@@ -875,8 +873,7 @@ xfs_attr_leaf_to_node(xfs_da_args_t *args) | |||
875 | goto out; | 873 | goto out; |
876 | node = bp1->data; | 874 | node = bp1->data; |
877 | leaf = bp2->data; | 875 | leaf = bp2->data; |
878 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 876 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
879 | == XFS_ATTR_LEAF_MAGIC); | ||
880 | /* both on-disk, don't endian-flip twice */ | 877 | /* both on-disk, don't endian-flip twice */ |
881 | node->btree[0].hashval = | 878 | node->btree[0].hashval = |
882 | leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval; | 879 | leaf->entries[INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval; |
@@ -920,7 +917,7 @@ xfs_attr_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) | |||
920 | leaf = bp->data; | 917 | leaf = bp->data; |
921 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); | 918 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); |
922 | hdr = &leaf->hdr; | 919 | hdr = &leaf->hdr; |
923 | INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_ATTR_LEAF_MAGIC); | 920 | hdr->info.magic = cpu_to_be16(XFS_ATTR_LEAF_MAGIC); |
924 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); | 921 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); |
925 | if (!hdr->firstused) { | 922 | if (!hdr->firstused) { |
926 | INT_SET(hdr->firstused, ARCH_CONVERT, | 923 | INT_SET(hdr->firstused, ARCH_CONVERT, |
@@ -1004,8 +1001,7 @@ xfs_attr_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1004 | int tablesize, entsize, sum, tmp, i; | 1001 | int tablesize, entsize, sum, tmp, i; |
1005 | 1002 | ||
1006 | leaf = bp->data; | 1003 | leaf = bp->data; |
1007 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1004 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1008 | == XFS_ATTR_LEAF_MAGIC); | ||
1009 | ASSERT((args->index >= 0) | 1005 | ASSERT((args->index >= 0) |
1010 | && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 1006 | && (args->index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); |
1011 | hdr = &leaf->hdr; | 1007 | hdr = &leaf->hdr; |
@@ -1079,8 +1075,7 @@ xfs_attr_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int mapindex) | |||
1079 | int tmp, i; | 1075 | int tmp, i; |
1080 | 1076 | ||
1081 | leaf = bp->data; | 1077 | leaf = bp->data; |
1082 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1078 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1083 | == XFS_ATTR_LEAF_MAGIC); | ||
1084 | hdr = &leaf->hdr; | 1079 | hdr = &leaf->hdr; |
1085 | ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); | 1080 | ASSERT((mapindex >= 0) && (mapindex < XFS_ATTR_LEAF_MAPSIZE)); |
1086 | ASSERT((args->index >= 0) | 1081 | ASSERT((args->index >= 0) |
@@ -1279,10 +1274,8 @@ xfs_attr_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1279 | ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); | 1274 | ASSERT(blk2->magic == XFS_ATTR_LEAF_MAGIC); |
1280 | leaf1 = blk1->bp->data; | 1275 | leaf1 = blk1->bp->data; |
1281 | leaf2 = blk2->bp->data; | 1276 | leaf2 = blk2->bp->data; |
1282 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 1277 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1283 | == XFS_ATTR_LEAF_MAGIC); | 1278 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1284 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | ||
1285 | == XFS_ATTR_LEAF_MAGIC); | ||
1286 | args = state->args; | 1279 | args = state->args; |
1287 | 1280 | ||
1288 | /* | 1281 | /* |
@@ -1566,7 +1559,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1566 | */ | 1559 | */ |
1567 | blk = &state->path.blk[ state->path.active-1 ]; | 1560 | blk = &state->path.blk[ state->path.active-1 ]; |
1568 | info = blk->bp->data; | 1561 | info = blk->bp->data; |
1569 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1562 | ASSERT(be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); |
1570 | leaf = (xfs_attr_leafblock_t *)info; | 1563 | leaf = (xfs_attr_leafblock_t *)info; |
1571 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1564 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1572 | bytes = sizeof(xfs_attr_leaf_hdr_t) + | 1565 | bytes = sizeof(xfs_attr_leaf_hdr_t) + |
@@ -1588,7 +1581,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1588 | * Make altpath point to the block we want to keep and | 1581 | * Make altpath point to the block we want to keep and |
1589 | * path point to the block we want to drop (this one). | 1582 | * path point to the block we want to drop (this one). |
1590 | */ | 1583 | */ |
1591 | forward = info->forw; | 1584 | forward = (info->forw != 0); |
1592 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1585 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1593 | error = xfs_da_path_shift(state, &state->altpath, forward, | 1586 | error = xfs_da_path_shift(state, &state->altpath, forward, |
1594 | 0, &retval); | 1587 | 0, &retval); |
@@ -1610,13 +1603,12 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1610 | * to shrink an attribute list over time. | 1603 | * to shrink an attribute list over time. |
1611 | */ | 1604 | */ |
1612 | /* start with smaller blk num */ | 1605 | /* start with smaller blk num */ |
1613 | forward = (INT_GET(info->forw, ARCH_CONVERT) | 1606 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); |
1614 | < INT_GET(info->back, ARCH_CONVERT)); | ||
1615 | for (i = 0; i < 2; forward = !forward, i++) { | 1607 | for (i = 0; i < 2; forward = !forward, i++) { |
1616 | if (forward) | 1608 | if (forward) |
1617 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 1609 | blkno = be32_to_cpu(info->forw); |
1618 | else | 1610 | else |
1619 | blkno = INT_GET(info->back, ARCH_CONVERT); | 1611 | blkno = be32_to_cpu(info->back); |
1620 | if (blkno == 0) | 1612 | if (blkno == 0) |
1621 | continue; | 1613 | continue; |
1622 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 1614 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -1630,8 +1622,7 @@ xfs_attr_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1630 | bytes = state->blocksize - (state->blocksize>>2); | 1622 | bytes = state->blocksize - (state->blocksize>>2); |
1631 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | 1623 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); |
1632 | leaf = bp->data; | 1624 | leaf = bp->data; |
1633 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1625 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1634 | == XFS_ATTR_LEAF_MAGIC); | ||
1635 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1626 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1636 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); | 1627 | bytes -= INT_GET(leaf->hdr.usedbytes, ARCH_CONVERT); |
1637 | bytes -= count * sizeof(xfs_attr_leaf_entry_t); | 1628 | bytes -= count * sizeof(xfs_attr_leaf_entry_t); |
@@ -1685,8 +1676,7 @@ xfs_attr_leaf_remove(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1685 | xfs_mount_t *mp; | 1676 | xfs_mount_t *mp; |
1686 | 1677 | ||
1687 | leaf = bp->data; | 1678 | leaf = bp->data; |
1688 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1679 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1689 | == XFS_ATTR_LEAF_MAGIC); | ||
1690 | hdr = &leaf->hdr; | 1680 | hdr = &leaf->hdr; |
1691 | mp = args->trans->t_mountp; | 1681 | mp = args->trans->t_mountp; |
1692 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) | 1682 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) |
@@ -1859,10 +1849,8 @@ xfs_attr_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1859 | ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1849 | ASSERT(save_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1860 | drop_leaf = drop_blk->bp->data; | 1850 | drop_leaf = drop_blk->bp->data; |
1861 | save_leaf = save_blk->bp->data; | 1851 | save_leaf = save_blk->bp->data; |
1862 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) | 1852 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1863 | == XFS_ATTR_LEAF_MAGIC); | 1853 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1864 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) | ||
1865 | == XFS_ATTR_LEAF_MAGIC); | ||
1866 | drop_hdr = &drop_leaf->hdr; | 1854 | drop_hdr = &drop_leaf->hdr; |
1867 | save_hdr = &save_leaf->hdr; | 1855 | save_hdr = &save_leaf->hdr; |
1868 | 1856 | ||
@@ -1972,8 +1960,7 @@ xfs_attr_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
1972 | xfs_dahash_t hashval; | 1960 | xfs_dahash_t hashval; |
1973 | 1961 | ||
1974 | leaf = bp->data; | 1962 | leaf = bp->data; |
1975 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 1963 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
1976 | == XFS_ATTR_LEAF_MAGIC); | ||
1977 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) | 1964 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) |
1978 | < (XFS_LBSIZE(args->dp->i_mount)/8)); | 1965 | < (XFS_LBSIZE(args->dp->i_mount)/8)); |
1979 | 1966 | ||
@@ -2090,8 +2077,7 @@ xfs_attr_leaf_getvalue(xfs_dabuf_t *bp, xfs_da_args_t *args) | |||
2090 | xfs_attr_leaf_name_remote_t *name_rmt; | 2077 | xfs_attr_leaf_name_remote_t *name_rmt; |
2091 | 2078 | ||
2092 | leaf = bp->data; | 2079 | leaf = bp->data; |
2093 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2080 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2094 | == XFS_ATTR_LEAF_MAGIC); | ||
2095 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) | 2081 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) |
2096 | < (XFS_LBSIZE(args->dp->i_mount)/8)); | 2082 | < (XFS_LBSIZE(args->dp->i_mount)/8)); |
2097 | ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 2083 | ASSERT(args->index < ((int)INT_GET(leaf->hdr.count, ARCH_CONVERT))); |
@@ -2159,10 +2145,8 @@ xfs_attr_leaf_moveents(xfs_attr_leafblock_t *leaf_s, int start_s, | |||
2159 | /* | 2145 | /* |
2160 | * Set up environment. | 2146 | * Set up environment. |
2161 | */ | 2147 | */ |
2162 | ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) | 2148 | ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2163 | == XFS_ATTR_LEAF_MAGIC); | 2149 | ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2164 | ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) | ||
2165 | == XFS_ATTR_LEAF_MAGIC); | ||
2166 | hdr_s = &leaf_s->hdr; | 2150 | hdr_s = &leaf_s->hdr; |
2167 | hdr_d = &leaf_d->hdr; | 2151 | hdr_d = &leaf_d->hdr; |
2168 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) | 2152 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) |
@@ -2301,10 +2285,8 @@ xfs_attr_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) | |||
2301 | 2285 | ||
2302 | leaf1 = leaf1_bp->data; | 2286 | leaf1 = leaf1_bp->data; |
2303 | leaf2 = leaf2_bp->data; | 2287 | leaf2 = leaf2_bp->data; |
2304 | ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 2288 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC) && |
2305 | == XFS_ATTR_LEAF_MAGIC) && | 2289 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC)); |
2306 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | ||
2307 | == XFS_ATTR_LEAF_MAGIC)); | ||
2308 | if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) | 2290 | if ( (INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) |
2309 | && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) | 2291 | && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) |
2310 | && ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < | 2292 | && ( (INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < |
@@ -2327,8 +2309,7 @@ xfs_attr_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
2327 | xfs_attr_leafblock_t *leaf; | 2309 | xfs_attr_leafblock_t *leaf; |
2328 | 2310 | ||
2329 | leaf = bp->data; | 2311 | leaf = bp->data; |
2330 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2312 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2331 | == XFS_ATTR_LEAF_MAGIC); | ||
2332 | if (count) | 2313 | if (count) |
2333 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 2314 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
2334 | if (!leaf->hdr.count) | 2315 | if (!leaf->hdr.count) |
@@ -2348,8 +2329,7 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index) | |||
2348 | xfs_attr_leaf_name_remote_t *name_rmt; | 2329 | xfs_attr_leaf_name_remote_t *name_rmt; |
2349 | int size; | 2330 | int size; |
2350 | 2331 | ||
2351 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2332 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2352 | == XFS_ATTR_LEAF_MAGIC); | ||
2353 | if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { | 2333 | if (leaf->entries[index].flags & XFS_ATTR_LOCAL) { |
2354 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); | 2334 | name_loc = XFS_ATTR_LEAF_NAME_LOCAL(leaf, index); |
2355 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, | 2335 | size = XFS_ATTR_LEAF_ENTSIZE_LOCAL(name_loc->namelen, |
@@ -2596,8 +2576,7 @@ xfs_attr_leaf_clearflag(xfs_da_args_t *args) | |||
2596 | ASSERT(bp != NULL); | 2576 | ASSERT(bp != NULL); |
2597 | 2577 | ||
2598 | leaf = bp->data; | 2578 | leaf = bp->data; |
2599 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2579 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2600 | == XFS_ATTR_LEAF_MAGIC); | ||
2601 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); | 2580 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); |
2602 | ASSERT(args->index >= 0); | 2581 | ASSERT(args->index >= 0); |
2603 | entry = &leaf->entries[ args->index ]; | 2582 | entry = &leaf->entries[ args->index ]; |
@@ -2663,8 +2642,7 @@ xfs_attr_leaf_setflag(xfs_da_args_t *args) | |||
2663 | ASSERT(bp != NULL); | 2642 | ASSERT(bp != NULL); |
2664 | 2643 | ||
2665 | leaf = bp->data; | 2644 | leaf = bp->data; |
2666 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2645 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2667 | == XFS_ATTR_LEAF_MAGIC); | ||
2668 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); | 2646 | ASSERT(args->index < INT_GET(leaf->hdr.count, ARCH_CONVERT)); |
2669 | ASSERT(args->index >= 0); | 2647 | ASSERT(args->index >= 0); |
2670 | entry = &leaf->entries[ args->index ]; | 2648 | entry = &leaf->entries[ args->index ]; |
@@ -2736,15 +2714,13 @@ xfs_attr_leaf_flipflags(xfs_da_args_t *args) | |||
2736 | } | 2714 | } |
2737 | 2715 | ||
2738 | leaf1 = bp1->data; | 2716 | leaf1 = bp1->data; |
2739 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) | 2717 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2740 | == XFS_ATTR_LEAF_MAGIC); | ||
2741 | ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT)); | 2718 | ASSERT(args->index < INT_GET(leaf1->hdr.count, ARCH_CONVERT)); |
2742 | ASSERT(args->index >= 0); | 2719 | ASSERT(args->index >= 0); |
2743 | entry1 = &leaf1->entries[ args->index ]; | 2720 | entry1 = &leaf1->entries[ args->index ]; |
2744 | 2721 | ||
2745 | leaf2 = bp2->data; | 2722 | leaf2 = bp2->data; |
2746 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2723 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2747 | == XFS_ATTR_LEAF_MAGIC); | ||
2748 | ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT)); | 2724 | ASSERT(args->index2 < INT_GET(leaf2->hdr.count, ARCH_CONVERT)); |
2749 | ASSERT(args->index2 >= 0); | 2725 | ASSERT(args->index2 >= 0); |
2750 | entry2 = &leaf2->entries[ args->index2 ]; | 2726 | entry2 = &leaf2->entries[ args->index2 ]; |
@@ -2842,9 +2818,9 @@ xfs_attr_root_inactive(xfs_trans_t **trans, xfs_inode_t *dp) | |||
2842 | * This is a depth-first traversal! | 2818 | * This is a depth-first traversal! |
2843 | */ | 2819 | */ |
2844 | info = bp->data; | 2820 | info = bp->data; |
2845 | if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 2821 | if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { |
2846 | error = xfs_attr_node_inactive(trans, dp, bp, 1); | 2822 | error = xfs_attr_node_inactive(trans, dp, bp, 1); |
2847 | } else if (INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 2823 | } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { |
2848 | error = xfs_attr_leaf_inactive(trans, dp, bp); | 2824 | error = xfs_attr_leaf_inactive(trans, dp, bp); |
2849 | } else { | 2825 | } else { |
2850 | error = XFS_ERROR(EIO); | 2826 | error = XFS_ERROR(EIO); |
@@ -2892,8 +2868,7 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2892 | } | 2868 | } |
2893 | 2869 | ||
2894 | node = bp->data; | 2870 | node = bp->data; |
2895 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) | 2871 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
2896 | == XFS_DA_NODE_MAGIC); | ||
2897 | parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ | 2872 | parent_blkno = xfs_da_blkno(bp); /* save for re-read later */ |
2898 | count = INT_GET(node->hdr.count, ARCH_CONVERT); | 2873 | count = INT_GET(node->hdr.count, ARCH_CONVERT); |
2899 | if (!count) { | 2874 | if (!count) { |
@@ -2927,12 +2902,10 @@ xfs_attr_node_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp, | |||
2927 | * Invalidate the subtree, however we have to. | 2902 | * Invalidate the subtree, however we have to. |
2928 | */ | 2903 | */ |
2929 | info = child_bp->data; | 2904 | info = child_bp->data; |
2930 | if (INT_GET(info->magic, ARCH_CONVERT) | 2905 | if (be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC) { |
2931 | == XFS_DA_NODE_MAGIC) { | ||
2932 | error = xfs_attr_node_inactive(trans, dp, | 2906 | error = xfs_attr_node_inactive(trans, dp, |
2933 | child_bp, level+1); | 2907 | child_bp, level+1); |
2934 | } else if (INT_GET(info->magic, ARCH_CONVERT) | 2908 | } else if (be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC) { |
2935 | == XFS_ATTR_LEAF_MAGIC) { | ||
2936 | error = xfs_attr_leaf_inactive(trans, dp, | 2909 | error = xfs_attr_leaf_inactive(trans, dp, |
2937 | child_bp); | 2910 | child_bp); |
2938 | } else { | 2911 | } else { |
@@ -2991,8 +2964,7 @@ xfs_attr_leaf_inactive(xfs_trans_t **trans, xfs_inode_t *dp, xfs_dabuf_t *bp) | |||
2991 | int error, count, size, tmp, i; | 2964 | int error, count, size, tmp, i; |
2992 | 2965 | ||
2993 | leaf = bp->data; | 2966 | leaf = bp->data; |
2994 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) | 2967 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_ATTR_LEAF_MAGIC); |
2995 | == XFS_ATTR_LEAF_MAGIC); | ||
2996 | 2968 | ||
2997 | /* | 2969 | /* |
2998 | * Count the number of "remote" value extents. | 2970 | * Count the number of "remote" value extents. |
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c index 31796c7faba0..4f3bb1cb9615 100644 --- a/fs/xfs/xfs_da_btree.c +++ b/fs/xfs/xfs_da_btree.c | |||
@@ -126,7 +126,7 @@ xfs_da_node_create(xfs_da_args_t *args, xfs_dablk_t blkno, int level, | |||
126 | node = bp->data; | 126 | node = bp->data; |
127 | node->hdr.info.forw = 0; | 127 | node->hdr.info.forw = 0; |
128 | node->hdr.info.back = 0; | 128 | node->hdr.info.back = 0; |
129 | INT_SET(node->hdr.info.magic, ARCH_CONVERT, XFS_DA_NODE_MAGIC); | 129 | node->hdr.info.magic = cpu_to_be16(XFS_DA_NODE_MAGIC); |
130 | node->hdr.info.pad = 0; | 130 | node->hdr.info.pad = 0; |
131 | node->hdr.count = 0; | 131 | node->hdr.count = 0; |
132 | INT_SET(node->hdr.level, ARCH_CONVERT, level); | 132 | INT_SET(node->hdr.level, ARCH_CONVERT, level); |
@@ -290,28 +290,28 @@ xfs_da_split(xfs_da_state_t *state) | |||
290 | 290 | ||
291 | node = oldblk->bp->data; | 291 | node = oldblk->bp->data; |
292 | if (node->hdr.info.forw) { | 292 | if (node->hdr.info.forw) { |
293 | if (INT_GET(node->hdr.info.forw, ARCH_CONVERT) == addblk->blkno) { | 293 | if (be32_to_cpu(node->hdr.info.forw) == addblk->blkno) { |
294 | bp = addblk->bp; | 294 | bp = addblk->bp; |
295 | } else { | 295 | } else { |
296 | ASSERT(state->extravalid); | 296 | ASSERT(state->extravalid); |
297 | bp = state->extrablk.bp; | 297 | bp = state->extrablk.bp; |
298 | } | 298 | } |
299 | node = bp->data; | 299 | node = bp->data; |
300 | INT_SET(node->hdr.info.back, ARCH_CONVERT, oldblk->blkno); | 300 | node->hdr.info.back = cpu_to_be32(oldblk->blkno); |
301 | xfs_da_log_buf(state->args->trans, bp, | 301 | xfs_da_log_buf(state->args->trans, bp, |
302 | XFS_DA_LOGRANGE(node, &node->hdr.info, | 302 | XFS_DA_LOGRANGE(node, &node->hdr.info, |
303 | sizeof(node->hdr.info))); | 303 | sizeof(node->hdr.info))); |
304 | } | 304 | } |
305 | node = oldblk->bp->data; | 305 | node = oldblk->bp->data; |
306 | if (INT_GET(node->hdr.info.back, ARCH_CONVERT)) { | 306 | if (node->hdr.info.back) { |
307 | if (INT_GET(node->hdr.info.back, ARCH_CONVERT) == addblk->blkno) { | 307 | if (be32_to_cpu(node->hdr.info.back) == addblk->blkno) { |
308 | bp = addblk->bp; | 308 | bp = addblk->bp; |
309 | } else { | 309 | } else { |
310 | ASSERT(state->extravalid); | 310 | ASSERT(state->extravalid); |
311 | bp = state->extrablk.bp; | 311 | bp = state->extrablk.bp; |
312 | } | 312 | } |
313 | node = bp->data; | 313 | node = bp->data; |
314 | INT_SET(node->hdr.info.forw, ARCH_CONVERT, oldblk->blkno); | 314 | node->hdr.info.forw = cpu_to_be32(oldblk->blkno); |
315 | xfs_da_log_buf(state->args->trans, bp, | 315 | xfs_da_log_buf(state->args->trans, bp, |
316 | XFS_DA_LOGRANGE(node, &node->hdr.info, | 316 | XFS_DA_LOGRANGE(node, &node->hdr.info, |
317 | sizeof(node->hdr.info))); | 317 | sizeof(node->hdr.info))); |
@@ -359,12 +359,12 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
359 | ASSERT(bp != NULL); | 359 | ASSERT(bp != NULL); |
360 | node = bp->data; | 360 | node = bp->data; |
361 | oldroot = blk1->bp->data; | 361 | oldroot = blk1->bp->data; |
362 | if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 362 | if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC) { |
363 | size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] - | 363 | size = (int)((char *)&oldroot->btree[INT_GET(oldroot->hdr.count, ARCH_CONVERT)] - |
364 | (char *)oldroot); | 364 | (char *)oldroot); |
365 | } else { | 365 | } else { |
366 | ASSERT(XFS_DIR_IS_V2(mp)); | 366 | ASSERT(XFS_DIR_IS_V2(mp)); |
367 | ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 367 | ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
368 | leaf = (xfs_dir2_leaf_t *)oldroot; | 368 | leaf = (xfs_dir2_leaf_t *)oldroot; |
369 | size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] - | 369 | size = (int)((char *)&leaf->ents[be16_to_cpu(leaf->hdr.count)] - |
370 | (char *)leaf); | 370 | (char *)leaf); |
@@ -392,7 +392,7 @@ xfs_da_root_split(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
392 | INT_SET(node->hdr.count, ARCH_CONVERT, 2); | 392 | INT_SET(node->hdr.count, ARCH_CONVERT, 2); |
393 | 393 | ||
394 | #ifdef DEBUG | 394 | #ifdef DEBUG |
395 | if (INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { | 395 | if (be16_to_cpu(oldroot->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC) { |
396 | ASSERT(blk1->blkno >= mp->m_dirleafblk && | 396 | ASSERT(blk1->blkno >= mp->m_dirleafblk && |
397 | blk1->blkno < mp->m_dirfreeblk); | 397 | blk1->blkno < mp->m_dirfreeblk); |
398 | ASSERT(blk2->blkno >= mp->m_dirleafblk && | 398 | ASSERT(blk2->blkno >= mp->m_dirleafblk && |
@@ -424,7 +424,7 @@ xfs_da_node_split(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
424 | int useextra; | 424 | int useextra; |
425 | 425 | ||
426 | node = oldblk->bp->data; | 426 | node = oldblk->bp->data; |
427 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 427 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
428 | 428 | ||
429 | /* | 429 | /* |
430 | * With V2 the extra block is data or freespace. | 430 | * With V2 the extra block is data or freespace. |
@@ -524,8 +524,8 @@ xfs_da_node_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
524 | node1 = node2; | 524 | node1 = node2; |
525 | node2 = tmpnode; | 525 | node2 = tmpnode; |
526 | } | 526 | } |
527 | ASSERT(INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 527 | ASSERT(be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
528 | ASSERT(INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 528 | ASSERT(be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
529 | count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2; | 529 | count = (INT_GET(node1->hdr.count, ARCH_CONVERT) - INT_GET(node2->hdr.count, ARCH_CONVERT)) / 2; |
530 | if (count == 0) | 530 | if (count == 0) |
531 | return; | 531 | return; |
@@ -622,7 +622,7 @@ xfs_da_node_add(xfs_da_state_t *state, xfs_da_state_blk_t *oldblk, | |||
622 | 622 | ||
623 | node = oldblk->bp->data; | 623 | node = oldblk->bp->data; |
624 | mp = state->mp; | 624 | mp = state->mp; |
625 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 625 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
626 | ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT))); | 626 | ASSERT((oldblk->index >= 0) && (oldblk->index <= INT_GET(node->hdr.count, ARCH_CONVERT))); |
627 | ASSERT(newblk->blkno != 0); | 627 | ASSERT(newblk->blkno != 0); |
628 | if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) | 628 | if (state->args->whichfork == XFS_DATA_FORK && XFS_DIR_IS_V2(mp)) |
@@ -768,7 +768,7 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | |||
768 | ASSERT(args != NULL); | 768 | ASSERT(args != NULL); |
769 | ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); | 769 | ASSERT(root_blk->magic == XFS_DA_NODE_MAGIC); |
770 | oldroot = root_blk->bp->data; | 770 | oldroot = root_blk->bp->data; |
771 | ASSERT(INT_GET(oldroot->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 771 | ASSERT(be16_to_cpu(oldroot->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
772 | ASSERT(!oldroot->hdr.info.forw); | 772 | ASSERT(!oldroot->hdr.info.forw); |
773 | ASSERT(!oldroot->hdr.info.back); | 773 | ASSERT(!oldroot->hdr.info.back); |
774 | 774 | ||
@@ -791,10 +791,10 @@ xfs_da_root_join(xfs_da_state_t *state, xfs_da_state_blk_t *root_blk) | |||
791 | ASSERT(bp != NULL); | 791 | ASSERT(bp != NULL); |
792 | blkinfo = bp->data; | 792 | blkinfo = bp->data; |
793 | if (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) { | 793 | if (INT_GET(oldroot->hdr.level, ARCH_CONVERT) == 1) { |
794 | ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 794 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || |
795 | INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 795 | be16_to_cpu(blkinfo->magic) == XFS_ATTR_LEAF_MAGIC); |
796 | } else { | 796 | } else { |
797 | ASSERT(INT_GET(blkinfo->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 797 | ASSERT(be16_to_cpu(blkinfo->magic) == XFS_DA_NODE_MAGIC); |
798 | } | 798 | } |
799 | ASSERT(!blkinfo->forw); | 799 | ASSERT(!blkinfo->forw); |
800 | ASSERT(!blkinfo->back); | 800 | ASSERT(!blkinfo->back); |
@@ -830,7 +830,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
830 | */ | 830 | */ |
831 | blk = &state->path.blk[ state->path.active-1 ]; | 831 | blk = &state->path.blk[ state->path.active-1 ]; |
832 | info = blk->bp->data; | 832 | info = blk->bp->data; |
833 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 833 | ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC); |
834 | node = (xfs_da_intnode_t *)info; | 834 | node = (xfs_da_intnode_t *)info; |
835 | count = INT_GET(node->hdr.count, ARCH_CONVERT); | 835 | count = INT_GET(node->hdr.count, ARCH_CONVERT); |
836 | if (count > (state->node_ents >> 1)) { | 836 | if (count > (state->node_ents >> 1)) { |
@@ -849,7 +849,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
849 | * Make altpath point to the block we want to keep and | 849 | * Make altpath point to the block we want to keep and |
850 | * path point to the block we want to drop (this one). | 850 | * path point to the block we want to drop (this one). |
851 | */ | 851 | */ |
852 | forward = info->forw; | 852 | forward = (info->forw != 0); |
853 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 853 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
854 | error = xfs_da_path_shift(state, &state->altpath, forward, | 854 | error = xfs_da_path_shift(state, &state->altpath, forward, |
855 | 0, &retval); | 855 | 0, &retval); |
@@ -871,13 +871,12 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
871 | * to shrink a directory over time. | 871 | * to shrink a directory over time. |
872 | */ | 872 | */ |
873 | /* start with smaller blk num */ | 873 | /* start with smaller blk num */ |
874 | forward = (INT_GET(info->forw, ARCH_CONVERT) | 874 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); |
875 | < INT_GET(info->back, ARCH_CONVERT)); | ||
876 | for (i = 0; i < 2; forward = !forward, i++) { | 875 | for (i = 0; i < 2; forward = !forward, i++) { |
877 | if (forward) | 876 | if (forward) |
878 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 877 | blkno = be32_to_cpu(info->forw); |
879 | else | 878 | else |
880 | blkno = INT_GET(info->back, ARCH_CONVERT); | 879 | blkno = be32_to_cpu(info->back); |
881 | if (blkno == 0) | 880 | if (blkno == 0) |
882 | continue; | 881 | continue; |
883 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 882 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -891,7 +890,7 @@ xfs_da_node_toosmall(xfs_da_state_t *state, int *action) | |||
891 | count -= state->node_ents >> 2; | 890 | count -= state->node_ents >> 2; |
892 | count -= INT_GET(node->hdr.count, ARCH_CONVERT); | 891 | count -= INT_GET(node->hdr.count, ARCH_CONVERT); |
893 | node = bp->data; | 892 | node = bp->data; |
894 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 893 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
895 | count -= INT_GET(node->hdr.count, ARCH_CONVERT); | 894 | count -= INT_GET(node->hdr.count, ARCH_CONVERT); |
896 | xfs_da_brelse(state->args->trans, bp); | 895 | xfs_da_brelse(state->args->trans, bp); |
897 | if (count >= 0) | 896 | if (count >= 0) |
@@ -973,7 +972,7 @@ xfs_da_fixhashpath(xfs_da_state_t *state, xfs_da_state_path_t *path) | |||
973 | } | 972 | } |
974 | for (blk--, level--; level >= 0; blk--, level--) { | 973 | for (blk--, level--; level >= 0; blk--, level--) { |
975 | node = blk->bp->data; | 974 | node = blk->bp->data; |
976 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 975 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
977 | btree = &node->btree[ blk->index ]; | 976 | btree = &node->btree[ blk->index ]; |
978 | if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash) | 977 | if (INT_GET(btree->hashval, ARCH_CONVERT) == lasthash) |
979 | break; | 978 | break; |
@@ -1041,8 +1040,8 @@ xfs_da_node_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1041 | 1040 | ||
1042 | drop_node = drop_blk->bp->data; | 1041 | drop_node = drop_blk->bp->data; |
1043 | save_node = save_blk->bp->data; | 1042 | save_node = save_blk->bp->data; |
1044 | ASSERT(INT_GET(drop_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1043 | ASSERT(be16_to_cpu(drop_node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1045 | ASSERT(INT_GET(save_node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1044 | ASSERT(be16_to_cpu(save_node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1046 | tp = state->args->trans; | 1045 | tp = state->args->trans; |
1047 | 1046 | ||
1048 | /* | 1047 | /* |
@@ -1138,15 +1137,15 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1138 | return(error); | 1137 | return(error); |
1139 | } | 1138 | } |
1140 | curr = blk->bp->data; | 1139 | curr = blk->bp->data; |
1141 | ASSERT(INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || | 1140 | ASSERT(be16_to_cpu(curr->magic) == XFS_DA_NODE_MAGIC || |
1142 | INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1141 | be16_to_cpu(curr->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1143 | INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1142 | be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC); |
1144 | 1143 | ||
1145 | /* | 1144 | /* |
1146 | * Search an intermediate node for a match. | 1145 | * Search an intermediate node for a match. |
1147 | */ | 1146 | */ |
1148 | blk->magic = INT_GET(curr->magic, ARCH_CONVERT); | 1147 | blk->magic = be16_to_cpu(curr->magic); |
1149 | if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 1148 | if (blk->magic == XFS_DA_NODE_MAGIC) { |
1150 | node = blk->bp->data; | 1149 | node = blk->bp->data; |
1151 | blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 1150 | blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); |
1152 | 1151 | ||
@@ -1193,15 +1192,15 @@ xfs_da_node_lookup_int(xfs_da_state_t *state, int *result) | |||
1193 | blkno = INT_GET(btree->before, ARCH_CONVERT); | 1192 | blkno = INT_GET(btree->before, ARCH_CONVERT); |
1194 | } | 1193 | } |
1195 | } | 1194 | } |
1196 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC) { | 1195 | else if (be16_to_cpu(curr->magic) == XFS_ATTR_LEAF_MAGIC) { |
1197 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); | 1196 | blk->hashval = xfs_attr_leaf_lasthash(blk->bp, NULL); |
1198 | break; | 1197 | break; |
1199 | } | 1198 | } |
1200 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { | 1199 | else if (be16_to_cpu(curr->magic) == XFS_DIR_LEAF_MAGIC) { |
1201 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); | 1200 | blk->hashval = xfs_dir_leaf_lasthash(blk->bp, NULL); |
1202 | break; | 1201 | break; |
1203 | } | 1202 | } |
1204 | else if (INT_GET(curr->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { | 1203 | else if (be16_to_cpu(curr->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1205 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); | 1204 | blk->hashval = xfs_dir2_leafn_lasthash(blk->bp, NULL); |
1206 | break; | 1205 | break; |
1207 | } | 1206 | } |
@@ -1274,8 +1273,8 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1274 | ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || | 1273 | ASSERT(old_blk->magic == XFS_DA_NODE_MAGIC || |
1275 | old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1274 | old_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1276 | old_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1275 | old_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1277 | ASSERT(old_blk->magic == INT_GET(old_info->magic, ARCH_CONVERT)); | 1276 | ASSERT(old_blk->magic == be16_to_cpu(old_info->magic)); |
1278 | ASSERT(new_blk->magic == INT_GET(new_info->magic, ARCH_CONVERT)); | 1277 | ASSERT(new_blk->magic == be16_to_cpu(new_info->magic)); |
1279 | ASSERT(old_blk->magic == new_blk->magic); | 1278 | ASSERT(old_blk->magic == new_blk->magic); |
1280 | 1279 | ||
1281 | switch (old_blk->magic) { | 1280 | switch (old_blk->magic) { |
@@ -1302,47 +1301,44 @@ xfs_da_blk_link(xfs_da_state_t *state, xfs_da_state_blk_t *old_blk, | |||
1302 | /* | 1301 | /* |
1303 | * Link new block in before existing block. | 1302 | * Link new block in before existing block. |
1304 | */ | 1303 | */ |
1305 | INT_SET(new_info->forw, ARCH_CONVERT, old_blk->blkno); | 1304 | new_info->forw = cpu_to_be32(old_blk->blkno); |
1306 | new_info->back = old_info->back; /* INT_: direct copy */ | 1305 | new_info->back = old_info->back; |
1307 | if (INT_GET(old_info->back, ARCH_CONVERT)) { | 1306 | if (old_info->back) { |
1308 | error = xfs_da_read_buf(args->trans, args->dp, | 1307 | error = xfs_da_read_buf(args->trans, args->dp, |
1309 | INT_GET(old_info->back, | 1308 | be32_to_cpu(old_info->back), |
1310 | ARCH_CONVERT), -1, &bp, | 1309 | -1, &bp, args->whichfork); |
1311 | args->whichfork); | ||
1312 | if (error) | 1310 | if (error) |
1313 | return(error); | 1311 | return(error); |
1314 | ASSERT(bp != NULL); | 1312 | ASSERT(bp != NULL); |
1315 | tmp_info = bp->data; | 1313 | tmp_info = bp->data; |
1316 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(old_info->magic, ARCH_CONVERT)); | 1314 | ASSERT(be16_to_cpu(tmp_info->magic) == be16_to_cpu(old_info->magic)); |
1317 | ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == old_blk->blkno); | 1315 | ASSERT(be32_to_cpu(tmp_info->forw) == old_blk->blkno); |
1318 | INT_SET(tmp_info->forw, ARCH_CONVERT, new_blk->blkno); | 1316 | tmp_info->forw = cpu_to_be32(new_blk->blkno); |
1319 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); | 1317 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); |
1320 | xfs_da_buf_done(bp); | 1318 | xfs_da_buf_done(bp); |
1321 | } | 1319 | } |
1322 | INT_SET(old_info->back, ARCH_CONVERT, new_blk->blkno); | 1320 | old_info->back = cpu_to_be32(new_blk->blkno); |
1323 | } else { | 1321 | } else { |
1324 | /* | 1322 | /* |
1325 | * Link new block in after existing block. | 1323 | * Link new block in after existing block. |
1326 | */ | 1324 | */ |
1327 | new_info->forw = old_info->forw; /* INT_: direct copy */ | 1325 | new_info->forw = old_info->forw; |
1328 | INT_SET(new_info->back, ARCH_CONVERT, old_blk->blkno); | 1326 | new_info->back = cpu_to_be32(old_blk->blkno); |
1329 | if (INT_GET(old_info->forw, ARCH_CONVERT)) { | 1327 | if (old_info->forw) { |
1330 | error = xfs_da_read_buf(args->trans, args->dp, | 1328 | error = xfs_da_read_buf(args->trans, args->dp, |
1331 | INT_GET(old_info->forw, ARCH_CONVERT), -1, &bp, | 1329 | be32_to_cpu(old_info->forw), |
1332 | args->whichfork); | 1330 | -1, &bp, args->whichfork); |
1333 | if (error) | 1331 | if (error) |
1334 | return(error); | 1332 | return(error); |
1335 | ASSERT(bp != NULL); | 1333 | ASSERT(bp != NULL); |
1336 | tmp_info = bp->data; | 1334 | tmp_info = bp->data; |
1337 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) | 1335 | ASSERT(tmp_info->magic == old_info->magic); |
1338 | == INT_GET(old_info->magic, ARCH_CONVERT)); | 1336 | ASSERT(be32_to_cpu(tmp_info->back) == old_blk->blkno); |
1339 | ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) | 1337 | tmp_info->back = cpu_to_be32(new_blk->blkno); |
1340 | == old_blk->blkno); | ||
1341 | INT_SET(tmp_info->back, ARCH_CONVERT, new_blk->blkno); | ||
1342 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); | 1338 | xfs_da_log_buf(args->trans, bp, 0, sizeof(*tmp_info)-1); |
1343 | xfs_da_buf_done(bp); | 1339 | xfs_da_buf_done(bp); |
1344 | } | 1340 | } |
1345 | INT_SET(old_info->forw, ARCH_CONVERT, new_blk->blkno); | 1341 | old_info->forw = cpu_to_be32(new_blk->blkno); |
1346 | } | 1342 | } |
1347 | 1343 | ||
1348 | xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); | 1344 | xfs_da_log_buf(args->trans, old_blk->bp, 0, sizeof(*tmp_info) - 1); |
@@ -1360,8 +1356,8 @@ xfs_da_node_order(xfs_dabuf_t *node1_bp, xfs_dabuf_t *node2_bp) | |||
1360 | 1356 | ||
1361 | node1 = node1_bp->data; | 1357 | node1 = node1_bp->data; |
1362 | node2 = node2_bp->data; | 1358 | node2 = node2_bp->data; |
1363 | ASSERT((INT_GET(node1->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) && | 1359 | ASSERT((be16_to_cpu(node1->hdr.info.magic) == XFS_DA_NODE_MAGIC) && |
1364 | (INT_GET(node2->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC)); | 1360 | (be16_to_cpu(node2->hdr.info.magic) == XFS_DA_NODE_MAGIC)); |
1365 | if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && | 1361 | if ((INT_GET(node1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(node2->hdr.count, ARCH_CONVERT) > 0) && |
1366 | ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < | 1362 | ((INT_GET(node2->btree[ 0 ].hashval, ARCH_CONVERT) < |
1367 | INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || | 1363 | INT_GET(node1->btree[ 0 ].hashval, ARCH_CONVERT)) || |
@@ -1381,7 +1377,7 @@ xfs_da_node_lasthash(xfs_dabuf_t *bp, int *count) | |||
1381 | xfs_da_intnode_t *node; | 1377 | xfs_da_intnode_t *node; |
1382 | 1378 | ||
1383 | node = bp->data; | 1379 | node = bp->data; |
1384 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1380 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1385 | if (count) | 1381 | if (count) |
1386 | *count = INT_GET(node->hdr.count, ARCH_CONVERT); | 1382 | *count = INT_GET(node->hdr.count, ARCH_CONVERT); |
1387 | if (!node->hdr.count) | 1383 | if (!node->hdr.count) |
@@ -1411,50 +1407,47 @@ xfs_da_blk_unlink(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1411 | ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || | 1407 | ASSERT(save_blk->magic == XFS_DA_NODE_MAGIC || |
1412 | save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1408 | save_blk->magic == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1413 | save_blk->magic == XFS_ATTR_LEAF_MAGIC); | 1409 | save_blk->magic == XFS_ATTR_LEAF_MAGIC); |
1414 | ASSERT(save_blk->magic == INT_GET(save_info->magic, ARCH_CONVERT)); | 1410 | ASSERT(save_blk->magic == be16_to_cpu(save_info->magic)); |
1415 | ASSERT(drop_blk->magic == INT_GET(drop_info->magic, ARCH_CONVERT)); | 1411 | ASSERT(drop_blk->magic == be16_to_cpu(drop_info->magic)); |
1416 | ASSERT(save_blk->magic == drop_blk->magic); | 1412 | ASSERT(save_blk->magic == drop_blk->magic); |
1417 | ASSERT((INT_GET(save_info->forw, ARCH_CONVERT) == drop_blk->blkno) || | 1413 | ASSERT((be32_to_cpu(save_info->forw) == drop_blk->blkno) || |
1418 | (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno)); | 1414 | (be32_to_cpu(save_info->back) == drop_blk->blkno)); |
1419 | ASSERT((INT_GET(drop_info->forw, ARCH_CONVERT) == save_blk->blkno) || | 1415 | ASSERT((be32_to_cpu(drop_info->forw) == save_blk->blkno) || |
1420 | (INT_GET(drop_info->back, ARCH_CONVERT) == save_blk->blkno)); | 1416 | (be32_to_cpu(drop_info->back) == save_blk->blkno)); |
1421 | 1417 | ||
1422 | /* | 1418 | /* |
1423 | * Unlink the leaf block from the doubly linked chain of leaves. | 1419 | * Unlink the leaf block from the doubly linked chain of leaves. |
1424 | */ | 1420 | */ |
1425 | if (INT_GET(save_info->back, ARCH_CONVERT) == drop_blk->blkno) { | 1421 | if (be32_to_cpu(save_info->back) == drop_blk->blkno) { |
1426 | save_info->back = drop_info->back; /* INT_: direct copy */ | 1422 | save_info->back = drop_info->back; |
1427 | if (INT_GET(drop_info->back, ARCH_CONVERT)) { | 1423 | if (drop_info->back) { |
1428 | error = xfs_da_read_buf(args->trans, args->dp, | 1424 | error = xfs_da_read_buf(args->trans, args->dp, |
1429 | INT_GET(drop_info->back, | 1425 | be32_to_cpu(drop_info->back), |
1430 | ARCH_CONVERT), -1, &bp, | 1426 | -1, &bp, args->whichfork); |
1431 | args->whichfork); | ||
1432 | if (error) | 1427 | if (error) |
1433 | return(error); | 1428 | return(error); |
1434 | ASSERT(bp != NULL); | 1429 | ASSERT(bp != NULL); |
1435 | tmp_info = bp->data; | 1430 | tmp_info = bp->data; |
1436 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) == INT_GET(save_info->magic, ARCH_CONVERT)); | 1431 | ASSERT(tmp_info->magic == save_info->magic); |
1437 | ASSERT(INT_GET(tmp_info->forw, ARCH_CONVERT) == drop_blk->blkno); | 1432 | ASSERT(be32_to_cpu(tmp_info->forw) == drop_blk->blkno); |
1438 | INT_SET(tmp_info->forw, ARCH_CONVERT, save_blk->blkno); | 1433 | tmp_info->forw = cpu_to_be32(save_blk->blkno); |
1439 | xfs_da_log_buf(args->trans, bp, 0, | 1434 | xfs_da_log_buf(args->trans, bp, 0, |
1440 | sizeof(*tmp_info) - 1); | 1435 | sizeof(*tmp_info) - 1); |
1441 | xfs_da_buf_done(bp); | 1436 | xfs_da_buf_done(bp); |
1442 | } | 1437 | } |
1443 | } else { | 1438 | } else { |
1444 | save_info->forw = drop_info->forw; /* INT_: direct copy */ | 1439 | save_info->forw = drop_info->forw; |
1445 | if (INT_GET(drop_info->forw, ARCH_CONVERT)) { | 1440 | if (drop_info->forw) { |
1446 | error = xfs_da_read_buf(args->trans, args->dp, | 1441 | error = xfs_da_read_buf(args->trans, args->dp, |
1447 | INT_GET(drop_info->forw, ARCH_CONVERT), -1, &bp, | 1442 | be32_to_cpu(drop_info->forw), |
1448 | args->whichfork); | 1443 | -1, &bp, args->whichfork); |
1449 | if (error) | 1444 | if (error) |
1450 | return(error); | 1445 | return(error); |
1451 | ASSERT(bp != NULL); | 1446 | ASSERT(bp != NULL); |
1452 | tmp_info = bp->data; | 1447 | tmp_info = bp->data; |
1453 | ASSERT(INT_GET(tmp_info->magic, ARCH_CONVERT) | 1448 | ASSERT(tmp_info->magic == save_info->magic); |
1454 | == INT_GET(save_info->magic, ARCH_CONVERT)); | 1449 | ASSERT(be32_to_cpu(tmp_info->back) == drop_blk->blkno); |
1455 | ASSERT(INT_GET(tmp_info->back, ARCH_CONVERT) | 1450 | tmp_info->back = cpu_to_be32(save_blk->blkno); |
1456 | == drop_blk->blkno); | ||
1457 | INT_SET(tmp_info->back, ARCH_CONVERT, save_blk->blkno); | ||
1458 | xfs_da_log_buf(args->trans, bp, 0, | 1451 | xfs_da_log_buf(args->trans, bp, 0, |
1459 | sizeof(*tmp_info) - 1); | 1452 | sizeof(*tmp_info) - 1); |
1460 | xfs_da_buf_done(bp); | 1453 | xfs_da_buf_done(bp); |
@@ -1497,7 +1490,7 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1497 | for (blk = &path->blk[level]; level >= 0; blk--, level--) { | 1490 | for (blk = &path->blk[level]; level >= 0; blk--, level--) { |
1498 | ASSERT(blk->bp != NULL); | 1491 | ASSERT(blk->bp != NULL); |
1499 | node = blk->bp->data; | 1492 | node = blk->bp->data; |
1500 | ASSERT(INT_GET(node->hdr.info.magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1493 | ASSERT(be16_to_cpu(node->hdr.info.magic) == XFS_DA_NODE_MAGIC); |
1501 | if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { | 1494 | if (forward && (blk->index < INT_GET(node->hdr.count, ARCH_CONVERT)-1)) { |
1502 | blk->index++; | 1495 | blk->index++; |
1503 | blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); | 1496 | blkno = INT_GET(node->btree[ blk->index ].before, ARCH_CONVERT); |
@@ -1536,11 +1529,11 @@ xfs_da_path_shift(xfs_da_state_t *state, xfs_da_state_path_t *path, | |||
1536 | return(error); | 1529 | return(error); |
1537 | ASSERT(blk->bp != NULL); | 1530 | ASSERT(blk->bp != NULL); |
1538 | info = blk->bp->data; | 1531 | info = blk->bp->data; |
1539 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC || | 1532 | ASSERT(be16_to_cpu(info->magic) == XFS_DA_NODE_MAGIC || |
1540 | INT_GET(info->magic, ARCH_CONVERT) == XFS_DIRX_LEAF_MAGIC(state->mp) || | 1533 | be16_to_cpu(info->magic) == XFS_DIRX_LEAF_MAGIC(state->mp) || |
1541 | INT_GET(info->magic, ARCH_CONVERT) == XFS_ATTR_LEAF_MAGIC); | 1534 | be16_to_cpu(info->magic) == XFS_ATTR_LEAF_MAGIC); |
1542 | blk->magic = INT_GET(info->magic, ARCH_CONVERT); | 1535 | blk->magic = be16_to_cpu(info->magic); |
1543 | if (INT_GET(info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC) { | 1536 | if (blk->magic == XFS_DA_NODE_MAGIC) { |
1544 | node = (xfs_da_intnode_t *)info; | 1537 | node = (xfs_da_intnode_t *)info; |
1545 | blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); | 1538 | blk->hashval = INT_GET(node->btree[ INT_GET(node->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT); |
1546 | if (forward) | 1539 | if (forward) |
@@ -1788,19 +1781,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1788 | /* | 1781 | /* |
1789 | * Get values from the moved block. | 1782 | * Get values from the moved block. |
1790 | */ | 1783 | */ |
1791 | if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) { | 1784 | if (be16_to_cpu(dead_info->magic) == XFS_DIR_LEAF_MAGIC) { |
1792 | ASSERT(XFS_DIR_IS_V1(mp)); | 1785 | ASSERT(XFS_DIR_IS_V1(mp)); |
1793 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; | 1786 | dead_leaf = (xfs_dir_leafblock_t *)dead_info; |
1794 | dead_level = 0; | 1787 | dead_level = 0; |
1795 | dead_hash = | 1788 | dead_hash = |
1796 | INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1789 | INT_GET(dead_leaf->entries[INT_GET(dead_leaf->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); |
1797 | } else if (INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC) { | 1790 | } else if (be16_to_cpu(dead_info->magic) == XFS_DIR2_LEAFN_MAGIC) { |
1798 | ASSERT(XFS_DIR_IS_V2(mp)); | 1791 | ASSERT(XFS_DIR_IS_V2(mp)); |
1799 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; | 1792 | dead_leaf2 = (xfs_dir2_leaf_t *)dead_info; |
1800 | dead_level = 0; | 1793 | dead_level = 0; |
1801 | dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval); | 1794 | dead_hash = be32_to_cpu(dead_leaf2->ents[be16_to_cpu(dead_leaf2->hdr.count) - 1].hashval); |
1802 | } else { | 1795 | } else { |
1803 | ASSERT(INT_GET(dead_info->magic, ARCH_CONVERT) == XFS_DA_NODE_MAGIC); | 1796 | ASSERT(be16_to_cpu(dead_info->magic) == XFS_DA_NODE_MAGIC); |
1804 | dead_node = (xfs_da_intnode_t *)dead_info; | 1797 | dead_node = (xfs_da_intnode_t *)dead_info; |
1805 | dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT); | 1798 | dead_level = INT_GET(dead_node->hdr.level, ARCH_CONVERT); |
1806 | dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); | 1799 | dead_hash = INT_GET(dead_node->btree[INT_GET(dead_node->hdr.count, ARCH_CONVERT) - 1].hashval, ARCH_CONVERT); |
@@ -1809,19 +1802,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1809 | /* | 1802 | /* |
1810 | * If the moved block has a left sibling, fix up the pointers. | 1803 | * If the moved block has a left sibling, fix up the pointers. |
1811 | */ | 1804 | */ |
1812 | if ((sib_blkno = INT_GET(dead_info->back, ARCH_CONVERT))) { | 1805 | if ((sib_blkno = be32_to_cpu(dead_info->back))) { |
1813 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) | 1806 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) |
1814 | goto done; | 1807 | goto done; |
1815 | sib_info = sib_buf->data; | 1808 | sib_info = sib_buf->data; |
1816 | if (unlikely( | 1809 | if (unlikely( |
1817 | INT_GET(sib_info->forw, ARCH_CONVERT) != last_blkno || | 1810 | be32_to_cpu(sib_info->forw) != last_blkno || |
1818 | INT_GET(sib_info->magic, ARCH_CONVERT) != INT_GET(dead_info->magic, ARCH_CONVERT))) { | 1811 | sib_info->magic != dead_info->magic)) { |
1819 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", | 1812 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(2)", |
1820 | XFS_ERRLEVEL_LOW, mp); | 1813 | XFS_ERRLEVEL_LOW, mp); |
1821 | error = XFS_ERROR(EFSCORRUPTED); | 1814 | error = XFS_ERROR(EFSCORRUPTED); |
1822 | goto done; | 1815 | goto done; |
1823 | } | 1816 | } |
1824 | INT_SET(sib_info->forw, ARCH_CONVERT, dead_blkno); | 1817 | sib_info->forw = cpu_to_be32(dead_blkno); |
1825 | xfs_da_log_buf(tp, sib_buf, | 1818 | xfs_da_log_buf(tp, sib_buf, |
1826 | XFS_DA_LOGRANGE(sib_info, &sib_info->forw, | 1819 | XFS_DA_LOGRANGE(sib_info, &sib_info->forw, |
1827 | sizeof(sib_info->forw))); | 1820 | sizeof(sib_info->forw))); |
@@ -1831,20 +1824,19 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1831 | /* | 1824 | /* |
1832 | * If the moved block has a right sibling, fix up the pointers. | 1825 | * If the moved block has a right sibling, fix up the pointers. |
1833 | */ | 1826 | */ |
1834 | if ((sib_blkno = INT_GET(dead_info->forw, ARCH_CONVERT))) { | 1827 | if ((sib_blkno = be32_to_cpu(dead_info->forw))) { |
1835 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) | 1828 | if ((error = xfs_da_read_buf(tp, ip, sib_blkno, -1, &sib_buf, w))) |
1836 | goto done; | 1829 | goto done; |
1837 | sib_info = sib_buf->data; | 1830 | sib_info = sib_buf->data; |
1838 | if (unlikely( | 1831 | if (unlikely( |
1839 | INT_GET(sib_info->back, ARCH_CONVERT) != last_blkno | 1832 | be32_to_cpu(sib_info->back) != last_blkno || |
1840 | || INT_GET(sib_info->magic, ARCH_CONVERT) | 1833 | sib_info->magic != dead_info->magic)) { |
1841 | != INT_GET(dead_info->magic, ARCH_CONVERT))) { | ||
1842 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", | 1834 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(3)", |
1843 | XFS_ERRLEVEL_LOW, mp); | 1835 | XFS_ERRLEVEL_LOW, mp); |
1844 | error = XFS_ERROR(EFSCORRUPTED); | 1836 | error = XFS_ERROR(EFSCORRUPTED); |
1845 | goto done; | 1837 | goto done; |
1846 | } | 1838 | } |
1847 | INT_SET(sib_info->back, ARCH_CONVERT, dead_blkno); | 1839 | sib_info->back = cpu_to_be32(dead_blkno); |
1848 | xfs_da_log_buf(tp, sib_buf, | 1840 | xfs_da_log_buf(tp, sib_buf, |
1849 | XFS_DA_LOGRANGE(sib_info, &sib_info->back, | 1841 | XFS_DA_LOGRANGE(sib_info, &sib_info->back, |
1850 | sizeof(sib_info->back))); | 1842 | sizeof(sib_info->back))); |
@@ -1861,7 +1853,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1861 | goto done; | 1853 | goto done; |
1862 | par_node = par_buf->data; | 1854 | par_node = par_buf->data; |
1863 | if (unlikely( | 1855 | if (unlikely( |
1864 | INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC || | 1856 | be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC || |
1865 | (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) { | 1857 | (level >= 0 && level != INT_GET(par_node->hdr.level, ARCH_CONVERT) + 1))) { |
1866 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", | 1858 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(4)", |
1867 | XFS_ERRLEVEL_LOW, mp); | 1859 | XFS_ERRLEVEL_LOW, mp); |
@@ -1898,7 +1890,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1898 | continue; | 1890 | continue; |
1899 | if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT)) | 1891 | if (entno < INT_GET(par_node->hdr.count, ARCH_CONVERT)) |
1900 | break; | 1892 | break; |
1901 | par_blkno = INT_GET(par_node->hdr.info.forw, ARCH_CONVERT); | 1893 | par_blkno = be32_to_cpu(par_node->hdr.info.forw); |
1902 | xfs_da_brelse(tp, par_buf); | 1894 | xfs_da_brelse(tp, par_buf); |
1903 | par_buf = NULL; | 1895 | par_buf = NULL; |
1904 | if (unlikely(par_blkno == 0)) { | 1896 | if (unlikely(par_blkno == 0)) { |
@@ -1912,7 +1904,7 @@ xfs_da_swap_lastblock(xfs_da_args_t *args, xfs_dablk_t *dead_blknop, | |||
1912 | par_node = par_buf->data; | 1904 | par_node = par_buf->data; |
1913 | if (unlikely( | 1905 | if (unlikely( |
1914 | INT_GET(par_node->hdr.level, ARCH_CONVERT) != level || | 1906 | INT_GET(par_node->hdr.level, ARCH_CONVERT) != level || |
1915 | INT_GET(par_node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC)) { | 1907 | be16_to_cpu(par_node->hdr.info.magic) != XFS_DA_NODE_MAGIC)) { |
1916 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", | 1908 | XFS_ERROR_REPORT("xfs_da_swap_lastblock(7)", |
1917 | XFS_ERRLEVEL_LOW, mp); | 1909 | XFS_ERRLEVEL_LOW, mp); |
1918 | error = XFS_ERROR(EFSCORRUPTED); | 1910 | error = XFS_ERROR(EFSCORRUPTED); |
@@ -2203,7 +2195,7 @@ xfs_da_do_buf( | |||
2203 | info = rbp->data; | 2195 | info = rbp->data; |
2204 | data = rbp->data; | 2196 | data = rbp->data; |
2205 | free = rbp->data; | 2197 | free = rbp->data; |
2206 | magic = INT_GET(info->magic, ARCH_CONVERT); | 2198 | magic = be16_to_cpu(info->magic); |
2207 | magic1 = be32_to_cpu(data->hdr.magic); | 2199 | magic1 = be32_to_cpu(data->hdr.magic); |
2208 | if (unlikely( | 2200 | if (unlikely( |
2209 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && | 2201 | XFS_TEST_ERROR((magic != XFS_DA_NODE_MAGIC) && |
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h index 41352113721a..e727bf456a12 100644 --- a/fs/xfs/xfs_da_btree.h +++ b/fs/xfs/xfs_da_btree.h | |||
@@ -45,10 +45,10 @@ struct zone; | |||
45 | (XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC) | 45 | (XFS_DIR_IS_V1(mp) ? XFS_DIR_LEAF_MAGIC : XFS_DIR2_LEAFN_MAGIC) |
46 | 46 | ||
47 | typedef struct xfs_da_blkinfo { | 47 | typedef struct xfs_da_blkinfo { |
48 | xfs_dablk_t forw; /* previous block in list */ | 48 | __be32 forw; /* previous block in list */ |
49 | xfs_dablk_t back; /* following block in list */ | 49 | __be32 back; /* following block in list */ |
50 | __uint16_t magic; /* validity check on block */ | 50 | __be16 magic; /* validity check on block */ |
51 | __uint16_t pad; /* unused */ | 51 | __be16 pad; /* unused */ |
52 | } xfs_da_blkinfo_t; | 52 | } xfs_da_blkinfo_t; |
53 | 53 | ||
54 | /* | 54 | /* |
diff --git a/fs/xfs/xfs_dir.c b/fs/xfs/xfs_dir.c index bb87d2a700a9..7a708e993db6 100644 --- a/fs/xfs/xfs_dir.c +++ b/fs/xfs/xfs_dir.c | |||
@@ -634,7 +634,7 @@ xfs_dir_leaf_removename(xfs_da_args_t *args, int *count, int *totallen) | |||
634 | return(retval); | 634 | return(retval); |
635 | ASSERT(bp != NULL); | 635 | ASSERT(bp != NULL); |
636 | leaf = bp->data; | 636 | leaf = bp->data; |
637 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 637 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
638 | retval = xfs_dir_leaf_lookup_int(bp, args, &index); | 638 | retval = xfs_dir_leaf_lookup_int(bp, args, &index); |
639 | if (retval == EEXIST) { | 639 | if (retval == EEXIST) { |
640 | (void)xfs_dir_leaf_remove(args->trans, bp, index); | 640 | (void)xfs_dir_leaf_remove(args->trans, bp, index); |
@@ -912,7 +912,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
912 | return(error); | 912 | return(error); |
913 | if (bp) | 913 | if (bp) |
914 | leaf = bp->data; | 914 | leaf = bp->data; |
915 | if (bp && INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { | 915 | if (bp && be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) { |
916 | xfs_dir_trace_g_dub("node: block not a leaf", | 916 | xfs_dir_trace_g_dub("node: block not a leaf", |
917 | dp, uio, bno); | 917 | dp, uio, bno); |
918 | xfs_da_brelse(trans, bp); | 918 | xfs_da_brelse(trans, bp); |
@@ -949,7 +949,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
949 | if (bp == NULL) | 949 | if (bp == NULL) |
950 | return(XFS_ERROR(EFSCORRUPTED)); | 950 | return(XFS_ERROR(EFSCORRUPTED)); |
951 | node = bp->data; | 951 | node = bp->data; |
952 | if (INT_GET(node->hdr.info.magic, ARCH_CONVERT) != XFS_DA_NODE_MAGIC) | 952 | if (be16_to_cpu(node->hdr.info.magic) != XFS_DA_NODE_MAGIC) |
953 | break; | 953 | break; |
954 | btree = &node->btree[0]; | 954 | btree = &node->btree[0]; |
955 | xfs_dir_trace_g_dun("node: node detail", dp, uio, node); | 955 | xfs_dir_trace_g_dun("node: node detail", dp, uio, node); |
@@ -982,7 +982,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
982 | */ | 982 | */ |
983 | for (;;) { | 983 | for (;;) { |
984 | leaf = bp->data; | 984 | leaf = bp->data; |
985 | if (unlikely(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC)) { | 985 | if (unlikely(be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC)) { |
986 | xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf); | 986 | xfs_dir_trace_g_dul("node: not a leaf", dp, uio, leaf); |
987 | xfs_da_brelse(trans, bp); | 987 | xfs_da_brelse(trans, bp); |
988 | XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)", | 988 | XFS_CORRUPTION_ERROR("xfs_dir_node_getdents(1)", |
@@ -990,7 +990,7 @@ xfs_dir_node_getdents(xfs_trans_t *trans, xfs_inode_t *dp, uio_t *uio, | |||
990 | return XFS_ERROR(EFSCORRUPTED); | 990 | return XFS_ERROR(EFSCORRUPTED); |
991 | } | 991 | } |
992 | xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf); | 992 | xfs_dir_trace_g_dul("node: leaf detail", dp, uio, leaf); |
993 | if ((nextbno = INT_GET(leaf->hdr.info.forw, ARCH_CONVERT))) { | 993 | if ((nextbno = be32_to_cpu(leaf->hdr.info.forw))) { |
994 | nextda = xfs_da_reada_buf(trans, dp, nextbno, | 994 | nextda = xfs_da_reada_buf(trans, dp, nextbno, |
995 | XFS_DATA_FORK); | 995 | XFS_DATA_FORK); |
996 | } else | 996 | } else |
@@ -1125,8 +1125,7 @@ xfs_dir_trace_g_dun(char *where, xfs_inode_t *dp, uio_t *uio, | |||
1125 | (void *)((unsigned long)(uio->uio_offset >> 32)), | 1125 | (void *)((unsigned long)(uio->uio_offset >> 32)), |
1126 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), | 1126 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), |
1127 | (void *)(unsigned long)uio->uio_resid, | 1127 | (void *)(unsigned long)uio->uio_resid, |
1128 | (void *)(unsigned long) | 1128 | (void *)(unsigned long)be32_to_cpu(node->hdr.info.forw), |
1129 | INT_GET(node->hdr.info.forw, ARCH_CONVERT), | ||
1130 | (void *)(unsigned long) | 1129 | (void *)(unsigned long) |
1131 | INT_GET(node->hdr.count, ARCH_CONVERT), | 1130 | INT_GET(node->hdr.count, ARCH_CONVERT), |
1132 | (void *)(unsigned long) | 1131 | (void *)(unsigned long) |
@@ -1150,8 +1149,7 @@ xfs_dir_trace_g_dul(char *where, xfs_inode_t *dp, uio_t *uio, | |||
1150 | (void *)((unsigned long)(uio->uio_offset >> 32)), | 1149 | (void *)((unsigned long)(uio->uio_offset >> 32)), |
1151 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), | 1150 | (void *)((unsigned long)(uio->uio_offset & 0xFFFFFFFF)), |
1152 | (void *)(unsigned long)uio->uio_resid, | 1151 | (void *)(unsigned long)uio->uio_resid, |
1153 | (void *)(unsigned long) | 1152 | (void *)(unsigned long)be32_to_cpu(leaf->hdr.info.forw), |
1154 | INT_GET(leaf->hdr.info.forw, ARCH_CONVERT), | ||
1155 | (void *)(unsigned long) | 1153 | (void *)(unsigned long) |
1156 | INT_GET(leaf->hdr.count, ARCH_CONVERT), | 1154 | INT_GET(leaf->hdr.count, ARCH_CONVERT), |
1157 | (void *)(unsigned long) | 1155 | (void *)(unsigned long) |
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c index 25d3a04f2e46..aaf5644d8fdc 100644 --- a/fs/xfs/xfs_dir2_block.c +++ b/fs/xfs/xfs_dir2_block.c | |||
@@ -905,7 +905,7 @@ xfs_dir2_leaf_to_block( | |||
905 | tp = args->trans; | 905 | tp = args->trans; |
906 | mp = dp->i_mount; | 906 | mp = dp->i_mount; |
907 | leaf = lbp->data; | 907 | leaf = lbp->data; |
908 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 908 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
909 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 909 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
910 | /* | 910 | /* |
911 | * If there are data blocks other than the first one, take this | 911 | * If there are data blocks other than the first one, take this |
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c index b5036512d02f..08648b18265c 100644 --- a/fs/xfs/xfs_dir2_leaf.c +++ b/fs/xfs/xfs_dir2_leaf.c | |||
@@ -564,7 +564,7 @@ xfs_dir2_leaf_check( | |||
564 | 564 | ||
565 | leaf = bp->data; | 565 | leaf = bp->data; |
566 | mp = dp->i_mount; | 566 | mp = dp->i_mount; |
567 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 567 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
568 | /* | 568 | /* |
569 | * This value is not restrictive enough. | 569 | * This value is not restrictive enough. |
570 | * Should factor in the size of the bests table as well. | 570 | * Should factor in the size of the bests table as well. |
@@ -1172,7 +1172,7 @@ xfs_dir2_leaf_init( | |||
1172 | /* | 1172 | /* |
1173 | * Initialize the header. | 1173 | * Initialize the header. |
1174 | */ | 1174 | */ |
1175 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, magic); | 1175 | leaf->hdr.info.magic = cpu_to_be16(magic); |
1176 | leaf->hdr.info.forw = 0; | 1176 | leaf->hdr.info.forw = 0; |
1177 | leaf->hdr.info.back = 0; | 1177 | leaf->hdr.info.back = 0; |
1178 | leaf->hdr.count = 0; | 1178 | leaf->hdr.count = 0; |
@@ -1208,7 +1208,7 @@ xfs_dir2_leaf_log_bests( | |||
1208 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ | 1208 | xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ |
1209 | 1209 | ||
1210 | leaf = bp->data; | 1210 | leaf = bp->data; |
1211 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 1211 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
1212 | ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); | 1212 | ltp = XFS_DIR2_LEAF_TAIL_P(tp->t_mountp, leaf); |
1213 | firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; | 1213 | firstb = XFS_DIR2_LEAF_BESTS_P(ltp) + first; |
1214 | lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; | 1214 | lastb = XFS_DIR2_LEAF_BESTS_P(ltp) + last; |
@@ -1231,8 +1231,8 @@ xfs_dir2_leaf_log_ents( | |||
1231 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1231 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1232 | 1232 | ||
1233 | leaf = bp->data; | 1233 | leaf = bp->data; |
1234 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || | 1234 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || |
1235 | INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1235 | be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1236 | firstlep = &leaf->ents[first]; | 1236 | firstlep = &leaf->ents[first]; |
1237 | lastlep = &leaf->ents[last]; | 1237 | lastlep = &leaf->ents[last]; |
1238 | xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), | 1238 | xfs_da_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), |
@@ -1250,8 +1250,8 @@ xfs_dir2_leaf_log_header( | |||
1250 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 1250 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
1251 | 1251 | ||
1252 | leaf = bp->data; | 1252 | leaf = bp->data; |
1253 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC || | 1253 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC || |
1254 | INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1254 | be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1255 | xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), | 1255 | xfs_da_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), |
1256 | (uint)(sizeof(leaf->hdr) - 1)); | 1256 | (uint)(sizeof(leaf->hdr) - 1)); |
1257 | } | 1257 | } |
@@ -1270,7 +1270,7 @@ xfs_dir2_leaf_log_tail( | |||
1270 | 1270 | ||
1271 | mp = tp->t_mountp; | 1271 | mp = tp->t_mountp; |
1272 | leaf = bp->data; | 1272 | leaf = bp->data; |
1273 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAF1_MAGIC); | 1273 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAF1_MAGIC); |
1274 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); | 1274 | ltp = XFS_DIR2_LEAF_TAIL_P(mp, leaf); |
1275 | xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), | 1275 | xfs_da_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), |
1276 | (uint)(mp->m_dirblksize - 1)); | 1276 | (uint)(mp->m_dirblksize - 1)); |
@@ -1806,7 +1806,7 @@ xfs_dir2_node_to_leaf( | |||
1806 | return 0; | 1806 | return 0; |
1807 | lbp = state->path.blk[0].bp; | 1807 | lbp = state->path.blk[0].bp; |
1808 | leaf = lbp->data; | 1808 | leaf = lbp->data; |
1809 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1809 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1810 | /* | 1810 | /* |
1811 | * Read the freespace block. | 1811 | * Read the freespace block. |
1812 | */ | 1812 | */ |
@@ -1837,7 +1837,7 @@ xfs_dir2_node_to_leaf( | |||
1837 | xfs_dir2_leaf_compact(args, lbp); | 1837 | xfs_dir2_leaf_compact(args, lbp); |
1838 | else | 1838 | else |
1839 | xfs_dir2_leaf_log_header(tp, lbp); | 1839 | xfs_dir2_leaf_log_header(tp, lbp); |
1840 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAF1_MAGIC); | 1840 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAF1_MAGIC); |
1841 | /* | 1841 | /* |
1842 | * Set up the leaf tail from the freespace block. | 1842 | * Set up the leaf tail from the freespace block. |
1843 | */ | 1843 | */ |
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c index 56b7cc89645e..af556f16a0c7 100644 --- a/fs/xfs/xfs_dir2_node.c +++ b/fs/xfs/xfs_dir2_node.c | |||
@@ -164,7 +164,7 @@ xfs_dir2_leaf_to_node( | |||
164 | *to = cpu_to_be16(off); | 164 | *to = cpu_to_be16(off); |
165 | } | 165 | } |
166 | free->hdr.nused = cpu_to_be32(n); | 166 | free->hdr.nused = cpu_to_be32(n); |
167 | INT_SET(leaf->hdr.info.magic, ARCH_CONVERT, XFS_DIR2_LEAFN_MAGIC); | 167 | leaf->hdr.info.magic = cpu_to_be16(XFS_DIR2_LEAFN_MAGIC); |
168 | /* | 168 | /* |
169 | * Log everything. | 169 | * Log everything. |
170 | */ | 170 | */ |
@@ -353,7 +353,7 @@ xfs_dir2_leafn_check( | |||
353 | 353 | ||
354 | leaf = bp->data; | 354 | leaf = bp->data; |
355 | mp = dp->i_mount; | 355 | mp = dp->i_mount; |
356 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 356 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
357 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); | 357 | ASSERT(be16_to_cpu(leaf->hdr.count) <= XFS_DIR2_MAX_LEAF_ENTS(mp)); |
358 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { | 358 | for (i = stale = 0; i < be16_to_cpu(leaf->hdr.count); i++) { |
359 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) { | 359 | if (i + 1 < be16_to_cpu(leaf->hdr.count)) { |
@@ -379,7 +379,7 @@ xfs_dir2_leafn_lasthash( | |||
379 | xfs_dir2_leaf_t *leaf; /* leaf structure */ | 379 | xfs_dir2_leaf_t *leaf; /* leaf structure */ |
380 | 380 | ||
381 | leaf = bp->data; | 381 | leaf = bp->data; |
382 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 382 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
383 | if (count) | 383 | if (count) |
384 | *count = be16_to_cpu(leaf->hdr.count); | 384 | *count = be16_to_cpu(leaf->hdr.count); |
385 | if (!leaf->hdr.count) | 385 | if (!leaf->hdr.count) |
@@ -420,7 +420,7 @@ xfs_dir2_leafn_lookup_int( | |||
420 | tp = args->trans; | 420 | tp = args->trans; |
421 | mp = dp->i_mount; | 421 | mp = dp->i_mount; |
422 | leaf = bp->data; | 422 | leaf = bp->data; |
423 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 423 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
424 | #ifdef __KERNEL__ | 424 | #ifdef __KERNEL__ |
425 | ASSERT(be16_to_cpu(leaf->hdr.count) > 0); | 425 | ASSERT(be16_to_cpu(leaf->hdr.count) > 0); |
426 | #endif | 426 | #endif |
@@ -720,8 +720,8 @@ xfs_dir2_leafn_order( | |||
720 | 720 | ||
721 | leaf1 = leaf1_bp->data; | 721 | leaf1 = leaf1_bp->data; |
722 | leaf2 = leaf2_bp->data; | 722 | leaf2 = leaf2_bp->data; |
723 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 723 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
724 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 724 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
725 | if (be16_to_cpu(leaf1->hdr.count) > 0 && | 725 | if (be16_to_cpu(leaf1->hdr.count) > 0 && |
726 | be16_to_cpu(leaf2->hdr.count) > 0 && | 726 | be16_to_cpu(leaf2->hdr.count) > 0 && |
727 | (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) || | 727 | (be32_to_cpu(leaf2->ents[0].hashval) < be32_to_cpu(leaf1->ents[0].hashval) || |
@@ -868,7 +868,7 @@ xfs_dir2_leafn_remove( | |||
868 | tp = args->trans; | 868 | tp = args->trans; |
869 | mp = dp->i_mount; | 869 | mp = dp->i_mount; |
870 | leaf = bp->data; | 870 | leaf = bp->data; |
871 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 871 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
872 | /* | 872 | /* |
873 | * Point to the entry we're removing. | 873 | * Point to the entry we're removing. |
874 | */ | 874 | */ |
@@ -1139,7 +1139,7 @@ xfs_dir2_leafn_toosmall( | |||
1139 | */ | 1139 | */ |
1140 | blk = &state->path.blk[state->path.active - 1]; | 1140 | blk = &state->path.blk[state->path.active - 1]; |
1141 | info = blk->bp->data; | 1141 | info = blk->bp->data; |
1142 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1142 | ASSERT(be16_to_cpu(info->magic) == XFS_DIR2_LEAFN_MAGIC); |
1143 | leaf = (xfs_dir2_leaf_t *)info; | 1143 | leaf = (xfs_dir2_leaf_t *)info; |
1144 | count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); | 1144 | count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); |
1145 | bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); | 1145 | bytes = (uint)sizeof(leaf->hdr) + count * (uint)sizeof(leaf->ents[0]); |
@@ -1161,7 +1161,7 @@ xfs_dir2_leafn_toosmall( | |||
1161 | * Make altpath point to the block we want to keep and | 1161 | * Make altpath point to the block we want to keep and |
1162 | * path point to the block we want to drop (this one). | 1162 | * path point to the block we want to drop (this one). |
1163 | */ | 1163 | */ |
1164 | forward = info->forw; | 1164 | forward = (info->forw != 0); |
1165 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1165 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1166 | error = xfs_da_path_shift(state, &state->altpath, forward, 0, | 1166 | error = xfs_da_path_shift(state, &state->altpath, forward, 0, |
1167 | &rval); | 1167 | &rval); |
@@ -1177,9 +1177,9 @@ xfs_dir2_leafn_toosmall( | |||
1177 | * We prefer coalescing with the lower numbered sibling so as | 1177 | * We prefer coalescing with the lower numbered sibling so as |
1178 | * to shrink a directory over time. | 1178 | * to shrink a directory over time. |
1179 | */ | 1179 | */ |
1180 | forward = INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT); | 1180 | forward = be32_to_cpu(info->forw) < be32_to_cpu(info->back); |
1181 | for (i = 0, bp = NULL; i < 2; forward = !forward, i++) { | 1181 | for (i = 0, bp = NULL; i < 2; forward = !forward, i++) { |
1182 | blkno = forward ?INT_GET( info->forw, ARCH_CONVERT) : INT_GET(info->back, ARCH_CONVERT); | 1182 | blkno = forward ? be32_to_cpu(info->forw) : be32_to_cpu(info->back); |
1183 | if (blkno == 0) | 1183 | if (blkno == 0) |
1184 | continue; | 1184 | continue; |
1185 | /* | 1185 | /* |
@@ -1198,7 +1198,7 @@ xfs_dir2_leafn_toosmall( | |||
1198 | count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); | 1198 | count = be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); |
1199 | bytes = state->blocksize - (state->blocksize >> 2); | 1199 | bytes = state->blocksize - (state->blocksize >> 2); |
1200 | leaf = bp->data; | 1200 | leaf = bp->data; |
1201 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1201 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1202 | count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); | 1202 | count += be16_to_cpu(leaf->hdr.count) - be16_to_cpu(leaf->hdr.stale); |
1203 | bytes -= count * (uint)sizeof(leaf->ents[0]); | 1203 | bytes -= count * (uint)sizeof(leaf->ents[0]); |
1204 | /* | 1204 | /* |
@@ -1257,8 +1257,8 @@ xfs_dir2_leafn_unbalance( | |||
1257 | ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); | 1257 | ASSERT(save_blk->magic == XFS_DIR2_LEAFN_MAGIC); |
1258 | drop_leaf = drop_blk->bp->data; | 1258 | drop_leaf = drop_blk->bp->data; |
1259 | save_leaf = save_blk->bp->data; | 1259 | save_leaf = save_blk->bp->data; |
1260 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1260 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1261 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR2_LEAFN_MAGIC); | 1261 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR2_LEAFN_MAGIC); |
1262 | /* | 1262 | /* |
1263 | * If there are any stale leaf entries, take this opportunity | 1263 | * If there are any stale leaf entries, take this opportunity |
1264 | * to purge them. | 1264 | * to purge them. |
diff --git a/fs/xfs/xfs_dir_leaf.c b/fs/xfs/xfs_dir_leaf.c index e83074016abb..0b2eca590b36 100644 --- a/fs/xfs/xfs_dir_leaf.c +++ b/fs/xfs/xfs_dir_leaf.c | |||
@@ -644,7 +644,7 @@ xfs_dir_leaf_to_shortform(xfs_da_args_t *iargs) | |||
644 | ASSERT(bp != NULL); | 644 | ASSERT(bp != NULL); |
645 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); | 645 | memcpy(tmpbuffer, bp->data, XFS_LBSIZE(dp->i_mount)); |
646 | leaf = (xfs_dir_leafblock_t *)tmpbuffer; | 646 | leaf = (xfs_dir_leafblock_t *)tmpbuffer; |
647 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 647 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
648 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); | 648 | memset(bp->data, 0, XFS_LBSIZE(dp->i_mount)); |
649 | 649 | ||
650 | /* | 650 | /* |
@@ -742,7 +742,7 @@ xfs_dir_leaf_to_node(xfs_da_args_t *args) | |||
742 | } | 742 | } |
743 | node = bp1->data; | 743 | node = bp1->data; |
744 | leaf = bp2->data; | 744 | leaf = bp2->data; |
745 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 745 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
746 | INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); | 746 | INT_SET(node->btree[0].hashval, ARCH_CONVERT, INT_GET(leaf->entries[ INT_GET(leaf->hdr.count, ARCH_CONVERT)-1 ].hashval, ARCH_CONVERT)); |
747 | xfs_da_buf_done(bp2); | 747 | xfs_da_buf_done(bp2); |
748 | INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); | 748 | INT_SET(node->btree[0].before, ARCH_CONVERT, blkno); |
@@ -781,7 +781,7 @@ xfs_dir_leaf_create(xfs_da_args_t *args, xfs_dablk_t blkno, xfs_dabuf_t **bpp) | |||
781 | leaf = bp->data; | 781 | leaf = bp->data; |
782 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); | 782 | memset((char *)leaf, 0, XFS_LBSIZE(dp->i_mount)); |
783 | hdr = &leaf->hdr; | 783 | hdr = &leaf->hdr; |
784 | INT_SET(hdr->info.magic, ARCH_CONVERT, XFS_DIR_LEAF_MAGIC); | 784 | hdr->info.magic = cpu_to_be16(XFS_DIR_LEAF_MAGIC); |
785 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); | 785 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount)); |
786 | if (!hdr->firstused) | 786 | if (!hdr->firstused) |
787 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); | 787 | INT_SET(hdr->firstused, ARCH_CONVERT, XFS_LBSIZE(dp->i_mount) - 1); |
@@ -860,7 +860,7 @@ xfs_dir_leaf_add(xfs_dabuf_t *bp, xfs_da_args_t *args, int index) | |||
860 | int tablesize, entsize, sum, i, tmp, error; | 860 | int tablesize, entsize, sum, i, tmp, error; |
861 | 861 | ||
862 | leaf = bp->data; | 862 | leaf = bp->data; |
863 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 863 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
864 | ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); | 864 | ASSERT((index >= 0) && (index <= INT_GET(leaf->hdr.count, ARCH_CONVERT))); |
865 | hdr = &leaf->hdr; | 865 | hdr = &leaf->hdr; |
866 | entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); | 866 | entsize = XFS_DIR_LEAF_ENTSIZE_BYNAME(args->namelen); |
@@ -940,7 +940,7 @@ xfs_dir_leaf_add_work(xfs_dabuf_t *bp, xfs_da_args_t *args, int index, | |||
940 | int tmp, i; | 940 | int tmp, i; |
941 | 941 | ||
942 | leaf = bp->data; | 942 | leaf = bp->data; |
943 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 943 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
944 | hdr = &leaf->hdr; | 944 | hdr = &leaf->hdr; |
945 | ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); | 945 | ASSERT((mapindex >= 0) && (mapindex < XFS_DIR_LEAF_MAPSIZE)); |
946 | ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); | 946 | ASSERT((index >= 0) && (index <= INT_GET(hdr->count, ARCH_CONVERT))); |
@@ -1097,8 +1097,8 @@ xfs_dir_leaf_rebalance(xfs_da_state_t *state, xfs_da_state_blk_t *blk1, | |||
1097 | ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); | 1097 | ASSERT(blk2->magic == XFS_DIR_LEAF_MAGIC); |
1098 | leaf1 = blk1->bp->data; | 1098 | leaf1 = blk1->bp->data; |
1099 | leaf2 = blk2->bp->data; | 1099 | leaf2 = blk2->bp->data; |
1100 | ASSERT(INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1100 | ASSERT(be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1101 | ASSERT(INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1101 | ASSERT(be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1102 | 1102 | ||
1103 | /* | 1103 | /* |
1104 | * Check ordering of blocks, reverse if it makes things simpler. | 1104 | * Check ordering of blocks, reverse if it makes things simpler. |
@@ -1325,7 +1325,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1325 | */ | 1325 | */ |
1326 | blk = &state->path.blk[ state->path.active-1 ]; | 1326 | blk = &state->path.blk[ state->path.active-1 ]; |
1327 | info = blk->bp->data; | 1327 | info = blk->bp->data; |
1328 | ASSERT(INT_GET(info->magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1328 | ASSERT(be16_to_cpu(info->magic) == XFS_DIR_LEAF_MAGIC); |
1329 | leaf = (xfs_dir_leafblock_t *)info; | 1329 | leaf = (xfs_dir_leafblock_t *)info; |
1330 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1330 | count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1331 | bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + | 1331 | bytes = (uint)sizeof(xfs_dir_leaf_hdr_t) + |
@@ -1348,7 +1348,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1348 | * Make altpath point to the block we want to keep and | 1348 | * Make altpath point to the block we want to keep and |
1349 | * path point to the block we want to drop (this one). | 1349 | * path point to the block we want to drop (this one). |
1350 | */ | 1350 | */ |
1351 | forward = info->forw; | 1351 | forward = (info->forw != 0); |
1352 | memcpy(&state->altpath, &state->path, sizeof(state->path)); | 1352 | memcpy(&state->altpath, &state->path, sizeof(state->path)); |
1353 | error = xfs_da_path_shift(state, &state->altpath, forward, | 1353 | error = xfs_da_path_shift(state, &state->altpath, forward, |
1354 | 0, &retval); | 1354 | 0, &retval); |
@@ -1369,12 +1369,12 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1369 | * We prefer coalescing with the lower numbered sibling so as | 1369 | * We prefer coalescing with the lower numbered sibling so as |
1370 | * to shrink a directory over time. | 1370 | * to shrink a directory over time. |
1371 | */ | 1371 | */ |
1372 | forward = (INT_GET(info->forw, ARCH_CONVERT) < INT_GET(info->back, ARCH_CONVERT)); /* start with smaller blk num */ | 1372 | forward = (be32_to_cpu(info->forw) < be32_to_cpu(info->back)); /* start with smaller blk num */ |
1373 | for (i = 0; i < 2; forward = !forward, i++) { | 1373 | for (i = 0; i < 2; forward = !forward, i++) { |
1374 | if (forward) | 1374 | if (forward) |
1375 | blkno = INT_GET(info->forw, ARCH_CONVERT); | 1375 | blkno = be32_to_cpu(info->forw); |
1376 | else | 1376 | else |
1377 | blkno = INT_GET(info->back, ARCH_CONVERT); | 1377 | blkno = be32_to_cpu(info->back); |
1378 | if (blkno == 0) | 1378 | if (blkno == 0) |
1379 | continue; | 1379 | continue; |
1380 | error = xfs_da_read_buf(state->args->trans, state->args->dp, | 1380 | error = xfs_da_read_buf(state->args->trans, state->args->dp, |
@@ -1389,7 +1389,7 @@ xfs_dir_leaf_toosmall(xfs_da_state_t *state, int *action) | |||
1389 | bytes = state->blocksize - (state->blocksize>>2); | 1389 | bytes = state->blocksize - (state->blocksize>>2); |
1390 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); | 1390 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); |
1391 | leaf = bp->data; | 1391 | leaf = bp->data; |
1392 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1392 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1393 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1393 | count += INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1394 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); | 1394 | bytes -= INT_GET(leaf->hdr.namebytes, ARCH_CONVERT); |
1395 | bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); | 1395 | bytes -= count * ((uint)sizeof(xfs_dir_leaf_name_t) - 1); |
@@ -1447,7 +1447,7 @@ xfs_dir_leaf_remove(xfs_trans_t *trans, xfs_dabuf_t *bp, int index) | |||
1447 | xfs_mount_t *mp; | 1447 | xfs_mount_t *mp; |
1448 | 1448 | ||
1449 | leaf = bp->data; | 1449 | leaf = bp->data; |
1450 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1450 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1451 | hdr = &leaf->hdr; | 1451 | hdr = &leaf->hdr; |
1452 | mp = trans->t_mountp; | 1452 | mp = trans->t_mountp; |
1453 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1453 | ASSERT((INT_GET(hdr->count, ARCH_CONVERT) > 0) && (INT_GET(hdr->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); |
@@ -1599,8 +1599,8 @@ xfs_dir_leaf_unbalance(xfs_da_state_t *state, xfs_da_state_blk_t *drop_blk, | |||
1599 | ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); | 1599 | ASSERT(save_blk->magic == XFS_DIR_LEAF_MAGIC); |
1600 | drop_leaf = drop_blk->bp->data; | 1600 | drop_leaf = drop_blk->bp->data; |
1601 | save_leaf = save_blk->bp->data; | 1601 | save_leaf = save_blk->bp->data; |
1602 | ASSERT(INT_GET(drop_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1602 | ASSERT(be16_to_cpu(drop_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1603 | ASSERT(INT_GET(save_leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1603 | ASSERT(be16_to_cpu(save_leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1604 | drop_hdr = &drop_leaf->hdr; | 1604 | drop_hdr = &drop_leaf->hdr; |
1605 | save_hdr = &save_leaf->hdr; | 1605 | save_hdr = &save_leaf->hdr; |
1606 | 1606 | ||
@@ -1695,7 +1695,7 @@ xfs_dir_leaf_lookup_int(xfs_dabuf_t *bp, xfs_da_args_t *args, int *index) | |||
1695 | xfs_dahash_t hashval; | 1695 | xfs_dahash_t hashval; |
1696 | 1696 | ||
1697 | leaf = bp->data; | 1697 | leaf = bp->data; |
1698 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1698 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1699 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); | 1699 | ASSERT(INT_GET(leaf->hdr.count, ARCH_CONVERT) < (XFS_LBSIZE(args->dp->i_mount)/8)); |
1700 | 1700 | ||
1701 | /* | 1701 | /* |
@@ -1782,8 +1782,8 @@ xfs_dir_leaf_moveents(xfs_dir_leafblock_t *leaf_s, int start_s, | |||
1782 | /* | 1782 | /* |
1783 | * Set up environment. | 1783 | * Set up environment. |
1784 | */ | 1784 | */ |
1785 | ASSERT(INT_GET(leaf_s->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1785 | ASSERT(be16_to_cpu(leaf_s->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1786 | ASSERT(INT_GET(leaf_d->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1786 | ASSERT(be16_to_cpu(leaf_d->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1787 | hdr_s = &leaf_s->hdr; | 1787 | hdr_s = &leaf_s->hdr; |
1788 | hdr_d = &leaf_d->hdr; | 1788 | hdr_d = &leaf_d->hdr; |
1789 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); | 1789 | ASSERT((INT_GET(hdr_s->count, ARCH_CONVERT) > 0) && (INT_GET(hdr_s->count, ARCH_CONVERT) < (XFS_LBSIZE(mp)/8))); |
@@ -1883,8 +1883,8 @@ xfs_dir_leaf_order(xfs_dabuf_t *leaf1_bp, xfs_dabuf_t *leaf2_bp) | |||
1883 | 1883 | ||
1884 | leaf1 = leaf1_bp->data; | 1884 | leaf1 = leaf1_bp->data; |
1885 | leaf2 = leaf2_bp->data; | 1885 | leaf2 = leaf2_bp->data; |
1886 | ASSERT((INT_GET(leaf1->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC) && | 1886 | ASSERT((be16_to_cpu(leaf1->hdr.info.magic) == XFS_DIR_LEAF_MAGIC) && |
1887 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC)); | 1887 | (be16_to_cpu(leaf2->hdr.info.magic) == XFS_DIR_LEAF_MAGIC)); |
1888 | if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && | 1888 | if ((INT_GET(leaf1->hdr.count, ARCH_CONVERT) > 0) && (INT_GET(leaf2->hdr.count, ARCH_CONVERT) > 0) && |
1889 | ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < | 1889 | ((INT_GET(leaf2->entries[ 0 ].hashval, ARCH_CONVERT) < |
1890 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || | 1890 | INT_GET(leaf1->entries[ 0 ].hashval, ARCH_CONVERT)) || |
@@ -1904,7 +1904,7 @@ xfs_dir_leaf_lasthash(xfs_dabuf_t *bp, int *count) | |||
1904 | xfs_dir_leafblock_t *leaf; | 1904 | xfs_dir_leafblock_t *leaf; |
1905 | 1905 | ||
1906 | leaf = bp->data; | 1906 | leaf = bp->data; |
1907 | ASSERT(INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) == XFS_DIR_LEAF_MAGIC); | 1907 | ASSERT(be16_to_cpu(leaf->hdr.info.magic) == XFS_DIR_LEAF_MAGIC); |
1908 | if (count) | 1908 | if (count) |
1909 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); | 1909 | *count = INT_GET(leaf->hdr.count, ARCH_CONVERT); |
1910 | if (!leaf->hdr.count) | 1910 | if (!leaf->hdr.count) |
@@ -1940,7 +1940,7 @@ xfs_dir_leaf_getdents_int( | |||
1940 | 1940 | ||
1941 | mp = dp->i_mount; | 1941 | mp = dp->i_mount; |
1942 | leaf = bp->data; | 1942 | leaf = bp->data; |
1943 | if (INT_GET(leaf->hdr.info.magic, ARCH_CONVERT) != XFS_DIR_LEAF_MAGIC) { | 1943 | if (be16_to_cpu(leaf->hdr.info.magic) != XFS_DIR_LEAF_MAGIC) { |
1944 | *eobp = 1; | 1944 | *eobp = 1; |
1945 | return XFS_ERROR(ENOENT); /* XXX wrong code */ | 1945 | return XFS_ERROR(ENOENT); /* XXX wrong code */ |
1946 | } | 1946 | } |
@@ -1992,7 +1992,7 @@ xfs_dir_leaf_getdents_int( | |||
1992 | 1992 | ||
1993 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { | 1993 | if (i == INT_GET(leaf->hdr.count, ARCH_CONVERT)) { |
1994 | xfs_dir_trace_g_du("leaf: hash not found", dp, uio); | 1994 | xfs_dir_trace_g_du("leaf: hash not found", dp, uio); |
1995 | if (!INT_GET(leaf->hdr.info.forw, ARCH_CONVERT)) | 1995 | if (!leaf->hdr.info.forw) |
1996 | uio->uio_offset = | 1996 | uio->uio_offset = |
1997 | XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); | 1997 | XFS_DA_MAKE_COOKIE(mp, 0, 0, XFS_DA_MAXHASH); |
1998 | /* | 1998 | /* |
@@ -2047,8 +2047,7 @@ xfs_dir_leaf_getdents_int( | |||
2047 | xfs_dir_trace_g_duc("leaf: middle cookie ", | 2047 | xfs_dir_trace_g_duc("leaf: middle cookie ", |
2048 | dp, uio, p.cook.o); | 2048 | dp, uio, p.cook.o); |
2049 | 2049 | ||
2050 | } else if ((thishash = INT_GET(leaf->hdr.info.forw, | 2050 | } else if ((thishash = be32_to_cpu(leaf->hdr.info.forw))) { |
2051 | ARCH_CONVERT))) { | ||
2052 | xfs_dabuf_t *bp2; | 2051 | xfs_dabuf_t *bp2; |
2053 | xfs_dir_leafblock_t *leaf2; | 2052 | xfs_dir_leafblock_t *leaf2; |
2054 | 2053 | ||
@@ -2064,9 +2063,9 @@ xfs_dir_leaf_getdents_int( | |||
2064 | leaf2 = bp2->data; | 2063 | leaf2 = bp2->data; |
2065 | 2064 | ||
2066 | if (unlikely( | 2065 | if (unlikely( |
2067 | (INT_GET(leaf2->hdr.info.magic, ARCH_CONVERT) | 2066 | (be16_to_cpu(leaf2->hdr.info.magic) |
2068 | != XFS_DIR_LEAF_MAGIC) | 2067 | != XFS_DIR_LEAF_MAGIC) |
2069 | || (INT_GET(leaf2->hdr.info.back, ARCH_CONVERT) | 2068 | || (be32_to_cpu(leaf2->hdr.info.back) |
2070 | != bno))) { /* GROT */ | 2069 | != bno))) { /* GROT */ |
2071 | XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", | 2070 | XFS_CORRUPTION_ERROR("xfs_dir_leaf_getdents_int(3)", |
2072 | XFS_ERRLEVEL_LOW, mp, | 2071 | XFS_ERRLEVEL_LOW, mp, |