aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/xfs_iomap.c
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2013-03-18 10:51:43 -0400
committerBen Myers <bpm@sgi.com>2013-03-22 17:04:23 -0400
commit3c58b5f809eda8ae8d891b7a87d0a235ab0f9bf5 (patch)
tree6bbaed0aafdbf44fb3fab25d51c0440d3c49fe9a /fs/xfs/xfs_iomap.c
parent56cea2d088811b8cf7d2893e29bcf369a912de69 (diff)
xfs: reorganize xfs_iomap_prealloc_size to remove indentation
The majority of xfs_iomap_prealloc_size() executes within the check for lack of default I/O size. Reverse the logic to remove the extra indentation. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Ben Myers <bpm@sgi.com> Reviewed-by: Mark Tinguely <tinguely@sgi.com> Signed-off-by: Ben Myers <bpm@sgi.com>
Diffstat (limited to 'fs/xfs/xfs_iomap.c')
-rw-r--r--fs/xfs/xfs_iomap.c63
1 files changed, 32 insertions, 31 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index c8cb337efccf..344557eef928 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -381,42 +381,43 @@ xfs_iomap_prealloc_size(
381 int nimaps) 381 int nimaps)
382{ 382{
383 xfs_fsblock_t alloc_blocks = 0; 383 xfs_fsblock_t alloc_blocks = 0;
384 int shift = 0;
385 int64_t freesp;
384 386
385 alloc_blocks = xfs_iomap_eof_prealloc_initial_size(mp, ip, offset, 387 alloc_blocks = xfs_iomap_eof_prealloc_initial_size(mp, ip, offset,
386 imap, nimaps); 388 imap, nimaps);
387 if (alloc_blocks > 0) { 389 if (!alloc_blocks)
388 int shift = 0; 390 goto check_writeio;
389 int64_t freesp; 391
390 392 alloc_blocks = XFS_FILEOFF_MIN(MAXEXTLEN,
391 alloc_blocks = XFS_FILEOFF_MIN(MAXEXTLEN, 393 rounddown_pow_of_two(alloc_blocks));
392 rounddown_pow_of_two(alloc_blocks)); 394
393 395 xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT);
394 xfs_icsb_sync_counters(mp, XFS_ICSB_LAZY_COUNT); 396 freesp = mp->m_sb.sb_fdblocks;
395 freesp = mp->m_sb.sb_fdblocks; 397 if (freesp < mp->m_low_space[XFS_LOWSP_5_PCNT]) {
396 if (freesp < mp->m_low_space[XFS_LOWSP_5_PCNT]) { 398 shift = 2;
397 shift = 2; 399 if (freesp < mp->m_low_space[XFS_LOWSP_4_PCNT])
398 if (freesp < mp->m_low_space[XFS_LOWSP_4_PCNT]) 400 shift++;
399 shift++; 401 if (freesp < mp->m_low_space[XFS_LOWSP_3_PCNT])
400 if (freesp < mp->m_low_space[XFS_LOWSP_3_PCNT]) 402 shift++;
401 shift++; 403 if (freesp < mp->m_low_space[XFS_LOWSP_2_PCNT])
402 if (freesp < mp->m_low_space[XFS_LOWSP_2_PCNT]) 404 shift++;
403 shift++; 405 if (freesp < mp->m_low_space[XFS_LOWSP_1_PCNT])
404 if (freesp < mp->m_low_space[XFS_LOWSP_1_PCNT]) 406 shift++;
405 shift++;
406 }
407 if (shift)
408 alloc_blocks >>= shift;
409
410 /*
411 * If we are still trying to allocate more space than is
412 * available, squash the prealloc hard. This can happen if we
413 * have a large file on a small filesystem and the above
414 * lowspace thresholds are smaller than MAXEXTLEN.
415 */
416 while (alloc_blocks && alloc_blocks >= freesp)
417 alloc_blocks >>= 4;
418 } 407 }
408 if (shift)
409 alloc_blocks >>= shift;
410
411 /*
412 * If we are still trying to allocate more space than is
413 * available, squash the prealloc hard. This can happen if we
414 * have a large file on a small filesystem and the above
415 * lowspace thresholds are smaller than MAXEXTLEN.
416 */
417 while (alloc_blocks && alloc_blocks >= freesp)
418 alloc_blocks >>= 4;
419 419
420check_writeio:
420 if (alloc_blocks < mp->m_writeio_blocks) 421 if (alloc_blocks < mp->m_writeio_blocks)
421 alloc_blocks = mp->m_writeio_blocks; 422 alloc_blocks = mp->m_writeio_blocks;
422 423