From: Christoph Hellwig Date: Fri, 17 Nov 2017 04:11:34 +0000 (-0600) Subject: xfs: treat idx as a cursor in xfs_bmap_add_extent_hole_delay X-Git-Tag: v4.15.0-rc1~143^2~27 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ee2bb3f58521f7e661f6234485dae75d69cd40c9;p=thirdparty%2Fxfsprogs-dev.git xfs: treat idx as a cursor in xfs_bmap_add_extent_hole_delay Source kernel commit: 41d196f439509fd8b09364ca1ba48194cccc6d6e 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 6999bdb87..fb0e63996 100644 --- a/libxfs/xfs_bmap.c +++ b/libxfs/xfs_bmap.c @@ -2575,7 +2575,6 @@ xfs_bmap_add_extent_hole_delay( * on the left and on the right. * Merge all three into a single extent record. */ - --*idx; temp = left.br_blockcount + new->br_blockcount + right.br_blockcount; @@ -2586,9 +2585,10 @@ xfs_bmap_add_extent_hole_delay( oldlen); left.br_startblock = nullstartblock(newlen); left.br_blockcount = temp; - xfs_iext_update_extent(ip, state, *idx, &left); - xfs_iext_remove(ip, *idx + 1, 1, state); + xfs_iext_remove(ip, *idx, 1, state); + --*idx; + xfs_iext_update_extent(ip, state, *idx, &left); break; case BMAP_LEFT_CONTIG: @@ -2597,7 +2597,6 @@ xfs_bmap_add_extent_hole_delay( * on the left. * Merge the new allocation with the left neighbor. */ - --*idx; temp = left.br_blockcount + new->br_blockcount; oldlen = startblockval(left.br_startblock) + @@ -2606,6 +2605,8 @@ xfs_bmap_add_extent_hole_delay( oldlen); left.br_blockcount = temp; left.br_startblock = nullstartblock(newlen); + + --*idx; xfs_iext_update_extent(ip, state, *idx, &left); break;