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

xfs: treat idx as a cursor in xfs_bmap_collapse_extents

Stop poking before and after the index and just increment or decrement
it while doing our operations on it to prepare for a new extent list
implementation.
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 657fcb23
...@@ -5517,7 +5517,7 @@ xfs_bmse_merge( ...@@ -5517,7 +5517,7 @@ xfs_bmse_merge(
struct xfs_inode *ip, struct xfs_inode *ip,
int whichfork, int whichfork,
xfs_fileoff_t shift, /* shift fsb */ xfs_fileoff_t shift, /* shift fsb */
int current_ext, /* idx of gotp */ int *current_ext, /* idx of gotp */
struct xfs_bmbt_irec *got, /* extent to shift */ struct xfs_bmbt_irec *got, /* extent to shift */
struct xfs_bmbt_irec *left, /* preceding extent */ struct xfs_bmbt_irec *left, /* preceding extent */
struct xfs_btree_cur *cur, struct xfs_btree_cur *cur,
...@@ -5572,9 +5572,10 @@ xfs_bmse_merge( ...@@ -5572,9 +5572,10 @@ xfs_bmse_merge(
return error; return error;
done: done:
xfs_iext_remove(ip, *current_ext, 1, 0);
--*current_ext;
xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork),
current_ext - 1, &new); *current_ext, &new);
xfs_iext_remove(ip, current_ext, 1, 0);
/* update reverse mapping. rmap functions merge the rmaps for us */ /* update reverse mapping. rmap functions merge the rmaps for us */
error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got); error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got);
...@@ -5688,16 +5689,10 @@ xfs_bmap_collapse_extents( ...@@ -5688,16 +5689,10 @@ xfs_bmap_collapse_extents(
if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) { if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) {
error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb, error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
current_ext, &got, &prev, cur, &current_ext, &got, &prev, cur,
&logflags, dfops); &logflags, dfops);
if (error) if (error)
goto del_cursor; goto del_cursor;
/* update got after merge */
if (!xfs_iext_get_extent(ifp, current_ext, &got)) {
*done = true;
goto del_cursor;
}
goto done; goto done;
} }
} else { } else {
...@@ -5712,12 +5707,12 @@ xfs_bmap_collapse_extents( ...@@ -5712,12 +5707,12 @@ xfs_bmap_collapse_extents(
if (error) if (error)
goto del_cursor; goto del_cursor;
done:
if (!xfs_iext_get_extent(ifp, ++current_ext, &got)) { if (!xfs_iext_get_extent(ifp, ++current_ext, &got)) {
*done = true; *done = true;
goto del_cursor; goto del_cursor;
} }
done:
*next_fsb = got.br_startoff; *next_fsb = got.br_startoff;
del_cursor: del_cursor:
if (cur) if (cur)
......
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