Commit 21592863 authored by Brian Foster's avatar Brian Foster Committed by Darrick J. Wong

xfs: rename agfl perag res type to rmapbt

The AGFL perag reservation type accounts all allocations that feed
into (or are released from) the allocation group free list (agfl).
The purpose of the reservation is to support worst case conditions
for the reverse mapping btree (rmapbt). As such, the agfl
reservation usage accounting only considers rmapbt usage when the
in-core counters are initialized at mount time.

This implementation inconsistency leads to divergence of the in-core
and on-disk usage accounting over time. In preparation to resolve
this inconsistency and adjust the AGFL reservation into an rmapbt
specific reservation, rename the AGFL reservation type and
associated accounting fields to something more rmapbt-specific. Also
fix up a couple tracepoints that incorrectly use the AGFL
reservation type to pass the agfl state of the associated extent
where the raw reservation type is expected.

Note that this patch does not change perag reservation behavior.
Signed-off-by: default avatarBrian Foster <bfoster@redhat.com>
Reviewed-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: default avatarDarrick J. Wong <darrick.wong@oracle.com>
parent b3fed434
...@@ -95,13 +95,13 @@ xfs_ag_resv_critical( ...@@ -95,13 +95,13 @@ xfs_ag_resv_critical(
switch (type) { switch (type) {
case XFS_AG_RESV_METADATA: case XFS_AG_RESV_METADATA:
avail = pag->pagf_freeblks - pag->pag_agfl_resv.ar_reserved; avail = pag->pagf_freeblks - pag->pag_rmapbt_resv.ar_reserved;
orig = pag->pag_meta_resv.ar_asked; orig = pag->pag_meta_resv.ar_asked;
break; break;
case XFS_AG_RESV_AGFL: case XFS_AG_RESV_RMAPBT:
avail = pag->pagf_freeblks + pag->pagf_flcount - avail = pag->pagf_freeblks + pag->pagf_flcount -
pag->pag_meta_resv.ar_reserved; pag->pag_meta_resv.ar_reserved;
orig = pag->pag_agfl_resv.ar_asked; orig = pag->pag_rmapbt_resv.ar_asked;
break; break;
default: default:
ASSERT(0); ASSERT(0);
...@@ -126,10 +126,10 @@ xfs_ag_resv_needed( ...@@ -126,10 +126,10 @@ xfs_ag_resv_needed(
{ {
xfs_extlen_t len; xfs_extlen_t len;
len = pag->pag_meta_resv.ar_reserved + pag->pag_agfl_resv.ar_reserved; len = pag->pag_meta_resv.ar_reserved + pag->pag_rmapbt_resv.ar_reserved;
switch (type) { switch (type) {
case XFS_AG_RESV_METADATA: case XFS_AG_RESV_METADATA:
case XFS_AG_RESV_AGFL: case XFS_AG_RESV_RMAPBT:
len -= xfs_perag_resv(pag, type)->ar_reserved; len -= xfs_perag_resv(pag, type)->ar_reserved;
break; break;
case XFS_AG_RESV_NONE: case XFS_AG_RESV_NONE:
...@@ -160,10 +160,11 @@ __xfs_ag_resv_free( ...@@ -160,10 +160,11 @@ __xfs_ag_resv_free(
if (pag->pag_agno == 0) if (pag->pag_agno == 0)
pag->pag_mount->m_ag_max_usable += resv->ar_asked; pag->pag_mount->m_ag_max_usable += resv->ar_asked;
/* /*
* AGFL blocks are always considered "free", so whatever * RMAPBT blocks come from the AGFL and AGFL blocks are always
* was reserved at mount time must be given back at umount. * considered "free", so whatever was reserved at mount time must be
* given back at umount.
*/ */
if (type == XFS_AG_RESV_AGFL) if (type == XFS_AG_RESV_RMAPBT)
oldresv = resv->ar_orig_reserved; oldresv = resv->ar_orig_reserved;
else else
oldresv = resv->ar_reserved; oldresv = resv->ar_reserved;
...@@ -185,7 +186,7 @@ xfs_ag_resv_free( ...@@ -185,7 +186,7 @@ xfs_ag_resv_free(
int error; int error;
int err2; int err2;
error = __xfs_ag_resv_free(pag, XFS_AG_RESV_AGFL); error = __xfs_ag_resv_free(pag, XFS_AG_RESV_RMAPBT);
err2 = __xfs_ag_resv_free(pag, XFS_AG_RESV_METADATA); err2 = __xfs_ag_resv_free(pag, XFS_AG_RESV_METADATA);
if (err2 && !error) if (err2 && !error)
error = err2; error = err2;
...@@ -284,15 +285,15 @@ xfs_ag_resv_init( ...@@ -284,15 +285,15 @@ xfs_ag_resv_init(
} }
} }
/* Create the AGFL metadata reservation */ /* Create the RMAPBT metadata reservation */
if (pag->pag_agfl_resv.ar_asked == 0) { if (pag->pag_rmapbt_resv.ar_asked == 0) {
ask = used = 0; ask = used = 0;
error = xfs_rmapbt_calc_reserves(mp, agno, &ask, &used); error = xfs_rmapbt_calc_reserves(mp, agno, &ask, &used);
if (error) if (error)
goto out; goto out;
error = __xfs_ag_resv_init(pag, XFS_AG_RESV_AGFL, ask, used); error = __xfs_ag_resv_init(pag, XFS_AG_RESV_RMAPBT, ask, used);
if (error) if (error)
goto out; goto out;
} }
...@@ -304,7 +305,7 @@ xfs_ag_resv_init( ...@@ -304,7 +305,7 @@ xfs_ag_resv_init(
return error; return error;
ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved + ASSERT(xfs_perag_resv(pag, XFS_AG_RESV_METADATA)->ar_reserved +
xfs_perag_resv(pag, XFS_AG_RESV_AGFL)->ar_reserved <= xfs_perag_resv(pag, XFS_AG_RESV_RMAPBT)->ar_reserved <=
pag->pagf_freeblks + pag->pagf_flcount); pag->pagf_freeblks + pag->pagf_flcount);
#endif #endif
out: out:
...@@ -326,7 +327,7 @@ xfs_ag_resv_alloc_extent( ...@@ -326,7 +327,7 @@ xfs_ag_resv_alloc_extent(
switch (type) { switch (type) {
case XFS_AG_RESV_METADATA: case XFS_AG_RESV_METADATA:
case XFS_AG_RESV_AGFL: case XFS_AG_RESV_RMAPBT:
resv = xfs_perag_resv(pag, type); resv = xfs_perag_resv(pag, type);
break; break;
default: default:
...@@ -341,7 +342,7 @@ xfs_ag_resv_alloc_extent( ...@@ -341,7 +342,7 @@ xfs_ag_resv_alloc_extent(
len = min_t(xfs_extlen_t, args->len, resv->ar_reserved); len = min_t(xfs_extlen_t, args->len, resv->ar_reserved);
resv->ar_reserved -= len; resv->ar_reserved -= len;
if (type == XFS_AG_RESV_AGFL) if (type == XFS_AG_RESV_RMAPBT)
return; return;
/* Allocations of reserved blocks only need on-disk sb updates... */ /* Allocations of reserved blocks only need on-disk sb updates... */
xfs_trans_mod_sb(args->tp, XFS_TRANS_SB_RES_FDBLOCKS, -(int64_t)len); xfs_trans_mod_sb(args->tp, XFS_TRANS_SB_RES_FDBLOCKS, -(int64_t)len);
...@@ -366,7 +367,7 @@ xfs_ag_resv_free_extent( ...@@ -366,7 +367,7 @@ xfs_ag_resv_free_extent(
switch (type) { switch (type) {
case XFS_AG_RESV_METADATA: case XFS_AG_RESV_METADATA:
case XFS_AG_RESV_AGFL: case XFS_AG_RESV_RMAPBT:
resv = xfs_perag_resv(pag, type); resv = xfs_perag_resv(pag, type);
break; break;
default: default:
...@@ -379,7 +380,7 @@ xfs_ag_resv_free_extent( ...@@ -379,7 +380,7 @@ xfs_ag_resv_free_extent(
leftover = min_t(xfs_extlen_t, len, resv->ar_asked - resv->ar_reserved); leftover = min_t(xfs_extlen_t, len, resv->ar_asked - resv->ar_reserved);
resv->ar_reserved += leftover; resv->ar_reserved += leftover;
if (type == XFS_AG_RESV_AGFL) if (type == XFS_AG_RESV_RMAPBT)
return; return;
/* Freeing into the reserved pool only requires on-disk update... */ /* Freeing into the reserved pool only requires on-disk update... */
xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FDBLOCKS, len); xfs_trans_mod_sb(tp, XFS_TRANS_SB_RES_FDBLOCKS, len);
......
...@@ -728,7 +728,7 @@ xfs_alloc_ag_vextent( ...@@ -728,7 +728,7 @@ xfs_alloc_ag_vextent(
ASSERT(args->len >= args->minlen); ASSERT(args->len >= args->minlen);
ASSERT(args->len <= args->maxlen); ASSERT(args->len <= args->maxlen);
ASSERT(!args->wasfromfl || args->resv != XFS_AG_RESV_AGFL); ASSERT(!args->wasfromfl || args->resv != XFS_AG_RESV_RMAPBT);
ASSERT(args->agbno % args->alignment == 0); ASSERT(args->agbno % args->alignment == 0);
/* if not file data, insert new block into the reverse map btree */ /* if not file data, insert new block into the reverse map btree */
...@@ -1600,7 +1600,7 @@ xfs_alloc_ag_vextent_small( ...@@ -1600,7 +1600,7 @@ xfs_alloc_ag_vextent_small(
* freelist. * freelist.
*/ */
else if (args->minlen == 1 && args->alignment == 1 && else if (args->minlen == 1 && args->alignment == 1 &&
args->resv != XFS_AG_RESV_AGFL && args->resv != XFS_AG_RESV_RMAPBT &&
(be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount)
> args->minleft)) { > args->minleft)) {
error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno, 0); error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno, 0);
...@@ -1634,7 +1634,7 @@ xfs_alloc_ag_vextent_small( ...@@ -1634,7 +1634,7 @@ xfs_alloc_ag_vextent_small(
* If we're feeding an AGFL block to something that * If we're feeding an AGFL block to something that
* doesn't live in the free space, we need to clear * doesn't live in the free space, we need to clear
* out the OWN_AG rmap and add the block back to * out the OWN_AG rmap and add the block back to
* the AGFL per-AG reservation. * the RMAPBT per-AG reservation.
*/ */
xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG); xfs_rmap_ag_owner(&oinfo, XFS_RMAP_OWN_AG);
error = xfs_rmap_free(args->tp, args->agbp, args->agno, error = xfs_rmap_free(args->tp, args->agbp, args->agno,
...@@ -1642,7 +1642,7 @@ xfs_alloc_ag_vextent_small( ...@@ -1642,7 +1642,7 @@ xfs_alloc_ag_vextent_small(
if (error) if (error)
goto error0; goto error0;
pag = xfs_perag_get(args->mp, args->agno); pag = xfs_perag_get(args->mp, args->agno);
xfs_ag_resv_free_extent(pag, XFS_AG_RESV_AGFL, xfs_ag_resv_free_extent(pag, XFS_AG_RESV_RMAPBT,
args->tp, 1); args->tp, 1);
xfs_perag_put(pag); xfs_perag_put(pag);
...@@ -1928,14 +1928,12 @@ xfs_free_ag_extent( ...@@ -1928,14 +1928,12 @@ xfs_free_ag_extent(
XFS_STATS_INC(mp, xs_freex); XFS_STATS_INC(mp, xs_freex);
XFS_STATS_ADD(mp, xs_freeb, len); XFS_STATS_ADD(mp, xs_freeb, len);
trace_xfs_free_extent(mp, agno, bno, len, type == XFS_AG_RESV_AGFL, trace_xfs_free_extent(mp, agno, bno, len, type, haveleft, haveright);
haveleft, haveright);
return 0; return 0;
error0: error0:
trace_xfs_free_extent(mp, agno, bno, len, type == XFS_AG_RESV_AGFL, trace_xfs_free_extent(mp, agno, bno, len, type, -1, -1);
-1, -1);
if (bno_cur) if (bno_cur)
xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR); xfs_btree_del_cursor(bno_cur, XFS_BTREE_ERROR);
if (cnt_cur) if (cnt_cur)
...@@ -2172,7 +2170,7 @@ xfs_alloc_fix_freelist( ...@@ -2172,7 +2170,7 @@ xfs_alloc_fix_freelist(
if (error) if (error)
goto out_agbp_relse; goto out_agbp_relse;
error = xfs_free_ag_extent(tp, agbp, args->agno, bno, 1, error = xfs_free_ag_extent(tp, agbp, args->agno, bno, 1,
&targs.oinfo, XFS_AG_RESV_AGFL); &targs.oinfo, XFS_AG_RESV_RMAPBT);
if (error) if (error)
goto out_agbp_relse; goto out_agbp_relse;
bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0); bp = xfs_btree_get_bufs(mp, tp, args->agno, bno, 0);
...@@ -2198,7 +2196,7 @@ xfs_alloc_fix_freelist( ...@@ -2198,7 +2196,7 @@ xfs_alloc_fix_freelist(
while (pag->pagf_flcount < need) { while (pag->pagf_flcount < need) {
targs.agbno = 0; targs.agbno = 0;
targs.maxlen = need - pag->pagf_flcount; targs.maxlen = need - pag->pagf_flcount;
targs.resv = XFS_AG_RESV_AGFL; targs.resv = XFS_AG_RESV_RMAPBT;
/* Allocate as many blocks as possible at once. */ /* Allocate as many blocks as possible at once. */
error = xfs_alloc_ag_vextent(&targs); error = xfs_alloc_ag_vextent(&targs);
...@@ -2879,7 +2877,7 @@ xfs_free_extent( ...@@ -2879,7 +2877,7 @@ xfs_free_extent(
int error; int error;
ASSERT(len != 0); ASSERT(len != 0);
ASSERT(type != XFS_AG_RESV_AGFL); ASSERT(type != XFS_AG_RESV_RMAPBT);
if (XFS_TEST_ERROR(false, mp, if (XFS_TEST_ERROR(false, mp,
XFS_ERRTAG_FREE_EXTENT)) XFS_ERRTAG_FREE_EXTENT))
......
...@@ -326,7 +326,7 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d) ...@@ -326,7 +326,7 @@ xfs_daddr_to_agbno(struct xfs_mount *mp, xfs_daddr_t d)
enum xfs_ag_resv_type { enum xfs_ag_resv_type {
XFS_AG_RESV_NONE = 0, XFS_AG_RESV_NONE = 0,
XFS_AG_RESV_METADATA, XFS_AG_RESV_METADATA,
XFS_AG_RESV_AGFL, XFS_AG_RESV_RMAPBT,
}; };
struct xfs_ag_resv { struct xfs_ag_resv {
...@@ -390,8 +390,8 @@ typedef struct xfs_perag { ...@@ -390,8 +390,8 @@ typedef struct xfs_perag {
/* Blocks reserved for all kinds of metadata. */ /* Blocks reserved for all kinds of metadata. */
struct xfs_ag_resv pag_meta_resv; struct xfs_ag_resv pag_meta_resv;
/* Blocks reserved for just AGFL-based metadata. */ /* Blocks reserved for the reverse mapping btree. */
struct xfs_ag_resv pag_agfl_resv; struct xfs_ag_resv pag_rmapbt_resv;
/* reference count */ /* reference count */
uint8_t pagf_refcount_level; uint8_t pagf_refcount_level;
...@@ -405,8 +405,8 @@ xfs_perag_resv( ...@@ -405,8 +405,8 @@ xfs_perag_resv(
switch (type) { switch (type) {
case XFS_AG_RESV_METADATA: case XFS_AG_RESV_METADATA:
return &pag->pag_meta_resv; return &pag->pag_meta_resv;
case XFS_AG_RESV_AGFL: case XFS_AG_RESV_RMAPBT:
return &pag->pag_agfl_resv; return &pag->pag_rmapbt_resv;
default: default:
return NULL; return NULL;
} }
......
...@@ -1061,7 +1061,7 @@ xfs_reflink_ag_has_free_space( ...@@ -1061,7 +1061,7 @@ xfs_reflink_ag_has_free_space(
return 0; return 0;
pag = xfs_perag_get(mp, agno); pag = xfs_perag_get(mp, agno);
if (xfs_ag_resv_critical(pag, XFS_AG_RESV_AGFL) || if (xfs_ag_resv_critical(pag, XFS_AG_RESV_RMAPBT) ||
xfs_ag_resv_critical(pag, XFS_AG_RESV_METADATA)) xfs_ag_resv_critical(pag, XFS_AG_RESV_METADATA))
error = -ENOSPC; error = -ENOSPC;
xfs_perag_put(pag); xfs_perag_put(pag);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment