diff options
author | Darrick J. Wong <darrick.wong@oracle.com> | 2016-08-02 22:26:22 -0400 |
---|---|---|
committer | Dave Chinner <david@fromorbit.com> | 2016-08-02 22:26:22 -0400 |
commit | c1d22ae89cf6086d6a457b3b9241fcb36ebddd14 (patch) | |
tree | 8b587b63557dc80ac1a5a5a432973de8f89c8156 /fs | |
parent | 1f704b2b47822435765aee16f120ae06cc40e78c (diff) |
xfs: in btree_lshift, only allocate temporary cursor when needed
We only need the temporary cursor in _btree_lshift if we're shifting
in an overlapped btree. Therefore, factor that into a single block
of code so we avoid unnecessary cursor duplication.
Also fix use of the wrong cursor when checking for corruption in
xfs_btree_rshift().
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Dave Chinner <dchinner@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/xfs/libxfs/xfs_btree.c | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c index 40c19f82190c..b5c213a051cd 100644 --- a/fs/xfs/libxfs/xfs_btree.c +++ b/fs/xfs/libxfs/xfs_btree.c | |||
@@ -2397,29 +2397,29 @@ xfs_btree_lshift( | |||
2397 | * Using a temporary cursor, update the parent key values of the | 2397 | * Using a temporary cursor, update the parent key values of the |
2398 | * block on the left. | 2398 | * block on the left. |
2399 | */ | 2399 | */ |
2400 | error = xfs_btree_dup_cursor(cur, &tcur); | 2400 | if (cur->bc_flags & XFS_BTREE_OVERLAPPING) { |
2401 | if (error) | 2401 | error = xfs_btree_dup_cursor(cur, &tcur); |
2402 | goto error0; | 2402 | if (error) |
2403 | i = xfs_btree_firstrec(tcur, level); | 2403 | goto error0; |
2404 | XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0); | 2404 | i = xfs_btree_firstrec(tcur, level); |
2405 | 2405 | XFS_WANT_CORRUPTED_GOTO(tcur->bc_mp, i == 1, error0); | |
2406 | error = xfs_btree_decrement(tcur, level, &i); | ||
2407 | if (error) | ||
2408 | goto error1; | ||
2409 | 2406 | ||
2410 | /* Update the parent keys of the right block. */ | 2407 | error = xfs_btree_decrement(tcur, level, &i); |
2411 | error = xfs_btree_update_keys(cur, level); | 2408 | if (error) |
2412 | if (error) | 2409 | goto error1; |
2413 | goto error1; | ||
2414 | 2410 | ||
2415 | /* Update the parent high keys of the left block, if needed. */ | 2411 | /* Update the parent high keys of the left block, if needed. */ |
2416 | if (tcur->bc_flags & XFS_BTREE_OVERLAPPING) { | ||
2417 | error = xfs_btree_update_keys(tcur, level); | 2412 | error = xfs_btree_update_keys(tcur, level); |
2418 | if (error) | 2413 | if (error) |
2419 | goto error1; | 2414 | goto error1; |
2415 | |||
2416 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | ||
2420 | } | 2417 | } |
2421 | 2418 | ||
2422 | xfs_btree_del_cursor(tcur, XFS_BTREE_NOERROR); | 2419 | /* Update the parent keys of the right block. */ |
2420 | error = xfs_btree_update_keys(cur, level); | ||
2421 | if (error) | ||
2422 | goto error0; | ||
2423 | 2423 | ||
2424 | /* Slide the cursor value left one. */ | 2424 | /* Slide the cursor value left one. */ |
2425 | cur->bc_ptrs[level]--; | 2425 | cur->bc_ptrs[level]--; |
@@ -2580,7 +2580,7 @@ xfs_btree_rshift( | |||
2580 | if (error) | 2580 | if (error) |
2581 | goto error0; | 2581 | goto error0; |
2582 | i = xfs_btree_lastrec(tcur, level); | 2582 | i = xfs_btree_lastrec(tcur, level); |
2583 | XFS_WANT_CORRUPTED_GOTO(cur->bc_mp, i == 1, error0); | 2583 | XFS_WANT_CORRUPTED_GOTO(tcur->bc_mp, i == 1, error0); |
2584 | 2584 | ||
2585 | error = xfs_btree_increment(tcur, level, &i); | 2585 | error = xfs_btree_increment(tcur, level, &i); |
2586 | if (error) | 2586 | if (error) |