Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>

+11 -8
+4 -4
fs/xfs/libxfs/xfs_ialloc.c
··· 690 690 * but not to use them in the actual exact allocation. 691 691 */ 692 692 args.alignment = 1; 693 - args.minalignslop = xfs_ialloc_cluster_alignment(args.mp) - 1; 693 + args.minalignslop = args.mp->m_cluster_align - 1; 694 694 695 695 /* Allow space for the inode btree to split. */ 696 696 args.minleft = args.mp->m_in_maxlevels - 1; ··· 725 725 args.alignment = args.mp->m_dalign; 726 726 isaligned = 1; 727 727 } else 728 - args.alignment = xfs_ialloc_cluster_alignment(args.mp); 728 + args.alignment = args.mp->m_cluster_align; 729 729 /* 730 730 * Need to figure out where to allocate the inode blocks. 731 731 * Ideally they should be spaced out through the a.g. ··· 754 754 args.type = XFS_ALLOCTYPE_NEAR_BNO; 755 755 args.agbno = be32_to_cpu(agi->agi_root); 756 756 args.fsbno = XFS_AGB_TO_FSB(args.mp, agno, args.agbno); 757 - args.alignment = xfs_ialloc_cluster_alignment(args.mp); 757 + args.alignment = args.mp->m_cluster_align; 758 758 if ((error = xfs_alloc_vextent(&args))) 759 759 return error; 760 760 } ··· 1017 1017 */ 1018 1018 ineed = mp->m_ialloc_min_blks; 1019 1019 if (flags && ineed > 1) 1020 - ineed += xfs_ialloc_cluster_alignment(mp); 1020 + ineed += mp->m_cluster_align; 1021 1021 longest = pag->pagf_longest; 1022 1022 if (!longest) 1023 1023 longest = pag->pagf_flcount > 0;
+2 -3
fs/xfs/libxfs/xfs_types.c
··· 87 87 * Calculate the first inode, which will be in the first 88 88 * cluster-aligned block after the AGFL. 89 89 */ 90 - bno = round_up(XFS_AGFL_BLOCK(mp) + 1, 91 - xfs_ialloc_cluster_alignment(mp)); 90 + bno = round_up(XFS_AGFL_BLOCK(mp) + 1, mp->m_cluster_align); 92 91 *first = XFS_AGB_TO_AGINO(mp, bno); 93 92 94 93 /* 95 94 * Calculate the last inode, which will be at the end of the 96 95 * last (aligned) cluster that can be allocated in the AG. 97 96 */ 98 - bno = round_down(eoag, xfs_ialloc_cluster_alignment(mp)); 97 + bno = round_down(eoag, mp->m_cluster_align); 99 98 *last = XFS_AGB_TO_AGINO(mp, bno) - 1; 100 99 } 101 100
+1 -1
fs/xfs/scrub/ialloc.c
··· 300 300 301 301 /* Make sure this record is aligned to cluster and inoalignmnt size. */ 302 302 agbno = XFS_AGINO_TO_AGBNO(mp, irec.ir_startino); 303 - if ((agbno & (xfs_ialloc_cluster_alignment(mp) - 1)) || 303 + if ((agbno & (mp->m_cluster_align - 1)) || 304 304 (agbno & (mp->m_blocks_per_cluster - 1))) 305 305 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); 306 306
+2
fs/xfs/xfs_mount.c
··· 800 800 } 801 801 mp->m_blocks_per_cluster = xfs_icluster_size_fsb(mp); 802 802 mp->m_inodes_per_cluster = XFS_FSB_TO_INO(mp, mp->m_blocks_per_cluster); 803 + mp->m_cluster_align = xfs_ialloc_cluster_alignment(mp); 804 + mp->m_cluster_align_inodes = XFS_FSB_TO_INO(mp, mp->m_cluster_align); 803 805 804 806 /* 805 807 * If enabled, sparse inode chunk alignment is expected to match the
+2
fs/xfs/xfs_mount.h
··· 103 103 uint m_inode_cluster_size;/* min inode buf size */ 104 104 unsigned int m_inodes_per_cluster; 105 105 unsigned int m_blocks_per_cluster; 106 + unsigned int m_cluster_align; 107 + unsigned int m_cluster_align_inodes; 106 108 uint m_blockmask; /* sb_blocksize-1 */ 107 109 uint m_blockwsize; /* sb_blocksize in words */ 108 110 uint m_blockwmask; /* blockwsize-1 */