Commit 7efc7945 authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Dave Chinner

xfs: use new extent lookup helpers in __xfs_bunmapi

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 2d58f6ef
...@@ -5430,8 +5430,6 @@ __xfs_bunmapi( ...@@ -5430,8 +5430,6 @@ __xfs_bunmapi(
{ {
xfs_btree_cur_t *cur; /* bmap btree cursor */ xfs_btree_cur_t *cur; /* bmap btree cursor */
xfs_bmbt_irec_t del; /* extent being deleted */ xfs_bmbt_irec_t del; /* extent being deleted */
int eof; /* is deleting at eof */
xfs_bmbt_rec_host_t *ep; /* extent record pointer */
int error; /* error return value */ int error; /* error return value */
xfs_extnum_t extno; /* extent number in list */ xfs_extnum_t extno; /* extent number in list */
xfs_bmbt_irec_t got; /* current extent record */ xfs_bmbt_irec_t got; /* current extent record */
...@@ -5441,7 +5439,6 @@ __xfs_bunmapi( ...@@ -5441,7 +5439,6 @@ __xfs_bunmapi(
int logflags; /* transaction logging flags */ int logflags; /* transaction logging flags */
xfs_extlen_t mod; /* rt extent offset */ xfs_extlen_t mod; /* rt extent offset */
xfs_mount_t *mp; /* mount structure */ xfs_mount_t *mp; /* mount structure */
xfs_bmbt_irec_t prev; /* previous extent record */
xfs_fileoff_t start; /* first file offset deleted */ xfs_fileoff_t start; /* first file offset deleted */
int tmp_logflags; /* partial logging flags */ int tmp_logflags; /* partial logging flags */
int wasdel; /* was a delayed alloc extent */ int wasdel; /* was a delayed alloc extent */
...@@ -5480,18 +5477,17 @@ __xfs_bunmapi( ...@@ -5480,18 +5477,17 @@ __xfs_bunmapi(
isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip); isrt = (whichfork == XFS_DATA_FORK) && XFS_IS_REALTIME_INODE(ip);
start = bno; start = bno;
bno = start + len - 1; bno = start + len - 1;
ep = xfs_bmap_search_extents(ip, bno, whichfork, &eof, &lastx, &got,
&prev);
/* /*
* Check to see if the given block number is past the end of the * Check to see if the given block number is past the end of the
* file, back up to the last block if so... * file, back up to the last block if so...
*/ */
if (eof) { if (!xfs_iext_lookup_extent(ip, ifp, bno, &lastx, &got)) {
ep = xfs_iext_get_ext(ifp, --lastx); ASSERT(lastx > 0);
xfs_bmbt_get_all(ep, &got); xfs_iext_get_extent(ifp, --lastx, &got);
bno = got.br_startoff + got.br_blockcount - 1; bno = got.br_startoff + got.br_blockcount - 1;
} }
logflags = 0; logflags = 0;
if (ifp->if_flags & XFS_IFBROOT) { if (ifp->if_flags & XFS_IFBROOT) {
ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE); ASSERT(XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE);
...@@ -5522,8 +5518,7 @@ __xfs_bunmapi( ...@@ -5522,8 +5518,7 @@ __xfs_bunmapi(
if (got.br_startoff > bno) { if (got.br_startoff > bno) {
if (--lastx < 0) if (--lastx < 0)
break; break;
ep = xfs_iext_get_ext(ifp, lastx); xfs_iext_get_extent(ifp, lastx, &got);
xfs_bmbt_get_all(ep, &got);
} }
/* /*
* Is the last block of this extent before the range * Is the last block of this extent before the range
...@@ -5537,7 +5532,6 @@ __xfs_bunmapi( ...@@ -5537,7 +5532,6 @@ __xfs_bunmapi(
* Then deal with the (possibly delayed) allocated space * Then deal with the (possibly delayed) allocated space
* we found. * we found.
*/ */
ASSERT(ep != NULL);
del = got; del = got;
wasdel = isnullstartblock(del.br_startblock); wasdel = isnullstartblock(del.br_startblock);
if (got.br_startoff < start) { if (got.br_startoff < start) {
...@@ -5618,15 +5612,12 @@ __xfs_bunmapi( ...@@ -5618,15 +5612,12 @@ __xfs_bunmapi(
*/ */
ASSERT(bno >= del.br_blockcount); ASSERT(bno >= del.br_blockcount);
bno -= del.br_blockcount; bno -= del.br_blockcount;
if (got.br_startoff > bno) { if (got.br_startoff > bno && --lastx >= 0)
if (--lastx >= 0) { xfs_iext_get_extent(ifp, lastx, &got);
ep = xfs_iext_get_ext(ifp,
lastx);
xfs_bmbt_get_all(ep, &got);
}
}
continue; continue;
} else if (del.br_state == XFS_EXT_UNWRITTEN) { } else if (del.br_state == XFS_EXT_UNWRITTEN) {
struct xfs_bmbt_irec prev;
/* /*
* This one is already unwritten. * This one is already unwritten.
* It must have a written left neighbor. * It must have a written left neighbor.
...@@ -5634,8 +5625,7 @@ __xfs_bunmapi( ...@@ -5634,8 +5625,7 @@ __xfs_bunmapi(
* try again. * try again.
*/ */
ASSERT(lastx > 0); ASSERT(lastx > 0);
xfs_bmbt_get_all(xfs_iext_get_ext(ifp, xfs_iext_get_extent(ifp, lastx - 1, &prev);
lastx - 1), &prev);
ASSERT(prev.br_state == XFS_EXT_NORM); ASSERT(prev.br_state == XFS_EXT_NORM);
ASSERT(!isnullstartblock(prev.br_startblock)); ASSERT(!isnullstartblock(prev.br_startblock));
ASSERT(del.br_startblock == ASSERT(del.br_startblock ==
...@@ -5733,13 +5723,9 @@ __xfs_bunmapi( ...@@ -5733,13 +5723,9 @@ __xfs_bunmapi(
*/ */
if (bno != (xfs_fileoff_t)-1 && bno >= start) { if (bno != (xfs_fileoff_t)-1 && bno >= start) {
if (lastx >= 0) { if (lastx >= 0) {
ep = xfs_iext_get_ext(ifp, lastx); xfs_iext_get_extent(ifp, lastx, &got);
if (xfs_bmbt_get_startoff(ep) > bno) { if (got.br_startoff > bno && --lastx >= 0)
if (--lastx >= 0) xfs_iext_get_extent(ifp, lastx, &got);
ep = xfs_iext_get_ext(ifp,
lastx);
}
xfs_bmbt_get_all(ep, &got);
} }
extno++; extno++;
} }
......
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