aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_ialloc.c
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:46:24 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:47:16 -0500
commit43004b2a8da2652b5ec526269a8acfba7d3d219c (patch)
tree197c76e61334c576f18530dd05a86958aac4101e /fs/xfs/libxfs/xfs_ialloc.c
parent7280fedaf3a0f9097c0621c7d5b35849954d7f54 (diff)
xfs: add a block to inode count converter
Add new helpers to convert units of fs blocks into inodes, and AG blocks into AG inodes, respectively. Convert all the open-coded conversions and XFS_OFFBNO_TO_AGINO(, , 0) calls to use them, as appropriate. The OFFBNO_TO_AGINO macro is retained for xfs_repair. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reviewed-by: Brian Foster <bfoster@redhat.com>
Diffstat (limited to 'fs/xfs/libxfs/xfs_ialloc.c')
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c17
1 files changed, 8 insertions, 9 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index fcf0d17405d8..3ac4a836428d 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -300,7 +300,7 @@ xfs_ialloc_inode_init(
300 * blocks size. 300 * blocks size.
301 */ 301 */
302 blks_per_cluster = xfs_icluster_size_fsb(mp); 302 blks_per_cluster = xfs_icluster_size_fsb(mp);
303 inodes_per_cluster = blks_per_cluster << mp->m_sb.sb_inopblog; 303 inodes_per_cluster = XFS_FSB_TO_INO(mp, blks_per_cluster);
304 nbufs = length / blks_per_cluster; 304 nbufs = length / blks_per_cluster;
305 305
306 /* 306 /*
@@ -312,7 +312,7 @@ xfs_ialloc_inode_init(
312 * 312 *
313 * For v3 inodes, we also need to write the inode number into the inode, 313 * For v3 inodes, we also need to write the inode number into the inode,
314 * so calculate the first inode number of the chunk here as 314 * so calculate the first inode number of the chunk here as
315 * XFS_OFFBNO_TO_AGINO() only works within a filesystem block, not 315 * XFS_AGB_TO_AGINO() only works within a filesystem block, not
316 * across multiple filesystem blocks (such as a cluster) and so cannot 316 * across multiple filesystem blocks (such as a cluster) and so cannot
317 * be used in the cluster buffer loop below. 317 * be used in the cluster buffer loop below.
318 * 318 *
@@ -324,8 +324,7 @@ xfs_ialloc_inode_init(
324 */ 324 */
325 if (xfs_sb_version_hascrc(&mp->m_sb)) { 325 if (xfs_sb_version_hascrc(&mp->m_sb)) {
326 version = 3; 326 version = 3;
327 ino = XFS_AGINO_TO_INO(mp, agno, 327 ino = XFS_AGINO_TO_INO(mp, agno, XFS_AGB_TO_AGINO(mp, agbno));
328 XFS_OFFBNO_TO_AGINO(mp, agbno, 0));
329 328
330 /* 329 /*
331 * log the initialisation that is about to take place as an 330 * log the initialisation that is about to take place as an
@@ -445,7 +444,7 @@ xfs_align_sparse_ino(
445 return; 444 return;
446 445
447 /* calculate the inode offset and align startino */ 446 /* calculate the inode offset and align startino */
448 offset = mod << mp->m_sb.sb_inopblog; 447 offset = XFS_AGB_TO_AGINO(mp, mod);
449 *startino -= offset; 448 *startino -= offset;
450 449
451 /* 450 /*
@@ -797,7 +796,7 @@ sparse_alloc:
797 if (error) 796 if (error)
798 return error; 797 return error;
799 798
800 newlen = args.len << args.mp->m_sb.sb_inopblog; 799 newlen = XFS_AGB_TO_AGINO(args.mp, args.len);
801 ASSERT(newlen <= XFS_INODES_PER_CHUNK); 800 ASSERT(newlen <= XFS_INODES_PER_CHUNK);
802 allocmask = (1 << (newlen / XFS_INODES_PER_HOLEMASK_BIT)) - 1; 801 allocmask = (1 << (newlen / XFS_INODES_PER_HOLEMASK_BIT)) - 1;
803 } 802 }
@@ -825,7 +824,7 @@ sparse_alloc:
825 /* 824 /*
826 * Convert the results. 825 * Convert the results.
827 */ 826 */
828 newino = XFS_OFFBNO_TO_AGINO(args.mp, args.agbno, 0); 827 newino = XFS_AGB_TO_AGINO(args.mp, args.agbno);
829 828
830 if (xfs_inobt_issparse(~allocmask)) { 829 if (xfs_inobt_issparse(~allocmask)) {
831 /* 830 /*
@@ -2724,8 +2723,8 @@ xfs_ialloc_has_inodes_at_extent(
2724 xfs_agino_t low; 2723 xfs_agino_t low;
2725 xfs_agino_t high; 2724 xfs_agino_t high;
2726 2725
2727 low = XFS_OFFBNO_TO_AGINO(cur->bc_mp, bno, 0); 2726 low = XFS_AGB_TO_AGINO(cur->bc_mp, bno);
2728 high = XFS_OFFBNO_TO_AGINO(cur->bc_mp, bno + len, 0) - 1; 2727 high = XFS_AGB_TO_AGINO(cur->bc_mp, bno + len) - 1;
2729 2728
2730 return xfs_ialloc_has_inode_record(cur, low, high, exists); 2729 return xfs_ialloc_has_inode_record(cur, low, high, exists);
2731} 2730}