diff options
author | Dave Chinner <dchinner@redhat.com> | 2014-12-03 17:42:24 -0500 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2014-12-03 17:42:24 -0500 |
commit | b11bd671ba8a0268753db25684115acde57d3d32 (patch) | |
tree | 8ee588f9409192aed706c00557642ad7adafce54 /fs/xfs/libxfs | |
parent | 7a1df1561609c14ac457d65d9a4a2b6c0f4204ad (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/libxfs')
-rw-r--r-- | fs/xfs/libxfs/xfs_bmap.c | 43 |
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( | |||
5544 | startoff = got.br_startoff - offset_shift_fsb; | 5544 | startoff = got.br_startoff - offset_shift_fsb; |
5545 | 5545 | ||
5546 | /* delalloc extents should be prevented by caller */ | 5546 | /* delalloc extents should be prevented by caller */ |
5547 | XFS_WANT_CORRUPTED_GOTO(!isnullstartblock(got.br_startblock), | 5547 | XFS_WANT_CORRUPTED_RETURN(!isnullstartblock(got.br_startblock)); |
5548 | out_error); | ||
5549 | 5548 | ||
5550 | /* | 5549 | /* |
5551 | * If this is the first extent in the file, make sure there's enough | 5550 | * Check for merge if we've got an extent to the left, otherwise make |
5552 | * room at the start of the file and jump right to the shift as there's | 5551 | * sure there's enough room at the start of the file for the shift. |
5553 | * no left extent to merge. | ||
5554 | */ | 5552 | */ |
5555 | if (*current_ext == 0) { | 5553 | if (*current_ext) { |
5556 | if (got.br_startoff < offset_shift_fsb) | 5554 | /* grab the left extent and check for a large enough hole */ |
5557 | return -EINVAL; | 5555 | leftp = xfs_iext_get_ext(ifp, *current_ext - 1); |
5558 | goto shift_extent; | 5556 | xfs_bmbt_get_all(leftp, &left); |
5559 | } | ||
5560 | 5557 | ||
5561 | /* grab the left extent and check for a large enough hole */ | 5558 | if (startoff < left.br_startoff + left.br_blockcount) |
5562 | leftp = xfs_iext_get_ext(ifp, *current_ext - 1); | 5559 | return -EINVAL; |
5563 | xfs_bmbt_get_all(leftp, &left); | ||
5564 | 5560 | ||
5565 | if (startoff < left.br_startoff + left.br_blockcount) | 5561 | /* check whether to merge the extent or shift it down */ |
5562 | if (xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) { | ||
5563 | return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, | ||
5564 | *current_ext, gotp, leftp, cur, | ||
5565 | logflags); | ||
5566 | } | ||
5567 | } else if (got.br_startoff < offset_shift_fsb) | ||
5566 | return -EINVAL; | 5568 | return -EINVAL; |
5567 | 5569 | ||
5568 | /* check whether to merge the extent or shift it down */ | ||
5569 | if (!xfs_bmse_can_merge(&left, &got, offset_shift_fsb)) | ||
5570 | goto shift_extent; | ||
5571 | |||
5572 | return xfs_bmse_merge(ip, whichfork, offset_shift_fsb, *current_ext, | ||
5573 | gotp, leftp, cur, logflags); | ||
5574 | |||
5575 | shift_extent: | ||
5576 | /* | 5570 | /* |
5577 | * Increment the extent index for the next iteration, update the start | 5571 | * Increment the extent index for the next iteration, update the start |
5578 | * offset of the in-core extent and update the btree if applicable. | 5572 | * offset of the in-core extent and update the btree if applicable. |
@@ -5589,14 +5583,11 @@ shift_extent: | |||
5589 | got.br_blockcount, &i); | 5583 | got.br_blockcount, &i); |
5590 | if (error) | 5584 | if (error) |
5591 | return error; | 5585 | return error; |
5592 | XFS_WANT_CORRUPTED_GOTO(i == 1, out_error); | 5586 | XFS_WANT_CORRUPTED_RETURN(i == 1); |
5593 | 5587 | ||
5594 | got.br_startoff = startoff; | 5588 | got.br_startoff = startoff; |
5595 | return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, | 5589 | return xfs_bmbt_update(cur, got.br_startoff, got.br_startblock, |
5596 | got.br_blockcount, got.br_state); | 5590 | got.br_blockcount, got.br_state); |
5597 | |||
5598 | out_error: | ||
5599 | return error; | ||
5600 | } | 5591 | } |
5601 | 5592 | ||
5602 | /* | 5593 | /* |