Commit 656152e5 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: use new extent lookup helpers xfs_file_iomap_begin_delay

And only lookup the previous extent inside xfs_iomap_prealloc_size
if we actually need it.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 65c5f419
...@@ -395,11 +395,12 @@ xfs_iomap_prealloc_size( ...@@ -395,11 +395,12 @@ xfs_iomap_prealloc_size(
struct xfs_inode *ip, struct xfs_inode *ip,
loff_t offset, loff_t offset,
loff_t count, loff_t count,
xfs_extnum_t idx, xfs_extnum_t idx)
struct xfs_bmbt_irec *prev)
{ {
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp = XFS_IFORK_PTR(ip, XFS_DATA_FORK);
xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset); xfs_fileoff_t offset_fsb = XFS_B_TO_FSBT(mp, offset);
struct xfs_bmbt_irec prev;
int shift = 0; int shift = 0;
int64_t freesp; int64_t freesp;
xfs_fsblock_t qblocks; xfs_fsblock_t qblocks;
...@@ -419,8 +420,8 @@ xfs_iomap_prealloc_size( ...@@ -419,8 +420,8 @@ xfs_iomap_prealloc_size(
*/ */
if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) || if ((mp->m_flags & XFS_MOUNT_DFLT_IOSIZE) ||
XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) || XFS_ISIZE(ip) < XFS_FSB_TO_B(mp, mp->m_dalign) ||
idx == 0 || !xfs_iext_get_extent(ifp, idx - 1, &prev) ||
prev->br_startoff + prev->br_blockcount < offset_fsb) prev.br_startoff + prev.br_blockcount < offset_fsb)
return mp->m_writeio_blocks; return mp->m_writeio_blocks;
/* /*
...@@ -439,8 +440,8 @@ xfs_iomap_prealloc_size( ...@@ -439,8 +440,8 @@ xfs_iomap_prealloc_size(
* always extends to MAXEXTLEN rather than falling short due to things * always extends to MAXEXTLEN rather than falling short due to things
* like stripe unit/width alignment of real extents. * like stripe unit/width alignment of real extents.
*/ */
if (prev->br_blockcount <= (MAXEXTLEN >> 1)) if (prev.br_blockcount <= (MAXEXTLEN >> 1))
alloc_blocks = prev->br_blockcount << 1; alloc_blocks = prev.br_blockcount << 1;
else else
alloc_blocks = XFS_B_TO_FSB(mp, offset); alloc_blocks = XFS_B_TO_FSB(mp, offset);
if (!alloc_blocks) if (!alloc_blocks)
...@@ -538,7 +539,6 @@ xfs_file_iomap_begin_delay( ...@@ -538,7 +539,6 @@ xfs_file_iomap_begin_delay(
xfs_fileoff_t end_fsb, orig_end_fsb; xfs_fileoff_t end_fsb, orig_end_fsb;
int error = 0, eof = 0; int error = 0, eof = 0;
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_bmbt_irec prev;
xfs_extnum_t idx; xfs_extnum_t idx;
ASSERT(!XFS_IS_REALTIME_INODE(ip)); ASSERT(!XFS_IS_REALTIME_INODE(ip));
...@@ -563,8 +563,7 @@ xfs_file_iomap_begin_delay( ...@@ -563,8 +563,7 @@ xfs_file_iomap_begin_delay(
goto out_unlock; goto out_unlock;
} }
xfs_bmap_search_extents(ip, offset_fsb, XFS_DATA_FORK, &eof, &idx, eof = !xfs_iext_lookup_extent(ip, ifp, offset_fsb, &idx, &got);
&got, &prev);
if (!eof && got.br_startoff <= offset_fsb) { if (!eof && got.br_startoff <= offset_fsb) {
if (xfs_is_reflink_inode(ip)) { if (xfs_is_reflink_inode(ip)) {
bool shared; bool shared;
...@@ -601,8 +600,7 @@ xfs_file_iomap_begin_delay( ...@@ -601,8 +600,7 @@ xfs_file_iomap_begin_delay(
if (eof) { if (eof) {
xfs_fsblock_t prealloc_blocks; xfs_fsblock_t prealloc_blocks;
prealloc_blocks = prealloc_blocks = xfs_iomap_prealloc_size(ip, offset, count, idx);
xfs_iomap_prealloc_size(ip, offset, count, idx, &prev);
if (prealloc_blocks) { if (prealloc_blocks) {
xfs_extlen_t align; xfs_extlen_t align;
xfs_off_t end_offset; xfs_off_t end_offset;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment