1739a2fe0SDarrick J. Wong // SPDX-License-Identifier: GPL-2.0-or-later 24860a05dSDarrick J. Wong /* 3ecc73f8aSDarrick J. Wong * Copyright (C) 2019-2023 Oracle. All Rights Reserved. 4739a2fe0SDarrick J. Wong * Author: Darrick J. Wong <djwong@kernel.org> 54860a05dSDarrick J. Wong */ 64860a05dSDarrick J. Wong #include "xfs.h" 74860a05dSDarrick J. Wong #include "xfs_fs.h" 84860a05dSDarrick J. Wong #include "xfs_shared.h" 94860a05dSDarrick J. Wong #include "xfs_format.h" 10d5c88131SDarrick J. Wong #include "xfs_trans_resv.h" 11d5c88131SDarrick J. Wong #include "xfs_mount.h" 124860a05dSDarrick J. Wong #include "xfs_btree.h" 139bbafc71SDave Chinner #include "xfs_ag.h" 144860a05dSDarrick J. Wong #include "xfs_health.h" 15ab7bd650SDarrick J. Wong #include "xfs_rtgroup.h" 164860a05dSDarrick J. Wong #include "scrub/scrub.h" 175f213ddbSDarrick J. Wong #include "scrub/health.h" 18a1f3e0ccSDarrick J. Wong #include "scrub/common.h" 194860a05dSDarrick J. Wong 204860a05dSDarrick J. Wong /* 214860a05dSDarrick J. Wong * Scrub and In-Core Filesystem Health Assessments 224860a05dSDarrick J. Wong * =============================================== 234860a05dSDarrick J. Wong * 244860a05dSDarrick J. Wong * Online scrub and repair have the time and the ability to perform stronger 254860a05dSDarrick J. Wong * checks than we can do from the metadata verifiers, because they can 264860a05dSDarrick J. Wong * cross-reference records between data structures. Therefore, scrub is in a 274860a05dSDarrick J. Wong * good position to update the online filesystem health assessments to reflect 284860a05dSDarrick J. Wong * the good/bad state of the data structure. 294860a05dSDarrick J. Wong * 304860a05dSDarrick J. Wong * We therefore extend scrub in the following ways to achieve this: 314860a05dSDarrick J. Wong * 324860a05dSDarrick J. Wong * 1. Create a "sick_mask" field in the scrub context. When we're setting up a 334860a05dSDarrick J. Wong * scrub call, set this to the default XFS_SICK_* flag(s) for the selected 344860a05dSDarrick J. Wong * scrub type (call it A). Scrub and repair functions can override the default 354860a05dSDarrick J. Wong * sick_mask value if they choose. 364860a05dSDarrick J. Wong * 374860a05dSDarrick J. Wong * 2. If the scrubber returns a runtime error code, we exit making no changes 384860a05dSDarrick J. Wong * to the incore sick state. 394860a05dSDarrick J. Wong * 404860a05dSDarrick J. Wong * 3. If the scrubber finds that A is clean, use sick_mask to clear the incore 414860a05dSDarrick J. Wong * sick flags before exiting. 424860a05dSDarrick J. Wong * 434860a05dSDarrick J. Wong * 4. If the scrubber finds that A is corrupt, use sick_mask to set the incore 444860a05dSDarrick J. Wong * sick flags. If the user didn't want to repair then we exit, leaving the 454860a05dSDarrick J. Wong * metadata structure unfixed and the sick flag set. 464860a05dSDarrick J. Wong * 474860a05dSDarrick J. Wong * 5. Now we know that A is corrupt and the user wants to repair, so run the 484860a05dSDarrick J. Wong * repairer. If the repairer returns an error code, we exit with that error 494860a05dSDarrick J. Wong * code, having made no further changes to the incore sick state. 504860a05dSDarrick J. Wong * 514860a05dSDarrick J. Wong * 6. If repair rebuilds A correctly and the subsequent re-scrub of A is clean, 524860a05dSDarrick J. Wong * use sick_mask to clear the incore sick flags. This should have the effect 534860a05dSDarrick J. Wong * that A is no longer marked sick. 544860a05dSDarrick J. Wong * 554860a05dSDarrick J. Wong * 7. If repair rebuilds A incorrectly, the re-scrub will find it corrupt and 564860a05dSDarrick J. Wong * use sick_mask to set the incore sick flags. This should have no externally 574860a05dSDarrick J. Wong * visible effect since we already set them in step (4). 584860a05dSDarrick J. Wong * 594860a05dSDarrick J. Wong * There are some complications to this story, however. For certain types of 604860a05dSDarrick J. Wong * complementary metadata indices (e.g. inobt/finobt), it is easier to rebuild 614860a05dSDarrick J. Wong * both structures at the same time. The following principles apply to this 624860a05dSDarrick J. Wong * type of repair strategy: 634860a05dSDarrick J. Wong * 644860a05dSDarrick J. Wong * 8. Any repair function that rebuilds multiple structures should update 654860a05dSDarrick J. Wong * sick_mask_visible to reflect whatever other structures are rebuilt, and 664860a05dSDarrick J. Wong * verify that all the rebuilt structures can pass a scrub check. The outcomes 674860a05dSDarrick J. Wong * of 5-7 still apply, but with a sick_mask that covers everything being 684860a05dSDarrick J. Wong * rebuilt. 694860a05dSDarrick J. Wong */ 704860a05dSDarrick J. Wong 714860a05dSDarrick J. Wong /* Map our scrub type to a sick mask and a set of health update functions. */ 724860a05dSDarrick J. Wong 734860a05dSDarrick J. Wong enum xchk_health_group { 74*aa7bfb53SDarrick J. Wong XHG_NONE = 1, 75*aa7bfb53SDarrick J. Wong XHG_FS, 764860a05dSDarrick J. Wong XHG_AG, 774860a05dSDarrick J. Wong XHG_INO, 78ab7bd650SDarrick J. Wong XHG_RTGROUP, 794860a05dSDarrick J. Wong }; 804860a05dSDarrick J. Wong 814860a05dSDarrick J. Wong struct xchk_health_map { 824860a05dSDarrick J. Wong enum xchk_health_group group; 834860a05dSDarrick J. Wong unsigned int sick_mask; 844860a05dSDarrick J. Wong }; 854860a05dSDarrick J. Wong 864860a05dSDarrick J. Wong static const struct xchk_health_map type_to_health_flag[XFS_SCRUB_TYPE_NR] = { 87*aa7bfb53SDarrick J. Wong [XFS_SCRUB_TYPE_PROBE] = { XHG_NONE, 0 }, 884860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_SB] = { XHG_AG, XFS_SICK_AG_SB }, 894860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_AGF] = { XHG_AG, XFS_SICK_AG_AGF }, 904860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_AGFL] = { XHG_AG, XFS_SICK_AG_AGFL }, 914860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_AGI] = { XHG_AG, XFS_SICK_AG_AGI }, 924860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BNOBT] = { XHG_AG, XFS_SICK_AG_BNOBT }, 934860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_CNTBT] = { XHG_AG, XFS_SICK_AG_CNTBT }, 944860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_INOBT] = { XHG_AG, XFS_SICK_AG_INOBT }, 954860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_FINOBT] = { XHG_AG, XFS_SICK_AG_FINOBT }, 964860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_RMAPBT] = { XHG_AG, XFS_SICK_AG_RMAPBT }, 974860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_REFCNTBT] = { XHG_AG, XFS_SICK_AG_REFCNTBT }, 984860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_INODE] = { XHG_INO, XFS_SICK_INO_CORE }, 994860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BMBTD] = { XHG_INO, XFS_SICK_INO_BMBTD }, 1004860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BMBTA] = { XHG_INO, XFS_SICK_INO_BMBTA }, 1014860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BMBTC] = { XHG_INO, XFS_SICK_INO_BMBTC }, 1024860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_DIR] = { XHG_INO, XFS_SICK_INO_DIR }, 1034860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_XATTR] = { XHG_INO, XFS_SICK_INO_XATTR }, 1044860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_SYMLINK] = { XHG_INO, XFS_SICK_INO_SYMLINK }, 1054860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_PARENT] = { XHG_INO, XFS_SICK_INO_PARENT }, 106ab7bd650SDarrick J. Wong [XFS_SCRUB_TYPE_RTBITMAP] = { XHG_RTGROUP, XFS_SICK_RG_BITMAP }, 107ab7bd650SDarrick J. Wong [XFS_SCRUB_TYPE_RTSUM] = { XHG_RTGROUP, XFS_SICK_RG_SUMMARY }, 1084860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_UQUOTA] = { XHG_FS, XFS_SICK_FS_UQUOTA }, 1094860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_GQUOTA] = { XHG_FS, XFS_SICK_FS_GQUOTA }, 1104860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_PQUOTA] = { XHG_FS, XFS_SICK_FS_PQUOTA }, 11175efa57dSDarrick J. Wong [XFS_SCRUB_TYPE_FSCOUNTERS] = { XHG_FS, XFS_SICK_FS_COUNTERS }, 11248dd9117SDarrick J. Wong [XFS_SCRUB_TYPE_QUOTACHECK] = { XHG_FS, XFS_SICK_FS_QUOTACHECK }, 113f1184081SDarrick J. Wong [XFS_SCRUB_TYPE_NLINKS] = { XHG_FS, XFS_SICK_FS_NLINKS }, 11437056912SDarrick J. Wong [XFS_SCRUB_TYPE_DIRTREE] = { XHG_INO, XFS_SICK_INO_DIRTREE }, 115b3c03efaSDarrick J. Wong [XFS_SCRUB_TYPE_METAPATH] = { XHG_FS, XFS_SICK_FS_METAPATH }, 1163f1bdf50SDarrick J. Wong [XFS_SCRUB_TYPE_RGSUPER] = { XHG_RTGROUP, XFS_SICK_RG_SUPER }, 1174860a05dSDarrick J. Wong }; 1184860a05dSDarrick J. Wong 1194860a05dSDarrick J. Wong /* Return the health status mask for this scrub type. */ 1204860a05dSDarrick J. Wong unsigned int 1214860a05dSDarrick J. Wong xchk_health_mask_for_scrub_type( 1224860a05dSDarrick J. Wong __u32 scrub_type) 1234860a05dSDarrick J. Wong { 1244860a05dSDarrick J. Wong return type_to_health_flag[scrub_type].sick_mask; 1254860a05dSDarrick J. Wong } 1264860a05dSDarrick J. Wong 1274860a05dSDarrick J. Wong /* 128d9041681SDarrick J. Wong * If the scrub state is clean, add @mask to the scrub sick mask to clear 129d9041681SDarrick J. Wong * additional sick flags from the metadata object's sick state. 130d9041681SDarrick J. Wong */ 131d9041681SDarrick J. Wong void 132d9041681SDarrick J. Wong xchk_mark_healthy_if_clean( 133d9041681SDarrick J. Wong struct xfs_scrub *sc, 134d9041681SDarrick J. Wong unsigned int mask) 135d9041681SDarrick J. Wong { 136d9041681SDarrick J. Wong if (!(sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | 137d9041681SDarrick J. Wong XFS_SCRUB_OFLAG_XCORRUPT))) 138*aa7bfb53SDarrick J. Wong sc->healthy_mask |= mask; 139d9041681SDarrick J. Wong } 140d9041681SDarrick J. Wong 141d9041681SDarrick J. Wong /* 142d9041681SDarrick J. Wong * If we're scrubbing a piece of file metadata for the first time, does it look 143d9041681SDarrick J. Wong * like it has been zapped? Skip the check if we just repaired the metadata 144d9041681SDarrick J. Wong * and are revalidating it. 145d9041681SDarrick J. Wong */ 146d9041681SDarrick J. Wong bool 147d9041681SDarrick J. Wong xchk_file_looks_zapped( 148d9041681SDarrick J. Wong struct xfs_scrub *sc, 149d9041681SDarrick J. Wong unsigned int mask) 150d9041681SDarrick J. Wong { 151d9041681SDarrick J. Wong ASSERT((mask & ~XFS_SICK_INO_ZAPPED) == 0); 152d9041681SDarrick J. Wong 153d9041681SDarrick J. Wong if (sc->flags & XREP_ALREADY_FIXED) 154d9041681SDarrick J. Wong return false; 155d9041681SDarrick J. Wong 156d9041681SDarrick J. Wong return xfs_inode_has_sickness(sc->ip, mask); 157d9041681SDarrick J. Wong } 158d9041681SDarrick J. Wong 159d9041681SDarrick J. Wong /* 160a1f3e0ccSDarrick J. Wong * Scrub gave the filesystem a clean bill of health, so clear all the indirect 161a1f3e0ccSDarrick J. Wong * markers of past problems (at least for the fs and ags) so that we can be 162a1f3e0ccSDarrick J. Wong * healthy again. 163a1f3e0ccSDarrick J. Wong */ 164a1f3e0ccSDarrick J. Wong STATIC void 165a1f3e0ccSDarrick J. Wong xchk_mark_all_healthy( 166a1f3e0ccSDarrick J. Wong struct xfs_mount *mp) 167a1f3e0ccSDarrick J. Wong { 16886437e6aSChristoph Hellwig struct xfs_perag *pag = NULL; 169ab7bd650SDarrick J. Wong struct xfs_rtgroup *rtg = NULL; 170a1f3e0ccSDarrick J. Wong 171a1f3e0ccSDarrick J. Wong xfs_fs_mark_healthy(mp, XFS_SICK_FS_INDIRECT); 17286437e6aSChristoph Hellwig while ((pag = xfs_perag_next(mp, pag))) 1735c8483ceSChristoph Hellwig xfs_group_mark_healthy(pag_group(pag), XFS_SICK_AG_INDIRECT); 174ab7bd650SDarrick J. Wong while ((rtg = xfs_rtgroup_next(mp, rtg))) 175ab7bd650SDarrick J. Wong xfs_group_mark_healthy(rtg_group(rtg), XFS_SICK_RG_INDIRECT); 176a1f3e0ccSDarrick J. Wong } 177a1f3e0ccSDarrick J. Wong 178a1f3e0ccSDarrick J. Wong /* 1794860a05dSDarrick J. Wong * Update filesystem health assessments based on what we found and did. 1804860a05dSDarrick J. Wong * 1814860a05dSDarrick J. Wong * If the scrubber finds errors, we mark sick whatever's mentioned in 1824860a05dSDarrick J. Wong * sick_mask, no matter whether this is a first scan or an 1834860a05dSDarrick J. Wong * evaluation of repair effectiveness. 1844860a05dSDarrick J. Wong * 1854860a05dSDarrick J. Wong * Otherwise, no direct corruption was found, so mark whatever's in 1864860a05dSDarrick J. Wong * sick_mask as healthy. 1874860a05dSDarrick J. Wong */ 1884860a05dSDarrick J. Wong void 1894860a05dSDarrick J. Wong xchk_update_health( 1904860a05dSDarrick J. Wong struct xfs_scrub *sc) 1914860a05dSDarrick J. Wong { 1924860a05dSDarrick J. Wong struct xfs_perag *pag; 193ab7bd650SDarrick J. Wong struct xfs_rtgroup *rtg; 194*aa7bfb53SDarrick J. Wong unsigned int mask = sc->sick_mask; 1954860a05dSDarrick J. Wong bool bad; 1964860a05dSDarrick J. Wong 197a1f3e0ccSDarrick J. Wong /* 198a1f3e0ccSDarrick J. Wong * The HEALTHY scrub type is a request from userspace to clear all the 199a1f3e0ccSDarrick J. Wong * indirect flags after a clean scan of the entire filesystem. As such 200a1f3e0ccSDarrick J. Wong * there's no sick flag defined for it, so we branch here ahead of the 201a1f3e0ccSDarrick J. Wong * mask check. 202a1f3e0ccSDarrick J. Wong */ 203a1f3e0ccSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_HEALTHY && 204a1f3e0ccSDarrick J. Wong !(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) { 205a1f3e0ccSDarrick J. Wong xchk_mark_all_healthy(sc->mp); 206a1f3e0ccSDarrick J. Wong return; 207a1f3e0ccSDarrick J. Wong } 208a1f3e0ccSDarrick J. Wong 2099de4b514SDarrick J. Wong bad = (sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | 2109de4b514SDarrick J. Wong XFS_SCRUB_OFLAG_XCORRUPT)); 211*aa7bfb53SDarrick J. Wong if (!bad) 212*aa7bfb53SDarrick J. Wong mask |= sc->healthy_mask; 2134860a05dSDarrick J. Wong switch (type_to_health_flag[sc->sm->sm_type].group) { 214*aa7bfb53SDarrick J. Wong case XHG_NONE: 215*aa7bfb53SDarrick J. Wong break; 2164860a05dSDarrick J. Wong case XHG_AG: 217*aa7bfb53SDarrick J. Wong if (!mask) 218*aa7bfb53SDarrick J. Wong return; 2194860a05dSDarrick J. Wong pag = xfs_perag_get(sc->mp, sc->sm->sm_agno); 2204860a05dSDarrick J. Wong if (bad) 221*aa7bfb53SDarrick J. Wong xfs_group_mark_corrupt(pag_group(pag), mask); 2224860a05dSDarrick J. Wong else 223*aa7bfb53SDarrick J. Wong xfs_group_mark_healthy(pag_group(pag), mask); 2244860a05dSDarrick J. Wong xfs_perag_put(pag); 2254860a05dSDarrick J. Wong break; 2264860a05dSDarrick J. Wong case XHG_INO: 2274860a05dSDarrick J. Wong if (!sc->ip) 2284860a05dSDarrick J. Wong return; 2290e24ec3cSDarrick J. Wong /* 230*aa7bfb53SDarrick J. Wong * If we're coming in for repairs then we don't want sickness 231*aa7bfb53SDarrick J. Wong * flags to propagate to the incore health status if the inode 232*aa7bfb53SDarrick J. Wong * gets inactivated before we can fix it. 2330e24ec3cSDarrick J. Wong */ 2340e24ec3cSDarrick J. Wong if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) 2350e24ec3cSDarrick J. Wong mask |= XFS_SICK_INO_FORGET; 236*aa7bfb53SDarrick J. Wong if (!mask) 237*aa7bfb53SDarrick J. Wong return; 238*aa7bfb53SDarrick J. Wong if (bad) 2390e24ec3cSDarrick J. Wong xfs_inode_mark_corrupt(sc->ip, mask); 240*aa7bfb53SDarrick J. Wong else 241*aa7bfb53SDarrick J. Wong xfs_inode_mark_healthy(sc->ip, mask); 2424860a05dSDarrick J. Wong break; 2434860a05dSDarrick J. Wong case XHG_FS: 244*aa7bfb53SDarrick J. Wong if (!mask) 245*aa7bfb53SDarrick J. Wong return; 2464860a05dSDarrick J. Wong if (bad) 247*aa7bfb53SDarrick J. Wong xfs_fs_mark_corrupt(sc->mp, mask); 2484860a05dSDarrick J. Wong else 249*aa7bfb53SDarrick J. Wong xfs_fs_mark_healthy(sc->mp, mask); 2504860a05dSDarrick J. Wong break; 251ab7bd650SDarrick J. Wong case XHG_RTGROUP: 252*aa7bfb53SDarrick J. Wong if (!mask) 253*aa7bfb53SDarrick J. Wong return; 254ab7bd650SDarrick J. Wong rtg = xfs_rtgroup_get(sc->mp, sc->sm->sm_agno); 2554860a05dSDarrick J. Wong if (bad) 256*aa7bfb53SDarrick J. Wong xfs_group_mark_corrupt(rtg_group(rtg), mask); 2574860a05dSDarrick J. Wong else 258*aa7bfb53SDarrick J. Wong xfs_group_mark_healthy(rtg_group(rtg), mask); 259ab7bd650SDarrick J. Wong xfs_rtgroup_put(rtg); 2604860a05dSDarrick J. Wong break; 2614860a05dSDarrick J. Wong default: 2624860a05dSDarrick J. Wong ASSERT(0); 2634860a05dSDarrick J. Wong break; 2644860a05dSDarrick J. Wong } 2654860a05dSDarrick J. Wong } 2664fb7951fSDarrick J. Wong 2674fb7951fSDarrick J. Wong /* Is the given per-AG btree healthy enough for scanning? */ 26848039926SChristoph Hellwig void 26948039926SChristoph Hellwig xchk_ag_btree_del_cursor_if_sick( 2704fb7951fSDarrick J. Wong struct xfs_scrub *sc, 27148039926SChristoph Hellwig struct xfs_btree_cur **curp, 27248039926SChristoph Hellwig unsigned int sm_type) 2734fb7951fSDarrick J. Wong { 27448039926SChristoph Hellwig unsigned int mask = (*curp)->bc_ops->sick_mask; 2754fb7951fSDarrick J. Wong 2764fb7951fSDarrick J. Wong /* 2774fb7951fSDarrick J. Wong * We always want the cursor if it's the same type as whatever we're 2784fb7951fSDarrick J. Wong * scrubbing, even if we already know the structure is corrupt. 2794fb7951fSDarrick J. Wong * 2804fb7951fSDarrick J. Wong * Otherwise, we're only interested in the btree for cross-referencing. 2814fb7951fSDarrick J. Wong * If we know the btree is bad then don't bother, just set XFAIL. 2824fb7951fSDarrick J. Wong */ 28348039926SChristoph Hellwig if (sc->sm->sm_type == sm_type) 28448039926SChristoph Hellwig return; 2854fb7951fSDarrick J. Wong 286d65eb8a6SDarrick J. Wong /* 287d65eb8a6SDarrick J. Wong * If we just repaired some AG metadata, sc->sick_mask will reflect all 288d65eb8a6SDarrick J. Wong * the per-AG metadata types that were repaired. Exclude these from 289d65eb8a6SDarrick J. Wong * the filesystem health query because we have not yet updated the 290d65eb8a6SDarrick J. Wong * health status and we want everything to be scanned. 291d65eb8a6SDarrick J. Wong */ 292d65eb8a6SDarrick J. Wong if ((sc->flags & XREP_ALREADY_FIXED) && 293d65eb8a6SDarrick J. Wong type_to_health_flag[sc->sm->sm_type].group == XHG_AG) 294d65eb8a6SDarrick J. Wong mask &= ~sc->sick_mask; 295d65eb8a6SDarrick J. Wong 29677a530e6SChristoph Hellwig if (xfs_group_has_sickness((*curp)->bc_group, mask)) { 2974fb7951fSDarrick J. Wong sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XFAIL; 29848039926SChristoph Hellwig xfs_btree_del_cursor(*curp, XFS_BTREE_NOERROR); 29948039926SChristoph Hellwig *curp = NULL; 3004fb7951fSDarrick J. Wong } 3014fb7951fSDarrick J. Wong } 302a1f3e0ccSDarrick J. Wong 303a1f3e0ccSDarrick J. Wong /* 304a1f3e0ccSDarrick J. Wong * Quick scan to double-check that there isn't any evidence of lingering 305a1f3e0ccSDarrick J. Wong * primary health problems. If we're still clear, then the health update will 306a1f3e0ccSDarrick J. Wong * take care of clearing the indirect evidence. 307a1f3e0ccSDarrick J. Wong */ 308a1f3e0ccSDarrick J. Wong int 309a1f3e0ccSDarrick J. Wong xchk_health_record( 310a1f3e0ccSDarrick J. Wong struct xfs_scrub *sc) 311a1f3e0ccSDarrick J. Wong { 312a1f3e0ccSDarrick J. Wong struct xfs_mount *mp = sc->mp; 31386437e6aSChristoph Hellwig struct xfs_perag *pag = NULL; 314ab7bd650SDarrick J. Wong struct xfs_rtgroup *rtg = NULL; 315a1f3e0ccSDarrick J. Wong unsigned int sick; 316a1f3e0ccSDarrick J. Wong unsigned int checked; 317a1f3e0ccSDarrick J. Wong 318a1f3e0ccSDarrick J. Wong xfs_fs_measure_sickness(mp, &sick, &checked); 319a1f3e0ccSDarrick J. Wong if (sick & XFS_SICK_FS_PRIMARY) 320a1f3e0ccSDarrick J. Wong xchk_set_corrupt(sc); 321a1f3e0ccSDarrick J. Wong 32286437e6aSChristoph Hellwig while ((pag = xfs_perag_next(mp, pag))) { 3235c8483ceSChristoph Hellwig xfs_group_measure_sickness(pag_group(pag), &sick, &checked); 324a1f3e0ccSDarrick J. Wong if (sick & XFS_SICK_AG_PRIMARY) 325a1f3e0ccSDarrick J. Wong xchk_set_corrupt(sc); 326a1f3e0ccSDarrick J. Wong } 327a1f3e0ccSDarrick J. Wong 328ab7bd650SDarrick J. Wong while ((rtg = xfs_rtgroup_next(mp, rtg))) { 329ab7bd650SDarrick J. Wong xfs_group_measure_sickness(rtg_group(rtg), &sick, &checked); 330ab7bd650SDarrick J. Wong if (sick & XFS_SICK_RG_PRIMARY) 331ab7bd650SDarrick J. Wong xchk_set_corrupt(sc); 332ab7bd650SDarrick J. Wong } 333ab7bd650SDarrick J. Wong 334a1f3e0ccSDarrick J. Wong return 0; 335a1f3e0ccSDarrick J. Wong } 336