aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorBrian Foster <bfoster@redhat.com>2017-01-09 10:38:47 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-12 05:39:42 -0500
commit06ac11df915d5d607780b86fa7d98f1ab57dab16 (patch)
treede11754d66d3a44271d46a53ec3dcb881a1d2909 /fs
parent553937d3cce8d3806655771099928ab5525fa7e4 (diff)
xfs: pass post-eof speculative prealloc blocks to bmapi
commit f782088c9e5d08e9494c63e68b4e85716df3e5f8 upstream. xfs_file_iomap_begin_delay() implements post-eof speculative preallocation by extending the block count of the requested delayed allocation. Now that xfs_bmapi_reserve_delalloc() has been updated to handle prealloc blocks separately and tag the inode, update xfs_file_iomap_begin_delay() to use the new parameter and rely on the former to tag the inode. Note that this patch does not change behavior. Signed-off-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com> Cc: Christoph Hellwig <hch@lst.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r--fs/xfs/xfs_iomap.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index e4bfde212cc2..15a83813b708 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -536,10 +536,11 @@ xfs_file_iomap_begin_delay(
536 xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); 536 xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
537 xfs_fileoff_t maxbytes_fsb = 537 xfs_fileoff_t maxbytes_fsb =
538 XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes); 538 XFS_B_TO_FSB(mp, mp->m_super->s_maxbytes);
539 xfs_fileoff_t end_fsb, orig_end_fsb; 539 xfs_fileoff_t end_fsb;
540 int error = 0, eof = 0; 540 int error = 0, eof = 0;
541 struct xfs_bmbt_irec got; 541 struct xfs_bmbt_irec got;
542 xfs_extnum_t idx; 542 xfs_extnum_t idx;
543 xfs_fsblock_t prealloc_blocks = 0;
543 544
544 ASSERT(!XFS_IS_REALTIME_INODE(ip)); 545 ASSERT(!XFS_IS_REALTIME_INODE(ip));
545 ASSERT(!xfs_get_extsz_hint(ip)); 546 ASSERT(!xfs_get_extsz_hint(ip));
@@ -594,33 +595,32 @@ xfs_file_iomap_begin_delay(
594 * the lower level functions are updated. 595 * the lower level functions are updated.
595 */ 596 */
596 count = min_t(loff_t, count, 1024 * PAGE_SIZE); 597 count = min_t(loff_t, count, 1024 * PAGE_SIZE);
597 end_fsb = orig_end_fsb = 598 end_fsb = min(XFS_B_TO_FSB(mp, offset + count), maxbytes_fsb);
598 min(XFS_B_TO_FSB(mp, offset + count), maxbytes_fsb);
599 599
600 if (eof) { 600 if (eof) {
601 xfs_fsblock_t prealloc_blocks;
602
603 prealloc_blocks = xfs_iomap_prealloc_size(ip, offset, count, idx); 601 prealloc_blocks = xfs_iomap_prealloc_size(ip, offset, count, idx);
604 if (prealloc_blocks) { 602 if (prealloc_blocks) {
605 xfs_extlen_t align; 603 xfs_extlen_t align;
606 xfs_off_t end_offset; 604 xfs_off_t end_offset;
605 xfs_fileoff_t p_end_fsb;
607 606
608 end_offset = XFS_WRITEIO_ALIGN(mp, offset + count - 1); 607 end_offset = XFS_WRITEIO_ALIGN(mp, offset + count - 1);
609 end_fsb = XFS_B_TO_FSBT(mp, end_offset) + 608 p_end_fsb = XFS_B_TO_FSBT(mp, end_offset) +
610 prealloc_blocks; 609 prealloc_blocks;
611 610
612 align = xfs_eof_alignment(ip, 0); 611 align = xfs_eof_alignment(ip, 0);
613 if (align) 612 if (align)
614 end_fsb = roundup_64(end_fsb, align); 613 p_end_fsb = roundup_64(p_end_fsb, align);
615 614
616 end_fsb = min(end_fsb, maxbytes_fsb); 615 p_end_fsb = min(p_end_fsb, maxbytes_fsb);
617 ASSERT(end_fsb > offset_fsb); 616 ASSERT(p_end_fsb > offset_fsb);
617 prealloc_blocks = p_end_fsb - end_fsb;
618 } 618 }
619 } 619 }
620 620
621retry: 621retry:
622 error = xfs_bmapi_reserve_delalloc(ip, XFS_DATA_FORK, offset_fsb, 622 error = xfs_bmapi_reserve_delalloc(ip, XFS_DATA_FORK, offset_fsb,
623 end_fsb - offset_fsb, 0, &got, &idx, eof); 623 end_fsb - offset_fsb, prealloc_blocks, &got, &idx, eof);
624 switch (error) { 624 switch (error) {
625 case 0: 625 case 0:
626 break; 626 break;
@@ -628,8 +628,8 @@ retry:
628 case -EDQUOT: 628 case -EDQUOT:
629 /* retry without any preallocation */ 629 /* retry without any preallocation */
630 trace_xfs_delalloc_enospc(ip, offset, count); 630 trace_xfs_delalloc_enospc(ip, offset, count);
631 if (end_fsb != orig_end_fsb) { 631 if (prealloc_blocks) {
632 end_fsb = orig_end_fsb; 632 prealloc_blocks = 0;
633 goto retry; 633 goto retry;
634 } 634 }
635 /*FALLTHRU*/ 635 /*FALLTHRU*/
@@ -637,13 +637,6 @@ retry:
637 goto out_unlock; 637 goto out_unlock;
638 } 638 }
639 639
640 /*
641 * Tag the inode as speculatively preallocated so we can reclaim this
642 * space on demand, if necessary.
643 */
644 if (end_fsb != orig_end_fsb)
645 xfs_inode_set_eofblocks_tag(ip);
646
647 trace_xfs_iomap_alloc(ip, offset, count, 0, &got); 640 trace_xfs_iomap_alloc(ip, offset, count, 0, &got);
648done: 641done:
649 if (isnullstartblock(got.br_startblock)) 642 if (isnullstartblock(got.br_startblock))