aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2019-06-05 14:19:34 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2019-06-12 11:37:40 -0400
commitef325959993edd53e3ce7c818b18f776ac0740a6 (patch)
tree8f59c28771ff546a572add92d22c031622eb9a19 /fs/xfs
parentfe0da9c09b2dc448ff781d1426ecb36d145ce51b (diff)
xfs: separate inode geometry
Separate the inode geometry information into a distinct structure. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Dave Chinner <dchinner@redhat.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_format.h38
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c107
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.h6
-rw-r--r--fs/xfs/libxfs/xfs_ialloc_btree.c15
-rw-r--r--fs/xfs/libxfs/xfs_inode_buf.c2
-rw-r--r--fs/xfs/libxfs/xfs_sb.c24
-rw-r--r--fs/xfs/libxfs/xfs_trans_resv.c17
-rw-r--r--fs/xfs/libxfs/xfs_trans_space.h7
-rw-r--r--fs/xfs/libxfs/xfs_types.c4
-rw-r--r--fs/xfs/scrub/ialloc.c21
-rw-r--r--fs/xfs/scrub/quota.c2
-rw-r--r--fs/xfs/xfs_fsops.c4
-rw-r--r--fs/xfs/xfs_inode.c16
-rw-r--r--fs/xfs/xfs_itable.c11
-rw-r--r--fs/xfs/xfs_log_recover.c21
-rw-r--r--fs/xfs/xfs_mount.c49
-rw-r--r--fs/xfs/xfs_mount.h19
-rw-r--r--fs/xfs/xfs_super.c6
18 files changed, 208 insertions, 161 deletions
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index 9bb3c48843ec..0e831f04725c 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -1071,7 +1071,7 @@ static inline void xfs_dinode_put_rdev(struct xfs_dinode *dip, xfs_dev_t rdev)
1071#define XFS_INO_MASK(k) (uint32_t)((1ULL << (k)) - 1) 1071#define XFS_INO_MASK(k) (uint32_t)((1ULL << (k)) - 1)
1072#define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog 1072#define XFS_INO_OFFSET_BITS(mp) (mp)->m_sb.sb_inopblog
1073#define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog 1073#define XFS_INO_AGBNO_BITS(mp) (mp)->m_sb.sb_agblklog
1074#define XFS_INO_AGINO_BITS(mp) (mp)->m_agino_log 1074#define XFS_INO_AGINO_BITS(mp) ((mp)->m_ino_geo.agino_log)
1075#define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log 1075#define XFS_INO_AGNO_BITS(mp) (mp)->m_agno_log
1076#define XFS_INO_BITS(mp) \ 1076#define XFS_INO_BITS(mp) \
1077 XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp) 1077 XFS_INO_AGNO_BITS(mp) + XFS_INO_AGINO_BITS(mp)
@@ -1694,4 +1694,40 @@ struct xfs_acl {
1694#define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1) 1694#define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
1695#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1) 1695#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
1696 1696
1697struct xfs_ino_geometry {
1698 /* Maximum inode count in this filesystem. */
1699 uint64_t maxicount;
1700
1701 /*
1702 * Desired inode cluster buffer size, in bytes. This value is not
1703 * rounded up to at least one filesystem block.
1704 */
1705 unsigned int inode_cluster_size;
1706
1707 /* Inode cluster sizes, adjusted to be at least 1 fsb. */
1708 unsigned int inodes_per_cluster;
1709 unsigned int blocks_per_cluster;
1710
1711 /* Inode cluster alignment. */
1712 unsigned int cluster_align;
1713 unsigned int cluster_align_inodes;
1714 unsigned int inoalign_mask; /* mask sb_inoalignmt if used */
1715
1716 unsigned int inobt_mxr[2]; /* max inobt btree records */
1717 unsigned int inobt_mnr[2]; /* min inobt btree records */
1718 unsigned int inobt_maxlevels; /* max inobt btree levels. */
1719
1720 /* Size of inode allocations under normal operation. */
1721 unsigned int ialloc_inos;
1722 unsigned int ialloc_blks;
1723
1724 /* Minimum inode blocks for a sparse allocation. */
1725 unsigned int ialloc_min_blks;
1726
1727 /* stripe unit inode alignment */
1728 unsigned int ialloc_align;
1729
1730 unsigned int agino_log; /* #bits for agino in inum */
1731};
1732
1697#endif /* __XFS_FORMAT_H__ */ 1733#endif /* __XFS_FORMAT_H__ */
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index fe9898875097..49f556cf244b 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -299,7 +299,7 @@ xfs_ialloc_inode_init(
299 * sizes, manipulate the inodes in buffers which are multiples of the 299 * sizes, manipulate the inodes in buffers which are multiples of the
300 * blocks size. 300 * blocks size.
301 */ 301 */
302 nbufs = length / mp->m_blocks_per_cluster; 302 nbufs = length / M_IGEO(mp)->blocks_per_cluster;
303 303
304 /* 304 /*
305 * Figure out what version number to use in the inodes we create. If 305 * Figure out what version number to use in the inodes we create. If
@@ -343,9 +343,10 @@ xfs_ialloc_inode_init(
343 * Get the block. 343 * Get the block.
344 */ 344 */
345 d = XFS_AGB_TO_DADDR(mp, agno, agbno + 345 d = XFS_AGB_TO_DADDR(mp, agno, agbno +
346 (j * mp->m_blocks_per_cluster)); 346 (j * M_IGEO(mp)->blocks_per_cluster));
347 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 347 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
348 mp->m_bsize * mp->m_blocks_per_cluster, 348 mp->m_bsize *
349 M_IGEO(mp)->blocks_per_cluster,
349 XBF_UNMAPPED); 350 XBF_UNMAPPED);
350 if (!fbuf) 351 if (!fbuf)
351 return -ENOMEM; 352 return -ENOMEM;
@@ -353,7 +354,7 @@ xfs_ialloc_inode_init(
353 /* Initialize the inode buffers and log them appropriately. */ 354 /* Initialize the inode buffers and log them appropriately. */
354 fbuf->b_ops = &xfs_inode_buf_ops; 355 fbuf->b_ops = &xfs_inode_buf_ops;
355 xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); 356 xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));
356 for (i = 0; i < mp->m_inodes_per_cluster; i++) { 357 for (i = 0; i < M_IGEO(mp)->inodes_per_cluster; i++) {
357 int ioffset = i << mp->m_sb.sb_inodelog; 358 int ioffset = i << mp->m_sb.sb_inodelog;
358 uint isize = xfs_dinode_size(version); 359 uint isize = xfs_dinode_size(version);
359 360
@@ -616,24 +617,26 @@ error:
616 * Allocate new inodes in the allocation group specified by agbp. 617 * Allocate new inodes in the allocation group specified by agbp.
617 * Return 0 for success, else error code. 618 * Return 0 for success, else error code.
618 */ 619 */
619STATIC int /* error code or 0 */ 620STATIC int
620xfs_ialloc_ag_alloc( 621xfs_ialloc_ag_alloc(
621 xfs_trans_t *tp, /* transaction pointer */ 622 struct xfs_trans *tp,
622 xfs_buf_t *agbp, /* alloc group buffer */ 623 struct xfs_buf *agbp,
623 int *alloc) 624 int *alloc)
624{ 625{
625 xfs_agi_t *agi; /* allocation group header */ 626 struct xfs_agi *agi;
626 xfs_alloc_arg_t args; /* allocation argument structure */ 627 struct xfs_alloc_arg args;
627 xfs_agnumber_t agno; 628 xfs_agnumber_t agno;
628 int error; 629 int error;
629 xfs_agino_t newino; /* new first inode's number */ 630 xfs_agino_t newino; /* new first inode's number */
630 xfs_agino_t newlen; /* new number of inodes */ 631 xfs_agino_t newlen; /* new number of inodes */
631 int isaligned = 0; /* inode allocation at stripe unit */ 632 int isaligned = 0; /* inode allocation at stripe */
632 /* boundary */ 633 /* unit boundary */
633 uint16_t allocmask = (uint16_t) -1; /* init. to full chunk */ 634 /* init. to full chunk */
635 uint16_t allocmask = (uint16_t) -1;
634 struct xfs_inobt_rec_incore rec; 636 struct xfs_inobt_rec_incore rec;
635 struct xfs_perag *pag; 637 struct xfs_perag *pag;
636 int do_sparse = 0; 638 struct xfs_ino_geometry *igeo = M_IGEO(tp->t_mountp);
639 int do_sparse = 0;
637 640
638 memset(&args, 0, sizeof(args)); 641 memset(&args, 0, sizeof(args));
639 args.tp = tp; 642 args.tp = tp;
@@ -644,7 +647,7 @@ xfs_ialloc_ag_alloc(
644#ifdef DEBUG 647#ifdef DEBUG
645 /* randomly do sparse inode allocations */ 648 /* randomly do sparse inode allocations */
646 if (xfs_sb_version_hassparseinodes(&tp->t_mountp->m_sb) && 649 if (xfs_sb_version_hassparseinodes(&tp->t_mountp->m_sb) &&
647 args.mp->m_ialloc_min_blks < args.mp->m_ialloc_blks) 650 igeo->ialloc_min_blks < igeo->ialloc_blks)
648 do_sparse = prandom_u32() & 1; 651 do_sparse = prandom_u32() & 1;
649#endif 652#endif
650 653
@@ -652,12 +655,12 @@ xfs_ialloc_ag_alloc(
652 * Locking will ensure that we don't have two callers in here 655 * Locking will ensure that we don't have two callers in here
653 * at one time. 656 * at one time.
654 */ 657 */
655 newlen = args.mp->m_ialloc_inos; 658 newlen = igeo->ialloc_inos;
656 if (args.mp->m_maxicount && 659 if (igeo->maxicount &&
657 percpu_counter_read_positive(&args.mp->m_icount) + newlen > 660 percpu_counter_read_positive(&args.mp->m_icount) + newlen >
658 args.mp->m_maxicount) 661 igeo->maxicount)
659 return -ENOSPC; 662 return -ENOSPC;
660 args.minlen = args.maxlen = args.mp->m_ialloc_blks; 663 args.minlen = args.maxlen = igeo->ialloc_blks;
661 /* 664 /*
662 * First try to allocate inodes contiguous with the last-allocated 665 * First try to allocate inodes contiguous with the last-allocated
663 * chunk of inodes. If the filesystem is striped, this will fill 666 * chunk of inodes. If the filesystem is striped, this will fill
@@ -667,7 +670,7 @@ xfs_ialloc_ag_alloc(
667 newino = be32_to_cpu(agi->agi_newino); 670 newino = be32_to_cpu(agi->agi_newino);
668 agno = be32_to_cpu(agi->agi_seqno); 671 agno = be32_to_cpu(agi->agi_seqno);
669 args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) + 672 args.agbno = XFS_AGINO_TO_AGBNO(args.mp, newino) +
670 args.mp->m_ialloc_blks; 673 igeo->ialloc_blks;
671 if (do_sparse) 674 if (do_sparse)
672 goto sparse_alloc; 675 goto sparse_alloc;
673 if (likely(newino != NULLAGINO && 676 if (likely(newino != NULLAGINO &&
@@ -690,10 +693,10 @@ xfs_ialloc_ag_alloc(
690 * but not to use them in the actual exact allocation. 693 * but not to use them in the actual exact allocation.
691 */ 694 */
692 args.alignment = 1; 695 args.alignment = 1;
693 args.minalignslop = args.mp->m_cluster_align - 1; 696 args.minalignslop = igeo->cluster_align - 1;
694 697
695 /* Allow space for the inode btree to split. */ 698 /* Allow space for the inode btree to split. */
696 args.minleft = args.mp->m_in_maxlevels - 1; 699 args.minleft = igeo->inobt_maxlevels - 1;
697 if ((error = xfs_alloc_vextent(&args))) 700 if ((error = xfs_alloc_vextent(&args)))
698 return error; 701 return error;
699 702
@@ -720,12 +723,12 @@ xfs_ialloc_ag_alloc(
720 * pieces, so don't need alignment anyway. 723 * pieces, so don't need alignment anyway.
721 */ 724 */
722 isaligned = 0; 725 isaligned = 0;
723 if (args.mp->m_sinoalign) { 726 if (igeo->ialloc_align) {
724 ASSERT(!(args.mp->m_flags & XFS_MOUNT_NOALIGN)); 727 ASSERT(!(args.mp->m_flags & XFS_MOUNT_NOALIGN));
725 args.alignment = args.mp->m_dalign; 728 args.alignment = args.mp->m_dalign;
726 isaligned = 1; 729 isaligned = 1;
727 } else 730 } else
728 args.alignment = args.mp->m_cluster_align; 731 args.alignment = igeo->cluster_align;
729 /* 732 /*
730 * Need to figure out where to allocate the inode blocks. 733 * Need to figure out where to allocate the inode blocks.
731 * Ideally they should be spaced out through the a.g. 734 * Ideally they should be spaced out through the a.g.
@@ -741,7 +744,7 @@ xfs_ialloc_ag_alloc(
741 /* 744 /*
742 * Allow space for the inode btree to split. 745 * Allow space for the inode btree to split.
743 */ 746 */
744 args.minleft = args.mp->m_in_maxlevels - 1; 747 args.minleft = igeo->inobt_maxlevels - 1;
745 if ((error = xfs_alloc_vextent(&args))) 748 if ((error = xfs_alloc_vextent(&args)))
746 return error; 749 return error;
747 } 750 }
@@ -754,7 +757,7 @@ xfs_ialloc_ag_alloc(
754 args.type = XFS_ALLOCTYPE_NEAR_BNO; 757 args.type = XFS_ALLOCTYPE_NEAR_BNO;
755 args.agbno = be32_to_cpu(agi->agi_root); 758 args.agbno = be32_to_cpu(agi->agi_root);
756 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 759 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
757 args.alignment = args.mp->m_cluster_align; 760 args.alignment = igeo->cluster_align;
758 if ((error = xfs_alloc_vextent(&args))) 761 if ((error = xfs_alloc_vextent(&args)))
759 return error; 762 return error;
760 } 763 }
@@ -764,7 +767,7 @@ xfs_ialloc_ag_alloc(
764 * the sparse allocation length is smaller than a full chunk. 767 * the sparse allocation length is smaller than a full chunk.
765 */ 768 */
766 if (xfs_sb_version_hassparseinodes(&args.mp->m_sb) && 769 if (xfs_sb_version_hassparseinodes(&args.mp->m_sb) &&
767 args.mp->m_ialloc_min_blks < args.mp->m_ialloc_blks && 770 igeo->ialloc_min_blks < igeo->ialloc_blks &&
768 args.fsbno == NULLFSBLOCK) { 771 args.fsbno == NULLFSBLOCK) {
769sparse_alloc: 772sparse_alloc:
770 args.type = XFS_ALLOCTYPE_NEAR_BNO; 773 args.type = XFS_ALLOCTYPE_NEAR_BNO;
@@ -773,7 +776,7 @@ sparse_alloc:
773 args.alignment = args.mp->m_sb.sb_spino_align; 776 args.alignment = args.mp->m_sb.sb_spino_align;
774 args.prod = 1; 777 args.prod = 1;
775 778
776 args.minlen = args.mp->m_ialloc_min_blks; 779 args.minlen = igeo->ialloc_min_blks;
777 args.maxlen = args.minlen; 780 args.maxlen = args.minlen;
778 781
779 /* 782 /*
@@ -789,7 +792,7 @@ sparse_alloc:
789 args.min_agbno = args.mp->m_sb.sb_inoalignmt; 792 args.min_agbno = args.mp->m_sb.sb_inoalignmt;
790 args.max_agbno = round_down(args.mp->m_sb.sb_agblocks, 793 args.max_agbno = round_down(args.mp->m_sb.sb_agblocks,
791 args.mp->m_sb.sb_inoalignmt) - 794 args.mp->m_sb.sb_inoalignmt) -
792 args.mp->m_ialloc_blks; 795 igeo->ialloc_blks;
793 796
794 error = xfs_alloc_vextent(&args); 797 error = xfs_alloc_vextent(&args);
795 if (error) 798 if (error)
@@ -1006,7 +1009,7 @@ xfs_ialloc_ag_select(
1006 * space needed for alignment of inode chunks when checking the 1009 * space needed for alignment of inode chunks when checking the
1007 * longest contiguous free space in the AG - this prevents us 1010 * longest contiguous free space in the AG - this prevents us
1008 * from getting ENOSPC because we have free space larger than 1011 * from getting ENOSPC because we have free space larger than
1009 * m_ialloc_blks but alignment constraints prevent us from using 1012 * ialloc_blks but alignment constraints prevent us from using
1010 * it. 1013 * it.
1011 * 1014 *
1012 * If we can't find an AG with space for full alignment slack to 1015 * If we can't find an AG with space for full alignment slack to
@@ -1015,9 +1018,9 @@ xfs_ialloc_ag_select(
1015 * if we fail allocation due to alignment issues then it is most 1018 * if we fail allocation due to alignment issues then it is most
1016 * likely a real ENOSPC condition. 1019 * likely a real ENOSPC condition.
1017 */ 1020 */
1018 ineed = mp->m_ialloc_min_blks; 1021 ineed = M_IGEO(mp)->ialloc_min_blks;
1019 if (flags && ineed > 1) 1022 if (flags && ineed > 1)
1020 ineed += mp->m_cluster_align; 1023 ineed += M_IGEO(mp)->cluster_align;
1021 longest = pag->pagf_longest; 1024 longest = pag->pagf_longest;
1022 if (!longest) 1025 if (!longest)
1023 longest = pag->pagf_flcount > 0; 1026 longest = pag->pagf_flcount > 0;
@@ -1703,6 +1706,7 @@ xfs_dialloc(
1703 int noroom = 0; 1706 int noroom = 0;
1704 xfs_agnumber_t start_agno; 1707 xfs_agnumber_t start_agno;
1705 struct xfs_perag *pag; 1708 struct xfs_perag *pag;
1709 struct xfs_ino_geometry *igeo = M_IGEO(mp);
1706 int okalloc = 1; 1710 int okalloc = 1;
1707 1711
1708 if (*IO_agbp) { 1712 if (*IO_agbp) {
@@ -1733,9 +1737,9 @@ xfs_dialloc(
1733 * Read rough value of mp->m_icount by percpu_counter_read_positive, 1737 * Read rough value of mp->m_icount by percpu_counter_read_positive,
1734 * which will sacrifice the preciseness but improve the performance. 1738 * which will sacrifice the preciseness but improve the performance.
1735 */ 1739 */
1736 if (mp->m_maxicount && 1740 if (igeo->maxicount &&
1737 percpu_counter_read_positive(&mp->m_icount) + mp->m_ialloc_inos 1741 percpu_counter_read_positive(&mp->m_icount) + igeo->ialloc_inos
1738 > mp->m_maxicount) { 1742 > igeo->maxicount) {
1739 noroom = 1; 1743 noroom = 1;
1740 okalloc = 0; 1744 okalloc = 0;
1741 } 1745 }
@@ -1852,7 +1856,8 @@ xfs_difree_inode_chunk(
1852 if (!xfs_inobt_issparse(rec->ir_holemask)) { 1856 if (!xfs_inobt_issparse(rec->ir_holemask)) {
1853 /* not sparse, calculate extent info directly */ 1857 /* not sparse, calculate extent info directly */
1854 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno), 1858 xfs_bmap_add_free(tp, XFS_AGB_TO_FSB(mp, agno, sagbno),
1855 mp->m_ialloc_blks, &XFS_RMAP_OINFO_INODES); 1859 M_IGEO(mp)->ialloc_blks,
1860 &XFS_RMAP_OINFO_INODES);
1856 return; 1861 return;
1857 } 1862 }
1858 1863
@@ -2261,7 +2266,7 @@ xfs_imap_lookup(
2261 2266
2262 /* check that the returned record contains the required inode */ 2267 /* check that the returned record contains the required inode */
2263 if (rec.ir_startino > agino || 2268 if (rec.ir_startino > agino ||
2264 rec.ir_startino + mp->m_ialloc_inos <= agino) 2269 rec.ir_startino + M_IGEO(mp)->ialloc_inos <= agino)
2265 return -EINVAL; 2270 return -EINVAL;
2266 2271
2267 /* for untrusted inodes check it is allocated first */ 2272 /* for untrusted inodes check it is allocated first */
@@ -2352,7 +2357,7 @@ xfs_imap(
2352 * If the inode cluster size is the same as the blocksize or 2357 * If the inode cluster size is the same as the blocksize or
2353 * smaller we get to the buffer by simple arithmetics. 2358 * smaller we get to the buffer by simple arithmetics.
2354 */ 2359 */
2355 if (mp->m_blocks_per_cluster == 1) { 2360 if (M_IGEO(mp)->blocks_per_cluster == 1) {
2356 offset = XFS_INO_TO_OFFSET(mp, ino); 2361 offset = XFS_INO_TO_OFFSET(mp, ino);
2357 ASSERT(offset < mp->m_sb.sb_inopblock); 2362 ASSERT(offset < mp->m_sb.sb_inopblock);
2358 2363
@@ -2368,8 +2373,8 @@ xfs_imap(
2368 * find the location. Otherwise we have to do a btree 2373 * find the location. Otherwise we have to do a btree
2369 * lookup to find the location. 2374 * lookup to find the location.
2370 */ 2375 */
2371 if (mp->m_inoalign_mask) { 2376 if (M_IGEO(mp)->inoalign_mask) {
2372 offset_agbno = agbno & mp->m_inoalign_mask; 2377 offset_agbno = agbno & M_IGEO(mp)->inoalign_mask;
2373 chunk_agbno = agbno - offset_agbno; 2378 chunk_agbno = agbno - offset_agbno;
2374 } else { 2379 } else {
2375 error = xfs_imap_lookup(mp, tp, agno, agino, agbno, 2380 error = xfs_imap_lookup(mp, tp, agno, agino, agbno,
@@ -2381,13 +2386,13 @@ xfs_imap(
2381out_map: 2386out_map:
2382 ASSERT(agbno >= chunk_agbno); 2387 ASSERT(agbno >= chunk_agbno);
2383 cluster_agbno = chunk_agbno + 2388 cluster_agbno = chunk_agbno +
2384 ((offset_agbno / mp->m_blocks_per_cluster) * 2389 ((offset_agbno / M_IGEO(mp)->blocks_per_cluster) *
2385 mp->m_blocks_per_cluster); 2390 M_IGEO(mp)->blocks_per_cluster);
2386 offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) + 2391 offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +
2387 XFS_INO_TO_OFFSET(mp, ino); 2392 XFS_INO_TO_OFFSET(mp, ino);
2388 2393
2389 imap->im_blkno = XFS_AGB_TO_DADDR(mp, agno, cluster_agbno); 2394 imap->im_blkno = XFS_AGB_TO_DADDR(mp, agno, cluster_agbno);
2390 imap->im_len = XFS_FSB_TO_BB(mp, mp->m_blocks_per_cluster); 2395 imap->im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
2391 imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); 2396 imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
2392 2397
2393 /* 2398 /*
@@ -2409,7 +2414,7 @@ out_map:
2409} 2414}
2410 2415
2411/* 2416/*
2412 * Compute and fill in value of m_in_maxlevels. 2417 * Compute and fill in value of m_ino_geo.inobt_maxlevels.
2413 */ 2418 */
2414void 2419void
2415xfs_ialloc_compute_maxlevels( 2420xfs_ialloc_compute_maxlevels(
@@ -2418,8 +2423,8 @@ xfs_ialloc_compute_maxlevels(
2418 uint inodes; 2423 uint inodes;
2419 2424
2420 inodes = (1LL << XFS_INO_AGINO_BITS(mp)) >> XFS_INODES_PER_CHUNK_LOG; 2425 inodes = (1LL << XFS_INO_AGINO_BITS(mp)) >> XFS_INODES_PER_CHUNK_LOG;
2421 mp->m_in_maxlevels = xfs_btree_compute_maxlevels(mp->m_inobt_mnr, 2426 M_IGEO(mp)->inobt_maxlevels = xfs_btree_compute_maxlevels(
2422 inodes); 2427 M_IGEO(mp)->inobt_mnr, inodes);
2423} 2428}
2424 2429
2425/* 2430/*
diff --git a/fs/xfs/libxfs/xfs_ialloc.h b/fs/xfs/libxfs/xfs_ialloc.h
index e936b7cc9389..e7d935e69b11 100644
--- a/fs/xfs/libxfs/xfs_ialloc.h
+++ b/fs/xfs/libxfs/xfs_ialloc.h
@@ -28,9 +28,9 @@ static inline int
28xfs_icluster_size_fsb( 28xfs_icluster_size_fsb(
29 struct xfs_mount *mp) 29 struct xfs_mount *mp)
30{ 30{
31 if (mp->m_sb.sb_blocksize >= mp->m_inode_cluster_size) 31 if (mp->m_sb.sb_blocksize >= M_IGEO(mp)->inode_cluster_size)
32 return 1; 32 return 1;
33 return mp->m_inode_cluster_size >> mp->m_sb.sb_blocklog; 33 return M_IGEO(mp)->inode_cluster_size >> mp->m_sb.sb_blocklog;
34} 34}
35 35
36/* 36/*
@@ -96,7 +96,7 @@ xfs_imap(
96 uint flags); /* flags for inode btree lookup */ 96 uint flags); /* flags for inode btree lookup */
97 97
98/* 98/*
99 * Compute and fill in value of m_in_maxlevels. 99 * Compute and fill in value of m_ino_geo.inobt_maxlevels.
100 */ 100 */
101void 101void
102xfs_ialloc_compute_maxlevels( 102xfs_ialloc_compute_maxlevels(
diff --git a/fs/xfs/libxfs/xfs_ialloc_btree.c b/fs/xfs/libxfs/xfs_ialloc_btree.c
index bc2dfacd2f4a..ac4b65da4c2b 100644
--- a/fs/xfs/libxfs/xfs_ialloc_btree.c
+++ b/fs/xfs/libxfs/xfs_ialloc_btree.c
@@ -28,7 +28,7 @@ xfs_inobt_get_minrecs(
28 struct xfs_btree_cur *cur, 28 struct xfs_btree_cur *cur,
29 int level) 29 int level)
30{ 30{
31 return cur->bc_mp->m_inobt_mnr[level != 0]; 31 return M_IGEO(cur->bc_mp)->inobt_mnr[level != 0];
32} 32}
33 33
34STATIC struct xfs_btree_cur * 34STATIC struct xfs_btree_cur *
@@ -164,7 +164,7 @@ xfs_inobt_get_maxrecs(
164 struct xfs_btree_cur *cur, 164 struct xfs_btree_cur *cur,
165 int level) 165 int level)
166{ 166{
167 return cur->bc_mp->m_inobt_mxr[level != 0]; 167 return M_IGEO(cur->bc_mp)->inobt_mxr[level != 0];
168} 168}
169 169
170STATIC void 170STATIC void
@@ -281,10 +281,11 @@ xfs_inobt_verify(
281 281
282 /* level verification */ 282 /* level verification */
283 level = be16_to_cpu(block->bb_level); 283 level = be16_to_cpu(block->bb_level);
284 if (level >= mp->m_in_maxlevels) 284 if (level >= M_IGEO(mp)->inobt_maxlevels)
285 return __this_address; 285 return __this_address;
286 286
287 return xfs_btree_sblock_verify(bp, mp->m_inobt_mxr[level != 0]); 287 return xfs_btree_sblock_verify(bp,
288 M_IGEO(mp)->inobt_mxr[level != 0]);
288} 289}
289 290
290static void 291static void
@@ -546,7 +547,7 @@ xfs_inobt_max_size(
546 xfs_agblock_t agblocks = xfs_ag_block_count(mp, agno); 547 xfs_agblock_t agblocks = xfs_ag_block_count(mp, agno);
547 548
548 /* Bail out if we're uninitialized, which can happen in mkfs. */ 549 /* Bail out if we're uninitialized, which can happen in mkfs. */
549 if (mp->m_inobt_mxr[0] == 0) 550 if (M_IGEO(mp)->inobt_mxr[0] == 0)
550 return 0; 551 return 0;
551 552
552 /* 553 /*
@@ -558,7 +559,7 @@ xfs_inobt_max_size(
558 XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno) 559 XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
559 agblocks -= mp->m_sb.sb_logblocks; 560 agblocks -= mp->m_sb.sb_logblocks;
560 561
561 return xfs_btree_calc_size(mp->m_inobt_mnr, 562 return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr,
562 (uint64_t)agblocks * mp->m_sb.sb_inopblock / 563 (uint64_t)agblocks * mp->m_sb.sb_inopblock /
563 XFS_INODES_PER_CHUNK); 564 XFS_INODES_PER_CHUNK);
564} 565}
@@ -619,5 +620,5 @@ xfs_iallocbt_calc_size(
619 struct xfs_mount *mp, 620 struct xfs_mount *mp,
620 unsigned long long len) 621 unsigned long long len)
621{ 622{
622 return xfs_btree_calc_size(mp->m_inobt_mnr, len); 623 return xfs_btree_calc_size(M_IGEO(mp)->inobt_mnr, len);
623} 624}
diff --git a/fs/xfs/libxfs/xfs_inode_buf.c b/fs/xfs/libxfs/xfs_inode_buf.c
index e021d5133ccb..c1293d170d98 100644
--- a/fs/xfs/libxfs/xfs_inode_buf.c
+++ b/fs/xfs/libxfs/xfs_inode_buf.c
@@ -36,7 +36,7 @@ xfs_inobp_check(
36 int j; 36 int j;
37 xfs_dinode_t *dip; 37 xfs_dinode_t *dip;
38 38
39 j = mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog; 39 j = M_IGEO(mp)->inode_cluster_size >> mp->m_sb.sb_inodelog;
40 40
41 for (i = 0; i < j; i++) { 41 for (i = 0; i < j; i++) {
42 dip = xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize); 42 dip = xfs_buf_offset(bp, i * mp->m_sb.sb_inodesize);
diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c
index e76a3e5d28d7..a44eb52b861d 100644
--- a/fs/xfs/libxfs/xfs_sb.c
+++ b/fs/xfs/libxfs/xfs_sb.c
@@ -804,16 +804,18 @@ const struct xfs_buf_ops xfs_sb_quiet_buf_ops = {
804 */ 804 */
805void 805void
806xfs_sb_mount_common( 806xfs_sb_mount_common(
807 struct xfs_mount *mp, 807 struct xfs_mount *mp,
808 struct xfs_sb *sbp) 808 struct xfs_sb *sbp)
809{ 809{
810 struct xfs_ino_geometry *igeo = M_IGEO(mp);
811
810 mp->m_agfrotor = mp->m_agirotor = 0; 812 mp->m_agfrotor = mp->m_agirotor = 0;
811 mp->m_maxagi = mp->m_sb.sb_agcount; 813 mp->m_maxagi = mp->m_sb.sb_agcount;
812 mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG; 814 mp->m_blkbit_log = sbp->sb_blocklog + XFS_NBBYLOG;
813 mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT; 815 mp->m_blkbb_log = sbp->sb_blocklog - BBSHIFT;
814 mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT; 816 mp->m_sectbb_log = sbp->sb_sectlog - BBSHIFT;
815 mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1; 817 mp->m_agno_log = xfs_highbit32(sbp->sb_agcount - 1) + 1;
816 mp->m_agino_log = sbp->sb_inopblog + sbp->sb_agblklog; 818 igeo->agino_log = sbp->sb_inopblog + sbp->sb_agblklog;
817 mp->m_blockmask = sbp->sb_blocksize - 1; 819 mp->m_blockmask = sbp->sb_blocksize - 1;
818 mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG; 820 mp->m_blockwsize = sbp->sb_blocksize >> XFS_WORDLOG;
819 mp->m_blockwmask = mp->m_blockwsize - 1; 821 mp->m_blockwmask = mp->m_blockwsize - 1;
@@ -823,10 +825,10 @@ xfs_sb_mount_common(
823 mp->m_alloc_mnr[0] = mp->m_alloc_mxr[0] / 2; 825 mp->m_alloc_mnr[0] = mp->m_alloc_mxr[0] / 2;
824 mp->m_alloc_mnr[1] = mp->m_alloc_mxr[1] / 2; 826 mp->m_alloc_mnr[1] = mp->m_alloc_mxr[1] / 2;
825 827
826 mp->m_inobt_mxr[0] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, 1); 828 igeo->inobt_mxr[0] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, 1);
827 mp->m_inobt_mxr[1] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, 0); 829 igeo->inobt_mxr[1] = xfs_inobt_maxrecs(mp, sbp->sb_blocksize, 0);
828 mp->m_inobt_mnr[0] = mp->m_inobt_mxr[0] / 2; 830 igeo->inobt_mnr[0] = igeo->inobt_mxr[0] / 2;
829 mp->m_inobt_mnr[1] = mp->m_inobt_mxr[1] / 2; 831 igeo->inobt_mnr[1] = igeo->inobt_mxr[1] / 2;
830 832
831 mp->m_bmap_dmxr[0] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, 1); 833 mp->m_bmap_dmxr[0] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, 1);
832 mp->m_bmap_dmxr[1] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, 0); 834 mp->m_bmap_dmxr[1] = xfs_bmbt_maxrecs(mp, sbp->sb_blocksize, 0);
@@ -844,14 +846,14 @@ xfs_sb_mount_common(
844 mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2; 846 mp->m_refc_mnr[1] = mp->m_refc_mxr[1] / 2;
845 847
846 mp->m_bsize = XFS_FSB_TO_BB(mp, 1); 848 mp->m_bsize = XFS_FSB_TO_BB(mp, 1);
847 mp->m_ialloc_inos = max_t(uint16_t, XFS_INODES_PER_CHUNK, 849 igeo->ialloc_inos = max_t(uint16_t, XFS_INODES_PER_CHUNK,
848 sbp->sb_inopblock); 850 sbp->sb_inopblock);
849 mp->m_ialloc_blks = mp->m_ialloc_inos >> sbp->sb_inopblog; 851 igeo->ialloc_blks = igeo->ialloc_inos >> sbp->sb_inopblog;
850 852
851 if (sbp->sb_spino_align) 853 if (sbp->sb_spino_align)
852 mp->m_ialloc_min_blks = sbp->sb_spino_align; 854 igeo->ialloc_min_blks = sbp->sb_spino_align;
853 else 855 else
854 mp->m_ialloc_min_blks = mp->m_ialloc_blks; 856 igeo->ialloc_min_blks = igeo->ialloc_blks;
855 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp); 857 mp->m_alloc_set_aside = xfs_alloc_set_aside(mp);
856 mp->m_ag_max_usable = xfs_alloc_ag_max_usable(mp); 858 mp->m_ag_max_usable = xfs_alloc_ag_max_usable(mp);
857} 859}
diff --git a/fs/xfs/libxfs/xfs_trans_resv.c b/fs/xfs/libxfs/xfs_trans_resv.c
index 83f4ee2afc49..2663dd7975a5 100644
--- a/fs/xfs/libxfs/xfs_trans_resv.c
+++ b/fs/xfs/libxfs/xfs_trans_resv.c
@@ -136,9 +136,10 @@ STATIC uint
136xfs_calc_inobt_res( 136xfs_calc_inobt_res(
137 struct xfs_mount *mp) 137 struct xfs_mount *mp)
138{ 138{
139 return xfs_calc_buf_res(mp->m_in_maxlevels, XFS_FSB_TO_B(mp, 1)) + 139 return xfs_calc_buf_res(M_IGEO(mp)->inobt_maxlevels,
140 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1), 140 XFS_FSB_TO_B(mp, 1)) +
141 XFS_FSB_TO_B(mp, 1)); 141 xfs_calc_buf_res(xfs_allocfree_log_count(mp, 1),
142 XFS_FSB_TO_B(mp, 1));
142} 143}
143 144
144/* 145/*
@@ -167,7 +168,7 @@ xfs_calc_finobt_res(
167 * includes: 168 * includes:
168 * 169 *
169 * the allocation btrees: 2 trees * (max depth - 1) * block size 170 * the allocation btrees: 2 trees * (max depth - 1) * block size
170 * the inode chunk: m_ialloc_blks * N 171 * the inode chunk: m_ino_geo.ialloc_blks * N
171 * 172 *
172 * The size N of the inode chunk reservation depends on whether it is for 173 * The size N of the inode chunk reservation depends on whether it is for
173 * allocation or free and which type of create transaction is in use. An inode 174 * allocation or free and which type of create transaction is in use. An inode
@@ -193,7 +194,7 @@ xfs_calc_inode_chunk_res(
193 size = XFS_FSB_TO_B(mp, 1); 194 size = XFS_FSB_TO_B(mp, 1);
194 } 195 }
195 196
196 res += xfs_calc_buf_res(mp->m_ialloc_blks, size); 197 res += xfs_calc_buf_res(M_IGEO(mp)->ialloc_blks, size);
197 return res; 198 return res;
198} 199}
199 200
@@ -307,7 +308,8 @@ xfs_calc_iunlink_remove_reservation(
307 struct xfs_mount *mp) 308 struct xfs_mount *mp)
308{ 309{
309 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) + 310 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
310 2 * max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size); 311 2 * max_t(uint, XFS_FSB_TO_B(mp, 1),
312 M_IGEO(mp)->inode_cluster_size);
311} 313}
312 314
313/* 315/*
@@ -345,7 +347,8 @@ STATIC uint
345xfs_calc_iunlink_add_reservation(xfs_mount_t *mp) 347xfs_calc_iunlink_add_reservation(xfs_mount_t *mp)
346{ 348{
347 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) + 349 return xfs_calc_buf_res(1, mp->m_sb.sb_sectsize) +
348 max_t(uint, XFS_FSB_TO_B(mp, 1), mp->m_inode_cluster_size); 350 max_t(uint, XFS_FSB_TO_B(mp, 1),
351 M_IGEO(mp)->inode_cluster_size);
349} 352}
350 353
351/* 354/*
diff --git a/fs/xfs/libxfs/xfs_trans_space.h b/fs/xfs/libxfs/xfs_trans_space.h
index a62fb950bef1..88221c7a04cc 100644
--- a/fs/xfs/libxfs/xfs_trans_space.h
+++ b/fs/xfs/libxfs/xfs_trans_space.h
@@ -56,9 +56,9 @@
56#define XFS_DIRREMOVE_SPACE_RES(mp) \ 56#define XFS_DIRREMOVE_SPACE_RES(mp) \
57 XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK) 57 XFS_DAREMOVE_SPACE_RES(mp, XFS_DATA_FORK)
58#define XFS_IALLOC_SPACE_RES(mp) \ 58#define XFS_IALLOC_SPACE_RES(mp) \
59 ((mp)->m_ialloc_blks + \ 59 (M_IGEO(mp)->ialloc_blks + \
60 (xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1 * \ 60 (xfs_sb_version_hasfinobt(&mp->m_sb) ? 2 : 1 * \
61 ((mp)->m_in_maxlevels - 1))) 61 (M_IGEO(mp)->inobt_maxlevels - 1)))
62 62
63/* 63/*
64 * Space reservation values for various transactions. 64 * Space reservation values for various transactions.
@@ -94,7 +94,8 @@
94#define XFS_SYMLINK_SPACE_RES(mp,nl,b) \ 94#define XFS_SYMLINK_SPACE_RES(mp,nl,b) \
95 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b)) 95 (XFS_IALLOC_SPACE_RES(mp) + XFS_DIRENTER_SPACE_RES(mp,nl) + (b))
96#define XFS_IFREE_SPACE_RES(mp) \ 96#define XFS_IFREE_SPACE_RES(mp) \
97 (xfs_sb_version_hasfinobt(&mp->m_sb) ? (mp)->m_in_maxlevels : 0) 97 (xfs_sb_version_hasfinobt(&mp->m_sb) ? \
98 M_IGEO(mp)->inobt_maxlevels : 0)
98 99
99 100
100#endif /* __XFS_TRANS_SPACE_H__ */ 101#endif /* __XFS_TRANS_SPACE_H__ */
diff --git a/fs/xfs/libxfs/xfs_types.c b/fs/xfs/libxfs/xfs_types.c
index d51acc95bc00..a2bd9f5a5e30 100644
--- a/fs/xfs/libxfs/xfs_types.c
+++ b/fs/xfs/libxfs/xfs_types.c
@@ -87,14 +87,14 @@ xfs_agino_range(
87 * Calculate the first inode, which will be in the first 87 * Calculate the first inode, which will be in the first
88 * cluster-aligned block after the AGFL. 88 * cluster-aligned block after the AGFL.
89 */ 89 */
90 bno = round_up(XFS_AGFL_BLOCK(mp) + 1, mp->m_cluster_align); 90 bno = round_up(XFS_AGFL_BLOCK(mp) + 1, M_IGEO(mp)->cluster_align);
91 *first = XFS_AGB_TO_AGINO(mp, bno); 91 *first = XFS_AGB_TO_AGINO(mp, bno);
92 92
93 /* 93 /*
94 * Calculate the last inode, which will be at the end of the 94 * Calculate the last inode, which will be at the end of the
95 * last (aligned) cluster that can be allocated in the AG. 95 * last (aligned) cluster that can be allocated in the AG.
96 */ 96 */
97 bno = round_down(eoag, mp->m_cluster_align); 97 bno = round_down(eoag, M_IGEO(mp)->cluster_align);
98 *last = XFS_AGB_TO_AGINO(mp, bno) - 1; 98 *last = XFS_AGB_TO_AGINO(mp, bno) - 1;
99} 99}
100 100
diff --git a/fs/xfs/scrub/ialloc.c b/fs/xfs/scrub/ialloc.c
index 9b47117180cb..3c3abd096143 100644
--- a/fs/xfs/scrub/ialloc.c
+++ b/fs/xfs/scrub/ialloc.c
@@ -230,7 +230,7 @@ xchk_iallocbt_check_cluster(
230 int error = 0; 230 int error = 0;
231 231
232 nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK, 232 nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK,
233 mp->m_inodes_per_cluster); 233 M_IGEO(mp)->inodes_per_cluster);
234 234
235 /* Map this inode cluster */ 235 /* Map this inode cluster */
236 agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino + cluster_base); 236 agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino + cluster_base);
@@ -251,7 +251,7 @@ xchk_iallocbt_check_cluster(
251 */ 251 */
252 ir_holemask = (irec->ir_holemask & cluster_mask); 252 ir_holemask = (irec->ir_holemask & cluster_mask);
253 imap.im_blkno = XFS_AGB_TO_DADDR(mp, agno, agbno); 253 imap.im_blkno = XFS_AGB_TO_DADDR(mp, agno, agbno);
254 imap.im_len = XFS_FSB_TO_BB(mp, mp->m_blocks_per_cluster); 254 imap.im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
255 imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) << 255 imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) <<
256 mp->m_sb.sb_inodelog; 256 mp->m_sb.sb_inodelog;
257 257
@@ -276,12 +276,12 @@ xchk_iallocbt_check_cluster(
276 /* If any part of this is a hole, skip it. */ 276 /* If any part of this is a hole, skip it. */
277 if (ir_holemask) { 277 if (ir_holemask) {
278 xchk_xref_is_not_owned_by(bs->sc, agbno, 278 xchk_xref_is_not_owned_by(bs->sc, agbno,
279 mp->m_blocks_per_cluster, 279 M_IGEO(mp)->blocks_per_cluster,
280 &XFS_RMAP_OINFO_INODES); 280 &XFS_RMAP_OINFO_INODES);
281 return 0; 281 return 0;
282 } 282 }
283 283
284 xchk_xref_is_owned_by(bs->sc, agbno, mp->m_blocks_per_cluster, 284 xchk_xref_is_owned_by(bs->sc, agbno, M_IGEO(mp)->blocks_per_cluster,
285 &XFS_RMAP_OINFO_INODES); 285 &XFS_RMAP_OINFO_INODES);
286 286
287 /* Grab the inode cluster buffer. */ 287 /* Grab the inode cluster buffer. */
@@ -333,7 +333,7 @@ xchk_iallocbt_check_clusters(
333 */ 333 */
334 for (cluster_base = 0; 334 for (cluster_base = 0;
335 cluster_base < XFS_INODES_PER_CHUNK; 335 cluster_base < XFS_INODES_PER_CHUNK;
336 cluster_base += bs->sc->mp->m_inodes_per_cluster) { 336 cluster_base += M_IGEO(bs->sc->mp)->inodes_per_cluster) {
337 error = xchk_iallocbt_check_cluster(bs, irec, cluster_base); 337 error = xchk_iallocbt_check_cluster(bs, irec, cluster_base);
338 if (error) 338 if (error)
339 break; 339 break;
@@ -355,6 +355,7 @@ xchk_iallocbt_rec_alignment(
355{ 355{
356 struct xfs_mount *mp = bs->sc->mp; 356 struct xfs_mount *mp = bs->sc->mp;
357 struct xchk_iallocbt *iabt = bs->private; 357 struct xchk_iallocbt *iabt = bs->private;
358 struct xfs_ino_geometry *igeo = M_IGEO(mp);
358 359
359 /* 360 /*
360 * finobt records have different positioning requirements than inobt 361 * finobt records have different positioning requirements than inobt
@@ -372,7 +373,7 @@ xchk_iallocbt_rec_alignment(
372 unsigned int imask; 373 unsigned int imask;
373 374
374 imask = min_t(unsigned int, XFS_INODES_PER_CHUNK, 375 imask = min_t(unsigned int, XFS_INODES_PER_CHUNK,
375 mp->m_cluster_align_inodes) - 1; 376 igeo->cluster_align_inodes) - 1;
376 if (irec->ir_startino & imask) 377 if (irec->ir_startino & imask)
377 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 378 xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
378 return; 379 return;
@@ -400,17 +401,17 @@ xchk_iallocbt_rec_alignment(
400 } 401 }
401 402
402 /* inobt records must be aligned to cluster and inoalignmnt size. */ 403 /* inobt records must be aligned to cluster and inoalignmnt size. */
403 if (irec->ir_startino & (mp->m_cluster_align_inodes - 1)) { 404 if (irec->ir_startino & (igeo->cluster_align_inodes - 1)) {
404 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 405 xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
405 return; 406 return;
406 } 407 }
407 408
408 if (irec->ir_startino & (mp->m_inodes_per_cluster - 1)) { 409 if (irec->ir_startino & (igeo->inodes_per_cluster - 1)) {
409 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 410 xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
410 return; 411 return;
411 } 412 }
412 413
413 if (mp->m_inodes_per_cluster <= XFS_INODES_PER_CHUNK) 414 if (igeo->inodes_per_cluster <= XFS_INODES_PER_CHUNK)
414 return; 415 return;
415 416
416 /* 417 /*
@@ -419,7 +420,7 @@ xchk_iallocbt_rec_alignment(
419 * after this one. 420 * after this one.
420 */ 421 */
421 iabt->next_startino = irec->ir_startino + XFS_INODES_PER_CHUNK; 422 iabt->next_startino = irec->ir_startino + XFS_INODES_PER_CHUNK;
422 iabt->next_cluster_ino = irec->ir_startino + mp->m_inodes_per_cluster; 423 iabt->next_cluster_ino = irec->ir_startino + igeo->inodes_per_cluster;
423} 424}
424 425
425/* Scrub an inobt/finobt record. */ 426/* Scrub an inobt/finobt record. */
diff --git a/fs/xfs/scrub/quota.c b/fs/xfs/scrub/quota.c
index 5dfe2b5924db..de75effddb0d 100644
--- a/fs/xfs/scrub/quota.c
+++ b/fs/xfs/scrub/quota.c
@@ -144,7 +144,7 @@ xchk_quota_item(
144 if (bsoft > bhard) 144 if (bsoft > bhard)
145 xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); 145 xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset);
146 146
147 if (ihard > mp->m_maxicount) 147 if (ihard > M_IGEO(mp)->maxicount)
148 xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset); 148 xchk_fblock_set_warning(sc, XFS_DATA_FORK, offset);
149 if (isoft > ihard) 149 if (isoft > ihard)
150 xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset); 150 xchk_fblock_set_corrupt(sc, XFS_DATA_FORK, offset);
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 3d0e0570e3aa..773cb02e7312 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -251,9 +251,9 @@ xfs_growfs_data(
251 if (mp->m_sb.sb_imax_pct) { 251 if (mp->m_sb.sb_imax_pct) {
252 uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct; 252 uint64_t icount = mp->m_sb.sb_dblocks * mp->m_sb.sb_imax_pct;
253 do_div(icount, 100); 253 do_div(icount, 100);
254 mp->m_maxicount = XFS_FSB_TO_INO(mp, icount); 254 M_IGEO(mp)->maxicount = XFS_FSB_TO_INO(mp, icount);
255 } else 255 } else
256 mp->m_maxicount = 0; 256 M_IGEO(mp)->maxicount = 0;
257 257
258 /* Update secondary superblocks now the physical grow has completed */ 258 /* Update secondary superblocks now the physical grow has completed */
259 error = xfs_update_secondary_sbs(mp); 259 error = xfs_update_secondary_sbs(mp);
diff --git a/fs/xfs/xfs_inode.c b/fs/xfs/xfs_inode.c
index 71d216cf6f87..65eace4b8723 100644
--- a/fs/xfs/xfs_inode.c
+++ b/fs/xfs/xfs_inode.c
@@ -2537,13 +2537,14 @@ xfs_ifree_cluster(
2537 xfs_inode_log_item_t *iip; 2537 xfs_inode_log_item_t *iip;
2538 struct xfs_log_item *lip; 2538 struct xfs_log_item *lip;
2539 struct xfs_perag *pag; 2539 struct xfs_perag *pag;
2540 struct xfs_ino_geometry *igeo = M_IGEO(mp);
2540 xfs_ino_t inum; 2541 xfs_ino_t inum;
2541 2542
2542 inum = xic->first_ino; 2543 inum = xic->first_ino;
2543 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum)); 2544 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, inum));
2544 nbufs = mp->m_ialloc_blks / mp->m_blocks_per_cluster; 2545 nbufs = igeo->ialloc_blks / igeo->blocks_per_cluster;
2545 2546
2546 for (j = 0; j < nbufs; j++, inum += mp->m_inodes_per_cluster) { 2547 for (j = 0; j < nbufs; j++, inum += igeo->inodes_per_cluster) {
2547 /* 2548 /*
2548 * The allocation bitmap tells us which inodes of the chunk were 2549 * The allocation bitmap tells us which inodes of the chunk were
2549 * physically allocated. Skip the cluster if an inode falls into 2550 * physically allocated. Skip the cluster if an inode falls into
@@ -2551,7 +2552,7 @@ xfs_ifree_cluster(
2551 */ 2552 */
2552 ioffset = inum - xic->first_ino; 2553 ioffset = inum - xic->first_ino;
2553 if ((xic->alloc & XFS_INOBT_MASK(ioffset)) == 0) { 2554 if ((xic->alloc & XFS_INOBT_MASK(ioffset)) == 0) {
2554 ASSERT(ioffset % mp->m_inodes_per_cluster == 0); 2555 ASSERT(ioffset % igeo->inodes_per_cluster == 0);
2555 continue; 2556 continue;
2556 } 2557 }
2557 2558
@@ -2567,7 +2568,7 @@ xfs_ifree_cluster(
2567 * to mark all the active inodes on the buffer stale. 2568 * to mark all the active inodes on the buffer stale.
2568 */ 2569 */
2569 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno, 2570 bp = xfs_trans_get_buf(tp, mp->m_ddev_targp, blkno,
2570 mp->m_bsize * mp->m_blocks_per_cluster, 2571 mp->m_bsize * igeo->blocks_per_cluster,
2571 XBF_UNMAPPED); 2572 XBF_UNMAPPED);
2572 2573
2573 if (!bp) 2574 if (!bp)
@@ -2614,7 +2615,7 @@ xfs_ifree_cluster(
2614 * transaction stale above, which means there is no point in 2615 * transaction stale above, which means there is no point in
2615 * even trying to lock them. 2616 * even trying to lock them.
2616 */ 2617 */
2617 for (i = 0; i < mp->m_inodes_per_cluster; i++) { 2618 for (i = 0; i < igeo->inodes_per_cluster; i++) {
2618retry: 2619retry:
2619 rcu_read_lock(); 2620 rcu_read_lock();
2620 ip = radix_tree_lookup(&pag->pag_ici_root, 2621 ip = radix_tree_lookup(&pag->pag_ici_root,
@@ -3476,19 +3477,20 @@ xfs_iflush_cluster(
3476 int cilist_size; 3477 int cilist_size;
3477 struct xfs_inode **cilist; 3478 struct xfs_inode **cilist;
3478 struct xfs_inode *cip; 3479 struct xfs_inode *cip;
3480 struct xfs_ino_geometry *igeo = M_IGEO(mp);
3479 int nr_found; 3481 int nr_found;
3480 int clcount = 0; 3482 int clcount = 0;
3481 int i; 3483 int i;
3482 3484
3483 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino)); 3485 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, ip->i_ino));
3484 3486
3485 inodes_per_cluster = mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog; 3487 inodes_per_cluster = igeo->inode_cluster_size >> mp->m_sb.sb_inodelog;
3486 cilist_size = inodes_per_cluster * sizeof(xfs_inode_t *); 3488 cilist_size = inodes_per_cluster * sizeof(xfs_inode_t *);
3487 cilist = kmem_alloc(cilist_size, KM_MAYFAIL|KM_NOFS); 3489 cilist = kmem_alloc(cilist_size, KM_MAYFAIL|KM_NOFS);
3488 if (!cilist) 3490 if (!cilist)
3489 goto out_put; 3491 goto out_put;
3490 3492
3491 mask = ~(((mp->m_inode_cluster_size >> mp->m_sb.sb_inodelog)) - 1); 3493 mask = ~(((igeo->inode_cluster_size >> mp->m_sb.sb_inodelog)) - 1);
3492 first_index = XFS_INO_TO_AGINO(mp, ip->i_ino) & mask; 3494 first_index = XFS_INO_TO_AGINO(mp, ip->i_ino) & mask;
3493 rcu_read_lock(); 3495 rcu_read_lock();
3494 /* really need a gang lookup range call here */ 3496 /* really need a gang lookup range call here */
diff --git a/fs/xfs/xfs_itable.c b/fs/xfs/xfs_itable.c
index 1e1a0af1dd34..eef307cf90a7 100644
--- a/fs/xfs/xfs_itable.c
+++ b/fs/xfs/xfs_itable.c
@@ -167,6 +167,7 @@ xfs_bulkstat_ichunk_ra(
167 xfs_agnumber_t agno, 167 xfs_agnumber_t agno,
168 struct xfs_inobt_rec_incore *irec) 168 struct xfs_inobt_rec_incore *irec)
169{ 169{
170 struct xfs_ino_geometry *igeo = M_IGEO(mp);
170 xfs_agblock_t agbno; 171 xfs_agblock_t agbno;
171 struct blk_plug plug; 172 struct blk_plug plug;
172 int i; /* inode chunk index */ 173 int i; /* inode chunk index */
@@ -174,12 +175,14 @@ xfs_bulkstat_ichunk_ra(
174 agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino); 175 agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino);
175 176
176 blk_start_plug(&plug); 177 blk_start_plug(&plug);
177 for (i = 0; i < XFS_INODES_PER_CHUNK; 178 for (i = 0;
178 i += mp->m_inodes_per_cluster, agbno += mp->m_blocks_per_cluster) { 179 i < XFS_INODES_PER_CHUNK;
179 if (xfs_inobt_maskn(i, mp->m_inodes_per_cluster) & 180 i += igeo->inodes_per_cluster,
181 agbno += igeo->blocks_per_cluster) {
182 if (xfs_inobt_maskn(i, igeo->inodes_per_cluster) &
180 ~irec->ir_free) { 183 ~irec->ir_free) {
181 xfs_btree_reada_bufs(mp, agno, agbno, 184 xfs_btree_reada_bufs(mp, agno, agbno,
182 mp->m_blocks_per_cluster, 185 igeo->blocks_per_cluster,
183 &xfs_inode_buf_ops); 186 &xfs_inode_buf_ops);
184 } 187 }
185 } 188 }
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c
index 9329f5adbfbe..1557304f3d68 100644
--- a/fs/xfs/xfs_log_recover.c
+++ b/fs/xfs/xfs_log_recover.c
@@ -2882,19 +2882,19 @@ xlog_recover_buffer_pass2(
2882 * 2882 *
2883 * Also make sure that only inode buffers with good sizes stay in 2883 * Also make sure that only inode buffers with good sizes stay in
2884 * the buffer cache. The kernel moves inodes in buffers of 1 block 2884 * the buffer cache. The kernel moves inodes in buffers of 1 block
2885 * or mp->m_inode_cluster_size bytes, whichever is bigger. The inode 2885 * or inode_cluster_size bytes, whichever is bigger. The inode
2886 * buffers in the log can be a different size if the log was generated 2886 * buffers in the log can be a different size if the log was generated
2887 * by an older kernel using unclustered inode buffers or a newer kernel 2887 * by an older kernel using unclustered inode buffers or a newer kernel
2888 * running with a different inode cluster size. Regardless, if the 2888 * running with a different inode cluster size. Regardless, if the
2889 * the inode buffer size isn't max(blocksize, mp->m_inode_cluster_size) 2889 * the inode buffer size isn't max(blocksize, inode_cluster_size)
2890 * for *our* value of mp->m_inode_cluster_size, then we need to keep 2890 * for *our* value of inode_cluster_size, then we need to keep
2891 * the buffer out of the buffer cache so that the buffer won't 2891 * the buffer out of the buffer cache so that the buffer won't
2892 * overlap with future reads of those inodes. 2892 * overlap with future reads of those inodes.
2893 */ 2893 */
2894 if (XFS_DINODE_MAGIC == 2894 if (XFS_DINODE_MAGIC ==
2895 be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) && 2895 be16_to_cpu(*((__be16 *)xfs_buf_offset(bp, 0))) &&
2896 (BBTOB(bp->b_io_length) != max(log->l_mp->m_sb.sb_blocksize, 2896 (BBTOB(bp->b_io_length) != max(log->l_mp->m_sb.sb_blocksize,
2897 (uint32_t)log->l_mp->m_inode_cluster_size))) { 2897 M_IGEO(log->l_mp)->inode_cluster_size))) {
2898 xfs_buf_stale(bp); 2898 xfs_buf_stale(bp);
2899 error = xfs_bwrite(bp); 2899 error = xfs_bwrite(bp);
2900 } else { 2900 } else {
@@ -3849,6 +3849,7 @@ xlog_recover_do_icreate_pass2(
3849{ 3849{
3850 struct xfs_mount *mp = log->l_mp; 3850 struct xfs_mount *mp = log->l_mp;
3851 struct xfs_icreate_log *icl; 3851 struct xfs_icreate_log *icl;
3852 struct xfs_ino_geometry *igeo = M_IGEO(mp);
3852 xfs_agnumber_t agno; 3853 xfs_agnumber_t agno;
3853 xfs_agblock_t agbno; 3854 xfs_agblock_t agbno;
3854 unsigned int count; 3855 unsigned int count;
@@ -3898,10 +3899,10 @@ xlog_recover_do_icreate_pass2(
3898 3899
3899 /* 3900 /*
3900 * The inode chunk is either full or sparse and we only support 3901 * The inode chunk is either full or sparse and we only support
3901 * m_ialloc_min_blks sized sparse allocations at this time. 3902 * m_ino_geo.ialloc_min_blks sized sparse allocations at this time.
3902 */ 3903 */
3903 if (length != mp->m_ialloc_blks && 3904 if (length != igeo->ialloc_blks &&
3904 length != mp->m_ialloc_min_blks) { 3905 length != igeo->ialloc_min_blks) {
3905 xfs_warn(log->l_mp, 3906 xfs_warn(log->l_mp,
3906 "%s: unsupported chunk length", __FUNCTION__); 3907 "%s: unsupported chunk length", __FUNCTION__);
3907 return -EINVAL; 3908 return -EINVAL;
@@ -3921,13 +3922,13 @@ xlog_recover_do_icreate_pass2(
3921 * buffers for cancellation so we don't overwrite anything written after 3922 * buffers for cancellation so we don't overwrite anything written after
3922 * a cancellation. 3923 * a cancellation.
3923 */ 3924 */
3924 bb_per_cluster = XFS_FSB_TO_BB(mp, mp->m_blocks_per_cluster); 3925 bb_per_cluster = XFS_FSB_TO_BB(mp, igeo->blocks_per_cluster);
3925 nbufs = length / mp->m_blocks_per_cluster; 3926 nbufs = length / igeo->blocks_per_cluster;
3926 for (i = 0, cancel_count = 0; i < nbufs; i++) { 3927 for (i = 0, cancel_count = 0; i < nbufs; i++) {
3927 xfs_daddr_t daddr; 3928 xfs_daddr_t daddr;
3928 3929
3929 daddr = XFS_AGB_TO_DADDR(mp, agno, 3930 daddr = XFS_AGB_TO_DADDR(mp, agno,
3930 agbno + i * mp->m_blocks_per_cluster); 3931 agbno + i * igeo->blocks_per_cluster);
3931 if (xlog_check_buffer_cancelled(log, daddr, bb_per_cluster, 0)) 3932 if (xlog_check_buffer_cancelled(log, daddr, bb_per_cluster, 0))
3932 cancel_count++; 3933 cancel_count++;
3933 } 3934 }
diff --git a/fs/xfs/xfs_mount.c b/fs/xfs/xfs_mount.c
index 6b2bfe81dc51..73e5cfc4d0ec 100644
--- a/fs/xfs/xfs_mount.c
+++ b/fs/xfs/xfs_mount.c
@@ -433,10 +433,12 @@ xfs_update_alignment(xfs_mount_t *mp)
433 * Set the maximum inode count for this filesystem 433 * Set the maximum inode count for this filesystem
434 */ 434 */
435STATIC void 435STATIC void
436xfs_set_maxicount(xfs_mount_t *mp) 436xfs_set_maxicount(
437 struct xfs_mount *mp)
437{ 438{
438 xfs_sb_t *sbp = &(mp->m_sb); 439 struct xfs_sb *sbp = &(mp->m_sb);
439 uint64_t icount; 440 struct xfs_ino_geometry *igeo = M_IGEO(mp);
441 uint64_t icount;
440 442
441 if (sbp->sb_imax_pct) { 443 if (sbp->sb_imax_pct) {
442 /* 444 /*
@@ -445,11 +447,11 @@ xfs_set_maxicount(xfs_mount_t *mp)
445 */ 447 */
446 icount = sbp->sb_dblocks * sbp->sb_imax_pct; 448 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
447 do_div(icount, 100); 449 do_div(icount, 100);
448 do_div(icount, mp->m_ialloc_blks); 450 do_div(icount, igeo->ialloc_blks);
449 mp->m_maxicount = (icount * mp->m_ialloc_blks) << 451 igeo->maxicount = XFS_FSB_TO_INO(mp,
450 sbp->sb_inopblog; 452 icount * igeo->ialloc_blks);
451 } else { 453 } else {
452 mp->m_maxicount = 0; 454 igeo->maxicount = 0;
453 } 455 }
454} 456}
455 457
@@ -518,18 +520,18 @@ xfs_set_inoalignment(xfs_mount_t *mp)
518{ 520{
519 if (xfs_sb_version_hasalign(&mp->m_sb) && 521 if (xfs_sb_version_hasalign(&mp->m_sb) &&
520 mp->m_sb.sb_inoalignmt >= xfs_icluster_size_fsb(mp)) 522 mp->m_sb.sb_inoalignmt >= xfs_icluster_size_fsb(mp))
521 mp->m_inoalign_mask = mp->m_sb.sb_inoalignmt - 1; 523 M_IGEO(mp)->inoalign_mask = mp->m_sb.sb_inoalignmt - 1;
522 else 524 else
523 mp->m_inoalign_mask = 0; 525 M_IGEO(mp)->inoalign_mask = 0;
524 /* 526 /*
525 * If we are using stripe alignment, check whether 527 * If we are using stripe alignment, check whether
526 * the stripe unit is a multiple of the inode alignment 528 * the stripe unit is a multiple of the inode alignment
527 */ 529 */
528 if (mp->m_dalign && mp->m_inoalign_mask && 530 if (mp->m_dalign && M_IGEO(mp)->inoalign_mask &&
529 !(mp->m_dalign & mp->m_inoalign_mask)) 531 !(mp->m_dalign & M_IGEO(mp)->inoalign_mask))
530 mp->m_sinoalign = mp->m_dalign; 532 M_IGEO(mp)->ialloc_align = mp->m_dalign;
531 else 533 else
532 mp->m_sinoalign = 0; 534 M_IGEO(mp)->ialloc_align = 0;
533} 535}
534 536
535/* 537/*
@@ -683,6 +685,7 @@ xfs_mountfs(
683{ 685{
684 struct xfs_sb *sbp = &(mp->m_sb); 686 struct xfs_sb *sbp = &(mp->m_sb);
685 struct xfs_inode *rip; 687 struct xfs_inode *rip;
688 struct xfs_ino_geometry *igeo = M_IGEO(mp);
686 uint64_t resblks; 689 uint64_t resblks;
687 uint quotamount = 0; 690 uint quotamount = 0;
688 uint quotaflags = 0; 691 uint quotaflags = 0;
@@ -797,18 +800,20 @@ xfs_mountfs(
797 * has set the inode alignment value appropriately for larger cluster 800 * has set the inode alignment value appropriately for larger cluster
798 * sizes. 801 * sizes.
799 */ 802 */
800 mp->m_inode_cluster_size = XFS_INODE_BIG_CLUSTER_SIZE; 803 igeo->inode_cluster_size = XFS_INODE_BIG_CLUSTER_SIZE;
801 if (xfs_sb_version_hascrc(&mp->m_sb)) { 804 if (xfs_sb_version_hascrc(&mp->m_sb)) {
802 int new_size = mp->m_inode_cluster_size; 805 int new_size = igeo->inode_cluster_size;
803 806
804 new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE; 807 new_size *= mp->m_sb.sb_inodesize / XFS_DINODE_MIN_SIZE;
805 if (mp->m_sb.sb_inoalignmt >= XFS_B_TO_FSBT(mp, new_size)) 808 if (mp->m_sb.sb_inoalignmt >= XFS_B_TO_FSBT(mp, new_size))
806 mp->m_inode_cluster_size = new_size; 809 igeo->inode_cluster_size = new_size;
807 } 810 }
808 mp->m_blocks_per_cluster = xfs_icluster_size_fsb(mp); 811 igeo->blocks_per_cluster = xfs_icluster_size_fsb(mp);
809 mp->m_inodes_per_cluster = XFS_FSB_TO_INO(mp, mp->m_blocks_per_cluster); 812 igeo->inodes_per_cluster = XFS_FSB_TO_INO(mp,
810 mp->m_cluster_align = xfs_ialloc_cluster_alignment(mp); 813 igeo->blocks_per_cluster);
811 mp->m_cluster_align_inodes = XFS_FSB_TO_INO(mp, mp->m_cluster_align); 814 igeo->cluster_align = xfs_ialloc_cluster_alignment(mp);
815 igeo->cluster_align_inodes = XFS_FSB_TO_INO(mp,
816 igeo->cluster_align);
812 817
813 /* 818 /*
814 * If enabled, sparse inode chunk alignment is expected to match the 819 * If enabled, sparse inode chunk alignment is expected to match the
@@ -817,11 +822,11 @@ xfs_mountfs(
817 */ 822 */
818 if (xfs_sb_version_hassparseinodes(&mp->m_sb) && 823 if (xfs_sb_version_hassparseinodes(&mp->m_sb) &&
819 mp->m_sb.sb_spino_align != 824 mp->m_sb.sb_spino_align !=
820 XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)) { 825 XFS_B_TO_FSBT(mp, igeo->inode_cluster_size)) {
821 xfs_warn(mp, 826 xfs_warn(mp,
822 "Sparse inode block alignment (%u) must match cluster size (%llu).", 827 "Sparse inode block alignment (%u) must match cluster size (%llu).",
823 mp->m_sb.sb_spino_align, 828 mp->m_sb.sb_spino_align,
824 XFS_B_TO_FSBT(mp, mp->m_inode_cluster_size)); 829 XFS_B_TO_FSBT(mp, igeo->inode_cluster_size));
825 error = -EINVAL; 830 error = -EINVAL;
826 goto out_remove_uuid; 831 goto out_remove_uuid;
827 } 832 }
diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
index c81a5cd7c228..181a9848df20 100644
--- a/fs/xfs/xfs_mount.h
+++ b/fs/xfs/xfs_mount.h
@@ -105,6 +105,7 @@ typedef struct xfs_mount {
105 struct xfs_da_geometry *m_dir_geo; /* directory block geometry */ 105 struct xfs_da_geometry *m_dir_geo; /* directory block geometry */
106 struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */ 106 struct xfs_da_geometry *m_attr_geo; /* attribute block geometry */
107 struct xlog *m_log; /* log specific stuff */ 107 struct xlog *m_log; /* log specific stuff */
108 struct xfs_ino_geometry m_ino_geo; /* inode geometry */
108 int m_logbufs; /* number of log buffers */ 109 int m_logbufs; /* number of log buffers */
109 int m_logbsize; /* size of each log buffer */ 110 int m_logbsize; /* size of each log buffer */
110 uint m_rsumlevels; /* rt summary levels */ 111 uint m_rsumlevels; /* rt summary levels */
@@ -126,12 +127,6 @@ typedef struct xfs_mount {
126 uint8_t m_blkbit_log; /* blocklog + NBBY */ 127 uint8_t m_blkbit_log; /* blocklog + NBBY */
127 uint8_t m_blkbb_log; /* blocklog - BBSHIFT */ 128 uint8_t m_blkbb_log; /* blocklog - BBSHIFT */
128 uint8_t m_agno_log; /* log #ag's */ 129 uint8_t m_agno_log; /* log #ag's */
129 uint8_t m_agino_log; /* #bits for agino in inum */
130 uint m_inode_cluster_size;/* min inode buf size */
131 unsigned int m_inodes_per_cluster;
132 unsigned int m_blocks_per_cluster;
133 unsigned int m_cluster_align;
134 unsigned int m_cluster_align_inodes;
135 uint m_blockmask; /* sb_blocksize-1 */ 130 uint m_blockmask; /* sb_blocksize-1 */
136 uint m_blockwsize; /* sb_blocksize in words */ 131 uint m_blockwsize; /* sb_blocksize in words */
137 uint m_blockwmask; /* blockwsize-1 */ 132 uint m_blockwmask; /* blockwsize-1 */
@@ -139,15 +134,12 @@ typedef struct xfs_mount {
139 uint m_alloc_mnr[2]; /* min alloc btree records */ 134 uint m_alloc_mnr[2]; /* min alloc btree records */
140 uint m_bmap_dmxr[2]; /* max bmap btree records */ 135 uint m_bmap_dmxr[2]; /* max bmap btree records */
141 uint m_bmap_dmnr[2]; /* min bmap btree records */ 136 uint m_bmap_dmnr[2]; /* min bmap btree records */
142 uint m_inobt_mxr[2]; /* max inobt btree records */
143 uint m_inobt_mnr[2]; /* min inobt btree records */
144 uint m_rmap_mxr[2]; /* max rmap btree records */ 137 uint m_rmap_mxr[2]; /* max rmap btree records */
145 uint m_rmap_mnr[2]; /* min rmap btree records */ 138 uint m_rmap_mnr[2]; /* min rmap btree records */
146 uint m_refc_mxr[2]; /* max refc btree records */ 139 uint m_refc_mxr[2]; /* max refc btree records */
147 uint m_refc_mnr[2]; /* min refc btree records */ 140 uint m_refc_mnr[2]; /* min refc btree records */
148 uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */ 141 uint m_ag_maxlevels; /* XFS_AG_MAXLEVELS */
149 uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */ 142 uint m_bm_maxlevels[2]; /* XFS_BM_MAXLEVELS */
150 uint m_in_maxlevels; /* max inobt btree levels. */
151 uint m_rmap_maxlevels; /* max rmap btree levels */ 143 uint m_rmap_maxlevels; /* max rmap btree levels */
152 uint m_refc_maxlevels; /* max refcount btree level */ 144 uint m_refc_maxlevels; /* max refcount btree level */
153 xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */ 145 xfs_extlen_t m_ag_prealloc_blocks; /* reserved ag blocks */
@@ -159,20 +151,13 @@ typedef struct xfs_mount {
159 int m_fixedfsid[2]; /* unchanged for life of FS */ 151 int m_fixedfsid[2]; /* unchanged for life of FS */
160 uint64_t m_flags; /* global mount flags */ 152 uint64_t m_flags; /* global mount flags */
161 bool m_finobt_nores; /* no per-AG finobt resv. */ 153 bool m_finobt_nores; /* no per-AG finobt resv. */
162 int m_ialloc_inos; /* inodes in inode allocation */
163 int m_ialloc_blks; /* blocks in inode allocation */
164 int m_ialloc_min_blks;/* min blocks in sparse inode
165 * allocation */
166 int m_inoalign_mask;/* mask sb_inoalignmt if used */
167 uint m_qflags; /* quota status flags */ 154 uint m_qflags; /* quota status flags */
168 struct xfs_trans_resv m_resv; /* precomputed res values */ 155 struct xfs_trans_resv m_resv; /* precomputed res values */
169 uint64_t m_maxicount; /* maximum inode count */
170 uint64_t m_resblks; /* total reserved blocks */ 156 uint64_t m_resblks; /* total reserved blocks */
171 uint64_t m_resblks_avail;/* available reserved blocks */ 157 uint64_t m_resblks_avail;/* available reserved blocks */
172 uint64_t m_resblks_save; /* reserved blks @ remount,ro */ 158 uint64_t m_resblks_save; /* reserved blks @ remount,ro */
173 int m_dalign; /* stripe unit */ 159 int m_dalign; /* stripe unit */
174 int m_swidth; /* stripe width */ 160 int m_swidth; /* stripe width */
175 int m_sinoalign; /* stripe unit inode alignment */
176 uint8_t m_sectbb_log; /* sectlog - BBSHIFT */ 161 uint8_t m_sectbb_log; /* sectlog - BBSHIFT */
177 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */ 162 const struct xfs_nameops *m_dirnameops; /* vector of dir name ops */
178 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */ 163 const struct xfs_dir_ops *m_dir_inode_ops; /* vector of dir inode ops */
@@ -226,6 +211,8 @@ typedef struct xfs_mount {
226#endif 211#endif
227} xfs_mount_t; 212} xfs_mount_t;
228 213
214#define M_IGEO(mp) (&(mp)->m_ino_geo)
215
229/* 216/*
230 * Flags for m_flags. 217 * Flags for m_flags.
231 */ 218 */
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index a14d11d78bd8..594c119824cc 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -582,7 +582,7 @@ xfs_set_inode_alloc(
582 * Calculate how much should be reserved for inodes to meet 582 * Calculate how much should be reserved for inodes to meet
583 * the max inode percentage. Used only for inode32. 583 * the max inode percentage. Used only for inode32.
584 */ 584 */
585 if (mp->m_maxicount) { 585 if (M_IGEO(mp)->maxicount) {
586 uint64_t icount; 586 uint64_t icount;
587 587
588 icount = sbp->sb_dblocks * sbp->sb_imax_pct; 588 icount = sbp->sb_dblocks * sbp->sb_imax_pct;
@@ -1131,10 +1131,10 @@ xfs_fs_statfs(
1131 1131
1132 fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree); 1132 fakeinos = XFS_FSB_TO_INO(mp, statp->f_bfree);
1133 statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER); 1133 statp->f_files = min(icount + fakeinos, (uint64_t)XFS_MAXINUMBER);
1134 if (mp->m_maxicount) 1134 if (M_IGEO(mp)->maxicount)
1135 statp->f_files = min_t(typeof(statp->f_files), 1135 statp->f_files = min_t(typeof(statp->f_files),
1136 statp->f_files, 1136 statp->f_files,
1137 mp->m_maxicount); 1137 M_IGEO(mp)->maxicount);
1138 1138
1139 /* If sb_icount overshot maxicount, report actual allocation */ 1139 /* If sb_icount overshot maxicount, report actual allocation */
1140 statp->f_files = max_t(typeof(statp->f_files), 1140 statp->f_files = max_t(typeof(statp->f_files),