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

Prepare for also tracking the health status of the upcoming realtime
groups by moving the health tracking code 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/util.c
libxfs/xfs_ag.c
libxfs/xfs_ag.h
libxfs/xfs_group.c
libxfs/xfs_group.h
libxfs/xfs_health.h

index a3f3ad299336c7c57d427ea41c7058e91777da60..97da94506aee014fbce2d62c1269d05881a8b585 100644 (file)
@@ -449,8 +449,8 @@ void xfs_ag_geom_health(struct xfs_perag *pag, struct xfs_ag_geometry *ageo) { }
 void xfs_fs_mark_sick(struct xfs_mount *mp, unsigned int mask) { }
 void xfs_agno_mark_sick(struct xfs_mount *mp, xfs_agnumber_t agno,
                unsigned int mask) { }
-void xfs_ag_mark_sick(struct xfs_perag *pag, unsigned int mask) { }
-void xfs_ag_measure_sickness(struct xfs_perag *pag, unsigned int *sick,
+void xfs_group_mark_sick(struct xfs_group *xg, unsigned int mask) { }
+void xfs_group_measure_sickness(struct xfs_group *xg, unsigned int *sick,
                unsigned int *checked)
 {
        *sick = 0;
index 15d4ac5a99f0e7e4ad5de0155cf233b952f6641d..20af8b67d86e885e4b82b9df01a8cc7e40665a35 100644 (file)
@@ -230,7 +230,6 @@ xfs_perag_alloc(
        /* Place kernel structure only init below this point. */
        spin_lock_init(&pag->pag_ici_lock);
        spin_lock_init(&pag->pagb_lock);
-       spin_lock_init(&pag->pag_state_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);
index 80969682dc4746ef886ddd0eace4d2df797e114d..8271cb72c88387005e57c383926cd420fe06e2a4 100644 (file)
@@ -69,13 +69,6 @@ struct xfs_perag {
 #ifdef __KERNEL__
        /* -- kernel only structures below this line -- */
 
-       /*
-        * Bitsets of per-ag metadata that have been checked and/or are sick.
-        * Callers should hold pag_state_lock before accessing this field.
-        */
-       uint16_t        pag_checked;
-       uint16_t        pag_sick;
-
 #ifdef CONFIG_XFS_ONLINE_REPAIR
        /*
         * Alternate btree heights so that online repair won't trip the write
@@ -87,8 +80,6 @@ struct xfs_perag {
        uint8_t         pagf_repair_rmap_level;
 #endif
 
-       spinlock_t      pag_state_lock;
-
        spinlock_t      pagb_lock;      /* lock for pagb_tree */
        struct rb_root  pagb_tree;      /* ordered tree of busy extents */
        unsigned int    pagb_gen;       /* generation count for pagb_tree */
index 04d65033b75eca181dcb12d96d4fc6c7f5a17b0f..c5269cd659f327ba10a91f299b7f185169576972 100644 (file)
@@ -181,6 +181,10 @@ xfs_group_insert(
        xg->xg_gno = index;
        xg->xg_type = type;
 
+#ifdef __KERNEL__
+       spin_lock_init(&xg->xg_state_lock);
+#endif
+
        /* Active ref owned by mount indicates group is online. */
        atomic_set(&xg->xg_active_ref, 1);
 
index dd7da90443054b4aee971df0abde3b4c65ef83be..d2c61dd1f43e448f59ba73fe17981309b0ac9620 100644 (file)
@@ -11,6 +11,18 @@ struct xfs_group {
        enum xfs_group_type     xg_type;
        atomic_t                xg_ref;         /* passive reference count */
        atomic_t                xg_active_ref;  /* active reference count */
+
+#ifdef __KERNEL__
+       /* -- kernel only structures below this line -- */
+
+       /*
+        * Bitsets of per-ag metadata that have been checked and/or are sick.
+        * Callers should hold xg_state_lock before accessing this field.
+        */
+       uint16_t                xg_checked;
+       uint16_t                xg_sick;
+       spinlock_t              xg_state_lock;
+#endif /* __KERNEL__ */
 };
 
 struct xfs_group *xfs_group_get(struct xfs_mount *mp, uint32_t index,
index b0edb4288e59297ea5a6a54c67da1d70ea471d0c..13301420a2f670fc0de657a1ef1d33a17bd00467 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef __XFS_HEALTH_H__
 #define __XFS_HEALTH_H__
 
+struct xfs_group;
+
 /*
  * In-Core Filesystem Health Assessments
  * =====================================
@@ -197,10 +199,12 @@ void xfs_rt_measure_sickness(struct xfs_mount *mp, unsigned int *sick,
 
 void xfs_agno_mark_sick(struct xfs_mount *mp, xfs_agnumber_t agno,
                unsigned int mask);
-void xfs_ag_mark_sick(struct xfs_perag *pag, unsigned int mask);
-void xfs_ag_mark_corrupt(struct xfs_perag *pag, unsigned int mask);
-void xfs_ag_mark_healthy(struct xfs_perag *pag, unsigned int mask);
-void xfs_ag_measure_sickness(struct xfs_perag *pag, unsigned int *sick,
+void xfs_group_mark_sick(struct xfs_group *xg, unsigned int mask);
+#define xfs_ag_mark_sick(pag, mask) \
+       xfs_group_mark_sick(pag_group(pag), (mask))
+void xfs_group_mark_corrupt(struct xfs_group *xg, unsigned int mask);
+void xfs_group_mark_healthy(struct xfs_group *xg, unsigned int mask);
+void xfs_group_measure_sickness(struct xfs_group *xg, unsigned int *sick,
                unsigned int *checked);
 
 void xfs_inode_mark_sick(struct xfs_inode *ip, unsigned int mask);
@@ -227,22 +231,19 @@ xfs_fs_has_sickness(struct xfs_mount *mp, unsigned int mask)
 }
 
 static inline bool
-xfs_rt_has_sickness(struct xfs_mount *mp, unsigned int mask)
+xfs_group_has_sickness(
+       struct xfs_group        *xg,
+       unsigned int            mask)
 {
-       unsigned int    sick, checked;
-
-       xfs_rt_measure_sickness(mp, &sick, &checked);
-       return sick & mask;
-}
-
-static inline bool
-xfs_ag_has_sickness(struct xfs_perag *pag, unsigned int mask)
-{
-       unsigned int    sick, checked;
+       unsigned int            sick, checked;
 
-       xfs_ag_measure_sickness(pag, &sick, &checked);
+       xfs_group_measure_sickness(xg, &sick, &checked);
        return sick & mask;
 }
+#define xfs_ag_has_sickness(pag, mask) \
+       xfs_group_has_sickness(pag_group(pag), (mask))
+#define xfs_ag_is_healthy(pag) \
+       (!xfs_ag_has_sickness((pag), UINT_MAX))
 
 static inline bool
 xfs_inode_has_sickness(struct xfs_inode *ip, unsigned int mask)
@@ -259,18 +260,6 @@ xfs_fs_is_healthy(struct xfs_mount *mp)
        return !xfs_fs_has_sickness(mp, -1U);
 }
 
-static inline bool
-xfs_rt_is_healthy(struct xfs_mount *mp)
-{
-       return !xfs_rt_has_sickness(mp, -1U);
-}
-
-static inline bool
-xfs_ag_is_healthy(struct xfs_perag *pag)
-{
-       return !xfs_ag_has_sickness(pag, -1U);
-}
-
 static inline bool
 xfs_inode_is_healthy(struct xfs_inode *ip)
 {