diff options
Diffstat (limited to 'fs/xfs/libxfs/xfs_refcount.c')
| -rw-r--r-- | fs/xfs/libxfs/xfs_refcount.c | 46 | 
1 files changed, 31 insertions, 15 deletions
| diff --git a/fs/xfs/libxfs/xfs_refcount.c b/fs/xfs/libxfs/xfs_refcount.c index e5d767a7fc5d..327ba25e9e17 100644 --- a/fs/xfs/libxfs/xfs_refcount.c +++ b/fs/xfs/libxfs/xfs_refcount.c @@ -24,6 +24,8 @@  #include "xfs_rmap.h"  #include "xfs_ag.h" +struct kmem_cache	*xfs_refcount_intent_cache; +  /* Allowable refcount adjustment amounts. */  enum xfs_refc_adjust_op {  	XFS_REFCOUNT_ADJUST_INCREASE	= 1, @@ -916,8 +918,7 @@ xfs_refcount_adjust_extents(  	struct xfs_btree_cur	*cur,  	xfs_agblock_t		*agbno,  	xfs_extlen_t		*aglen, -	enum xfs_refc_adjust_op	adj, -	struct xfs_owner_info	*oinfo) +	enum xfs_refc_adjust_op	adj)  {  	struct xfs_refcount_irec	ext, tmp;  	int				error; @@ -974,8 +975,8 @@ xfs_refcount_adjust_extents(  				fsbno = XFS_AGB_TO_FSB(cur->bc_mp,  						cur->bc_ag.pag->pag_agno,  						tmp.rc_startblock); -				xfs_bmap_add_free(cur->bc_tp, fsbno, -						  tmp.rc_blockcount, oinfo); +				xfs_free_extent_later(cur->bc_tp, fsbno, +						  tmp.rc_blockcount, NULL);  			}  			(*agbno) += tmp.rc_blockcount; @@ -1019,8 +1020,8 @@ xfs_refcount_adjust_extents(  			fsbno = XFS_AGB_TO_FSB(cur->bc_mp,  					cur->bc_ag.pag->pag_agno,  					ext.rc_startblock); -			xfs_bmap_add_free(cur->bc_tp, fsbno, ext.rc_blockcount, -					  oinfo); +			xfs_free_extent_later(cur->bc_tp, fsbno, +					ext.rc_blockcount, NULL);  		}  skip: @@ -1048,8 +1049,7 @@ xfs_refcount_adjust(  	xfs_extlen_t		aglen,  	xfs_agblock_t		*new_agbno,  	xfs_extlen_t		*new_aglen, -	enum xfs_refc_adjust_op	adj, -	struct xfs_owner_info	*oinfo) +	enum xfs_refc_adjust_op	adj)  {  	bool			shape_changed;  	int			shape_changes = 0; @@ -1092,8 +1092,7 @@ xfs_refcount_adjust(  		cur->bc_ag.refc.shape_changes++;  	/* Now that we've taken care of the ends, adjust the middle extents */ -	error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen, -			adj, oinfo); +	error = xfs_refcount_adjust_extents(cur, new_agbno, new_aglen, adj);  	if (error)  		goto out_error; @@ -1188,12 +1187,12 @@ xfs_refcount_finish_one(  	switch (type) {  	case XFS_REFCOUNT_INCREASE:  		error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno, -			new_len, XFS_REFCOUNT_ADJUST_INCREASE, NULL); +				new_len, XFS_REFCOUNT_ADJUST_INCREASE);  		*new_fsb = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno);  		break;  	case XFS_REFCOUNT_DECREASE:  		error = xfs_refcount_adjust(rcur, bno, blockcount, &new_agbno, -			new_len, XFS_REFCOUNT_ADJUST_DECREASE, NULL); +				new_len, XFS_REFCOUNT_ADJUST_DECREASE);  		*new_fsb = XFS_AGB_TO_FSB(mp, pag->pag_agno, new_agbno);  		break;  	case XFS_REFCOUNT_ALLOC_COW: @@ -1235,8 +1234,8 @@ __xfs_refcount_add(  			type, XFS_FSB_TO_AGBNO(tp->t_mountp, startblock),  			blockcount); -	ri = kmem_alloc(sizeof(struct xfs_refcount_intent), -			KM_NOFS); +	ri = kmem_cache_alloc(xfs_refcount_intent_cache, +			GFP_NOFS | __GFP_NOFAIL);  	INIT_LIST_HEAD(&ri->ri_list);  	ri->ri_type = type;  	ri->ri_startblock = startblock; @@ -1742,7 +1741,7 @@ xfs_refcount_recover_cow_leftovers(  				rr->rr_rrec.rc_blockcount);  		/* Free the block. */ -		xfs_bmap_add_free(tp, fsb, rr->rr_rrec.rc_blockcount, NULL); +		xfs_free_extent_later(tp, fsb, rr->rr_rrec.rc_blockcount, NULL);  		error = xfs_trans_commit(tp);  		if (error) @@ -1782,3 +1781,20 @@ xfs_refcount_has_record(  	return xfs_btree_has_record(cur, &low, &high, exists);  } + +int __init +xfs_refcount_intent_init_cache(void) +{ +	xfs_refcount_intent_cache = kmem_cache_create("xfs_refc_intent", +			sizeof(struct xfs_refcount_intent), +			0, 0, NULL); + +	return xfs_refcount_intent_cache != NULL ? 0 : -ENOMEM; +} + +void +xfs_refcount_intent_destroy_cache(void) +{ +	kmem_cache_destroy(xfs_refcount_intent_cache); +	xfs_refcount_intent_cache = NULL; +} |