]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: pass transaction lock while setting up agresv on cyclic metadata
authorDarrick J. Wong <darrick.wong@oracle.com>
Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)
committerEric Sandeen <sandeen@redhat.com>
Fri, 5 Oct 2018 02:36:10 +0000 (21:36 -0500)
Source kernel commit: ebcbef3a61a6081ffe20b0b684f18ebbf23f1dfb

Pass a tranaction pointer through to all helpers that calculate the
per-AG block reservation.  Online repair will use this to reinitialize
per-ag reservations while it still holds all the AG headers locked to
the repair transaction.

Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
libxfs/xfs_ag_resv.c
libxfs/xfs_ag_resv.h
libxfs/xfs_ialloc_btree.c
libxfs/xfs_ialloc_btree.h
libxfs/xfs_refcount_btree.c
libxfs/xfs_refcount_btree.h
libxfs/xfs_rmap_btree.c
libxfs/xfs_rmap_btree.h

index fec6a85c0db78a5c90c19b448cf81c20297ba2fb..1544a9e8ec6df164eb8494c99645cb11a7fe3293 100644 (file)
@@ -247,7 +247,8 @@ __xfs_ag_resv_init(
 /* Create a per-AG block reservation. */
 int
 xfs_ag_resv_init(
-       struct xfs_perag                *pag)
+       struct xfs_perag                *pag,
+       struct xfs_trans                *tp)
 {
        struct xfs_mount                *mp = pag->pag_mount;
        xfs_agnumber_t                  agno = pag->pag_agno;
@@ -259,11 +260,11 @@ xfs_ag_resv_init(
        if (pag->pag_meta_resv.ar_asked == 0) {
                ask = used = 0;
 
-               error = xfs_refcountbt_calc_reserves(mp, agno, &ask, &used);
+               error = xfs_refcountbt_calc_reserves(mp, tp, agno, &ask, &used);
                if (error)
                        goto out;
 
-               error = xfs_finobt_calc_reserves(mp, agno, &ask, &used);
+               error = xfs_finobt_calc_reserves(mp, tp, agno, &ask, &used);
                if (error)
                        goto out;
 
@@ -281,7 +282,7 @@ xfs_ag_resv_init(
 
                        mp->m_inotbt_nores = true;
 
-                       error = xfs_refcountbt_calc_reserves(mp, agno, &ask,
+                       error = xfs_refcountbt_calc_reserves(mp, tp, agno, &ask,
                                        &used);
                        if (error)
                                goto out;
@@ -297,7 +298,7 @@ xfs_ag_resv_init(
        if (pag->pag_rmapbt_resv.ar_asked == 0) {
                ask = used = 0;
 
-               error = xfs_rmapbt_calc_reserves(mp, agno, &ask, &used);
+               error = xfs_rmapbt_calc_reserves(mp, tp, agno, &ask, &used);
                if (error)
                        goto out;
 
@@ -308,7 +309,7 @@ xfs_ag_resv_init(
 
 #ifdef DEBUG
        /* need to read in the AGF for the ASSERT below to work */
-       error = xfs_alloc_pagf_init(pag->pag_mount, NULL, pag->pag_agno, 0);
+       error = xfs_alloc_pagf_init(pag->pag_mount, tp, pag->pag_agno, 0);
        if (error)
                return error;
 
index dc953fc84b2fae2253fb15a529baf1aa614d655f..c0352edc8e414e009be788d3e756d34fe3e07915 100644 (file)
@@ -7,7 +7,7 @@
 #define        __XFS_AG_RESV_H__
 
 int xfs_ag_resv_free(struct xfs_perag *pag);
-int xfs_ag_resv_init(struct xfs_perag *pag);
+int xfs_ag_resv_init(struct xfs_perag *pag, struct xfs_trans *tp);
 
 bool xfs_ag_resv_critical(struct xfs_perag *pag, enum xfs_ag_resv_type type);
 xfs_extlen_t xfs_ag_resv_needed(struct xfs_perag *pag,
index f38170a3d0d9d9d4ae8db426f92f35339f2a4c3f..6c7769ee8e6576277b35f5100437177879fd83b5 100644 (file)
@@ -551,6 +551,7 @@ xfs_inobt_max_size(
 static int
 xfs_inobt_count_blocks(
        struct xfs_mount        *mp,
+       struct xfs_trans        *tp,
        xfs_agnumber_t          agno,
        xfs_btnum_t             btnum,
        xfs_extlen_t            *tree_blocks)
@@ -559,14 +560,14 @@ xfs_inobt_count_blocks(
        struct xfs_btree_cur    *cur;
        int                     error;
 
-       error = xfs_ialloc_read_agi(mp, NULL, agno, &agbp);
+       error = xfs_ialloc_read_agi(mp, tp, agno, &agbp);
        if (error)
                return error;
 
-       cur = xfs_inobt_init_cursor(mp, NULL, agbp, agno, btnum);
+       cur = xfs_inobt_init_cursor(mp, tp, agbp, agno, btnum);
        error = xfs_btree_count_blocks(cur, tree_blocks);
        xfs_btree_del_cursor(cur, error);
-       xfs_buf_relse(agbp);
+       xfs_trans_brelse(tp, agbp);
 
        return error;
 }
@@ -577,6 +578,7 @@ xfs_inobt_count_blocks(
 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)
@@ -587,7 +589,7 @@ xfs_finobt_calc_reserves(
        if (!xfs_sb_version_hasfinobt(&mp->m_sb))
                return 0;
 
-       error = xfs_inobt_count_blocks(mp, agno, XFS_BTNUM_FINO, &tree_len);
+       error = xfs_inobt_count_blocks(mp, tp, agno, XFS_BTNUM_FINO, &tree_len);
        if (error)
                return error;
 
index bf8f0c405e7d2cd8e037618a47abfcab64a728a2..ebdd0c6b8766228bdd04b6ad854413a15c88ee62 100644 (file)
@@ -60,8 +60,8 @@ int xfs_inobt_rec_check_count(struct xfs_mount *,
 #define xfs_inobt_rec_check_count(mp, rec)     0
 #endif /* DEBUG */
 
-int xfs_finobt_calc_reserves(struct xfs_mount *mp, xfs_agnumber_t agno,
-               xfs_extlen_t *ask, xfs_extlen_t *used);
+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);
 extern xfs_extlen_t xfs_iallocbt_calc_size(struct xfs_mount *mp,
                unsigned long long len);
 
index 04eb0232c5cbfc586a435aee971a65a568dc7961..864b70cf17865a0b5e7da1df83524f107150e13c 100644 (file)
@@ -403,6 +403,7 @@ xfs_refcountbt_max_size(
 int
 xfs_refcountbt_calc_reserves(
        struct xfs_mount        *mp,
+       struct xfs_trans        *tp,
        xfs_agnumber_t          agno,
        xfs_extlen_t            *ask,
        xfs_extlen_t            *used)
@@ -417,14 +418,14 @@ xfs_refcountbt_calc_reserves(
                return 0;
 
 
-       error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
+       error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
        if (error)
                return error;
 
        agf = XFS_BUF_TO_AGF(agbp);
        agblocks = be32_to_cpu(agf->agf_length);
        tree_len = be32_to_cpu(agf->agf_refcount_blocks);
-       xfs_buf_relse(agbp);
+       xfs_trans_brelse(tp, agbp);
 
        *ask += xfs_refcountbt_max_size(mp, agblocks);
        *used += tree_len;
index 801c2c7732fd7985e8ff0c230718f6aaa49764dd..ba416f71c82472128b922bc25efbc0e5d70ea627 100644 (file)
@@ -55,6 +55,7 @@ extern xfs_extlen_t xfs_refcountbt_max_size(struct xfs_mount *mp,
                xfs_agblock_t agblocks);
 
 extern int xfs_refcountbt_calc_reserves(struct xfs_mount *mp,
-               xfs_agnumber_t agno, xfs_extlen_t *ask, xfs_extlen_t *used);
+               struct xfs_trans *tp, xfs_agnumber_t agno, xfs_extlen_t *ask,
+               xfs_extlen_t *used);
 
 #endif /* __XFS_REFCOUNT_BTREE_H__ */
index bee158e58dc2359906801f6be04a1d6d04de6a65..cd81bbc22493e8d78fef3fff5eafb6ad2f706e57 100644 (file)
@@ -552,6 +552,7 @@ xfs_rmapbt_max_size(
 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)
@@ -565,14 +566,14 @@ xfs_rmapbt_calc_reserves(
        if (!xfs_sb_version_hasrmapbt(&mp->m_sb))
                return 0;
 
-       error = xfs_alloc_read_agf(mp, NULL, agno, 0, &agbp);
+       error = xfs_alloc_read_agf(mp, tp, agno, 0, &agbp);
        if (error)
                return error;
 
        agf = XFS_BUF_TO_AGF(agbp);
        agblocks = be32_to_cpu(agf->agf_length);
        tree_len = be32_to_cpu(agf->agf_rmap_blocks);
-       xfs_buf_relse(agbp);
+       xfs_trans_brelse(tp, agbp);
 
        /* Reserve 1% of the AG or enough for 1 block per record. */
        *ask += max(agblocks / 100, xfs_rmapbt_max_size(mp, agblocks));
index 35b5d06e41a2761ce4eca30096e72d1d7e8d82ab..1cf1336f626c596c25663265ca97ea66b8ace04f 100644 (file)
@@ -51,7 +51,7 @@ extern xfs_extlen_t xfs_rmapbt_calc_size(struct xfs_mount *mp,
 extern xfs_extlen_t xfs_rmapbt_max_size(struct xfs_mount *mp,
                xfs_agblock_t agblocks);
 
-extern int xfs_rmapbt_calc_reserves(struct xfs_mount *mp,
+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);
 
 #endif /* __XFS_RMAP_BTREE_H__ */