aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:46:25 -0500
committerDarrick J. Wong <darrick.wong@oracle.com>2018-12-12 11:47:17 -0500
commit83dcdb4469e759f984db92616d7885fc14329841 (patch)
treee0bafc6d2181267d8794b398eadd9a8fa840d0fd /fs/xfs/libxfs
parent43004b2a8da2652b5ec526269a8acfba7d3d219c (diff)
xfs: precalculate inodes and blocks per inode cluster
Store the number of inodes and blocks per inode cluster 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>
Diffstat (limited to 'fs/xfs/libxfs')
-rw-r--r--fs/xfs/libxfs/xfs_ialloc.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/fs/xfs/libxfs/xfs_ialloc.c b/fs/xfs/libxfs/xfs_ialloc.c
index 3ac4a836428d..c7b2579a8e73 100644
--- a/fs/xfs/libxfs/xfs_ialloc.c
+++ b/fs/xfs/libxfs/xfs_ialloc.c
@@ -288,7 +288,7 @@ xfs_ialloc_inode_init(
288{ 288{
289 struct xfs_buf *fbuf; 289 struct xfs_buf *fbuf;
290 struct xfs_dinode *free; 290 struct xfs_dinode *free;
291 int nbufs, blks_per_cluster, inodes_per_cluster; 291 int nbufs;
292 int version; 292 int version;
293 int i, j; 293 int i, j;
294 xfs_daddr_t d; 294 xfs_daddr_t d;
@@ -299,9 +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 blks_per_cluster = xfs_icluster_size_fsb(mp); 302 nbufs = length / mp->m_blocks_per_cluster;
303 inodes_per_cluster = XFS_FSB_TO_INO(mp, blks_per_cluster);
304 nbufs = length / blks_per_cluster;
305 303
306 /* 304 /*
307 * 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
@@ -344,9 +342,10 @@ xfs_ialloc_inode_init(
344 /* 342 /*
345 * Get the block. 343 * Get the block.
346 */ 344 */
347 d = XFS_AGB_TO_DADDR(mp, agno, agbno + (j * blks_per_cluster)); 345 d = XFS_AGB_TO_DADDR(mp, agno, agbno +
346 (j * mp->m_blocks_per_cluster));
348 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d, 347 fbuf = xfs_trans_get_buf(tp, mp->m_ddev_targp, d,
349 mp->m_bsize * blks_per_cluster, 348 mp->m_bsize * mp->m_blocks_per_cluster,
350 XBF_UNMAPPED); 349 XBF_UNMAPPED);
351 if (!fbuf) 350 if (!fbuf)
352 return -ENOMEM; 351 return -ENOMEM;
@@ -354,7 +353,7 @@ xfs_ialloc_inode_init(
354 /* Initialize the inode buffers and log them appropriately. */ 353 /* Initialize the inode buffers and log them appropriately. */
355 fbuf->b_ops = &xfs_inode_buf_ops; 354 fbuf->b_ops = &xfs_inode_buf_ops;
356 xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length)); 355 xfs_buf_zero(fbuf, 0, BBTOB(fbuf->b_length));
357 for (i = 0; i < inodes_per_cluster; i++) { 356 for (i = 0; i < mp->m_inodes_per_cluster; i++) {
358 int ioffset = i << mp->m_sb.sb_inodelog; 357 int ioffset = i << mp->m_sb.sb_inodelog;
359 uint isize = xfs_dinode_size(version); 358 uint isize = xfs_dinode_size(version);
360 359
@@ -2289,7 +2288,6 @@ xfs_imap(
2289 xfs_agblock_t agbno; /* block number of inode in the alloc group */ 2288 xfs_agblock_t agbno; /* block number of inode in the alloc group */
2290 xfs_agino_t agino; /* inode number within alloc group */ 2289 xfs_agino_t agino; /* inode number within alloc group */
2291 xfs_agnumber_t agno; /* allocation group number */ 2290 xfs_agnumber_t agno; /* allocation group number */
2292 int blks_per_cluster; /* num blocks per inode cluster */
2293 xfs_agblock_t chunk_agbno; /* first block in inode chunk */ 2291 xfs_agblock_t chunk_agbno; /* first block in inode chunk */
2294 xfs_agblock_t cluster_agbno; /* first block in inode cluster */ 2292 xfs_agblock_t cluster_agbno; /* first block in inode cluster */
2295 int error; /* error code */ 2293 int error; /* error code */
@@ -2335,8 +2333,6 @@ xfs_imap(
2335 return -EINVAL; 2333 return -EINVAL;
2336 } 2334 }
2337 2335
2338 blks_per_cluster = xfs_icluster_size_fsb(mp);
2339
2340 /* 2336 /*
2341 * For bulkstat and handle lookups, we have an untrusted inode number 2337 * For bulkstat and handle lookups, we have an untrusted inode number
2342 * that we have to verify is valid. We cannot do this just by reading 2338 * that we have to verify is valid. We cannot do this just by reading
@@ -2356,7 +2352,7 @@ xfs_imap(
2356 * If the inode cluster size is the same as the blocksize or 2352 * If the inode cluster size is the same as the blocksize or
2357 * smaller we get to the buffer by simple arithmetics. 2353 * smaller we get to the buffer by simple arithmetics.
2358 */ 2354 */
2359 if (blks_per_cluster == 1) { 2355 if (mp->m_blocks_per_cluster == 1) {
2360 offset = XFS_INO_TO_OFFSET(mp, ino); 2356 offset = XFS_INO_TO_OFFSET(mp, ino);
2361 ASSERT(offset < mp->m_sb.sb_inopblock); 2357 ASSERT(offset < mp->m_sb.sb_inopblock);
2362 2358
@@ -2385,12 +2381,13 @@ xfs_imap(
2385out_map: 2381out_map:
2386 ASSERT(agbno >= chunk_agbno); 2382 ASSERT(agbno >= chunk_agbno);
2387 cluster_agbno = chunk_agbno + 2383 cluster_agbno = chunk_agbno +
2388 ((offset_agbno / blks_per_cluster) * blks_per_cluster); 2384 ((offset_agbno / mp->m_blocks_per_cluster) *
2385 mp->m_blocks_per_cluster);
2389 offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) + 2386 offset = ((agbno - cluster_agbno) * mp->m_sb.sb_inopblock) +
2390 XFS_INO_TO_OFFSET(mp, ino); 2387 XFS_INO_TO_OFFSET(mp, ino);
2391 2388
2392 imap->im_blkno = XFS_AGB_TO_DADDR(mp, agno, cluster_agbno); 2389 imap->im_blkno = XFS_AGB_TO_DADDR(mp, agno, cluster_agbno);
2393 imap->im_len = XFS_FSB_TO_BB(mp, blks_per_cluster); 2390 imap->im_len = XFS_FSB_TO_BB(mp, mp->m_blocks_per_cluster);
2394 imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog); 2391 imap->im_boffset = (unsigned short)(offset << mp->m_sb.sb_inodelog);
2395 2392
2396 /* 2393 /*