aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-01-09 10:38:46 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-01-12 05:39:41 -0500
commit553937d3cce8d3806655771099928ab5525fa7e4 (patch)
tree2b036764b4275eb52a6a867683ccc2e44dda7a8f /fs
parent3d6e3b12bb4eac5cadb4733530c1967fe9e3d6a9 (diff)
xfs: use new extent lookup helpers xfs_file_iomap_begin_delay
commit 656152e552e5cbe0c11ad261b524376217c2fb13 upstream. And only lookup the previous extent inside xfs_iomap_prealloc_size if we actually need it. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Brian Foster <bfoster@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.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/fs/xfs/xfs_iomap.c b/fs/xfs/xfs_iomap.c
index cc25892cfc63..e4bfde212cc2 100644
--- a/fs/xfs/xfs_iomap.c
+++ b/fs/xfs/xfs_iomap.c
@@ -395,11 +395,12 @@ xfs_iomap_prealloc_size(
395 struct xfs_inode *ip, 395 struct xfs_inode *ip,
396 loff_t offset, 396 loff_t offset,
397 loff_t count, 397 loff_t count,
398 xfs_extnum_t idx, 398 xfs_extnum_t idx)
399 struct xfs_bmbt_irec *prev)
400{ 399{
401 struct xfs_mount *mp = ip->i_mount; 400 struct xfs_mount *mp = ip->i_mount;
401 struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
402 xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); 402 xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
403 struct xfs_bmbt_irec prev;
403 int shift = 0; 404 int shift = 0;
404 int64_t freesp; 405 int64_t freesp;
405 xfs_fsblock_t qblocks; 406 xfs_fsblock_t qblocks;
@@ -419,8 +420,8 @@ xfs_iomap_prealloc_size(
419 */ 420 */
420 if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) || 421 if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ||
421 XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) || 422 XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) ||
422 idx == 0 || 423 !xfs_iext_get_extent(ifp, idx - 1, &prev) ||
423 prev->br_startoff + prev->br_blockcount < offset_fsb) 424 prev.br_startoff + prev.br_blockcount < offset_fsb)
424 return mp->m_writeio_blocks; 425 return mp->m_writeio_blocks;
425 426
426 /* 427 /*
@@ -439,8 +440,8 @@ xfs_iomap_prealloc_size(
439 * always extends to MAXEXTLEN rather than falling short due to things 440 * always extends to MAXEXTLEN rather than falling short due to things
440 * like stripe unit/width alignment of real extents. 441 * like stripe unit/width alignment of real extents.
441 */ 442 */
442 if (prev->br_blockcount <= (MAXEXTLEN >> 1)) 443 if (prev.br_blockcount <= (MAXEXTLEN >> 1))
443 alloc_blocks = prev->br_blockcount << 1; 444 alloc_blocks = prev.br_blockcount << 1;
444 else 445 else
445 alloc_blocks = XFS_B_TO_FSB(mp, offset); 446 alloc_blocks = XFS_B_TO_FSB(mp, offset);
446 if (!alloc_blocks) 447 if (!alloc_blocks)
@@ -538,7 +539,6 @@ xfs_file_iomap_begin_delay(
538 xfs_fileoff_t end_fsb, orig_end_fsb; 539 xfs_fileoff_t end_fsb, orig_end_fsb;
539 int error = 0, eof = 0; 540 int error = 0, eof = 0;
540 struct xfs_bmbt_irec got; 541 struct xfs_bmbt_irec got;
541 struct xfs_bmbt_irec prev;
542 xfs_extnum_t idx; 542 xfs_extnum_t idx;
543 543
544 ASSERT(!XFS_IS_REALTIME_INODE(ip)); 544 ASSERT(!XFS_IS_REALTIME_INODE(ip));
@@ -563,8 +563,7 @@ xfs_file_iomap_begin_delay(
563 goto out_unlock; 563 goto out_unlock;
564 } 564 }
565 565
566 xfs_bmap_search_extents(ip, offset_fsb, XFS_DATA_FORK, &eof, &idx, 566 eof = !xfs_iext_lookup_extent(ip, ifp, offset_fsb, &idx, &got);
567 &got, &prev);
568 if (!eof && got.br_startoff <= offset_fsb) { 567 if (!eof && got.br_startoff <= offset_fsb) {
569 if (xfs_is_reflink_inode(ip)) { 568 if (xfs_is_reflink_inode(ip)) {
570 bool shared; 569 bool shared;
@@ -601,8 +600,7 @@ xfs_file_iomap_begin_delay(
601 if (eof) { 600 if (eof) {
602 xfs_fsblock_t prealloc_blocks; 601 xfs_fsblock_t prealloc_blocks;
603 602
604 prealloc_blocks = 603 prealloc_blocks = xfs_iomap_prealloc_size(ip, offset, count, idx);
605 xfs_iomap_prealloc_size(ip, offset, count, idx, &prev);
606 if (prealloc_blocks) { 604 if (prealloc_blocks) {
607 xfs_extlen_t align; 605 xfs_extlen_t align;
608 xfs_off_t end_offset; 606 xfs_off_t end_offset;