Commit 3345746e authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: simplify xfs_map_blocks by using xfs_iext_lookup_extent directly

xfs_bmapi_read adds zero value in xfs_map_blocks.  Replace it with a
direct call to the low-level extent lookup function.

Note that we now always pass a 0 length to the trace points as we ask
for an unspecified len.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 060d4eaa
...@@ -375,7 +375,6 @@ xfs_map_blocks( ...@@ -375,7 +375,6 @@ xfs_map_blocks(
int whichfork = XFS_DATA_FORK; int whichfork = XFS_DATA_FORK;
struct xfs_iext_cursor icur; struct xfs_iext_cursor icur;
int error = 0; int error = 0;
int nimaps = 1;
if (XFS_FORCED_SHUTDOWN(mp)) if (XFS_FORCED_SHUTDOWN(mp))
return -EIO; return -EIO;
...@@ -431,24 +430,16 @@ xfs_map_blocks( ...@@ -431,24 +430,16 @@ xfs_map_blocks(
* offset. This will convert delayed allocations (including COW ones) * offset. This will convert delayed allocations (including COW ones)
* into real extents. * into real extents.
*/ */
error = xfs_bmapi_read(ip, offset_fsb, end_fsb - offset_fsb, if (!xfs_iext_lookup_extent(ip, &ip->i_df, offset_fsb, &icur, &imap))
&imap, &nimaps, XFS_BMAPI_ENTIRE); imap.br_startoff = end_fsb; /* fake a hole past EOF */
xfs_iunlock(ip, XFS_ILOCK_SHARED); xfs_iunlock(ip, XFS_ILOCK_SHARED);
if (error)
return error;
if (!nimaps) { if (imap.br_startoff > offset_fsb) {
/* /* landed in a hole or beyond EOF */
* Lookup returns no match? Beyond eof? regardless, imap.br_blockcount = imap.br_startoff - offset_fsb;
* return it as a hole so we don't write it
*/
imap.br_startoff = offset_fsb; imap.br_startoff = offset_fsb;
imap.br_blockcount = end_fsb - offset_fsb;
imap.br_startblock = HOLESTARTBLOCK; imap.br_startblock = HOLESTARTBLOCK;
wpc->io_type = XFS_IO_HOLE; wpc->io_type = XFS_IO_HOLE;
} else if (imap.br_startblock == HOLESTARTBLOCK) {
/* landed in a hole */
wpc->io_type = XFS_IO_HOLE;
} else { } else {
if (isnullstartblock(imap.br_startblock)) { if (isnullstartblock(imap.br_startblock)) {
/* got a delalloc extent */ /* got a delalloc extent */
......
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