xfs: push perags through the ag reservation callouts
We currently pass an agno from the AG reservation functions to the individual feature accounting functions, which in future may have to do perag lookups to access per-AG state. Instead, pre-emptively plumb the perag through from the highest AG reservation layer to the feature callouts so they won't have to look it up again. Signed-off-by: Dave Chinner <dchinner@redhat.com> Reviewed-by: Darrick J. Wong <djwong@kernel.org> Reviewed-by: Brian Foster <bfoster@redhat.com>
This commit is contained in:
committed by
Dave Chinner
parent
45d0662117
commit
30933120ad
@@ -250,7 +250,6 @@ xfs_ag_resv_init(
|
|||||||
struct xfs_trans *tp)
|
struct xfs_trans *tp)
|
||||||
{
|
{
|
||||||
struct xfs_mount *mp = pag->pag_mount;
|
struct xfs_mount *mp = pag->pag_mount;
|
||||||
xfs_agnumber_t agno = pag->pag_agno;
|
|
||||||
xfs_extlen_t ask;
|
xfs_extlen_t ask;
|
||||||
xfs_extlen_t used;
|
xfs_extlen_t used;
|
||||||
int error = 0, error2;
|
int error = 0, error2;
|
||||||
@@ -260,11 +259,11 @@ xfs_ag_resv_init(
|
|||||||
if (pag->pag_meta_resv.ar_asked == 0) {
|
if (pag->pag_meta_resv.ar_asked == 0) {
|
||||||
ask = used = 0;
|
ask = used = 0;
|
||||||
|
|
||||||
error = xfs_refcountbt_calc_reserves(mp, tp, agno, &ask, &used);
|
error = xfs_refcountbt_calc_reserves(mp, tp, pag, &ask, &used);
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
error = xfs_finobt_calc_reserves(mp, tp, agno, &ask, &used);
|
error = xfs_finobt_calc_reserves(mp, tp, pag, &ask, &used);
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
@@ -282,7 +281,7 @@ xfs_ag_resv_init(
|
|||||||
|
|
||||||
mp->m_finobt_nores = true;
|
mp->m_finobt_nores = true;
|
||||||
|
|
||||||
error = xfs_refcountbt_calc_reserves(mp, tp, agno, &ask,
|
error = xfs_refcountbt_calc_reserves(mp, tp, pag, &ask,
|
||||||
&used);
|
&used);
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
@@ -300,7 +299,7 @@ xfs_ag_resv_init(
|
|||||||
if (pag->pag_rmapbt_resv.ar_asked == 0) {
|
if (pag->pag_rmapbt_resv.ar_asked == 0) {
|
||||||
ask = used = 0;
|
ask = used = 0;
|
||||||
|
|
||||||
error = xfs_rmapbt_calc_reserves(mp, tp, agno, &ask, &used);
|
error = xfs_rmapbt_calc_reserves(mp, tp, pag, &ask, &used);
|
||||||
if (error)
|
if (error)
|
||||||
goto out;
|
goto out;
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,7 @@
|
|||||||
#include "xfs_trace.h"
|
#include "xfs_trace.h"
|
||||||
#include "xfs_trans.h"
|
#include "xfs_trans.h"
|
||||||
#include "xfs_rmap.h"
|
#include "xfs_rmap.h"
|
||||||
|
#include "xfs_ag.h"
|
||||||
|
|
||||||
STATIC int
|
STATIC int
|
||||||
xfs_inobt_get_minrecs(
|
xfs_inobt_get_minrecs(
|
||||||
@@ -680,7 +681,7 @@ static int
|
|||||||
xfs_inobt_count_blocks(
|
xfs_inobt_count_blocks(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
struct xfs_perag *pag,
|
||||||
xfs_btnum_t btnum,
|
xfs_btnum_t btnum,
|
||||||
xfs_extlen_t *tree_blocks)
|
xfs_extlen_t *tree_blocks)
|
||||||
{
|
{
|
||||||
@@ -688,7 +689,7 @@ xfs_inobt_count_blocks(
|
|||||||
struct xfs_btree_cur *cur = NULL;
|
struct xfs_btree_cur *cur = NULL;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = xfs_inobt_cur(mp, tp, agno, btnum, &cur, &agbp);
|
error = xfs_inobt_cur(mp, tp, pag->pag_agno, btnum, &cur, &agbp);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -704,14 +705,14 @@ static int
|
|||||||
xfs_finobt_read_blocks(
|
xfs_finobt_read_blocks(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
struct xfs_perag *pag,
|
||||||
xfs_extlen_t *tree_blocks)
|
xfs_extlen_t *tree_blocks)
|
||||||
{
|
{
|
||||||
struct xfs_buf *agbp;
|
struct xfs_buf *agbp;
|
||||||
struct xfs_agi *agi;
|
struct xfs_agi *agi;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
|
error = xfs_ialloc_read_agi(mp, tp, pag->pag_agno, &agbp);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -728,7 +729,7 @@ int
|
|||||||
xfs_finobt_calc_reserves(
|
xfs_finobt_calc_reserves(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
struct xfs_perag *pag,
|
||||||
xfs_extlen_t *ask,
|
xfs_extlen_t *ask,
|
||||||
xfs_extlen_t *used)
|
xfs_extlen_t *used)
|
||||||
{
|
{
|
||||||
@@ -739,14 +740,14 @@ xfs_finobt_calc_reserves(
|
|||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
|
if (xfs_sb_version_hasinobtcounts(&mp->m_sb))
|
||||||
error = xfs_finobt_read_blocks(mp, tp, agno, &tree_len);
|
error = xfs_finobt_read_blocks(mp, tp, pag, &tree_len);
|
||||||
else
|
else
|
||||||
error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO,
|
error = xfs_inobt_count_blocks(mp, tp, pag, XFS_BTNUM_FINO,
|
||||||
&tree_len);
|
&tree_len);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
*ask += xfs_inobt_max_size(mp, agno);
|
*ask += xfs_inobt_max_size(mp, pag->pag_agno);
|
||||||
*used += tree_len;
|
*used += tree_len;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ int xfs_inobt_rec_check_count(struct xfs_mount *,
|
|||||||
#endif /* DEBUG */
|
#endif /* DEBUG */
|
||||||
|
|
||||||
int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,
|
int xfs_finobt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
|
struct xfs_perag *pag, xfs_extlen_t *ask, xfs_extlen_t *used);
|
||||||
extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
|
extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
|
||||||
unsigned long long len);
|
unsigned long long len);
|
||||||
int xfs_inobt_cur(struct xfs_mount *mp, struct xfs_trans *tp,
|
int xfs_inobt_cur(struct xfs_mount *mp, struct xfs_trans *tp,
|
||||||
|
|||||||
@@ -450,7 +450,7 @@ int
|
|||||||
xfs_refcountbt_calc_reserves(
|
xfs_refcountbt_calc_reserves(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
struct xfs_perag *pag,
|
||||||
xfs_extlen_t *ask,
|
xfs_extlen_t *ask,
|
||||||
xfs_extlen_t *used)
|
xfs_extlen_t *used)
|
||||||
{
|
{
|
||||||
@@ -463,8 +463,7 @@ xfs_refcountbt_calc_reserves(
|
|||||||
if (!xfs_sb_version_hasreflink(&mp->m_sb))
|
if (!xfs_sb_version_hasreflink(&mp->m_sb))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
error = xfs_alloc_read_agf(mp, tp, pag->pag_agno, 0, &agbp);
|
||||||
error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
|
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -479,7 +478,7 @@ xfs_refcountbt_calc_reserves(
|
|||||||
* expansion. We therefore can pretend the space isn't there.
|
* expansion. We therefore can pretend the space isn't there.
|
||||||
*/
|
*/
|
||||||
if (mp->m_sb.sb_logstart &&
|
if (mp->m_sb.sb_logstart &&
|
||||||
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
|
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
|
||||||
agblocks -= mp->m_sb.sb_logblocks;
|
agblocks -= mp->m_sb.sb_logblocks;
|
||||||
|
|
||||||
*ask += xfs_refcountbt_max_size(mp, agblocks);
|
*ask += xfs_refcountbt_max_size(mp, agblocks);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@
|
|||||||
struct xfs_buf;
|
struct xfs_buf;
|
||||||
struct xfs_btree_cur;
|
struct xfs_btree_cur;
|
||||||
struct xfs_mount;
|
struct xfs_mount;
|
||||||
|
struct xfs_perag;
|
||||||
struct xbtree_afakeroot;
|
struct xbtree_afakeroot;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -58,7 +59,7 @@ extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
|
|||||||
xfs_agblock_t agblocks);
|
xfs_agblock_t agblocks);
|
||||||
|
|
||||||
extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
|
extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
|
||||||
struct xfs_trans *tp, xfs_agnumber_t agno, xfs_extlen_t *ask,
|
struct xfs_trans *tp, struct xfs_perag *pag, xfs_extlen_t *ask,
|
||||||
xfs_extlen_t *used);
|
xfs_extlen_t *used);
|
||||||
|
|
||||||
void xfs_refcountbt_commit_staged_btree(struct xfs_btree_cur *cur,
|
void xfs_refcountbt_commit_staged_btree(struct xfs_btree_cur *cur,
|
||||||
|
|||||||
@@ -595,7 +595,7 @@ int
|
|||||||
xfs_rmapbt_calc_reserves(
|
xfs_rmapbt_calc_reserves(
|
||||||
struct xfs_mount *mp,
|
struct xfs_mount *mp,
|
||||||
struct xfs_trans *tp,
|
struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno,
|
struct xfs_perag *pag,
|
||||||
xfs_extlen_t *ask,
|
xfs_extlen_t *ask,
|
||||||
xfs_extlen_t *used)
|
xfs_extlen_t *used)
|
||||||
{
|
{
|
||||||
@@ -608,7 +608,7 @@ xfs_rmapbt_calc_reserves(
|
|||||||
if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
|
if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
|
error = xfs_alloc_read_agf(mp, tp, pag->pag_agno, 0, &agbp);
|
||||||
if (error)
|
if (error)
|
||||||
return error;
|
return error;
|
||||||
|
|
||||||
@@ -623,7 +623,7 @@ xfs_rmapbt_calc_reserves(
|
|||||||
* expansion. We therefore can pretend the space isn't there.
|
* expansion. We therefore can pretend the space isn't there.
|
||||||
*/
|
*/
|
||||||
if (mp->m_sb.sb_logstart &&
|
if (mp->m_sb.sb_logstart &&
|
||||||
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == agno)
|
XFS_FSB_TO_AGNO(mp, mp->m_sb.sb_logstart) == pag->pag_agno)
|
||||||
agblocks -= mp->m_sb.sb_logblocks;
|
agblocks -= mp->m_sb.sb_logblocks;
|
||||||
|
|
||||||
/* Reserve 1% of the AG or enough for 1 block per record. */
|
/* Reserve 1% of the AG or enough for 1 block per record. */
|
||||||
|
|||||||
@@ -57,6 +57,6 @@ extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
|
|||||||
xfs_agblock_t agblocks);
|
xfs_agblock_t agblocks);
|
||||||
|
|
||||||
extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,
|
extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp, struct xfs_trans *tp,
|
||||||
xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
|
struct xfs_perag *pag, xfs_extlen_t *ask, xfs_extlen_t *used);
|
||||||
|
|
||||||
#endif /* __XFS_RMAP_BTREE_H__ */
|
#endif /* __XFS_RMAP_BTREE_H__ */
|
||||||
|
|||||||
Reference in New Issue
Block a user