]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
xfs: move draining of deferred operations to the generic group structure
authorChristoph Hellwig <hch@lst.de>
Mon, 25 Nov 2024 21:14:15 +0000 (13:14 -0800)
committerDarrick J. Wong <djwong@kernel.org>
Tue, 24 Dec 2024 02:01:24 +0000 (18:01 -0800)
Source kernel commit: 34cf3a6f3952ecabd54b4fe3d431aa44ce98fe45

Prepare supporting the upcoming realtime groups feature by moving the
deferred operation draining to the generic xfs_group structure.

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>
Reviewed-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_ag.c
libxfs/xfs_ag.h
libxfs/xfs_group.c
libxfs/xfs_group.h

index 20af8b67d86e885e4b82b9df01a8cc7e40665a35..d67e40f49a3fc03404295ead0177ede46992cae2 100644 (file)
@@ -110,7 +110,6 @@ xfs_perag_uninit(
 #ifdef __KERNEL__
        struct xfs_perag        *pag = to_perag(xg);
 
-       xfs_defer_drain_free(&pag->pag_intents_drain);
        cancel_delayed_work_sync(&pag->pag_blockgc_work);
        xfs_buf_cache_destroy(&pag->pag_bcache);
 #endif
@@ -232,7 +231,6 @@ xfs_perag_alloc(
        spin_lock_init(&pag->pagb_lock);
        INIT_DELAYED_WORK(&pag->pag_blockgc_work, xfs_blockgc_worker);
        INIT_RADIX_TREE(&pag->pag_ici_root, GFP_ATOMIC);
-       xfs_defer_drain_init(&pag->pag_intents_drain);
        init_waitqueue_head(&pag->pagb_wait);
        pag->pagb_tree = RB_ROOT;
        xfs_hooks_init(&pag->pag_rmap_update_hooks);
@@ -240,7 +238,7 @@ xfs_perag_alloc(
 
        error = xfs_buf_cache_init(&pag->pag_bcache);
        if (error)
-               goto out_defer_drain_free;
+               goto out_free_perag;
 
        /*
         * Pre-calculated geometry
@@ -258,8 +256,7 @@ xfs_perag_alloc(
 
 out_buf_cache_destroy:
        xfs_buf_cache_destroy(&pag->pag_bcache);
-out_defer_drain_free:
-       xfs_defer_drain_free(&pag->pag_intents_drain);
+out_free_perag:
        kfree(pag);
        return error;
 }
index 8271cb72c88387005e57c383926cd420fe06e2a4..45f8de06cdbc8abf5f56a90f66c484353df83e6c 100644 (file)
@@ -97,15 +97,6 @@ struct xfs_perag {
        /* background prealloc block trimming */
        struct delayed_work     pag_blockgc_work;
 
-       /*
-        * We use xfs_drain to track the number of deferred log intent items
-        * that have been queued (but not yet processed) so that waiters (e.g.
-        * scrub) will not lock resources when other threads are in the middle
-        * of processing a chain of intent items only to find momentary
-        * inconsistencies.
-        */
-       struct xfs_defer_drain  pag_intents_drain;
-
        /* Hook to feed rmapbt updates to an active online repair. */
        struct xfs_hooks        pag_rmap_update_hooks;
 #endif /* __KERNEL__ */
index c5269cd659f327ba10a91f299b7f185169576972..dfcebf2e9b30f85f25f124fac198fafe41a03004 100644 (file)
@@ -159,6 +159,8 @@ xfs_group_free(
 
        XFS_IS_CORRUPT(mp, atomic_read(&xg->xg_ref) != 0);
 
+       xfs_defer_drain_free(&xg->xg_intents_drain);
+
        if (uninit)
                uninit(xg);
 
@@ -184,6 +186,7 @@ xfs_group_insert(
 #ifdef __KERNEL__
        spin_lock_init(&xg->xg_state_lock);
 #endif
+       xfs_defer_drain_init(&xg->xg_intents_drain);
 
        /* Active ref owned by mount indicates group is online. */
        atomic_set(&xg->xg_active_ref, 1);
@@ -191,6 +194,7 @@ xfs_group_insert(
        error = xa_insert(&mp->m_groups[type].xa, index, xg, GFP_KERNEL);
        if (error) {
                WARN_ON_ONCE(error == -EBUSY);
+               xfs_defer_drain_free(&xg->xg_intents_drain);
                return error;
        }
 
index d2c61dd1f43e448f59ba73fe17981309b0ac9620..ebefbba7d98cc21568c0ea66b4266d0a0f0eb343 100644 (file)
@@ -22,6 +22,15 @@ struct xfs_group {
        uint16_t                xg_checked;
        uint16_t                xg_sick;
        spinlock_t              xg_state_lock;
+
+       /*
+        * We use xfs_drain to track the number of deferred log intent items
+        * that have been queued (but not yet processed) so that waiters (e.g.
+        * scrub) will not lock resources when other threads are in the middle
+        * of processing a chain of intent items only to find momentary
+        * inconsistencies.
+        */
+       struct xfs_defer_drain  xg_intents_drain;
 #endif /* __KERNEL__ */
 };