Commit 6b18af0d authored by Christoph Hellwig's avatar Christoph Hellwig Committed by Darrick J. Wong

xfs: remove XFS_BMAP_MAX_SHIFT_EXTENTS

The define was always set to 1, which means looping until we reach is
was dead code from the start.

Also remove an initialization of next_fsb for the done case that doesn't
fit the new code flow - it was never checked by the caller in the done
case to start with.
Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent 4ed36c6b
...@@ -5703,8 +5703,7 @@ xfs_bmse_shift_one( ...@@ -5703,8 +5703,7 @@ xfs_bmse_shift_one(
/* /*
* Shift extent records to the left/right to cover/create a hole. * Shift extent records to the left/right to cover/create a hole.
* *
* The maximum number of extents to be shifted in a single operation is * @stop_fsb specifies the file offset at which to stop shift and the
* @num_exts. @stop_fsb specifies the file offset at which to stop shift and the
* file offset where we've left off is returned in @next_fsb. @offset_shift_fsb * file offset where we've left off is returned in @next_fsb. @offset_shift_fsb
* is the length by which each extent is shifted. If there is no hole to shift * is the length by which each extent is shifted. If there is no hole to shift
* the extents into, this will be considered invalid operation and we abort * the extents into, this will be considered invalid operation and we abort
...@@ -5720,14 +5719,12 @@ xfs_bmap_shift_extents( ...@@ -5720,14 +5719,12 @@ xfs_bmap_shift_extents(
xfs_fileoff_t stop_fsb, xfs_fileoff_t stop_fsb,
xfs_fsblock_t *firstblock, xfs_fsblock_t *firstblock,
struct xfs_defer_ops *dfops, struct xfs_defer_ops *dfops,
enum shift_direction direction, enum shift_direction direction)
int num_exts)
{ {
struct xfs_btree_cur *cur = NULL; struct xfs_btree_cur *cur = NULL;
struct xfs_bmbt_irec got; struct xfs_bmbt_irec got;
struct xfs_mount *mp = ip->i_mount; struct xfs_mount *mp = ip->i_mount;
struct xfs_ifork *ifp; struct xfs_ifork *ifp;
xfs_extnum_t nexts = 0;
xfs_extnum_t current_ext; xfs_extnum_t current_ext;
xfs_extnum_t total_extents; xfs_extnum_t total_extents;
xfs_extnum_t stop_extent; xfs_extnum_t stop_extent;
...@@ -5825,31 +5822,27 @@ xfs_bmap_shift_extents( ...@@ -5825,31 +5822,27 @@ xfs_bmap_shift_extents(
} }
} }
while (nexts++ < num_exts) { error = xfs_bmse_shift_one(ip, whichfork, offset_shift_fsb,
error = xfs_bmse_shift_one(ip, whichfork, offset_shift_fsb, &current_ext, &got, cur, &logflags,
&current_ext, &got, cur, &logflags, direction, dfops);
direction, dfops); if (error)
if (error) goto del_cursor;
goto del_cursor; /*
/* * If there was an extent merge during the shift, the extent
* If there was an extent merge during the shift, the extent * count can change. Update the total and grade the next record.
* count can change. Update the total and grade the next record. */
*/ if (direction == SHIFT_LEFT) {
if (direction == SHIFT_LEFT) { total_extents = xfs_iext_count(ifp);
total_extents = xfs_iext_count(ifp); stop_extent = total_extents;
stop_extent = total_extents; }
}
if (current_ext == stop_extent) { if (current_ext == stop_extent) {
*done = 1; *done = 1;
*next_fsb = NULLFSBLOCK; goto del_cursor;
break;
}
xfs_iext_get_extent(ifp, current_ext, &got);
} }
xfs_iext_get_extent(ifp, current_ext, &got);
if (!*done) *next_fsb = got.br_startoff;
*next_fsb = got.br_startoff;
del_cursor: del_cursor:
if (cur) if (cur)
......
...@@ -183,15 +183,6 @@ static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec) ...@@ -183,15 +183,6 @@ static inline bool xfs_bmap_is_real_extent(struct xfs_bmbt_irec *irec)
!isnullstartblock(irec->br_startblock); !isnullstartblock(irec->br_startblock);
} }
/*
* This macro is used to determine how many extents will be shifted
* in one write transaction. We could require two splits,
* an extent move on the first and an extent merge on the second,
* So it is proper that one extent is shifted inside write transaction
* at a time.
*/
#define XFS_BMAP_MAX_SHIFT_EXTENTS 1
enum shift_direction { enum shift_direction {
SHIFT_LEFT = 0, SHIFT_LEFT = 0,
SHIFT_RIGHT, SHIFT_RIGHT,
...@@ -240,8 +231,7 @@ uint xfs_default_attroffset(struct xfs_inode *ip); ...@@ -240,8 +231,7 @@ uint xfs_default_attroffset(struct xfs_inode *ip);
int xfs_bmap_shift_extents(struct xfs_trans *tp, struct xfs_inode *ip, int xfs_bmap_shift_extents(struct xfs_trans *tp, struct xfs_inode *ip,
xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb, xfs_fileoff_t *next_fsb, xfs_fileoff_t offset_shift_fsb,
int *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock, int *done, xfs_fileoff_t stop_fsb, xfs_fsblock_t *firstblock,
struct xfs_defer_ops *dfops, enum shift_direction direction, struct xfs_defer_ops *dfops, enum shift_direction direction);
int num_exts);
int xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset); int xfs_bmap_split_extent(struct xfs_inode *ip, xfs_fileoff_t split_offset);
int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork, int xfs_bmapi_reserve_delalloc(struct xfs_inode *ip, int whichfork,
xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc, xfs_fileoff_t off, xfs_filblks_t len, xfs_filblks_t prealloc,
......
...@@ -1359,14 +1359,9 @@ xfs_collapse_file_space( ...@@ -1359,14 +1359,9 @@ xfs_collapse_file_space(
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_defer_init(&dfops, &first_block); xfs_defer_init(&dfops, &first_block);
/*
* We are using the write transaction in which max 2 bmbt
* updates are allowed
*/
error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb, error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb,
&done, stop_fsb, &first_block, &dfops, &done, stop_fsb, &first_block, &dfops,
SHIFT_LEFT, XFS_BMAP_MAX_SHIFT_EXTENTS); SHIFT_LEFT);
if (error) if (error)
goto out_bmap_cancel; goto out_bmap_cancel;
...@@ -1438,14 +1433,9 @@ xfs_insert_file_space( ...@@ -1438,14 +1433,9 @@ xfs_insert_file_space(
xfs_ilock(ip, XFS_ILOCK_EXCL); xfs_ilock(ip, XFS_ILOCK_EXCL);
xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL); xfs_trans_ijoin(tp, ip, XFS_ILOCK_EXCL);
xfs_defer_init(&dfops, &first_block); xfs_defer_init(&dfops, &first_block);
/*
* We are using the write transaction in which max 2 bmbt
* updates are allowed
*/
error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb, error = xfs_bmap_shift_extents(tp, ip, &next_fsb, shift_fsb,
&done, stop_fsb, &first_block, &dfops, &done, stop_fsb, &first_block, &dfops,
SHIFT_RIGHT, XFS_BMAP_MAX_SHIFT_EXTENTS); SHIFT_RIGHT);
if (error) if (error)
goto out_bmap_cancel; goto out_bmap_cancel;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment