Skip to content

Commit 7272f77

Browse files
Christoph HellwigDarrick J. Wong
authored andcommitted
xfs: remove xfs_defer_agfl_block
xfs_free_extent_later can handle the extra AGFL special casing with very little extra logic. Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: Darrick J. Wong <[email protected]> Signed-off-by: Darrick J. Wong <[email protected]>
1 parent 851a678 commit 7272f77

File tree

1 file changed

+22
-46
lines changed

1 file changed

+22
-46
lines changed

fs/xfs/libxfs/xfs_alloc.c

Lines changed: 22 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2509,48 +2509,6 @@ xfs_agfl_reset(
25092509
clear_bit(XFS_AGSTATE_AGFL_NEEDS_RESET, &pag->pag_opstate);
25102510
}
25112511

2512-
/*
2513-
* Defer an AGFL block free. This is effectively equivalent to
2514-
* xfs_free_extent_later() with some special handling particular to AGFL blocks.
2515-
*
2516-
* Deferring AGFL frees helps prevent log reservation overruns due to too many
2517-
* allocation operations in a transaction. AGFL frees are prone to this problem
2518-
* because for one they are always freed one at a time. Further, an immediate
2519-
* AGFL block free can cause a btree join and require another block free before
2520-
* the real allocation can proceed. Deferring the free disconnects freeing up
2521-
* the AGFL slot from freeing the block.
2522-
*/
2523-
static int
2524-
xfs_defer_agfl_block(
2525-
struct xfs_trans *tp,
2526-
xfs_agnumber_t agno,
2527-
xfs_agblock_t agbno,
2528-
struct xfs_owner_info *oinfo)
2529-
{
2530-
struct xfs_mount *mp = tp->t_mountp;
2531-
struct xfs_extent_free_item *xefi;
2532-
xfs_fsblock_t fsbno = XFS_AGB_TO_FSB(mp, agno, agbno);
2533-
2534-
ASSERT(xfs_extfree_item_cache != NULL);
2535-
ASSERT(oinfo != NULL);
2536-
2537-
if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbno(mp, fsbno)))
2538-
return -EFSCORRUPTED;
2539-
2540-
xefi = kmem_cache_zalloc(xfs_extfree_item_cache,
2541-
GFP_KERNEL | __GFP_NOFAIL);
2542-
xefi->xefi_startblock = fsbno;
2543-
xefi->xefi_blockcount = 1;
2544-
xefi->xefi_owner = oinfo->oi_owner;
2545-
xefi->xefi_agresv = XFS_AG_RESV_AGFL;
2546-
2547-
trace_xfs_agfl_free_defer(mp, xefi);
2548-
2549-
xfs_extent_free_get_group(mp, xefi);
2550-
xfs_defer_add(tp, &xefi->xefi_list, &xfs_agfl_free_defer_type);
2551-
return 0;
2552-
}
2553-
25542512
/*
25552513
* Add the extent to the list of extents to be free at transaction end.
25562514
* The list is maintained sorted (by block number).
@@ -2571,7 +2529,6 @@ xfs_defer_extent_free(
25712529
ASSERT(len <= XFS_MAX_BMBT_EXTLEN);
25722530
ASSERT(!isnullstartblock(bno));
25732531
ASSERT(!(free_flags & ~XFS_FREE_EXTENT_ALL_FLAGS));
2574-
ASSERT(type != XFS_AG_RESV_AGFL);
25752532

25762533
if (XFS_IS_CORRUPT(mp, !xfs_verify_fsbext(mp, bno, len)))
25772534
return -EFSCORRUPTED;
@@ -2598,7 +2555,13 @@ xfs_defer_extent_free(
25982555
trace_xfs_extent_free_defer(mp, xefi);
25992556

26002557
xfs_extent_free_get_group(mp, xefi);
2601-
*dfpp = xfs_defer_add(tp, &xefi->xefi_list, &xfs_extent_free_defer_type);
2558+
2559+
if (xefi->xefi_agresv == XFS_AG_RESV_AGFL)
2560+
*dfpp = xfs_defer_add(tp, &xefi->xefi_list,
2561+
&xfs_agfl_free_defer_type);
2562+
else
2563+
*dfpp = xfs_defer_add(tp, &xefi->xefi_list,
2564+
&xfs_extent_free_defer_type);
26022565
return 0;
26032566
}
26042567

@@ -2856,8 +2819,21 @@ xfs_alloc_fix_freelist(
28562819
if (error)
28572820
goto out_agbp_relse;
28582821

2859-
/* defer agfl frees */
2860-
error = xfs_defer_agfl_block(tp, args->agno, bno, &targs.oinfo);
2822+
/*
2823+
* Defer the AGFL block free.
2824+
*
2825+
* This helps to prevent log reservation overruns due to too
2826+
* many allocation operations in a transaction. AGFL frees are
2827+
* prone to this problem because for one they are always freed
2828+
* one at a time. Further, an immediate AGFL block free can
2829+
* cause a btree join and require another block free before the
2830+
* real allocation can proceed.
2831+
* Deferring the free disconnects freeing up the AGFL slot from
2832+
* freeing the block.
2833+
*/
2834+
error = xfs_free_extent_later(tp,
2835+
XFS_AGB_TO_FSB(mp, args->agno, bno), 1,
2836+
&targs.oinfo, XFS_AG_RESV_AGFL, 0);
28612837
if (error)
28622838
goto out_agbp_relse;
28632839
}

0 commit comments

Comments
 (0)