diff options
Diffstat (limited to 'fs/xfs/xfs_attr_leaf.c')
-rw-r--r-- | fs/xfs/xfs_attr_leaf.c | 114 |
1 files changed, 59 insertions, 55 deletions
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c index 77611032586d..ae33b141342b 100644 --- a/fs/xfs/xfs_attr_leaf.c +++ b/fs/xfs/xfs_attr_leaf.c | |||
@@ -80,11 +80,12 @@ STATIC int xfs_attr3_leaf_figure_balance(xfs_da_state_t *state, | |||
80 | /* | 80 | /* |
81 | * Utility routines. | 81 | * Utility routines. |
82 | */ | 82 | */ |
83 | STATIC void xfs_attr3_leaf_moveents(struct xfs_attr_leafblock *src_leaf, | 83 | STATIC void xfs_attr3_leaf_moveents(struct xfs_da_args *args, |
84 | struct xfs_attr_leafblock *src_leaf, | ||
84 | struct xfs_attr3_icleaf_hdr *src_ichdr, int src_start, | 85 | struct xfs_attr3_icleaf_hdr *src_ichdr, int src_start, |
85 | struct xfs_attr_leafblock *dst_leaf, | 86 | struct xfs_attr_leafblock *dst_leaf, |
86 | struct xfs_attr3_icleaf_hdr *dst_ichdr, int dst_start, | 87 | struct xfs_attr3_icleaf_hdr *dst_ichdr, int dst_start, |
87 | int move_count, struct xfs_mount *mp); | 88 | int move_count); |
88 | STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); | 89 | STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); |
89 | 90 | ||
90 | void | 91 | void |
@@ -806,18 +807,18 @@ xfs_attr3_leaf_to_shortform( | |||
806 | 807 | ||
807 | trace_xfs_attr_leaf_to_sf(args); | 808 | trace_xfs_attr_leaf_to_sf(args); |
808 | 809 | ||
809 | tmpbuffer = kmem_alloc(XFS_LBSIZE(dp->i_mount), KM_SLEEP); | 810 | tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP); |
810 | if (!tmpbuffer) | 811 | if (!tmpbuffer) |
811 | return ENOMEM; | 812 | return ENOMEM; |
812 | 813 | ||
813 | memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(dp->i_mount)); | 814 | memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); |
814 | 815 | ||
815 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; | 816 | leaf = (xfs_attr_leafblock_t *)tmpbuffer; |
816 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); | 817 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); |
817 | entry = xfs_attr3_leaf_entryp(leaf); | 818 | entry = xfs_attr3_leaf_entryp(leaf); |
818 | 819 | ||
819 | /* XXX (dgc): buffer is about to be marked stale - why zero it? */ | 820 | /* XXX (dgc): buffer is about to be marked stale - why zero it? */ |
820 | memset(bp->b_addr, 0, XFS_LBSIZE(dp->i_mount)); | 821 | memset(bp->b_addr, 0, args->geo->blksize); |
821 | 822 | ||
822 | /* | 823 | /* |
823 | * Clean out the prior contents of the attribute list. | 824 | * Clean out the prior contents of the attribute list. |
@@ -906,12 +907,12 @@ xfs_attr3_leaf_to_node( | |||
906 | /* copy leaf to new buffer, update identifiers */ | 907 | /* copy leaf to new buffer, update identifiers */ |
907 | xfs_trans_buf_set_type(args->trans, bp2, XFS_BLFT_ATTR_LEAF_BUF); | 908 | xfs_trans_buf_set_type(args->trans, bp2, XFS_BLFT_ATTR_LEAF_BUF); |
908 | bp2->b_ops = bp1->b_ops; | 909 | bp2->b_ops = bp1->b_ops; |
909 | memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(mp)); | 910 | memcpy(bp2->b_addr, bp1->b_addr, args->geo->blksize); |
910 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | 911 | if (xfs_sb_version_hascrc(&mp->m_sb)) { |
911 | struct xfs_da3_blkinfo *hdr3 = bp2->b_addr; | 912 | struct xfs_da3_blkinfo *hdr3 = bp2->b_addr; |
912 | hdr3->blkno = cpu_to_be64(bp2->b_bn); | 913 | hdr3->blkno = cpu_to_be64(bp2->b_bn); |
913 | } | 914 | } |
914 | xfs_trans_log_buf(args->trans, bp2, 0, XFS_LBSIZE(mp) - 1); | 915 | xfs_trans_log_buf(args->trans, bp2, 0, args->geo->blksize - 1); |
915 | 916 | ||
916 | /* | 917 | /* |
917 | * Set up the new root node. | 918 | * Set up the new root node. |
@@ -932,7 +933,7 @@ xfs_attr3_leaf_to_node( | |||
932 | btree[0].before = cpu_to_be32(blkno); | 933 | btree[0].before = cpu_to_be32(blkno); |
933 | icnodehdr.count = 1; | 934 | icnodehdr.count = 1; |
934 | dp->d_ops->node_hdr_to_disk(node, &icnodehdr); | 935 | dp->d_ops->node_hdr_to_disk(node, &icnodehdr); |
935 | xfs_trans_log_buf(args->trans, bp1, 0, XFS_LBSIZE(mp) - 1); | 936 | xfs_trans_log_buf(args->trans, bp1, 0, args->geo->blksize - 1); |
936 | error = 0; | 937 | error = 0; |
937 | out: | 938 | out: |
938 | return error; | 939 | return error; |
@@ -968,10 +969,10 @@ xfs_attr3_leaf_create( | |||
968 | bp->b_ops = &xfs_attr3_leaf_buf_ops; | 969 | bp->b_ops = &xfs_attr3_leaf_buf_ops; |
969 | xfs_trans_buf_set_type(args->trans, bp, XFS_BLFT_ATTR_LEAF_BUF); | 970 | xfs_trans_buf_set_type(args->trans, bp, XFS_BLFT_ATTR_LEAF_BUF); |
970 | leaf = bp->b_addr; | 971 | leaf = bp->b_addr; |
971 | memset(leaf, 0, XFS_LBSIZE(mp)); | 972 | memset(leaf, 0, args->geo->blksize); |
972 | 973 | ||
973 | memset(&ichdr, 0, sizeof(ichdr)); | 974 | memset(&ichdr, 0, sizeof(ichdr)); |
974 | ichdr.firstused = XFS_LBSIZE(mp); | 975 | ichdr.firstused = args->geo->blksize; |
975 | 976 | ||
976 | if (xfs_sb_version_hascrc(&mp->m_sb)) { | 977 | if (xfs_sb_version_hascrc(&mp->m_sb)) { |
977 | struct xfs_da3_blkinfo *hdr3 = bp->b_addr; | 978 | struct xfs_da3_blkinfo *hdr3 = bp->b_addr; |
@@ -990,7 +991,7 @@ xfs_attr3_leaf_create( | |||
990 | ichdr.freemap[0].size = ichdr.firstused - ichdr.freemap[0].base; | 991 | ichdr.freemap[0].size = ichdr.firstused - ichdr.freemap[0].base; |
991 | 992 | ||
992 | xfs_attr3_leaf_hdr_to_disk(leaf, &ichdr); | 993 | xfs_attr3_leaf_hdr_to_disk(leaf, &ichdr); |
993 | xfs_trans_log_buf(args->trans, bp, 0, XFS_LBSIZE(mp) - 1); | 994 | xfs_trans_log_buf(args->trans, bp, 0, args->geo->blksize - 1); |
994 | 995 | ||
995 | *bpp = bp; | 996 | *bpp = bp; |
996 | return 0; | 997 | return 0; |
@@ -1175,11 +1176,11 @@ xfs_attr3_leaf_add_work( | |||
1175 | * Allocate space for the new string (at the end of the run). | 1176 | * Allocate space for the new string (at the end of the run). |
1176 | */ | 1177 | */ |
1177 | mp = args->trans->t_mountp; | 1178 | mp = args->trans->t_mountp; |
1178 | ASSERT(ichdr->freemap[mapindex].base < XFS_LBSIZE(mp)); | 1179 | ASSERT(ichdr->freemap[mapindex].base < args->geo->blksize); |
1179 | ASSERT((ichdr->freemap[mapindex].base & 0x3) == 0); | 1180 | ASSERT((ichdr->freemap[mapindex].base & 0x3) == 0); |
1180 | ASSERT(ichdr->freemap[mapindex].size >= | 1181 | ASSERT(ichdr->freemap[mapindex].size >= |
1181 | xfs_attr_leaf_newentsize(args, NULL)); | 1182 | xfs_attr_leaf_newentsize(args, NULL)); |
1182 | ASSERT(ichdr->freemap[mapindex].size < XFS_LBSIZE(mp)); | 1183 | ASSERT(ichdr->freemap[mapindex].size < args->geo->blksize); |
1183 | ASSERT((ichdr->freemap[mapindex].size & 0x3) == 0); | 1184 | ASSERT((ichdr->freemap[mapindex].size & 0x3) == 0); |
1184 | 1185 | ||
1185 | ichdr->freemap[mapindex].size -= xfs_attr_leaf_newentsize(args, &tmp); | 1186 | ichdr->freemap[mapindex].size -= xfs_attr_leaf_newentsize(args, &tmp); |
@@ -1267,14 +1268,13 @@ xfs_attr3_leaf_compact( | |||
1267 | struct xfs_attr_leafblock *leaf_dst; | 1268 | struct xfs_attr_leafblock *leaf_dst; |
1268 | struct xfs_attr3_icleaf_hdr ichdr_src; | 1269 | struct xfs_attr3_icleaf_hdr ichdr_src; |
1269 | struct xfs_trans *trans = args->trans; | 1270 | struct xfs_trans *trans = args->trans; |
1270 | struct xfs_mount *mp = trans->t_mountp; | ||
1271 | char *tmpbuffer; | 1271 | char *tmpbuffer; |
1272 | 1272 | ||
1273 | trace_xfs_attr_leaf_compact(args); | 1273 | trace_xfs_attr_leaf_compact(args); |
1274 | 1274 | ||
1275 | tmpbuffer = kmem_alloc(XFS_LBSIZE(mp), KM_SLEEP); | 1275 | tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP); |
1276 | memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(mp)); | 1276 | memcpy(tmpbuffer, bp->b_addr, args->geo->blksize); |
1277 | memset(bp->b_addr, 0, XFS_LBSIZE(mp)); | 1277 | memset(bp->b_addr, 0, args->geo->blksize); |
1278 | leaf_src = (xfs_attr_leafblock_t *)tmpbuffer; | 1278 | leaf_src = (xfs_attr_leafblock_t *)tmpbuffer; |
1279 | leaf_dst = bp->b_addr; | 1279 | leaf_dst = bp->b_addr; |
1280 | 1280 | ||
@@ -1287,7 +1287,7 @@ xfs_attr3_leaf_compact( | |||
1287 | 1287 | ||
1288 | /* Initialise the incore headers */ | 1288 | /* Initialise the incore headers */ |
1289 | ichdr_src = *ichdr_dst; /* struct copy */ | 1289 | ichdr_src = *ichdr_dst; /* struct copy */ |
1290 | ichdr_dst->firstused = XFS_LBSIZE(mp); | 1290 | ichdr_dst->firstused = args->geo->blksize; |
1291 | ichdr_dst->usedbytes = 0; | 1291 | ichdr_dst->usedbytes = 0; |
1292 | ichdr_dst->count = 0; | 1292 | ichdr_dst->count = 0; |
1293 | ichdr_dst->holes = 0; | 1293 | ichdr_dst->holes = 0; |
@@ -1302,13 +1302,13 @@ xfs_attr3_leaf_compact( | |||
1302 | * Copy all entry's in the same (sorted) order, | 1302 | * Copy all entry's in the same (sorted) order, |
1303 | * but allocate name/value pairs packed and in sequence. | 1303 | * but allocate name/value pairs packed and in sequence. |
1304 | */ | 1304 | */ |
1305 | xfs_attr3_leaf_moveents(leaf_src, &ichdr_src, 0, leaf_dst, ichdr_dst, 0, | 1305 | xfs_attr3_leaf_moveents(args, leaf_src, &ichdr_src, 0, |
1306 | ichdr_src.count, mp); | 1306 | leaf_dst, ichdr_dst, 0, ichdr_src.count); |
1307 | /* | 1307 | /* |
1308 | * this logs the entire buffer, but the caller must write the header | 1308 | * this logs the entire buffer, but the caller must write the header |
1309 | * back to the buffer when it is finished modifying it. | 1309 | * back to the buffer when it is finished modifying it. |
1310 | */ | 1310 | */ |
1311 | xfs_trans_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); | 1311 | xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1); |
1312 | 1312 | ||
1313 | kmem_free(tmpbuffer); | 1313 | kmem_free(tmpbuffer); |
1314 | } | 1314 | } |
@@ -1459,8 +1459,8 @@ xfs_attr3_leaf_rebalance( | |||
1459 | /* | 1459 | /* |
1460 | * Move high entries from leaf1 to low end of leaf2. | 1460 | * Move high entries from leaf1 to low end of leaf2. |
1461 | */ | 1461 | */ |
1462 | xfs_attr3_leaf_moveents(leaf1, &ichdr1, ichdr1.count - count, | 1462 | xfs_attr3_leaf_moveents(args, leaf1, &ichdr1, |
1463 | leaf2, &ichdr2, 0, count, state->mp); | 1463 | ichdr1.count - count, leaf2, &ichdr2, 0, count); |
1464 | 1464 | ||
1465 | } else if (count > ichdr1.count) { | 1465 | } else if (count > ichdr1.count) { |
1466 | /* | 1466 | /* |
@@ -1488,8 +1488,8 @@ xfs_attr3_leaf_rebalance( | |||
1488 | /* | 1488 | /* |
1489 | * Move low entries from leaf2 to high end of leaf1. | 1489 | * Move low entries from leaf2 to high end of leaf1. |
1490 | */ | 1490 | */ |
1491 | xfs_attr3_leaf_moveents(leaf2, &ichdr2, 0, leaf1, &ichdr1, | 1491 | xfs_attr3_leaf_moveents(args, leaf2, &ichdr2, 0, leaf1, &ichdr1, |
1492 | ichdr1.count, count, state->mp); | 1492 | ichdr1.count, count); |
1493 | } | 1493 | } |
1494 | 1494 | ||
1495 | xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1); | 1495 | xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1); |
@@ -1795,7 +1795,6 @@ xfs_attr3_leaf_remove( | |||
1795 | struct xfs_attr_leafblock *leaf; | 1795 | struct xfs_attr_leafblock *leaf; |
1796 | struct xfs_attr3_icleaf_hdr ichdr; | 1796 | struct xfs_attr3_icleaf_hdr ichdr; |
1797 | struct xfs_attr_leaf_entry *entry; | 1797 | struct xfs_attr_leaf_entry *entry; |
1798 | struct xfs_mount *mp = args->trans->t_mountp; | ||
1799 | int before; | 1798 | int before; |
1800 | int after; | 1799 | int after; |
1801 | int smallest; | 1800 | int smallest; |
@@ -1809,7 +1808,7 @@ xfs_attr3_leaf_remove( | |||
1809 | leaf = bp->b_addr; | 1808 | leaf = bp->b_addr; |
1810 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); | 1809 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); |
1811 | 1810 | ||
1812 | ASSERT(ichdr.count > 0 && ichdr.count < XFS_LBSIZE(mp) / 8); | 1811 | ASSERT(ichdr.count > 0 && ichdr.count < args->geo->blksize / 8); |
1813 | ASSERT(args->index >= 0 && args->index < ichdr.count); | 1812 | ASSERT(args->index >= 0 && args->index < ichdr.count); |
1814 | ASSERT(ichdr.firstused >= ichdr.count * sizeof(*entry) + | 1813 | ASSERT(ichdr.firstused >= ichdr.count * sizeof(*entry) + |
1815 | xfs_attr3_leaf_hdr_size(leaf)); | 1814 | xfs_attr3_leaf_hdr_size(leaf)); |
@@ -1817,7 +1816,7 @@ xfs_attr3_leaf_remove( | |||
1817 | entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; | 1816 | entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; |
1818 | 1817 | ||
1819 | ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused); | 1818 | ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused); |
1820 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); | 1819 | ASSERT(be16_to_cpu(entry->nameidx) < args->geo->blksize); |
1821 | 1820 | ||
1822 | /* | 1821 | /* |
1823 | * Scan through free region table: | 1822 | * Scan through free region table: |
@@ -1832,8 +1831,8 @@ xfs_attr3_leaf_remove( | |||
1832 | smallest = XFS_ATTR_LEAF_MAPSIZE - 1; | 1831 | smallest = XFS_ATTR_LEAF_MAPSIZE - 1; |
1833 | entsize = xfs_attr_leaf_entsize(leaf, args->index); | 1832 | entsize = xfs_attr_leaf_entsize(leaf, args->index); |
1834 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) { | 1833 | for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) { |
1835 | ASSERT(ichdr.freemap[i].base < XFS_LBSIZE(mp)); | 1834 | ASSERT(ichdr.freemap[i].base < args->geo->blksize); |
1836 | ASSERT(ichdr.freemap[i].size < XFS_LBSIZE(mp)); | 1835 | ASSERT(ichdr.freemap[i].size < args->geo->blksize); |
1837 | if (ichdr.freemap[i].base == tablesize) { | 1836 | if (ichdr.freemap[i].base == tablesize) { |
1838 | ichdr.freemap[i].base -= sizeof(xfs_attr_leaf_entry_t); | 1837 | ichdr.freemap[i].base -= sizeof(xfs_attr_leaf_entry_t); |
1839 | ichdr.freemap[i].size += sizeof(xfs_attr_leaf_entry_t); | 1838 | ichdr.freemap[i].size += sizeof(xfs_attr_leaf_entry_t); |
@@ -1910,11 +1909,11 @@ xfs_attr3_leaf_remove( | |||
1910 | * removing the name. | 1909 | * removing the name. |
1911 | */ | 1910 | */ |
1912 | if (smallest) { | 1911 | if (smallest) { |
1913 | tmp = XFS_LBSIZE(mp); | 1912 | tmp = args->geo->blksize; |
1914 | entry = xfs_attr3_leaf_entryp(leaf); | 1913 | entry = xfs_attr3_leaf_entryp(leaf); |
1915 | for (i = ichdr.count - 1; i >= 0; entry++, i--) { | 1914 | for (i = ichdr.count - 1; i >= 0; entry++, i--) { |
1916 | ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused); | 1915 | ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused); |
1917 | ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); | 1916 | ASSERT(be16_to_cpu(entry->nameidx) < args->geo->blksize); |
1918 | 1917 | ||
1919 | if (be16_to_cpu(entry->nameidx) < tmp) | 1918 | if (be16_to_cpu(entry->nameidx) < tmp) |
1920 | tmp = be16_to_cpu(entry->nameidx); | 1919 | tmp = be16_to_cpu(entry->nameidx); |
@@ -1954,7 +1953,6 @@ xfs_attr3_leaf_unbalance( | |||
1954 | struct xfs_attr3_icleaf_hdr drophdr; | 1953 | struct xfs_attr3_icleaf_hdr drophdr; |
1955 | struct xfs_attr3_icleaf_hdr savehdr; | 1954 | struct xfs_attr3_icleaf_hdr savehdr; |
1956 | struct xfs_attr_leaf_entry *entry; | 1955 | struct xfs_attr_leaf_entry *entry; |
1957 | struct xfs_mount *mp = state->mp; | ||
1958 | 1956 | ||
1959 | trace_xfs_attr_leaf_unbalance(state->args); | 1957 | trace_xfs_attr_leaf_unbalance(state->args); |
1960 | 1958 | ||
@@ -1981,13 +1979,15 @@ xfs_attr3_leaf_unbalance( | |||
1981 | */ | 1979 | */ |
1982 | if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, | 1980 | if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, |
1983 | drop_blk->bp, &drophdr)) { | 1981 | drop_blk->bp, &drophdr)) { |
1984 | xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, | 1982 | xfs_attr3_leaf_moveents(state->args, |
1983 | drop_leaf, &drophdr, 0, | ||
1985 | save_leaf, &savehdr, 0, | 1984 | save_leaf, &savehdr, 0, |
1986 | drophdr.count, mp); | 1985 | drophdr.count); |
1987 | } else { | 1986 | } else { |
1988 | xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, | 1987 | xfs_attr3_leaf_moveents(state->args, |
1988 | drop_leaf, &drophdr, 0, | ||
1989 | save_leaf, &savehdr, | 1989 | save_leaf, &savehdr, |
1990 | savehdr.count, drophdr.count, mp); | 1990 | savehdr.count, drophdr.count); |
1991 | } | 1991 | } |
1992 | } else { | 1992 | } else { |
1993 | /* | 1993 | /* |
@@ -2017,19 +2017,23 @@ xfs_attr3_leaf_unbalance( | |||
2017 | 2017 | ||
2018 | if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, | 2018 | if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, |
2019 | drop_blk->bp, &drophdr)) { | 2019 | drop_blk->bp, &drophdr)) { |
2020 | xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, | 2020 | xfs_attr3_leaf_moveents(state->args, |
2021 | drop_leaf, &drophdr, 0, | ||
2021 | tmp_leaf, &tmphdr, 0, | 2022 | tmp_leaf, &tmphdr, 0, |
2022 | drophdr.count, mp); | 2023 | drophdr.count); |
2023 | xfs_attr3_leaf_moveents(save_leaf, &savehdr, 0, | 2024 | xfs_attr3_leaf_moveents(state->args, |
2025 | save_leaf, &savehdr, 0, | ||
2024 | tmp_leaf, &tmphdr, tmphdr.count, | 2026 | tmp_leaf, &tmphdr, tmphdr.count, |
2025 | savehdr.count, mp); | 2027 | savehdr.count); |
2026 | } else { | 2028 | } else { |
2027 | xfs_attr3_leaf_moveents(save_leaf, &savehdr, 0, | 2029 | xfs_attr3_leaf_moveents(state->args, |
2030 | save_leaf, &savehdr, 0, | ||
2028 | tmp_leaf, &tmphdr, 0, | 2031 | tmp_leaf, &tmphdr, 0, |
2029 | savehdr.count, mp); | 2032 | savehdr.count); |
2030 | xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, | 2033 | xfs_attr3_leaf_moveents(state->args, |
2034 | drop_leaf, &drophdr, 0, | ||
2031 | tmp_leaf, &tmphdr, tmphdr.count, | 2035 | tmp_leaf, &tmphdr, tmphdr.count, |
2032 | drophdr.count, mp); | 2036 | drophdr.count); |
2033 | } | 2037 | } |
2034 | memcpy(save_leaf, tmp_leaf, state->blocksize); | 2038 | memcpy(save_leaf, tmp_leaf, state->blocksize); |
2035 | savehdr = tmphdr; /* struct copy */ | 2039 | savehdr = tmphdr; /* struct copy */ |
@@ -2084,7 +2088,7 @@ xfs_attr3_leaf_lookup_int( | |||
2084 | leaf = bp->b_addr; | 2088 | leaf = bp->b_addr; |
2085 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); | 2089 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); |
2086 | entries = xfs_attr3_leaf_entryp(leaf); | 2090 | entries = xfs_attr3_leaf_entryp(leaf); |
2087 | ASSERT(ichdr.count < XFS_LBSIZE(args->dp->i_mount) / 8); | 2091 | ASSERT(ichdr.count < args->geo->blksize / 8); |
2088 | 2092 | ||
2089 | /* | 2093 | /* |
2090 | * Binary search. (note: small blocks will skip this loop) | 2094 | * Binary search. (note: small blocks will skip this loop) |
@@ -2188,7 +2192,7 @@ xfs_attr3_leaf_getvalue( | |||
2188 | 2192 | ||
2189 | leaf = bp->b_addr; | 2193 | leaf = bp->b_addr; |
2190 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); | 2194 | xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); |
2191 | ASSERT(ichdr.count < XFS_LBSIZE(args->dp->i_mount) / 8); | 2195 | ASSERT(ichdr.count < args->geo->blksize / 8); |
2192 | ASSERT(args->index < ichdr.count); | 2196 | ASSERT(args->index < ichdr.count); |
2193 | 2197 | ||
2194 | entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; | 2198 | entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; |
@@ -2239,14 +2243,14 @@ xfs_attr3_leaf_getvalue( | |||
2239 | /*ARGSUSED*/ | 2243 | /*ARGSUSED*/ |
2240 | STATIC void | 2244 | STATIC void |
2241 | xfs_attr3_leaf_moveents( | 2245 | xfs_attr3_leaf_moveents( |
2246 | struct xfs_da_args *args, | ||
2242 | struct xfs_attr_leafblock *leaf_s, | 2247 | struct xfs_attr_leafblock *leaf_s, |
2243 | struct xfs_attr3_icleaf_hdr *ichdr_s, | 2248 | struct xfs_attr3_icleaf_hdr *ichdr_s, |
2244 | int start_s, | 2249 | int start_s, |
2245 | struct xfs_attr_leafblock *leaf_d, | 2250 | struct xfs_attr_leafblock *leaf_d, |
2246 | struct xfs_attr3_icleaf_hdr *ichdr_d, | 2251 | struct xfs_attr3_icleaf_hdr *ichdr_d, |
2247 | int start_d, | 2252 | int start_d, |
2248 | int count, | 2253 | int count) |
2249 | struct xfs_mount *mp) | ||
2250 | { | 2254 | { |
2251 | struct xfs_attr_leaf_entry *entry_s; | 2255 | struct xfs_attr_leaf_entry *entry_s; |
2252 | struct xfs_attr_leaf_entry *entry_d; | 2256 | struct xfs_attr_leaf_entry *entry_d; |
@@ -2266,10 +2270,10 @@ xfs_attr3_leaf_moveents( | |||
2266 | ASSERT(ichdr_s->magic == XFS_ATTR_LEAF_MAGIC || | 2270 | ASSERT(ichdr_s->magic == XFS_ATTR_LEAF_MAGIC || |
2267 | ichdr_s->magic == XFS_ATTR3_LEAF_MAGIC); | 2271 | ichdr_s->magic == XFS_ATTR3_LEAF_MAGIC); |
2268 | ASSERT(ichdr_s->magic == ichdr_d->magic); | 2272 | ASSERT(ichdr_s->magic == ichdr_d->magic); |
2269 | ASSERT(ichdr_s->count > 0 && ichdr_s->count < XFS_LBSIZE(mp) / 8); | 2273 | ASSERT(ichdr_s->count > 0 && ichdr_s->count < args->geo->blksize / 8); |
2270 | ASSERT(ichdr_s->firstused >= (ichdr_s->count * sizeof(*entry_s)) | 2274 | ASSERT(ichdr_s->firstused >= (ichdr_s->count * sizeof(*entry_s)) |
2271 | + xfs_attr3_leaf_hdr_size(leaf_s)); | 2275 | + xfs_attr3_leaf_hdr_size(leaf_s)); |
2272 | ASSERT(ichdr_d->count < XFS_LBSIZE(mp) / 8); | 2276 | ASSERT(ichdr_d->count < args->geo->blksize / 8); |
2273 | ASSERT(ichdr_d->firstused >= (ichdr_d->count * sizeof(*entry_d)) | 2277 | ASSERT(ichdr_d->firstused >= (ichdr_d->count * sizeof(*entry_d)) |
2274 | + xfs_attr3_leaf_hdr_size(leaf_d)); | 2278 | + xfs_attr3_leaf_hdr_size(leaf_d)); |
2275 | 2279 | ||
@@ -2321,11 +2325,11 @@ xfs_attr3_leaf_moveents( | |||
2321 | entry_d->nameidx = cpu_to_be16(ichdr_d->firstused); | 2325 | entry_d->nameidx = cpu_to_be16(ichdr_d->firstused); |
2322 | entry_d->flags = entry_s->flags; | 2326 | entry_d->flags = entry_s->flags; |
2323 | ASSERT(be16_to_cpu(entry_d->nameidx) + tmp | 2327 | ASSERT(be16_to_cpu(entry_d->nameidx) + tmp |
2324 | <= XFS_LBSIZE(mp)); | 2328 | <= args->geo->blksize); |
2325 | memmove(xfs_attr3_leaf_name(leaf_d, desti), | 2329 | memmove(xfs_attr3_leaf_name(leaf_d, desti), |
2326 | xfs_attr3_leaf_name(leaf_s, start_s + i), tmp); | 2330 | xfs_attr3_leaf_name(leaf_s, start_s + i), tmp); |
2327 | ASSERT(be16_to_cpu(entry_s->nameidx) + tmp | 2331 | ASSERT(be16_to_cpu(entry_s->nameidx) + tmp |
2328 | <= XFS_LBSIZE(mp)); | 2332 | <= args->geo->blksize); |
2329 | memset(xfs_attr3_leaf_name(leaf_s, start_s + i), 0, tmp); | 2333 | memset(xfs_attr3_leaf_name(leaf_s, start_s + i), 0, tmp); |
2330 | ichdr_s->usedbytes -= tmp; | 2334 | ichdr_s->usedbytes -= tmp; |
2331 | ichdr_d->usedbytes += tmp; | 2335 | ichdr_d->usedbytes += tmp; |
@@ -2346,7 +2350,7 @@ xfs_attr3_leaf_moveents( | |||
2346 | tmp = count * sizeof(xfs_attr_leaf_entry_t); | 2350 | tmp = count * sizeof(xfs_attr_leaf_entry_t); |
2347 | entry_s = &xfs_attr3_leaf_entryp(leaf_s)[start_s]; | 2351 | entry_s = &xfs_attr3_leaf_entryp(leaf_s)[start_s]; |
2348 | ASSERT(((char *)entry_s + tmp) <= | 2352 | ASSERT(((char *)entry_s + tmp) <= |
2349 | ((char *)leaf_s + XFS_LBSIZE(mp))); | 2353 | ((char *)leaf_s + args->geo->blksize)); |
2350 | memset(entry_s, 0, tmp); | 2354 | memset(entry_s, 0, tmp); |
2351 | } else { | 2355 | } else { |
2352 | /* | 2356 | /* |
@@ -2361,7 +2365,7 @@ xfs_attr3_leaf_moveents( | |||
2361 | tmp = count * sizeof(xfs_attr_leaf_entry_t); | 2365 | tmp = count * sizeof(xfs_attr_leaf_entry_t); |
2362 | entry_s = &xfs_attr3_leaf_entryp(leaf_s)[ichdr_s->count]; | 2366 | entry_s = &xfs_attr3_leaf_entryp(leaf_s)[ichdr_s->count]; |
2363 | ASSERT(((char *)entry_s + tmp) <= | 2367 | ASSERT(((char *)entry_s + tmp) <= |
2364 | ((char *)leaf_s + XFS_LBSIZE(mp))); | 2368 | ((char *)leaf_s + args->geo->blksize)); |
2365 | memset(entry_s, 0, tmp); | 2369 | memset(entry_s, 0, tmp); |
2366 | } | 2370 | } |
2367 | 2371 | ||