summaryrefslogtreecommitdiff
path: root/fs/xfs
diff options
context:
space:
mode:
authorDave Chinner <dchinner@redhat.com>2014-12-04 09:42:24 +1100
committerDave Chinner <david@fromorbit.com>2014-12-04 09:42:24 +1100
commitb11bd671ba8a0268753db25684115acde57d3d32 (patch)
tree8ee588f9409192aed706c00557642ad7adafce54 /fs/xfs
parent7a1df1561609c14ac457d65d9a4a2b6c0f4204ad (diff)
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: Dave Chinner <dchinner@redhat.com> Reviewed-by: Brian Foster <bfoster@redhat.com> Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs/xfs')
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c43
1 files changed, 17 insertions, 26 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 20d2e96aef6a..0628a678de12 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5544,35 +5544,29 @@ xfs_bmse_shift_one(
startoff = got.br_startoff - offset_shift_fsb;
/* delalloc extents should be prevented by caller */
- XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock),
- out_error);
+ XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock));
/*
- * If this is the first extent in the file, make sure there's enough
- * room at the start of the file and jump right to the shift as there's
- * no left extent to merge.
+ * Check for merge if we've got an extent to the left, otherwise make
+ * sure there's enough room at the start of the file for the shift.
*/
- if (*current_ext == 0) {
- if (got.br_startoff < offset_shift_fsb)
- return -EINVAL;
- goto shift_extent;
- }
+ if (*current_ext) {
+ /* grab the left extent and check for a large enough hole */
+ leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
+ xfs_bmbt_get_all(leftp, &left);
- /* grab the left extent and check for a large enough hole */
- leftp = xfs_iext_get_ext(ifp, *current_ext - 1);
- xfs_bmbt_get_all(leftp, &left);
+ if (startoff < left.br_startoff + left.br_blockcount)
+ return -EINVAL;
- if (startoff < left.br_startoff + left.br_blockcount)
+ /* check whether to merge the extent or shift it down */
+ if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) {
+ return xfs_bmse_merge(ip, whichfork, offset_shift_fsb,
+ *current_ext, gotp, leftp, cur,
+ logflags);
+ }
+ } else if (got.br_startoff < offset_shift_fsb)
return -EINVAL;
- /* check whether to merge the extent or shift it down */
- 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, logflags);
-
-shift_extent:
/*
* Increment the extent index for the next iteration, update the start
* offset of the in-core extent and update the btree if applicable.
@@ -5589,14 +5583,11 @@ shift_extent:
got.br_blockcount, &i);
if (error)
return error;
- XFS_WANT_CORRUPTED_GOTO(i == 1, out_error);
+ XFS_WANT_CORRUPTED_RETURN(i == 1);
got.br_startoff = startoff;
return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock,
got.br_blockcount, got.br_state);
-
-out_error:
- return error;
}
/*