]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: precalculate cluster alignment in inodes and blocks
authorDarrick J. Wong <darrick.wong@oracle.com>
Wed, 27 Feb 2019 23:13:45 +0000 (17:13 -0600)
committerEric Sandeen <sandeen@redhat.com>
Wed, 27 Feb 2019 23:13:45 +0000 (17:13 -0600)
Source kernel commit: c1b4a321ede083521b91c314e1c4fa233ac33740

Store the inode cluster alignment information in units of inodes and
blocks in the mount data so that we don't have to keep recalculating
them.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/xfs_mount.h
libxfs/init.c
libxfs/xfs_ialloc.c
libxfs/xfs_types.c

index 4948fa7024240d58e1cbe0e2dcf54eba4396c464..1d31f60bf242294484cd9f23b6f04a279353bfe6 100644 (file)
@@ -45,6 +45,8 @@ typedef struct xfs_mount {
        uint                    m_inode_cluster_size;/* min inode buf size */
        unsigned int            m_inodes_per_cluster;
        unsigned int            m_blocks_per_cluster;
+       unsigned int            m_cluster_align;
+       unsigned int            m_cluster_align_inodes;
        uint                    m_blockmask;    /* sb_blocksize-1 */
        uint                    m_blockwsize;   /* sb_blocksize in words */
        uint                    m_blockwmask;   /* blockwsize-1 */
index 3302fd00f62e24d211ca611242409dc64fb368cb..37bd28290253189ad51cf3b88271a27ae074aded 100644 (file)
@@ -678,6 +678,8 @@ libxfs_mount(
        }
        mp->m_blocks_per_cluster = xfs_icluster_size_fsb(mp);
        mp->m_inodes_per_cluster = XFS_FSB_TO_INO(mp, mp->m_blocks_per_cluster);
+       mp->m_cluster_align = xfs_ialloc_cluster_alignment(mp);
+       mp->m_cluster_align_inodes = XFS_FSB_TO_INO(mp, mp->m_cluster_align);
 
        /*
         * Set whether we're using stripe alignment.
index b7c93463bfcecc6127fcaefc81c71a86fae4de13..a600c038a2a4a895d40927b1c2339891ed14dc7e 100644 (file)
@@ -684,7 +684,7 @@ xfs_ialloc_ag_alloc(
                 * but not to use them in the actual exact allocation.
                 */
                args.alignment = 1;
-               args.minalignslop = xfs_ialloc_cluster_alignment(args.mp) - 1;
+               args.minalignslop = args.mp->m_cluster_align - 1;
 
                /* Allow space for the inode btree to split. */
                args.minleft = args.mp->m_in_maxlevels - 1;
@@ -719,7 +719,7 @@ xfs_ialloc_ag_alloc(
                        args.alignment = args.mp->m_dalign;
                        isaligned = 1;
                } else
-                       args.alignment = xfs_ialloc_cluster_alignment(args.mp);
+                       args.alignment = args.mp->m_cluster_align;
                /*
                 * Need to figure out where to allocate the inode blocks.
                 * Ideally they should be spaced out through the a.g.
@@ -748,7 +748,7 @@ xfs_ialloc_ag_alloc(
                args.type = XFS_ALLOCTYPE_NEAR_BNO;
                args.agbno = be32_to_cpu(agi->agi_root);
                args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
-               args.alignment = xfs_ialloc_cluster_alignment(args.mp);
+               args.alignment = args.mp->m_cluster_align;
                if ((error = xfs_alloc_vextent(&args)))
                        return error;
        }
@@ -1011,7 +1011,7 @@ xfs_ialloc_ag_select(
                 */
                ineed = mp->m_ialloc_min_blks;
                if (flags && ineed > 1)
-                       ineed += xfs_ialloc_cluster_alignment(mp);
+                       ineed += mp->m_cluster_align;
                longest = pag->pagf_longest;
                if (!longest)
                        longest = pag->pagf_flcount > 0;
index 2bfda2aa821d9417adf30c8809c01e2cc4b69773..852ca21c5d1dab245ad05b1353595d642cd80560 100644 (file)
@@ -87,15 +87,14 @@ xfs_agino_range(
         * Calculate the first inode, which will be in the first
         * cluster-aligned block after the AGFL.
         */
-       bno = round_up(XFS_AGFL_BLOCK(mp) + 1,
-                       xfs_ialloc_cluster_alignment(mp));
+       bno = round_up(XFS_AGFL_BLOCK(mp) + 1, mp->m_cluster_align);
        *first = XFS_AGB_TO_AGINO(mp, bno);
 
        /*
         * Calculate the last inode, which will be at the end of the
         * last (aligned) cluster that can be allocated in the AG.
         */
-       bno = round_down(eoag, xfs_ialloc_cluster_alignment(mp));
+       bno = round_down(eoag, mp->m_cluster_align);
        *last = XFS_AGB_TO_AGINO(mp, bno) - 1;
 }