aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDave Chinner <david@fromorbit.com>2014-06-09 17:32:41 -0400
committerDave Chinner <david@fromorbit.com>2014-06-09 17:32:41 -0400
commit8612c7e594808e4a67bc2d4661f5925df2be3f51 (patch)
treebf13dd921033fb4aaba8bd5ad309e933b6427ad8
parentb70f14e1ffbb47369b1cc2cdf558c3468ae9e484 (diff)
parent35f46c5f04cc7c45ce59d3ba4c28ba138184414b (diff)
Merge branch 'xfs-da-geom' into for-next
-rw-r--r--fs/xfs/xfs_attr.c17
-rw-r--r--fs/xfs/xfs_attr_leaf.c184
-rw-r--r--fs/xfs/xfs_attr_leaf.h3
-rw-r--r--fs/xfs/xfs_attr_list.c1
-rw-r--r--fs/xfs/xfs_attr_remote.c55
-rw-r--r--fs/xfs/xfs_bmap.c3
-rw-r--r--fs/xfs/xfs_da_btree.c65
-rw-r--r--fs/xfs/xfs_da_btree.h20
-rw-r--r--fs/xfs/xfs_da_format.c36
-rw-r--r--fs/xfs/xfs_da_format.h154
-rw-r--r--fs/xfs/xfs_dir2.c132
-rw-r--r--fs/xfs/xfs_dir2.h30
-rw-r--r--fs/xfs/xfs_dir2_block.c88
-rw-r--r--fs/xfs/xfs_dir2_data.c80
-rw-r--r--fs/xfs/xfs_dir2_leaf.c200
-rw-r--r--fs/xfs/xfs_dir2_node.c188
-rw-r--r--fs/xfs/xfs_dir2_priv.h138
-rw-r--r--fs/xfs/xfs_dir2_readdir.c142
-rw-r--r--fs/xfs/xfs_dir2_sf.c18
-rw-r--r--fs/xfs/xfs_fsops.c4
-rw-r--r--fs/xfs/xfs_log_rlimit.c2
-rw-r--r--fs/xfs/xfs_mount.c16
-rw-r--r--fs/xfs/xfs_mount.h12
-rw-r--r--fs/xfs/xfs_symlink.c1
-rw-r--r--fs/xfs/xfs_trans_resv.c3
-rw-r--r--fs/xfs/xfs_trans_space.h5
26 files changed, 819 insertions, 778 deletions
diff --git a/fs/xfs/xfs_attr.c b/fs/xfs/xfs_attr.c
index 1fc1f06277da..bfe36fc2cdc2 100644
--- a/fs/xfs/xfs_attr.c
+++ b/fs/xfs/xfs_attr.c
@@ -88,6 +88,7 @@ xfs_attr_args_init(
88 return EINVAL; 88 return EINVAL;
89 89
90 memset(args, 0, sizeof(*args)); 90 memset(args, 0, sizeof(*args));
91 args->geo = dp->i_mount->m_attr_geo;
91 args->whichfork = XFS_ATTR_FORK; 92 args->whichfork = XFS_ATTR_FORK;
92 args->dp = dp; 93 args->dp = dp;
93 args->flags = flags; 94 args->flags = flags;
@@ -173,12 +174,10 @@ xfs_attr_calc_size(
173 * Determine space new attribute will use, and if it would be 174 * Determine space new attribute will use, and if it would be
174 * "local" or "remote" (note: local != inline). 175 * "local" or "remote" (note: local != inline).
175 */ 176 */
176 size = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, 177 size = xfs_attr_leaf_newentsize(args, local);
177 mp->m_sb.sb_blocksize, local);
178
179 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); 178 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
180 if (*local) { 179 if (*local) {
181 if (size > (mp->m_sb.sb_blocksize >> 1)) { 180 if (size > (args->geo->blksize / 2)) {
182 /* Double split possible */ 181 /* Double split possible */
183 nblks *= 2; 182 nblks *= 2;
184 } 183 }
@@ -864,7 +863,7 @@ xfs_attr_leaf_get(xfs_da_args_t *args)
864} 863}
865 864
866/*======================================================================== 865/*========================================================================
867 * External routines when attribute list size > XFS_LBSIZE(mp). 866 * External routines when attribute list size > geo->blksize
868 *========================================================================*/ 867 *========================================================================*/
869 868
870/* 869/*
@@ -897,8 +896,6 @@ restart:
897 state = xfs_da_state_alloc(); 896 state = xfs_da_state_alloc();
898 state->args = args; 897 state->args = args;
899 state->mp = mp; 898 state->mp = mp;
900 state->blocksize = state->mp->m_sb.sb_blocksize;
901 state->node_ents = state->mp->m_attr_node_ents;
902 899
903 /* 900 /*
904 * Search to see if name already exists, and get back a pointer 901 * Search to see if name already exists, and get back a pointer
@@ -1076,8 +1073,6 @@ restart:
1076 state = xfs_da_state_alloc(); 1073 state = xfs_da_state_alloc();
1077 state->args = args; 1074 state->args = args;
1078 state->mp = mp; 1075 state->mp = mp;
1079 state->blocksize = state->mp->m_sb.sb_blocksize;
1080 state->node_ents = state->mp->m_attr_node_ents;
1081 state->inleaf = 0; 1076 state->inleaf = 0;
1082 error = xfs_da3_node_lookup_int(state, &retval); 1077 error = xfs_da3_node_lookup_int(state, &retval);
1083 if (error) 1078 if (error)
@@ -1168,8 +1163,6 @@ xfs_attr_node_removename(xfs_da_args_t *args)
1168 state = xfs_da_state_alloc(); 1163 state = xfs_da_state_alloc();
1169 state->args = args; 1164 state->args = args;
1170 state->mp = dp->i_mount; 1165 state->mp = dp->i_mount;
1171 state->blocksize = state->mp->m_sb.sb_blocksize;
1172 state->node_ents = state->mp->m_attr_node_ents;
1173 1166
1174 /* 1167 /*
1175 * Search to see if name exists, and get back a pointer to it. 1168 * Search to see if name exists, and get back a pointer to it.
@@ -1431,8 +1424,6 @@ xfs_attr_node_get(xfs_da_args_t *args)
1431 state = xfs_da_state_alloc(); 1424 state = xfs_da_state_alloc();
1432 state->args = args; 1425 state->args = args;
1433 state->mp = args->dp->i_mount; 1426 state->mp = args->dp->i_mount;
1434 state->blocksize = state->mp->m_sb.sb_blocksize;
1435 state->node_ents = state->mp->m_attr_node_ents;
1436 1427
1437 /* 1428 /*
1438 * Search to see if name exists, and get back a pointer to it. 1429 * Search to see if name exists, and get back a pointer to it.
diff --git a/fs/xfs/xfs_attr_leaf.c b/fs/xfs/xfs_attr_leaf.c
index 511c283459b1..28712d29e43c 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
@@ -711,6 +712,7 @@ xfs_attr_shortform_to_leaf(xfs_da_args_t *args)
711 712
712 memset((char *)&nargs, 0, sizeof(nargs)); 713 memset((char *)&nargs, 0, sizeof(nargs));
713 nargs.dp = dp; 714 nargs.dp = dp;
715 nargs.geo = args->geo;
714 nargs.firstblock = args->firstblock; 716 nargs.firstblock = args->firstblock;
715 nargs.flist = args->flist; 717 nargs.flist = args->flist;
716 nargs.total = args->total; 718 nargs.total = args->total;
@@ -805,18 +807,18 @@ xfs_attr3_leaf_to_shortform(
805 807
806 trace_xfs_attr_leaf_to_sf(args); 808 trace_xfs_attr_leaf_to_sf(args);
807 809
808 tmpbuffer = kmem_alloc(XFS_LBSIZE(dp->i_mount), KM_SLEEP); 810 tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP);
809 if (!tmpbuffer) 811 if (!tmpbuffer)
810 return ENOMEM; 812 return ENOMEM;
811 813
812 memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(dp->i_mount)); 814 memcpy(tmpbuffer, bp->b_addr, args->geo->blksize);
813 815
814 leaf = (xfs_attr_leafblock_t *)tmpbuffer; 816 leaf = (xfs_attr_leafblock_t *)tmpbuffer;
815 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); 817 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
816 entry = xfs_attr3_leaf_entryp(leaf); 818 entry = xfs_attr3_leaf_entryp(leaf);
817 819
818 /* 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? */
819 memset(bp->b_addr, 0, XFS_LBSIZE(dp->i_mount)); 821 memset(bp->b_addr, 0, args->geo->blksize);
820 822
821 /* 823 /*
822 * Clean out the prior contents of the attribute list. 824 * Clean out the prior contents of the attribute list.
@@ -838,6 +840,7 @@ xfs_attr3_leaf_to_shortform(
838 * Copy the attributes 840 * Copy the attributes
839 */ 841 */
840 memset((char *)&nargs, 0, sizeof(nargs)); 842 memset((char *)&nargs, 0, sizeof(nargs));
843 nargs.geo = args->geo;
841 nargs.dp = dp; 844 nargs.dp = dp;
842 nargs.firstblock = args->firstblock; 845 nargs.firstblock = args->firstblock;
843 nargs.flist = args->flist; 846 nargs.flist = args->flist;
@@ -904,12 +907,12 @@ xfs_attr3_leaf_to_node(
904 /* copy leaf to new buffer, update identifiers */ 907 /* copy leaf to new buffer, update identifiers */
905 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);
906 bp2->b_ops = bp1->b_ops; 909 bp2->b_ops = bp1->b_ops;
907 memcpy(bp2->b_addr, bp1->b_addr, XFS_LBSIZE(mp)); 910 memcpy(bp2->b_addr, bp1->b_addr, args->geo->blksize);
908 if (xfs_sb_version_hascrc(&mp->m_sb)) { 911 if (xfs_sb_version_hascrc(&mp->m_sb)) {
909 struct xfs_da3_blkinfo *hdr3 = bp2->b_addr; 912 struct xfs_da3_blkinfo *hdr3 = bp2->b_addr;
910 hdr3->blkno = cpu_to_be64(bp2->b_bn); 913 hdr3->blkno = cpu_to_be64(bp2->b_bn);
911 } 914 }
912 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);
913 916
914 /* 917 /*
915 * Set up the new root node. 918 * Set up the new root node.
@@ -930,7 +933,7 @@ xfs_attr3_leaf_to_node(
930 btree[0].before = cpu_to_be32(blkno); 933 btree[0].before = cpu_to_be32(blkno);
931 icnodehdr.count = 1; 934 icnodehdr.count = 1;
932 dp->d_ops->node_hdr_to_disk(node, &icnodehdr); 935 dp->d_ops->node_hdr_to_disk(node, &icnodehdr);
933 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);
934 error = 0; 937 error = 0;
935out: 938out:
936 return error; 939 return error;
@@ -966,10 +969,10 @@ xfs_attr3_leaf_create(
966 bp->b_ops = &xfs_attr3_leaf_buf_ops; 969 bp->b_ops = &xfs_attr3_leaf_buf_ops;
967 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);
968 leaf = bp->b_addr; 971 leaf = bp->b_addr;
969 memset(leaf, 0, XFS_LBSIZE(mp)); 972 memset(leaf, 0, args->geo->blksize);
970 973
971 memset(&ichdr, 0, sizeof(ichdr)); 974 memset(&ichdr, 0, sizeof(ichdr));
972 ichdr.firstused = XFS_LBSIZE(mp); 975 ichdr.firstused = args->geo->blksize;
973 976
974 if (xfs_sb_version_hascrc(&mp->m_sb)) { 977 if (xfs_sb_version_hascrc(&mp->m_sb)) {
975 struct xfs_da3_blkinfo *hdr3 = bp->b_addr; 978 struct xfs_da3_blkinfo *hdr3 = bp->b_addr;
@@ -988,7 +991,7 @@ xfs_attr3_leaf_create(
988 ichdr.freemap[0].size = ichdr.firstused - ichdr.freemap[0].base; 991 ichdr.freemap[0].size = ichdr.firstused - ichdr.freemap[0].base;
989 992
990 xfs_attr3_leaf_hdr_to_disk(leaf, &ichdr); 993 xfs_attr3_leaf_hdr_to_disk(leaf, &ichdr);
991 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);
992 995
993 *bpp = bp; 996 *bpp = bp;
994 return 0; 997 return 0;
@@ -1074,8 +1077,7 @@ xfs_attr3_leaf_add(
1074 leaf = bp->b_addr; 1077 leaf = bp->b_addr;
1075 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); 1078 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
1076 ASSERT(args->index >= 0 && args->index <= ichdr.count); 1079 ASSERT(args->index >= 0 && args->index <= ichdr.count);
1077 entsize = xfs_attr_leaf_newentsize(args->namelen, args->valuelen, 1080 entsize = xfs_attr_leaf_newentsize(args, NULL);
1078 args->trans->t_mountp->m_sb.sb_blocksize, NULL);
1079 1081
1080 /* 1082 /*
1081 * Search through freemap for first-fit on new name length. 1083 * Search through freemap for first-fit on new name length.
@@ -1174,17 +1176,14 @@ xfs_attr3_leaf_add_work(
1174 * 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).
1175 */ 1177 */
1176 mp = args->trans->t_mountp; 1178 mp = args->trans->t_mountp;
1177 ASSERT(ichdr->freemap[mapindex].base < XFS_LBSIZE(mp)); 1179 ASSERT(ichdr->freemap[mapindex].base < args->geo->blksize);
1178 ASSERT((ichdr->freemap[mapindex].base & 0x3) == 0); 1180 ASSERT((ichdr->freemap[mapindex].base & 0x3) == 0);
1179 ASSERT(ichdr->freemap[mapindex].size >= 1181 ASSERT(ichdr->freemap[mapindex].size >=
1180 xfs_attr_leaf_newentsize(args->namelen, args->valuelen, 1182 xfs_attr_leaf_newentsize(args, NULL));
1181 mp->m_sb.sb_blocksize, NULL)); 1183 ASSERT(ichdr->freemap[mapindex].size < args->geo->blksize);
1182 ASSERT(ichdr->freemap[mapindex].size < XFS_LBSIZE(mp));
1183 ASSERT((ichdr->freemap[mapindex].size & 0x3) == 0); 1184 ASSERT((ichdr->freemap[mapindex].size & 0x3) == 0);
1184 1185
1185 ichdr->freemap[mapindex].size -= 1186 ichdr->freemap[mapindex].size -= xfs_attr_leaf_newentsize(args, &tmp);
1186 xfs_attr_leaf_newentsize(args->namelen, args->valuelen,
1187 mp->m_sb.sb_blocksize, &tmp);
1188 1187
1189 entry->nameidx = cpu_to_be16(ichdr->freemap[mapindex].base + 1188 entry->nameidx = cpu_to_be16(ichdr->freemap[mapindex].base +
1190 ichdr->freemap[mapindex].size); 1189 ichdr->freemap[mapindex].size);
@@ -1269,14 +1268,13 @@ xfs_attr3_leaf_compact(
1269 struct xfs_attr_leafblock *leaf_dst; 1268 struct xfs_attr_leafblock *leaf_dst;
1270 struct xfs_attr3_icleaf_hdr ichdr_src; 1269 struct xfs_attr3_icleaf_hdr ichdr_src;
1271 struct xfs_trans *trans = args->trans; 1270 struct xfs_trans *trans = args->trans;
1272 struct xfs_mount *mp = trans->t_mountp;
1273 char *tmpbuffer; 1271 char *tmpbuffer;
1274 1272
1275 trace_xfs_attr_leaf_compact(args); 1273 trace_xfs_attr_leaf_compact(args);
1276 1274
1277 tmpbuffer = kmem_alloc(XFS_LBSIZE(mp), KM_SLEEP); 1275 tmpbuffer = kmem_alloc(args->geo->blksize, KM_SLEEP);
1278 memcpy(tmpbuffer, bp->b_addr, XFS_LBSIZE(mp)); 1276 memcpy(tmpbuffer, bp->b_addr, args->geo->blksize);
1279 memset(bp->b_addr, 0, XFS_LBSIZE(mp)); 1277 memset(bp->b_addr, 0, args->geo->blksize);
1280 leaf_src = (xfs_attr_leafblock_t *)tmpbuffer; 1278 leaf_src = (xfs_attr_leafblock_t *)tmpbuffer;
1281 leaf_dst = bp->b_addr; 1279 leaf_dst = bp->b_addr;
1282 1280
@@ -1289,7 +1287,7 @@ xfs_attr3_leaf_compact(
1289 1287
1290 /* Initialise the incore headers */ 1288 /* Initialise the incore headers */
1291 ichdr_src = *ichdr_dst; /* struct copy */ 1289 ichdr_src = *ichdr_dst; /* struct copy */
1292 ichdr_dst->firstused = XFS_LBSIZE(mp); 1290 ichdr_dst->firstused = args->geo->blksize;
1293 ichdr_dst->usedbytes = 0; 1291 ichdr_dst->usedbytes = 0;
1294 ichdr_dst->count = 0; 1292 ichdr_dst->count = 0;
1295 ichdr_dst->holes = 0; 1293 ichdr_dst->holes = 0;
@@ -1304,13 +1302,13 @@ xfs_attr3_leaf_compact(
1304 * Copy all entry's in the same (sorted) order, 1302 * Copy all entry's in the same (sorted) order,
1305 * but allocate name/value pairs packed and in sequence. 1303 * but allocate name/value pairs packed and in sequence.
1306 */ 1304 */
1307 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,
1308 ichdr_src.count, mp); 1306 leaf_dst, ichdr_dst, 0, ichdr_src.count);
1309 /* 1307 /*
1310 * 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
1311 * back to the buffer when it is finished modifying it. 1309 * back to the buffer when it is finished modifying it.
1312 */ 1310 */
1313 xfs_trans_log_buf(trans, bp, 0, XFS_LBSIZE(mp) - 1); 1311 xfs_trans_log_buf(trans, bp, 0, args->geo->blksize - 1);
1314 1312
1315 kmem_free(tmpbuffer); 1313 kmem_free(tmpbuffer);
1316} 1314}
@@ -1461,8 +1459,8 @@ xfs_attr3_leaf_rebalance(
1461 /* 1459 /*
1462 * Move high entries from leaf1 to low end of leaf2. 1460 * Move high entries from leaf1 to low end of leaf2.
1463 */ 1461 */
1464 xfs_attr3_leaf_moveents(leaf1, &ichdr1, ichdr1.count - count, 1462 xfs_attr3_leaf_moveents(args, leaf1, &ichdr1,
1465 leaf2, &ichdr2, 0, count, state->mp); 1463 ichdr1.count - count, leaf2, &ichdr2, 0, count);
1466 1464
1467 } else if (count > ichdr1.count) { 1465 } else if (count > ichdr1.count) {
1468 /* 1466 /*
@@ -1490,14 +1488,14 @@ xfs_attr3_leaf_rebalance(
1490 /* 1488 /*
1491 * Move low entries from leaf2 to high end of leaf1. 1489 * Move low entries from leaf2 to high end of leaf1.
1492 */ 1490 */
1493 xfs_attr3_leaf_moveents(leaf2, &ichdr2, 0, leaf1, &ichdr1, 1491 xfs_attr3_leaf_moveents(args, leaf2, &ichdr2, 0, leaf1, &ichdr1,
1494 ichdr1.count, count, state->mp); 1492 ichdr1.count, count);
1495 } 1493 }
1496 1494
1497 xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1); 1495 xfs_attr3_leaf_hdr_to_disk(leaf1, &ichdr1);
1498 xfs_attr3_leaf_hdr_to_disk(leaf2, &ichdr2); 1496 xfs_attr3_leaf_hdr_to_disk(leaf2, &ichdr2);
1499 xfs_trans_log_buf(args->trans, blk1->bp, 0, state->blocksize-1); 1497 xfs_trans_log_buf(args->trans, blk1->bp, 0, args->geo->blksize - 1);
1500 xfs_trans_log_buf(args->trans, blk2->bp, 0, state->blocksize-1); 1498 xfs_trans_log_buf(args->trans, blk2->bp, 0, args->geo->blksize - 1);
1501 1499
1502 /* 1500 /*
1503 * Copy out last hashval in each block for B-tree code. 1501 * Copy out last hashval in each block for B-tree code.
@@ -1592,11 +1590,9 @@ xfs_attr3_leaf_figure_balance(
1592 max = ichdr1->count + ichdr2->count; 1590 max = ichdr1->count + ichdr2->count;
1593 half = (max + 1) * sizeof(*entry); 1591 half = (max + 1) * sizeof(*entry);
1594 half += ichdr1->usedbytes + ichdr2->usedbytes + 1592 half += ichdr1->usedbytes + ichdr2->usedbytes +
1595 xfs_attr_leaf_newentsize(state->args->namelen, 1593 xfs_attr_leaf_newentsize(state->args, NULL);
1596 state->args->valuelen,
1597 state->blocksize, NULL);
1598 half /= 2; 1594 half /= 2;
1599 lastdelta = state->blocksize; 1595 lastdelta = state->args->geo->blksize;
1600 entry = xfs_attr3_leaf_entryp(leaf1); 1596 entry = xfs_attr3_leaf_entryp(leaf1);
1601 for (count = index = 0; count < max; entry++, index++, count++) { 1597 for (count = index = 0; count < max; entry++, index++, count++) {
1602 1598
@@ -1606,10 +1602,7 @@ xfs_attr3_leaf_figure_balance(
1606 */ 1602 */
1607 if (count == blk1->index) { 1603 if (count == blk1->index) {
1608 tmp = totallen + sizeof(*entry) + 1604 tmp = totallen + sizeof(*entry) +
1609 xfs_attr_leaf_newentsize( 1605 xfs_attr_leaf_newentsize(state->args, NULL);
1610 state->args->namelen,
1611 state->args->valuelen,
1612 state->blocksize, NULL);
1613 if (XFS_ATTR_ABS(half - tmp) > lastdelta) 1606 if (XFS_ATTR_ABS(half - tmp) > lastdelta)
1614 break; 1607 break;
1615 lastdelta = XFS_ATTR_ABS(half - tmp); 1608 lastdelta = XFS_ATTR_ABS(half - tmp);
@@ -1645,10 +1638,7 @@ xfs_attr3_leaf_figure_balance(
1645 totallen -= count * sizeof(*entry); 1638 totallen -= count * sizeof(*entry);
1646 if (foundit) { 1639 if (foundit) {
1647 totallen -= sizeof(*entry) + 1640 totallen -= sizeof(*entry) +
1648 xfs_attr_leaf_newentsize( 1641 xfs_attr_leaf_newentsize(state->args, NULL);
1649 state->args->namelen,
1650 state->args->valuelen,
1651 state->blocksize, NULL);
1652 } 1642 }
1653 1643
1654 *countarg = count; 1644 *countarg = count;
@@ -1700,7 +1690,7 @@ xfs_attr3_leaf_toosmall(
1700 bytes = xfs_attr3_leaf_hdr_size(leaf) + 1690 bytes = xfs_attr3_leaf_hdr_size(leaf) +
1701 ichdr.count * sizeof(xfs_attr_leaf_entry_t) + 1691 ichdr.count * sizeof(xfs_attr_leaf_entry_t) +
1702 ichdr.usedbytes; 1692 ichdr.usedbytes;
1703 if (bytes > (state->blocksize >> 1)) { 1693 if (bytes > (state->args->geo->blksize >> 1)) {
1704 *action = 0; /* blk over 50%, don't try to join */ 1694 *action = 0; /* blk over 50%, don't try to join */
1705 return(0); 1695 return(0);
1706 } 1696 }
@@ -1754,7 +1744,8 @@ xfs_attr3_leaf_toosmall(
1754 1744
1755 xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr); 1745 xfs_attr3_leaf_hdr_from_disk(&ichdr2, bp->b_addr);
1756 1746
1757 bytes = state->blocksize - (state->blocksize >> 2) - 1747 bytes = state->args->geo->blksize -
1748 (state->args->geo->blksize >> 2) -
1758 ichdr.usedbytes - ichdr2.usedbytes - 1749 ichdr.usedbytes - ichdr2.usedbytes -
1759 ((ichdr.count + ichdr2.count) * 1750 ((ichdr.count + ichdr2.count) *
1760 sizeof(xfs_attr_leaf_entry_t)) - 1751 sizeof(xfs_attr_leaf_entry_t)) -
@@ -1805,7 +1796,6 @@ xfs_attr3_leaf_remove(
1805 struct xfs_attr_leafblock *leaf; 1796 struct xfs_attr_leafblock *leaf;
1806 struct xfs_attr3_icleaf_hdr ichdr; 1797 struct xfs_attr3_icleaf_hdr ichdr;
1807 struct xfs_attr_leaf_entry *entry; 1798 struct xfs_attr_leaf_entry *entry;
1808 struct xfs_mount *mp = args->trans->t_mountp;
1809 int before; 1799 int before;
1810 int after; 1800 int after;
1811 int smallest; 1801 int smallest;
@@ -1819,7 +1809,7 @@ xfs_attr3_leaf_remove(
1819 leaf = bp->b_addr; 1809 leaf = bp->b_addr;
1820 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); 1810 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
1821 1811
1822 ASSERT(ichdr.count > 0 && ichdr.count < XFS_LBSIZE(mp) / 8); 1812 ASSERT(ichdr.count > 0 && ichdr.count < args->geo->blksize / 8);
1823 ASSERT(args->index >= 0 && args->index < ichdr.count); 1813 ASSERT(args->index >= 0 && args->index < ichdr.count);
1824 ASSERT(ichdr.firstused >= ichdr.count * sizeof(*entry) + 1814 ASSERT(ichdr.firstused >= ichdr.count * sizeof(*entry) +
1825 xfs_attr3_leaf_hdr_size(leaf)); 1815 xfs_attr3_leaf_hdr_size(leaf));
@@ -1827,7 +1817,7 @@ xfs_attr3_leaf_remove(
1827 entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; 1817 entry = &xfs_attr3_leaf_entryp(leaf)[args->index];
1828 1818
1829 ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused); 1819 ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused);
1830 ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); 1820 ASSERT(be16_to_cpu(entry->nameidx) < args->geo->blksize);
1831 1821
1832 /* 1822 /*
1833 * Scan through free region table: 1823 * Scan through free region table:
@@ -1842,8 +1832,8 @@ xfs_attr3_leaf_remove(
1842 smallest = XFS_ATTR_LEAF_MAPSIZE - 1; 1832 smallest = XFS_ATTR_LEAF_MAPSIZE - 1;
1843 entsize = xfs_attr_leaf_entsize(leaf, args->index); 1833 entsize = xfs_attr_leaf_entsize(leaf, args->index);
1844 for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) { 1834 for (i = 0; i < XFS_ATTR_LEAF_MAPSIZE; i++) {
1845 ASSERT(ichdr.freemap[i].base < XFS_LBSIZE(mp)); 1835 ASSERT(ichdr.freemap[i].base < args->geo->blksize);
1846 ASSERT(ichdr.freemap[i].size < XFS_LBSIZE(mp)); 1836 ASSERT(ichdr.freemap[i].size < args->geo->blksize);
1847 if (ichdr.freemap[i].base == tablesize) { 1837 if (ichdr.freemap[i].base == tablesize) {
1848 ichdr.freemap[i].base -= sizeof(xfs_attr_leaf_entry_t); 1838 ichdr.freemap[i].base -= sizeof(xfs_attr_leaf_entry_t);
1849 ichdr.freemap[i].size += sizeof(xfs_attr_leaf_entry_t); 1839 ichdr.freemap[i].size += sizeof(xfs_attr_leaf_entry_t);
@@ -1920,11 +1910,11 @@ xfs_attr3_leaf_remove(
1920 * removing the name. 1910 * removing the name.
1921 */ 1911 */
1922 if (smallest) { 1912 if (smallest) {
1923 tmp = XFS_LBSIZE(mp); 1913 tmp = args->geo->blksize;
1924 entry = xfs_attr3_leaf_entryp(leaf); 1914 entry = xfs_attr3_leaf_entryp(leaf);
1925 for (i = ichdr.count - 1; i >= 0; entry++, i--) { 1915 for (i = ichdr.count - 1; i >= 0; entry++, i--) {
1926 ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused); 1916 ASSERT(be16_to_cpu(entry->nameidx) >= ichdr.firstused);
1927 ASSERT(be16_to_cpu(entry->nameidx) < XFS_LBSIZE(mp)); 1917 ASSERT(be16_to_cpu(entry->nameidx) < args->geo->blksize);
1928 1918
1929 if (be16_to_cpu(entry->nameidx) < tmp) 1919 if (be16_to_cpu(entry->nameidx) < tmp)
1930 tmp = be16_to_cpu(entry->nameidx); 1920 tmp = be16_to_cpu(entry->nameidx);
@@ -1947,7 +1937,7 @@ xfs_attr3_leaf_remove(
1947 tmp = ichdr.usedbytes + xfs_attr3_leaf_hdr_size(leaf) + 1937 tmp = ichdr.usedbytes + xfs_attr3_leaf_hdr_size(leaf) +
1948 ichdr.count * sizeof(xfs_attr_leaf_entry_t); 1938 ichdr.count * sizeof(xfs_attr_leaf_entry_t);
1949 1939
1950 return tmp < mp->m_attr_magicpct; /* leaf is < 37% full */ 1940 return tmp < args->geo->magicpct; /* leaf is < 37% full */
1951} 1941}
1952 1942
1953/* 1943/*
@@ -1964,7 +1954,6 @@ xfs_attr3_leaf_unbalance(
1964 struct xfs_attr3_icleaf_hdr drophdr; 1954 struct xfs_attr3_icleaf_hdr drophdr;
1965 struct xfs_attr3_icleaf_hdr savehdr; 1955 struct xfs_attr3_icleaf_hdr savehdr;
1966 struct xfs_attr_leaf_entry *entry; 1956 struct xfs_attr_leaf_entry *entry;
1967 struct xfs_mount *mp = state->mp;
1968 1957
1969 trace_xfs_attr_leaf_unbalance(state->args); 1958 trace_xfs_attr_leaf_unbalance(state->args);
1970 1959
@@ -1991,13 +1980,15 @@ xfs_attr3_leaf_unbalance(
1991 */ 1980 */
1992 if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, 1981 if (xfs_attr3_leaf_order(save_blk->bp, &savehdr,
1993 drop_blk->bp, &drophdr)) { 1982 drop_blk->bp, &drophdr)) {
1994 xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, 1983 xfs_attr3_leaf_moveents(state->args,
1984 drop_leaf, &drophdr, 0,
1995 save_leaf, &savehdr, 0, 1985 save_leaf, &savehdr, 0,
1996 drophdr.count, mp); 1986 drophdr.count);
1997 } else { 1987 } else {
1998 xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, 1988 xfs_attr3_leaf_moveents(state->args,
1989 drop_leaf, &drophdr, 0,
1999 save_leaf, &savehdr, 1990 save_leaf, &savehdr,
2000 savehdr.count, drophdr.count, mp); 1991 savehdr.count, drophdr.count);
2001 } 1992 }
2002 } else { 1993 } else {
2003 /* 1994 /*
@@ -2007,7 +1998,7 @@ xfs_attr3_leaf_unbalance(
2007 struct xfs_attr_leafblock *tmp_leaf; 1998 struct xfs_attr_leafblock *tmp_leaf;
2008 struct xfs_attr3_icleaf_hdr tmphdr; 1999 struct xfs_attr3_icleaf_hdr tmphdr;
2009 2000
2010 tmp_leaf = kmem_zalloc(state->blocksize, KM_SLEEP); 2001 tmp_leaf = kmem_zalloc(state->args->geo->blksize, KM_SLEEP);
2011 2002
2012 /* 2003 /*
2013 * Copy the header into the temp leaf so that all the stuff 2004 * Copy the header into the temp leaf so that all the stuff
@@ -2020,35 +2011,39 @@ xfs_attr3_leaf_unbalance(
2020 tmphdr.magic = savehdr.magic; 2011 tmphdr.magic = savehdr.magic;
2021 tmphdr.forw = savehdr.forw; 2012 tmphdr.forw = savehdr.forw;
2022 tmphdr.back = savehdr.back; 2013 tmphdr.back = savehdr.back;
2023 tmphdr.firstused = state->blocksize; 2014 tmphdr.firstused = state->args->geo->blksize;
2024 2015
2025 /* write the header to the temp buffer to initialise it */ 2016 /* write the header to the temp buffer to initialise it */
2026 xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr); 2017 xfs_attr3_leaf_hdr_to_disk(tmp_leaf, &tmphdr);
2027 2018
2028 if (xfs_attr3_leaf_order(save_blk->bp, &savehdr, 2019 if (xfs_attr3_leaf_order(save_blk->bp, &savehdr,
2029 drop_blk->bp, &drophdr)) { 2020 drop_blk->bp, &drophdr)) {
2030 xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, 2021 xfs_attr3_leaf_moveents(state->args,
2022 drop_leaf, &drophdr, 0,
2031 tmp_leaf, &tmphdr, 0, 2023 tmp_leaf, &tmphdr, 0,
2032 drophdr.count, mp); 2024 drophdr.count);
2033 xfs_attr3_leaf_moveents(save_leaf, &savehdr, 0, 2025 xfs_attr3_leaf_moveents(state->args,
2026 save_leaf, &savehdr, 0,
2034 tmp_leaf, &tmphdr, tmphdr.count, 2027 tmp_leaf, &tmphdr, tmphdr.count,
2035 savehdr.count, mp); 2028 savehdr.count);
2036 } else { 2029 } else {
2037 xfs_attr3_leaf_moveents(save_leaf, &savehdr, 0, 2030 xfs_attr3_leaf_moveents(state->args,
2031 save_leaf, &savehdr, 0,
2038 tmp_leaf, &tmphdr, 0, 2032 tmp_leaf, &tmphdr, 0,
2039 savehdr.count, mp); 2033 savehdr.count);
2040 xfs_attr3_leaf_moveents(drop_leaf, &drophdr, 0, 2034 xfs_attr3_leaf_moveents(state->args,
2035 drop_leaf, &drophdr, 0,
2041 tmp_leaf, &tmphdr, tmphdr.count, 2036 tmp_leaf, &tmphdr, tmphdr.count,
2042 drophdr.count, mp); 2037 drophdr.count);
2043 } 2038 }
2044 memcpy(save_leaf, tmp_leaf, state->blocksize); 2039 memcpy(save_leaf, tmp_leaf, state->args->geo->blksize);
2045 savehdr = tmphdr; /* struct copy */ 2040 savehdr = tmphdr; /* struct copy */
2046 kmem_free(tmp_leaf); 2041 kmem_free(tmp_leaf);
2047 } 2042 }
2048 2043
2049 xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr); 2044 xfs_attr3_leaf_hdr_to_disk(save_leaf, &savehdr);
2050 xfs_trans_log_buf(state->args->trans, save_blk->bp, 0, 2045 xfs_trans_log_buf(state->args->trans, save_blk->bp, 0,
2051 state->blocksize - 1); 2046 state->args->geo->blksize - 1);
2052 2047
2053 /* 2048 /*
2054 * Copy out last hashval in each block for B-tree code. 2049 * Copy out last hashval in each block for B-tree code.
@@ -2094,7 +2089,7 @@ xfs_attr3_leaf_lookup_int(
2094 leaf = bp->b_addr; 2089 leaf = bp->b_addr;
2095 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); 2090 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
2096 entries = xfs_attr3_leaf_entryp(leaf); 2091 entries = xfs_attr3_leaf_entryp(leaf);
2097 ASSERT(ichdr.count < XFS_LBSIZE(args->dp->i_mount) / 8); 2092 ASSERT(ichdr.count < args->geo->blksize / 8);
2098 2093
2099 /* 2094 /*
2100 * Binary search. (note: small blocks will skip this loop) 2095 * Binary search. (note: small blocks will skip this loop)
@@ -2198,7 +2193,7 @@ xfs_attr3_leaf_getvalue(
2198 2193
2199 leaf = bp->b_addr; 2194 leaf = bp->b_addr;
2200 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf); 2195 xfs_attr3_leaf_hdr_from_disk(&ichdr, leaf);
2201 ASSERT(ichdr.count < XFS_LBSIZE(args->dp->i_mount) / 8); 2196 ASSERT(ichdr.count < args->geo->blksize / 8);
2202 ASSERT(args->index < ichdr.count); 2197 ASSERT(args->index < ichdr.count);
2203 2198
2204 entry = &xfs_attr3_leaf_entryp(leaf)[args->index]; 2199 entry = &xfs_attr3_leaf_entryp(leaf)[args->index];
@@ -2249,14 +2244,14 @@ xfs_attr3_leaf_getvalue(
2249/*ARGSUSED*/ 2244/*ARGSUSED*/
2250STATIC void 2245STATIC void
2251xfs_attr3_leaf_moveents( 2246xfs_attr3_leaf_moveents(
2247 struct xfs_da_args *args,
2252 struct xfs_attr_leafblock *leaf_s, 2248 struct xfs_attr_leafblock *leaf_s,
2253 struct xfs_attr3_icleaf_hdr *ichdr_s, 2249 struct xfs_attr3_icleaf_hdr *ichdr_s,
2254 int start_s, 2250 int start_s,
2255 struct xfs_attr_leafblock *leaf_d, 2251 struct xfs_attr_leafblock *leaf_d,
2256 struct xfs_attr3_icleaf_hdr *ichdr_d, 2252 struct xfs_attr3_icleaf_hdr *ichdr_d,
2257 int start_d, 2253 int start_d,
2258 int count, 2254 int count)
2259 struct xfs_mount *mp)
2260{ 2255{
2261 struct xfs_attr_leaf_entry *entry_s; 2256 struct xfs_attr_leaf_entry *entry_s;
2262 struct xfs_attr_leaf_entry *entry_d; 2257 struct xfs_attr_leaf_entry *entry_d;
@@ -2276,10 +2271,10 @@ xfs_attr3_leaf_moveents(
2276 ASSERT(ichdr_s->magic == XFS_ATTR_LEAF_MAGIC || 2271 ASSERT(ichdr_s->magic == XFS_ATTR_LEAF_MAGIC ||
2277 ichdr_s->magic == XFS_ATTR3_LEAF_MAGIC); 2272 ichdr_s->magic == XFS_ATTR3_LEAF_MAGIC);
2278 ASSERT(ichdr_s->magic == ichdr_d->magic); 2273 ASSERT(ichdr_s->magic == ichdr_d->magic);
2279 ASSERT(ichdr_s->count > 0 && ichdr_s->count < XFS_LBSIZE(mp) / 8); 2274 ASSERT(ichdr_s->count > 0 && ichdr_s->count < args->geo->blksize / 8);
2280 ASSERT(ichdr_s->firstused >= (ichdr_s->count * sizeof(*entry_s)) 2275 ASSERT(ichdr_s->firstused >= (ichdr_s->count * sizeof(*entry_s))
2281 + xfs_attr3_leaf_hdr_size(leaf_s)); 2276 + xfs_attr3_leaf_hdr_size(leaf_s));
2282 ASSERT(ichdr_d->count < XFS_LBSIZE(mp) / 8); 2277 ASSERT(ichdr_d->count < args->geo->blksize / 8);
2283 ASSERT(ichdr_d->firstused >= (ichdr_d->count * sizeof(*entry_d)) 2278 ASSERT(ichdr_d->firstused >= (ichdr_d->count * sizeof(*entry_d))
2284 + xfs_attr3_leaf_hdr_size(leaf_d)); 2279 + xfs_attr3_leaf_hdr_size(leaf_d));
2285 2280
@@ -2331,11 +2326,11 @@ xfs_attr3_leaf_moveents(
2331 entry_d->nameidx = cpu_to_be16(ichdr_d->firstused); 2326 entry_d->nameidx = cpu_to_be16(ichdr_d->firstused);
2332 entry_d->flags = entry_s->flags; 2327 entry_d->flags = entry_s->flags;
2333 ASSERT(be16_to_cpu(entry_d->nameidx) + tmp 2328 ASSERT(be16_to_cpu(entry_d->nameidx) + tmp
2334 <= XFS_LBSIZE(mp)); 2329 <= args->geo->blksize);
2335 memmove(xfs_attr3_leaf_name(leaf_d, desti), 2330 memmove(xfs_attr3_leaf_name(leaf_d, desti),
2336 xfs_attr3_leaf_name(leaf_s, start_s + i), tmp); 2331 xfs_attr3_leaf_name(leaf_s, start_s + i), tmp);
2337 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp 2332 ASSERT(be16_to_cpu(entry_s->nameidx) + tmp
2338 <= XFS_LBSIZE(mp)); 2333 <= args->geo->blksize);
2339 memset(xfs_attr3_leaf_name(leaf_s, start_s + i), 0, tmp); 2334 memset(xfs_attr3_leaf_name(leaf_s, start_s + i), 0, tmp);
2340 ichdr_s->usedbytes -= tmp; 2335 ichdr_s->usedbytes -= tmp;
2341 ichdr_d->usedbytes += tmp; 2336 ichdr_d->usedbytes += tmp;
@@ -2356,7 +2351,7 @@ xfs_attr3_leaf_moveents(
2356 tmp = count * sizeof(xfs_attr_leaf_entry_t); 2351 tmp = count * sizeof(xfs_attr_leaf_entry_t);
2357 entry_s = &xfs_attr3_leaf_entryp(leaf_s)[start_s]; 2352 entry_s = &xfs_attr3_leaf_entryp(leaf_s)[start_s];
2358 ASSERT(((char *)entry_s + tmp) <= 2353 ASSERT(((char *)entry_s + tmp) <=
2359 ((char *)leaf_s + XFS_LBSIZE(mp))); 2354 ((char *)leaf_s + args->geo->blksize));
2360 memset(entry_s, 0, tmp); 2355 memset(entry_s, 0, tmp);
2361 } else { 2356 } else {
2362 /* 2357 /*
@@ -2371,7 +2366,7 @@ xfs_attr3_leaf_moveents(
2371 tmp = count * sizeof(xfs_attr_leaf_entry_t); 2366 tmp = count * sizeof(xfs_attr_leaf_entry_t);
2372 entry_s = &xfs_attr3_leaf_entryp(leaf_s)[ichdr_s->count]; 2367 entry_s = &xfs_attr3_leaf_entryp(leaf_s)[ichdr_s->count];
2373 ASSERT(((char *)entry_s + tmp) <= 2368 ASSERT(((char *)entry_s + tmp) <=
2374 ((char *)leaf_s + XFS_LBSIZE(mp))); 2369 ((char *)leaf_s + args->geo->blksize));
2375 memset(entry_s, 0, tmp); 2370 memset(entry_s, 0, tmp);
2376 } 2371 }
2377 2372
@@ -2439,22 +2434,21 @@ xfs_attr_leaf_entsize(xfs_attr_leafblock_t *leaf, int index)
2439 * a "local" or a "remote" attribute. 2434 * a "local" or a "remote" attribute.
2440 */ 2435 */
2441int 2436int
2442xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, int *local) 2437xfs_attr_leaf_newentsize(
2438 struct xfs_da_args *args,
2439 int *local)
2443{ 2440{
2444 int size; 2441 int size;
2445 2442
2446 size = xfs_attr_leaf_entsize_local(namelen, valuelen); 2443 size = xfs_attr_leaf_entsize_local(args->namelen, args->valuelen);
2447 if (size < xfs_attr_leaf_entsize_local_max(blocksize)) { 2444 if (size < xfs_attr_leaf_entsize_local_max(args->geo->blksize)) {
2448 if (local) { 2445 if (local)
2449 *local = 1; 2446 *local = 1;
2450 } 2447 return size;
2451 } else {
2452 size = xfs_attr_leaf_entsize_remote(namelen);
2453 if (local) {
2454 *local = 0;
2455 }
2456 } 2448 }
2457 return size; 2449 if (local)
2450 *local = 0;
2451 return xfs_attr_leaf_entsize_remote(args->namelen);
2458} 2452}
2459 2453
2460 2454
diff --git a/fs/xfs/xfs_attr_leaf.h b/fs/xfs/xfs_attr_leaf.h
index 3ec5ec0b8678..e2929da7c3ba 100644
--- a/fs/xfs/xfs_attr_leaf.h
+++ b/fs/xfs/xfs_attr_leaf.h
@@ -96,8 +96,7 @@ int xfs_attr3_root_inactive(struct xfs_trans **trans, struct xfs_inode *dp);
96xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count); 96xfs_dahash_t xfs_attr_leaf_lasthash(struct xfs_buf *bp, int *count);
97int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp, 97int xfs_attr_leaf_order(struct xfs_buf *leaf1_bp,
98 struct xfs_buf *leaf2_bp); 98 struct xfs_buf *leaf2_bp);
99int xfs_attr_leaf_newentsize(int namelen, int valuelen, int blocksize, 99int xfs_attr_leaf_newentsize(struct xfs_da_args *args, int *local);
100 int *local);
101int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp, 100int xfs_attr3_leaf_read(struct xfs_trans *tp, struct xfs_inode *dp,
102 xfs_dablk_t bno, xfs_daddr_t mappedbno, 101 xfs_dablk_t bno, xfs_daddr_t mappedbno,
103 struct xfs_buf **bpp); 102 struct xfs_buf **bpp);
diff --git a/fs/xfs/xfs_attr_list.c b/fs/xfs/xfs_attr_list.c
index 833fe5d98d80..90e2eeb21207 100644
--- a/fs/xfs/xfs_attr_list.c
+++ b/fs/xfs/xfs_attr_list.c
@@ -444,6 +444,7 @@ xfs_attr3_leaf_list_int(
444 xfs_da_args_t args; 444 xfs_da_args_t args;
445 445
446 memset((char *)&args, 0, sizeof(args)); 446 memset((char *)&args, 0, sizeof(args));
447 args.geo = context->dp->i_mount->m_attr_geo;
447 args.dp = context->dp; 448 args.dp = context->dp;
448 args.whichfork = XFS_ATTR_FORK; 449 args.whichfork = XFS_ATTR_FORK;
449 args.valuelen = valuelen; 450 args.valuelen = valuelen;
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_bmap.c b/fs/xfs/xfs_bmap.c
index 1ff0da6e2bf9..96175df211b1 100644
--- a/fs/xfs/xfs_bmap.c
+++ b/fs/xfs/xfs_bmap.c
@@ -1098,10 +1098,11 @@ xfs_bmap_add_attrfork_local(
1098 1098
1099 if (S_ISDIR(ip->i_d.di_mode)) { 1099 if (S_ISDIR(ip->i_d.di_mode)) {
1100 memset(&dargs, 0, sizeof(dargs)); 1100 memset(&dargs, 0, sizeof(dargs));
1101 dargs.geo = ip->i_mount->m_dir_geo;
1101 dargs.dp = ip; 1102 dargs.dp = ip;
1102 dargs.firstblock = firstblock; 1103 dargs.firstblock = firstblock;
1103 dargs.flist = flist; 1104 dargs.flist = flist;
1104 dargs.total = ip->i_mount->m_dirblkfsbs; 1105 dargs.total = dargs.geo->fsbcount;
1105 dargs.whichfork = XFS_DATA_FORK; 1106 dargs.whichfork = XFS_DATA_FORK;
1106 dargs.trans = tp; 1107 dargs.trans = tp;
1107 return xfs_dir2_sf_to_block(&dargs); 1108 return xfs_dir2_sf_to_block(&dargs);
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 4db5102d403a..a514ab616650 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -167,8 +167,8 @@ xfs_da3_node_verify(
167 * we don't know if the node is for and attribute or directory tree, 167 * we don't know if the node is for and attribute or directory tree,
168 * so only fail if the count is outside both bounds 168 * so only fail if the count is outside both bounds
169 */ 169 */
170 if (ichdr.count > mp->m_dir_node_ents && 170 if (ichdr.count > mp->m_dir_geo->node_ents &&
171 ichdr.count > mp->m_attr_node_ents) 171 ichdr.count > mp->m_attr_geo->node_ents)
172 return false; 172 return false;
173 173
174 /* XXX: hash order check? */ 174 /* XXX: hash order check? */
@@ -598,7 +598,7 @@ xfs_da3_root_split(
598 * Set up the new root node. 598 * Set up the new root node.
599 */ 599 */
600 error = xfs_da3_node_create(args, 600 error = xfs_da3_node_create(args,
601 (args->whichfork == XFS_DATA_FORK) ? mp->m_dirleafblk : 0, 601 (args->whichfork == XFS_DATA_FORK) ? args->geo->leafblk : 0,
602 level + 1, &bp, args->whichfork); 602 level + 1, &bp, args->whichfork);
603 if (error) 603 if (error)
604 return error; 604 return error;
@@ -616,10 +616,10 @@ xfs_da3_root_split(
616#ifdef DEBUG 616#ifdef DEBUG
617 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 617 if (oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
618 oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) { 618 oldroot->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)) {
619 ASSERT(blk1->blkno >= mp->m_dirleafblk && 619 ASSERT(blk1->blkno >= args->geo->leafblk &&
620 blk1->blkno < mp->m_dirfreeblk); 620 blk1->blkno < args->geo->freeblk);
621 ASSERT(blk2->blkno >= mp->m_dirleafblk && 621 ASSERT(blk2->blkno >= args->geo->leafblk &&
622 blk2->blkno < mp->m_dirfreeblk); 622 blk2->blkno < args->geo->freeblk);
623 } 623 }
624#endif 624#endif
625 625
@@ -663,7 +663,7 @@ xfs_da3_node_split(
663 /* 663 /*
664 * Do we have to split the node? 664 * Do we have to split the node?
665 */ 665 */
666 if (nodehdr.count + newcount > state->node_ents) { 666 if (nodehdr.count + newcount > state->args->geo->node_ents) {
667 /* 667 /*
668 * Allocate a new node, add to the doubly linked chain of 668 * Allocate a new node, add to the doubly linked chain of
669 * nodes, then move some of our excess entries into it. 669 * nodes, then move some of our excess entries into it.
@@ -894,8 +894,8 @@ xfs_da3_node_add(
894 ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count); 894 ASSERT(oldblk->index >= 0 && oldblk->index <= nodehdr.count);
895 ASSERT(newblk->blkno != 0); 895 ASSERT(newblk->blkno != 0);
896 if (state->args->whichfork == XFS_DATA_FORK) 896 if (state->args->whichfork == XFS_DATA_FORK)
897 ASSERT(newblk->blkno >= state->mp->m_dirleafblk && 897 ASSERT(newblk->blkno >= state->args->geo->leafblk &&
898 newblk->blkno < state->mp->m_dirfreeblk); 898 newblk->blkno < state->args->geo->freeblk);
899 899
900 /* 900 /*
901 * We may need to make some room before we insert the new node. 901 * We may need to make some room before we insert the new node.
@@ -1089,14 +1089,15 @@ xfs_da3_root_join(
1089 * that could occur. For dir3 blocks we also need to update the block 1089 * that could occur. For dir3 blocks we also need to update the block
1090 * number in the buffer header. 1090 * number in the buffer header.
1091 */ 1091 */
1092 memcpy(root_blk->bp->b_addr, bp->b_addr, state->blocksize); 1092 memcpy(root_blk->bp->b_addr, bp->b_addr, args->geo->blksize);
1093 root_blk->bp->b_ops = bp->b_ops; 1093 root_blk->bp->b_ops = bp->b_ops;
1094 xfs_trans_buf_copy_type(root_blk->bp, bp); 1094 xfs_trans_buf_copy_type(root_blk->bp, bp);
1095 if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) { 1095 if (oldroothdr.magic == XFS_DA3_NODE_MAGIC) {
1096 struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr; 1096 struct xfs_da3_blkinfo *da3 = root_blk->bp->b_addr;
1097 da3->blkno = cpu_to_be64(root_blk->bp->b_bn); 1097 da3->blkno = cpu_to_be64(root_blk->bp->b_bn);
1098 } 1098 }
1099 xfs_trans_log_buf(args->trans, root_blk->bp, 0, state->blocksize - 1); 1099 xfs_trans_log_buf(args->trans, root_blk->bp, 0,
1100 args->geo->blksize - 1);
1100 error = xfs_da_shrink_inode(args, child, bp); 1101 error = xfs_da_shrink_inode(args, child, bp);
1101 return(error); 1102 return(error);
1102} 1103}
@@ -1139,7 +1140,7 @@ xfs_da3_node_toosmall(
1139 info = blk->bp->b_addr; 1140 info = blk->bp->b_addr;
1140 node = (xfs_da_intnode_t *)info; 1141 node = (xfs_da_intnode_t *)info;
1141 dp->d_ops->node_hdr_from_disk(&nodehdr, node); 1142 dp->d_ops->node_hdr_from_disk(&nodehdr, node);
1142 if (nodehdr.count > (state->node_ents >> 1)) { 1143 if (nodehdr.count > (state->args->geo->node_ents >> 1)) {
1143 *action = 0; /* blk over 50%, don't try to join */ 1144 *action = 0; /* blk over 50%, don't try to join */
1144 return(0); /* blk over 50%, don't try to join */ 1145 return(0); /* blk over 50%, don't try to join */
1145 } 1146 }
@@ -1176,8 +1177,8 @@ xfs_da3_node_toosmall(
1176 * We prefer coalescing with the lower numbered sibling so as 1177 * We prefer coalescing with the lower numbered sibling so as
1177 * to shrink a directory over time. 1178 * to shrink a directory over time.
1178 */ 1179 */
1179 count = state->node_ents; 1180 count = state->args->geo->node_ents;
1180 count -= state->node_ents >> 2; 1181 count -= state->args->geo->node_ents >> 2;
1181 count -= nodehdr.count; 1182 count -= nodehdr.count;
1182 1183
1183 /* start with smaller blk num */ 1184 /* start with smaller blk num */
@@ -1472,7 +1473,7 @@ xfs_da3_node_lookup_int(
1472 * Descend thru the B-tree searching each level for the right 1473 * Descend thru the B-tree searching each level for the right
1473 * node to use, until the right hashval is found. 1474 * node to use, until the right hashval is found.
1474 */ 1475 */
1475 blkno = (args->whichfork == XFS_DATA_FORK)? state->mp->m_dirleafblk : 0; 1476 blkno = (args->whichfork == XFS_DATA_FORK)? args->geo->leafblk : 0;
1476 for (blk = &state->path.blk[0], state->path.active = 1; 1477 for (blk = &state->path.blk[0], state->path.active = 1;
1477 state->path.active <= XFS_DA_NODE_MAXDEPTH; 1478 state->path.active <= XFS_DA_NODE_MAXDEPTH;
1478 blk++, state->path.active++) { 1479 blk++, state->path.active++) {
@@ -2090,20 +2091,12 @@ xfs_da_grow_inode(
2090 xfs_dablk_t *new_blkno) 2091 xfs_dablk_t *new_blkno)
2091{ 2092{
2092 xfs_fileoff_t bno; 2093 xfs_fileoff_t bno;
2093 int count;
2094 int error; 2094 int error;
2095 2095
2096 trace_xfs_da_grow_inode(args); 2096 trace_xfs_da_grow_inode(args);
2097 2097
2098 if (args->whichfork == XFS_DATA_FORK) { 2098 bno = args->geo->leafblk;
2099 bno = args->dp->i_mount->m_dirleafblk; 2099 error = xfs_da_grow_inode_int(args, &bno, args->geo->fsbcount);
2100 count = args->dp->i_mount->m_dirblkfsbs;
2101 } else {
2102 bno = 0;
2103 count = 1;
2104 }
2105
2106 error = xfs_da_grow_inode_int(args, &bno, count);
2107 if (!error) 2100 if (!error)
2108 *new_blkno = (xfs_dablk_t)bno; 2101 *new_blkno = (xfs_dablk_t)bno;
2109 return error; 2102 return error;
@@ -2158,7 +2151,7 @@ xfs_da3_swap_lastblock(
2158 w = args->whichfork; 2151 w = args->whichfork;
2159 ASSERT(w == XFS_DATA_FORK); 2152 ASSERT(w == XFS_DATA_FORK);
2160 mp = dp->i_mount; 2153 mp = dp->i_mount;
2161 lastoff = mp->m_dirfreeblk; 2154 lastoff = args->geo->freeblk;
2162 error = xfs_bmap_last_before(tp, dp, &lastoff, w); 2155 error = xfs_bmap_last_before(tp, dp, &lastoff, w);
2163 if (error) 2156 if (error)
2164 return error; 2157 return error;
@@ -2170,15 +2163,15 @@ xfs_da3_swap_lastblock(
2170 /* 2163 /*
2171 * Read the last block in the btree space. 2164 * Read the last block in the btree space.
2172 */ 2165 */
2173 last_blkno = (xfs_dablk_t)lastoff - mp->m_dirblkfsbs; 2166 last_blkno = (xfs_dablk_t)lastoff - args->geo->fsbcount;
2174 error = xfs_da3_node_read(tp, dp, last_blkno, -1, &last_buf, w); 2167 error = xfs_da3_node_read(tp, dp, last_blkno, -1, &last_buf, w);
2175 if (error) 2168 if (error)
2176 return error; 2169 return error;
2177 /* 2170 /*
2178 * Copy the last block into the dead buffer and log it. 2171 * Copy the last block into the dead buffer and log it.
2179 */ 2172 */
2180 memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize); 2173 memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize);
2181 xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1); 2174 xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1);
2182 dead_info = dead_buf->b_addr; 2175 dead_info = dead_buf->b_addr;
2183 /* 2176 /*
2184 * Get values from the moved block. 2177 * Get values from the moved block.
@@ -2247,7 +2240,7 @@ xfs_da3_swap_lastblock(
2247 sizeof(sib_info->back))); 2240 sizeof(sib_info->back)));
2248 sib_buf = NULL; 2241 sib_buf = NULL;
2249 } 2242 }
2250 par_blkno = mp->m_dirleafblk; 2243 par_blkno = args->geo->leafblk;
2251 level = -1; 2244 level = -1;
2252 /* 2245 /*
2253 * Walk down the tree looking for the parent of the moved block. 2246 * Walk down the tree looking for the parent of the moved block.
@@ -2357,10 +2350,7 @@ xfs_da_shrink_inode(
2357 w = args->whichfork; 2350 w = args->whichfork;
2358 tp = args->trans; 2351 tp = args->trans;
2359 mp = dp->i_mount; 2352 mp = dp->i_mount;
2360 if (w == XFS_DATA_FORK) 2353 count = args->geo->fsbcount;
2361 count = mp->m_dirblkfsbs;
2362 else
2363 count = 1;
2364 for (;;) { 2354 for (;;) {
2365 /* 2355 /*
2366 * Remove extents. If we get ENOSPC for a dir we have to move 2356 * Remove extents. If we get ENOSPC for a dir we have to move
@@ -2479,7 +2469,10 @@ xfs_dabuf_map(
2479 ASSERT(map && *map); 2469 ASSERT(map && *map);
2480 ASSERT(*nmaps == 1); 2470 ASSERT(*nmaps == 1);
2481 2471
2482 nfsb = (whichfork == XFS_DATA_FORK) ? mp->m_dirblkfsbs : 1; 2472 if (whichfork == XFS_DATA_FORK)
2473 nfsb = mp->m_dir_geo->fsbcount;
2474 else
2475 nfsb = mp->m_attr_geo->fsbcount;
2483 2476
2484 /* 2477 /*
2485 * Caller doesn't have a mapping. -2 means don't complain 2478 * Caller doesn't have a mapping. -2 means don't complain
diff --git a/fs/xfs/xfs_da_btree.h b/fs/xfs/xfs_da_btree.h
index c824a0aa039f..6e153e399a77 100644
--- a/fs/xfs/xfs_da_btree.h
+++ b/fs/xfs/xfs_da_btree.h
@@ -25,6 +25,23 @@ struct xfs_trans;
25struct zone; 25struct zone;
26struct xfs_dir_ops; 26struct xfs_dir_ops;
27 27
28/*
29 * Directory/attribute geometry information. There will be one of these for each
30 * data fork type, and it will be passed around via the xfs_da_args. Global
31 * structures will be attached to the xfs_mount.
32 */
33struct xfs_da_geometry {
34 int blksize; /* da block size in bytes */
35 int fsbcount; /* da block size in filesystem blocks */
36 uint8_t fsblog; /* log2 of _filesystem_ block size */
37 uint8_t blklog; /* log2 of da block size */
38 uint node_ents; /* # of entries in a danode */
39 int magicpct; /* 37% of block size in bytes */
40 xfs_dablk_t datablk; /* blockno of dir data v2 */
41 xfs_dablk_t leafblk; /* blockno of leaf data v2 */
42 xfs_dablk_t freeblk; /* blockno of free data v2 */
43};
44
28/*======================================================================== 45/*========================================================================
29 * Btree searching and modification structure definitions. 46 * Btree searching and modification structure definitions.
30 *========================================================================*/ 47 *========================================================================*/
@@ -42,6 +59,7 @@ enum xfs_dacmp {
42 * Structure to ease passing around component names. 59 * Structure to ease passing around component names.
43 */ 60 */
44typedef struct xfs_da_args { 61typedef struct xfs_da_args {
62 struct xfs_da_geometry *geo; /* da block geometry */
45 const __uint8_t *name; /* string (maybe not NULL terminated) */ 63 const __uint8_t *name; /* string (maybe not NULL terminated) */
46 int namelen; /* length of string (maybe no NULL) */ 64 int namelen; /* length of string (maybe no NULL) */
47 __uint8_t filetype; /* filetype of inode for directories */ 65 __uint8_t filetype; /* filetype of inode for directories */
@@ -110,8 +128,6 @@ typedef struct xfs_da_state_path {
110typedef struct xfs_da_state { 128typedef struct xfs_da_state {
111 xfs_da_args_t *args; /* filename arguments */ 129 xfs_da_args_t *args; /* filename arguments */
112 struct xfs_mount *mp; /* filesystem mount point */ 130 struct xfs_mount *mp; /* filesystem mount point */
113 unsigned int blocksize; /* logical block size */
114 unsigned int node_ents; /* how many entries in danode */
115 xfs_da_state_path_t path; /* search/split paths */ 131 xfs_da_state_path_t path; /* search/split paths */
116 xfs_da_state_path_t altpath; /* alternate path for join */ 132 xfs_da_state_path_t altpath; /* alternate path for join */
117 unsigned char inleaf; /* insert into 1->lf, 0->splf */ 133 unsigned char inleaf; /* insert into 1->lf, 0->splf */
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c
index e6c83e1fbc8a..c9aee52a37e2 100644
--- a/fs/xfs/xfs_da_format.c
+++ b/fs/xfs/xfs_da_format.c
@@ -26,8 +26,10 @@
26#include "xfs_ag.h" 26#include "xfs_ag.h"
27#include "xfs_mount.h" 27#include "xfs_mount.h"
28#include "xfs_da_format.h" 28#include "xfs_da_format.h"
29#include "xfs_da_btree.h"
29#include "xfs_inode.h" 30#include "xfs_inode.h"
30#include "xfs_dir2.h" 31#include "xfs_dir2.h"
32#include "xfs_dir2_priv.h"
31 33
32/* 34/*
33 * Shortform directory ops 35 * Shortform directory ops
@@ -425,9 +427,9 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
425 * Directory Leaf block operations 427 * Directory Leaf block operations
426 */ 428 */
427static int 429static int
428xfs_dir2_max_leaf_ents(struct xfs_mount *mp) 430xfs_dir2_max_leaf_ents(struct xfs_da_geometry *geo)
429{ 431{
430 return (mp->m_dirblksize - sizeof(struct xfs_dir2_leaf_hdr)) / 432 return (geo->blksize - sizeof(struct xfs_dir2_leaf_hdr)) /
431 (uint)sizeof(struct xfs_dir2_leaf_entry); 433 (uint)sizeof(struct xfs_dir2_leaf_entry);
432} 434}
433 435
@@ -438,9 +440,9 @@ xfs_dir2_leaf_ents_p(struct xfs_dir2_leaf *lp)
438} 440}
439 441
440static int 442static int
441xfs_dir3_max_leaf_ents(struct xfs_mount *mp) 443xfs_dir3_max_leaf_ents(struct xfs_da_geometry *geo)
442{ 444{
443 return (mp->m_dirblksize - sizeof(struct xfs_dir3_leaf_hdr)) / 445 return (geo->blksize - sizeof(struct xfs_dir3_leaf_hdr)) /
444 (uint)sizeof(struct xfs_dir2_leaf_entry); 446 (uint)sizeof(struct xfs_dir2_leaf_entry);
445} 447}
446 448
@@ -591,9 +593,9 @@ xfs_da3_node_hdr_to_disk(
591 * Directory free space block operations 593 * Directory free space block operations
592 */ 594 */
593static int 595static int
594xfs_dir2_free_max_bests(struct xfs_mount *mp) 596xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)
595{ 597{
596 return (mp->m_dirblksize - sizeof(struct xfs_dir2_free_hdr)) / 598 return (geo->blksize - sizeof(struct xfs_dir2_free_hdr)) /
597 sizeof(xfs_dir2_data_off_t); 599 sizeof(xfs_dir2_data_off_t);
598} 600}
599 601
@@ -607,24 +609,25 @@ xfs_dir2_free_bests_p(struct xfs_dir2_free *free)
607 * Convert data space db to the corresponding free db. 609 * Convert data space db to the corresponding free db.
608 */ 610 */
609static xfs_dir2_db_t 611static xfs_dir2_db_t
610xfs_dir2_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) 612xfs_dir2_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
611{ 613{
612 return XFS_DIR2_FREE_FIRSTDB(mp) + db / xfs_dir2_free_max_bests(mp); 614 return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
615 (db / xfs_dir2_free_max_bests(geo));
613} 616}
614 617
615/* 618/*
616 * Convert data space db to the corresponding index in a free db. 619 * Convert data space db to the corresponding index in a free db.
617 */ 620 */
618static int 621static int
619xfs_dir2_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db) 622xfs_dir2_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
620{ 623{
621 return db % xfs_dir2_free_max_bests(mp); 624 return db % xfs_dir2_free_max_bests(geo);
622} 625}
623 626
624static int 627static int
625xfs_dir3_free_max_bests(struct xfs_mount *mp) 628xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)
626{ 629{
627 return (mp->m_dirblksize - sizeof(struct xfs_dir3_free_hdr)) / 630 return (geo->blksize - sizeof(struct xfs_dir3_free_hdr)) /
628 sizeof(xfs_dir2_data_off_t); 631 sizeof(xfs_dir2_data_off_t);
629} 632}
630 633
@@ -638,18 +641,19 @@ xfs_dir3_free_bests_p(struct xfs_dir2_free *free)
638 * Convert data space db to the corresponding free db. 641 * Convert data space db to the corresponding free db.
639 */ 642 */
640static xfs_dir2_db_t 643static xfs_dir2_db_t
641xfs_dir3_db_to_fdb(struct xfs_mount *mp, xfs_dir2_db_t db) 644xfs_dir3_db_to_fdb(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
642{ 645{
643 return XFS_DIR2_FREE_FIRSTDB(mp) + db / xfs_dir3_free_max_bests(mp); 646 return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
647 (db / xfs_dir3_free_max_bests(geo));
644} 648}
645 649
646/* 650/*
647 * Convert data space db to the corresponding index in a free db. 651 * Convert data space db to the corresponding index in a free db.
648 */ 652 */
649static int 653static int
650xfs_dir3_db_to_fdindex(struct xfs_mount *mp, xfs_dir2_db_t db) 654xfs_dir3_db_to_fdindex(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
651{ 655{
652 return db % xfs_dir3_free_max_bests(mp); 656 return db % xfs_dir3_free_max_bests(geo);
653} 657}
654 658
655static void 659static void
diff --git a/fs/xfs/xfs_da_format.h b/fs/xfs/xfs_da_format.h
index 1432b576b4a7..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 *
@@ -330,8 +324,6 @@ xfs_dir2_sf_firstentry(struct xfs_dir2_sf_hdr *hdr)
330#define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG)) 324#define XFS_DIR2_SPACE_SIZE (1ULL << (32 + XFS_DIR2_DATA_ALIGN_LOG))
331#define XFS_DIR2_DATA_SPACE 0 325#define XFS_DIR2_DATA_SPACE 0
332#define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE) 326#define XFS_DIR2_DATA_OFFSET (XFS_DIR2_DATA_SPACE * XFS_DIR2_SPACE_SIZE)
333#define XFS_DIR2_DATA_FIRSTDB(mp) \
334 xfs_dir2_byte_to_db(mp, XFS_DIR2_DATA_OFFSET)
335 327
336/* 328/*
337 * Describe a free area in the data block. 329 * Describe a free area in the data block.
@@ -456,8 +448,6 @@ xfs_dir2_data_unused_tag_p(struct xfs_dir2_data_unused *dup)
456 */ 448 */
457#define XFS_DIR2_LEAF_SPACE 1 449#define XFS_DIR2_LEAF_SPACE 1
458#define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE) 450#define XFS_DIR2_LEAF_OFFSET (XFS_DIR2_LEAF_SPACE * XFS_DIR2_SPACE_SIZE)
459#define XFS_DIR2_LEAF_FIRSTDB(mp) \
460 xfs_dir2_byte_to_db(mp, XFS_DIR2_LEAF_OFFSET)
461 451
462/* 452/*
463 * Leaf block header. 453 * Leaf block header.
@@ -514,17 +504,6 @@ struct xfs_dir3_leaf {
514#define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc) 504#define XFS_DIR3_LEAF_CRC_OFF offsetof(struct xfs_dir3_leaf_hdr, info.crc)
515 505
516/* 506/*
517 * Get address of the bestcount field in the single-leaf block.
518 */
519static inline struct xfs_dir2_leaf_tail *
520xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp)
521{
522 return (struct xfs_dir2_leaf_tail *)
523 ((char *)lp + mp->m_dirblksize -
524 sizeof(struct xfs_dir2_leaf_tail));
525}
526
527/*
528 * Get address of the bests array in the single-leaf block. 507 * Get address of the bests array in the single-leaf block.
529 */ 508 */
530static inline __be16 * 509static inline __be16 *
@@ -534,123 +513,6 @@ xfs_dir2_leaf_bests_p(struct xfs_dir2_leaf_tail *ltp)
534} 513}
535 514
536/* 515/*
537 * DB blocks here are logical directory block numbers, not filesystem blocks.
538 */
539
540/*
541 * Convert dataptr to byte in file space
542 */
543static inline xfs_dir2_off_t
544xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp)
545{
546 return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
547}
548
549/*
550 * Convert byte in file space to dataptr. It had better be aligned.
551 */
552static inline xfs_dir2_dataptr_t
553xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
554{
555 return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
556}
557
558/*
559 * Convert byte in space to (DB) block
560 */
561static inline xfs_dir2_db_t
562xfs_dir2_byte_to_db(struct xfs_mount *mp, xfs_dir2_off_t by)
563{
564 return (xfs_dir2_db_t)
565 (by >> (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog));
566}
567
568/*
569 * Convert dataptr to a block number
570 */
571static inline xfs_dir2_db_t
572xfs_dir2_dataptr_to_db(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
573{
574 return xfs_dir2_byte_to_db(mp, xfs_dir2_dataptr_to_byte(dp));
575}
576
577/*
578 * Convert byte in space to offset in a block
579 */
580static inline xfs_dir2_data_aoff_t
581xfs_dir2_byte_to_off(struct xfs_mount *mp, xfs_dir2_off_t by)
582{
583 return (xfs_dir2_data_aoff_t)(by &
584 ((1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) - 1));
585}
586
587/*
588 * Convert dataptr to a byte offset in a block
589 */
590static inline xfs_dir2_data_aoff_t
591xfs_dir2_dataptr_to_off(struct xfs_mount *mp, xfs_dir2_dataptr_t dp)
592{
593 return xfs_dir2_byte_to_off(mp, xfs_dir2_dataptr_to_byte(dp));
594}
595
596/*
597 * Convert block and offset to byte in space
598 */
599static inline xfs_dir2_off_t
600xfs_dir2_db_off_to_byte(struct xfs_mount *mp, xfs_dir2_db_t db,
601 xfs_dir2_data_aoff_t o)
602{
603 return ((xfs_dir2_off_t)db <<
604 (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog)) + o;
605}
606
607/*
608 * Convert block (DB) to block (dablk)
609 */
610static inline xfs_dablk_t
611xfs_dir2_db_to_da(struct xfs_mount *mp, xfs_dir2_db_t db)
612{
613 return (xfs_dablk_t)(db << mp->m_sb.sb_dirblklog);
614}
615
616/*
617 * Convert byte in space to (DA) block
618 */
619static inline xfs_dablk_t
620xfs_dir2_byte_to_da(struct xfs_mount *mp, xfs_dir2_off_t by)
621{
622 return xfs_dir2_db_to_da(mp, xfs_dir2_byte_to_db(mp, by));
623}
624
625/*
626 * Convert block and offset to dataptr
627 */
628static inline xfs_dir2_dataptr_t
629xfs_dir2_db_off_to_dataptr(struct xfs_mount *mp, xfs_dir2_db_t db,
630 xfs_dir2_data_aoff_t o)
631{
632 return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(mp, db, o));
633}
634
635/*
636 * Convert block (dablk) to block (DB)
637 */
638static inline xfs_dir2_db_t
639xfs_dir2_da_to_db(struct xfs_mount *mp, xfs_dablk_t da)
640{
641 return (xfs_dir2_db_t)(da >> mp->m_sb.sb_dirblklog);
642}
643
644/*
645 * Convert block (dablk) to byte offset in space
646 */
647static inline xfs_dir2_off_t
648xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
649{
650 return xfs_dir2_db_off_to_byte(mp, xfs_dir2_da_to_db(mp, da), 0);
651}
652
653/*
654 * Free space block defintions for the node format. 516 * Free space block defintions for the node format.
655 */ 517 */
656 518
@@ -659,8 +521,6 @@ xfs_dir2_da_to_byte(struct xfs_mount *mp, xfs_dablk_t da)
659 */ 521 */
660#define XFS_DIR2_FREE_SPACE 2 522#define XFS_DIR2_FREE_SPACE 2
661#define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE) 523#define XFS_DIR2_FREE_OFFSET (XFS_DIR2_FREE_SPACE * XFS_DIR2_SPACE_SIZE)
662#define XFS_DIR2_FREE_FIRSTDB(mp) \
663 xfs_dir2_byte_to_db(mp, XFS_DIR2_FREE_OFFSET)
664 524
665typedef struct xfs_dir2_free_hdr { 525typedef struct xfs_dir2_free_hdr {
666 __be32 magic; /* XFS_DIR2_FREE_MAGIC */ 526 __be32 magic; /* XFS_DIR2_FREE_MAGIC */
@@ -736,16 +596,6 @@ typedef struct xfs_dir2_block_tail {
736} xfs_dir2_block_tail_t; 596} xfs_dir2_block_tail_t;
737 597
738/* 598/*
739 * Pointer to the leaf header embedded in a data block (1-block format)
740 */
741static inline struct xfs_dir2_block_tail *
742xfs_dir2_block_tail_p(struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr)
743{
744 return ((struct xfs_dir2_block_tail *)
745 ((char *)hdr + mp->m_dirblksize)) - 1;
746}
747
748/*
749 * Pointer to the leaf entries embedded in a data block (1-block format) 599 * Pointer to the leaf entries embedded in a data block (1-block format)
750 */ 600 */
751static inline struct xfs_dir2_leaf_entry * 601static inline struct xfs_dir2_leaf_entry *
@@ -764,10 +614,6 @@ xfs_dir2_block_leaf_p(struct xfs_dir2_block_tail *btp)
764 * 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
765 * 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.
766 * 616 *
767 *========================================================================
768 * Attribute structure when equal to XFS_LBSIZE(mp) bytes.
769 *========================================================================
770 *
771 * 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
772 * 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
773 * 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,
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 93fcebd5edd2..79670cda48ae 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -85,11 +85,12 @@ static struct xfs_nameops xfs_ascii_ci_nameops = {
85 .compname = xfs_ascii_ci_compname, 85 .compname = xfs_ascii_ci_compname,
86}; 86};
87 87
88void 88int
89xfs_dir_mount( 89xfs_da_mount(
90 xfs_mount_t *mp) 90 struct xfs_mount *mp)
91{ 91{
92 int nodehdr_size; 92 struct xfs_da_geometry *dageo;
93 int nodehdr_size;
93 94
94 95
95 ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT); 96 ASSERT(mp->m_sb.sb_versionnum & XFS_SB_VERSION_DIRV2BIT);
@@ -99,24 +100,59 @@ xfs_dir_mount(
99 mp->m_dir_inode_ops = xfs_dir_get_ops(mp, NULL); 100 mp->m_dir_inode_ops = xfs_dir_get_ops(mp, NULL);
100 mp->m_nondir_inode_ops = xfs_nondir_get_ops(mp, NULL); 101 mp->m_nondir_inode_ops = xfs_nondir_get_ops(mp, NULL);
101 102
102 mp->m_dirblksize = 1 << (mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog);
103 mp->m_dirblkfsbs = 1 << mp->m_sb.sb_dirblklog;
104 mp->m_dirdatablk = xfs_dir2_db_to_da(mp, XFS_DIR2_DATA_FIRSTDB(mp));
105 mp->m_dirleafblk = xfs_dir2_db_to_da(mp, XFS_DIR2_LEAF_FIRSTDB(mp));
106 mp->m_dirfreeblk = xfs_dir2_db_to_da(mp, XFS_DIR2_FREE_FIRSTDB(mp));
107
108 nodehdr_size = mp->m_dir_inode_ops->node_hdr_size; 103 nodehdr_size = mp->m_dir_inode_ops->node_hdr_size;
109 mp->m_attr_node_ents = (mp->m_sb.sb_blocksize - nodehdr_size) / 104 mp->m_dir_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
105 KM_SLEEP | KM_MAYFAIL);
106 mp->m_attr_geo = kmem_zalloc(sizeof(struct xfs_da_geometry),
107 KM_SLEEP | KM_MAYFAIL);
108 if (!mp->m_dir_geo || !mp->m_attr_geo) {
109 kmem_free(mp->m_dir_geo);
110 kmem_free(mp->m_attr_geo);
111 return ENOMEM;
112 }
113
114 /* set up directory geometry */
115 dageo = mp->m_dir_geo;
116 dageo->blklog = mp->m_sb.sb_blocklog + mp->m_sb.sb_dirblklog;
117 dageo->fsblog = mp->m_sb.sb_blocklog;
118 dageo->blksize = 1 << dageo->blklog;
119 dageo->fsbcount = 1 << mp->m_sb.sb_dirblklog;
120
121 /*
122 * Now we've set up the block conversion variables, we can calculate the
123 * segment block constants using the geometry structure.
124 */
125 dageo->datablk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_DATA_OFFSET);
126 dageo->leafblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_LEAF_OFFSET);
127 dageo->freeblk = xfs_dir2_byte_to_da(dageo, XFS_DIR2_FREE_OFFSET);
128 dageo->node_ents = (dageo->blksize - nodehdr_size) /
110 (uint)sizeof(xfs_da_node_entry_t); 129 (uint)sizeof(xfs_da_node_entry_t);
111 mp->m_dir_node_ents = (mp->m_dirblksize - nodehdr_size) / 130 dageo->magicpct = (dageo->blksize * 37) / 100;
131
132 /* set up attribute geometry - single fsb only */
133 dageo = mp->m_attr_geo;
134 dageo->blklog = mp->m_sb.sb_blocklog;
135 dageo->fsblog = mp->m_sb.sb_blocklog;
136 dageo->blksize = 1 << dageo->blklog;
137 dageo->fsbcount = 1;
138 dageo->node_ents = (dageo->blksize - nodehdr_size) /
112 (uint)sizeof(xfs_da_node_entry_t); 139 (uint)sizeof(xfs_da_node_entry_t);
140 dageo->magicpct = (dageo->blksize * 37) / 100;
113 141
114 mp->m_dir_magicpct = (mp->m_dirblksize * 37) / 100;
115 if (xfs_sb_version_hasasciici(&mp->m_sb)) 142 if (xfs_sb_version_hasasciici(&mp->m_sb))
116 mp->m_dirnameops = &xfs_ascii_ci_nameops; 143 mp->m_dirnameops = &xfs_ascii_ci_nameops;
117 else 144 else
118 mp->m_dirnameops = &xfs_default_nameops; 145 mp->m_dirnameops = &xfs_default_nameops;
119 146
147 return 0;
148}
149
150void
151xfs_da_unmount(
152 struct xfs_mount *mp)
153{
154 kmem_free(mp->m_dir_geo);
155 kmem_free(mp->m_attr_geo);
120} 156}
121 157
122/* 158/*
@@ -192,6 +228,7 @@ xfs_dir_init(
192 if (!args) 228 if (!args)
193 return ENOMEM; 229 return ENOMEM;
194 230
231 args->geo = dp->i_mount->m_dir_geo;
195 args->dp = dp; 232 args->dp = dp;
196 args->trans = tp; 233 args->trans = tp;
197 error = xfs_dir2_sf_create(args, pdp->i_ino); 234 error = xfs_dir2_sf_create(args, pdp->i_ino);
@@ -226,6 +263,7 @@ xfs_dir_createname(
226 if (!args) 263 if (!args)
227 return ENOMEM; 264 return ENOMEM;
228 265
266 args->geo = dp->i_mount->m_dir_geo;
229 args->name = name->name; 267 args->name = name->name;
230 args->namelen = name->len; 268 args->namelen = name->len;
231 args->filetype = name->type; 269 args->filetype = name->type;
@@ -244,7 +282,7 @@ xfs_dir_createname(
244 goto out_free; 282 goto out_free;
245 } 283 }
246 284
247 rval = xfs_dir2_isblock(dp, &v); 285 rval = xfs_dir2_isblock(args, &v);
248 if (rval) 286 if (rval)
249 goto out_free; 287 goto out_free;
250 if (v) { 288 if (v) {
@@ -252,7 +290,7 @@ xfs_dir_createname(
252 goto out_free; 290 goto out_free;
253 } 291 }
254 292
255 rval = xfs_dir2_isleaf(dp, &v); 293 rval = xfs_dir2_isleaf(args, &v);
256 if (rval) 294 if (rval)
257 goto out_free; 295 goto out_free;
258 if (v) 296 if (v)
@@ -320,6 +358,7 @@ xfs_dir_lookup(
320 * annotations into the reclaim path for the ilock. 358 * annotations into the reclaim path for the ilock.
321 */ 359 */
322 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS); 360 args = kmem_zalloc(sizeof(*args), KM_SLEEP | KM_NOFS);
361 args->geo = dp->i_mount->m_dir_geo;
323 args->name = name->name; 362 args->name = name->name;
324 args->namelen = name->len; 363 args->namelen = name->len;
325 args->filetype = name->type; 364 args->filetype = name->type;
@@ -336,7 +375,7 @@ xfs_dir_lookup(
336 goto out_check_rval; 375 goto out_check_rval;
337 } 376 }
338 377
339 rval = xfs_dir2_isblock(dp, &v); 378 rval = xfs_dir2_isblock(args, &v);
340 if (rval) 379 if (rval)
341 goto out_free; 380 goto out_free;
342 if (v) { 381 if (v) {
@@ -344,7 +383,7 @@ xfs_dir_lookup(
344 goto out_check_rval; 383 goto out_check_rval;
345 } 384 }
346 385
347 rval = xfs_dir2_isleaf(dp, &v); 386 rval = xfs_dir2_isleaf(args, &v);
348 if (rval) 387 if (rval)
349 goto out_free; 388 goto out_free;
350 if (v) 389 if (v)
@@ -391,6 +430,7 @@ xfs_dir_removename(
391 if (!args) 430 if (!args)
392 return ENOMEM; 431 return ENOMEM;
393 432
433 args->geo = dp->i_mount->m_dir_geo;
394 args->name = name->name; 434 args->name = name->name;
395 args->namelen = name->len; 435 args->namelen = name->len;
396 args->filetype = name->type; 436 args->filetype = name->type;
@@ -408,7 +448,7 @@ xfs_dir_removename(
408 goto out_free; 448 goto out_free;
409 } 449 }
410 450
411 rval = xfs_dir2_isblock(dp, &v); 451 rval = xfs_dir2_isblock(args, &v);
412 if (rval) 452 if (rval)
413 goto out_free; 453 goto out_free;
414 if (v) { 454 if (v) {
@@ -416,7 +456,7 @@ xfs_dir_removename(
416 goto out_free; 456 goto out_free;
417 } 457 }
418 458
419 rval = xfs_dir2_isleaf(dp, &v); 459 rval = xfs_dir2_isleaf(args, &v);
420 if (rval) 460 if (rval)
421 goto out_free; 461 goto out_free;
422 if (v) 462 if (v)
@@ -455,6 +495,7 @@ xfs_dir_replace(
455 if (!args) 495 if (!args)
456 return ENOMEM; 496 return ENOMEM;
457 497
498 args->geo = dp->i_mount->m_dir_geo;
458 args->name = name->name; 499 args->name = name->name;
459 args->namelen = name->len; 500 args->namelen = name->len;
460 args->filetype = name->type; 501 args->filetype = name->type;
@@ -472,7 +513,7 @@ xfs_dir_replace(
472 goto out_free; 513 goto out_free;
473 } 514 }
474 515
475 rval = xfs_dir2_isblock(dp, &v); 516 rval = xfs_dir2_isblock(args, &v);
476 if (rval) 517 if (rval)
477 goto out_free; 518 goto out_free;
478 if (v) { 519 if (v) {
@@ -480,7 +521,7 @@ xfs_dir_replace(
480 goto out_free; 521 goto out_free;
481 } 522 }
482 523
483 rval = xfs_dir2_isleaf(dp, &v); 524 rval = xfs_dir2_isleaf(args, &v);
484 if (rval) 525 if (rval)
485 goto out_free; 526 goto out_free;
486 if (v) 527 if (v)
@@ -516,6 +557,7 @@ xfs_dir_canenter(
516 if (!args) 557 if (!args)
517 return ENOMEM; 558 return ENOMEM;
518 559
560 args->geo = dp->i_mount->m_dir_geo;
519 args->name = name->name; 561 args->name = name->name;
520 args->namelen = name->len; 562 args->namelen = name->len;
521 args->filetype = name->type; 563 args->filetype = name->type;
@@ -531,7 +573,7 @@ xfs_dir_canenter(
531 goto out_free; 573 goto out_free;
532 } 574 }
533 575
534 rval = xfs_dir2_isblock(dp, &v); 576 rval = xfs_dir2_isblock(args, &v);
535 if (rval) 577 if (rval)
536 goto out_free; 578 goto out_free;
537 if (v) { 579 if (v) {
@@ -539,7 +581,7 @@ xfs_dir_canenter(
539 goto out_free; 581 goto out_free;
540 } 582 }
541 583
542 rval = xfs_dir2_isleaf(dp, &v); 584 rval = xfs_dir2_isleaf(args, &v);
543 if (rval) 585 if (rval)
544 goto out_free; 586 goto out_free;
545 if (v) 587 if (v)
@@ -579,13 +621,13 @@ xfs_dir2_grow_inode(
579 * Set lowest possible block in the space requested. 621 * Set lowest possible block in the space requested.
580 */ 622 */
581 bno = XFS_B_TO_FSBT(mp, space * XFS_DIR2_SPACE_SIZE); 623 bno = XFS_B_TO_FSBT(mp, space * XFS_DIR2_SPACE_SIZE);
582 count = mp->m_dirblkfsbs; 624 count = args->geo->fsbcount;
583 625
584 error = xfs_da_grow_inode_int(args, &bno, count); 626 error = xfs_da_grow_inode_int(args, &bno, count);
585 if (error) 627 if (error)
586 return error; 628 return error;
587 629
588 *dbp = xfs_dir2_da_to_db(mp, (xfs_dablk_t)bno); 630 *dbp = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)bno);
589 631
590 /* 632 /*
591 * Update file's size if this is the data space and it grew. 633 * Update file's size if this is the data space and it grew.
@@ -607,18 +649,16 @@ xfs_dir2_grow_inode(
607 */ 649 */
608int 650int
609xfs_dir2_isblock( 651xfs_dir2_isblock(
610 xfs_inode_t *dp, 652 struct xfs_da_args *args,
611 int *vp) /* out: 1 is block, 0 is not block */ 653 int *vp) /* out: 1 is block, 0 is not block */
612{ 654{
613 xfs_fileoff_t last; /* last file offset */ 655 xfs_fileoff_t last; /* last file offset */
614 xfs_mount_t *mp; 656 int rval;
615 int rval;
616 657
617 mp = dp->i_mount; 658 if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
618 if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK)))
619 return rval; 659 return rval;
620 rval = XFS_FSB_TO_B(mp, last) == mp->m_dirblksize; 660 rval = XFS_FSB_TO_B(args->dp->i_mount, last) == args->geo->blksize;
621 ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dirblksize); 661 ASSERT(rval == 0 || args->dp->i_d.di_size == args->geo->blksize);
622 *vp = rval; 662 *vp = rval;
623 return 0; 663 return 0;
624} 664}
@@ -628,17 +668,15 @@ xfs_dir2_isblock(
628 */ 668 */
629int 669int
630xfs_dir2_isleaf( 670xfs_dir2_isleaf(
631 xfs_inode_t *dp, 671 struct xfs_da_args *args,
632 int *vp) /* out: 1 is leaf, 0 is not leaf */ 672 int *vp) /* out: 1 is block, 0 is not block */
633{ 673{
634 xfs_fileoff_t last; /* last file offset */ 674 xfs_fileoff_t last; /* last file offset */
635 xfs_mount_t *mp; 675 int rval;
636 int rval;
637 676
638 mp = dp->i_mount; 677 if ((rval = xfs_bmap_last_offset(args->dp, &last, XFS_DATA_FORK)))
639 if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK)))
640 return rval; 678 return rval;
641 *vp = last == mp->m_dirleafblk + (1 << mp->m_sb.sb_dirblklog); 679 *vp = last == args->geo->leafblk + args->geo->fsbcount;
642 return 0; 680 return 0;
643} 681}
644 682
@@ -666,11 +704,11 @@ xfs_dir2_shrink_inode(
666 dp = args->dp; 704 dp = args->dp;
667 mp = dp->i_mount; 705 mp = dp->i_mount;
668 tp = args->trans; 706 tp = args->trans;
669 da = xfs_dir2_db_to_da(mp, db); 707 da = xfs_dir2_db_to_da(args->geo, db);
670 /* 708 /*
671 * Unmap the fsblock(s). 709 * Unmap the fsblock(s).
672 */ 710 */
673 if ((error = xfs_bunmapi(tp, dp, da, mp->m_dirblkfsbs, 711 if ((error = xfs_bunmapi(tp, dp, da, args->geo->fsbcount,
674 XFS_BMAPI_METADATA, 0, args->firstblock, args->flist, 712 XFS_BMAPI_METADATA, 0, args->firstblock, args->flist,
675 &done))) { 713 &done))) {
676 /* 714 /*
@@ -697,12 +735,12 @@ xfs_dir2_shrink_inode(
697 /* 735 /*
698 * If it's not a data block, we're done. 736 * If it's not a data block, we're done.
699 */ 737 */
700 if (db >= XFS_DIR2_LEAF_FIRSTDB(mp)) 738 if (db >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET))
701 return 0; 739 return 0;
702 /* 740 /*
703 * If the block isn't the last one in the directory, we're done. 741 * If the block isn't the last one in the directory, we're done.
704 */ 742 */
705 if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(mp, db + 1, 0)) 743 if (dp->i_d.di_size > xfs_dir2_db_off_to_byte(args->geo, db + 1, 0))
706 return 0; 744 return 0;
707 bno = da; 745 bno = da;
708 if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) { 746 if ((error = xfs_bmap_last_before(tp, dp, &bno, XFS_DATA_FORK))) {
@@ -711,7 +749,7 @@ xfs_dir2_shrink_inode(
711 */ 749 */
712 return error; 750 return error;
713 } 751 }
714 if (db == mp->m_dirdatablk) 752 if (db == args->geo->datablk)
715 ASSERT(bno == 0); 753 ASSERT(bno == 0);
716 else 754 else
717 ASSERT(bno > 0); 755 ASSERT(bno > 0);
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h
index 64a6b19c2fd0..c8e86b0b5e99 100644
--- a/fs/xfs/xfs_dir2.h
+++ b/fs/xfs/xfs_dir2.h
@@ -80,7 +80,7 @@ struct xfs_dir_ops {
80 struct xfs_dir3_icleaf_hdr *from); 80 struct xfs_dir3_icleaf_hdr *from);
81 void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to, 81 void (*leaf_hdr_from_disk)(struct xfs_dir3_icleaf_hdr *to,
82 struct xfs_dir2_leaf *from); 82 struct xfs_dir2_leaf *from);
83 int (*leaf_max_ents)(struct xfs_mount *mp); 83 int (*leaf_max_ents)(struct xfs_da_geometry *geo);
84 struct xfs_dir2_leaf_entry * 84 struct xfs_dir2_leaf_entry *
85 (*leaf_ents_p)(struct xfs_dir2_leaf *lp); 85 (*leaf_ents_p)(struct xfs_dir2_leaf *lp);
86 86
@@ -97,10 +97,12 @@ struct xfs_dir_ops {
97 struct xfs_dir3_icfree_hdr *from); 97 struct xfs_dir3_icfree_hdr *from);
98 void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to, 98 void (*free_hdr_from_disk)(struct xfs_dir3_icfree_hdr *to,
99 struct xfs_dir2_free *from); 99 struct xfs_dir2_free *from);
100 int (*free_max_bests)(struct xfs_mount *mp); 100 int (*free_max_bests)(struct xfs_da_geometry *geo);
101 __be16 * (*free_bests_p)(struct xfs_dir2_free *free); 101 __be16 * (*free_bests_p)(struct xfs_dir2_free *free);
102 xfs_dir2_db_t (*db_to_fdb)(struct xfs_mount *mp, xfs_dir2_db_t db); 102 xfs_dir2_db_t (*db_to_fdb)(struct xfs_da_geometry *geo,
103 int (*db_to_fdindex)(struct xfs_mount *mp, xfs_dir2_db_t db); 103 xfs_dir2_db_t db);
104 int (*db_to_fdindex)(struct xfs_da_geometry *geo,
105 xfs_dir2_db_t db);
104}; 106};
105 107
106extern const struct xfs_dir_ops * 108extern const struct xfs_dir_ops *
@@ -112,7 +114,9 @@ extern const struct xfs_dir_ops *
112 * Generic directory interface routines 114 * Generic directory interface routines
113 */ 115 */
114extern void xfs_dir_startup(void); 116extern void xfs_dir_startup(void);
115extern void xfs_dir_mount(struct xfs_mount *mp); 117extern int xfs_da_mount(struct xfs_mount *mp);
118extern void xfs_da_unmount(struct xfs_mount *mp);
119
116extern int xfs_dir_isempty(struct xfs_inode *dp); 120extern int xfs_dir_isempty(struct xfs_inode *dp);
117extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp, 121extern int xfs_dir_init(struct xfs_trans *tp, struct xfs_inode *dp,
118 struct xfs_inode *pdp); 122 struct xfs_inode *pdp);
@@ -142,23 +146,23 @@ extern int xfs_dir2_sf_to_block(struct xfs_da_args *args);
142/* 146/*
143 * Interface routines used by userspace utilities 147 * Interface routines used by userspace utilities
144 */ 148 */
145extern int xfs_dir2_isblock(struct xfs_inode *dp, int *r); 149extern int xfs_dir2_isblock(struct xfs_da_args *args, int *r);
146extern int xfs_dir2_isleaf(struct xfs_inode *dp, int *r); 150extern int xfs_dir2_isleaf(struct xfs_da_args *args, int *r);
147extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db, 151extern int xfs_dir2_shrink_inode(struct xfs_da_args *args, xfs_dir2_db_t db,
148 struct xfs_buf *bp); 152 struct xfs_buf *bp);
149 153
150extern void xfs_dir2_data_freescan(struct xfs_inode *dp, 154extern void xfs_dir2_data_freescan(struct xfs_inode *dp,
151 struct xfs_dir2_data_hdr *hdr, int *loghead); 155 struct xfs_dir2_data_hdr *hdr, int *loghead);
152extern void xfs_dir2_data_log_entry(struct xfs_trans *tp, struct xfs_inode *dp, 156extern void xfs_dir2_data_log_entry(struct xfs_da_args *args,
153 struct xfs_buf *bp, struct xfs_dir2_data_entry *dep); 157 struct xfs_buf *bp, struct xfs_dir2_data_entry *dep);
154extern void xfs_dir2_data_log_header(struct xfs_trans *tp, struct xfs_inode *dp, 158extern void xfs_dir2_data_log_header(struct xfs_da_args *args,
155 struct xfs_buf *bp); 159 struct xfs_buf *bp);
156extern void xfs_dir2_data_log_unused(struct xfs_trans *tp, struct xfs_buf *bp, 160extern void xfs_dir2_data_log_unused(struct xfs_da_args *args,
157 struct xfs_dir2_data_unused *dup); 161 struct xfs_buf *bp, struct xfs_dir2_data_unused *dup);
158extern void xfs_dir2_data_make_free(struct xfs_trans *tp, struct xfs_inode *dp, 162extern void xfs_dir2_data_make_free(struct xfs_da_args *args,
159 struct xfs_buf *bp, xfs_dir2_data_aoff_t offset, 163 struct xfs_buf *bp, xfs_dir2_data_aoff_t offset,
160 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp); 164 xfs_dir2_data_aoff_t len, int *needlogp, int *needscanp);
161extern void xfs_dir2_data_use_free(struct xfs_trans *tp, struct xfs_inode *dp, 165extern void xfs_dir2_data_use_free(struct xfs_da_args *args,
162 struct xfs_buf *bp, struct xfs_dir2_data_unused *dup, 166 struct xfs_buf *bp, struct xfs_dir2_data_unused *dup,
163 xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len, 167 xfs_dir2_data_aoff_t offset, xfs_dir2_data_aoff_t len,
164 int *needlogp, int *needscanp); 168 int *needlogp, int *needscanp);
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index dd9d00515582..c7cd3154026a 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -136,7 +136,7 @@ xfs_dir3_block_read(
136 struct xfs_mount *mp = dp->i_mount; 136 struct xfs_mount *mp = dp->i_mount;
137 int err; 137 int err;
138 138
139 err = xfs_da_read_buf(tp, dp, mp->m_dirdatablk, -1, bpp, 139 err = xfs_da_read_buf(tp, dp, mp->m_dir_geo->datablk, -1, bpp,
140 XFS_DATA_FORK, &xfs_dir3_block_buf_ops); 140 XFS_DATA_FORK, &xfs_dir3_block_buf_ops);
141 if (!err && tp) 141 if (!err && tp)
142 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF); 142 xfs_trans_buf_set_type(tp, *bpp, XFS_BLFT_DIR_BLOCK_BUF);
@@ -281,8 +281,7 @@ out:
281 */ 281 */
282static void 282static void
283xfs_dir2_block_compact( 283xfs_dir2_block_compact(
284 struct xfs_trans *tp, 284 struct xfs_da_args *args,
285 struct xfs_inode *dp,
286 struct xfs_buf *bp, 285 struct xfs_buf *bp,
287 struct xfs_dir2_data_hdr *hdr, 286 struct xfs_dir2_data_hdr *hdr,
288 struct xfs_dir2_block_tail *btp, 287 struct xfs_dir2_block_tail *btp,
@@ -315,7 +314,7 @@ xfs_dir2_block_compact(
315 *lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1); 314 *lfloglow = toidx + 1 - (be32_to_cpu(btp->stale) - 1);
316 *lfloghigh -= be32_to_cpu(btp->stale) - 1; 315 *lfloghigh -= be32_to_cpu(btp->stale) - 1;
317 be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1)); 316 be32_add_cpu(&btp->count, -(be32_to_cpu(btp->stale) - 1));
318 xfs_dir2_data_make_free(tp, dp, bp, 317 xfs_dir2_data_make_free(args, bp,
319 (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), 318 (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
320 (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)), 319 (xfs_dir2_data_aoff_t)((be32_to_cpu(btp->stale) - 1) * sizeof(*blp)),
321 needlog, &needscan); 320 needlog, &needscan);
@@ -325,7 +324,7 @@ xfs_dir2_block_compact(
325 * This needs to happen before the next call to use_free. 324 * This needs to happen before the next call to use_free.
326 */ 325 */
327 if (needscan) 326 if (needscan)
328 xfs_dir2_data_freescan(dp, hdr, needlog); 327 xfs_dir2_data_freescan(args->dp, hdr, needlog);
329} 328}
330 329
331/* 330/*
@@ -377,7 +376,7 @@ xfs_dir2_block_addname(
377 * Set up pointers to parts of the block. 376 * Set up pointers to parts of the block.
378 */ 377 */
379 hdr = bp->b_addr; 378 hdr = bp->b_addr;
380 btp = xfs_dir2_block_tail_p(mp, hdr); 379 btp = xfs_dir2_block_tail_p(args->geo, hdr);
381 blp = xfs_dir2_block_leaf_p(btp); 380 blp = xfs_dir2_block_leaf_p(btp);
382 381
383 /* 382 /*
@@ -420,7 +419,7 @@ xfs_dir2_block_addname(
420 * If need to compact the leaf entries, do it now. 419 * If need to compact the leaf entries, do it now.
421 */ 420 */
422 if (compact) { 421 if (compact) {
423 xfs_dir2_block_compact(tp, dp, bp, hdr, btp, blp, &needlog, 422 xfs_dir2_block_compact(args, bp, hdr, btp, blp, &needlog,
424 &lfloghigh, &lfloglow); 423 &lfloghigh, &lfloglow);
425 /* recalculate blp post-compaction */ 424 /* recalculate blp post-compaction */
426 blp = xfs_dir2_block_leaf_p(btp); 425 blp = xfs_dir2_block_leaf_p(btp);
@@ -455,7 +454,7 @@ xfs_dir2_block_addname(
455 /* 454 /*
456 * Mark the space needed for the new leaf entry, now in use. 455 * Mark the space needed for the new leaf entry, now in use.
457 */ 456 */
458 xfs_dir2_data_use_free(tp, dp, bp, enddup, 457 xfs_dir2_data_use_free(args, bp, enddup,
459 (xfs_dir2_data_aoff_t) 458 (xfs_dir2_data_aoff_t)
460 ((char *)enddup - (char *)hdr + be16_to_cpu(enddup->length) - 459 ((char *)enddup - (char *)hdr + be16_to_cpu(enddup->length) -
461 sizeof(*blp)), 460 sizeof(*blp)),
@@ -542,7 +541,7 @@ xfs_dir2_block_addname(
542 /* 541 /*
543 * Mark space for the data entry used. 542 * Mark space for the data entry used.
544 */ 543 */
545 xfs_dir2_data_use_free(tp, dp, bp, dup, 544 xfs_dir2_data_use_free(args, bp, dup,
546 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), 545 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr),
547 (xfs_dir2_data_aoff_t)len, &needlog, &needscan); 546 (xfs_dir2_data_aoff_t)len, &needlog, &needscan);
548 /* 547 /*
@@ -560,9 +559,9 @@ xfs_dir2_block_addname(
560 if (needscan) 559 if (needscan)
561 xfs_dir2_data_freescan(dp, hdr, &needlog); 560 xfs_dir2_data_freescan(dp, hdr, &needlog);
562 if (needlog) 561 if (needlog)
563 xfs_dir2_data_log_header(tp, dp, bp); 562 xfs_dir2_data_log_header(args, bp);
564 xfs_dir2_block_log_tail(tp, bp); 563 xfs_dir2_block_log_tail(tp, bp);
565 xfs_dir2_data_log_entry(tp, dp, bp, dep); 564 xfs_dir2_data_log_entry(args, bp, dep);
566 xfs_dir3_data_check(dp, bp); 565 xfs_dir3_data_check(dp, bp);
567 return 0; 566 return 0;
568} 567}
@@ -581,7 +580,7 @@ xfs_dir2_block_log_leaf(
581 xfs_dir2_leaf_entry_t *blp; 580 xfs_dir2_leaf_entry_t *blp;
582 xfs_dir2_block_tail_t *btp; 581 xfs_dir2_block_tail_t *btp;
583 582
584 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 583 btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
585 blp = xfs_dir2_block_leaf_p(btp); 584 blp = xfs_dir2_block_leaf_p(btp);
586 xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr), 585 xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr),
587 (uint)((char *)&blp[last + 1] - (char *)hdr - 1)); 586 (uint)((char *)&blp[last + 1] - (char *)hdr - 1));
@@ -598,7 +597,7 @@ xfs_dir2_block_log_tail(
598 xfs_dir2_data_hdr_t *hdr = bp->b_addr; 597 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
599 xfs_dir2_block_tail_t *btp; 598 xfs_dir2_block_tail_t *btp;
600 599
601 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 600 btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
602 xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr), 601 xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr),
603 (uint)((char *)(btp + 1) - (char *)hdr - 1)); 602 (uint)((char *)(btp + 1) - (char *)hdr - 1));
604} 603}
@@ -633,13 +632,14 @@ xfs_dir2_block_lookup(
633 mp = dp->i_mount; 632 mp = dp->i_mount;
634 hdr = bp->b_addr; 633 hdr = bp->b_addr;
635 xfs_dir3_data_check(dp, bp); 634 xfs_dir3_data_check(dp, bp);
636 btp = xfs_dir2_block_tail_p(mp, hdr); 635 btp = xfs_dir2_block_tail_p(args->geo, hdr);
637 blp = xfs_dir2_block_leaf_p(btp); 636 blp = xfs_dir2_block_leaf_p(btp);
638 /* 637 /*
639 * Get the offset from the leaf entry, to point to the data. 638 * Get the offset from the leaf entry, to point to the data.
640 */ 639 */
641 dep = (xfs_dir2_data_entry_t *)((char *)hdr + 640 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
642 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); 641 xfs_dir2_dataptr_to_off(args->geo,
642 be32_to_cpu(blp[ent].address)));
643 /* 643 /*
644 * Fill in inode number, CI name if appropriate, release the block. 644 * Fill in inode number, CI name if appropriate, release the block.
645 */ 645 */
@@ -685,7 +685,7 @@ xfs_dir2_block_lookup_int(
685 685
686 hdr = bp->b_addr; 686 hdr = bp->b_addr;
687 xfs_dir3_data_check(dp, bp); 687 xfs_dir3_data_check(dp, bp);
688 btp = xfs_dir2_block_tail_p(mp, hdr); 688 btp = xfs_dir2_block_tail_p(args->geo, hdr);
689 blp = xfs_dir2_block_leaf_p(btp); 689 blp = xfs_dir2_block_leaf_p(btp);
690 /* 690 /*
691 * Loop doing a binary search for our hash value. 691 * Loop doing a binary search for our hash value.
@@ -723,7 +723,7 @@ xfs_dir2_block_lookup_int(
723 * Get pointer to the entry from the leaf. 723 * Get pointer to the entry from the leaf.
724 */ 724 */
725 dep = (xfs_dir2_data_entry_t *) 725 dep = (xfs_dir2_data_entry_t *)
726 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, addr)); 726 ((char *)hdr + xfs_dir2_dataptr_to_off(args->geo, addr));
727 /* 727 /*
728 * Compare name and if it's an exact match, return the index 728 * Compare name and if it's an exact match, return the index
729 * and buffer. If it's the first case-insensitive match, store 729 * and buffer. If it's the first case-insensitive match, store
@@ -790,18 +790,19 @@ xfs_dir2_block_removename(
790 tp = args->trans; 790 tp = args->trans;
791 mp = dp->i_mount; 791 mp = dp->i_mount;
792 hdr = bp->b_addr; 792 hdr = bp->b_addr;
793 btp = xfs_dir2_block_tail_p(mp, hdr); 793 btp = xfs_dir2_block_tail_p(args->geo, hdr);
794 blp = xfs_dir2_block_leaf_p(btp); 794 blp = xfs_dir2_block_leaf_p(btp);
795 /* 795 /*
796 * Point to the data entry using the leaf entry. 796 * Point to the data entry using the leaf entry.
797 */ 797 */
798 dep = (xfs_dir2_data_entry_t *) 798 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
799 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); 799 xfs_dir2_dataptr_to_off(args->geo,
800 be32_to_cpu(blp[ent].address)));
800 /* 801 /*
801 * Mark the data entry's space free. 802 * Mark the data entry's space free.
802 */ 803 */
803 needlog = needscan = 0; 804 needlog = needscan = 0;
804 xfs_dir2_data_make_free(tp, dp, bp, 805 xfs_dir2_data_make_free(args, bp,
805 (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), 806 (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
806 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); 807 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
807 /* 808 /*
@@ -820,7 +821,7 @@ xfs_dir2_block_removename(
820 if (needscan) 821 if (needscan)
821 xfs_dir2_data_freescan(dp, hdr, &needlog); 822 xfs_dir2_data_freescan(dp, hdr, &needlog);
822 if (needlog) 823 if (needlog)
823 xfs_dir2_data_log_header(tp, dp, bp); 824 xfs_dir2_data_log_header(args, bp);
824 xfs_dir3_data_check(dp, bp); 825 xfs_dir3_data_check(dp, bp);
825 /* 826 /*
826 * See if the size as a shortform is good enough. 827 * See if the size as a shortform is good enough.
@@ -865,20 +866,21 @@ xfs_dir2_block_replace(
865 dp = args->dp; 866 dp = args->dp;
866 mp = dp->i_mount; 867 mp = dp->i_mount;
867 hdr = bp->b_addr; 868 hdr = bp->b_addr;
868 btp = xfs_dir2_block_tail_p(mp, hdr); 869 btp = xfs_dir2_block_tail_p(args->geo, hdr);
869 blp = xfs_dir2_block_leaf_p(btp); 870 blp = xfs_dir2_block_leaf_p(btp);
870 /* 871 /*
871 * Point to the data entry we need to change. 872 * Point to the data entry we need to change.
872 */ 873 */
873 dep = (xfs_dir2_data_entry_t *) 874 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
874 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(blp[ent].address))); 875 xfs_dir2_dataptr_to_off(args->geo,
876 be32_to_cpu(blp[ent].address)));
875 ASSERT(be64_to_cpu(dep->inumber) != args->inumber); 877 ASSERT(be64_to_cpu(dep->inumber) != args->inumber);
876 /* 878 /*
877 * Change the inode number to the new value. 879 * Change the inode number to the new value.
878 */ 880 */
879 dep->inumber = cpu_to_be64(args->inumber); 881 dep->inumber = cpu_to_be64(args->inumber);
880 dp->d_ops->data_put_ftype(dep, args->filetype); 882 dp->d_ops->data_put_ftype(dep, args->filetype);
881 xfs_dir2_data_log_entry(args->trans, dp, bp, dep); 883 xfs_dir2_data_log_entry(args, bp, dep);
882 xfs_dir3_data_check(dp, bp); 884 xfs_dir3_data_check(dp, bp);
883 return 0; 885 return 0;
884} 886}
@@ -938,7 +940,7 @@ xfs_dir2_leaf_to_block(
938 leaf = lbp->b_addr; 940 leaf = lbp->b_addr;
939 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 941 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
940 ents = dp->d_ops->leaf_ents_p(leaf); 942 ents = dp->d_ops->leaf_ents_p(leaf);
941 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 943 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
942 944
943 ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC || 945 ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC ||
944 leafhdr.magic == XFS_DIR3_LEAF1_MAGIC); 946 leafhdr.magic == XFS_DIR3_LEAF1_MAGIC);
@@ -948,13 +950,13 @@ xfs_dir2_leaf_to_block(
948 * been left behind during no-space-reservation operations. 950 * been left behind during no-space-reservation operations.
949 * These will show up in the leaf bests table. 951 * These will show up in the leaf bests table.
950 */ 952 */
951 while (dp->i_d.di_size > mp->m_dirblksize) { 953 while (dp->i_d.di_size > args->geo->blksize) {
952 int hdrsz; 954 int hdrsz;
953 955
954 hdrsz = dp->d_ops->data_entry_offset; 956 hdrsz = dp->d_ops->data_entry_offset;
955 bestsp = xfs_dir2_leaf_bests_p(ltp); 957 bestsp = xfs_dir2_leaf_bests_p(ltp);
956 if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == 958 if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
957 mp->m_dirblksize - hdrsz) { 959 args->geo->blksize - hdrsz) {
958 if ((error = 960 if ((error =
959 xfs_dir2_leaf_trim_data(args, lbp, 961 xfs_dir2_leaf_trim_data(args, lbp,
960 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) 962 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
@@ -966,7 +968,7 @@ xfs_dir2_leaf_to_block(
966 * Read the data block if we don't already have it, give up if it fails. 968 * Read the data block if we don't already have it, give up if it fails.
967 */ 969 */
968 if (!dbp) { 970 if (!dbp) {
969 error = xfs_dir3_data_read(tp, dp, mp->m_dirdatablk, -1, &dbp); 971 error = xfs_dir3_data_read(tp, dp, args->geo->datablk, -1, &dbp);
970 if (error) 972 if (error)
971 return error; 973 return error;
972 } 974 }
@@ -982,7 +984,7 @@ xfs_dir2_leaf_to_block(
982 /* 984 /*
983 * Look at the last data entry. 985 * Look at the last data entry.
984 */ 986 */
985 tagp = (__be16 *)((char *)hdr + mp->m_dirblksize) - 1; 987 tagp = (__be16 *)((char *)hdr + args->geo->blksize) - 1;
986 dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); 988 dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp));
987 /* 989 /*
988 * If it's not free or is too short we can't do it. 990 * If it's not free or is too short we can't do it.
@@ -1001,12 +1003,12 @@ xfs_dir2_leaf_to_block(
1001 /* 1003 /*
1002 * Use up the space at the end of the block (blp/btp). 1004 * Use up the space at the end of the block (blp/btp).
1003 */ 1005 */
1004 xfs_dir2_data_use_free(tp, dp, dbp, dup, mp->m_dirblksize - size, size, 1006 xfs_dir2_data_use_free(args, dbp, dup, args->geo->blksize - size, size,
1005 &needlog, &needscan); 1007 &needlog, &needscan);
1006 /* 1008 /*
1007 * Initialize the block tail. 1009 * Initialize the block tail.
1008 */ 1010 */
1009 btp = xfs_dir2_block_tail_p(mp, hdr); 1011 btp = xfs_dir2_block_tail_p(args->geo, hdr);
1010 btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale); 1012 btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale);
1011 btp->stale = 0; 1013 btp->stale = 0;
1012 xfs_dir2_block_log_tail(tp, dbp); 1014 xfs_dir2_block_log_tail(tp, dbp);
@@ -1027,11 +1029,11 @@ xfs_dir2_leaf_to_block(
1027 if (needscan) 1029 if (needscan)
1028 xfs_dir2_data_freescan(dp, hdr, &needlog); 1030 xfs_dir2_data_freescan(dp, hdr, &needlog);
1029 if (needlog) 1031 if (needlog)
1030 xfs_dir2_data_log_header(tp, dp, dbp); 1032 xfs_dir2_data_log_header(args, dbp);
1031 /* 1033 /*
1032 * Pitch the old leaf block. 1034 * Pitch the old leaf block.
1033 */ 1035 */
1034 error = xfs_da_shrink_inode(args, mp->m_dirleafblk, lbp); 1036 error = xfs_da_shrink_inode(args, args->geo->leafblk, lbp);
1035 if (error) 1037 if (error)
1036 return error; 1038 return error;
1037 1039
@@ -1140,13 +1142,13 @@ xfs_dir2_sf_to_block(
1140 */ 1142 */
1141 dup = dp->d_ops->data_unused_p(hdr); 1143 dup = dp->d_ops->data_unused_p(hdr);
1142 needlog = needscan = 0; 1144 needlog = needscan = 0;
1143 xfs_dir2_data_use_free(tp, dp, bp, dup, mp->m_dirblksize - i, i, &needlog, 1145 xfs_dir2_data_use_free(args, bp, dup, args->geo->blksize - i,
1144 &needscan); 1146 i, &needlog, &needscan);
1145 ASSERT(needscan == 0); 1147 ASSERT(needscan == 0);
1146 /* 1148 /*
1147 * Fill in the tail. 1149 * Fill in the tail.
1148 */ 1150 */
1149 btp = xfs_dir2_block_tail_p(mp, hdr); 1151 btp = xfs_dir2_block_tail_p(args->geo, hdr);
1150 btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */ 1152 btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */
1151 btp->stale = 0; 1153 btp->stale = 0;
1152 blp = xfs_dir2_block_leaf_p(btp); 1154 blp = xfs_dir2_block_leaf_p(btp);
@@ -1154,7 +1156,7 @@ xfs_dir2_sf_to_block(
1154 /* 1156 /*
1155 * Remove the freespace, we'll manage it. 1157 * Remove the freespace, we'll manage it.
1156 */ 1158 */
1157 xfs_dir2_data_use_free(tp, dp, bp, dup, 1159 xfs_dir2_data_use_free(args, bp, dup,
1158 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), 1160 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr),
1159 be16_to_cpu(dup->length), &needlog, &needscan); 1161 be16_to_cpu(dup->length), &needlog, &needscan);
1160 /* 1162 /*
@@ -1167,7 +1169,7 @@ xfs_dir2_sf_to_block(
1167 dp->d_ops->data_put_ftype(dep, XFS_DIR3_FT_DIR); 1169 dp->d_ops->data_put_ftype(dep, XFS_DIR3_FT_DIR);
1168 tagp = dp->d_ops->data_entry_tag_p(dep); 1170 tagp = dp->d_ops->data_entry_tag_p(dep);
1169 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 1171 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
1170 xfs_dir2_data_log_entry(tp, dp, bp, dep); 1172 xfs_dir2_data_log_entry(args, bp, dep);
1171 blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot); 1173 blp[0].hashval = cpu_to_be32(xfs_dir_hash_dot);
1172 blp[0].address = cpu_to_be32(xfs_dir2_byte_to_dataptr( 1174 blp[0].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(
1173 (char *)dep - (char *)hdr)); 1175 (char *)dep - (char *)hdr));
@@ -1181,7 +1183,7 @@ xfs_dir2_sf_to_block(
1181 dp->d_ops->data_put_ftype(dep, XFS_DIR3_FT_DIR); 1183 dp->d_ops->data_put_ftype(dep, XFS_DIR3_FT_DIR);
1182 tagp = dp->d_ops->data_entry_tag_p(dep); 1184 tagp = dp->d_ops->data_entry_tag_p(dep);
1183 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 1185 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
1184 xfs_dir2_data_log_entry(tp, dp, bp, dep); 1186 xfs_dir2_data_log_entry(args, bp, dep);
1185 blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot); 1187 blp[1].hashval = cpu_to_be32(xfs_dir_hash_dotdot);
1186 blp[1].address = cpu_to_be32(xfs_dir2_byte_to_dataptr( 1188 blp[1].address = cpu_to_be32(xfs_dir2_byte_to_dataptr(
1187 (char *)dep - (char *)hdr)); 1189 (char *)dep - (char *)hdr));
@@ -1215,7 +1217,7 @@ xfs_dir2_sf_to_block(
1215 dup->length = cpu_to_be16(newoffset - offset); 1217 dup->length = cpu_to_be16(newoffset - offset);
1216 *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16( 1218 *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16(
1217 ((char *)dup - (char *)hdr)); 1219 ((char *)dup - (char *)hdr));
1218 xfs_dir2_data_log_unused(tp, bp, dup); 1220 xfs_dir2_data_log_unused(args, bp, dup);
1219 xfs_dir2_data_freeinsert(hdr, 1221 xfs_dir2_data_freeinsert(hdr,
1220 dp->d_ops->data_bestfree_p(hdr), 1222 dp->d_ops->data_bestfree_p(hdr),
1221 dup, &dummy); 1223 dup, &dummy);
@@ -1232,7 +1234,7 @@ xfs_dir2_sf_to_block(
1232 memcpy(dep->name, sfep->name, dep->namelen); 1234 memcpy(dep->name, sfep->name, dep->namelen);
1233 tagp = dp->d_ops->data_entry_tag_p(dep); 1235 tagp = dp->d_ops->data_entry_tag_p(dep);
1234 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 1236 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
1235 xfs_dir2_data_log_entry(tp, dp, bp, dep); 1237 xfs_dir2_data_log_entry(args, bp, dep);
1236 name.name = sfep->name; 1238 name.name = sfep->name;
1237 name.len = sfep->namelen; 1239 name.len = sfep->namelen;
1238 blp[2 + i].hashval = cpu_to_be32(mp->m_dirnameops-> 1240 blp[2 + i].hashval = cpu_to_be32(mp->m_dirnameops->
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index bae8b5b8d1c2..8c2f6422648e 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -63,8 +63,10 @@ __xfs_dir3_data_check(
63 int stale; /* count of stale leaves */ 63 int stale; /* count of stale leaves */
64 struct xfs_name name; 64 struct xfs_name name;
65 const struct xfs_dir_ops *ops; 65 const struct xfs_dir_ops *ops;
66 struct xfs_da_geometry *geo;
66 67
67 mp = bp->b_target->bt_mount; 68 mp = bp->b_target->bt_mount;
69 geo = mp->m_dir_geo;
68 70
69 /* 71 /*
70 * We can be passed a null dp here from a verifier, so we need to go the 72 * We can be passed a null dp here from a verifier, so we need to go the
@@ -78,7 +80,7 @@ __xfs_dir3_data_check(
78 switch (hdr->magic) { 80 switch (hdr->magic) {
79 case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC): 81 case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC):
80 case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC): 82 case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC):
81 btp = xfs_dir2_block_tail_p(mp, hdr); 83 btp = xfs_dir2_block_tail_p(geo, hdr);
82 lep = xfs_dir2_block_leaf_p(btp); 84 lep = xfs_dir2_block_leaf_p(btp);
83 endp = (char *)lep; 85 endp = (char *)lep;
84 86
@@ -94,7 +96,7 @@ __xfs_dir3_data_check(
94 break; 96 break;
95 case cpu_to_be32(XFS_DIR3_DATA_MAGIC): 97 case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
96 case cpu_to_be32(XFS_DIR2_DATA_MAGIC): 98 case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
97 endp = (char *)hdr + mp->m_dirblksize; 99 endp = (char *)hdr + geo->blksize;
98 break; 100 break;
99 default: 101 default:
100 XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp); 102 XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp);
@@ -172,9 +174,9 @@ __xfs_dir3_data_check(
172 lastfree = 0; 174 lastfree = 0;
173 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 175 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
174 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { 176 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
175 addr = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 177 addr = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
176 (xfs_dir2_data_aoff_t) 178 (xfs_dir2_data_aoff_t)
177 ((char *)dep - (char *)hdr)); 179 ((char *)dep - (char *)hdr));
178 name.name = dep->name; 180 name.name = dep->name;
179 name.len = dep->namelen; 181 name.len = dep->namelen;
180 hash = mp->m_dirnameops->hashname(&name); 182 hash = mp->m_dirnameops->hashname(&name);
@@ -509,6 +511,7 @@ xfs_dir2_data_freescan(
509 struct xfs_dir2_data_free *bf; 511 struct xfs_dir2_data_free *bf;
510 char *endp; /* end of block's data */ 512 char *endp; /* end of block's data */
511 char *p; /* current entry pointer */ 513 char *p; /* current entry pointer */
514 struct xfs_da_geometry *geo = dp->i_mount->m_dir_geo;
512 515
513 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 516 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
514 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || 517 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
@@ -527,10 +530,10 @@ xfs_dir2_data_freescan(
527 p = (char *)dp->d_ops->data_entry_p(hdr); 530 p = (char *)dp->d_ops->data_entry_p(hdr);
528 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 531 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
529 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { 532 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
530 btp = xfs_dir2_block_tail_p(dp->i_mount, hdr); 533 btp = xfs_dir2_block_tail_p(geo, hdr);
531 endp = (char *)xfs_dir2_block_leaf_p(btp); 534 endp = (char *)xfs_dir2_block_leaf_p(btp);
532 } else 535 } else
533 endp = (char *)hdr + dp->i_mount->m_dirblksize; 536 endp = (char *)hdr + geo->blksize;
534 /* 537 /*
535 * Loop over the block's entries. 538 * Loop over the block's entries.
536 */ 539 */
@@ -584,8 +587,8 @@ xfs_dir3_data_init(
584 /* 587 /*
585 * Get the buffer set up for the block. 588 * Get the buffer set up for the block.
586 */ 589 */
587 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, blkno), -1, &bp, 590 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, blkno),
588 XFS_DATA_FORK); 591 -1, &bp, XFS_DATA_FORK);
589 if (error) 592 if (error)
590 return error; 593 return error;
591 bp->b_ops = &xfs_dir3_data_buf_ops; 594 bp->b_ops = &xfs_dir3_data_buf_ops;
@@ -620,15 +623,15 @@ xfs_dir3_data_init(
620 dup = dp->d_ops->data_unused_p(hdr); 623 dup = dp->d_ops->data_unused_p(hdr);
621 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); 624 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
622 625
623 t = mp->m_dirblksize - (uint)dp->d_ops->data_entry_offset; 626 t = args->geo->blksize - (uint)dp->d_ops->data_entry_offset;
624 bf[0].length = cpu_to_be16(t); 627 bf[0].length = cpu_to_be16(t);
625 dup->length = cpu_to_be16(t); 628 dup->length = cpu_to_be16(t);
626 *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr); 629 *xfs_dir2_data_unused_tag_p(dup) = cpu_to_be16((char *)dup - (char *)hdr);
627 /* 630 /*
628 * Log it and return it. 631 * Log it and return it.
629 */ 632 */
630 xfs_dir2_data_log_header(tp, dp, bp); 633 xfs_dir2_data_log_header(args, bp);
631 xfs_dir2_data_log_unused(tp, bp, dup); 634 xfs_dir2_data_log_unused(args, bp, dup);
632 *bpp = bp; 635 *bpp = bp;
633 return 0; 636 return 0;
634} 637}
@@ -638,8 +641,7 @@ xfs_dir3_data_init(
638 */ 641 */
639void 642void
640xfs_dir2_data_log_entry( 643xfs_dir2_data_log_entry(
641 struct xfs_trans *tp, 644 struct xfs_da_args *args,
642 struct xfs_inode *dp,
643 struct xfs_buf *bp, 645 struct xfs_buf *bp,
644 xfs_dir2_data_entry_t *dep) /* data entry pointer */ 646 xfs_dir2_data_entry_t *dep) /* data entry pointer */
645{ 647{
@@ -650,8 +652,8 @@ xfs_dir2_data_log_entry(
650 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 652 hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
651 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); 653 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
652 654
653 xfs_trans_log_buf(tp, bp, (uint)((char *)dep - (char *)hdr), 655 xfs_trans_log_buf(args->trans, bp, (uint)((char *)dep - (char *)hdr),
654 (uint)((char *)(dp->d_ops->data_entry_tag_p(dep) + 1) - 656 (uint)((char *)(args->dp->d_ops->data_entry_tag_p(dep) + 1) -
655 (char *)hdr - 1)); 657 (char *)hdr - 1));
656} 658}
657 659
@@ -660,8 +662,7 @@ xfs_dir2_data_log_entry(
660 */ 662 */
661void 663void
662xfs_dir2_data_log_header( 664xfs_dir2_data_log_header(
663 struct xfs_trans *tp, 665 struct xfs_da_args *args,
664 struct xfs_inode *dp,
665 struct xfs_buf *bp) 666 struct xfs_buf *bp)
666{ 667{
667#ifdef DEBUG 668#ifdef DEBUG
@@ -673,7 +674,8 @@ xfs_dir2_data_log_header(
673 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); 674 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
674#endif 675#endif
675 676
676 xfs_trans_log_buf(tp, bp, 0, dp->d_ops->data_entry_offset - 1); 677 xfs_trans_log_buf(args->trans, bp, 0,
678 args->dp->d_ops->data_entry_offset - 1);
677} 679}
678 680
679/* 681/*
@@ -681,7 +683,7 @@ xfs_dir2_data_log_header(
681 */ 683 */
682void 684void
683xfs_dir2_data_log_unused( 685xfs_dir2_data_log_unused(
684 struct xfs_trans *tp, 686 struct xfs_da_args *args,
685 struct xfs_buf *bp, 687 struct xfs_buf *bp,
686 xfs_dir2_data_unused_t *dup) /* data unused pointer */ 688 xfs_dir2_data_unused_t *dup) /* data unused pointer */
687{ 689{
@@ -695,13 +697,13 @@ xfs_dir2_data_log_unused(
695 /* 697 /*
696 * Log the first part of the unused entry. 698 * Log the first part of the unused entry.
697 */ 699 */
698 xfs_trans_log_buf(tp, bp, (uint)((char *)dup - (char *)hdr), 700 xfs_trans_log_buf(args->trans, bp, (uint)((char *)dup - (char *)hdr),
699 (uint)((char *)&dup->length + sizeof(dup->length) - 701 (uint)((char *)&dup->length + sizeof(dup->length) -
700 1 - (char *)hdr)); 702 1 - (char *)hdr));
701 /* 703 /*
702 * Log the end (tag) of the unused entry. 704 * Log the end (tag) of the unused entry.
703 */ 705 */
704 xfs_trans_log_buf(tp, bp, 706 xfs_trans_log_buf(args->trans, bp,
705 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr), 707 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr),
706 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr + 708 (uint)((char *)xfs_dir2_data_unused_tag_p(dup) - (char *)hdr +
707 sizeof(xfs_dir2_data_off_t) - 1)); 709 sizeof(xfs_dir2_data_off_t) - 1));
@@ -713,8 +715,7 @@ xfs_dir2_data_log_unused(
713 */ 715 */
714void 716void
715xfs_dir2_data_make_free( 717xfs_dir2_data_make_free(
716 struct xfs_trans *tp, 718 struct xfs_da_args *args,
717 struct xfs_inode *dp,
718 struct xfs_buf *bp, 719 struct xfs_buf *bp,
719 xfs_dir2_data_aoff_t offset, /* starting byte offset */ 720 xfs_dir2_data_aoff_t offset, /* starting byte offset */
720 xfs_dir2_data_aoff_t len, /* length in bytes */ 721 xfs_dir2_data_aoff_t len, /* length in bytes */
@@ -724,14 +725,12 @@ xfs_dir2_data_make_free(
724 xfs_dir2_data_hdr_t *hdr; /* data block pointer */ 725 xfs_dir2_data_hdr_t *hdr; /* data block pointer */
725 xfs_dir2_data_free_t *dfp; /* bestfree pointer */ 726 xfs_dir2_data_free_t *dfp; /* bestfree pointer */
726 char *endptr; /* end of data area */ 727 char *endptr; /* end of data area */
727 xfs_mount_t *mp; /* filesystem mount point */
728 int needscan; /* need to regen bestfree */ 728 int needscan; /* need to regen bestfree */
729 xfs_dir2_data_unused_t *newdup; /* new unused entry */ 729 xfs_dir2_data_unused_t *newdup; /* new unused entry */
730 xfs_dir2_data_unused_t *postdup; /* unused entry after us */ 730 xfs_dir2_data_unused_t *postdup; /* unused entry after us */
731 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ 731 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */
732 struct xfs_dir2_data_free *bf; 732 struct xfs_dir2_data_free *bf;
733 733
734 mp = tp->t_mountp;
735 hdr = bp->b_addr; 734 hdr = bp->b_addr;
736 735
737 /* 736 /*
@@ -739,20 +738,20 @@ xfs_dir2_data_make_free(
739 */ 738 */
740 if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 739 if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
741 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)) 740 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC))
742 endptr = (char *)hdr + mp->m_dirblksize; 741 endptr = (char *)hdr + args->geo->blksize;
743 else { 742 else {
744 xfs_dir2_block_tail_t *btp; /* block tail */ 743 xfs_dir2_block_tail_t *btp; /* block tail */
745 744
746 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 745 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
747 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); 746 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
748 btp = xfs_dir2_block_tail_p(mp, hdr); 747 btp = xfs_dir2_block_tail_p(args->geo, hdr);
749 endptr = (char *)xfs_dir2_block_leaf_p(btp); 748 endptr = (char *)xfs_dir2_block_leaf_p(btp);
750 } 749 }
751 /* 750 /*
752 * If this isn't the start of the block, then back up to 751 * If this isn't the start of the block, then back up to
753 * the previous entry and see if it's free. 752 * the previous entry and see if it's free.
754 */ 753 */
755 if (offset > dp->d_ops->data_entry_offset) { 754 if (offset > args->dp->d_ops->data_entry_offset) {
756 __be16 *tagp; /* tag just before us */ 755 __be16 *tagp; /* tag just before us */
757 756
758 tagp = (__be16 *)((char *)hdr + offset) - 1; 757 tagp = (__be16 *)((char *)hdr + offset) - 1;
@@ -778,7 +777,7 @@ xfs_dir2_data_make_free(
778 * Previous and following entries are both free, 777 * Previous and following entries are both free,
779 * merge everything into a single free entry. 778 * merge everything into a single free entry.
780 */ 779 */
781 bf = dp->d_ops->data_bestfree_p(hdr); 780 bf = args->dp->d_ops->data_bestfree_p(hdr);
782 if (prevdup && postdup) { 781 if (prevdup && postdup) {
783 xfs_dir2_data_free_t *dfp2; /* another bestfree pointer */ 782 xfs_dir2_data_free_t *dfp2; /* another bestfree pointer */
784 783
@@ -800,7 +799,7 @@ xfs_dir2_data_make_free(
800 be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length)); 799 be16_add_cpu(&prevdup->length, len + be16_to_cpu(postdup->length));
801 *xfs_dir2_data_unused_tag_p(prevdup) = 800 *xfs_dir2_data_unused_tag_p(prevdup) =
802 cpu_to_be16((char *)prevdup - (char *)hdr); 801 cpu_to_be16((char *)prevdup - (char *)hdr);
803 xfs_dir2_data_log_unused(tp, bp, prevdup); 802 xfs_dir2_data_log_unused(args, bp, prevdup);
804 if (!needscan) { 803 if (!needscan) {
805 /* 804 /*
806 * Has to be the case that entries 0 and 1 are 805 * Has to be the case that entries 0 and 1 are
@@ -835,7 +834,7 @@ xfs_dir2_data_make_free(
835 be16_add_cpu(&prevdup->length, len); 834 be16_add_cpu(&prevdup->length, len);
836 *xfs_dir2_data_unused_tag_p(prevdup) = 835 *xfs_dir2_data_unused_tag_p(prevdup) =
837 cpu_to_be16((char *)prevdup - (char *)hdr); 836 cpu_to_be16((char *)prevdup - (char *)hdr);
838 xfs_dir2_data_log_unused(tp, bp, prevdup); 837 xfs_dir2_data_log_unused(args, bp, prevdup);
839 /* 838 /*
840 * If the previous entry was in the table, the new entry 839 * If the previous entry was in the table, the new entry
841 * is longer, so it will be in the table too. Remove 840 * is longer, so it will be in the table too. Remove
@@ -863,7 +862,7 @@ xfs_dir2_data_make_free(
863 newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length)); 862 newdup->length = cpu_to_be16(len + be16_to_cpu(postdup->length));
864 *xfs_dir2_data_unused_tag_p(newdup) = 863 *xfs_dir2_data_unused_tag_p(newdup) =
865 cpu_to_be16((char *)newdup - (char *)hdr); 864 cpu_to_be16((char *)newdup - (char *)hdr);
866 xfs_dir2_data_log_unused(tp, bp, newdup); 865 xfs_dir2_data_log_unused(args, bp, newdup);
867 /* 866 /*
868 * If the following entry was in the table, the new entry 867 * If the following entry was in the table, the new entry
869 * is longer, so it will be in the table too. Remove 868 * is longer, so it will be in the table too. Remove
@@ -890,7 +889,7 @@ xfs_dir2_data_make_free(
890 newdup->length = cpu_to_be16(len); 889 newdup->length = cpu_to_be16(len);
891 *xfs_dir2_data_unused_tag_p(newdup) = 890 *xfs_dir2_data_unused_tag_p(newdup) =
892 cpu_to_be16((char *)newdup - (char *)hdr); 891 cpu_to_be16((char *)newdup - (char *)hdr);
893 xfs_dir2_data_log_unused(tp, bp, newdup); 892 xfs_dir2_data_log_unused(args, bp, newdup);
894 xfs_dir2_data_freeinsert(hdr, bf, newdup, needlogp); 893 xfs_dir2_data_freeinsert(hdr, bf, newdup, needlogp);
895 } 894 }
896 *needscanp = needscan; 895 *needscanp = needscan;
@@ -901,8 +900,7 @@ xfs_dir2_data_make_free(
901 */ 900 */
902void 901void
903xfs_dir2_data_use_free( 902xfs_dir2_data_use_free(
904 struct xfs_trans *tp, 903 struct xfs_da_args *args,
905 struct xfs_inode *dp,
906 struct xfs_buf *bp, 904 struct xfs_buf *bp,
907 xfs_dir2_data_unused_t *dup, /* unused entry */ 905 xfs_dir2_data_unused_t *dup, /* unused entry */
908 xfs_dir2_data_aoff_t offset, /* starting offset to use */ 906 xfs_dir2_data_aoff_t offset, /* starting offset to use */
@@ -933,7 +931,7 @@ xfs_dir2_data_use_free(
933 * Look up the entry in the bestfree table. 931 * Look up the entry in the bestfree table.
934 */ 932 */
935 oldlen = be16_to_cpu(dup->length); 933 oldlen = be16_to_cpu(dup->length);
936 bf = dp->d_ops->data_bestfree_p(hdr); 934 bf = args->dp->d_ops->data_bestfree_p(hdr);
937 dfp = xfs_dir2_data_freefind(hdr, bf, dup); 935 dfp = xfs_dir2_data_freefind(hdr, bf, dup);
938 ASSERT(dfp || oldlen <= be16_to_cpu(bf[2].length)); 936 ASSERT(dfp || oldlen <= be16_to_cpu(bf[2].length));
939 /* 937 /*
@@ -965,7 +963,7 @@ xfs_dir2_data_use_free(
965 newdup->length = cpu_to_be16(oldlen - len); 963 newdup->length = cpu_to_be16(oldlen - len);
966 *xfs_dir2_data_unused_tag_p(newdup) = 964 *xfs_dir2_data_unused_tag_p(newdup) =
967 cpu_to_be16((char *)newdup - (char *)hdr); 965 cpu_to_be16((char *)newdup - (char *)hdr);
968 xfs_dir2_data_log_unused(tp, bp, newdup); 966 xfs_dir2_data_log_unused(args, bp, newdup);
969 /* 967 /*
970 * If it was in the table, remove it and add the new one. 968 * If it was in the table, remove it and add the new one.
971 */ 969 */
@@ -993,7 +991,7 @@ xfs_dir2_data_use_free(
993 newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup); 991 newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup);
994 *xfs_dir2_data_unused_tag_p(newdup) = 992 *xfs_dir2_data_unused_tag_p(newdup) =
995 cpu_to_be16((char *)newdup - (char *)hdr); 993 cpu_to_be16((char *)newdup - (char *)hdr);
996 xfs_dir2_data_log_unused(tp, bp, newdup); 994 xfs_dir2_data_log_unused(args, bp, newdup);
997 /* 995 /*
998 * If it was in the table, remove it and add the new one. 996 * If it was in the table, remove it and add the new one.
999 */ 997 */
@@ -1021,13 +1019,13 @@ xfs_dir2_data_use_free(
1021 newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup); 1019 newdup->length = cpu_to_be16(((char *)hdr + offset) - (char *)newdup);
1022 *xfs_dir2_data_unused_tag_p(newdup) = 1020 *xfs_dir2_data_unused_tag_p(newdup) =
1023 cpu_to_be16((char *)newdup - (char *)hdr); 1021 cpu_to_be16((char *)newdup - (char *)hdr);
1024 xfs_dir2_data_log_unused(tp, bp, newdup); 1022 xfs_dir2_data_log_unused(args, bp, newdup);
1025 newdup2 = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len); 1023 newdup2 = (xfs_dir2_data_unused_t *)((char *)hdr + offset + len);
1026 newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); 1024 newdup2->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
1027 newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length)); 1025 newdup2->length = cpu_to_be16(oldlen - len - be16_to_cpu(newdup->length));
1028 *xfs_dir2_data_unused_tag_p(newdup2) = 1026 *xfs_dir2_data_unused_tag_p(newdup2) =
1029 cpu_to_be16((char *)newdup2 - (char *)hdr); 1027 cpu_to_be16((char *)newdup2 - (char *)hdr);
1030 xfs_dir2_data_log_unused(tp, bp, newdup2); 1028 xfs_dir2_data_log_unused(args, bp, newdup2);
1031 /* 1029 /*
1032 * If the old entry was in the table, we need to scan 1030 * If the old entry was in the table, we need to scan
1033 * if the 3rd entry was valid, since these entries 1031 * if the 3rd entry was valid, since these entries
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index f571723e2378..fb0aad4440c1 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -41,9 +41,10 @@
41 */ 41 */
42static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, struct xfs_buf **lbpp, 42static int xfs_dir2_leaf_lookup_int(xfs_da_args_t *args, struct xfs_buf **lbpp,
43 int *indexp, struct xfs_buf **dbpp); 43 int *indexp, struct xfs_buf **dbpp);
44static void xfs_dir3_leaf_log_bests(struct xfs_trans *tp, struct xfs_buf *bp, 44static void xfs_dir3_leaf_log_bests(struct xfs_da_args *args,
45 int first, int last); 45 struct xfs_buf *bp, int first, int last);
46static void xfs_dir3_leaf_log_tail(struct xfs_trans *tp, struct xfs_buf *bp); 46static void xfs_dir3_leaf_log_tail(struct xfs_da_args *args,
47 struct xfs_buf *bp);
47 48
48/* 49/*
49 * Check the internal consistency of a leaf1 block. 50 * Check the internal consistency of a leaf1 block.
@@ -92,6 +93,7 @@ xfs_dir3_leaf_check_int(
92 int i; 93 int i;
93 const struct xfs_dir_ops *ops; 94 const struct xfs_dir_ops *ops;
94 struct xfs_dir3_icleaf_hdr leafhdr; 95 struct xfs_dir3_icleaf_hdr leafhdr;
96 struct xfs_da_geometry *geo = mp->m_dir_geo;
95 97
96 /* 98 /*
97 * we can be passed a null dp here from a verifier, so we need to go the 99 * we can be passed a null dp here from a verifier, so we need to go the
@@ -105,14 +107,14 @@ xfs_dir3_leaf_check_int(
105 } 107 }
106 108
107 ents = ops->leaf_ents_p(leaf); 109 ents = ops->leaf_ents_p(leaf);
108 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 110 ltp = xfs_dir2_leaf_tail_p(geo, leaf);
109 111
110 /* 112 /*
111 * XXX (dgc): This value is not restrictive enough. 113 * XXX (dgc): This value is not restrictive enough.
112 * Should factor in the size of the bests table as well. 114 * Should factor in the size of the bests table as well.
113 * We can deduce a value for that from di_size. 115 * We can deduce a value for that from di_size.
114 */ 116 */
115 if (hdr->count > ops->leaf_max_ents(mp)) 117 if (hdr->count > ops->leaf_max_ents(geo))
116 return false; 118 return false;
117 119
118 /* Leaves and bests don't overlap in leaf format. */ 120 /* Leaves and bests don't overlap in leaf format. */
@@ -323,7 +325,7 @@ xfs_dir3_leaf_init(
323 if (type == XFS_DIR2_LEAF1_MAGIC) { 325 if (type == XFS_DIR2_LEAF1_MAGIC) {
324 struct xfs_dir2_leaf_tail *ltp; 326 struct xfs_dir2_leaf_tail *ltp;
325 327
326 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 328 ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
327 ltp->bestcount = 0; 329 ltp->bestcount = 0;
328 bp->b_ops = &xfs_dir3_leaf1_buf_ops; 330 bp->b_ops = &xfs_dir3_leaf1_buf_ops;
329 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF); 331 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF);
@@ -347,18 +349,18 @@ xfs_dir3_leaf_get_buf(
347 int error; 349 int error;
348 350
349 ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC); 351 ASSERT(magic == XFS_DIR2_LEAF1_MAGIC || magic == XFS_DIR2_LEAFN_MAGIC);
350 ASSERT(bno >= XFS_DIR2_LEAF_FIRSTDB(mp) && 352 ASSERT(bno >= xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET) &&
351 bno < XFS_DIR2_FREE_FIRSTDB(mp)); 353 bno < xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
352 354
353 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, bno), -1, &bp, 355 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, bno),
354 XFS_DATA_FORK); 356 -1, &bp, XFS_DATA_FORK);
355 if (error) 357 if (error)
356 return error; 358 return error;
357 359
358 xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic); 360 xfs_dir3_leaf_init(mp, tp, bp, dp->i_ino, magic);
359 xfs_dir3_leaf_log_header(tp, dp, bp); 361 xfs_dir3_leaf_log_header(args, bp);
360 if (magic == XFS_DIR2_LEAF1_MAGIC) 362 if (magic == XFS_DIR2_LEAF1_MAGIC)
361 xfs_dir3_leaf_log_tail(tp, bp); 363 xfs_dir3_leaf_log_tail(args, bp);
362 *bpp = bp; 364 *bpp = bp;
363 return 0; 365 return 0;
364} 366}
@@ -403,8 +405,8 @@ xfs_dir2_block_to_leaf(
403 if ((error = xfs_da_grow_inode(args, &blkno))) { 405 if ((error = xfs_da_grow_inode(args, &blkno))) {
404 return error; 406 return error;
405 } 407 }
406 ldb = xfs_dir2_da_to_db(mp, blkno); 408 ldb = xfs_dir2_da_to_db(args->geo, blkno);
407 ASSERT(ldb == XFS_DIR2_LEAF_FIRSTDB(mp)); 409 ASSERT(ldb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_LEAF_OFFSET));
408 /* 410 /*
409 * Initialize the leaf block, get a buffer for it. 411 * Initialize the leaf block, get a buffer for it.
410 */ 412 */
@@ -415,7 +417,7 @@ xfs_dir2_block_to_leaf(
415 leaf = lbp->b_addr; 417 leaf = lbp->b_addr;
416 hdr = dbp->b_addr; 418 hdr = dbp->b_addr;
417 xfs_dir3_data_check(dp, dbp); 419 xfs_dir3_data_check(dp, dbp);
418 btp = xfs_dir2_block_tail_p(mp, hdr); 420 btp = xfs_dir2_block_tail_p(args->geo, hdr);
419 blp = xfs_dir2_block_leaf_p(btp); 421 blp = xfs_dir2_block_leaf_p(btp);
420 bf = dp->d_ops->data_bestfree_p(hdr); 422 bf = dp->d_ops->data_bestfree_p(hdr);
421 ents = dp->d_ops->leaf_ents_p(leaf); 423 ents = dp->d_ops->leaf_ents_p(leaf);
@@ -427,23 +429,23 @@ xfs_dir2_block_to_leaf(
427 leafhdr.count = be32_to_cpu(btp->count); 429 leafhdr.count = be32_to_cpu(btp->count);
428 leafhdr.stale = be32_to_cpu(btp->stale); 430 leafhdr.stale = be32_to_cpu(btp->stale);
429 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 431 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
430 xfs_dir3_leaf_log_header(tp, dp, lbp); 432 xfs_dir3_leaf_log_header(args, lbp);
431 433
432 /* 434 /*
433 * Could compact these but I think we always do the conversion 435 * Could compact these but I think we always do the conversion
434 * after squeezing out stale entries. 436 * after squeezing out stale entries.
435 */ 437 */
436 memcpy(ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t)); 438 memcpy(ents, blp, be32_to_cpu(btp->count) * sizeof(xfs_dir2_leaf_entry_t));
437 xfs_dir3_leaf_log_ents(tp, dp, lbp, 0, leafhdr.count - 1); 439 xfs_dir3_leaf_log_ents(args, lbp, 0, leafhdr.count - 1);
438 needscan = 0; 440 needscan = 0;
439 needlog = 1; 441 needlog = 1;
440 /* 442 /*
441 * Make the space formerly occupied by the leaf entries and block 443 * Make the space formerly occupied by the leaf entries and block
442 * tail be free. 444 * tail be free.
443 */ 445 */
444 xfs_dir2_data_make_free(tp, dp, dbp, 446 xfs_dir2_data_make_free(args, dbp,
445 (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), 447 (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
446 (xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize - 448 (xfs_dir2_data_aoff_t)((char *)hdr + args->geo->blksize -
447 (char *)blp), 449 (char *)blp),
448 &needlog, &needscan); 450 &needlog, &needscan);
449 /* 451 /*
@@ -461,7 +463,7 @@ xfs_dir2_block_to_leaf(
461 /* 463 /*
462 * Set up leaf tail and bests table. 464 * Set up leaf tail and bests table.
463 */ 465 */
464 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 466 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
465 ltp->bestcount = cpu_to_be32(1); 467 ltp->bestcount = cpu_to_be32(1);
466 bestsp = xfs_dir2_leaf_bests_p(ltp); 468 bestsp = xfs_dir2_leaf_bests_p(ltp);
467 bestsp[0] = bf[0].length; 469 bestsp[0] = bf[0].length;
@@ -469,10 +471,10 @@ xfs_dir2_block_to_leaf(
469 * Log the data header and leaf bests table. 471 * Log the data header and leaf bests table.
470 */ 472 */
471 if (needlog) 473 if (needlog)
472 xfs_dir2_data_log_header(tp, dp, dbp); 474 xfs_dir2_data_log_header(args, dbp);
473 xfs_dir3_leaf_check(dp, lbp); 475 xfs_dir3_leaf_check(dp, lbp);
474 xfs_dir3_data_check(dp, dbp); 476 xfs_dir3_data_check(dp, dbp);
475 xfs_dir3_leaf_log_bests(tp, lbp, 0, 0); 477 xfs_dir3_leaf_log_bests(args, lbp, 0, 0);
476 return 0; 478 return 0;
477} 479}
478 480
@@ -641,7 +643,7 @@ xfs_dir2_leaf_addname(
641 tp = args->trans; 643 tp = args->trans;
642 mp = dp->i_mount; 644 mp = dp->i_mount;
643 645
644 error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp); 646 error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
645 if (error) 647 if (error)
646 return error; 648 return error;
647 649
@@ -653,7 +655,7 @@ xfs_dir2_leaf_addname(
653 */ 655 */
654 index = xfs_dir2_leaf_search_hash(args, lbp); 656 index = xfs_dir2_leaf_search_hash(args, lbp);
655 leaf = lbp->b_addr; 657 leaf = lbp->b_addr;
656 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 658 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
657 ents = dp->d_ops->leaf_ents_p(leaf); 659 ents = dp->d_ops->leaf_ents_p(leaf);
658 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 660 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
659 bestsp = xfs_dir2_leaf_bests_p(ltp); 661 bestsp = xfs_dir2_leaf_bests_p(ltp);
@@ -670,7 +672,7 @@ xfs_dir2_leaf_addname(
670 index++, lep++) { 672 index++, lep++) {
671 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR) 673 if (be32_to_cpu(lep->address) == XFS_DIR2_NULL_DATAPTR)
672 continue; 674 continue;
673 i = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 675 i = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
674 ASSERT(i < be32_to_cpu(ltp->bestcount)); 676 ASSERT(i < be32_to_cpu(ltp->bestcount));
675 ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF)); 677 ASSERT(bestsp[i] != cpu_to_be16(NULLDATAOFF));
676 if (be16_to_cpu(bestsp[i]) >= length) { 678 if (be16_to_cpu(bestsp[i]) >= length) {
@@ -810,14 +812,15 @@ xfs_dir2_leaf_addname(
810 memmove(&bestsp[0], &bestsp[1], 812 memmove(&bestsp[0], &bestsp[1],
811 be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0])); 813 be32_to_cpu(ltp->bestcount) * sizeof(bestsp[0]));
812 be32_add_cpu(&ltp->bestcount, 1); 814 be32_add_cpu(&ltp->bestcount, 1);
813 xfs_dir3_leaf_log_tail(tp, lbp); 815 xfs_dir3_leaf_log_tail(args, lbp);
814 xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); 816 xfs_dir3_leaf_log_bests(args, lbp, 0,
817 be32_to_cpu(ltp->bestcount) - 1);
815 } 818 }
816 /* 819 /*
817 * If we're filling in a previously empty block just log it. 820 * If we're filling in a previously empty block just log it.
818 */ 821 */
819 else 822 else
820 xfs_dir3_leaf_log_bests(tp, lbp, use_block, use_block); 823 xfs_dir3_leaf_log_bests(args, lbp, use_block, use_block);
821 hdr = dbp->b_addr; 824 hdr = dbp->b_addr;
822 bf = dp->d_ops->data_bestfree_p(hdr); 825 bf = dp->d_ops->data_bestfree_p(hdr);
823 bestsp[use_block] = bf[0].length; 826 bestsp[use_block] = bf[0].length;
@@ -828,8 +831,8 @@ xfs_dir2_leaf_addname(
828 * Just read that one in. 831 * Just read that one in.
829 */ 832 */
830 error = xfs_dir3_data_read(tp, dp, 833 error = xfs_dir3_data_read(tp, dp,
831 xfs_dir2_db_to_da(mp, use_block), 834 xfs_dir2_db_to_da(args->geo, use_block),
832 -1, &dbp); 835 -1, &dbp);
833 if (error) { 836 if (error) {
834 xfs_trans_brelse(tp, lbp); 837 xfs_trans_brelse(tp, lbp);
835 return error; 838 return error;
@@ -848,7 +851,7 @@ xfs_dir2_leaf_addname(
848 /* 851 /*
849 * Mark the initial part of our freespace in use for the new entry. 852 * Mark the initial part of our freespace in use for the new entry.
850 */ 853 */
851 xfs_dir2_data_use_free(tp, dp, dbp, dup, 854 xfs_dir2_data_use_free(args, dbp, dup,
852 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, 855 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
853 &needlog, &needscan); 856 &needlog, &needscan);
854 /* 857 /*
@@ -870,8 +873,8 @@ xfs_dir2_leaf_addname(
870 * Need to log the data block's header. 873 * Need to log the data block's header.
871 */ 874 */
872 if (needlog) 875 if (needlog)
873 xfs_dir2_data_log_header(tp, dp, dbp); 876 xfs_dir2_data_log_header(args, dbp);
874 xfs_dir2_data_log_entry(tp, dp, dbp, dep); 877 xfs_dir2_data_log_entry(args, dbp, dep);
875 /* 878 /*
876 * If the bests table needs to be changed, do it. 879 * If the bests table needs to be changed, do it.
877 * Log the change unless we've already done that. 880 * Log the change unless we've already done that.
@@ -879,7 +882,7 @@ xfs_dir2_leaf_addname(
879 if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(bf[0].length)) { 882 if (be16_to_cpu(bestsp[use_block]) != be16_to_cpu(bf[0].length)) {
880 bestsp[use_block] = bf[0].length; 883 bestsp[use_block] = bf[0].length;
881 if (!grown) 884 if (!grown)
882 xfs_dir3_leaf_log_bests(tp, lbp, use_block, use_block); 885 xfs_dir3_leaf_log_bests(args, lbp, use_block, use_block);
883 } 886 }
884 887
885 lep = xfs_dir3_leaf_find_entry(&leafhdr, ents, index, compact, lowstale, 888 lep = xfs_dir3_leaf_find_entry(&leafhdr, ents, index, compact, lowstale,
@@ -889,14 +892,15 @@ xfs_dir2_leaf_addname(
889 * Fill in the new leaf entry. 892 * Fill in the new leaf entry.
890 */ 893 */
891 lep->hashval = cpu_to_be32(args->hashval); 894 lep->hashval = cpu_to_be32(args->hashval);
892 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, use_block, 895 lep->address = cpu_to_be32(
896 xfs_dir2_db_off_to_dataptr(args->geo, use_block,
893 be16_to_cpu(*tagp))); 897 be16_to_cpu(*tagp)));
894 /* 898 /*
895 * Log the leaf fields and give up the buffers. 899 * Log the leaf fields and give up the buffers.
896 */ 900 */
897 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 901 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
898 xfs_dir3_leaf_log_header(tp, dp, lbp); 902 xfs_dir3_leaf_log_header(args, lbp);
899 xfs_dir3_leaf_log_ents(tp, dp, lbp, lfloglow, lfloghigh); 903 xfs_dir3_leaf_log_ents(args, lbp, lfloglow, lfloghigh);
900 xfs_dir3_leaf_check(dp, lbp); 904 xfs_dir3_leaf_check(dp, lbp);
901 xfs_dir3_data_check(dp, dbp); 905 xfs_dir3_data_check(dp, dbp);
902 return 0; 906 return 0;
@@ -948,9 +952,9 @@ xfs_dir3_leaf_compact(
948 leafhdr->stale = 0; 952 leafhdr->stale = 0;
949 953
950 dp->d_ops->leaf_hdr_to_disk(leaf, leafhdr); 954 dp->d_ops->leaf_hdr_to_disk(leaf, leafhdr);
951 xfs_dir3_leaf_log_header(args->trans, dp, bp); 955 xfs_dir3_leaf_log_header(args, bp);
952 if (loglow != -1) 956 if (loglow != -1)
953 xfs_dir3_leaf_log_ents(args->trans, dp, bp, loglow, to - 1); 957 xfs_dir3_leaf_log_ents(args, bp, loglow, to - 1);
954} 958}
955 959
956/* 960/*
@@ -1052,7 +1056,7 @@ xfs_dir3_leaf_compact_x1(
1052 */ 1056 */
1053static void 1057static void
1054xfs_dir3_leaf_log_bests( 1058xfs_dir3_leaf_log_bests(
1055 xfs_trans_t *tp, /* transaction pointer */ 1059 struct xfs_da_args *args,
1056 struct xfs_buf *bp, /* leaf buffer */ 1060 struct xfs_buf *bp, /* leaf buffer */
1057 int first, /* first entry to log */ 1061 int first, /* first entry to log */
1058 int last) /* last entry to log */ 1062 int last) /* last entry to log */
@@ -1065,10 +1069,11 @@ xfs_dir3_leaf_log_bests(
1065 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1069 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1066 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC)); 1070 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC));
1067 1071
1068 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf); 1072 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1069 firstb = xfs_dir2_leaf_bests_p(ltp) + first; 1073 firstb = xfs_dir2_leaf_bests_p(ltp) + first;
1070 lastb = xfs_dir2_leaf_bests_p(ltp) + last; 1074 lastb = xfs_dir2_leaf_bests_p(ltp) + last;
1071 xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf), 1075 xfs_trans_log_buf(args->trans, bp,
1076 (uint)((char *)firstb - (char *)leaf),
1072 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1)); 1077 (uint)((char *)lastb - (char *)leaf + sizeof(*lastb) - 1));
1073} 1078}
1074 1079
@@ -1077,8 +1082,7 @@ xfs_dir3_leaf_log_bests(
1077 */ 1082 */
1078void 1083void
1079xfs_dir3_leaf_log_ents( 1084xfs_dir3_leaf_log_ents(
1080 struct xfs_trans *tp, 1085 struct xfs_da_args *args,
1081 struct xfs_inode *dp,
1082 struct xfs_buf *bp, 1086 struct xfs_buf *bp,
1083 int first, 1087 int first,
1084 int last) 1088 int last)
@@ -1093,10 +1097,11 @@ xfs_dir3_leaf_log_ents(
1093 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 1097 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
1094 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); 1098 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
1095 1099
1096 ents = dp->d_ops->leaf_ents_p(leaf); 1100 ents = args->dp->d_ops->leaf_ents_p(leaf);
1097 firstlep = &ents[first]; 1101 firstlep = &ents[first];
1098 lastlep = &ents[last]; 1102 lastlep = &ents[last];
1099 xfs_trans_log_buf(tp, bp, (uint)((char *)firstlep - (char *)leaf), 1103 xfs_trans_log_buf(args->trans, bp,
1104 (uint)((char *)firstlep - (char *)leaf),
1100 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1)); 1105 (uint)((char *)lastlep - (char *)leaf + sizeof(*lastlep) - 1));
1101} 1106}
1102 1107
@@ -1105,8 +1110,7 @@ xfs_dir3_leaf_log_ents(
1105 */ 1110 */
1106void 1111void
1107xfs_dir3_leaf_log_header( 1112xfs_dir3_leaf_log_header(
1108 struct xfs_trans *tp, 1113 struct xfs_da_args *args,
1109 struct xfs_inode *dp,
1110 struct xfs_buf *bp) 1114 struct xfs_buf *bp)
1111{ 1115{
1112 struct xfs_dir2_leaf *leaf = bp->b_addr; 1116 struct xfs_dir2_leaf *leaf = bp->b_addr;
@@ -1116,8 +1120,9 @@ xfs_dir3_leaf_log_header(
1116 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 1120 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
1117 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); 1121 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
1118 1122
1119 xfs_trans_log_buf(tp, bp, (uint)((char *)&leaf->hdr - (char *)leaf), 1123 xfs_trans_log_buf(args->trans, bp,
1120 dp->d_ops->leaf_hdr_size - 1); 1124 (uint)((char *)&leaf->hdr - (char *)leaf),
1125 args->dp->d_ops->leaf_hdr_size - 1);
1121} 1126}
1122 1127
1123/* 1128/*
@@ -1125,21 +1130,20 @@ xfs_dir3_leaf_log_header(
1125 */ 1130 */
1126STATIC void 1131STATIC void
1127xfs_dir3_leaf_log_tail( 1132xfs_dir3_leaf_log_tail(
1128 struct xfs_trans *tp, 1133 struct xfs_da_args *args,
1129 struct xfs_buf *bp) 1134 struct xfs_buf *bp)
1130{ 1135{
1131 struct xfs_dir2_leaf *leaf = bp->b_addr; 1136 struct xfs_dir2_leaf *leaf = bp->b_addr;
1132 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */ 1137 xfs_dir2_leaf_tail_t *ltp; /* leaf tail structure */
1133 struct xfs_mount *mp = tp->t_mountp;
1134 1138
1135 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1139 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1136 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) || 1140 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC) ||
1137 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 1141 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
1138 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); 1142 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
1139 1143
1140 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1144 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1141 xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), 1145 xfs_trans_log_buf(args->trans, bp, (uint)((char *)ltp - (char *)leaf),
1142 (uint)(mp->m_dirblksize - 1)); 1146 (uint)(args->geo->blksize - 1));
1143} 1147}
1144 1148
1145/* 1149/*
@@ -1185,7 +1189,7 @@ xfs_dir2_leaf_lookup(
1185 */ 1189 */
1186 dep = (xfs_dir2_data_entry_t *) 1190 dep = (xfs_dir2_data_entry_t *)
1187 ((char *)dbp->b_addr + 1191 ((char *)dbp->b_addr +
1188 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1192 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1189 /* 1193 /*
1190 * Return the found inode number & CI name if appropriate 1194 * Return the found inode number & CI name if appropriate
1191 */ 1195 */
@@ -1231,7 +1235,7 @@ xfs_dir2_leaf_lookup_int(
1231 tp = args->trans; 1235 tp = args->trans;
1232 mp = dp->i_mount; 1236 mp = dp->i_mount;
1233 1237
1234 error = xfs_dir3_leaf_read(tp, dp, mp->m_dirleafblk, -1, &lbp); 1238 error = xfs_dir3_leaf_read(tp, dp, args->geo->leafblk, -1, &lbp);
1235 if (error) 1239 if (error)
1236 return error; 1240 return error;
1237 1241
@@ -1260,7 +1264,8 @@ xfs_dir2_leaf_lookup_int(
1260 /* 1264 /*
1261 * Get the new data block number. 1265 * Get the new data block number.
1262 */ 1266 */
1263 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1267 newdb = xfs_dir2_dataptr_to_db(args->geo,
1268 be32_to_cpu(lep->address));
1264 /* 1269 /*
1265 * If it's not the same as the old data block number, 1270 * If it's not the same as the old data block number,
1266 * need to pitch the old one and read the new one. 1271 * need to pitch the old one and read the new one.
@@ -1269,8 +1274,8 @@ xfs_dir2_leaf_lookup_int(
1269 if (dbp) 1274 if (dbp)
1270 xfs_trans_brelse(tp, dbp); 1275 xfs_trans_brelse(tp, dbp);
1271 error = xfs_dir3_data_read(tp, dp, 1276 error = xfs_dir3_data_read(tp, dp,
1272 xfs_dir2_db_to_da(mp, newdb), 1277 xfs_dir2_db_to_da(args->geo, newdb),
1273 -1, &dbp); 1278 -1, &dbp);
1274 if (error) { 1279 if (error) {
1275 xfs_trans_brelse(tp, lbp); 1280 xfs_trans_brelse(tp, lbp);
1276 return error; 1281 return error;
@@ -1281,7 +1286,8 @@ xfs_dir2_leaf_lookup_int(
1281 * Point to the data entry. 1286 * Point to the data entry.
1282 */ 1287 */
1283 dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr + 1288 dep = (xfs_dir2_data_entry_t *)((char *)dbp->b_addr +
1284 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 1289 xfs_dir2_dataptr_to_off(args->geo,
1290 be32_to_cpu(lep->address)));
1285 /* 1291 /*
1286 * Compare name and if it's an exact match, return the index 1292 * Compare name and if it's an exact match, return the index
1287 * and buffer. If it's the first case-insensitive match, store 1293 * and buffer. If it's the first case-insensitive match, store
@@ -1310,8 +1316,8 @@ xfs_dir2_leaf_lookup_int(
1310 if (cidb != curdb) { 1316 if (cidb != curdb) {
1311 xfs_trans_brelse(tp, dbp); 1317 xfs_trans_brelse(tp, dbp);
1312 error = xfs_dir3_data_read(tp, dp, 1318 error = xfs_dir3_data_read(tp, dp,
1313 xfs_dir2_db_to_da(mp, cidb), 1319 xfs_dir2_db_to_da(args->geo, cidb),
1314 -1, &dbp); 1320 -1, &dbp);
1315 if (error) { 1321 if (error) {
1316 xfs_trans_brelse(tp, lbp); 1322 xfs_trans_brelse(tp, lbp);
1317 return error; 1323 return error;
@@ -1380,18 +1386,18 @@ xfs_dir2_leaf_removename(
1380 * Point to the leaf entry, use that to point to the data entry. 1386 * Point to the leaf entry, use that to point to the data entry.
1381 */ 1387 */
1382 lep = &ents[index]; 1388 lep = &ents[index];
1383 db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1389 db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
1384 dep = (xfs_dir2_data_entry_t *) 1390 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
1385 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 1391 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1386 needscan = needlog = 0; 1392 needscan = needlog = 0;
1387 oldbest = be16_to_cpu(bf[0].length); 1393 oldbest = be16_to_cpu(bf[0].length);
1388 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1394 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1389 bestsp = xfs_dir2_leaf_bests_p(ltp); 1395 bestsp = xfs_dir2_leaf_bests_p(ltp);
1390 ASSERT(be16_to_cpu(bestsp[db]) == oldbest); 1396 ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
1391 /* 1397 /*
1392 * Mark the former data entry unused. 1398 * Mark the former data entry unused.
1393 */ 1399 */
1394 xfs_dir2_data_make_free(tp, dp, dbp, 1400 xfs_dir2_data_make_free(args, dbp,
1395 (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr), 1401 (xfs_dir2_data_aoff_t)((char *)dep - (char *)hdr),
1396 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); 1402 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
1397 /* 1403 /*
@@ -1399,10 +1405,10 @@ xfs_dir2_leaf_removename(
1399 */ 1405 */
1400 leafhdr.stale++; 1406 leafhdr.stale++;
1401 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 1407 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1402 xfs_dir3_leaf_log_header(tp, dp, lbp); 1408 xfs_dir3_leaf_log_header(args, lbp);
1403 1409
1404 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); 1410 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
1405 xfs_dir3_leaf_log_ents(tp, dp, lbp, index, index); 1411 xfs_dir3_leaf_log_ents(args, lbp, index, index);
1406 1412
1407 /* 1413 /*
1408 * Scan the freespace in the data block again if necessary, 1414 * Scan the freespace in the data block again if necessary,
@@ -1411,22 +1417,22 @@ xfs_dir2_leaf_removename(
1411 if (needscan) 1417 if (needscan)
1412 xfs_dir2_data_freescan(dp, hdr, &needlog); 1418 xfs_dir2_data_freescan(dp, hdr, &needlog);
1413 if (needlog) 1419 if (needlog)
1414 xfs_dir2_data_log_header(tp, dp, dbp); 1420 xfs_dir2_data_log_header(args, dbp);
1415 /* 1421 /*
1416 * If the longest freespace in the data block has changed, 1422 * If the longest freespace in the data block has changed,
1417 * put the new value in the bests table and log that. 1423 * put the new value in the bests table and log that.
1418 */ 1424 */
1419 if (be16_to_cpu(bf[0].length) != oldbest) { 1425 if (be16_to_cpu(bf[0].length) != oldbest) {
1420 bestsp[db] = bf[0].length; 1426 bestsp[db] = bf[0].length;
1421 xfs_dir3_leaf_log_bests(tp, lbp, db, db); 1427 xfs_dir3_leaf_log_bests(args, lbp, db, db);
1422 } 1428 }
1423 xfs_dir3_data_check(dp, dbp); 1429 xfs_dir3_data_check(dp, dbp);
1424 /* 1430 /*
1425 * If the data block is now empty then get rid of the data block. 1431 * If the data block is now empty then get rid of the data block.
1426 */ 1432 */
1427 if (be16_to_cpu(bf[0].length) == 1433 if (be16_to_cpu(bf[0].length) ==
1428 mp->m_dirblksize - dp->d_ops->data_entry_offset) { 1434 args->geo->blksize - dp->d_ops->data_entry_offset) {
1429 ASSERT(db != mp->m_dirdatablk); 1435 ASSERT(db != args->geo->datablk);
1430 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { 1436 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1431 /* 1437 /*
1432 * Nope, can't get rid of it because it caused 1438 * Nope, can't get rid of it because it caused
@@ -1459,15 +1465,16 @@ xfs_dir2_leaf_removename(
1459 memmove(&bestsp[db - i], bestsp, 1465 memmove(&bestsp[db - i], bestsp,
1460 (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp)); 1466 (be32_to_cpu(ltp->bestcount) - (db - i)) * sizeof(*bestsp));
1461 be32_add_cpu(&ltp->bestcount, -(db - i)); 1467 be32_add_cpu(&ltp->bestcount, -(db - i));
1462 xfs_dir3_leaf_log_tail(tp, lbp); 1468 xfs_dir3_leaf_log_tail(args, lbp);
1463 xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); 1469 xfs_dir3_leaf_log_bests(args, lbp, 0,
1470 be32_to_cpu(ltp->bestcount) - 1);
1464 } else 1471 } else
1465 bestsp[db] = cpu_to_be16(NULLDATAOFF); 1472 bestsp[db] = cpu_to_be16(NULLDATAOFF);
1466 } 1473 }
1467 /* 1474 /*
1468 * If the data block was not the first one, drop it. 1475 * If the data block was not the first one, drop it.
1469 */ 1476 */
1470 else if (db != mp->m_dirdatablk) 1477 else if (db != args->geo->datablk)
1471 dbp = NULL; 1478 dbp = NULL;
1472 1479
1473 xfs_dir3_leaf_check(dp, lbp); 1480 xfs_dir3_leaf_check(dp, lbp);
@@ -1515,7 +1522,7 @@ xfs_dir2_leaf_replace(
1515 */ 1522 */
1516 dep = (xfs_dir2_data_entry_t *) 1523 dep = (xfs_dir2_data_entry_t *)
1517 ((char *)dbp->b_addr + 1524 ((char *)dbp->b_addr +
1518 xfs_dir2_dataptr_to_off(dp->i_mount, be32_to_cpu(lep->address))); 1525 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1519 ASSERT(args->inumber != be64_to_cpu(dep->inumber)); 1526 ASSERT(args->inumber != be64_to_cpu(dep->inumber));
1520 /* 1527 /*
1521 * Put the new inode number in, log it. 1528 * Put the new inode number in, log it.
@@ -1523,7 +1530,7 @@ xfs_dir2_leaf_replace(
1523 dep->inumber = cpu_to_be64(args->inumber); 1530 dep->inumber = cpu_to_be64(args->inumber);
1524 dp->d_ops->data_put_ftype(dep, args->filetype); 1531 dp->d_ops->data_put_ftype(dep, args->filetype);
1525 tp = args->trans; 1532 tp = args->trans;
1526 xfs_dir2_data_log_entry(tp, dp, dbp, dep); 1533 xfs_dir2_data_log_entry(args, dbp, dep);
1527 xfs_dir3_leaf_check(dp, lbp); 1534 xfs_dir3_leaf_check(dp, lbp);
1528 xfs_trans_brelse(tp, lbp); 1535 xfs_trans_brelse(tp, lbp);
1529 return 0; 1536 return 0;
@@ -1609,12 +1616,13 @@ xfs_dir2_leaf_trim_data(
1609 /* 1616 /*
1610 * Read the offending data block. We need its buffer. 1617 * Read the offending data block. We need its buffer.
1611 */ 1618 */
1612 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, db), -1, &dbp); 1619 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(args->geo, db),
1620 -1, &dbp);
1613 if (error) 1621 if (error)
1614 return error; 1622 return error;
1615 1623
1616 leaf = lbp->b_addr; 1624 leaf = lbp->b_addr;
1617 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1625 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1618 1626
1619#ifdef DEBUG 1627#ifdef DEBUG
1620{ 1628{
@@ -1624,7 +1632,7 @@ xfs_dir2_leaf_trim_data(
1624 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 1632 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
1625 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); 1633 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
1626 ASSERT(be16_to_cpu(bf[0].length) == 1634 ASSERT(be16_to_cpu(bf[0].length) ==
1627 mp->m_dirblksize - dp->d_ops->data_entry_offset); 1635 args->geo->blksize - dp->d_ops->data_entry_offset);
1628 ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); 1636 ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
1629} 1637}
1630#endif 1638#endif
@@ -1643,8 +1651,8 @@ xfs_dir2_leaf_trim_data(
1643 bestsp = xfs_dir2_leaf_bests_p(ltp); 1651 bestsp = xfs_dir2_leaf_bests_p(ltp);
1644 be32_add_cpu(&ltp->bestcount, -1); 1652 be32_add_cpu(&ltp->bestcount, -1);
1645 memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp)); 1653 memmove(&bestsp[1], &bestsp[0], be32_to_cpu(ltp->bestcount) * sizeof(*bestsp));
1646 xfs_dir3_leaf_log_tail(tp, lbp); 1654 xfs_dir3_leaf_log_tail(args, lbp);
1647 xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); 1655 xfs_dir3_leaf_log_bests(args, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
1648 return 0; 1656 return 0;
1649} 1657}
1650 1658
@@ -1711,19 +1719,19 @@ xfs_dir2_node_to_leaf(
1711 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) { 1719 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) {
1712 return error; 1720 return error;
1713 } 1721 }
1714 fo -= mp->m_dirblkfsbs; 1722 fo -= args->geo->fsbcount;
1715 /* 1723 /*
1716 * If there are freespace blocks other than the first one, 1724 * If there are freespace blocks other than the first one,
1717 * take this opportunity to remove trailing empty freespace blocks 1725 * take this opportunity to remove trailing empty freespace blocks
1718 * that may have been left behind during no-space-reservation 1726 * that may have been left behind during no-space-reservation
1719 * operations. 1727 * operations.
1720 */ 1728 */
1721 while (fo > mp->m_dirfreeblk) { 1729 while (fo > args->geo->freeblk) {
1722 if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) { 1730 if ((error = xfs_dir2_node_trim_free(args, fo, &rval))) {
1723 return error; 1731 return error;
1724 } 1732 }
1725 if (rval) 1733 if (rval)
1726 fo -= mp->m_dirblkfsbs; 1734 fo -= args->geo->fsbcount;
1727 else 1735 else
1728 return 0; 1736 return 0;
1729 } 1737 }
@@ -1736,7 +1744,7 @@ xfs_dir2_node_to_leaf(
1736 /* 1744 /*
1737 * If it's not the single leaf block, give up. 1745 * If it's not the single leaf block, give up.
1738 */ 1746 */
1739 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize) 1747 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + args->geo->blksize)
1740 return 0; 1748 return 0;
1741 lbp = state->path.blk[0].bp; 1749 lbp = state->path.blk[0].bp;
1742 leaf = lbp->b_addr; 1750 leaf = lbp->b_addr;
@@ -1748,7 +1756,7 @@ xfs_dir2_node_to_leaf(
1748 /* 1756 /*
1749 * Read the freespace block. 1757 * Read the freespace block.
1750 */ 1758 */
1751 error = xfs_dir2_free_read(tp, dp, mp->m_dirfreeblk, &fbp); 1759 error = xfs_dir2_free_read(tp, dp, args->geo->freeblk, &fbp);
1752 if (error) 1760 if (error)
1753 return error; 1761 return error;
1754 free = fbp->b_addr; 1762 free = fbp->b_addr;
@@ -1760,7 +1768,7 @@ xfs_dir2_node_to_leaf(
1760 * Now see if the leafn and free data will fit in a leaf1. 1768 * Now see if the leafn and free data will fit in a leaf1.
1761 * If not, release the buffer and give up. 1769 * If not, release the buffer and give up.
1762 */ 1770 */
1763 if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > mp->m_dirblksize) { 1771 if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > args->geo->blksize) {
1764 xfs_trans_brelse(tp, fbp); 1772 xfs_trans_brelse(tp, fbp);
1765 return 0; 1773 return 0;
1766 } 1774 }
@@ -1780,7 +1788,7 @@ xfs_dir2_node_to_leaf(
1780 /* 1788 /*
1781 * Set up the leaf tail from the freespace block. 1789 * Set up the leaf tail from the freespace block.
1782 */ 1790 */
1783 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1791 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1784 ltp->bestcount = cpu_to_be32(freehdr.nvalid); 1792 ltp->bestcount = cpu_to_be32(freehdr.nvalid);
1785 1793
1786 /* 1794 /*
@@ -1790,15 +1798,17 @@ xfs_dir2_node_to_leaf(
1790 freehdr.nvalid * sizeof(xfs_dir2_data_off_t)); 1798 freehdr.nvalid * sizeof(xfs_dir2_data_off_t));
1791 1799
1792 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 1800 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1793 xfs_dir3_leaf_log_header(tp, dp, lbp); 1801 xfs_dir3_leaf_log_header(args, lbp);
1794 xfs_dir3_leaf_log_bests(tp, lbp, 0, be32_to_cpu(ltp->bestcount) - 1); 1802 xfs_dir3_leaf_log_bests(args, lbp, 0, be32_to_cpu(ltp->bestcount) - 1);
1795 xfs_dir3_leaf_log_tail(tp, lbp); 1803 xfs_dir3_leaf_log_tail(args, lbp);
1796 xfs_dir3_leaf_check(dp, lbp); 1804 xfs_dir3_leaf_check(dp, lbp);
1797 1805
1798 /* 1806 /*
1799 * Get rid of the freespace block. 1807 * Get rid of the freespace block.
1800 */ 1808 */
1801 error = xfs_dir2_shrink_inode(args, XFS_DIR2_FREE_FIRSTDB(mp), fbp); 1809 error = xfs_dir2_shrink_inode(args,
1810 xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET),
1811 fbp);
1802 if (error) { 1812 if (error) {
1803 /* 1813 /*
1804 * This can't fail here because it can only happen when 1814 * This can't fail here because it can only happen when
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 9cb91ee0914b..da43d304fca2 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -195,17 +195,18 @@ xfs_dir2_free_try_read(
195 195
196static int 196static int
197xfs_dir3_free_get_buf( 197xfs_dir3_free_get_buf(
198 struct xfs_trans *tp, 198 xfs_da_args_t *args,
199 struct xfs_inode *dp,
200 xfs_dir2_db_t fbno, 199 xfs_dir2_db_t fbno,
201 struct xfs_buf **bpp) 200 struct xfs_buf **bpp)
202{ 201{
202 struct xfs_trans *tp = args->trans;
203 struct xfs_inode *dp = args->dp;
203 struct xfs_mount *mp = dp->i_mount; 204 struct xfs_mount *mp = dp->i_mount;
204 struct xfs_buf *bp; 205 struct xfs_buf *bp;
205 int error; 206 int error;
206 struct xfs_dir3_icfree_hdr hdr; 207 struct xfs_dir3_icfree_hdr hdr;
207 208
208 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(mp, fbno), 209 error = xfs_da_get_buf(tp, dp, xfs_dir2_db_to_da(args->geo, fbno),
209 -1, &bp, XFS_DATA_FORK); 210 -1, &bp, XFS_DATA_FORK);
210 if (error) 211 if (error)
211 return error; 212 return error;
@@ -240,8 +241,7 @@ xfs_dir3_free_get_buf(
240 */ 241 */
241STATIC void 242STATIC void
242xfs_dir2_free_log_bests( 243xfs_dir2_free_log_bests(
243 struct xfs_trans *tp, 244 struct xfs_da_args *args,
244 struct xfs_inode *dp,
245 struct xfs_buf *bp, 245 struct xfs_buf *bp,
246 int first, /* first entry to log */ 246 int first, /* first entry to log */
247 int last) /* last entry to log */ 247 int last) /* last entry to log */
@@ -250,10 +250,10 @@ xfs_dir2_free_log_bests(
250 __be16 *bests; 250 __be16 *bests;
251 251
252 free = bp->b_addr; 252 free = bp->b_addr;
253 bests = dp->d_ops->free_bests_p(free); 253 bests = args->dp->d_ops->free_bests_p(free);
254 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 254 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
255 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 255 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
256 xfs_trans_log_buf(tp, bp, 256 xfs_trans_log_buf(args->trans, bp,
257 (uint)((char *)&bests[first] - (char *)free), 257 (uint)((char *)&bests[first] - (char *)free),
258 (uint)((char *)&bests[last] - (char *)free + 258 (uint)((char *)&bests[last] - (char *)free +
259 sizeof(bests[0]) - 1)); 259 sizeof(bests[0]) - 1));
@@ -264,8 +264,7 @@ xfs_dir2_free_log_bests(
264 */ 264 */
265static void 265static void
266xfs_dir2_free_log_header( 266xfs_dir2_free_log_header(
267 struct xfs_trans *tp, 267 struct xfs_da_args *args,
268 struct xfs_inode *dp,
269 struct xfs_buf *bp) 268 struct xfs_buf *bp)
270{ 269{
271#ifdef DEBUG 270#ifdef DEBUG
@@ -275,7 +274,8 @@ xfs_dir2_free_log_header(
275 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) || 274 ASSERT(free->hdr.magic == cpu_to_be32(XFS_DIR2_FREE_MAGIC) ||
276 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC)); 275 free->hdr.magic == cpu_to_be32(XFS_DIR3_FREE_MAGIC));
277#endif 276#endif
278 xfs_trans_log_buf(tp, bp, 0, dp->d_ops->free_hdr_size - 1); 277 xfs_trans_log_buf(args->trans, bp, 0,
278 args->dp->d_ops->free_hdr_size - 1);
279} 279}
280 280
281/* 281/*
@@ -315,20 +315,20 @@ xfs_dir2_leaf_to_node(
315 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_FREE_SPACE, &fdb))) { 315 if ((error = xfs_dir2_grow_inode(args, XFS_DIR2_FREE_SPACE, &fdb))) {
316 return error; 316 return error;
317 } 317 }
318 ASSERT(fdb == XFS_DIR2_FREE_FIRSTDB(mp)); 318 ASSERT(fdb == xfs_dir2_byte_to_db(args->geo, XFS_DIR2_FREE_OFFSET));
319 /* 319 /*
320 * Get the buffer for the new freespace block. 320 * Get the buffer for the new freespace block.
321 */ 321 */
322 error = xfs_dir3_free_get_buf(tp, dp, fdb, &fbp); 322 error = xfs_dir3_free_get_buf(args, fdb, &fbp);
323 if (error) 323 if (error)
324 return error; 324 return error;
325 325
326 free = fbp->b_addr; 326 free = fbp->b_addr;
327 dp->d_ops->free_hdr_from_disk(&freehdr, free); 327 dp->d_ops->free_hdr_from_disk(&freehdr, free);
328 leaf = lbp->b_addr; 328 leaf = lbp->b_addr;
329 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 329 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
330 ASSERT(be32_to_cpu(ltp->bestcount) <= 330 ASSERT(be32_to_cpu(ltp->bestcount) <=
331 (uint)dp->i_d.di_size / mp->m_dirblksize); 331 (uint)dp->i_d.di_size / args->geo->blksize);
332 332
333 /* 333 /*
334 * Copy freespace entries from the leaf block to the new block. 334 * Copy freespace entries from the leaf block to the new block.
@@ -349,8 +349,8 @@ xfs_dir2_leaf_to_node(
349 freehdr.nvalid = be32_to_cpu(ltp->bestcount); 349 freehdr.nvalid = be32_to_cpu(ltp->bestcount);
350 350
351 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr); 351 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
352 xfs_dir2_free_log_bests(tp, dp, fbp, 0, freehdr.nvalid - 1); 352 xfs_dir2_free_log_bests(args, fbp, 0, freehdr.nvalid - 1);
353 xfs_dir2_free_log_header(tp, dp, fbp); 353 xfs_dir2_free_log_header(args, fbp);
354 354
355 /* 355 /*
356 * Converting the leaf to a leafnode is just a matter of changing the 356 * Converting the leaf to a leafnode is just a matter of changing the
@@ -364,7 +364,7 @@ xfs_dir2_leaf_to_node(
364 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC); 364 leaf->hdr.info.magic = cpu_to_be16(XFS_DIR3_LEAFN_MAGIC);
365 lbp->b_ops = &xfs_dir3_leafn_buf_ops; 365 lbp->b_ops = &xfs_dir3_leafn_buf_ops;
366 xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF); 366 xfs_trans_buf_set_type(tp, lbp, XFS_BLFT_DIR_LEAFN_BUF);
367 xfs_dir3_leaf_log_header(tp, dp, lbp); 367 xfs_dir3_leaf_log_header(args, lbp);
368 xfs_dir3_leaf_check(dp, lbp); 368 xfs_dir3_leaf_check(dp, lbp);
369 return 0; 369 return 0;
370} 370}
@@ -415,7 +415,7 @@ xfs_dir2_leafn_add(
415 * a compact. 415 * a compact.
416 */ 416 */
417 417
418 if (leafhdr.count == dp->d_ops->leaf_max_ents(mp)) { 418 if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) {
419 if (!leafhdr.stale) 419 if (!leafhdr.stale)
420 return XFS_ERROR(ENOSPC); 420 return XFS_ERROR(ENOSPC);
421 compact = leafhdr.stale > 1; 421 compact = leafhdr.stale > 1;
@@ -450,12 +450,12 @@ xfs_dir2_leafn_add(
450 highstale, &lfloglow, &lfloghigh); 450 highstale, &lfloglow, &lfloghigh);
451 451
452 lep->hashval = cpu_to_be32(args->hashval); 452 lep->hashval = cpu_to_be32(args->hashval);
453 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(mp, 453 lep->address = cpu_to_be32(xfs_dir2_db_off_to_dataptr(args->geo,
454 args->blkno, args->index)); 454 args->blkno, args->index));
455 455
456 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 456 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
457 xfs_dir3_leaf_log_header(tp, dp, bp); 457 xfs_dir3_leaf_log_header(args, bp);
458 xfs_dir3_leaf_log_ents(tp, dp, bp, lfloglow, lfloghigh); 458 xfs_dir3_leaf_log_ents(args, bp, lfloglow, lfloghigh);
459 xfs_dir3_leaf_check(dp, bp); 459 xfs_dir3_leaf_check(dp, bp);
460 return 0; 460 return 0;
461} 461}
@@ -471,7 +471,8 @@ xfs_dir2_free_hdr_check(
471 471
472 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr); 472 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr);
473 473
474 ASSERT((hdr.firstdb % dp->d_ops->free_max_bests(dp->i_mount)) == 0); 474 ASSERT((hdr.firstdb %
475 dp->d_ops->free_max_bests(dp->i_mount->m_dir_geo)) == 0);
475 ASSERT(hdr.firstdb <= db); 476 ASSERT(hdr.firstdb <= db);
476 ASSERT(db < hdr.firstdb + hdr.nvalid); 477 ASSERT(db < hdr.firstdb + hdr.nvalid);
477} 478}
@@ -576,7 +577,8 @@ xfs_dir2_leafn_lookup_for_addname(
576 /* 577 /*
577 * Pull the data block number from the entry. 578 * Pull the data block number from the entry.
578 */ 579 */
579 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 580 newdb = xfs_dir2_dataptr_to_db(args->geo,
581 be32_to_cpu(lep->address));
580 /* 582 /*
581 * For addname, we're looking for a place to put the new entry. 583 * For addname, we're looking for a place to put the new entry.
582 * We want to use a data block with an entry of equal 584 * We want to use a data block with an entry of equal
@@ -593,7 +595,7 @@ xfs_dir2_leafn_lookup_for_addname(
593 * Convert the data block to the free block 595 * Convert the data block to the free block
594 * holding its freespace information. 596 * holding its freespace information.
595 */ 597 */
596 newfdb = dp->d_ops->db_to_fdb(mp, newdb); 598 newfdb = dp->d_ops->db_to_fdb(args->geo, newdb);
597 /* 599 /*
598 * If it's not the one we have in hand, read it in. 600 * If it's not the one we have in hand, read it in.
599 */ 601 */
@@ -605,7 +607,8 @@ xfs_dir2_leafn_lookup_for_addname(
605 xfs_trans_brelse(tp, curbp); 607 xfs_trans_brelse(tp, curbp);
606 608
607 error = xfs_dir2_free_read(tp, dp, 609 error = xfs_dir2_free_read(tp, dp,
608 xfs_dir2_db_to_da(mp, newfdb), 610 xfs_dir2_db_to_da(args->geo,
611 newfdb),
609 &curbp); 612 &curbp);
610 if (error) 613 if (error)
611 return error; 614 return error;
@@ -616,7 +619,7 @@ xfs_dir2_leafn_lookup_for_addname(
616 /* 619 /*
617 * Get the index for our entry. 620 * Get the index for our entry.
618 */ 621 */
619 fi = dp->d_ops->db_to_fdindex(mp, curdb); 622 fi = dp->d_ops->db_to_fdindex(args->geo, curdb);
620 /* 623 /*
621 * If it has room, return it. 624 * If it has room, return it.
622 */ 625 */
@@ -721,7 +724,8 @@ xfs_dir2_leafn_lookup_for_entry(
721 /* 724 /*
722 * Pull the data block number from the entry. 725 * Pull the data block number from the entry.
723 */ 726 */
724 newdb = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 727 newdb = xfs_dir2_dataptr_to_db(args->geo,
728 be32_to_cpu(lep->address));
725 /* 729 /*
726 * Not adding a new entry, so we really want to find 730 * Not adding a new entry, so we really want to find
727 * the name given to us. 731 * the name given to us.
@@ -746,7 +750,8 @@ xfs_dir2_leafn_lookup_for_entry(
746 curbp = state->extrablk.bp; 750 curbp = state->extrablk.bp;
747 } else { 751 } else {
748 error = xfs_dir3_data_read(tp, dp, 752 error = xfs_dir3_data_read(tp, dp,
749 xfs_dir2_db_to_da(mp, newdb), 753 xfs_dir2_db_to_da(args->geo,
754 newdb),
750 -1, &curbp); 755 -1, &curbp);
751 if (error) 756 if (error)
752 return error; 757 return error;
@@ -758,7 +763,8 @@ xfs_dir2_leafn_lookup_for_entry(
758 * Point to the data entry. 763 * Point to the data entry.
759 */ 764 */
760 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr + 765 dep = (xfs_dir2_data_entry_t *)((char *)curbp->b_addr +
761 xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address))); 766 xfs_dir2_dataptr_to_off(args->geo,
767 be32_to_cpu(lep->address)));
762 /* 768 /*
763 * Compare the entry and if it's an exact match, return 769 * Compare the entry and if it's an exact match, return
764 * EEXIST immediately. If it's the first case-insensitive 770 * EEXIST immediately. If it's the first case-insensitive
@@ -844,7 +850,6 @@ xfs_dir3_leafn_moveents(
844 int start_d,/* destination leaf index */ 850 int start_d,/* destination leaf index */
845 int count) /* count of leaves to copy */ 851 int count) /* count of leaves to copy */
846{ 852{
847 struct xfs_trans *tp = args->trans;
848 int stale; /* count stale leaves copied */ 853 int stale; /* count stale leaves copied */
849 854
850 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count); 855 trace_xfs_dir2_leafn_moveents(args, start_s, start_d, count);
@@ -863,7 +868,7 @@ xfs_dir3_leafn_moveents(
863 if (start_d < dhdr->count) { 868 if (start_d < dhdr->count) {
864 memmove(&dents[start_d + count], &dents[start_d], 869 memmove(&dents[start_d + count], &dents[start_d],
865 (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t)); 870 (dhdr->count - start_d) * sizeof(xfs_dir2_leaf_entry_t));
866 xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, start_d + count, 871 xfs_dir3_leaf_log_ents(args, bp_d, start_d + count,
867 count + dhdr->count - 1); 872 count + dhdr->count - 1);
868 } 873 }
869 /* 874 /*
@@ -885,8 +890,7 @@ xfs_dir3_leafn_moveents(
885 */ 890 */
886 memcpy(&dents[start_d], &sents[start_s], 891 memcpy(&dents[start_d], &sents[start_s],
887 count * sizeof(xfs_dir2_leaf_entry_t)); 892 count * sizeof(xfs_dir2_leaf_entry_t));
888 xfs_dir3_leaf_log_ents(tp, args->dp, bp_d, 893 xfs_dir3_leaf_log_ents(args, bp_d, start_d, start_d + count - 1);
889 start_d, start_d + count - 1);
890 894
891 /* 895 /*
892 * If there are source entries after the ones we copied, 896 * If there are source entries after the ones we copied,
@@ -895,8 +899,7 @@ xfs_dir3_leafn_moveents(
895 if (start_s + count < shdr->count) { 899 if (start_s + count < shdr->count) {
896 memmove(&sents[start_s], &sents[start_s + count], 900 memmove(&sents[start_s], &sents[start_s + count],
897 count * sizeof(xfs_dir2_leaf_entry_t)); 901 count * sizeof(xfs_dir2_leaf_entry_t));
898 xfs_dir3_leaf_log_ents(tp, args->dp, bp_s, 902 xfs_dir3_leaf_log_ents(args, bp_s, start_s, start_s + count - 1);
899 start_s, start_s + count - 1);
900 } 903 }
901 904
902 /* 905 /*
@@ -1032,8 +1035,8 @@ xfs_dir2_leafn_rebalance(
1032 /* log the changes made when moving the entries */ 1035 /* log the changes made when moving the entries */
1033 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1); 1036 dp->d_ops->leaf_hdr_to_disk(leaf1, &hdr1);
1034 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2); 1037 dp->d_ops->leaf_hdr_to_disk(leaf2, &hdr2);
1035 xfs_dir3_leaf_log_header(args->trans, dp, blk1->bp); 1038 xfs_dir3_leaf_log_header(args, blk1->bp);
1036 xfs_dir3_leaf_log_header(args->trans, dp, blk2->bp); 1039 xfs_dir3_leaf_log_header(args, blk2->bp);
1037 1040
1038 xfs_dir3_leaf_check(dp, blk1->bp); 1041 xfs_dir3_leaf_check(dp, blk1->bp);
1039 xfs_dir3_leaf_check(dp, blk2->bp); 1042 xfs_dir3_leaf_check(dp, blk2->bp);
@@ -1076,7 +1079,6 @@ xfs_dir3_data_block_free(
1076 struct xfs_buf *fbp, 1079 struct xfs_buf *fbp,
1077 int longest) 1080 int longest)
1078{ 1081{
1079 struct xfs_trans *tp = args->trans;
1080 int logfree = 0; 1082 int logfree = 0;
1081 __be16 *bests; 1083 __be16 *bests;
1082 struct xfs_dir3_icfree_hdr freehdr; 1084 struct xfs_dir3_icfree_hdr freehdr;
@@ -1090,7 +1092,7 @@ xfs_dir3_data_block_free(
1090 * value. 1092 * value.
1091 */ 1093 */
1092 bests[findex] = cpu_to_be16(longest); 1094 bests[findex] = cpu_to_be16(longest);
1093 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 1095 xfs_dir2_free_log_bests(args, fbp, findex, findex);
1094 return 0; 1096 return 0;
1095 } 1097 }
1096 1098
@@ -1118,7 +1120,7 @@ xfs_dir3_data_block_free(
1118 } 1120 }
1119 1121
1120 dp->d_ops->free_hdr_to_disk(free, &freehdr); 1122 dp->d_ops->free_hdr_to_disk(free, &freehdr);
1121 xfs_dir2_free_log_header(tp, dp, fbp); 1123 xfs_dir2_free_log_header(args, fbp);
1122 1124
1123 /* 1125 /*
1124 * If there are no useful entries left in the block, get rid of the 1126 * If there are no useful entries left in the block, get rid of the
@@ -1142,7 +1144,7 @@ xfs_dir3_data_block_free(
1142 1144
1143 /* Log the free entry that changed, unless we got rid of it. */ 1145 /* Log the free entry that changed, unless we got rid of it. */
1144 if (logfree) 1146 if (logfree)
1145 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 1147 xfs_dir2_free_log_bests(args, fbp, findex, findex);
1146 return 0; 1148 return 0;
1147} 1149}
1148 1150
@@ -1193,9 +1195,9 @@ xfs_dir2_leafn_remove(
1193 /* 1195 /*
1194 * Extract the data block and offset from the entry. 1196 * Extract the data block and offset from the entry.
1195 */ 1197 */
1196 db = xfs_dir2_dataptr_to_db(mp, be32_to_cpu(lep->address)); 1198 db = xfs_dir2_dataptr_to_db(args->geo, be32_to_cpu(lep->address));
1197 ASSERT(dblk->blkno == db); 1199 ASSERT(dblk->blkno == db);
1198 off = xfs_dir2_dataptr_to_off(mp, be32_to_cpu(lep->address)); 1200 off = xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address));
1199 ASSERT(dblk->index == off); 1201 ASSERT(dblk->index == off);
1200 1202
1201 /* 1203 /*
@@ -1204,10 +1206,10 @@ xfs_dir2_leafn_remove(
1204 */ 1206 */
1205 leafhdr.stale++; 1207 leafhdr.stale++;
1206 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr); 1208 dp->d_ops->leaf_hdr_to_disk(leaf, &leafhdr);
1207 xfs_dir3_leaf_log_header(tp, dp, bp); 1209 xfs_dir3_leaf_log_header(args, bp);
1208 1210
1209 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR); 1211 lep->address = cpu_to_be32(XFS_DIR2_NULL_DATAPTR);
1210 xfs_dir3_leaf_log_ents(tp, dp, bp, index, index); 1212 xfs_dir3_leaf_log_ents(args, bp, index, index);
1211 1213
1212 /* 1214 /*
1213 * Make the data entry free. Keep track of the longest freespace 1215 * Make the data entry free. Keep track of the longest freespace
@@ -1219,7 +1221,7 @@ xfs_dir2_leafn_remove(
1219 bf = dp->d_ops->data_bestfree_p(hdr); 1221 bf = dp->d_ops->data_bestfree_p(hdr);
1220 longest = be16_to_cpu(bf[0].length); 1222 longest = be16_to_cpu(bf[0].length);
1221 needlog = needscan = 0; 1223 needlog = needscan = 0;
1222 xfs_dir2_data_make_free(tp, dp, dbp, off, 1224 xfs_dir2_data_make_free(args, dbp, off,
1223 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan); 1225 dp->d_ops->data_entsize(dep->namelen), &needlog, &needscan);
1224 /* 1226 /*
1225 * Rescan the data block freespaces for bestfree. 1227 * Rescan the data block freespaces for bestfree.
@@ -1228,7 +1230,7 @@ xfs_dir2_leafn_remove(
1228 if (needscan) 1230 if (needscan)
1229 xfs_dir2_data_freescan(dp, hdr, &needlog); 1231 xfs_dir2_data_freescan(dp, hdr, &needlog);
1230 if (needlog) 1232 if (needlog)
1231 xfs_dir2_data_log_header(tp, dp, dbp); 1233 xfs_dir2_data_log_header(args, dbp);
1232 xfs_dir3_data_check(dp, dbp); 1234 xfs_dir3_data_check(dp, dbp);
1233 /* 1235 /*
1234 * If the longest data block freespace changes, need to update 1236 * If the longest data block freespace changes, need to update
@@ -1245,8 +1247,9 @@ xfs_dir2_leafn_remove(
1245 * Convert the data block number to a free block, 1247 * Convert the data block number to a free block,
1246 * read in the free block. 1248 * read in the free block.
1247 */ 1249 */
1248 fdb = dp->d_ops->db_to_fdb(mp, db); 1250 fdb = dp->d_ops->db_to_fdb(args->geo, db);
1249 error = xfs_dir2_free_read(tp, dp, xfs_dir2_db_to_da(mp, fdb), 1251 error = xfs_dir2_free_read(tp, dp,
1252 xfs_dir2_db_to_da(args->geo, fdb),
1250 &fbp); 1253 &fbp);
1251 if (error) 1254 if (error)
1252 return error; 1255 return error;
@@ -1255,20 +1258,21 @@ xfs_dir2_leafn_remove(
1255 { 1258 {
1256 struct xfs_dir3_icfree_hdr freehdr; 1259 struct xfs_dir3_icfree_hdr freehdr;
1257 dp->d_ops->free_hdr_from_disk(&freehdr, free); 1260 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1258 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) * 1261 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(args->geo) *
1259 (fdb - XFS_DIR2_FREE_FIRSTDB(mp))); 1262 (fdb - xfs_dir2_byte_to_db(args->geo,
1263 XFS_DIR2_FREE_OFFSET)));
1260 } 1264 }
1261#endif 1265#endif
1262 /* 1266 /*
1263 * Calculate which entry we need to fix. 1267 * Calculate which entry we need to fix.
1264 */ 1268 */
1265 findex = dp->d_ops->db_to_fdindex(mp, db); 1269 findex = dp->d_ops->db_to_fdindex(args->geo, db);
1266 longest = be16_to_cpu(bf[0].length); 1270 longest = be16_to_cpu(bf[0].length);
1267 /* 1271 /*
1268 * If the data block is now empty we can get rid of it 1272 * If the data block is now empty we can get rid of it
1269 * (usually). 1273 * (usually).
1270 */ 1274 */
1271 if (longest == mp->m_dirblksize - 1275 if (longest == args->geo->blksize -
1272 dp->d_ops->data_entry_offset) { 1276 dp->d_ops->data_entry_offset) {
1273 /* 1277 /*
1274 * Try to punch out the data block. 1278 * Try to punch out the data block.
@@ -1303,7 +1307,7 @@ xfs_dir2_leafn_remove(
1303 */ 1307 */
1304 *rval = (dp->d_ops->leaf_hdr_size + 1308 *rval = (dp->d_ops->leaf_hdr_size +
1305 (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) < 1309 (uint)sizeof(ents[0]) * (leafhdr.count - leafhdr.stale)) <
1306 mp->m_dir_magicpct; 1310 args->geo->magicpct;
1307 return 0; 1311 return 0;
1308} 1312}
1309 1313
@@ -1336,7 +1340,7 @@ xfs_dir2_leafn_split(
1336 /* 1340 /*
1337 * Initialize the new leaf block. 1341 * Initialize the new leaf block.
1338 */ 1342 */
1339 error = xfs_dir3_leaf_get_buf(args, xfs_dir2_da_to_db(mp, blkno), 1343 error = xfs_dir3_leaf_get_buf(args, xfs_dir2_da_to_db(args->geo, blkno),
1340 &newblk->bp, XFS_DIR2_LEAFN_MAGIC); 1344 &newblk->bp, XFS_DIR2_LEAFN_MAGIC);
1341 if (error) 1345 if (error)
1342 return error; 1346 return error;
@@ -1410,7 +1414,7 @@ xfs_dir2_leafn_toosmall(
1410 1414
1411 count = leafhdr.count - leafhdr.stale; 1415 count = leafhdr.count - leafhdr.stale;
1412 bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]); 1416 bytes = dp->d_ops->leaf_hdr_size + count * sizeof(ents[0]);
1413 if (bytes > (state->blocksize >> 1)) { 1417 if (bytes > (state->args->geo->blksize >> 1)) {
1414 /* 1418 /*
1415 * Blk over 50%, don't try to join. 1419 * Blk over 50%, don't try to join.
1416 */ 1420 */
@@ -1463,7 +1467,8 @@ xfs_dir2_leafn_toosmall(
1463 * Count bytes in the two blocks combined. 1467 * Count bytes in the two blocks combined.
1464 */ 1468 */
1465 count = leafhdr.count - leafhdr.stale; 1469 count = leafhdr.count - leafhdr.stale;
1466 bytes = state->blocksize - (state->blocksize >> 2); 1470 bytes = state->args->geo->blksize -
1471 (state->args->geo->blksize >> 2);
1467 1472
1468 leaf = bp->b_addr; 1473 leaf = bp->b_addr;
1469 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf); 1474 dp->d_ops->leaf_hdr_from_disk(&hdr2, leaf);
@@ -1560,8 +1565,8 @@ xfs_dir2_leafn_unbalance(
1560 /* log the changes made when moving the entries */ 1565 /* log the changes made when moving the entries */
1561 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr); 1566 dp->d_ops->leaf_hdr_to_disk(save_leaf, &savehdr);
1562 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr); 1567 dp->d_ops->leaf_hdr_to_disk(drop_leaf, &drophdr);
1563 xfs_dir3_leaf_log_header(args->trans, dp, save_blk->bp); 1568 xfs_dir3_leaf_log_header(args, save_blk->bp);
1564 xfs_dir3_leaf_log_header(args->trans, dp, drop_blk->bp); 1569 xfs_dir3_leaf_log_header(args, drop_blk->bp);
1565 1570
1566 xfs_dir3_leaf_check(dp, save_blk->bp); 1571 xfs_dir3_leaf_check(dp, save_blk->bp);
1567 xfs_dir3_leaf_check(dp, drop_blk->bp); 1572 xfs_dir3_leaf_check(dp, drop_blk->bp);
@@ -1587,8 +1592,6 @@ xfs_dir2_node_addname(
1587 state = xfs_da_state_alloc(); 1592 state = xfs_da_state_alloc();
1588 state->args = args; 1593 state->args = args;
1589 state->mp = args->dp->i_mount; 1594 state->mp = args->dp->i_mount;
1590 state->blocksize = state->mp->m_dirblksize;
1591 state->node_ents = state->mp->m_dir_node_ents;
1592 /* 1595 /*
1593 * Look up the name. We're not supposed to find it, but 1596 * Look up the name. We're not supposed to find it, but
1594 * this gives us the insertion point. 1597 * this gives us the insertion point.
@@ -1729,7 +1732,7 @@ xfs_dir2_node_addname_int(
1729 1732
1730 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK))) 1733 if ((error = xfs_bmap_last_offset(dp, &fo, XFS_DATA_FORK)))
1731 return error; 1734 return error;
1732 lastfbno = xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo); 1735 lastfbno = xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)fo);
1733 fbno = ifbno; 1736 fbno = ifbno;
1734 } 1737 }
1735 /* 1738 /*
@@ -1747,7 +1750,8 @@ xfs_dir2_node_addname_int(
1747 * us a freespace block to start with. 1750 * us a freespace block to start with.
1748 */ 1751 */
1749 if (++fbno == 0) 1752 if (++fbno == 0)
1750 fbno = XFS_DIR2_FREE_FIRSTDB(mp); 1753 fbno = xfs_dir2_byte_to_db(args->geo,
1754 XFS_DIR2_FREE_OFFSET);
1751 /* 1755 /*
1752 * If it's ifbno we already looked at it. 1756 * If it's ifbno we already looked at it.
1753 */ 1757 */
@@ -1765,8 +1769,8 @@ xfs_dir2_node_addname_int(
1765 * to avoid it. 1769 * to avoid it.
1766 */ 1770 */
1767 error = xfs_dir2_free_try_read(tp, dp, 1771 error = xfs_dir2_free_try_read(tp, dp,
1768 xfs_dir2_db_to_da(mp, fbno), 1772 xfs_dir2_db_to_da(args->geo, fbno),
1769 &fbp); 1773 &fbp);
1770 if (error) 1774 if (error)
1771 return error; 1775 return error;
1772 if (!fbp) 1776 if (!fbp)
@@ -1834,10 +1838,10 @@ xfs_dir2_node_addname_int(
1834 * Get the freespace block corresponding to the data block 1838 * Get the freespace block corresponding to the data block
1835 * that was just allocated. 1839 * that was just allocated.
1836 */ 1840 */
1837 fbno = dp->d_ops->db_to_fdb(mp, dbno); 1841 fbno = dp->d_ops->db_to_fdb(args->geo, dbno);
1838 error = xfs_dir2_free_try_read(tp, dp, 1842 error = xfs_dir2_free_try_read(tp, dp,
1839 xfs_dir2_db_to_da(mp, fbno), 1843 xfs_dir2_db_to_da(args->geo, fbno),
1840 &fbp); 1844 &fbp);
1841 if (error) 1845 if (error)
1842 return error; 1846 return error;
1843 1847
@@ -1851,12 +1855,13 @@ xfs_dir2_node_addname_int(
1851 if (error) 1855 if (error)
1852 return error; 1856 return error;
1853 1857
1854 if (unlikely(dp->d_ops->db_to_fdb(mp, dbno) != fbno)) { 1858 if (dp->d_ops->db_to_fdb(args->geo, dbno) != fbno) {
1855 xfs_alert(mp, 1859 xfs_alert(mp,
1856 "%s: dir ino %llu needed freesp block %lld for\n" 1860 "%s: dir ino %llu needed freesp block %lld for\n"
1857 " data block %lld, got %lld ifbno %llu lastfbno %d", 1861 " data block %lld, got %lld ifbno %llu lastfbno %d",
1858 __func__, (unsigned long long)dp->i_ino, 1862 __func__, (unsigned long long)dp->i_ino,
1859 (long long)dp->d_ops->db_to_fdb(mp, dbno), 1863 (long long)dp->d_ops->db_to_fdb(
1864 args->geo, dbno),
1860 (long long)dbno, (long long)fbno, 1865 (long long)dbno, (long long)fbno,
1861 (unsigned long long)ifbno, lastfbno); 1866 (unsigned long long)ifbno, lastfbno);
1862 if (fblk) { 1867 if (fblk) {
@@ -1877,7 +1882,7 @@ xfs_dir2_node_addname_int(
1877 /* 1882 /*
1878 * Get a buffer for the new block. 1883 * Get a buffer for the new block.
1879 */ 1884 */
1880 error = xfs_dir3_free_get_buf(tp, dp, fbno, &fbp); 1885 error = xfs_dir3_free_get_buf(args, fbno, &fbp);
1881 if (error) 1886 if (error)
1882 return error; 1887 return error;
1883 free = fbp->b_addr; 1888 free = fbp->b_addr;
@@ -1887,8 +1892,10 @@ xfs_dir2_node_addname_int(
1887 /* 1892 /*
1888 * Remember the first slot as our empty slot. 1893 * Remember the first slot as our empty slot.
1889 */ 1894 */
1890 freehdr.firstdb = (fbno - XFS_DIR2_FREE_FIRSTDB(mp)) * 1895 freehdr.firstdb =
1891 dp->d_ops->free_max_bests(mp); 1896 (fbno - xfs_dir2_byte_to_db(args->geo,
1897 XFS_DIR2_FREE_OFFSET)) *
1898 dp->d_ops->free_max_bests(args->geo);
1892 } else { 1899 } else {
1893 free = fbp->b_addr; 1900 free = fbp->b_addr;
1894 bests = dp->d_ops->free_bests_p(free); 1901 bests = dp->d_ops->free_bests_p(free);
@@ -1898,13 +1905,13 @@ xfs_dir2_node_addname_int(
1898 /* 1905 /*
1899 * Set the freespace block index from the data block number. 1906 * Set the freespace block index from the data block number.
1900 */ 1907 */
1901 findex = dp->d_ops->db_to_fdindex(mp, dbno); 1908 findex = dp->d_ops->db_to_fdindex(args->geo, dbno);
1902 /* 1909 /*
1903 * If it's after the end of the current entries in the 1910 * If it's after the end of the current entries in the
1904 * freespace block, extend that table. 1911 * freespace block, extend that table.
1905 */ 1912 */
1906 if (findex >= freehdr.nvalid) { 1913 if (findex >= freehdr.nvalid) {
1907 ASSERT(findex < dp->d_ops->free_max_bests(mp)); 1914 ASSERT(findex < dp->d_ops->free_max_bests(args->geo));
1908 freehdr.nvalid = findex + 1; 1915 freehdr.nvalid = findex + 1;
1909 /* 1916 /*
1910 * Tag new entry so nused will go up. 1917 * Tag new entry so nused will go up.
@@ -1918,7 +1925,7 @@ xfs_dir2_node_addname_int(
1918 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) { 1925 if (bests[findex] == cpu_to_be16(NULLDATAOFF)) {
1919 freehdr.nused++; 1926 freehdr.nused++;
1920 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr); 1927 dp->d_ops->free_hdr_to_disk(fbp->b_addr, &freehdr);
1921 xfs_dir2_free_log_header(tp, dp, fbp); 1928 xfs_dir2_free_log_header(args, fbp);
1922 } 1929 }
1923 /* 1930 /*
1924 * Update the real value in the table. 1931 * Update the real value in the table.
@@ -1943,7 +1950,8 @@ xfs_dir2_node_addname_int(
1943 /* 1950 /*
1944 * Read the data block in. 1951 * Read the data block in.
1945 */ 1952 */
1946 error = xfs_dir3_data_read(tp, dp, xfs_dir2_db_to_da(mp, dbno), 1953 error = xfs_dir3_data_read(tp, dp,
1954 xfs_dir2_db_to_da(args->geo, dbno),
1947 -1, &dbp); 1955 -1, &dbp);
1948 if (error) 1956 if (error)
1949 return error; 1957 return error;
@@ -1961,7 +1969,7 @@ xfs_dir2_node_addname_int(
1961 /* 1969 /*
1962 * Mark the first part of the unused space, inuse for us. 1970 * Mark the first part of the unused space, inuse for us.
1963 */ 1971 */
1964 xfs_dir2_data_use_free(tp, dp, dbp, dup, 1972 xfs_dir2_data_use_free(args, dbp, dup,
1965 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length, 1973 (xfs_dir2_data_aoff_t)((char *)dup - (char *)hdr), length,
1966 &needlog, &needscan); 1974 &needlog, &needscan);
1967 /* 1975 /*
@@ -1974,7 +1982,7 @@ xfs_dir2_node_addname_int(
1974 dp->d_ops->data_put_ftype(dep, args->filetype); 1982 dp->d_ops->data_put_ftype(dep, args->filetype);
1975 tagp = dp->d_ops->data_entry_tag_p(dep); 1983 tagp = dp->d_ops->data_entry_tag_p(dep);
1976 *tagp = cpu_to_be16((char *)dep - (char *)hdr); 1984 *tagp = cpu_to_be16((char *)dep - (char *)hdr);
1977 xfs_dir2_data_log_entry(tp, dp, dbp, dep); 1985 xfs_dir2_data_log_entry(args, dbp, dep);
1978 /* 1986 /*
1979 * Rescan the block for bestfree if needed. 1987 * Rescan the block for bestfree if needed.
1980 */ 1988 */
@@ -1984,7 +1992,7 @@ xfs_dir2_node_addname_int(
1984 * Log the data block header if needed. 1992 * Log the data block header if needed.
1985 */ 1993 */
1986 if (needlog) 1994 if (needlog)
1987 xfs_dir2_data_log_header(tp, dp, dbp); 1995 xfs_dir2_data_log_header(args, dbp);
1988 /* 1996 /*
1989 * If the freespace entry is now wrong, update it. 1997 * If the freespace entry is now wrong, update it.
1990 */ 1998 */
@@ -1997,7 +2005,7 @@ xfs_dir2_node_addname_int(
1997 * Log the freespace entry if needed. 2005 * Log the freespace entry if needed.
1998 */ 2006 */
1999 if (logfree) 2007 if (logfree)
2000 xfs_dir2_free_log_bests(tp, dp, fbp, findex, findex); 2008 xfs_dir2_free_log_bests(args, fbp, findex, findex);
2001 /* 2009 /*
2002 * Return the data block and offset in args, then drop the data block. 2010 * Return the data block and offset in args, then drop the data block.
2003 */ 2011 */
@@ -2028,8 +2036,6 @@ xfs_dir2_node_lookup(
2028 state = xfs_da_state_alloc(); 2036 state = xfs_da_state_alloc();
2029 state->args = args; 2037 state->args = args;
2030 state->mp = args->dp->i_mount; 2038 state->mp = args->dp->i_mount;
2031 state->blocksize = state->mp->m_dirblksize;
2032 state->node_ents = state->mp->m_dir_node_ents;
2033 /* 2039 /*
2034 * Fill in the path to the entry in the cursor. 2040 * Fill in the path to the entry in the cursor.
2035 */ 2041 */
@@ -2083,8 +2089,6 @@ xfs_dir2_node_removename(
2083 state = xfs_da_state_alloc(); 2089 state = xfs_da_state_alloc();
2084 state->args = args; 2090 state->args = args;
2085 state->mp = args->dp->i_mount; 2091 state->mp = args->dp->i_mount;
2086 state->blocksize = state->mp->m_dirblksize;
2087 state->node_ents = state->mp->m_dir_node_ents;
2088 2092
2089 /* Look up the entry we're deleting, set up the cursor. */ 2093 /* Look up the entry we're deleting, set up the cursor. */
2090 error = xfs_da3_node_lookup_int(state, &rval); 2094 error = xfs_da3_node_lookup_int(state, &rval);
@@ -2153,8 +2157,6 @@ xfs_dir2_node_replace(
2153 state = xfs_da_state_alloc(); 2157 state = xfs_da_state_alloc();
2154 state->args = args; 2158 state->args = args;
2155 state->mp = args->dp->i_mount; 2159 state->mp = args->dp->i_mount;
2156 state->blocksize = state->mp->m_dirblksize;
2157 state->node_ents = state->mp->m_dir_node_ents;
2158 inum = args->inumber; 2160 inum = args->inumber;
2159 /* 2161 /*
2160 * Lookup the entry to change in the btree. 2162 * Lookup the entry to change in the btree.
@@ -2186,15 +2188,15 @@ xfs_dir2_node_replace(
2186 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); 2188 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
2187 dep = (xfs_dir2_data_entry_t *) 2189 dep = (xfs_dir2_data_entry_t *)
2188 ((char *)hdr + 2190 ((char *)hdr +
2189 xfs_dir2_dataptr_to_off(state->mp, be32_to_cpu(lep->address))); 2191 xfs_dir2_dataptr_to_off(args->geo,
2192 be32_to_cpu(lep->address)));
2190 ASSERT(inum != be64_to_cpu(dep->inumber)); 2193 ASSERT(inum != be64_to_cpu(dep->inumber));
2191 /* 2194 /*
2192 * Fill in the new inode number and log the entry. 2195 * Fill in the new inode number and log the entry.
2193 */ 2196 */
2194 dep->inumber = cpu_to_be64(inum); 2197 dep->inumber = cpu_to_be64(inum);
2195 args->dp->d_ops->data_put_ftype(dep, args->filetype); 2198 args->dp->d_ops->data_put_ftype(dep, args->filetype);
2196 xfs_dir2_data_log_entry(args->trans, args->dp, 2199 xfs_dir2_data_log_entry(args, state->extrablk.bp, dep);
2197 state->extrablk.bp, dep);
2198 rval = 0; 2200 rval = 0;
2199 } 2201 }
2200 /* 2202 /*
@@ -2262,9 +2264,9 @@ xfs_dir2_node_trim_free(
2262 /* 2264 /*
2263 * Blow the block away. 2265 * Blow the block away.
2264 */ 2266 */
2265 if ((error = 2267 error = xfs_dir2_shrink_inode(args,
2266 xfs_dir2_shrink_inode(args, xfs_dir2_da_to_db(mp, (xfs_dablk_t)fo), 2268 xfs_dir2_da_to_db(args->geo, (xfs_dablk_t)fo), bp);
2267 bp))) { 2269 if (error) {
2268 /* 2270 /*
2269 * Can't fail with ENOSPC since that only happens with no 2271 * Can't fail with ENOSPC since that only happens with no
2270 * space reservation, when breaking up an extent into two 2272 * space reservation, when breaking up an extent into two
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 2429960739e9..27ce0794d196 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -20,6 +20,140 @@
20 20
21struct dir_context; 21struct dir_context;
22 22
23/*
24 * Directory offset/block conversion functions.
25 *
26 * DB blocks here are logical directory block numbers, not filesystem blocks.
27 */
28
29/*
30 * Convert dataptr to byte in file space
31 */
32static inline xfs_dir2_off_t
33xfs_dir2_dataptr_to_byte(xfs_dir2_dataptr_t dp)
34{
35 return (xfs_dir2_off_t)dp << XFS_DIR2_DATA_ALIGN_LOG;
36}
37
38/*
39 * Convert byte in file space to dataptr. It had better be aligned.
40 */
41static inline xfs_dir2_dataptr_t
42xfs_dir2_byte_to_dataptr(xfs_dir2_off_t by)
43{
44 return (xfs_dir2_dataptr_t)(by >> XFS_DIR2_DATA_ALIGN_LOG);
45}
46
47/*
48 * Convert byte in space to (DB) block
49 */
50static inline xfs_dir2_db_t
51xfs_dir2_byte_to_db(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
52{
53 return (xfs_dir2_db_t)(by >> geo->blklog);
54}
55
56/*
57 * Convert dataptr to a block number
58 */
59static inline xfs_dir2_db_t
60xfs_dir2_dataptr_to_db(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
61{
62 return xfs_dir2_byte_to_db(geo, xfs_dir2_dataptr_to_byte(dp));
63}
64
65/*
66 * Convert byte in space to offset in a block
67 */
68static inline xfs_dir2_data_aoff_t
69xfs_dir2_byte_to_off(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
70{
71 return (xfs_dir2_data_aoff_t)(by & (geo->blksize - 1));
72}
73
74/*
75 * Convert dataptr to a byte offset in a block
76 */
77static inline xfs_dir2_data_aoff_t
78xfs_dir2_dataptr_to_off(struct xfs_da_geometry *geo, xfs_dir2_dataptr_t dp)
79{
80 return xfs_dir2_byte_to_off(geo, xfs_dir2_dataptr_to_byte(dp));
81}
82
83/*
84 * Convert block and offset to byte in space
85 */
86static inline xfs_dir2_off_t
87xfs_dir2_db_off_to_byte(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
88 xfs_dir2_data_aoff_t o)
89{
90 return ((xfs_dir2_off_t)db << geo->blklog) + o;
91}
92
93/*
94 * Convert block (DB) to block (dablk)
95 */
96static inline xfs_dablk_t
97xfs_dir2_db_to_da(struct xfs_da_geometry *geo, xfs_dir2_db_t db)
98{
99 return (xfs_dablk_t)(db << (geo->blklog - geo->fsblog));
100}
101
102/*
103 * Convert byte in space to (DA) block
104 */
105static inline xfs_dablk_t
106xfs_dir2_byte_to_da(struct xfs_da_geometry *geo, xfs_dir2_off_t by)
107{
108 return xfs_dir2_db_to_da(geo, xfs_dir2_byte_to_db(geo, by));
109}
110
111/*
112 * Convert block and offset to dataptr
113 */
114static inline xfs_dir2_dataptr_t
115xfs_dir2_db_off_to_dataptr(struct xfs_da_geometry *geo, xfs_dir2_db_t db,
116 xfs_dir2_data_aoff_t o)
117{
118 return xfs_dir2_byte_to_dataptr(xfs_dir2_db_off_to_byte(geo, db, o));
119}
120
121/*
122 * Convert block (dablk) to block (DB)
123 */
124static inline xfs_dir2_db_t
125xfs_dir2_da_to_db(struct xfs_da_geometry *geo, xfs_dablk_t da)
126{
127 return (xfs_dir2_db_t)(da >> (geo->blklog - geo->fsblog));
128}
129
130/*
131 * Convert block (dablk) to byte offset in space
132 */
133static inline xfs_dir2_off_t
134xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
135{
136 return xfs_dir2_db_off_to_byte(geo, xfs_dir2_da_to_db(geo, da), 0);
137}
138
139/*
140 * Directory tail pointer accessor functions. Based on block geometry.
141 */
142static inline struct xfs_dir2_block_tail *
143xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
144{
145 return ((struct xfs_dir2_block_tail *)
146 ((char *)hdr + geo->blksize)) - 1;
147}
148
149static inline struct xfs_dir2_leaf_tail *
150xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
151{
152 return (struct xfs_dir2_leaf_tail *)
153 ((char *)lp + geo->blksize -
154 sizeof(struct xfs_dir2_leaf_tail));
155}
156
23/* xfs_dir2.c */ 157/* xfs_dir2.c */
24extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino); 158extern int xfs_dir_ino_validate(struct xfs_mount *mp, xfs_ino_t ino);
25extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space, 159extern int xfs_dir2_grow_inode(struct xfs_da_args *args, int space,
@@ -77,9 +211,9 @@ extern void xfs_dir3_leaf_compact_x1(struct xfs_dir3_icleaf_hdr *leafhdr,
77 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp); 211 int *lowstalep, int *highstalep, int *lowlogp, int *highlogp);
78extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno, 212extern int xfs_dir3_leaf_get_buf(struct xfs_da_args *args, xfs_dir2_db_t bno,
79 struct xfs_buf **bpp, __uint16_t magic); 213 struct xfs_buf **bpp, __uint16_t magic);
80extern void xfs_dir3_leaf_log_ents(struct xfs_trans *tp, struct xfs_inode *dp, 214extern void xfs_dir3_leaf_log_ents(struct xfs_da_args *args,
81 struct xfs_buf *bp, int first, int last); 215 struct xfs_buf *bp, int first, int last);
82extern void xfs_dir3_leaf_log_header(struct xfs_trans *tp, struct xfs_inode *dp, 216extern void xfs_dir3_leaf_log_header(struct xfs_da_args *args,
83 struct xfs_buf *bp); 217 struct xfs_buf *bp);
84extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args); 218extern int xfs_dir2_leaf_lookup(struct xfs_da_args *args);
85extern int xfs_dir2_leaf_removename(struct xfs_da_args *args); 219extern int xfs_dir2_leaf_removename(struct xfs_da_args *args);
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index bf7a5cee7adc..48e99afb9cb0 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -76,26 +76,25 @@ const unsigned char xfs_mode_to_ftype[S_IFMT >> S_SHIFT] = {
76 76
77STATIC int 77STATIC int
78xfs_dir2_sf_getdents( 78xfs_dir2_sf_getdents(
79 xfs_inode_t *dp, /* incore directory inode */ 79 struct xfs_da_args *args,
80 struct dir_context *ctx) 80 struct dir_context *ctx)
81{ 81{
82 int i; /* shortform entry number */ 82 int i; /* shortform entry number */
83 xfs_mount_t *mp; /* filesystem mount point */ 83 struct xfs_inode *dp = args->dp; /* incore directory inode */
84 xfs_dir2_dataptr_t off; /* current entry's offset */ 84 xfs_dir2_dataptr_t off; /* current entry's offset */
85 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */ 85 xfs_dir2_sf_entry_t *sfep; /* shortform directory entry */
86 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */ 86 xfs_dir2_sf_hdr_t *sfp; /* shortform structure */
87 xfs_dir2_dataptr_t dot_offset; 87 xfs_dir2_dataptr_t dot_offset;
88 xfs_dir2_dataptr_t dotdot_offset; 88 xfs_dir2_dataptr_t dotdot_offset;
89 xfs_ino_t ino; 89 xfs_ino_t ino;
90 90 struct xfs_da_geometry *geo = args->geo;
91 mp = dp->i_mount;
92 91
93 ASSERT(dp->i_df.if_flags & XFS_IFINLINE); 92 ASSERT(dp->i_df.if_flags & XFS_IFINLINE);
94 /* 93 /*
95 * Give up if the directory is way too short. 94 * Give up if the directory is way too short.
96 */ 95 */
97 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) { 96 if (dp->i_d.di_size < offsetof(xfs_dir2_sf_hdr_t, parent)) {
98 ASSERT(XFS_FORCED_SHUTDOWN(mp)); 97 ASSERT(XFS_FORCED_SHUTDOWN(dp->i_mount));
99 return XFS_ERROR(EIO); 98 return XFS_ERROR(EIO);
100 } 99 }
101 100
@@ -109,18 +108,18 @@ xfs_dir2_sf_getdents(
109 /* 108 /*
110 * If the block number in the offset is out of range, we're done. 109 * If the block number in the offset is out of range, we're done.
111 */ 110 */
112 if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) 111 if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > geo->datablk)
113 return 0; 112 return 0;
114 113
115 /* 114 /*
116 * Precalculate offsets for . and .. as we will always need them. 115 * Precalculate offsets for . and .. as we will always need them.
117 * 116 *
118 * XXX(hch): the second argument is sometimes 0 and sometimes 117 * XXX(hch): the second argument is sometimes 0 and sometimes
119 * mp->m_dirdatablk. 118 * geo->datablk
120 */ 119 */
121 dot_offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 120 dot_offset = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
122 dp->d_ops->data_dot_offset); 121 dp->d_ops->data_dot_offset);
123 dotdot_offset = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 122 dotdot_offset = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
124 dp->d_ops->data_dotdot_offset); 123 dp->d_ops->data_dotdot_offset);
125 124
126 /* 125 /*
@@ -149,7 +148,7 @@ xfs_dir2_sf_getdents(
149 for (i = 0; i < sfp->count; i++) { 148 for (i = 0; i < sfp->count; i++) {
150 __uint8_t filetype; 149 __uint8_t filetype;
151 150
152 off = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 151 off = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
153 xfs_dir2_sf_get_offset(sfep)); 152 xfs_dir2_sf_get_offset(sfep));
154 153
155 if (ctx->pos > off) { 154 if (ctx->pos > off) {
@@ -161,13 +160,13 @@ xfs_dir2_sf_getdents(
161 filetype = dp->d_ops->sf_get_ftype(sfep); 160 filetype = dp->d_ops->sf_get_ftype(sfep);
162 ctx->pos = off & 0x7fffffff; 161 ctx->pos = off & 0x7fffffff;
163 if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino, 162 if (!dir_emit(ctx, (char *)sfep->name, sfep->namelen, ino,
164 xfs_dir3_get_dtype(mp, filetype))) 163 xfs_dir3_get_dtype(dp->i_mount, filetype)))
165 return 0; 164 return 0;
166 sfep = dp->d_ops->sf_nextentry(sfp, sfep); 165 sfep = dp->d_ops->sf_nextentry(sfp, sfep);
167 } 166 }
168 167
169 ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 168 ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &
170 0x7fffffff; 169 0x7fffffff;
171 return 0; 170 return 0;
172} 171}
173 172
@@ -176,9 +175,10 @@ xfs_dir2_sf_getdents(
176 */ 175 */
177STATIC int 176STATIC int
178xfs_dir2_block_getdents( 177xfs_dir2_block_getdents(
179 xfs_inode_t *dp, /* incore inode */ 178 struct xfs_da_args *args,
180 struct dir_context *ctx) 179 struct dir_context *ctx)
181{ 180{
181 struct xfs_inode *dp = args->dp; /* incore directory inode */
182 xfs_dir2_data_hdr_t *hdr; /* block header */ 182 xfs_dir2_data_hdr_t *hdr; /* block header */
183 struct xfs_buf *bp; /* buffer for block */ 183 struct xfs_buf *bp; /* buffer for block */
184 xfs_dir2_block_tail_t *btp; /* block tail */ 184 xfs_dir2_block_tail_t *btp; /* block tail */
@@ -186,16 +186,15 @@ xfs_dir2_block_getdents(
186 xfs_dir2_data_unused_t *dup; /* block unused entry */ 186 xfs_dir2_data_unused_t *dup; /* block unused entry */
187 char *endptr; /* end of the data entries */ 187 char *endptr; /* end of the data entries */
188 int error; /* error return value */ 188 int error; /* error return value */
189 xfs_mount_t *mp; /* filesystem mount point */
190 char *ptr; /* current data entry */ 189 char *ptr; /* current data entry */
191 int wantoff; /* starting block offset */ 190 int wantoff; /* starting block offset */
192 xfs_off_t cook; 191 xfs_off_t cook;
192 struct xfs_da_geometry *geo = args->geo;
193 193
194 mp = dp->i_mount;
195 /* 194 /*
196 * If the block number in the offset is out of range, we're done. 195 * If the block number in the offset is out of range, we're done.
197 */ 196 */
198 if (xfs_dir2_dataptr_to_db(mp, ctx->pos) > mp->m_dirdatablk) 197 if (xfs_dir2_dataptr_to_db(geo, ctx->pos) > geo->datablk)
199 return 0; 198 return 0;
200 199
201 error = xfs_dir3_block_read(NULL, dp, &bp); 200 error = xfs_dir3_block_read(NULL, dp, &bp);
@@ -206,13 +205,13 @@ xfs_dir2_block_getdents(
206 * Extract the byte offset we start at from the seek pointer. 205 * Extract the byte offset we start at from the seek pointer.
207 * We'll skip entries before this. 206 * We'll skip entries before this.
208 */ 207 */
209 wantoff = xfs_dir2_dataptr_to_off(mp, ctx->pos); 208 wantoff = xfs_dir2_dataptr_to_off(geo, ctx->pos);
210 hdr = bp->b_addr; 209 hdr = bp->b_addr;
211 xfs_dir3_data_check(dp, bp); 210 xfs_dir3_data_check(dp, bp);
212 /* 211 /*
213 * Set up values for the loop. 212 * Set up values for the loop.
214 */ 213 */
215 btp = xfs_dir2_block_tail_p(mp, hdr); 214 btp = xfs_dir2_block_tail_p(geo, hdr);
216 ptr = (char *)dp->d_ops->data_entry_p(hdr); 215 ptr = (char *)dp->d_ops->data_entry_p(hdr);
217 endptr = (char *)xfs_dir2_block_leaf_p(btp); 216 endptr = (char *)xfs_dir2_block_leaf_p(btp);
218 217
@@ -244,7 +243,7 @@ xfs_dir2_block_getdents(
244 if ((char *)dep - (char *)hdr < wantoff) 243 if ((char *)dep - (char *)hdr < wantoff)
245 continue; 244 continue;
246 245
247 cook = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk, 246 cook = xfs_dir2_db_off_to_dataptr(geo, geo->datablk,
248 (char *)dep - (char *)hdr); 247 (char *)dep - (char *)hdr);
249 248
250 ctx->pos = cook & 0x7fffffff; 249 ctx->pos = cook & 0x7fffffff;
@@ -254,7 +253,7 @@ xfs_dir2_block_getdents(
254 */ 253 */
255 if (!dir_emit(ctx, (char *)dep->name, dep->namelen, 254 if (!dir_emit(ctx, (char *)dep->name, dep->namelen,
256 be64_to_cpu(dep->inumber), 255 be64_to_cpu(dep->inumber),
257 xfs_dir3_get_dtype(mp, filetype))) { 256 xfs_dir3_get_dtype(dp->i_mount, filetype))) {
258 xfs_trans_brelse(NULL, bp); 257 xfs_trans_brelse(NULL, bp);
259 return 0; 258 return 0;
260 } 259 }
@@ -264,8 +263,8 @@ xfs_dir2_block_getdents(
264 * Reached the end of the block. 263 * Reached the end of the block.
265 * Set the offset to a non-existent block 1 and return. 264 * Set the offset to a non-existent block 1 and return.
266 */ 265 */
267 ctx->pos = xfs_dir2_db_off_to_dataptr(mp, mp->m_dirdatablk + 1, 0) & 266 ctx->pos = xfs_dir2_db_off_to_dataptr(geo, geo->datablk + 1, 0) &
268 0x7fffffff; 267 0x7fffffff;
269 xfs_trans_brelse(NULL, bp); 268 xfs_trans_brelse(NULL, bp);
270 return 0; 269 return 0;
271} 270}
@@ -286,13 +285,13 @@ struct xfs_dir2_leaf_map_info {
286 285
287STATIC int 286STATIC int
288xfs_dir2_leaf_readbuf( 287xfs_dir2_leaf_readbuf(
289 struct xfs_inode *dp, 288 struct xfs_da_args *args,
290 size_t bufsize, 289 size_t bufsize,
291 struct xfs_dir2_leaf_map_info *mip, 290 struct xfs_dir2_leaf_map_info *mip,
292 xfs_dir2_off_t *curoff, 291 xfs_dir2_off_t *curoff,
293 struct xfs_buf **bpp) 292 struct xfs_buf **bpp)
294{ 293{
295 struct xfs_mount *mp = dp->i_mount; 294 struct xfs_inode *dp = args->dp;
296 struct xfs_buf *bp = *bpp; 295 struct xfs_buf *bp = *bpp;
297 struct xfs_bmbt_irec *map = mip->map; 296 struct xfs_bmbt_irec *map = mip->map;
298 struct blk_plug plug; 297 struct blk_plug plug;
@@ -300,6 +299,7 @@ xfs_dir2_leaf_readbuf(
300 int length; 299 int length;
301 int i; 300 int i;
302 int j; 301 int j;
302 struct xfs_da_geometry *geo = args->geo;
303 303
304 /* 304 /*
305 * If we have a buffer, we need to release it and 305 * If we have a buffer, we need to release it and
@@ -309,12 +309,12 @@ xfs_dir2_leaf_readbuf(
309 if (bp) { 309 if (bp) {
310 xfs_trans_brelse(NULL, bp); 310 xfs_trans_brelse(NULL, bp);
311 bp = NULL; 311 bp = NULL;
312 mip->map_blocks -= mp->m_dirblkfsbs; 312 mip->map_blocks -= geo->fsbcount;
313 /* 313 /*
314 * Loop to get rid of the extents for the 314 * Loop to get rid of the extents for the
315 * directory block. 315 * directory block.
316 */ 316 */
317 for (i = mp->m_dirblkfsbs; i > 0; ) { 317 for (i = geo->fsbcount; i > 0; ) {
318 j = min_t(int, map->br_blockcount, i); 318 j = min_t(int, map->br_blockcount, i);
319 map->br_blockcount -= j; 319 map->br_blockcount -= j;
320 map->br_startblock += j; 320 map->br_startblock += j;
@@ -333,8 +333,7 @@ xfs_dir2_leaf_readbuf(
333 /* 333 /*
334 * Recalculate the readahead blocks wanted. 334 * Recalculate the readahead blocks wanted.
335 */ 335 */
336 mip->ra_want = howmany(bufsize + mp->m_dirblksize, 336 mip->ra_want = howmany(bufsize + geo->blksize, (1 << geo->fsblog)) - 1;
337 mp->m_sb.sb_blocksize) - 1;
338 ASSERT(mip->ra_want >= 0); 337 ASSERT(mip->ra_want >= 0);
339 338
340 /* 339 /*
@@ -342,14 +341,14 @@ xfs_dir2_leaf_readbuf(
342 * run out of data blocks, get some more mappings. 341 * run out of data blocks, get some more mappings.
343 */ 342 */
344 if (1 + mip->ra_want > mip->map_blocks && 343 if (1 + mip->ra_want > mip->map_blocks &&
345 mip->map_off < xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET)) { 344 mip->map_off < xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET)) {
346 /* 345 /*
347 * Get more bmaps, fill in after the ones 346 * Get more bmaps, fill in after the ones
348 * we already have in the table. 347 * we already have in the table.
349 */ 348 */
350 mip->nmap = mip->map_size - mip->map_valid; 349 mip->nmap = mip->map_size - mip->map_valid;
351 error = xfs_bmapi_read(dp, mip->map_off, 350 error = xfs_bmapi_read(dp, mip->map_off,
352 xfs_dir2_byte_to_da(mp, XFS_DIR2_LEAF_OFFSET) - 351 xfs_dir2_byte_to_da(geo, XFS_DIR2_LEAF_OFFSET) -
353 mip->map_off, 352 mip->map_off,
354 &map[mip->map_valid], &mip->nmap, 0); 353 &map[mip->map_valid], &mip->nmap, 0);
355 354
@@ -370,7 +369,7 @@ xfs_dir2_leaf_readbuf(
370 i = mip->map_valid + mip->nmap - 1; 369 i = mip->map_valid + mip->nmap - 1;
371 mip->map_off = map[i].br_startoff + map[i].br_blockcount; 370 mip->map_off = map[i].br_startoff + map[i].br_blockcount;
372 } else 371 } else
373 mip->map_off = xfs_dir2_byte_to_da(mp, 372 mip->map_off = xfs_dir2_byte_to_da(geo,
374 XFS_DIR2_LEAF_OFFSET); 373 XFS_DIR2_LEAF_OFFSET);
375 374
376 /* 375 /*
@@ -396,18 +395,18 @@ xfs_dir2_leaf_readbuf(
396 * No valid mappings, so no more data blocks. 395 * No valid mappings, so no more data blocks.
397 */ 396 */
398 if (!mip->map_valid) { 397 if (!mip->map_valid) {
399 *curoff = xfs_dir2_da_to_byte(mp, mip->map_off); 398 *curoff = xfs_dir2_da_to_byte(geo, mip->map_off);
400 goto out; 399 goto out;
401 } 400 }
402 401
403 /* 402 /*
404 * Read the directory block starting at the first mapping. 403 * Read the directory block starting at the first mapping.
405 */ 404 */
406 mip->curdb = xfs_dir2_da_to_db(mp, map->br_startoff); 405 mip->curdb = xfs_dir2_da_to_db(geo, map->br_startoff);
407 error = xfs_dir3_data_read(NULL, dp, map->br_startoff, 406 error = xfs_dir3_data_read(NULL, dp, map->br_startoff,
408 map->br_blockcount >= mp->m_dirblkfsbs ? 407 map->br_blockcount >= geo->fsbcount ?
409 XFS_FSB_TO_DADDR(mp, map->br_startblock) : -1, &bp); 408 XFS_FSB_TO_DADDR(dp->i_mount, map->br_startblock) :
410 409 -1, &bp);
411 /* 410 /*
412 * Should just skip over the data block instead of giving up. 411 * Should just skip over the data block instead of giving up.
413 */ 412 */
@@ -419,7 +418,7 @@ xfs_dir2_leaf_readbuf(
419 * was previously ra. 418 * was previously ra.
420 */ 419 */
421 if (mip->ra_current) 420 if (mip->ra_current)
422 mip->ra_current -= mp->m_dirblkfsbs; 421 mip->ra_current -= geo->fsbcount;
423 422
424 /* 423 /*
425 * Do we need more readahead? 424 * Do we need more readahead?
@@ -427,16 +426,16 @@ xfs_dir2_leaf_readbuf(
427 blk_start_plug(&plug); 426 blk_start_plug(&plug);
428 for (mip->ra_index = mip->ra_offset = i = 0; 427 for (mip->ra_index = mip->ra_offset = i = 0;
429 mip->ra_want > mip->ra_current && i < mip->map_blocks; 428 mip->ra_want > mip->ra_current && i < mip->map_blocks;
430 i += mp->m_dirblkfsbs) { 429 i += geo->fsbcount) {
431 ASSERT(mip->ra_index < mip->map_valid); 430 ASSERT(mip->ra_index < mip->map_valid);
432 /* 431 /*
433 * Read-ahead a contiguous directory block. 432 * Read-ahead a contiguous directory block.
434 */ 433 */
435 if (i > mip->ra_current && 434 if (i > mip->ra_current &&
436 map[mip->ra_index].br_blockcount >= mp->m_dirblkfsbs) { 435 map[mip->ra_index].br_blockcount >= geo->fsbcount) {
437 xfs_dir3_data_readahead(dp, 436 xfs_dir3_data_readahead(dp,
438 map[mip->ra_index].br_startoff + mip->ra_offset, 437 map[mip->ra_index].br_startoff + mip->ra_offset,
439 XFS_FSB_TO_DADDR(mp, 438 XFS_FSB_TO_DADDR(dp->i_mount,
440 map[mip->ra_index].br_startblock + 439 map[mip->ra_index].br_startblock +
441 mip->ra_offset)); 440 mip->ra_offset));
442 mip->ra_current = i; 441 mip->ra_current = i;
@@ -456,12 +455,12 @@ xfs_dir2_leaf_readbuf(
456 /* 455 /*
457 * Advance offset through the mapping table. 456 * Advance offset through the mapping table.
458 */ 457 */
459 for (j = 0; j < mp->m_dirblkfsbs; j += length ) { 458 for (j = 0; j < geo->fsbcount; j += length ) {
460 /* 459 /*
461 * The rest of this extent but not more than a dir 460 * The rest of this extent but not more than a dir
462 * block. 461 * block.
463 */ 462 */
464 length = min_t(int, mp->m_dirblkfsbs, 463 length = min_t(int, geo->fsbcount,
465 map[mip->ra_index].br_blockcount - 464 map[mip->ra_index].br_blockcount -
466 mip->ra_offset); 465 mip->ra_offset);
467 mip->ra_offset += length; 466 mip->ra_offset += length;
@@ -488,22 +487,23 @@ out:
488 */ 487 */
489STATIC int 488STATIC int
490xfs_dir2_leaf_getdents( 489xfs_dir2_leaf_getdents(
491 xfs_inode_t *dp, /* incore directory inode */ 490 struct xfs_da_args *args,
492 struct dir_context *ctx, 491 struct dir_context *ctx,
493 size_t bufsize) 492 size_t bufsize)
494{ 493{
494 struct xfs_inode *dp = args->dp;
495 struct xfs_buf *bp = NULL; /* data block buffer */ 495 struct xfs_buf *bp = NULL; /* data block buffer */
496 xfs_dir2_data_hdr_t *hdr; /* data block header */ 496 xfs_dir2_data_hdr_t *hdr; /* data block header */
497 xfs_dir2_data_entry_t *dep; /* data entry */ 497 xfs_dir2_data_entry_t *dep; /* data entry */
498 xfs_dir2_data_unused_t *dup; /* unused entry */ 498 xfs_dir2_data_unused_t *dup; /* unused entry */
499 int error = 0; /* error return value */ 499 int error = 0; /* error return value */
500 int length; /* temporary length value */ 500 int length; /* temporary length value */
501 xfs_mount_t *mp; /* filesystem mount point */
502 int byteoff; /* offset in current block */ 501 int byteoff; /* offset in current block */
503 xfs_dir2_off_t curoff; /* current overall offset */ 502 xfs_dir2_off_t curoff; /* current overall offset */
504 xfs_dir2_off_t newoff; /* new curoff after new blk */ 503 xfs_dir2_off_t newoff; /* new curoff after new blk */
505 char *ptr = NULL; /* pointer to current data */ 504 char *ptr = NULL; /* pointer to current data */
506 struct xfs_dir2_leaf_map_info *map_info; 505 struct xfs_dir2_leaf_map_info *map_info;
506 struct xfs_da_geometry *geo = args->geo;
507 507
508 /* 508 /*
509 * If the offset is at or past the largest allowed value, 509 * If the offset is at or past the largest allowed value,
@@ -512,15 +512,12 @@ xfs_dir2_leaf_getdents(
512 if (ctx->pos >= XFS_DIR2_MAX_DATAPTR) 512 if (ctx->pos >= XFS_DIR2_MAX_DATAPTR)
513 return 0; 513 return 0;
514 514
515 mp = dp->i_mount;
516
517 /* 515 /*
518 * Set up to bmap a number of blocks based on the caller's 516 * Set up to bmap a number of blocks based on the caller's
519 * buffer size, the directory block size, and the filesystem 517 * buffer size, the directory block size, and the filesystem
520 * block size. 518 * block size.
521 */ 519 */
522 length = howmany(bufsize + mp->m_dirblksize, 520 length = howmany(bufsize + geo->blksize, (1 << geo->fsblog));
523 mp->m_sb.sb_blocksize);
524 map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) + 521 map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) +
525 (length * sizeof(struct xfs_bmbt_irec)), 522 (length * sizeof(struct xfs_bmbt_irec)),
526 KM_SLEEP | KM_NOFS); 523 KM_SLEEP | KM_NOFS);
@@ -536,8 +533,8 @@ xfs_dir2_leaf_getdents(
536 * Force this conversion through db so we truncate the offset 533 * Force this conversion through db so we truncate the offset
537 * down to get the start of the data block. 534 * down to get the start of the data block.
538 */ 535 */
539 map_info->map_off = xfs_dir2_db_to_da(mp, 536 map_info->map_off = xfs_dir2_db_to_da(geo,
540 xfs_dir2_byte_to_db(mp, curoff)); 537 xfs_dir2_byte_to_db(geo, curoff));
541 538
542 /* 539 /*
543 * Loop over directory entries until we reach the end offset. 540 * Loop over directory entries until we reach the end offset.
@@ -550,9 +547,9 @@ xfs_dir2_leaf_getdents(
550 * If we have no buffer, or we're off the end of the 547 * If we have no buffer, or we're off the end of the
551 * current buffer, need to get another one. 548 * current buffer, need to get another one.
552 */ 549 */
553 if (!bp || ptr >= (char *)bp->b_addr + mp->m_dirblksize) { 550 if (!bp || ptr >= (char *)bp->b_addr + geo->blksize) {
554 551
555 error = xfs_dir2_leaf_readbuf(dp, bufsize, map_info, 552 error = xfs_dir2_leaf_readbuf(args, bufsize, map_info,
556 &curoff, &bp); 553 &curoff, &bp);
557 if (error || !map_info->map_valid) 554 if (error || !map_info->map_valid)
558 break; 555 break;
@@ -560,7 +557,8 @@ xfs_dir2_leaf_getdents(
560 /* 557 /*
561 * Having done a read, we need to set a new offset. 558 * Having done a read, we need to set a new offset.
562 */ 559 */
563 newoff = xfs_dir2_db_off_to_byte(mp, map_info->curdb, 0); 560 newoff = xfs_dir2_db_off_to_byte(geo,
561 map_info->curdb, 0);
564 /* 562 /*
565 * Start of the current block. 563 * Start of the current block.
566 */ 564 */
@@ -570,7 +568,7 @@ xfs_dir2_leaf_getdents(
570 * Make sure we're in the right block. 568 * Make sure we're in the right block.
571 */ 569 */
572 else if (curoff > newoff) 570 else if (curoff > newoff)
573 ASSERT(xfs_dir2_byte_to_db(mp, curoff) == 571 ASSERT(xfs_dir2_byte_to_db(geo, curoff) ==
574 map_info->curdb); 572 map_info->curdb);
575 hdr = bp->b_addr; 573 hdr = bp->b_addr;
576 xfs_dir3_data_check(dp, bp); 574 xfs_dir3_data_check(dp, bp);
@@ -578,7 +576,7 @@ xfs_dir2_leaf_getdents(
578 * Find our position in the block. 576 * Find our position in the block.
579 */ 577 */
580 ptr = (char *)dp->d_ops->data_entry_p(hdr); 578 ptr = (char *)dp->d_ops->data_entry_p(hdr);
581 byteoff = xfs_dir2_byte_to_off(mp, curoff); 579 byteoff = xfs_dir2_byte_to_off(geo, curoff);
582 /* 580 /*
583 * Skip past the header. 581 * Skip past the header.
584 */ 582 */
@@ -607,10 +605,10 @@ xfs_dir2_leaf_getdents(
607 * Now set our real offset. 605 * Now set our real offset.
608 */ 606 */
609 curoff = 607 curoff =
610 xfs_dir2_db_off_to_byte(mp, 608 xfs_dir2_db_off_to_byte(geo,
611 xfs_dir2_byte_to_db(mp, curoff), 609 xfs_dir2_byte_to_db(geo, curoff),
612 (char *)ptr - (char *)hdr); 610 (char *)ptr - (char *)hdr);
613 if (ptr >= (char *)hdr + mp->m_dirblksize) { 611 if (ptr >= (char *)hdr + geo->blksize) {
614 continue; 612 continue;
615 } 613 }
616 } 614 }
@@ -637,7 +635,7 @@ xfs_dir2_leaf_getdents(
637 ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff; 635 ctx->pos = xfs_dir2_byte_to_dataptr(curoff) & 0x7fffffff;
638 if (!dir_emit(ctx, (char *)dep->name, dep->namelen, 636 if (!dir_emit(ctx, (char *)dep->name, dep->namelen,
639 be64_to_cpu(dep->inumber), 637 be64_to_cpu(dep->inumber),
640 xfs_dir3_get_dtype(mp, filetype))) 638 xfs_dir3_get_dtype(dp->i_mount, filetype)))
641 break; 639 break;
642 640
643 /* 641 /*
@@ -667,13 +665,14 @@ xfs_dir2_leaf_getdents(
667 */ 665 */
668int 666int
669xfs_readdir( 667xfs_readdir(
670 xfs_inode_t *dp, 668 struct xfs_inode *dp,
671 struct dir_context *ctx, 669 struct dir_context *ctx,
672 size_t bufsize) 670 size_t bufsize)
673{ 671{
674 int rval; /* return value */ 672 struct xfs_da_args args = { NULL };
675 int v; /* type-checking value */ 673 int rval;
676 uint lock_mode; 674 int v;
675 uint lock_mode;
677 676
678 trace_xfs_readdir(dp); 677 trace_xfs_readdir(dp);
679 678
@@ -683,15 +682,18 @@ xfs_readdir(
683 ASSERT(S_ISDIR(dp->i_d.di_mode)); 682 ASSERT(S_ISDIR(dp->i_d.di_mode));
684 XFS_STATS_INC(xs_dir_getdents); 683 XFS_STATS_INC(xs_dir_getdents);
685 684
685 args.dp = dp;
686 args.geo = dp->i_mount->m_dir_geo;
687
686 lock_mode = xfs_ilock_data_map_shared(dp); 688 lock_mode = xfs_ilock_data_map_shared(dp);
687 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL) 689 if (dp->i_d.di_format == XFS_DINODE_FMT_LOCAL)
688 rval = xfs_dir2_sf_getdents(dp, ctx); 690 rval = xfs_dir2_sf_getdents(&args, ctx);
689 else if ((rval = xfs_dir2_isblock(dp, &v))) 691 else if ((rval = xfs_dir2_isblock(&args, &v)))
690 ; 692 ;
691 else if (v) 693 else if (v)
692 rval = xfs_dir2_block_getdents(dp, ctx); 694 rval = xfs_dir2_block_getdents(&args, ctx);
693 else 695 else
694 rval = xfs_dir2_leaf_getdents(dp, ctx, bufsize); 696 rval = xfs_dir2_leaf_getdents(&args, ctx, bufsize);
695 xfs_iunlock(dp, lock_mode); 697 xfs_iunlock(dp, lock_mode);
696 698
697 return rval; 699 return rval;
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 7aab8ec117ad..53c3be619db5 100644
--- a/fs/xfs/xfs_dir2_sf.c
+++ b/fs/xfs/xfs_dir2_sf.c
@@ -82,8 +82,10 @@ xfs_dir2_block_sfsize(
82 xfs_ino_t parent = 0; /* parent inode number */ 82 xfs_ino_t parent = 0; /* parent inode number */
83 int size=0; /* total computed size */ 83 int size=0; /* total computed size */
84 int has_ftype; 84 int has_ftype;
85 struct xfs_da_geometry *geo;
85 86
86 mp = dp->i_mount; 87 mp = dp->i_mount;
88 geo = mp->m_dir_geo;
87 89
88 /* 90 /*
89 * if there is a filetype field, add the extra byte to the namelen 91 * if there is a filetype field, add the extra byte to the namelen
@@ -92,7 +94,7 @@ xfs_dir2_block_sfsize(
92 has_ftype = xfs_sb_version_hasftype(&mp->m_sb) ? 1 : 0; 94 has_ftype = xfs_sb_version_hasftype(&mp->m_sb) ? 1 : 0;
93 95
94 count = i8count = namelen = 0; 96 count = i8count = namelen = 0;
95 btp = xfs_dir2_block_tail_p(mp, hdr); 97 btp = xfs_dir2_block_tail_p(geo, hdr);
96 blp = xfs_dir2_block_leaf_p(btp); 98 blp = xfs_dir2_block_leaf_p(btp);
97 99
98 /* 100 /*
@@ -104,8 +106,8 @@ xfs_dir2_block_sfsize(
104 /* 106 /*
105 * Calculate the pointer to the entry at hand. 107 * Calculate the pointer to the entry at hand.
106 */ 108 */
107 dep = (xfs_dir2_data_entry_t *) 109 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
108 ((char *)hdr + xfs_dir2_dataptr_to_off(mp, addr)); 110 xfs_dir2_dataptr_to_off(geo, addr));
109 /* 111 /*
110 * Detect . and .., so we can special-case them. 112 * Detect . and .., so we can special-case them.
111 * . is not included in sf directories. 113 * . is not included in sf directories.
@@ -195,7 +197,7 @@ xfs_dir2_block_to_sf(
195 /* 197 /*
196 * Set up to loop over the block's entries. 198 * Set up to loop over the block's entries.
197 */ 199 */
198 btp = xfs_dir2_block_tail_p(mp, hdr); 200 btp = xfs_dir2_block_tail_p(args->geo, hdr);
199 ptr = (char *)dp->d_ops->data_entry_p(hdr); 201 ptr = (char *)dp->d_ops->data_entry_p(hdr);
200 endptr = (char *)xfs_dir2_block_leaf_p(btp); 202 endptr = (char *)xfs_dir2_block_leaf_p(btp);
201 sfep = xfs_dir2_sf_firstentry(sfp); 203 sfep = xfs_dir2_sf_firstentry(sfp);
@@ -247,7 +249,7 @@ xfs_dir2_block_to_sf(
247 249
248 /* now we are done with the block, we can shrink the inode */ 250 /* now we are done with the block, we can shrink the inode */
249 logflags = XFS_ILOG_CORE; 251 logflags = XFS_ILOG_CORE;
250 error = xfs_dir2_shrink_inode(args, mp->m_dirdatablk, bp); 252 error = xfs_dir2_shrink_inode(args, args->geo->datablk, bp);
251 if (error) { 253 if (error) {
252 ASSERT(error != ENOSPC); 254 ASSERT(error != ENOSPC);
253 goto out; 255 goto out;
@@ -586,7 +588,7 @@ xfs_dir2_sf_addname_pick(
586 * we'll go back, convert to block, then try the insert and convert 588 * we'll go back, convert to block, then try the insert and convert
587 * to leaf. 589 * to leaf.
588 */ 590 */
589 if (used + (holefit ? 0 : size) > mp->m_dirblksize) 591 if (used + (holefit ? 0 : size) > args->geo->blksize)
590 return 0; 592 return 0;
591 /* 593 /*
592 * If changing the inode number size, do it the hard way. 594 * If changing the inode number size, do it the hard way.
@@ -601,7 +603,7 @@ xfs_dir2_sf_addname_pick(
601 /* 603 /*
602 * If it won't fit at the end then do it the hard way (use the hole). 604 * If it won't fit at the end then do it the hard way (use the hole).
603 */ 605 */
604 if (used + size > mp->m_dirblksize) 606 if (used + size > args->geo->blksize)
605 return 2; 607 return 2;
606 /* 608 /*
607 * Do it the easy way. 609 * Do it the easy way.
@@ -652,7 +654,7 @@ xfs_dir2_sf_check(
652 ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size); 654 ASSERT((char *)sfep - (char *)sfp == dp->i_d.di_size);
653 ASSERT(offset + 655 ASSERT(offset +
654 (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) + 656 (sfp->count + 2) * (uint)sizeof(xfs_dir2_leaf_entry_t) +
655 (uint)sizeof(xfs_dir2_block_tail_t) <= mp->m_dirblksize); 657 (uint)sizeof(xfs_dir2_block_tail_t) <= args->geo->blksize);
656} 658}
657#endif /* DEBUG */ 659#endif /* DEBUG */
658 660
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 97886a74e073..d2295561570a 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -24,6 +24,8 @@
24#include "xfs_sb.h" 24#include "xfs_sb.h"
25#include "xfs_ag.h" 25#include "xfs_ag.h"
26#include "xfs_mount.h" 26#include "xfs_mount.h"
27#include "xfs_da_format.h"
28#include "xfs_da_btree.h"
27#include "xfs_inode.h" 29#include "xfs_inode.h"
28#include "xfs_trans.h" 30#include "xfs_trans.h"
29#include "xfs_inode_item.h" 31#include "xfs_inode_item.h"
@@ -105,7 +107,7 @@ xfs_fs_geometry(
105 geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ? 107 geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ?
106 mp->m_sb.sb_logsectsize : BBSIZE; 108 mp->m_sb.sb_logsectsize : BBSIZE;
107 geo->rtsectsize = mp->m_sb.sb_blocksize; 109 geo->rtsectsize = mp->m_sb.sb_blocksize;
108 geo->dirblocksize = mp->m_dirblksize; 110 geo->dirblocksize = mp->m_dir_geo->blksize;
109 } 111 }
110 if (new_version >= 4) { 112 if (new_version >= 4) {
111 geo->flags |= 113 geo->flags |=
diff --git a/fs/xfs/xfs_log_rlimit.c b/fs/xfs/xfs_log_rlimit.c
index 2af1a0a4d0f1..ee7e0e80246b 100644
--- a/fs/xfs/xfs_log_rlimit.c
+++ b/fs/xfs/xfs_log_rlimit.c
@@ -42,7 +42,7 @@ xfs_log_calc_max_attrsetm_res(
42 int size; 42 int size;
43 int nblks; 43 int nblks;
44 44
45 size = xfs_attr_leaf_entsize_local_max(mp->m_sb.sb_blocksize) - 45 size = xfs_attr_leaf_entsize_local_max(mp->m_attr_geo->blksize) -
46 MAXNAMELEN - 1; 46 MAXNAMELEN - 1;
47 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK); 47 nblks = XFS_DAENTER_SPACE_RES(mp, XFS_ATTR_FORK);
48 nblks += XFS_B_TO_FSB(mp, size); 48 nblks += XFS_B_TO_FSB(mp, size);
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 3f097825eff3..03c9d645865c 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -780,12 +780,11 @@ xfs_mountfs(
780 780
781 mp->m_dmevmask = 0; /* not persistent; set after each mount */ 781 mp->m_dmevmask = 0; /* not persistent; set after each mount */
782 782
783 xfs_dir_mount(mp); 783 error = xfs_da_mount(mp);
784 784 if (error) {
785 /* 785 xfs_warn(mp, "Failed dir/attr init: %d", error);
786 * Initialize the attribute manager's entries. 786 goto out_remove_uuid;
787 */ 787 }
788 mp->m_attr_magicpct = (mp->m_sb.sb_blocksize * 37) / 100;
789 788
790 /* 789 /*
791 * Initialize the precomputed transaction reservations values. 790 * Initialize the precomputed transaction reservations values.
@@ -800,7 +799,7 @@ xfs_mountfs(
800 error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi); 799 error = xfs_initialize_perag(mp, sbp->sb_agcount, &mp->m_maxagi);
801 if (error) { 800 if (error) {
802 xfs_warn(mp, "Failed per-ag init: %d", error); 801 xfs_warn(mp, "Failed per-ag init: %d", error);
803 goto out_remove_uuid; 802 goto out_free_dir;
804 } 803 }
805 804
806 if (!sbp->sb_logblocks) { 805 if (!sbp->sb_logblocks) {
@@ -975,6 +974,8 @@ xfs_mountfs(
975 xfs_wait_buftarg(mp->m_ddev_targp); 974 xfs_wait_buftarg(mp->m_ddev_targp);
976 out_free_perag: 975 out_free_perag:
977 xfs_free_perag(mp); 976 xfs_free_perag(mp);
977 out_free_dir:
978 xfs_da_unmount(mp);
978 out_remove_uuid: 979 out_remove_uuid:
979 xfs_uuid_unmount(mp); 980 xfs_uuid_unmount(mp);
980 out: 981 out:
@@ -1052,6 +1053,7 @@ xfs_unmountfs(
1052 "Freespace may not be correct on next mount."); 1053 "Freespace may not be correct on next mount.");
1053 1054
1054 xfs_log_unmount(mp); 1055 xfs_log_unmount(mp);
1056 xfs_da_unmount(mp);
1055 xfs_uuid_unmount(mp); 1057 xfs_uuid_unmount(mp);
1056 1058
1057#if defined(DEBUG) 1059#if defined(DEBUG)
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index a466c5e5826e..7295a0b7c343 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -27,6 +27,7 @@ struct xfs_nameops;
27struct xfs_ail; 27struct xfs_ail;
28struct xfs_quotainfo; 28struct xfs_quotainfo;
29struct xfs_dir_ops; 29struct xfs_dir_ops;
30struct xfs_da_geometry;
30 31
31#ifdef HAVE_PERCPU_SB 32#ifdef HAVE_PERCPU_SB
32 33
@@ -96,6 +97,8 @@ typedef struct xfs_mount {
96 uint m_readio_blocks; /* min read size blocks */ 97 uint m_readio_blocks; /* min read size blocks */
97 uint m_writeio_log; /* min write size log bytes */ 98 uint m_writeio_log; /* min write size log bytes */
98 uint m_writeio_blocks; /* min write size blocks */ 99 uint m_writeio_blocks; /* min write size blocks */
100 struct xfs_da_geometry *m_dir_geo; /* directory block geometry */
101 struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */
99 struct xlog *m_log; /* log specific stuff */ 102 struct xlog *m_log; /* log specific stuff */
100 int m_logbufs; /* number of log buffers */ 103 int m_logbufs; /* number of log buffers */
101 int m_logbsize; /* size of each log buffer */ 104 int m_logbsize; /* size of each log buffer */
@@ -131,8 +134,6 @@ typedef struct xfs_mount {
131 int m_fixedfsid[2]; /* unchanged for life of FS */ 134 int m_fixedfsid[2]; /* unchanged for life of FS */
132 uint m_dmevmask; /* DMI events for this FS */ 135 uint m_dmevmask; /* DMI events for this FS */
133 __uint64_t m_flags; /* global mount flags */ 136 __uint64_t m_flags; /* global mount flags */
134 uint m_dir_node_ents; /* #entries in a dir danode */
135 uint m_attr_node_ents; /* #entries in attr danode */
136 int m_ialloc_inos; /* inodes in inode allocation */ 137 int m_ialloc_inos; /* inodes in inode allocation */
137 int m_ialloc_blks; /* blocks in inode allocation */ 138 int m_ialloc_blks; /* blocks in inode allocation */
138 int m_inoalign_mask;/* mask sb_inoalignmt if used */ 139 int m_inoalign_mask;/* mask sb_inoalignmt if used */
@@ -145,17 +146,10 @@ typedef struct xfs_mount {
145 int m_dalign; /* stripe unit */ 146 int m_dalign; /* stripe unit */
146 int m_swidth; /* stripe width */ 147 int m_swidth; /* stripe width */
147 int m_sinoalign; /* stripe unit inode alignment */ 148 int m_sinoalign; /* stripe unit inode alignment */
148 int m_attr_magicpct;/* 37% of the blocksize */
149 int m_dir_magicpct; /* 37% of the dir blocksize */
150 __uint8_t m_sectbb_log; /* sectlog - BBSHIFT */ 149 __uint8_t m_sectbb_log; /* sectlog - BBSHIFT */
151 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ 150 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
152 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ 151 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */
153 const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ 152 const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */
154 int m_dirblksize; /* directory block sz--bytes */
155 int m_dirblkfsbs; /* directory block sz--fsbs */
156 xfs_dablk_t m_dirdatablk; /* blockno of dir data v2 */
157 xfs_dablk_t m_dirleafblk; /* blockno of dir non-data v2 */
158 xfs_dablk_t m_dirfreeblk; /* blockno of dirfreeindex v2 */
159 uint m_chsize; /* size of next field */ 153 uint m_chsize; /* size of next field */
160 atomic_t m_active_trans; /* number trans frozen */ 154 atomic_t m_active_trans; /* number trans frozen */
161#ifdef HAVE_PERCPU_SB 155#ifdef HAVE_PERCPU_SB
diff --git a/fs/xfs/xfs_symlink.c b/fs/xfs/xfs_symlink.c
index 0816b4018dfc..d69363c833e1 100644
--- a/fs/xfs/xfs_symlink.c
+++ b/fs/xfs/xfs_symlink.c
@@ -27,6 +27,7 @@
27#include "xfs_ag.h" 27#include "xfs_ag.h"
28#include "xfs_mount.h" 28#include "xfs_mount.h"
29#include "xfs_da_format.h" 29#include "xfs_da_format.h"
30#include "xfs_da_btree.h"
30#include "xfs_dir2.h" 31#include "xfs_dir2.h"
31#include "xfs_inode.h" 32#include "xfs_inode.h"
32#include "xfs_ialloc.h" 33#include "xfs_ialloc.h"
diff --git a/fs/xfs/xfs_trans_resv.c b/fs/xfs/xfs_trans_resv.c
index 52b6c3e3203e..f2bda7c76b8a 100644
--- a/fs/xfs/xfs_trans_resv.c
+++ b/fs/xfs/xfs_trans_resv.c
@@ -26,6 +26,7 @@
26#include "xfs_ag.h" 26#include "xfs_ag.h"
27#include "xfs_mount.h" 27#include "xfs_mount.h"
28#include "xfs_da_format.h" 28#include "xfs_da_format.h"
29#include "xfs_da_btree.h"
29#include "xfs_inode.h" 30#include "xfs_inode.h"
30#include "xfs_bmap_btree.h" 31#include "xfs_bmap_btree.h"
31#include "xfs_ialloc.h" 32#include "xfs_ialloc.h"
@@ -609,7 +610,7 @@ xfs_calc_addafork_reservation(
609 return XFS_DQUOT_LOGRES(mp) + 610 return XFS_DQUOT_LOGRES(mp) +
610 xfs_calc_inode_res(mp, 1) + 611 xfs_calc_inode_res(mp, 1) +
611 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + 612 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
612 xfs_calc_buf_res(1, mp->m_dirblksize) + 613 xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
613 xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1, 614 xfs_calc_buf_res(XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK) + 1,
614 XFS_FSB_TO_B(mp, 1)) + 615 XFS_FSB_TO_B(mp, 1)) +
615 xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), 616 xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1),
diff --git a/fs/xfs/xfs_trans_space.h b/fs/xfs/xfs_trans_space.h
index df4c1f81884c..bf9c4579334d 100644
--- a/fs/xfs/xfs_trans_space.h
+++ b/fs/xfs/xfs_trans_space.h
@@ -28,7 +28,8 @@
28 (((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \ 28 (((b + XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp) - 1) / \
29 XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \ 29 XFS_MAX_CONTIG_EXTENTS_PER_BLOCK(mp)) * \
30 XFS_EXTENTADD_SPACE_RES(mp,w)) 30 XFS_EXTENTADD_SPACE_RES(mp,w))
31#define XFS_DAENTER_1B(mp,w) ((w) == XFS_DATA_FORK ? (mp)->m_dirblkfsbs : 1) 31#define XFS_DAENTER_1B(mp,w) \
32 ((w) == XFS_DATA_FORK ? (mp)->m_dir_geo->fsbcount : 1)
32#define XFS_DAENTER_DBS(mp,w) \ 33#define XFS_DAENTER_DBS(mp,w) \
33 (XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0)) 34 (XFS_DA_NODE_MAXDEPTH + (((w) == XFS_DATA_FORK) ? 2 : 0))
34#define XFS_DAENTER_BLOCKS(mp,w) \ 35#define XFS_DAENTER_BLOCKS(mp,w) \
@@ -55,7 +56,7 @@
55 * Space reservation values for various transactions. 56 * Space reservation values for various transactions.
56 */ 57 */
57#define XFS_ADDAFORK_SPACE_RES(mp) \ 58#define XFS_ADDAFORK_SPACE_RES(mp) \
58 ((mp)->m_dirblkfsbs + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK)) 59 ((mp)->m_dir_geo->fsbcount + XFS_DAENTER_BMAP1B(mp, XFS_DATA_FORK))
59#define XFS_ATTRRM_SPACE_RES(mp) \ 60#define XFS_ATTRRM_SPACE_RES(mp) \
60 XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK) 61 XFS_DAREMOVE_SPACE_RES(mp, XFS_ATTR_FORK)
61/* This macro is not used - see inline code in xfs_attr_set */ 62/* This macro is not used - see inline code in xfs_attr_set */