aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:21:45 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:21:45 -0400
commitc2c4c477e0d02b0b352a71a25be56c9d35537265 (patch)
treec014163d3f5a2f851dd72f1c51dfe22db96eb936 /fs
parentc59f0ad23af0f4d7f64d2c2cdd85ceb49f6337fa (diff)
xfs: replace attr LBSIZE with xfs_da_geometry
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_attr.c2
-rw-r--r--fs/xfs/xfs_attr_leaf.c114
-rw-r--r--fs/xfs/xfs_attr_remote.c55
-rw-r--r--fs/xfs/xfs_da_format.h10
4 files changed, 89 insertions, 92 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 3d8c03edf657..470a22d190fb 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -863,7 +863,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
863} 863}
864 864
865/*======================================================================== 865/*========================================================================
866 * External routines when attribute list size > XFS_LBSIZE(mp). 866 * External routines when attribute list size > geo->blksize
867 *========================================================================*/ 867 *========================================================================*/
868 868
869/* 869/*
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 */
83STATIC void xfs_attr3_leaf_moveents(struct xfs_attr_leafblock *src_leaf, 83STATIC 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);
88STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index); 89STATIC int xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index);
89 90
90void 91void
@@ -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;
937out: 938out:
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*/
2240STATIC void 2244STATIC void
2241xfs_attr3_leaf_moveents( 2245xfs_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
diff --git a/fs/xfs/xfs_attr_remote.c b/fs/xfs/xfs_attr_remote.c
index 0f0679a134e2..b5adfecbb8ee 100644
--- a/fs/xfs/xfs_attr_remote.c
+++ b/fs/xfs/xfs_attr_remote.c
@@ -125,6 +125,7 @@ xfs_attr3_rmt_read_verify(
125 char *ptr; 125 char *ptr;
126 int len; 126 int len;
127 xfs_daddr_t bno; 127 xfs_daddr_t bno;
128 int blksize = mp->m_attr_geo->blksize;
128 129
129 /* no verification of non-crc buffers */ 130 /* no verification of non-crc buffers */
130 if (!xfs_sb_version_hascrc(&mp->m_sb)) 131 if (!xfs_sb_version_hascrc(&mp->m_sb))
@@ -133,21 +134,20 @@ xfs_attr3_rmt_read_verify(
133 ptr = bp->b_addr; 134 ptr = bp->b_addr;
134 bno = bp->b_bn; 135 bno = bp->b_bn;
135 len = BBTOB(bp->b_length); 136 len = BBTOB(bp->b_length);
136 ASSERT(len >= XFS_LBSIZE(mp)); 137 ASSERT(len >= blksize);
137 138
138 while (len > 0) { 139 while (len > 0) {
139 if (!xfs_verify_cksum(ptr, XFS_LBSIZE(mp), 140 if (!xfs_verify_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF)) {
140 XFS_ATTR3_RMT_CRC_OFF)) {
141 xfs_buf_ioerror(bp, EFSBADCRC); 141 xfs_buf_ioerror(bp, EFSBADCRC);
142 break; 142 break;
143 } 143 }
144 if (!xfs_attr3_rmt_verify(mp, ptr, XFS_LBSIZE(mp), bno)) { 144 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
145 xfs_buf_ioerror(bp, EFSCORRUPTED); 145 xfs_buf_ioerror(bp, EFSCORRUPTED);
146 break; 146 break;
147 } 147 }
148 len -= XFS_LBSIZE(mp); 148 len -= blksize;
149 ptr += XFS_LBSIZE(mp); 149 ptr += blksize;
150 bno += mp->m_bsize; 150 bno += BTOBB(blksize);
151 } 151 }
152 152
153 if (bp->b_error) 153 if (bp->b_error)
@@ -165,6 +165,7 @@ xfs_attr3_rmt_write_verify(
165 char *ptr; 165 char *ptr;
166 int len; 166 int len;
167 xfs_daddr_t bno; 167 xfs_daddr_t bno;
168 int blksize = mp->m_attr_geo->blksize;
168 169
169 /* no verification of non-crc buffers */ 170 /* no verification of non-crc buffers */
170 if (!xfs_sb_version_hascrc(&mp->m_sb)) 171 if (!xfs_sb_version_hascrc(&mp->m_sb))
@@ -173,10 +174,10 @@ xfs_attr3_rmt_write_verify(
173 ptr = bp->b_addr; 174 ptr = bp->b_addr;
174 bno = bp->b_bn; 175 bno = bp->b_bn;
175 len = BBTOB(bp->b_length); 176 len = BBTOB(bp->b_length);
176 ASSERT(len >= XFS_LBSIZE(mp)); 177 ASSERT(len >= blksize);
177 178
178 while (len > 0) { 179 while (len > 0) {
179 if (!xfs_attr3_rmt_verify(mp, ptr, XFS_LBSIZE(mp), bno)) { 180 if (!xfs_attr3_rmt_verify(mp, ptr, blksize, bno)) {
180 xfs_buf_ioerror(bp, EFSCORRUPTED); 181 xfs_buf_ioerror(bp, EFSCORRUPTED);
181 xfs_verifier_error(bp); 182 xfs_verifier_error(bp);
182 return; 183 return;
@@ -187,11 +188,11 @@ xfs_attr3_rmt_write_verify(
187 rmt = (struct xfs_attr3_rmt_hdr *)ptr; 188 rmt = (struct xfs_attr3_rmt_hdr *)ptr;
188 rmt->rm_lsn = cpu_to_be64(bip->bli_item.li_lsn); 189 rmt->rm_lsn = cpu_to_be64(bip->bli_item.li_lsn);
189 } 190 }
190 xfs_update_cksum(ptr, XFS_LBSIZE(mp), XFS_ATTR3_RMT_CRC_OFF); 191 xfs_update_cksum(ptr, blksize, XFS_ATTR3_RMT_CRC_OFF);
191 192
192 len -= XFS_LBSIZE(mp); 193 len -= blksize;
193 ptr += XFS_LBSIZE(mp); 194 ptr += blksize;
194 bno += mp->m_bsize; 195 bno += BTOBB(blksize);
195 } 196 }
196 ASSERT(len == 0); 197 ASSERT(len == 0);
197} 198}
@@ -240,12 +241,13 @@ xfs_attr_rmtval_copyout(
240 char *src = bp->b_addr; 241 char *src = bp->b_addr;
241 xfs_daddr_t bno = bp->b_bn; 242 xfs_daddr_t bno = bp->b_bn;
242 int len = BBTOB(bp->b_length); 243 int len = BBTOB(bp->b_length);
244 int blksize = mp->m_attr_geo->blksize;
243 245
244 ASSERT(len >= XFS_LBSIZE(mp)); 246 ASSERT(len >= blksize);
245 247
246 while (len > 0 && *valuelen > 0) { 248 while (len > 0 && *valuelen > 0) {
247 int hdr_size = 0; 249 int hdr_size = 0;
248 int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, XFS_LBSIZE(mp)); 250 int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, blksize);
249 251
250 byte_cnt = min(*valuelen, byte_cnt); 252 byte_cnt = min(*valuelen, byte_cnt);
251 253
@@ -263,9 +265,9 @@ xfs_attr_rmtval_copyout(
263 memcpy(*dst, src + hdr_size, byte_cnt); 265 memcpy(*dst, src + hdr_size, byte_cnt);
264 266
265 /* roll buffer forwards */ 267 /* roll buffer forwards */
266 len -= XFS_LBSIZE(mp); 268 len -= blksize;
267 src += XFS_LBSIZE(mp); 269 src += blksize;
268 bno += mp->m_bsize; 270 bno += BTOBB(blksize);
269 271
270 /* roll attribute data forwards */ 272 /* roll attribute data forwards */
271 *valuelen -= byte_cnt; 273 *valuelen -= byte_cnt;
@@ -287,12 +289,13 @@ xfs_attr_rmtval_copyin(
287 char *dst = bp->b_addr; 289 char *dst = bp->b_addr;
288 xfs_daddr_t bno = bp->b_bn; 290 xfs_daddr_t bno = bp->b_bn;
289 int len = BBTOB(bp->b_length); 291 int len = BBTOB(bp->b_length);
292 int blksize = mp->m_attr_geo->blksize;
290 293
291 ASSERT(len >= XFS_LBSIZE(mp)); 294 ASSERT(len >= blksize);
292 295
293 while (len > 0 && *valuelen > 0) { 296 while (len > 0 && *valuelen > 0) {
294 int hdr_size; 297 int hdr_size;
295 int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, XFS_LBSIZE(mp)); 298 int byte_cnt = XFS_ATTR3_RMT_BUF_SPACE(mp, blksize);
296 299
297 byte_cnt = min(*valuelen, byte_cnt); 300 byte_cnt = min(*valuelen, byte_cnt);
298 hdr_size = xfs_attr3_rmt_hdr_set(mp, dst, ino, *offset, 301 hdr_size = xfs_attr3_rmt_hdr_set(mp, dst, ino, *offset,
@@ -304,17 +307,17 @@ xfs_attr_rmtval_copyin(
304 * If this is the last block, zero the remainder of it. 307 * If this is the last block, zero the remainder of it.
305 * Check that we are actually the last block, too. 308 * Check that we are actually the last block, too.
306 */ 309 */
307 if (byte_cnt + hdr_size < XFS_LBSIZE(mp)) { 310 if (byte_cnt + hdr_size < blksize) {
308 ASSERT(*valuelen - byte_cnt == 0); 311 ASSERT(*valuelen - byte_cnt == 0);
309 ASSERT(len == XFS_LBSIZE(mp)); 312 ASSERT(len == blksize);
310 memset(dst + hdr_size + byte_cnt, 0, 313 memset(dst + hdr_size + byte_cnt, 0,
311 XFS_LBSIZE(mp) - hdr_size - byte_cnt); 314 blksize - hdr_size - byte_cnt);
312 } 315 }
313 316
314 /* roll buffer forwards */ 317 /* roll buffer forwards */
315 len -= XFS_LBSIZE(mp); 318 len -= blksize;
316 dst += XFS_LBSIZE(mp); 319 dst += blksize;
317 bno += mp->m_bsize; 320 bno += BTOBB(blksize);
318 321
319 /* roll attribute data forwards */ 322 /* roll attribute data forwards */
320 *valuelen -= byte_cnt; 323 *valuelen -= byte_cnt;
diff --git a/fs/xfs/xfs_da_format.h b/fs/xfs/xfs_da_format.h
index 44d7fac4ca64..0a49b0286372 100644
--- a/fs/xfs/xfs_da_format.h
+++ b/fs/xfs/xfs_da_format.h
@@ -19,10 +19,6 @@
19#ifndef __XFS_DA_FORMAT_H__ 19#ifndef __XFS_DA_FORMAT_H__
20#define __XFS_DA_FORMAT_H__ 20#define __XFS_DA_FORMAT_H__
21 21
22/*========================================================================
23 * Directory Structure when greater than XFS_LBSIZE(mp) bytes.
24 *========================================================================*/
25
26/* 22/*
27 * This structure is common to both leaf nodes and non-leaf nodes in the Btree. 23 * This structure is common to both leaf nodes and non-leaf nodes in the Btree.
28 * 24 *
@@ -122,8 +118,6 @@ struct xfs_da3_icnode_hdr {
122 __uint16_t level; 118 __uint16_t level;
123}; 119};
124 120
125#define XFS_LBSIZE(mp) (mp)->m_sb.sb_blocksize
126
127/* 121/*
128 * Directory version 2. 122 * Directory version 2.
129 * 123 *
@@ -620,10 +614,6 @@ xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
620 * of an attribute name may not be unique, we may have duplicate keys. The 614 * of an attribute name may not be unique, we may have duplicate keys. The
621 * internal links in the Btree are logical block offsets into the file. 615 * internal links in the Btree are logical block offsets into the file.
622 * 616 *
623 *========================================================================
624 * Attribute structure when equal to XFS_LBSIZE(mp) bytes.
625 *========================================================================
626 *
627 * Struct leaf_entry's are packed from the top. Name/values grow from the 617 * Struct leaf_entry's are packed from the top. Name/values grow from the
628 * bottom but are not packed. The freemap contains run-length-encoded entries 618 * bottom but are not packed. The freemap contains run-length-encoded entries
629 * for the free bytes after the leaf_entry's, but only the N largest such, 619 * for the free bytes after the leaf_entry's, but only the N largest such,