diff mbox

[6/8] xfs: minor cleanup for xfs_reflink_end_cow

Message ID 20180313143601.30028-7-hch@lst.de (mailing list archive)
State Accepted
Headers show

Commit Message

Christoph Hellwig March 13, 2018, 2:35 p.m. UTC
Use xfs_iext_prev_extent to skip to the previous extent instead of
opencoding it.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 fs/xfs/xfs_reflink.c | 17 ++++++++---------
 1 file changed, 8 insertions(+), 9 deletions(-)

Comments

Darrick J. Wong March 13, 2018, 8:46 p.m. UTC | #1
On Tue, Mar 13, 2018 at 03:35:59PM +0100, Christoph Hellwig wrote:
> Use xfs_iext_prev_extent to skip to the previous extent instead of
> opencoding it.
> 
> Signed-off-by: Christoph Hellwig <hch@lst.de>

Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  fs/xfs/xfs_reflink.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
> index 90aac8889dd9..cdbd342a5249 100644
> --- a/fs/xfs/xfs_reflink.c
> +++ b/fs/xfs/xfs_reflink.c
> @@ -762,10 +762,8 @@ xfs_reflink_end_cow(
>  		xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb);
>  
>  		/* Extent delete may have bumped ext forward */
> -		if (!del.br_blockcount) {
> -			xfs_iext_prev(ifp, &icur);
> -			goto next_extent;
> -		}
> +		if (!del.br_blockcount)
> +			goto prev_extent;
>  
>  		ASSERT(!isnullstartblock(got.br_startblock));
>  
> @@ -774,10 +772,8 @@ xfs_reflink_end_cow(
>  		 * speculatively preallocated CoW extents that have been
>  		 * allocated but have not yet been involved in a write.
>  		 */
> -		if (got.br_state == XFS_EXT_UNWRITTEN) {
> -			xfs_iext_prev(ifp, &icur);
> -			goto next_extent;
> -		}
> +		if (got.br_state == XFS_EXT_UNWRITTEN)
> +			goto prev_extent;
>  
>  		/* Unmap the old blocks in the data fork. */
>  		xfs_defer_init(&dfops, &firstfsb);
> @@ -816,9 +812,12 @@ xfs_reflink_end_cow(
>  		error = xfs_defer_finish(&tp, &dfops);
>  		if (error)
>  			goto out_defer;
> -next_extent:
>  		if (!xfs_iext_get_extent(ifp, &icur, &got))
>  			break;
> +		continue;
> +prev_extent:
> +		if (!xfs_iext_prev_extent(ifp, &icur, &got))
> +			break;
>  	}
>  
>  	error = xfs_trans_commit(tp);
> -- 
> 2.14.2
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/fs/xfs/xfs_reflink.c b/fs/xfs/xfs_reflink.c
index 90aac8889dd9..cdbd342a5249 100644
--- a/fs/xfs/xfs_reflink.c
+++ b/fs/xfs/xfs_reflink.c
@@ -762,10 +762,8 @@  xfs_reflink_end_cow(
 		xfs_trim_extent(&del, offset_fsb, end_fsb - offset_fsb);
 
 		/* Extent delete may have bumped ext forward */
-		if (!del.br_blockcount) {
-			xfs_iext_prev(ifp, &icur);
-			goto next_extent;
-		}
+		if (!del.br_blockcount)
+			goto prev_extent;
 
 		ASSERT(!isnullstartblock(got.br_startblock));
 
@@ -774,10 +772,8 @@  xfs_reflink_end_cow(
 		 * speculatively preallocated CoW extents that have been
 		 * allocated but have not yet been involved in a write.
 		 */
-		if (got.br_state == XFS_EXT_UNWRITTEN) {
-			xfs_iext_prev(ifp, &icur);
-			goto next_extent;
-		}
+		if (got.br_state == XFS_EXT_UNWRITTEN)
+			goto prev_extent;
 
 		/* Unmap the old blocks in the data fork. */
 		xfs_defer_init(&dfops, &firstfsb);
@@ -816,9 +812,12 @@  xfs_reflink_end_cow(
 		error = xfs_defer_finish(&tp, &dfops);
 		if (error)
 			goto out_defer;
-next_extent:
 		if (!xfs_iext_get_extent(ifp, &icur, &got))
 			break;
+		continue;
+prev_extent:
+		if (!xfs_iext_prev_extent(ifp, &icur, &got))
+			break;
 	}
 
 	error = xfs_trans_commit(tp);