Commit b11bd671 authored by Dave Chinner's avatar Dave Chinner Committed by Dave Chinner

xfs: cleanup xfs_bmse_shift_one goto mess

xfs_bmse_shift_one() jumps around determining whether to shift or
merge, making the code flow difficult to follow. Clean it up and
use direct error returns (including XFS_WANT_CORRUPTED_RETURN) to
make the code flow better and be easier to read.
Signed-off-by: default avatarDave Chinner <dchinner@redhat.com>
Reviewed-by: default avatarBrian Foster <bfoster@redhat.com>
Signed-off-by: default avatarDave Chinner <david@fromorbit.com>
parent 7a1df156
...@@ -5544,20 +5544,13 @@ xfs_bmse_shift_one( ...@@ -5544,20 +5544,13 @@ xfs_bmse_shift_one(
startoff = got.br_startoff - offset_shift_fsb; startoff = got.br_startoff - offset_shift_fsb;
/* delalloc extents should be prevented by caller */ /* delalloc extents should be prevented by caller */
XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock), XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock));
out_error);
/* /*
* If this is the first extent in the file, make sure there's enough * Check for merge if we've got an extent to the left, otherwise make
* room at the start of the file and jump right to the shift as there's * sure there's enough room at the start of the file for the shift.
* no left extent to merge.
*/ */
if (*current_ext == 0) { if (*current_ext) {
if (got.br_startoff < offset_shift_fsb)
return -EINVAL;
goto shift_extent;
}
/* grab the left extent and check for a large enough hole */ /* grab the left extent and check for a large enough hole */
leftp = xfs_iext_get_ext(ifp, *current_ext - 1); leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
xfs_bmbt_get_all(leftp, &left); xfs_bmbt_get_all(leftp, &left);
...@@ -5566,13 +5559,14 @@ xfs_bmse_shift_one( ...@@ -5566,13 +5559,14 @@ xfs_bmse_shift_one(
return -EINVAL; return -EINVAL;
/* check whether to merge the extent or shift it down */ /* check whether to merge the extent or shift it down */
if (!xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) {
goto shift_extent; return xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
*current_ext, gotp, leftp, cur,
return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, *current_ext, logflags);
gotp, leftp, cur, logflags); }
} else if (got.br_startoff < offset_shift_fsb)
return -EINVAL;
shift_extent:
/* /*
* Increment the extent index for the next iteration, update the start * Increment the extent index for the next iteration, update the start
* offset of the in-core extent and update the btree if applicable. * offset of the in-core extent and update the btree if applicable.
...@@ -5589,14 +5583,11 @@ xfs_bmse_shift_one( ...@@ -5589,14 +5583,11 @@ xfs_bmse_shift_one(
got.br_blockcount, &i); got.br_blockcount, &i);
if (error) if (error)
return error; return error;
XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); XFS_WANT_CORRUPTED_RETURN(i == 1);
got.br_startoff = startoff; got.br_startoff = startoff;
return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock,
got.br_blockcount, got.br_state); got.br_blockcount, got.br_state);
out_error:
return error;
} }
/* /*
......
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