aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-06-06 01:15:59 -0400
committerDave Chinner <david@fromorbit.com>2014-06-06 01:15:59 -0400
commit8f66193c89f0b0259db6b27b4df3deb828c294f9 (patch)
tree333c24e2c4d901d044e5b2c3c820cb680919f73c /fs/xfs
parentd6cf13051f31bf1a54b65643d0e578b3ca2f0692 (diff)
xfs: convert m_dirblksize to xfs_da_geometry
Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/xfs_da_btree.c4
-rw-r--r--fs/xfs/xfs_da_format.c36
-rw-r--r--fs/xfs/xfs_dir2.c5
-rw-r--r--fs/xfs/xfs_dir2.h10
-rw-r--r--fs/xfs/xfs_dir2_block.c32
-rw-r--r--fs/xfs/xfs_dir2_data.c17
-rw-r--r--fs/xfs/xfs_dir2_leaf.c35
-rw-r--r--fs/xfs/xfs_dir2_node.c42
-rw-r--r--fs/xfs/xfs_dir2_priv.h8
-rw-r--r--fs/xfs/xfs_dir2_readdir.c11
-rw-r--r--fs/xfs/xfs_dir2_sf.c14
-rw-r--r--fs/xfs/xfs_fsops.c4
-rw-r--r--fs/xfs/xfs_mount.h1
-rw-r--r--fs/xfs/xfs_trans_resv.c2
14 files changed, 115 insertions, 106 deletions
diff --git a/fs/xfs/xfs_da_btree.c b/fs/xfs/xfs_da_btree.c
index 70b934392f73..653e23f17f79 100644
--- a/fs/xfs/xfs_da_btree.c
+++ b/fs/xfs/xfs_da_btree.c
@@ -2169,8 +2169,8 @@ xfs_da3_swap_lastblock(
2169 /* 2169 /*
2170 * Copy the last block into the dead buffer and log it. 2170 * Copy the last block into the dead buffer and log it.
2171 */ 2171 */
2172 memcpy(dead_buf->b_addr, last_buf->b_addr, mp->m_dirblksize); 2172 memcpy(dead_buf->b_addr, last_buf->b_addr, args->geo->blksize);
2173 xfs_trans_log_buf(tp, dead_buf, 0, mp->m_dirblksize - 1); 2173 xfs_trans_log_buf(tp, dead_buf, 0, args->geo->blksize - 1);
2174 dead_info = dead_buf->b_addr; 2174 dead_info = dead_buf->b_addr;
2175 /* 2175 /*
2176 * Get values from the moved block. 2176 * Get values from the moved block.
diff --git a/fs/xfs/xfs_da_format.c b/fs/xfs/xfs_da_format.c
index ac8474e22e2b..c9aee52a37e2 100644
--- a/fs/xfs/xfs_da_format.c
+++ b/fs/xfs/xfs_da_format.c
@@ -427,9 +427,9 @@ xfs_dir3_data_unused_p(struct xfs_dir2_data_hdr *hdr)
427 * Directory Leaf block operations 427 * Directory Leaf block operations
428 */ 428 */
429static int 429static int
430xfs_dir2_max_leaf_ents(struct xfs_mount *mp) 430xfs_dir2_max_leaf_ents(struct xfs_da_geometry *geo)
431{ 431{
432 return (mp->m_dirblksize - sizeof(struct xfs_dir2_leaf_hdr)) / 432 return (geo->blksize - sizeof(struct xfs_dir2_leaf_hdr)) /
433 (uint)sizeof(struct xfs_dir2_leaf_entry); 433 (uint)sizeof(struct xfs_dir2_leaf_entry);
434} 434}
435 435
@@ -440,9 +440,9 @@ xfs_dir2_leaf_ents_p(struct xfs_dir2_leaf *lp)
440} 440}
441 441
442static int 442static int
443xfs_dir3_max_leaf_ents(struct xfs_mount *mp) 443xfs_dir3_max_leaf_ents(struct xfs_da_geometry *geo)
444{ 444{
445 return (mp->m_dirblksize - sizeof(struct xfs_dir3_leaf_hdr)) / 445 return (geo->blksize - sizeof(struct xfs_dir3_leaf_hdr)) /
446 (uint)sizeof(struct xfs_dir2_leaf_entry); 446 (uint)sizeof(struct xfs_dir2_leaf_entry);
447} 447}
448 448
@@ -593,9 +593,9 @@ xfs_da3_node_hdr_to_disk(
593 * Directory free space block operations 593 * Directory free space block operations
594 */ 594 */
595static int 595static int
596xfs_dir2_free_max_bests(struct xfs_mount *mp) 596xfs_dir2_free_max_bests(struct xfs_da_geometry *geo)
597{ 597{
598 return (mp->m_dirblksize - sizeof(struct xfs_dir2_free_hdr)) / 598 return (geo->blksize - sizeof(struct xfs_dir2_free_hdr)) /
599 sizeof(xfs_dir2_data_off_t); 599 sizeof(xfs_dir2_data_off_t);
600} 600}
601 601
@@ -609,25 +609,25 @@ xfs_dir2_free_bests_p(struct xfs_dir2_free *free)
609 * Convert data space db to the corresponding free db. 609 * Convert data space db to the corresponding free db.
610 */ 610 */
611static xfs_dir2_db_t 611static xfs_dir2_db_t
612xfs_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)
613{ 613{
614 return xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) + 614 return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
615 (db / xfs_dir2_free_max_bests(mp)); 615 (db / xfs_dir2_free_max_bests(geo));
616} 616}
617 617
618/* 618/*
619 * 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.
620 */ 620 */
621static int 621static int
622xfs_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)
623{ 623{
624 return db % xfs_dir2_free_max_bests(mp); 624 return db % xfs_dir2_free_max_bests(geo);
625} 625}
626 626
627static int 627static int
628xfs_dir3_free_max_bests(struct xfs_mount *mp) 628xfs_dir3_free_max_bests(struct xfs_da_geometry *geo)
629{ 629{
630 return (mp->m_dirblksize - sizeof(struct xfs_dir3_free_hdr)) / 630 return (geo->blksize - sizeof(struct xfs_dir3_free_hdr)) /
631 sizeof(xfs_dir2_data_off_t); 631 sizeof(xfs_dir2_data_off_t);
632} 632}
633 633
@@ -641,19 +641,19 @@ xfs_dir3_free_bests_p(struct xfs_dir2_free *free)
641 * Convert data space db to the corresponding free db. 641 * Convert data space db to the corresponding free db.
642 */ 642 */
643static xfs_dir2_db_t 643static xfs_dir2_db_t
644xfs_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)
645{ 645{
646 return xfs_dir2_byte_to_db(mp->m_dir_geo, XFS_DIR2_FREE_OFFSET) + 646 return xfs_dir2_byte_to_db(geo, XFS_DIR2_FREE_OFFSET) +
647 (db / xfs_dir3_free_max_bests(mp)); 647 (db / xfs_dir3_free_max_bests(geo));
648} 648}
649 649
650/* 650/*
651 * 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.
652 */ 652 */
653static int 653static int
654xfs_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)
655{ 655{
656 return db % xfs_dir3_free_max_bests(mp); 656 return db % xfs_dir3_free_max_bests(geo);
657} 657}
658 658
659static void 659static void
diff --git a/fs/xfs/xfs_dir2.c b/fs/xfs/xfs_dir2.c
index 3fbf0110eeb3..2685552480f0 100644
--- a/fs/xfs/xfs_dir2.c
+++ b/fs/xfs/xfs_dir2.c
@@ -145,7 +145,6 @@ xfs_da_mount(
145 mp->m_dirnameops = &xfs_default_nameops; 145 mp->m_dirnameops = &xfs_default_nameops;
146 146
147 /* XXX: these are to be removed as code is converted to use geo */ 147 /* XXX: these are to be removed as code is converted to use geo */
148 mp->m_dirblksize = mp->m_dir_geo->blksize;
149 mp->m_dir_node_ents = mp->m_dir_geo->node_ents; 148 mp->m_dir_node_ents = mp->m_dir_geo->node_ents;
150 mp->m_dir_magicpct = mp->m_dir_geo->magicpct; 149 mp->m_dir_magicpct = mp->m_dir_geo->magicpct;
151 mp->m_attr_node_ents = mp->m_attr_geo->node_ents; 150 mp->m_attr_node_ents = mp->m_attr_geo->node_ents;
@@ -665,8 +664,8 @@ xfs_dir2_isblock(
665 mp = dp->i_mount; 664 mp = dp->i_mount;
666 if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK))) 665 if ((rval = xfs_bmap_last_offset(dp, &last, XFS_DATA_FORK)))
667 return rval; 666 return rval;
668 rval = XFS_FSB_TO_B(mp, last) == mp->m_dirblksize; 667 rval = XFS_FSB_TO_B(mp, last) == mp->m_dir_geo->blksize;
669 ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dirblksize); 668 ASSERT(rval == 0 || dp->i_d.di_size == mp->m_dir_geo->blksize);
670 *vp = rval; 669 *vp = rval;
671 return 0; 670 return 0;
672} 671}
diff --git a/fs/xfs/xfs_dir2.h b/fs/xfs/xfs_dir2.h
index 7a85b9c1f849..9b709ae3ba1e 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 *
diff --git a/fs/xfs/xfs_dir2_block.c b/fs/xfs/xfs_dir2_block.c
index d950cde3afeb..4204df966980 100644
--- a/fs/xfs/xfs_dir2_block.c
+++ b/fs/xfs/xfs_dir2_block.c
@@ -377,7 +377,7 @@ xfs_dir2_block_addname(
377 * Set up pointers to parts of the block. 377 * Set up pointers to parts of the block.
378 */ 378 */
379 hdr = bp->b_addr; 379 hdr = bp->b_addr;
380 btp = xfs_dir2_block_tail_p(mp, hdr); 380 btp = xfs_dir2_block_tail_p(args->geo, hdr);
381 blp = xfs_dir2_block_leaf_p(btp); 381 blp = xfs_dir2_block_leaf_p(btp);
382 382
383 /* 383 /*
@@ -581,7 +581,7 @@ xfs_dir2_block_log_leaf(
581 xfs_dir2_leaf_entry_t *blp; 581 xfs_dir2_leaf_entry_t *blp;
582 xfs_dir2_block_tail_t *btp; 582 xfs_dir2_block_tail_t *btp;
583 583
584 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 584 btp = xfs_dir2_block_tail_p(tp->t_mountp->m_dir_geo, hdr);
585 blp = xfs_dir2_block_leaf_p(btp); 585 blp = xfs_dir2_block_leaf_p(btp);
586 xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr), 586 xfs_trans_log_buf(tp, bp, (uint)((char *)&blp[first] - (char *)hdr),
587 (uint)((char *)&blp[last + 1] - (char *)hdr - 1)); 587 (uint)((char *)&blp[last + 1] - (char *)hdr - 1));
@@ -598,7 +598,7 @@ xfs_dir2_block_log_tail(
598 xfs_dir2_data_hdr_t *hdr = bp->b_addr; 598 xfs_dir2_data_hdr_t *hdr = bp->b_addr;
599 xfs_dir2_block_tail_t *btp; 599 xfs_dir2_block_tail_t *btp;
600 600
601 btp = xfs_dir2_block_tail_p(tp->t_mountp, hdr); 601 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), 602 xfs_trans_log_buf(tp, bp, (uint)((char *)btp - (char *)hdr),
603 (uint)((char *)(btp + 1) - (char *)hdr - 1)); 603 (uint)((char *)(btp + 1) - (char *)hdr - 1));
604} 604}
@@ -633,7 +633,7 @@ xfs_dir2_block_lookup(
633 mp = dp->i_mount; 633 mp = dp->i_mount;
634 hdr = bp->b_addr; 634 hdr = bp->b_addr;
635 xfs_dir3_data_check(dp, bp); 635 xfs_dir3_data_check(dp, bp);
636 btp = xfs_dir2_block_tail_p(mp, hdr); 636 btp = xfs_dir2_block_tail_p(args->geo, hdr);
637 blp = xfs_dir2_block_leaf_p(btp); 637 blp = xfs_dir2_block_leaf_p(btp);
638 /* 638 /*
639 * Get the offset from the leaf entry, to point to the data. 639 * Get the offset from the leaf entry, to point to the data.
@@ -686,7 +686,7 @@ xfs_dir2_block_lookup_int(
686 686
687 hdr = bp->b_addr; 687 hdr = bp->b_addr;
688 xfs_dir3_data_check(dp, bp); 688 xfs_dir3_data_check(dp, bp);
689 btp = xfs_dir2_block_tail_p(mp, hdr); 689 btp = xfs_dir2_block_tail_p(args->geo, hdr);
690 blp = xfs_dir2_block_leaf_p(btp); 690 blp = xfs_dir2_block_leaf_p(btp);
691 /* 691 /*
692 * Loop doing a binary search for our hash value. 692 * Loop doing a binary search for our hash value.
@@ -791,7 +791,7 @@ xfs_dir2_block_removename(
791 tp = args->trans; 791 tp = args->trans;
792 mp = dp->i_mount; 792 mp = dp->i_mount;
793 hdr = bp->b_addr; 793 hdr = bp->b_addr;
794 btp = xfs_dir2_block_tail_p(mp, hdr); 794 btp = xfs_dir2_block_tail_p(args->geo, hdr);
795 blp = xfs_dir2_block_leaf_p(btp); 795 blp = xfs_dir2_block_leaf_p(btp);
796 /* 796 /*
797 * Point to the data entry using the leaf entry. 797 * Point to the data entry using the leaf entry.
@@ -867,7 +867,7 @@ xfs_dir2_block_replace(
867 dp = args->dp; 867 dp = args->dp;
868 mp = dp->i_mount; 868 mp = dp->i_mount;
869 hdr = bp->b_addr; 869 hdr = bp->b_addr;
870 btp = xfs_dir2_block_tail_p(mp, hdr); 870 btp = xfs_dir2_block_tail_p(args->geo, hdr);
871 blp = xfs_dir2_block_leaf_p(btp); 871 blp = xfs_dir2_block_leaf_p(btp);
872 /* 872 /*
873 * Point to the data entry we need to change. 873 * Point to the data entry we need to change.
@@ -941,7 +941,7 @@ xfs_dir2_leaf_to_block(
941 leaf = lbp->b_addr; 941 leaf = lbp->b_addr;
942 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 942 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
943 ents = dp->d_ops->leaf_ents_p(leaf); 943 ents = dp->d_ops->leaf_ents_p(leaf);
944 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 944 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
945 945
946 ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC || 946 ASSERT(leafhdr.magic == XFS_DIR2_LEAF1_MAGIC ||
947 leafhdr.magic == XFS_DIR3_LEAF1_MAGIC); 947 leafhdr.magic == XFS_DIR3_LEAF1_MAGIC);
@@ -951,13 +951,13 @@ xfs_dir2_leaf_to_block(
951 * been left behind during no-space-reservation operations. 951 * been left behind during no-space-reservation operations.
952 * These will show up in the leaf bests table. 952 * These will show up in the leaf bests table.
953 */ 953 */
954 while (dp->i_d.di_size > mp->m_dirblksize) { 954 while (dp->i_d.di_size > args->geo->blksize) {
955 int hdrsz; 955 int hdrsz;
956 956
957 hdrsz = dp->d_ops->data_entry_offset; 957 hdrsz = dp->d_ops->data_entry_offset;
958 bestsp = xfs_dir2_leaf_bests_p(ltp); 958 bestsp = xfs_dir2_leaf_bests_p(ltp);
959 if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) == 959 if (be16_to_cpu(bestsp[be32_to_cpu(ltp->bestcount) - 1]) ==
960 mp->m_dirblksize - hdrsz) { 960 args->geo->blksize - hdrsz) {
961 if ((error = 961 if ((error =
962 xfs_dir2_leaf_trim_data(args, lbp, 962 xfs_dir2_leaf_trim_data(args, lbp,
963 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1)))) 963 (xfs_dir2_db_t)(be32_to_cpu(ltp->bestcount) - 1))))
@@ -985,7 +985,7 @@ xfs_dir2_leaf_to_block(
985 /* 985 /*
986 * Look at the last data entry. 986 * Look at the last data entry.
987 */ 987 */
988 tagp = (__be16 *)((char *)hdr + mp->m_dirblksize) - 1; 988 tagp = (__be16 *)((char *)hdr + args->geo->blksize) - 1;
989 dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp)); 989 dup = (xfs_dir2_data_unused_t *)((char *)hdr + be16_to_cpu(*tagp));
990 /* 990 /*
991 * If it's not free or is too short we can't do it. 991 * If it's not free or is too short we can't do it.
@@ -1004,12 +1004,12 @@ xfs_dir2_leaf_to_block(
1004 /* 1004 /*
1005 * Use up the space at the end of the block (blp/btp). 1005 * Use up the space at the end of the block (blp/btp).
1006 */ 1006 */
1007 xfs_dir2_data_use_free(tp, dp, dbp, dup, mp->m_dirblksize - size, size, 1007 xfs_dir2_data_use_free(tp, dp, dbp, dup, args->geo->blksize - size, size,
1008 &needlog, &needscan); 1008 &needlog, &needscan);
1009 /* 1009 /*
1010 * Initialize the block tail. 1010 * Initialize the block tail.
1011 */ 1011 */
1012 btp = xfs_dir2_block_tail_p(mp, hdr); 1012 btp = xfs_dir2_block_tail_p(args->geo, hdr);
1013 btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale); 1013 btp->count = cpu_to_be32(leafhdr.count - leafhdr.stale);
1014 btp->stale = 0; 1014 btp->stale = 0;
1015 xfs_dir2_block_log_tail(tp, dbp); 1015 xfs_dir2_block_log_tail(tp, dbp);
@@ -1143,13 +1143,13 @@ xfs_dir2_sf_to_block(
1143 */ 1143 */
1144 dup = dp->d_ops->data_unused_p(hdr); 1144 dup = dp->d_ops->data_unused_p(hdr);
1145 needlog = needscan = 0; 1145 needlog = needscan = 0;
1146 xfs_dir2_data_use_free(tp, dp, bp, dup, mp->m_dirblksize - i, i, &needlog, 1146 xfs_dir2_data_use_free(tp, dp, bp, dup, args->geo->blksize - i,
1147 &needscan); 1147 i, &needlog, &needscan);
1148 ASSERT(needscan == 0); 1148 ASSERT(needscan == 0);
1149 /* 1149 /*
1150 * Fill in the tail. 1150 * Fill in the tail.
1151 */ 1151 */
1152 btp = xfs_dir2_block_tail_p(mp, hdr); 1152 btp = xfs_dir2_block_tail_p(args->geo, hdr);
1153 btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */ 1153 btp->count = cpu_to_be32(sfp->count + 2); /* ., .. */
1154 btp->stale = 0; 1154 btp->stale = 0;
1155 blp = xfs_dir2_block_leaf_p(btp); 1155 blp = xfs_dir2_block_leaf_p(btp);
diff --git a/fs/xfs/xfs_dir2_data.c b/fs/xfs/xfs_dir2_data.c
index 6c23f86e0148..b73d61adf104 100644
--- a/fs/xfs/xfs_dir2_data.c
+++ b/fs/xfs/xfs_dir2_data.c
@@ -80,7 +80,7 @@ __xfs_dir3_data_check(
80 switch (hdr->magic) { 80 switch (hdr->magic) {
81 case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC): 81 case cpu_to_be32(XFS_DIR3_BLOCK_MAGIC):
82 case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC): 82 case cpu_to_be32(XFS_DIR2_BLOCK_MAGIC):
83 btp = xfs_dir2_block_tail_p(mp, hdr); 83 btp = xfs_dir2_block_tail_p(geo, hdr);
84 lep = xfs_dir2_block_leaf_p(btp); 84 lep = xfs_dir2_block_leaf_p(btp);
85 endp = (char *)lep; 85 endp = (char *)lep;
86 86
@@ -96,7 +96,7 @@ __xfs_dir3_data_check(
96 break; 96 break;
97 case cpu_to_be32(XFS_DIR3_DATA_MAGIC): 97 case cpu_to_be32(XFS_DIR3_DATA_MAGIC):
98 case cpu_to_be32(XFS_DIR2_DATA_MAGIC): 98 case cpu_to_be32(XFS_DIR2_DATA_MAGIC):
99 endp = (char *)hdr + mp->m_dirblksize; 99 endp = (char *)hdr + geo->blksize;
100 break; 100 break;
101 default: 101 default:
102 XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp); 102 XFS_ERROR_REPORT("Bad Magic", XFS_ERRLEVEL_LOW, mp);
@@ -511,6 +511,7 @@ xfs_dir2_data_freescan(
511 struct xfs_dir2_data_free *bf; 511 struct xfs_dir2_data_free *bf;
512 char *endp; /* end of block's data */ 512 char *endp; /* end of block's data */
513 char *p; /* current entry pointer */ 513 char *p; /* current entry pointer */
514 struct xfs_da_geometry *geo = dp->i_mount->m_dir_geo;
514 515
515 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 516 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
516 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) || 517 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC) ||
@@ -529,10 +530,10 @@ xfs_dir2_data_freescan(
529 p = (char *)dp->d_ops->data_entry_p(hdr); 530 p = (char *)dp->d_ops->data_entry_p(hdr);
530 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 531 if (hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
531 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) { 532 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)) {
532 btp = xfs_dir2_block_tail_p(dp->i_mount, hdr); 533 btp = xfs_dir2_block_tail_p(geo, hdr);
533 endp = (char *)xfs_dir2_block_leaf_p(btp); 534 endp = (char *)xfs_dir2_block_leaf_p(btp);
534 } else 535 } else
535 endp = (char *)hdr + dp->i_mount->m_dirblksize; 536 endp = (char *)hdr + geo->blksize;
536 /* 537 /*
537 * Loop over the block's entries. 538 * Loop over the block's entries.
538 */ 539 */
@@ -622,7 +623,7 @@ xfs_dir3_data_init(
622 dup = dp->d_ops->data_unused_p(hdr); 623 dup = dp->d_ops->data_unused_p(hdr);
623 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG); 624 dup->freetag = cpu_to_be16(XFS_DIR2_DATA_FREE_TAG);
624 625
625 t = mp->m_dirblksize - (uint)dp->d_ops->data_entry_offset; 626 t = args->geo->blksize - (uint)dp->d_ops->data_entry_offset;
626 bf[0].length = cpu_to_be16(t); 627 bf[0].length = cpu_to_be16(t);
627 dup->length = cpu_to_be16(t); 628 dup->length = cpu_to_be16(t);
628 *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);
@@ -732,22 +733,24 @@ xfs_dir2_data_make_free(
732 xfs_dir2_data_unused_t *postdup; /* unused entry after us */ 733 xfs_dir2_data_unused_t *postdup; /* unused entry after us */
733 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */ 734 xfs_dir2_data_unused_t *prevdup; /* unused entry before us */
734 struct xfs_dir2_data_free *bf; 735 struct xfs_dir2_data_free *bf;
736 struct xfs_da_geometry *geo;
735 737
736 mp = tp->t_mountp; 738 mp = tp->t_mountp;
737 hdr = bp->b_addr; 739 hdr = bp->b_addr;
740 geo = mp->m_dir_geo;
738 741
739 /* 742 /*
740 * Figure out where the end of the data area is. 743 * Figure out where the end of the data area is.
741 */ 744 */
742 if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 745 if (hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
743 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)) 746 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC))
744 endptr = (char *)hdr + mp->m_dirblksize; 747 endptr = (char *)hdr + geo->blksize;
745 else { 748 else {
746 xfs_dir2_block_tail_t *btp; /* block tail */ 749 xfs_dir2_block_tail_t *btp; /* block tail */
747 750
748 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) || 751 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_BLOCK_MAGIC) ||
749 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC)); 752 hdr->magic == cpu_to_be32(XFS_DIR3_BLOCK_MAGIC));
750 btp = xfs_dir2_block_tail_p(mp, hdr); 753 btp = xfs_dir2_block_tail_p(geo, hdr);
751 endptr = (char *)xfs_dir2_block_leaf_p(btp); 754 endptr = (char *)xfs_dir2_block_leaf_p(btp);
752 } 755 }
753 /* 756 /*
diff --git a/fs/xfs/xfs_dir2_leaf.c b/fs/xfs/xfs_dir2_leaf.c
index a1f13103a16e..e517bd0544cd 100644
--- a/fs/xfs/xfs_dir2_leaf.c
+++ b/fs/xfs/xfs_dir2_leaf.c
@@ -92,6 +92,7 @@ xfs_dir3_leaf_check_int(
92 int i; 92 int i;
93 const struct xfs_dir_ops *ops; 93 const struct xfs_dir_ops *ops;
94 struct xfs_dir3_icleaf_hdr leafhdr; 94 struct xfs_dir3_icleaf_hdr leafhdr;
95 struct xfs_da_geometry *geo = mp->m_dir_geo;
95 96
96 /* 97 /*
97 * we can be passed a null dp here from a verifier, so we need to go the 98 * we can be passed a null dp here from a verifier, so we need to go the
@@ -105,14 +106,14 @@ xfs_dir3_leaf_check_int(
105 } 106 }
106 107
107 ents = ops->leaf_ents_p(leaf); 108 ents = ops->leaf_ents_p(leaf);
108 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 109 ltp = xfs_dir2_leaf_tail_p(geo, leaf);
109 110
110 /* 111 /*
111 * XXX (dgc): This value is not restrictive enough. 112 * XXX (dgc): This value is not restrictive enough.
112 * Should factor in the size of the bests table as well. 113 * Should factor in the size of the bests table as well.
113 * We can deduce a value for that from di_size. 114 * We can deduce a value for that from di_size.
114 */ 115 */
115 if (hdr->count > ops->leaf_max_ents(mp)) 116 if (hdr->count > ops->leaf_max_ents(geo))
116 return false; 117 return false;
117 118
118 /* Leaves and bests don't overlap in leaf format. */ 119 /* Leaves and bests don't overlap in leaf format. */
@@ -323,7 +324,7 @@ xfs_dir3_leaf_init(
323 if (type == XFS_DIR2_LEAF1_MAGIC) { 324 if (type == XFS_DIR2_LEAF1_MAGIC) {
324 struct xfs_dir2_leaf_tail *ltp; 325 struct xfs_dir2_leaf_tail *ltp;
325 326
326 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 327 ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
327 ltp->bestcount = 0; 328 ltp->bestcount = 0;
328 bp->b_ops = &xfs_dir3_leaf1_buf_ops; 329 bp->b_ops = &xfs_dir3_leaf1_buf_ops;
329 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF); 330 xfs_trans_buf_set_type(tp, bp, XFS_BLFT_DIR_LEAF1_BUF);
@@ -415,7 +416,7 @@ xfs_dir2_block_to_leaf(
415 leaf = lbp->b_addr; 416 leaf = lbp->b_addr;
416 hdr = dbp->b_addr; 417 hdr = dbp->b_addr;
417 xfs_dir3_data_check(dp, dbp); 418 xfs_dir3_data_check(dp, dbp);
418 btp = xfs_dir2_block_tail_p(mp, hdr); 419 btp = xfs_dir2_block_tail_p(args->geo, hdr);
419 blp = xfs_dir2_block_leaf_p(btp); 420 blp = xfs_dir2_block_leaf_p(btp);
420 bf = dp->d_ops->data_bestfree_p(hdr); 421 bf = dp->d_ops->data_bestfree_p(hdr);
421 ents = dp->d_ops->leaf_ents_p(leaf); 422 ents = dp->d_ops->leaf_ents_p(leaf);
@@ -443,7 +444,7 @@ xfs_dir2_block_to_leaf(
443 */ 444 */
444 xfs_dir2_data_make_free(tp, dp, dbp, 445 xfs_dir2_data_make_free(tp, dp, dbp,
445 (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr), 446 (xfs_dir2_data_aoff_t)((char *)blp - (char *)hdr),
446 (xfs_dir2_data_aoff_t)((char *)hdr + mp->m_dirblksize - 447 (xfs_dir2_data_aoff_t)((char *)hdr + args->geo->blksize -
447 (char *)blp), 448 (char *)blp),
448 &needlog, &needscan); 449 &needlog, &needscan);
449 /* 450 /*
@@ -461,7 +462,7 @@ xfs_dir2_block_to_leaf(
461 /* 462 /*
462 * Set up leaf tail and bests table. 463 * Set up leaf tail and bests table.
463 */ 464 */
464 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 465 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
465 ltp->bestcount = cpu_to_be32(1); 466 ltp->bestcount = cpu_to_be32(1);
466 bestsp = xfs_dir2_leaf_bests_p(ltp); 467 bestsp = xfs_dir2_leaf_bests_p(ltp);
467 bestsp[0] = bf[0].length; 468 bestsp[0] = bf[0].length;
@@ -653,7 +654,7 @@ xfs_dir2_leaf_addname(
653 */ 654 */
654 index = xfs_dir2_leaf_search_hash(args, lbp); 655 index = xfs_dir2_leaf_search_hash(args, lbp);
655 leaf = lbp->b_addr; 656 leaf = lbp->b_addr;
656 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 657 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
657 ents = dp->d_ops->leaf_ents_p(leaf); 658 ents = dp->d_ops->leaf_ents_p(leaf);
658 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf); 659 dp->d_ops->leaf_hdr_from_disk(&leafhdr, leaf);
659 bestsp = xfs_dir2_leaf_bests_p(ltp); 660 bestsp = xfs_dir2_leaf_bests_p(ltp);
@@ -1066,7 +1067,7 @@ xfs_dir3_leaf_log_bests(
1066 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) || 1067 ASSERT(leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAF1_MAGIC) ||
1067 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC)); 1068 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAF1_MAGIC));
1068 1069
1069 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp, leaf); 1070 ltp = xfs_dir2_leaf_tail_p(tp->t_mountp->m_dir_geo, leaf);
1070 firstb = xfs_dir2_leaf_bests_p(ltp) + first; 1071 firstb = xfs_dir2_leaf_bests_p(ltp) + first;
1071 lastb = xfs_dir2_leaf_bests_p(ltp) + last; 1072 lastb = xfs_dir2_leaf_bests_p(ltp) + last;
1072 xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf), 1073 xfs_trans_log_buf(tp, bp, (uint)((char *)firstb - (char *)leaf),
@@ -1138,9 +1139,9 @@ xfs_dir3_leaf_log_tail(
1138 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) || 1139 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR2_LEAFN_MAGIC) ||
1139 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC)); 1140 leaf->hdr.info.magic == cpu_to_be16(XFS_DIR3_LEAFN_MAGIC));
1140 1141
1141 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1142 ltp = xfs_dir2_leaf_tail_p(mp->m_dir_geo, leaf);
1142 xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf), 1143 xfs_trans_log_buf(tp, bp, (uint)((char *)ltp - (char *)leaf),
1143 (uint)(mp->m_dirblksize - 1)); 1144 (uint)(mp->m_dir_geo->blksize - 1));
1144} 1145}
1145 1146
1146/* 1147/*
@@ -1388,7 +1389,7 @@ xfs_dir2_leaf_removename(
1388 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address))); 1389 xfs_dir2_dataptr_to_off(args->geo, be32_to_cpu(lep->address)));
1389 needscan = needlog = 0; 1390 needscan = needlog = 0;
1390 oldbest = be16_to_cpu(bf[0].length); 1391 oldbest = be16_to_cpu(bf[0].length);
1391 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1392 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1392 bestsp = xfs_dir2_leaf_bests_p(ltp); 1393 bestsp = xfs_dir2_leaf_bests_p(ltp);
1393 ASSERT(be16_to_cpu(bestsp[db]) == oldbest); 1394 ASSERT(be16_to_cpu(bestsp[db]) == oldbest);
1394 /* 1395 /*
@@ -1428,7 +1429,7 @@ xfs_dir2_leaf_removename(
1428 * If the data block is now empty then get rid of the data block. 1429 * If the data block is now empty then get rid of the data block.
1429 */ 1430 */
1430 if (be16_to_cpu(bf[0].length) == 1431 if (be16_to_cpu(bf[0].length) ==
1431 mp->m_dirblksize - dp->d_ops->data_entry_offset) { 1432 args->geo->blksize - dp->d_ops->data_entry_offset) {
1432 ASSERT(db != args->geo->datablk); 1433 ASSERT(db != args->geo->datablk);
1433 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) { 1434 if ((error = xfs_dir2_shrink_inode(args, db, dbp))) {
1434 /* 1435 /*
@@ -1618,7 +1619,7 @@ xfs_dir2_leaf_trim_data(
1618 return error; 1619 return error;
1619 1620
1620 leaf = lbp->b_addr; 1621 leaf = lbp->b_addr;
1621 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1622 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1622 1623
1623#ifdef DEBUG 1624#ifdef DEBUG
1624{ 1625{
@@ -1628,7 +1629,7 @@ xfs_dir2_leaf_trim_data(
1628 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) || 1629 ASSERT(hdr->magic == cpu_to_be32(XFS_DIR2_DATA_MAGIC) ||
1629 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC)); 1630 hdr->magic == cpu_to_be32(XFS_DIR3_DATA_MAGIC));
1630 ASSERT(be16_to_cpu(bf[0].length) == 1631 ASSERT(be16_to_cpu(bf[0].length) ==
1631 mp->m_dirblksize - dp->d_ops->data_entry_offset); 1632 args->geo->blksize - dp->d_ops->data_entry_offset);
1632 ASSERT(db == be32_to_cpu(ltp->bestcount) - 1); 1633 ASSERT(db == be32_to_cpu(ltp->bestcount) - 1);
1633} 1634}
1634#endif 1635#endif
@@ -1740,7 +1741,7 @@ xfs_dir2_node_to_leaf(
1740 /* 1741 /*
1741 * If it's not the single leaf block, give up. 1742 * If it's not the single leaf block, give up.
1742 */ 1743 */
1743 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + mp->m_dirblksize) 1744 if (XFS_FSB_TO_B(mp, fo) > XFS_DIR2_LEAF_OFFSET + args->geo->blksize)
1744 return 0; 1745 return 0;
1745 lbp = state->path.blk[0].bp; 1746 lbp = state->path.blk[0].bp;
1746 leaf = lbp->b_addr; 1747 leaf = lbp->b_addr;
@@ -1764,7 +1765,7 @@ xfs_dir2_node_to_leaf(
1764 * Now see if the leafn and free data will fit in a leaf1. 1765 * Now see if the leafn and free data will fit in a leaf1.
1765 * If not, release the buffer and give up. 1766 * If not, release the buffer and give up.
1766 */ 1767 */
1767 if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > mp->m_dirblksize) { 1768 if (xfs_dir3_leaf_size(&leafhdr, freehdr.nvalid) > args->geo->blksize) {
1768 xfs_trans_brelse(tp, fbp); 1769 xfs_trans_brelse(tp, fbp);
1769 return 0; 1770 return 0;
1770 } 1771 }
@@ -1784,7 +1785,7 @@ xfs_dir2_node_to_leaf(
1784 /* 1785 /*
1785 * Set up the leaf tail from the freespace block. 1786 * Set up the leaf tail from the freespace block.
1786 */ 1787 */
1787 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 1788 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
1788 ltp->bestcount = cpu_to_be32(freehdr.nvalid); 1789 ltp->bestcount = cpu_to_be32(freehdr.nvalid);
1789 1790
1790 /* 1791 /*
diff --git a/fs/xfs/xfs_dir2_node.c b/fs/xfs/xfs_dir2_node.c
index 89777bf63551..ef34c197b62f 100644
--- a/fs/xfs/xfs_dir2_node.c
+++ b/fs/xfs/xfs_dir2_node.c
@@ -327,9 +327,9 @@ xfs_dir2_leaf_to_node(
327 free = fbp->b_addr; 327 free = fbp->b_addr;
328 dp->d_ops->free_hdr_from_disk(&freehdr, free); 328 dp->d_ops->free_hdr_from_disk(&freehdr, free);
329 leaf = lbp->b_addr; 329 leaf = lbp->b_addr;
330 ltp = xfs_dir2_leaf_tail_p(mp, leaf); 330 ltp = xfs_dir2_leaf_tail_p(args->geo, leaf);
331 ASSERT(be32_to_cpu(ltp->bestcount) <= 331 ASSERT(be32_to_cpu(ltp->bestcount) <=
332 (uint)dp->i_d.di_size / mp->m_dirblksize); 332 (uint)dp->i_d.di_size / args->geo->blksize);
333 333
334 /* 334 /*
335 * Copy freespace entries from the leaf block to the new block. 335 * Copy freespace entries from the leaf block to the new block.
@@ -416,7 +416,7 @@ xfs_dir2_leafn_add(
416 * a compact. 416 * a compact.
417 */ 417 */
418 418
419 if (leafhdr.count == dp->d_ops->leaf_max_ents(mp)) { 419 if (leafhdr.count == dp->d_ops->leaf_max_ents(args->geo)) {
420 if (!leafhdr.stale) 420 if (!leafhdr.stale)
421 return XFS_ERROR(ENOSPC); 421 return XFS_ERROR(ENOSPC);
422 compact = leafhdr.stale > 1; 422 compact = leafhdr.stale > 1;
@@ -472,7 +472,8 @@ xfs_dir2_free_hdr_check(
472 472
473 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr); 473 dp->d_ops->free_hdr_from_disk(&hdr, bp->b_addr);
474 474
475 ASSERT((hdr.firstdb % dp->d_ops->free_max_bests(dp->i_mount)) == 0); 475 ASSERT((hdr.firstdb %
476 dp->d_ops->free_max_bests(dp->i_mount->m_dir_geo)) == 0);
476 ASSERT(hdr.firstdb <= db); 477 ASSERT(hdr.firstdb <= db);
477 ASSERT(db < hdr.firstdb + hdr.nvalid); 478 ASSERT(db < hdr.firstdb + hdr.nvalid);
478} 479}
@@ -595,7 +596,7 @@ xfs_dir2_leafn_lookup_for_addname(
595 * Convert the data block to the free block 596 * Convert the data block to the free block
596 * holding its freespace information. 597 * holding its freespace information.
597 */ 598 */
598 newfdb = dp->d_ops->db_to_fdb(mp, newdb); 599 newfdb = dp->d_ops->db_to_fdb(args->geo, newdb);
599 /* 600 /*
600 * If it's not the one we have in hand, read it in. 601 * If it's not the one we have in hand, read it in.
601 */ 602 */
@@ -619,7 +620,7 @@ xfs_dir2_leafn_lookup_for_addname(
619 /* 620 /*
620 * Get the index for our entry. 621 * Get the index for our entry.
621 */ 622 */
622 fi = dp->d_ops->db_to_fdindex(mp, curdb); 623 fi = dp->d_ops->db_to_fdindex(args->geo, curdb);
623 /* 624 /*
624 * If it has room, return it. 625 * If it has room, return it.
625 */ 626 */
@@ -1251,7 +1252,7 @@ xfs_dir2_leafn_remove(
1251 * Convert the data block number to a free block, 1252 * Convert the data block number to a free block,
1252 * read in the free block. 1253 * read in the free block.
1253 */ 1254 */
1254 fdb = dp->d_ops->db_to_fdb(mp, db); 1255 fdb = dp->d_ops->db_to_fdb(args->geo, db);
1255 error = xfs_dir2_free_read(tp, dp, 1256 error = xfs_dir2_free_read(tp, dp,
1256 xfs_dir2_db_to_da(args->geo, fdb), 1257 xfs_dir2_db_to_da(args->geo, fdb),
1257 &fbp); 1258 &fbp);
@@ -1262,7 +1263,7 @@ xfs_dir2_leafn_remove(
1262 { 1263 {
1263 struct xfs_dir3_icfree_hdr freehdr; 1264 struct xfs_dir3_icfree_hdr freehdr;
1264 dp->d_ops->free_hdr_from_disk(&freehdr, free); 1265 dp->d_ops->free_hdr_from_disk(&freehdr, free);
1265 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(mp) * 1266 ASSERT(freehdr.firstdb == dp->d_ops->free_max_bests(args->geo) *
1266 (fdb - xfs_dir2_byte_to_db(args->geo, 1267 (fdb - xfs_dir2_byte_to_db(args->geo,
1267 XFS_DIR2_FREE_OFFSET))); 1268 XFS_DIR2_FREE_OFFSET)));
1268 } 1269 }
@@ -1270,13 +1271,13 @@ xfs_dir2_leafn_remove(
1270 /* 1271 /*
1271 * Calculate which entry we need to fix. 1272 * Calculate which entry we need to fix.
1272 */ 1273 */
1273 findex = dp->d_ops->db_to_fdindex(mp, db); 1274 findex = dp->d_ops->db_to_fdindex(args->geo, db);
1274 longest = be16_to_cpu(bf[0].length); 1275 longest = be16_to_cpu(bf[0].length);
1275 /* 1276 /*
1276 * If the data block is now empty we can get rid of it 1277 * If the data block is now empty we can get rid of it
1277 * (usually). 1278 * (usually).
1278 */ 1279 */
1279 if (longest == mp->m_dirblksize - 1280 if (longest == args->geo->blksize -
1280 dp->d_ops->data_entry_offset) { 1281 dp->d_ops->data_entry_offset) {
1281 /* 1282 /*
1282 * Try to punch out the data block. 1283 * Try to punch out the data block.
@@ -1595,7 +1596,7 @@ xfs_dir2_node_addname(
1595 state = xfs_da_state_alloc(); 1596 state = xfs_da_state_alloc();
1596 state->args = args; 1597 state->args = args;
1597 state->mp = args->dp->i_mount; 1598 state->mp = args->dp->i_mount;
1598 state->blocksize = state->mp->m_dirblksize; 1599 state->blocksize = state->args->geo->blksize;
1599 state->node_ents = state->mp->m_dir_node_ents; 1600 state->node_ents = state->mp->m_dir_node_ents;
1600 /* 1601 /*
1601 * Look up the name. We're not supposed to find it, but 1602 * Look up the name. We're not supposed to find it, but
@@ -1843,7 +1844,7 @@ xfs_dir2_node_addname_int(
1843 * Get the freespace block corresponding to the data block 1844 * Get the freespace block corresponding to the data block
1844 * that was just allocated. 1845 * that was just allocated.
1845 */ 1846 */
1846 fbno = dp->d_ops->db_to_fdb(mp, dbno); 1847 fbno = dp->d_ops->db_to_fdb(args->geo, dbno);
1847 error = xfs_dir2_free_try_read(tp, dp, 1848 error = xfs_dir2_free_try_read(tp, dp,
1848 xfs_dir2_db_to_da(args->geo, fbno), 1849 xfs_dir2_db_to_da(args->geo, fbno),
1849 &fbp); 1850 &fbp);
@@ -1860,12 +1861,13 @@ xfs_dir2_node_addname_int(
1860 if (error) 1861 if (error)
1861 return error; 1862 return error;
1862 1863
1863 if (unlikely(dp->d_ops->db_to_fdb(mp, dbno) != fbno)) { 1864 if (dp->d_ops->db_to_fdb(args->geo, dbno) != fbno) {
1864 xfs_alert(mp, 1865 xfs_alert(mp,
1865 "%s: dir ino %llu needed freesp block %lld for\n" 1866 "%s: dir ino %llu needed freesp block %lld for\n"
1866 " data block %lld, got %lld ifbno %llu lastfbno %d", 1867 " data block %lld, got %lld ifbno %llu lastfbno %d",
1867 __func__, (unsigned long long)dp->i_ino, 1868 __func__, (unsigned long long)dp->i_ino,
1868 (long long)dp->d_ops->db_to_fdb(mp, dbno), 1869 (long long)dp->d_ops->db_to_fdb(
1870 args->geo, dbno),
1869 (long long)dbno, (long long)fbno, 1871 (long long)dbno, (long long)fbno,
1870 (unsigned long long)ifbno, lastfbno); 1872 (unsigned long long)ifbno, lastfbno);
1871 if (fblk) { 1873 if (fblk) {
@@ -1899,7 +1901,7 @@ xfs_dir2_node_addname_int(
1899 freehdr.firstdb = 1901 freehdr.firstdb =
1900 (fbno - xfs_dir2_byte_to_db(args->geo, 1902 (fbno - xfs_dir2_byte_to_db(args->geo,
1901 XFS_DIR2_FREE_OFFSET)) * 1903 XFS_DIR2_FREE_OFFSET)) *
1902 dp->d_ops->free_max_bests(mp); 1904 dp->d_ops->free_max_bests(args->geo);
1903 } else { 1905 } else {
1904 free = fbp->b_addr; 1906 free = fbp->b_addr;
1905 bests = dp->d_ops->free_bests_p(free); 1907 bests = dp->d_ops->free_bests_p(free);
@@ -1909,13 +1911,13 @@ xfs_dir2_node_addname_int(
1909 /* 1911 /*
1910 * Set the freespace block index from the data block number. 1912 * Set the freespace block index from the data block number.
1911 */ 1913 */
1912 findex = dp->d_ops->db_to_fdindex(mp, dbno); 1914 findex = dp->d_ops->db_to_fdindex(args->geo, dbno);
1913 /* 1915 /*
1914 * If it's after the end of the current entries in the 1916 * If it's after the end of the current entries in the
1915 * freespace block, extend that table. 1917 * freespace block, extend that table.
1916 */ 1918 */
1917 if (findex >= freehdr.nvalid) { 1919 if (findex >= freehdr.nvalid) {
1918 ASSERT(findex < dp->d_ops->free_max_bests(mp)); 1920 ASSERT(findex < dp->d_ops->free_max_bests(args->geo));
1919 freehdr.nvalid = findex + 1; 1921 freehdr.nvalid = findex + 1;
1920 /* 1922 /*
1921 * Tag new entry so nused will go up. 1923 * Tag new entry so nused will go up.
@@ -2040,7 +2042,7 @@ xfs_dir2_node_lookup(
2040 state = xfs_da_state_alloc(); 2042 state = xfs_da_state_alloc();
2041 state->args = args; 2043 state->args = args;
2042 state->mp = args->dp->i_mount; 2044 state->mp = args->dp->i_mount;
2043 state->blocksize = state->mp->m_dirblksize; 2045 state->blocksize = args->geo->blksize;
2044 state->node_ents = state->mp->m_dir_node_ents; 2046 state->node_ents = state->mp->m_dir_node_ents;
2045 /* 2047 /*
2046 * Fill in the path to the entry in the cursor. 2048 * Fill in the path to the entry in the cursor.
@@ -2095,7 +2097,7 @@ xfs_dir2_node_removename(
2095 state = xfs_da_state_alloc(); 2097 state = xfs_da_state_alloc();
2096 state->args = args; 2098 state->args = args;
2097 state->mp = args->dp->i_mount; 2099 state->mp = args->dp->i_mount;
2098 state->blocksize = state->mp->m_dirblksize; 2100 state->blocksize = args->geo->blksize;
2099 state->node_ents = state->mp->m_dir_node_ents; 2101 state->node_ents = state->mp->m_dir_node_ents;
2100 2102
2101 /* Look up the entry we're deleting, set up the cursor. */ 2103 /* Look up the entry we're deleting, set up the cursor. */
@@ -2165,7 +2167,7 @@ xfs_dir2_node_replace(
2165 state = xfs_da_state_alloc(); 2167 state = xfs_da_state_alloc();
2166 state->args = args; 2168 state->args = args;
2167 state->mp = args->dp->i_mount; 2169 state->mp = args->dp->i_mount;
2168 state->blocksize = state->mp->m_dirblksize; 2170 state->blocksize = args->geo->blksize;
2169 state->node_ents = state->mp->m_dir_node_ents; 2171 state->node_ents = state->mp->m_dir_node_ents;
2170 inum = args->inumber; 2172 inum = args->inumber;
2171 /* 2173 /*
diff --git a/fs/xfs/xfs_dir2_priv.h b/fs/xfs/xfs_dir2_priv.h
index 071b685abcbb..436135f28f96 100644
--- a/fs/xfs/xfs_dir2_priv.h
+++ b/fs/xfs/xfs_dir2_priv.h
@@ -140,17 +140,17 @@ xfs_dir2_da_to_byte(struct xfs_da_geometry *geo, xfs_dablk_t da)
140 * Directory tail pointer accessor functions. Based on block geometry. 140 * Directory tail pointer accessor functions. Based on block geometry.
141 */ 141 */
142static inline struct xfs_dir2_block_tail * 142static inline struct xfs_dir2_block_tail *
143xfs_dir2_block_tail_p(struct xfs_mount *mp, struct xfs_dir2_data_hdr *hdr) 143xfs_dir2_block_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_data_hdr *hdr)
144{ 144{
145 return ((struct xfs_dir2_block_tail *) 145 return ((struct xfs_dir2_block_tail *)
146 ((char *)hdr + mp->m_dirblksize)) - 1; 146 ((char *)hdr + geo->blksize)) - 1;
147} 147}
148 148
149static inline struct xfs_dir2_leaf_tail * 149static inline struct xfs_dir2_leaf_tail *
150xfs_dir2_leaf_tail_p(struct xfs_mount *mp, struct xfs_dir2_leaf *lp) 150xfs_dir2_leaf_tail_p(struct xfs_da_geometry *geo, struct xfs_dir2_leaf *lp)
151{ 151{
152 return (struct xfs_dir2_leaf_tail *) 152 return (struct xfs_dir2_leaf_tail *)
153 ((char *)lp + mp->m_dirblksize - 153 ((char *)lp + geo->blksize -
154 sizeof(struct xfs_dir2_leaf_tail)); 154 sizeof(struct xfs_dir2_leaf_tail));
155} 155}
156 156
diff --git a/fs/xfs/xfs_dir2_readdir.c b/fs/xfs/xfs_dir2_readdir.c
index 8cb5340071e8..fa393d5c2a14 100644
--- a/fs/xfs/xfs_dir2_readdir.c
+++ b/fs/xfs/xfs_dir2_readdir.c
@@ -216,7 +216,7 @@ xfs_dir2_block_getdents(
216 /* 216 /*
217 * Set up values for the loop. 217 * Set up values for the loop.
218 */ 218 */
219 btp = xfs_dir2_block_tail_p(mp, hdr); 219 btp = xfs_dir2_block_tail_p(geo, hdr);
220 ptr = (char *)dp->d_ops->data_entry_p(hdr); 220 ptr = (char *)dp->d_ops->data_entry_p(hdr);
221 endptr = (char *)xfs_dir2_block_leaf_p(btp); 221 endptr = (char *)xfs_dir2_block_leaf_p(btp);
222 222
@@ -338,7 +338,7 @@ xfs_dir2_leaf_readbuf(
338 /* 338 /*
339 * Recalculate the readahead blocks wanted. 339 * Recalculate the readahead blocks wanted.
340 */ 340 */
341 mip->ra_want = howmany(bufsize + mp->m_dirblksize, 341 mip->ra_want = howmany(bufsize + geo->blksize,
342 mp->m_sb.sb_blocksize) - 1; 342 mp->m_sb.sb_blocksize) - 1;
343 ASSERT(mip->ra_want >= 0); 343 ASSERT(mip->ra_want >= 0);
344 344
@@ -526,8 +526,7 @@ xfs_dir2_leaf_getdents(
526 * buffer size, the directory block size, and the filesystem 526 * buffer size, the directory block size, and the filesystem
527 * block size. 527 * block size.
528 */ 528 */
529 length = howmany(bufsize + mp->m_dirblksize, 529 length = howmany(bufsize + geo->blksize, mp->m_sb.sb_blocksize);
530 mp->m_sb.sb_blocksize);
531 map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) + 530 map_info = kmem_zalloc(offsetof(struct xfs_dir2_leaf_map_info, map) +
532 (length * sizeof(struct xfs_bmbt_irec)), 531 (length * sizeof(struct xfs_bmbt_irec)),
533 KM_SLEEP | KM_NOFS); 532 KM_SLEEP | KM_NOFS);
@@ -557,7 +556,7 @@ xfs_dir2_leaf_getdents(
557 * If we have no buffer, or we're off the end of the 556 * If we have no buffer, or we're off the end of the
558 * current buffer, need to get another one. 557 * current buffer, need to get another one.
559 */ 558 */
560 if (!bp || ptr >= (char *)bp->b_addr + mp->m_dirblksize) { 559 if (!bp || ptr >= (char *)bp->b_addr + geo->blksize) {
561 560
562 error = xfs_dir2_leaf_readbuf(dp, bufsize, map_info, 561 error = xfs_dir2_leaf_readbuf(dp, bufsize, map_info,
563 &curoff, &bp); 562 &curoff, &bp);
@@ -618,7 +617,7 @@ xfs_dir2_leaf_getdents(
618 xfs_dir2_db_off_to_byte(geo, 617 xfs_dir2_db_off_to_byte(geo,
619 xfs_dir2_byte_to_db(geo, curoff), 618 xfs_dir2_byte_to_db(geo, curoff),
620 (char *)ptr - (char *)hdr); 619 (char *)ptr - (char *)hdr);
621 if (ptr >= (char *)hdr + mp->m_dirblksize) { 620 if (ptr >= (char *)hdr + geo->blksize) {
622 continue; 621 continue;
623 } 622 }
624 } 623 }
diff --git a/fs/xfs/xfs_dir2_sf.c b/fs/xfs/xfs_dir2_sf.c
index 10f4c2a23bc4..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 /*
@@ -105,7 +107,7 @@ xfs_dir2_block_sfsize(
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 *)((char *)hdr + 109 dep = (xfs_dir2_data_entry_t *)((char *)hdr +
108 xfs_dir2_dataptr_to_off(mp->m_dir_geo, 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);
@@ -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 3445ead7c1fc..a8cbcf06e792 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"
@@ -110,7 +112,7 @@ xfs_fs_geometry(
110 geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ? 112 geo->logsectsize = xfs_sb_version_hassector(&mp->m_sb) ?
111 mp->m_sb.sb_logsectsize : BBSIZE; 113 mp->m_sb.sb_logsectsize : BBSIZE;
112 geo->rtsectsize = mp->m_sb.sb_blocksize; 114 geo->rtsectsize = mp->m_sb.sb_blocksize;
113 geo->dirblocksize = mp->m_dirblksize; 115 geo->dirblocksize = mp->m_dir_geo->blksize;
114 } 116 }
115 if (new_version >= 4) { 117 if (new_version >= 4) {
116 geo->flags |= 118 geo->flags |=
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index a23e7b63d420..4e3f6cebebc6 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -154,7 +154,6 @@ typedef struct xfs_mount {
154 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ 154 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
155 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ 155 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */
156 const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */ 156 const struct xfs_dir_ops *m_nondir_inode_ops; /* !dir inode ops */
157 int m_dirblksize; /* directory block sz--bytes */
158 uint m_chsize; /* size of next field */ 157 uint m_chsize; /* size of next field */
159 atomic_t m_active_trans; /* number trans frozen */ 158 atomic_t m_active_trans; /* number trans frozen */
160#ifdef HAVE_PERCPU_SB 159#ifdef HAVE_PERCPU_SB
diff --git a/fs/xfs/xfs_trans_resv.c b/fs/xfs/xfs_trans_resv.c
index 63a42a180a67..f2bda7c76b8a 100644
--- a/fs/xfs/xfs_trans_resv.c
+++ b/fs/xfs/xfs_trans_resv.c
@@ -610,7 +610,7 @@ xfs_calc_addafork_reservation(
610 return XFS_DQUOT_LOGRES(mp) + 610 return XFS_DQUOT_LOGRES(mp) +
611 xfs_calc_inode_res(mp, 1) + 611 xfs_calc_inode_res(mp, 1) +
612 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) + 612 xfs_calc_buf_res(2, mp->m_sb.sb_sectsize) +
613 xfs_calc_buf_res(1, mp->m_dirblksize) + 613 xfs_calc_buf_res(1, mp->m_dir_geo->blksize) +
614 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,
615 XFS_FSB_TO_B(mp, 1)) + 615 XFS_FSB_TO_B(mp, 1)) +
616 xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1), 616 xfs_calc_buf_res(XFS_ALLOCFREE_LOG_COUNT(mp, 1),