aboutsummaryrefslogtreecommitdiffstats
path: root/fs/xfs/libxfs/xfs_btree.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/xfs/libxfs/xfs_btree.c')
-rw-r--r--fs/xfs/libxfs/xfs_btree.c32
1 files changed, 23 insertions, 9 deletions
diff --git a/fs/xfs/libxfs/xfs_btree.c b/fs/xfs/libxfs/xfs_btree.c
index a0eb18ce3ad3..1f88e1ce770f 100644
--- a/fs/xfs/libxfs/xfs_btree.c
+++ b/fs/xfs/libxfs/xfs_btree.c
@@ -294,6 +294,21 @@ xfs_btree_sblock_verify_crc(
294 return true; 294 return true;
295} 295}
296 296
297static int
298xfs_btree_free_block(
299 struct xfs_btree_cur *cur,
300 struct xfs_buf *bp)
301{
302 int error;
303
304 error = cur->bc_ops->free_block(cur, bp);
305 if (!error) {
306 xfs_trans_binval(cur->bc_tp, bp);
307 XFS_BTREE_STATS_INC(cur, free);
308 }
309 return error;
310}
311
297/* 312/*
298 * Delete the btree cursor. 313 * Delete the btree cursor.
299 */ 314 */
@@ -3209,6 +3224,7 @@ xfs_btree_kill_iroot(
3209 int level; 3224 int level;
3210 int index; 3225 int index;
3211 int numrecs; 3226 int numrecs;
3227 int error;
3212#ifdef DEBUG 3228#ifdef DEBUG
3213 union xfs_btree_ptr ptr; 3229 union xfs_btree_ptr ptr;
3214 int i; 3230 int i;
@@ -3272,8 +3288,6 @@ xfs_btree_kill_iroot(
3272 cpp = xfs_btree_ptr_addr(cur, 1, cblock); 3288 cpp = xfs_btree_ptr_addr(cur, 1, cblock);
3273#ifdef DEBUG 3289#ifdef DEBUG
3274 for (i = 0; i < numrecs; i++) { 3290 for (i = 0; i < numrecs; i++) {
3275 int error;
3276
3277 error = xfs_btree_check_ptr(cur, cpp, i, level - 1); 3291 error = xfs_btree_check_ptr(cur, cpp, i, level - 1);
3278 if (error) { 3292 if (error) {
3279 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); 3293 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
@@ -3283,8 +3297,11 @@ xfs_btree_kill_iroot(
3283#endif 3297#endif
3284 xfs_btree_copy_ptrs(cur, pp, cpp, numrecs); 3298 xfs_btree_copy_ptrs(cur, pp, cpp, numrecs);
3285 3299
3286 cur->bc_ops->free_block(cur, cbp); 3300 error = xfs_btree_free_block(cur, cbp);
3287 XFS_BTREE_STATS_INC(cur, free); 3301 if (error) {
3302 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
3303 return error;
3304 }
3288 3305
3289 cur->bc_bufs[level - 1] = NULL; 3306 cur->bc_bufs[level - 1] = NULL;
3290 be16_add_cpu(&block->bb_level, -1); 3307 be16_add_cpu(&block->bb_level, -1);
@@ -3317,14 +3334,12 @@ xfs_btree_kill_root(
3317 */ 3334 */
3318 cur->bc_ops->set_root(cur, newroot, -1); 3335 cur->bc_ops->set_root(cur, newroot, -1);
3319 3336
3320 error = cur->bc_ops->free_block(cur, bp); 3337 error = xfs_btree_free_block(cur, bp);
3321 if (error) { 3338 if (error) {
3322 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR); 3339 XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
3323 return error; 3340 return error;
3324 } 3341 }
3325 3342
3326 XFS_BTREE_STATS_INC(cur, free);
3327
3328 cur->bc_bufs[level] = NULL; 3343 cur->bc_bufs[level] = NULL;
3329 cur->bc_ra[level] = 0; 3344 cur->bc_ra[level] = 0;
3330 cur->bc_nlevels--; 3345 cur->bc_nlevels--;
@@ -3830,10 +3845,9 @@ xfs_btree_delrec(
3830 } 3845 }
3831 3846
3832 /* Free the deleted block. */ 3847 /* Free the deleted block. */
3833 error = cur->bc_ops->free_block(cur, rbp); 3848 error = xfs_btree_free_block(cur, rbp);
3834 if (error) 3849 if (error)
3835 goto error0; 3850 goto error0;
3836 XFS_BTREE_STATS_INC(cur, free);
3837 3851
3838 /* 3852 /*
3839 * If we joined with the left neighbor, set the buffer in the 3853 * If we joined with the left neighbor, set the buffer in the