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

xfs: use xfs_iext_get_extent in xfs_bmap_first_unused

Use the bmap abstraction instead of open-coding bmbt details here.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 50bb44c2
...@@ -1359,7 +1359,6 @@ xfs_bmap_first_unused( ...@@ -1359,7 +1359,6 @@ xfs_bmap_first_unused(
xfs_fileoff_t lastaddr; /* last block number seen */ xfs_fileoff_t lastaddr; /* last block number seen */
xfs_fileoff_t lowest; /* lowest useful block */ xfs_fileoff_t lowest; /* lowest useful block */
xfs_fileoff_t max; /* starting useful block */ xfs_fileoff_t max; /* starting useful block */
xfs_fileoff_t off; /* offset for this block */
xfs_extnum_t nextents; /* number of extent entries */ xfs_extnum_t nextents; /* number of extent entries */
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE || ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE ||
...@@ -1376,16 +1375,19 @@ xfs_bmap_first_unused( ...@@ -1376,16 +1375,19 @@ xfs_bmap_first_unused(
lowest = *first_unused; lowest = *first_unused;
nextents = xfs_iext_count(ifp); nextents = xfs_iext_count(ifp);
for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) { for (idx = 0, lastaddr = 0, max = lowest; idx < nextents; idx++) {
xfs_bmbt_rec_host_t *ep = xfs_iext_get_ext(ifp, idx); struct xfs_bmbt_irec got;
off = xfs_bmbt_get_startoff(ep);
xfs_iext_get_extent(ifp, idx, &got);
/* /*
* See if the hole before this extent will work. * See if the hole before this extent will work.
*/ */
if (off >= lowest + len && off - max >= len) { if (got.br_startoff >= lowest + len &&
got.br_startoff - max >= len) {
*first_unused = max; *first_unused = max;
return 0; return 0;
} }
lastaddr = off + xfs_bmbt_get_blockcount(ep); lastaddr = got.br_startoff + got.br_blockcount;
max = XFS_FILEOFF_MAX(lastaddr, lowest); max = XFS_FILEOFF_MAX(lastaddr, lowest);
} }
*first_unused = max; *first_unused = max;
......
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