]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
xfs: store a generic group structure in the intents
authorChristoph Hellwig <hch@lst.de>
Mon, 4 Nov 2024 04:18:46 +0000 (20:18 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 5 Nov 2024 21:38:30 +0000 (13:38 -0800)
Replace the pag pointers in the extent free, bmap, rmap and refcount
intent structures with a pointer to the generic group to prepare
for adding intents for realtime groups.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Darrick J. Wong <djwong@kernel.org>
12 files changed:
fs/xfs/libxfs/xfs_alloc.h
fs/xfs/libxfs/xfs_bmap.h
fs/xfs/libxfs/xfs_refcount.c
fs/xfs/libxfs/xfs_refcount.h
fs/xfs/libxfs/xfs_rmap.c
fs/xfs/libxfs/xfs_rmap.h
fs/xfs/xfs_bmap_item.c
fs/xfs/xfs_drain.c
fs/xfs/xfs_drain.h
fs/xfs/xfs_extfree_item.c
fs/xfs/xfs_refcount_item.c
fs/xfs/xfs_rmap_item.c

index 88fbce5001185f8e920d6e696360a9d105e2fd21..efbde04fbbb15f1fa63a724002366b532ab2dbaa 100644 (file)
@@ -248,7 +248,7 @@ struct xfs_extent_free_item {
        uint64_t                xefi_owner;
        xfs_fsblock_t           xefi_startblock;/* starting fs block number */
        xfs_extlen_t            xefi_blockcount;/* number of blocks in extent */
-       struct xfs_perag        *xefi_pag;
+       struct xfs_group        *xefi_group;
        unsigned int            xefi_flags;
        enum xfs_ag_resv_type   xefi_agresv;
 };
index 7592d46e97c661136e53978e0052d7f7caa799b8..4b721d9359943b76f742118378b5a18c8bf4a0ae 100644 (file)
@@ -248,7 +248,7 @@ struct xfs_bmap_intent {
        enum xfs_bmap_intent_type               bi_type;
        int                                     bi_whichfork;
        struct xfs_inode                        *bi_owner;
-       struct xfs_perag                        *bi_pag;
+       struct xfs_group                        *bi_group;
        struct xfs_bmbt_irec                    bi_bmap;
 };
 
index ed943f6e616d9645e7ba0ba98d9c1ca6af90d492..2dbab68b4fe69fc6c03566070359b8da593e5d0f 100644 (file)
@@ -1358,7 +1358,7 @@ xfs_refcount_finish_one(
         * If we haven't gotten a cursor or the cursor AG doesn't match
         * the startblock, get one now.
         */
-       if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) {
+       if (rcur != NULL && rcur->bc_group != ri->ri_group) {
                nr_ops = rcur->bc_refc.nr_ops;
                shape_changes = rcur->bc_refc.shape_changes;
                xfs_btree_del_cursor(rcur, 0);
@@ -1366,13 +1366,14 @@ xfs_refcount_finish_one(
                *pcur = NULL;
        }
        if (rcur == NULL) {
-               error = xfs_alloc_read_agf(ri->ri_pag, tp,
+               struct xfs_perag        *pag = to_perag(ri->ri_group);
+
+               error = xfs_alloc_read_agf(pag, tp,
                                XFS_ALLOC_FLAG_FREEING, &agbp);
                if (error)
                        return error;
 
-               *pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp,
-                                                         ri->ri_pag);
+               *pcur = rcur = xfs_refcountbt_init_cursor(mp, tp, agbp, pag);
                rcur->bc_refc.nr_ops = nr_ops;
                rcur->bc_refc.shape_changes = shape_changes;
        }
index 68acb0b1b4a8781598d4bbb8643a7a70f84e19fd..62d78afcf1f3ff2e1569cd85f50c78365f001816 100644 (file)
@@ -56,7 +56,7 @@ enum xfs_refcount_intent_type {
 
 struct xfs_refcount_intent {
        struct list_head                        ri_list;
-       struct xfs_perag                        *ri_pag;
+       struct xfs_group                        *ri_group;
        enum xfs_refcount_intent_type           ri_type;
        xfs_extlen_t                            ri_blockcount;
        xfs_fsblock_t                           ri_startblock;
index 0c404625986163471e290c5ad9eb81ba52fa26f8..d0df68dc31318522e3bf6a89d35ec8f4f377b76f 100644 (file)
@@ -2586,28 +2586,30 @@ xfs_rmap_finish_one(
         * If we haven't gotten a cursor or the cursor AG doesn't match
         * the startblock, get one now.
         */
-       if (rcur != NULL && to_perag(rcur->bc_group) != ri->ri_pag) {
+       if (rcur != NULL && rcur->bc_group != ri->ri_group) {
                xfs_btree_del_cursor(rcur, 0);
                rcur = NULL;
                *pcur = NULL;
        }
        if (rcur == NULL) {
+               struct xfs_perag        *pag = to_perag(ri->ri_group);
+
                /*
                 * Refresh the freelist before we start changing the
                 * rmapbt, because a shape change could cause us to
                 * allocate blocks.
                 */
-               error = xfs_free_extent_fix_freelist(tp, ri->ri_pag, &agbp);
+               error = xfs_free_extent_fix_freelist(tp, pag, &agbp);
                if (error) {
-                       xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL);
+                       xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL);
                        return error;
                }
                if (XFS_IS_CORRUPT(tp->t_mountp, !agbp)) {
-                       xfs_ag_mark_sick(ri->ri_pag, XFS_SICK_AG_AGFL);
+                       xfs_ag_mark_sick(pag, XFS_SICK_AG_AGFL);
                        return -EFSCORRUPTED;
                }
 
-               *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, ri->ri_pag);
+               *pcur = rcur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag);
        }
 
        xfs_rmap_ino_owner(&oinfo, ri->ri_owner, ri->ri_whichfork,
@@ -2620,8 +2622,8 @@ xfs_rmap_finish_one(
        if (error)
                return error;
 
-       xfs_rmap_update_hook(tp, pag_group(ri->ri_pag), ri->ri_type, bno,
-                            ri->ri_bmap.br_blockcount, unwritten, &oinfo);
+       xfs_rmap_update_hook(tp, ri->ri_group, ri->ri_type, bno,
+                       ri->ri_bmap.br_blockcount, unwritten, &oinfo);
        return 0;
 }
 
index d409b463bc666268a5cd313dcef36e0806042d4f..96b4321d831007a64e5d4c050bd0707c3c6205c8 100644 (file)
@@ -173,7 +173,7 @@ struct xfs_rmap_intent {
        int                                     ri_whichfork;
        uint64_t                                ri_owner;
        struct xfs_bmbt_irec                    ri_bmap;
-       struct xfs_perag                        *ri_pag;
+       struct xfs_group                        *ri_group;
 };
 
 /* functions for updating the rmapbt based on bmbt map/unmap operations */
index 35a8c1b8b3cb34e3033ec21363fe71d9f9a1592d..37dab184c2dfc267594a28b769ee7daf7908a443 100644 (file)
@@ -334,7 +334,8 @@ xfs_bmap_update_get_group(
         * intent drops the intent count, ensuring that the intent count
         * remains nonzero across the transaction roll.
         */
-       bi->bi_pag = xfs_perag_intent_get(mp, bi->bi_bmap.br_startblock);
+       bi->bi_group = xfs_group_intent_get(mp, bi->bi_bmap.br_startblock,
+                       XG_TYPE_AG);
 }
 
 /* Add this deferred BUI to the transaction. */
@@ -368,7 +369,7 @@ xfs_bmap_update_put_group(
        if (xfs_ifork_is_realtime(bi->bi_owner, bi->bi_whichfork))
                return;
 
-       xfs_perag_intent_put(bi->bi_pag);
+       xfs_group_intent_put(bi->bi_group);
 }
 
 /* Cancel a deferred bmap update. */
index 7a728a04f7a6b192930135cecf60387555451809..5ede81fadbd8ca6756ae8c163d590ad1657e6c60 100644 (file)
@@ -94,39 +94,39 @@ static inline int xfs_defer_drain_wait(struct xfs_defer_drain *dr)
 }
 
 /*
- * Get a passive reference to the AG that contains a fsbno and declare an
+ * Get a passive reference to the group that contains a fsbno and declare an
  * intent to update its metadata.
  *
  * Other threads that need exclusive access can decide to back off if they see
  * declared intentions.
  */
-struct xfs_perag *
-xfs_perag_intent_get(
+struct xfs_group *
+xfs_group_intent_get(
        struct xfs_mount        *mp,
-       xfs_fsblock_t           fsbno)
+       xfs_fsblock_t           fsbno,
+       enum xfs_group_type     type)
 {
-       struct xfs_perag        *pag;
+       struct xfs_group        *xg;
 
-       pag = xfs_perag_get(mp, XFS_FSB_TO_AGNO(mp, fsbno));
-       if (!pag)
+       xg = xfs_group_get_by_fsb(mp, fsbno, type);
+       if (!xg)
                return NULL;
-
-       trace_xfs_group_intent_hold(pag_group(pag), __return_address);
-       xfs_defer_drain_grab(pag_group(pag).xg_intents_drain);
-       return pag;
+       trace_xfs_group_intent_hold(xg, __return_address);
+       xfs_defer_drain_grab(&xg->xg_intents_drain);
+       return xg;
 }
 
 /*
- * Release our intent to update this AG's metadata, and then release our
- * passive ref to the AG.
+ * Release our intent to update this groups metadata, and then release our
+ * passive ref to it.
  */
 void
-xfs_perag_intent_put(
-       struct xfs_perag        *pag)
+xfs_group_intent_put(
+       struct xfs_group        *xg)
 {
-       trace_xfs_group_intent_rele(pag_group(pag), __return_address);
-       xfs_defer_drain_rele(pag_group(pag).xg_intents_drain);
-       xfs_perag_put(pag);
+       trace_xfs_group_intent_rele(xg, __return_address);
+       xfs_defer_drain_rele(&xg->xg_intents_drain);
+       xfs_group_put(xg);
 }
 
 /*
index 3e6143572e52d2fa5f66b62d5c25f23857b91735..efcf88df9a5e70e5a493341898032777d0729cea 100644 (file)
@@ -62,9 +62,9 @@ void xfs_drain_wait_enable(void);
  * soon as the item is added to the transaction and cannot drop the counter
  * until the item is finished or cancelled.
  */
-struct xfs_perag *xfs_perag_intent_get(struct xfs_mount *mp,
-               xfs_fsblock_t fsbno);
-void xfs_perag_intent_put(struct xfs_perag *pag);
+struct xfs_group *xfs_group_intent_get(struct xfs_mount *mp,
+               xfs_fsblock_t fsbno, enum xfs_group_type type);
+void xfs_group_intent_put(struct xfs_group *rtg);
 
 int xfs_group_intent_drain(struct xfs_group *xg);
 bool xfs_group_intent_busy(struct xfs_group *xg);
@@ -75,9 +75,9 @@ struct xfs_defer_drain { /* empty */ };
 #define xfs_defer_drain_free(dr)               ((void)0)
 #define xfs_defer_drain_init(dr)               ((void)0)
 
-#define xfs_perag_intent_get(mp, fsbno) \
-       xfs_perag_get((mp), XFS_FSB_TO_AGNO(mp, fsbno))
-#define xfs_perag_intent_put(pag)              xfs_perag_put(pag)
+#define xfs_group_intent_get(_mp, _fsbno, _type) \
+       xfs_group_get_by_fsb((_mp), (_fsbno), (_type))
+#define xfs_group_intent_put(xg)               xfs_group_put(xg)
 
 #endif /* CONFIG_XFS_DRAIN_INTENTS */
 
index c198962edea16326b1147af3c916aeab565962a9..e469510986e8d0915dcf94baa1a4f377a85937ab 100644 (file)
@@ -362,7 +362,7 @@ xfs_extent_free_diff_items(
        struct xfs_extent_free_item     *ra = xefi_entry(a);
        struct xfs_extent_free_item     *rb = xefi_entry(b);
 
-       return pag_agno(ra->xefi_pag) - pag_agno(rb->xefi_pag);
+       return ra->xefi_group->xg_gno - rb->xefi_group->xg_gno;
 }
 
 /* Log a free extent to the intent item. */
@@ -447,7 +447,8 @@ xfs_extent_free_defer_add(
 
        trace_xfs_extent_free_defer(mp, xefi);
 
-       xefi->xefi_pag = xfs_perag_intent_get(mp, xefi->xefi_startblock);
+       xefi->xefi_group = xfs_group_intent_get(mp, xefi->xefi_startblock,
+                       XG_TYPE_AG);
        if (xefi->xefi_agresv == XFS_AG_RESV_AGFL)
                *dfpp = xfs_defer_add(tp, &xefi->xefi_list,
                                &xfs_agfl_free_defer_type);
@@ -463,7 +464,7 @@ xfs_extent_free_cancel_item(
 {
        struct xfs_extent_free_item     *xefi = xefi_entry(item);
 
-       xfs_perag_intent_put(xefi->xefi_pag);
+       xfs_group_intent_put(xefi->xefi_group);
        kmem_cache_free(xfs_extfree_item_cache, xefi);
 }
 
@@ -499,7 +500,7 @@ xfs_extent_free_finish_item(
         * in this EFI to the EFD so this works correctly.
         */
        if (!(xefi->xefi_flags & XFS_EFI_CANCELLED))
-               error = __xfs_free_extent(tp, xefi->xefi_pag, agbno,
+               error = __xfs_free_extent(tp, to_perag(xefi->xefi_group), agbno,
                                xefi->xefi_blockcount, &oinfo, xefi->xefi_agresv,
                                xefi->xefi_flags & XFS_EFI_SKIP_DISCARD);
        if (error == -EAGAIN) {
@@ -545,7 +546,7 @@ xfs_agfl_free_finish_item(
 
        trace_xfs_agfl_free_deferred(mp, xefi);
 
-       error = xfs_alloc_read_agf(xefi->xefi_pag, tp, 0, &agbp);
+       error = xfs_alloc_read_agf(to_perag(xefi->xefi_group), tp, 0, &agbp);
        if (!error)
                error = xfs_free_ag_extent(tp, agbp, agbno, 1, &oinfo,
                                XFS_AG_RESV_AGFL);
@@ -578,7 +579,8 @@ xfs_efi_recover_work(
        xefi->xefi_blockcount = extp->ext_len;
        xefi->xefi_agresv = XFS_AG_RESV_NONE;
        xefi->xefi_owner = XFS_RMAP_OWN_UNKNOWN;
-       xefi->xefi_pag = xfs_perag_intent_get(mp, extp->ext_start);
+       xefi->xefi_group = xfs_group_intent_get(mp, extp->ext_start,
+                       XG_TYPE_AG);
 
        xfs_defer_add_item(dfp, &xefi->xefi_list);
 }
index 29f101005f3edabe441b72d33c5d273828433316..bede1c96c330111917166e66dd63942759287ba0 100644 (file)
@@ -244,7 +244,7 @@ xfs_refcount_update_diff_items(
        struct xfs_refcount_intent      *ra = ci_entry(a);
        struct xfs_refcount_intent      *rb = ci_entry(b);
 
-       return pag_agno(ra->ri_pag) - pag_agno(rb->ri_pag);
+       return ra->ri_group->xg_gno - rb->ri_group->xg_gno;
 }
 
 /* Log refcount updates in the intent item. */
@@ -330,7 +330,7 @@ xfs_refcount_defer_add(
 
        trace_xfs_refcount_defer(mp, ri);
 
-       ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_startblock);
+       ri->ri_group = xfs_group_intent_get(mp, ri->ri_startblock, XG_TYPE_AG);
        xfs_defer_add(tp, &ri->ri_list, &xfs_refcount_update_defer_type);
 }
 
@@ -341,7 +341,7 @@ xfs_refcount_update_cancel_item(
 {
        struct xfs_refcount_intent      *ri = ci_entry(item);
 
-       xfs_perag_intent_put(ri->ri_pag);
+       xfs_group_intent_put(ri->ri_group);
        kmem_cache_free(xfs_refcount_intent_cache, ri);
 }
 
@@ -431,7 +431,8 @@ xfs_cui_recover_work(
        ri->ri_type = pmap->pe_flags & XFS_REFCOUNT_EXTENT_TYPE_MASK;
        ri->ri_startblock = pmap->pe_startblock;
        ri->ri_blockcount = pmap->pe_len;
-       ri->ri_pag = xfs_perag_intent_get(mp, pmap->pe_startblock);
+       ri->ri_group = xfs_group_intent_get(mp, pmap->pe_startblock,
+                       XG_TYPE_AG);
 
        xfs_defer_add_item(dfp, &ri->ri_list);
 }
index 1b83d09351f028c6aa9612c5205eb4c4515ac6b9..76b3c0ed3b4f639660ffd40783cc4b2d11d65a97 100644 (file)
@@ -243,7 +243,7 @@ xfs_rmap_update_diff_items(
        struct xfs_rmap_intent          *ra = ri_entry(a);
        struct xfs_rmap_intent          *rb = ri_entry(b);
 
-       return pag_agno(ra->ri_pag) - pag_agno(rb->ri_pag);
+       return ra->ri_group->xg_gno - rb->ri_group->xg_gno;
 }
 
 /* Log rmap updates in the intent item. */
@@ -353,7 +353,8 @@ xfs_rmap_defer_add(
 
        trace_xfs_rmap_defer(mp, ri);
 
-       ri->ri_pag = xfs_perag_intent_get(mp, ri->ri_bmap.br_startblock);
+       ri->ri_group = xfs_group_intent_get(mp, ri->ri_bmap.br_startblock,
+                       XG_TYPE_AG);
        xfs_defer_add(tp, &ri->ri_list, &xfs_rmap_update_defer_type);
 }
 
@@ -364,7 +365,7 @@ xfs_rmap_update_cancel_item(
 {
        struct xfs_rmap_intent          *ri = ri_entry(item);
 
-       xfs_perag_intent_put(ri->ri_pag);
+       xfs_group_intent_put(ri->ri_group);
        kmem_cache_free(xfs_rmap_intent_cache, ri);
 }
 
@@ -494,7 +495,7 @@ xfs_rui_recover_work(
        ri->ri_bmap.br_blockcount = map->me_len;
        ri->ri_bmap.br_state = (map->me_flags & XFS_RMAP_EXTENT_UNWRITTEN) ?
                        XFS_EXT_UNWRITTEN : XFS_EXT_NORM;
-       ri->ri_pag = xfs_perag_intent_get(mp, map->me_startblock);
+       ri->ri_group = xfs_group_intent_get(mp, map->me_startblock, XG_TYPE_AG);
 
        xfs_defer_add_item(dfp, &ri->ri_list);
 }