xfs: factor btree block freeing into a helper
authorChristoph Hellwig <hch@lst.de>
Mon, 8 Feb 2016 03:58:07 +0000 (14:58 +1100)
committerDave Chinner <david@fromorbit.com>
Mon, 8 Feb 2016 03:58:07 +0000 (14:58 +1100)
Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Dave Chinner <david@fromorbit.com>
fs/xfs/libxfs/xfs_btree.c

index 3143577930bd2d7e1cd79397101b3e2b3e369241..77afb4a899b9d2fea1c08dc75d1a50879a0a650e 100644 (file)
@@ -294,6 +294,19 @@ xfs_btree_sblock_verify_crc(
        return true;
 }
 
+static int
+xfs_btree_free_block(
+       struct xfs_btree_cur    *cur,
+       struct xfs_buf          *bp)
+{
+       int                     error;
+
+       error = cur->bc_ops->free_block(cur, bp);
+       if (!error)
+               XFS_BTREE_STATS_INC(cur, free);
+       return error;
+}
+
 /*
  * Delete the btree cursor.
  */
@@ -3282,12 +3295,11 @@ xfs_btree_kill_iroot(
 #endif
        xfs_btree_copy_ptrs(cur, pp, cpp, numrecs);
 
-       error = cur->bc_ops->free_block(cur, cbp);
+       error = xfs_btree_free_block(cur, cbp);
        if (error) {
                XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
                return error;
        }
-       XFS_BTREE_STATS_INC(cur, free);
 
        cur->bc_bufs[level - 1] = NULL;
        be16_add_cpu(&block->bb_level, -1);
@@ -3320,14 +3332,12 @@ xfs_btree_kill_root(
         */
        cur->bc_ops->set_root(cur, newroot, -1);
 
-       error = cur->bc_ops->free_block(cur, bp);
+       error = xfs_btree_free_block(cur, bp);
        if (error) {
                XFS_BTREE_TRACE_CURSOR(cur, XBT_ERROR);
                return error;
        }
 
-       XFS_BTREE_STATS_INC(cur, free);
-
        cur->bc_bufs[level] = NULL;
        cur->bc_ra[level] = 0;
        cur->bc_nlevels--;
@@ -3833,10 +3843,9 @@ xfs_btree_delrec(
        }
 
        /* Free the deleted block. */
-       error = cur->bc_ops->free_block(cur, rbp);
+       error = xfs_btree_free_block(cur, rbp);
        if (error)
                goto error0;
-       XFS_BTREE_STATS_INC(cur, free);
 
        /*
         * If we joined with the left neighbor, set the buffer in the