]> www.infradead.org Git - users/hch/xfs.git/commitdiff
xfs: move the online repair rmap hooks to the generic group structure
authorChristoph Hellwig <hch@lst.de>
Sun, 1 Sep 2024 12:45:33 +0000 (15:45 +0300)
committerChristoph Hellwig <hch@lst.de>
Sun, 22 Sep 2024 05:37:32 +0000 (07:37 +0200)
Prepare for the upcoming realtime groups feature by moving the online
repair rmap hooks to based to the generic xfs_group structure.

Signed-off-by: Christoph Hellwig <hch@lst.de>
fs/xfs/libxfs/xfs_ag.c
fs/xfs/libxfs/xfs_ag.h
fs/xfs/libxfs/xfs_group.c
fs/xfs/libxfs/xfs_group.h
fs/xfs/libxfs/xfs_rmap.c
fs/xfs/libxfs/xfs_rmap.h
fs/xfs/scrub/rmap_repair.c

index 72589f485d9c86b86e962b6a06f8438aa3a1c057..56bc30e53738696f3dc6dca58c4b132d5d5ffcc9 100644 (file)
@@ -212,7 +212,6 @@ xfs_perag_alloc(
        INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
        init_waitqueue_head(&pag->pagb_wait);
        pag->pagb_tree = RB_ROOT;
-       xfs_hooks_init(&pag->pag_rmap_update_hooks);
 #endif /* __KERNEL__ */
 
        error = xfs_buf_cache_init(&pag->pag_bcache);
index 8ec00c6d9bd9e2fb00e590fe47d087dd51f2a127..a8c27906de98a2e1a7ecc5a063dd4c31725593dd 100644 (file)
@@ -96,9 +96,6 @@ struct xfs_perag {
 
        /* background prealloc block trimming */
        struct delayed_work     pag_blockgc_work;
-
-       /* Hook to feed rmapbt updates to an active online repair. */
-       struct xfs_hooks        pag_rmap_update_hooks;
 #endif /* __KERNEL__ */
 };
 
index 6d6d64288e49cfcf9565bb863d942c0ee8208371..50e35d07a915d7362b72e1a8b85deacc14015706 100644 (file)
@@ -186,6 +186,7 @@ xfs_group_insert(
 
 #ifdef __KERNEL__
        spin_lock_init(&xg->xg_state_lock);
+       xfs_hooks_init(&xg->xg_rmap_update_hooks);
 #endif
        xfs_defer_drain_init(&xg->xg_intents_drain);
 
index 3184214310a609c4c6a895dfd39f56d28e829ace..485cc5ce99f03fb33d66aa1bae62c07d24d28d18 100644 (file)
@@ -31,6 +31,11 @@ struct xfs_group {
         * inconsistencies.
         */
        struct xfs_defer_drain  xg_intents_drain;
+
+       /*
+        * Hook to feed rmapbt updates to an active online repair.
+        */
+       struct xfs_hooks        xg_rmap_update_hooks;
 #endif /* __KERNEL__ */
 };
 
index b6764d6b3ab8911462baa4bfdc0ac24ecd82184e..53c4b51c8a8217435e5ec301e7180af9048ffdfe 100644 (file)
@@ -835,7 +835,7 @@ xfs_rmap_hook_enable(void)
 static inline void
 xfs_rmap_update_hook(
        struct xfs_trans                *tp,
-       struct xfs_perag                *pag,
+       struct xfs_group                *xg,
        enum xfs_rmap_intent_type       op,
        xfs_agblock_t                   startblock,
        xfs_extlen_t                    blockcount,
@@ -850,27 +850,27 @@ xfs_rmap_update_hook(
                        .oinfo          = *oinfo, /* struct copy */
                };
 
-               if (pag)
-                       xfs_hooks_call(&pag->pag_rmap_update_hooks, op, &p);
+               if (xg)
+                       xfs_hooks_call(&xg->xg_rmap_update_hooks, op, &p);
        }
 }
 
 /* Call the specified function during a reverse mapping update. */
 int
 xfs_rmap_hook_add(
-       struct xfs_perag        *pag,
+       struct xfs_group        *xg,
        struct xfs_rmap_hook    *hook)
 {
-       return xfs_hooks_add(&pag->pag_rmap_update_hooks, &hook->rmap_hook);
+       return xfs_hooks_add(&xg->xg_rmap_update_hooks, &hook->rmap_hook);
 }
 
 /* Stop calling the specified function during a reverse mapping update. */
 void
 xfs_rmap_hook_del(
-       struct xfs_perag        *pag,
+       struct xfs_group        *xg,
        struct xfs_rmap_hook    *hook)
 {
-       xfs_hooks_del(&pag->pag_rmap_update_hooks, &hook->rmap_hook);
+       xfs_hooks_del(&xg->xg_rmap_update_hooks, &hook->rmap_hook);
 }
 
 /* Configure rmap update hook functions. */
@@ -905,7 +905,8 @@ xfs_rmap_free(
                return 0;
 
        cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag);
-       xfs_rmap_update_hook(tp, pag, XFS_RMAP_UNMAP, bno, len, false, oinfo);
+       xfs_rmap_update_hook(tp, &pag->pag_group, XFS_RMAP_UNMAP, bno, len,
+                       false, oinfo);
        error = xfs_rmap_unmap(cur, bno, len, false, oinfo);
 
        xfs_btree_del_cursor(cur, error);
@@ -1149,7 +1150,8 @@ xfs_rmap_alloc(
                return 0;
 
        cur = xfs_rmapbt_init_cursor(mp, tp, agbp, pag);
-       xfs_rmap_update_hook(tp, pag, XFS_RMAP_MAP, bno, len, false, oinfo);
+       xfs_rmap_update_hook(tp, &pag->pag_group, XFS_RMAP_MAP, bno, len, false,
+                       oinfo);
        error = xfs_rmap_map(cur, bno, len, false, oinfo);
 
        xfs_btree_del_cursor(cur, error);
@@ -2620,7 +2622,7 @@ xfs_rmap_finish_one(
        if (error)
                return error;
 
-       xfs_rmap_update_hook(tp, ri->ri_pag, ri->ri_type, bno,
+       xfs_rmap_update_hook(tp, &ri->ri_pag->pag_group, ri->ri_type, bno,
                        ri->ri_bmap.br_blockcount, unwritten, &oinfo);
        return 0;
 }
index b783dd4dd95d1abe73c4697f50fdd05efb11d518..d409b463bc666268a5cd313dcef36e0806042d4f 100644 (file)
@@ -264,8 +264,8 @@ struct xfs_rmap_hook {
 void xfs_rmap_hook_disable(void);
 void xfs_rmap_hook_enable(void);
 
-int xfs_rmap_hook_add(struct xfs_perag *pag, struct xfs_rmap_hook *hook);
-void xfs_rmap_hook_del(struct xfs_perag *pag, struct xfs_rmap_hook *hook);
+int xfs_rmap_hook_add(struct xfs_group *xg, struct xfs_rmap_hook *hook);
+void xfs_rmap_hook_del(struct xfs_group *xg, struct xfs_rmap_hook *hook);
 void xfs_rmap_hook_setup(struct xfs_rmap_hook *hook, notifier_fn_t mod_fn);
 #endif
 
index f88f58db909867d157927e07b14b3fe3279b68e9..4ab0ae4919c1a81556849075ad2ba2acdaad846d 100644 (file)
@@ -1611,7 +1611,7 @@ xrep_rmap_setup_scan(
         */
        ASSERT(sc->flags & XCHK_FSGATES_RMAP);
        xfs_rmap_hook_setup(&rr->rhook, xrep_rmapbt_live_update);
-       error = xfs_rmap_hook_add(sc->sa.pag, &rr->rhook);
+       error = xfs_rmap_hook_add(&sc->sa.pag->pag_group, &rr->rhook);
        if (error)
                goto out_iscan;
        return 0;
@@ -1632,7 +1632,7 @@ xrep_rmap_teardown(
        struct xfs_scrub        *sc = rr->sc;
 
        xchk_iscan_abort(&rr->iscan);
-       xfs_rmap_hook_del(sc->sa.pag, &rr->rhook);
+       xfs_rmap_hook_del(&sc->sa.pag->pag_group, &rr->rhook);
        xchk_iscan_teardown(&rr->iscan);
        xfbtree_destroy(&rr->rmap_btree);
        mutex_destroy(&rr->lock);