Commit c1b4a321 authored by Darrick J. Wong's avatar Darrick J. Wong
Browse files

xfs: precalculate cluster alignment in inodes and blocks



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: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
parent 83dcdb44
Loading
Loading
Loading
Loading
+4 −4
Original line number Original line Diff line number Diff line
@@ -690,7 +690,7 @@ xfs_ialloc_ag_alloc(
		 * but not to use them in the actual exact allocation.
		 * but not to use them in the actual exact allocation.
		 */
		 */
		args.alignment = 1;
		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. */
		/* Allow space for the inode btree to split. */
		args.minleft = args.mp->m_in_maxlevels - 1;
		args.minleft = args.mp->m_in_maxlevels - 1;
@@ -725,7 +725,7 @@ xfs_ialloc_ag_alloc(
			args.alignment = args.mp->m_dalign;
			args.alignment = args.mp->m_dalign;
			isaligned = 1;
			isaligned = 1;
		} else
		} 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.
		 * Need to figure out where to allocate the inode blocks.
		 * Ideally they should be spaced out through the a.g.
		 * Ideally they should be spaced out through the a.g.
@@ -754,7 +754,7 @@ xfs_ialloc_ag_alloc(
		args.type = XFS_ALLOCTYPE_NEAR_BNO;
		args.type = XFS_ALLOCTYPE_NEAR_BNO;
		args.agbno = be32_to_cpu(agi->agi_root);
		args.agbno = be32_to_cpu(agi->agi_root);
		args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno);
		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)))
		if ((error = xfs_alloc_vextent(&args)))
			return error;
			return error;
	}
	}
@@ -1017,7 +1017,7 @@ xfs_ialloc_ag_select(
		 */
		 */
		ineed = mp->m_ialloc_min_blks;
		ineed = mp->m_ialloc_min_blks;
		if (flags && ineed > 1)
		if (flags && ineed > 1)
			ineed += xfs_ialloc_cluster_alignment(mp);
			ineed += mp->m_cluster_align;
		longest = pag->pagf_longest;
		longest = pag->pagf_longest;
		if (!longest)
		if (!longest)
			longest = pag->pagf_flcount > 0;
			longest = pag->pagf_flcount > 0;
+2 −3
Original line number Original line Diff line number Diff line
@@ -87,15 +87,14 @@ xfs_agino_range(
	 * Calculate the first inode, which will be in the first
	 * Calculate the first inode, which will be in the first
	 * cluster-aligned block after the AGFL.
	 * cluster-aligned block after the AGFL.
	 */
	 */
	bno = round_up(XFS_AGFL_BLOCK(mp) + 1,
	bno = round_up(XFS_AGFL_BLOCK(mp) + 1, mp->m_cluster_align);
			xfs_ialloc_cluster_alignment(mp));
	*first = XFS_AGB_TO_AGINO(mp, bno);
	*first = XFS_AGB_TO_AGINO(mp, bno);


	/*
	/*
	 * Calculate the last inode, which will be at the end of the
	 * Calculate the last inode, which will be at the end of the
	 * last (aligned) cluster that can be allocated in the AG.
	 * 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;
	*last = XFS_AGB_TO_AGINO(mp, bno) - 1;
}
}


+1 −1
Original line number Original line Diff line number Diff line
@@ -300,7 +300,7 @@ xchk_iallocbt_rec(


	/* Make sure this record is aligned to cluster and inoalignmnt size. */
	/* Make sure this record is aligned to cluster and inoalignmnt size. */
	agbno = XFS_AGINO_TO_AGBNO(mp, irec.ir_startino);
	agbno = XFS_AGINO_TO_AGBNO(mp, irec.ir_startino);
	if ((agbno & (xfs_ialloc_cluster_alignment(mp) - 1)) ||
	if ((agbno & (mp->m_cluster_align - 1)) ||
	    (agbno & (mp->m_blocks_per_cluster - 1)))
	    (agbno & (mp->m_blocks_per_cluster - 1)))
		xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
		xchk_btree_set_corrupt(bs->sc, bs->cur, 0);


+2 −0
Original line number Original line Diff line number Diff line
@@ -800,6 +800,8 @@ xfs_mountfs(
	}
	}
	mp->m_blocks_per_cluster = xfs_icluster_size_fsb(mp);
	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_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);


	/*
	/*
	 * If enabled, sparse inode chunk alignment is expected to match the
	 * If enabled, sparse inode chunk alignment is expected to match the
+2 −0
Original line number Original line Diff line number Diff line
@@ -103,6 +103,8 @@ typedef struct xfs_mount {
	uint			m_inode_cluster_size;/* min inode buf size */
	uint			m_inode_cluster_size;/* min inode buf size */
	unsigned int		m_inodes_per_cluster;
	unsigned int		m_inodes_per_cluster;
	unsigned int		m_blocks_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_blockmask;	/* sb_blocksize-1 */
	uint			m_blockwsize;	/* sb_blocksize in words */
	uint			m_blockwsize;	/* sb_blocksize in words */
	uint			m_blockwmask;	/* blockwsize-1 */
	uint			m_blockwmask;	/* blockwsize-1 */