aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDarrick J. Wong <darrick.wong@oracle.com>2016-10-10 01:47:40 -0400
committerDave Chinner <david@fromorbit.com>2016-10-10 01:47:40 -0400
commit024adf48702212b0af15c682a7ff9773e1e092d6 (patch)
tree452b62e369489bd4d207d125615580913b4fb9ad
parent63646fc58d666f149b85ccf470bfc1576a779d4c (diff)
xfs: reduce stack usage of _reflink_clear_inode_flag
The loop in _reflink_clear_inode_flag isn't necessary since we jump out if any part of any extent is shared. Remove the loop and we no longer need two maps, so we can save some stack use. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Reported-by: Brian Foster <bfoster@redhat.com> Reviewed-by: Dave Chinner <dchinner@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
-rw-r--r--fs/xfs/xfs_reflink.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 9c58b4a83248..c4e35dccb803 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -1507,7 +1507,7 @@ xfs_reflink_clear_inode_flag(
1507 xfs_extlen_t aglen; 1507 xfs_extlen_t aglen;
1508 xfs_agblock_t rbno; 1508 xfs_agblock_t rbno;
1509 xfs_extlen_t rlen; 1509 xfs_extlen_t rlen;
1510 struct xfs_bmbt_irec map[2]; 1510 struct xfs_bmbt_irec map;
1511 int nmaps; 1511 int nmaps;
1512 int error = 0; 1512 int error = 0;
1513 1513
@@ -1521,37 +1521,29 @@ xfs_reflink_clear_inode_flag(
1521 * Look for extents in the file. Skip holes, delalloc, or 1521 * Look for extents in the file. Skip holes, delalloc, or
1522 * unwritten extents; they can't be reflinked. 1522 * unwritten extents; they can't be reflinked.
1523 */ 1523 */
1524 error = xfs_bmapi_read(ip, fbno, end - fbno, map, &nmaps, 0); 1524 error = xfs_bmapi_read(ip, fbno, end - fbno, &map, &nmaps, 0);
1525 if (error) 1525 if (error)
1526 return error; 1526 return error;
1527 if (nmaps == 0) 1527 if (nmaps == 0)
1528 break; 1528 break;
1529 if (map[0].br_startblock == HOLESTARTBLOCK || 1529 if (map.br_startblock == HOLESTARTBLOCK ||
1530 map[0].br_startblock == DELAYSTARTBLOCK || 1530 map.br_startblock == DELAYSTARTBLOCK ||
1531 ISUNWRITTEN(&map[0])) 1531 ISUNWRITTEN(&map))
1532 goto next; 1532 goto next;
1533 1533
1534 map[1] = map[0]; 1534 agno = XFS_FSB_TO_AGNO(mp, map.br_startblock);
1535 while (map[1].br_blockcount) { 1535 agbno = XFS_FSB_TO_AGBNO(mp, map.br_startblock);
1536 agno = XFS_FSB_TO_AGNO(mp, map[1].br_startblock); 1536 aglen = map.br_blockcount;
1537 agbno = XFS_FSB_TO_AGBNO(mp, map[1].br_startblock);
1538 aglen = map[1].br_blockcount;
1539
1540 error = xfs_reflink_find_shared(mp, agno, agbno, aglen,
1541 &rbno, &rlen, false);
1542 if (error)
1543 return error;
1544 /* Is there still a shared block here? */
1545 if (rbno != NULLAGBLOCK)
1546 return 0;
1547
1548 map[1].br_blockcount -= aglen;
1549 map[1].br_startoff += aglen;
1550 map[1].br_startblock += aglen;
1551 }
1552 1537
1538 error = xfs_reflink_find_shared(mp, agno, agbno, aglen,
1539 &rbno, &rlen, false);
1540 if (error)
1541 return error;
1542 /* Is there still a shared block here? */
1543 if (rbno != NULLAGBLOCK)
1544 return 0;
1553next: 1545next:
1554 fbno = map[0].br_startoff + map[0].br_blockcount; 1546 fbno = map.br_startoff + map.br_blockcount;
1555 } 1547 }
1556 1548
1557 /* 1549 /*