From 4e0f221ffcbd288f8b3cf2b5d649977cc1708964 Mon Sep 17 00:00:00 2001
From: Christoph Hellwig <hch@lst.de>
Date: Fri, 3 Nov 2017 10:34:41 -0700
Subject: [PATCH 54/77] xfs: treat idx as a cursor in xfs_bmap_collapse_extents
Git-commit: 42630361003461edd7607c1d459ab9d66ef97813
Patch-mainline: v4.15-rc1
References: bsc#1095344
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 <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Acked-by: Nikolay Borisov <nborisov@suse.com>
---
fs/xfs/libxfs/xfs_bmap.c | 17 ++++++-----------
1 file changed, 6 insertions(+), 11 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index c9ff672c9225..5ce9554cf1bd 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -5502,7 +5502,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,
@@ -5557,9 +5557,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 */
error = xfs_rmap_unmap_extent(mp, dfops, ip, whichfork, got);
@@ -5674,16 +5675,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 {
@@ -5698,12 +5693,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)
--
2.7.4