From: Christoph Hellwig Date: Fri, 17 Nov 2017 04:11:34 +0000 (-0600) Subject: xfs: treat idx as a cursor in xfs_bmap_collapse_extents X-Git-Tag: v4.15.0-rc1~143^2~23 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c162e3194bc34dcf7719693ba996dcb9be89e1ff;p=thirdparty%2Fxfsprogs-dev.git xfs: treat idx as a cursor in xfs_bmap_collapse_extents Source kernel commit: 42630361003461edd7607c1d459ab9d66ef97813 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: Christoph Hellwig Reviewed-by: Brian Foster Reviewed-by: Darrick J. Wong Signed-off-by: Darrick J. Wong Signed-off-by: Eric Sandeen --- diff --git a/libxfs/xfs_bmap.c b/libxfs/xfs_bmap.c index 78f482b0d..80039ffcf 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -5508,7 +5508,7 @@ xfs_bmse_merge( struct xfs_inode *ip, int whichfork, 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 *left, /* preceding extent */ struct xfs_btree_cur *cur, @@ -5563,9 +5563,10 @@ xfs_bmse_merge( return error; done: + xfs_iext_remove(ip, *current_ext, 1, 0); + --*current_ext; xfs_iext_update_extent(ip, xfs_bmap_fork_to_state(whichfork), - current_ext - 1, &new); - xfs_iext_remove(ip, current_ext, 1, 0); + *current_ext, &new); /* update reverse mapping. rmap functions merge the rmaps for us */ error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got); @@ -5679,16 +5680,10 @@ xfs_bmap_collapse_extents( if (xfs_bmse_can_merge(&prev, &got, offset_shift_fsb)) { error = xfs_bmse_merge(ip, whichfork, offset_shift_fsb, - current_ext, &got, &prev, cur, + ¤t_ext, &got, &prev, cur, &logflags, dfops); if (error) goto del_cursor; - - /* update got after merge */ - if (!xfs_iext_get_extent(ifp, current_ext, &got)) { - *done = true; - goto del_cursor; - } goto done; } } else { @@ -5703,12 +5698,12 @@ xfs_bmap_collapse_extents( if (error) goto del_cursor; +done: if (!xfs_iext_get_extent(ifp, ++current_ext, &got)) { *done = true; goto del_cursor; } -done: *next_fsb = got.br_startoff; del_cursor: if (cur)