aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristoph Hellwig <hch@lst.de>2017-08-29 18:44:12 -0400
committerDarrick J. Wong <darrick.wong@oracle.com>2017-09-01 16:08:25 -0400
commit05b7c8ab2be71e6fef4615451e7af1bc79ffdf29 (patch)
tree65e27c1b8be2b44f93c03912984b57723a38226f
parentf2285c148c4167337d12452bebccadd2ad821d5d (diff)
xfs: move some code around inside xfs_bmap_shift_extents
For the first right move we need to look up next_fsb. That means our last fsb that contains next_fsb must also be the current extent, so take advantage of that by moving the code around a bit. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
-rw-r--r--fs/xfs/libxfs/xfs_bmap.c54
1 files changed, 29 insertions, 25 deletions
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 99b5fa5c4b8d..e529bed6be41 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -6127,7 +6127,6 @@ xfs_bmap_shift_extents(
6127 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL)); 6127 ASSERT(xfs_isilocked(ip, XFS_IOLOCK_EXCL));
6128 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL)); 6128 ASSERT(xfs_isilocked(ip, XFS_ILOCK_EXCL));
6129 ASSERT(direction == SHIFT_LEFT || direction == SHIFT_RIGHT); 6129 ASSERT(direction == SHIFT_LEFT || direction == SHIFT_RIGHT);
6130 ASSERT(*next_fsb != NULLFSBLOCK || direction == SHIFT_RIGHT);
6131 6130
6132 ifp = XFS_IFORK_PTR(ip, whichfork); 6131 ifp = XFS_IFORK_PTR(ip, whichfork);
6133 if (!(ifp->if_flags & XFS_IFEXTENTS)) { 6132 if (!(ifp->if_flags & XFS_IFEXTENTS)) {
@@ -6159,43 +6158,48 @@ xfs_bmap_shift_extents(
6159 * In case of first right shift, we need to initialize next_fsb 6158 * In case of first right shift, we need to initialize next_fsb
6160 */ 6159 */
6161 if (*next_fsb == NULLFSBLOCK) { 6160 if (*next_fsb == NULLFSBLOCK) {
6162 gotp = xfs_iext_get_ext(ifp, total_extents - 1); 6161 ASSERT(direction == SHIFT_RIGHT);
6162
6163 current_ext = total_extents - 1;
6164 gotp = xfs_iext_get_ext(ifp, current_ext);
6163 xfs_bmbt_get_all(gotp, &got); 6165 xfs_bmbt_get_all(gotp, &got);
6164 *next_fsb = got.br_startoff; 6166 *next_fsb = got.br_startoff;
6165 if (stop_fsb > *next_fsb) { 6167 if (stop_fsb > *next_fsb) {
6166 *done = 1; 6168 *done = 1;
6167 goto del_cursor; 6169 goto del_cursor;
6168 } 6170 }
6171 } else {
6172 /*
6173 * Look up the extent index for the fsb where we start shifting. We can
6174 * henceforth iterate with current_ext as extent list changes are locked
6175 * out via ilock.
6176 *
6177 * gotp can be null in 2 cases: 1) if there are no extents or 2)
6178 * *next_fsb lies in a hole beyond which there are no extents. Either
6179 * way, we are done.
6180 */
6181 gotp = xfs_iext_bno_to_ext(ifp, *next_fsb, &current_ext);
6182 if (!gotp) {
6183 *done = 1;
6184 goto del_cursor;
6185 }
6169 } 6186 }
6170 6187
6171 /* Lookup the extent index at which we have to stop */ 6188 /* Lookup the extent index at which we have to stop */
6172 if (direction == SHIFT_RIGHT) { 6189 if (direction == SHIFT_RIGHT) {
6173 gotp = xfs_iext_bno_to_ext(ifp, stop_fsb, &stop_extent); 6190 xfs_iext_bno_to_ext(ifp, stop_fsb, &stop_extent);
6174 /* Make stop_extent exclusive of shift range */ 6191 /* Make stop_extent exclusive of shift range */
6175 stop_extent--; 6192 stop_extent--;
6176 } else 6193 if (current_ext <= stop_extent) {
6194 error = -EIO;
6195 goto del_cursor;
6196 }
6197 } else {
6177 stop_extent = total_extents; 6198 stop_extent = total_extents;
6178 6199 if (current_ext >= stop_extent) {
6179 /* 6200 error = -EIO;
6180 * Look up the extent index for the fsb where we start shifting. We can 6201 goto del_cursor;
6181 * henceforth iterate with current_ext as extent list changes are locked 6202 }
6182 * out via ilock.
6183 *
6184 * gotp can be null in 2 cases: 1) if there are no extents or 2)
6185 * *next_fsb lies in a hole beyond which there are no extents. Either
6186 * way, we are done.
6187 */
6188 gotp = xfs_iext_bno_to_ext(ifp, *next_fsb, &current_ext);
6189 if (!gotp) {
6190 *done = 1;
6191 goto del_cursor;
6192 }
6193
6194 /* some sanity checking before we finally start shifting extents */
6195 if ((direction == SHIFT_LEFT && current_ext >= stop_extent) ||
6196 (direction == SHIFT_RIGHT && current_ext <= stop_extent)) {
6197 error = -EIO;
6198 goto del_cursor;
6199 } 6203 }
6200 6204
6201 while (nexts++ < num_exts) { 6205 while (nexts++ < num_exts) {