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" 154860a05dSDarrick J. Wong #include "scrub/scrub.h" 165f213ddbSDarrick J. Wong #include "scrub/health.h" 17*a1f3e0ccSDarrick J. Wong #include "scrub/common.h" 184860a05dSDarrick J. Wong 194860a05dSDarrick J. Wong /* 204860a05dSDarrick J. Wong * Scrub and In-Core Filesystem Health Assessments 214860a05dSDarrick J. Wong * =============================================== 224860a05dSDarrick J. Wong * 234860a05dSDarrick J. Wong * Online scrub and repair have the time and the ability to perform stronger 244860a05dSDarrick J. Wong * checks than we can do from the metadata verifiers, because they can 254860a05dSDarrick J. Wong * cross-reference records between data structures. Therefore, scrub is in a 264860a05dSDarrick J. Wong * good position to update the online filesystem health assessments to reflect 274860a05dSDarrick J. Wong * the good/bad state of the data structure. 284860a05dSDarrick J. Wong * 294860a05dSDarrick J. Wong * We therefore extend scrub in the following ways to achieve this: 304860a05dSDarrick J. Wong * 314860a05dSDarrick J. Wong * 1. Create a "sick_mask" field in the scrub context. When we're setting up a 324860a05dSDarrick J. Wong * scrub call, set this to the default XFS_SICK_* flag(s) for the selected 334860a05dSDarrick J. Wong * scrub type (call it A). Scrub and repair functions can override the default 344860a05dSDarrick J. Wong * sick_mask value if they choose. 354860a05dSDarrick J. Wong * 364860a05dSDarrick J. Wong * 2. If the scrubber returns a runtime error code, we exit making no changes 374860a05dSDarrick J. Wong * to the incore sick state. 384860a05dSDarrick J. Wong * 394860a05dSDarrick J. Wong * 3. If the scrubber finds that A is clean, use sick_mask to clear the incore 404860a05dSDarrick J. Wong * sick flags before exiting. 414860a05dSDarrick J. Wong * 424860a05dSDarrick J. Wong * 4. If the scrubber finds that A is corrupt, use sick_mask to set the incore 434860a05dSDarrick J. Wong * sick flags. If the user didn't want to repair then we exit, leaving the 444860a05dSDarrick J. Wong * metadata structure unfixed and the sick flag set. 454860a05dSDarrick J. Wong * 464860a05dSDarrick J. Wong * 5. Now we know that A is corrupt and the user wants to repair, so run the 474860a05dSDarrick J. Wong * repairer. If the repairer returns an error code, we exit with that error 484860a05dSDarrick J. Wong * code, having made no further changes to the incore sick state. 494860a05dSDarrick J. Wong * 504860a05dSDarrick J. Wong * 6. If repair rebuilds A correctly and the subsequent re-scrub of A is clean, 514860a05dSDarrick J. Wong * use sick_mask to clear the incore sick flags. This should have the effect 524860a05dSDarrick J. Wong * that A is no longer marked sick. 534860a05dSDarrick J. Wong * 544860a05dSDarrick J. Wong * 7. If repair rebuilds A incorrectly, the re-scrub will find it corrupt and 554860a05dSDarrick J. Wong * use sick_mask to set the incore sick flags. This should have no externally 564860a05dSDarrick J. Wong * visible effect since we already set them in step (4). 574860a05dSDarrick J. Wong * 584860a05dSDarrick J. Wong * There are some complications to this story, however. For certain types of 594860a05dSDarrick J. Wong * complementary metadata indices (e.g. inobt/finobt), it is easier to rebuild 604860a05dSDarrick J. Wong * both structures at the same time. The following principles apply to this 614860a05dSDarrick J. Wong * type of repair strategy: 624860a05dSDarrick J. Wong * 634860a05dSDarrick J. Wong * 8. Any repair function that rebuilds multiple structures should update 644860a05dSDarrick J. Wong * sick_mask_visible to reflect whatever other structures are rebuilt, and 654860a05dSDarrick J. Wong * verify that all the rebuilt structures can pass a scrub check. The outcomes 664860a05dSDarrick J. Wong * of 5-7 still apply, but with a sick_mask that covers everything being 674860a05dSDarrick J. Wong * rebuilt. 684860a05dSDarrick J. Wong */ 694860a05dSDarrick J. Wong 704860a05dSDarrick J. Wong /* Map our scrub type to a sick mask and a set of health update functions. */ 714860a05dSDarrick J. Wong 724860a05dSDarrick J. Wong enum xchk_health_group { 734860a05dSDarrick J. Wong XHG_FS = 1, 744860a05dSDarrick J. Wong XHG_RT, 754860a05dSDarrick J. Wong XHG_AG, 764860a05dSDarrick J. Wong XHG_INO, 774860a05dSDarrick J. Wong }; 784860a05dSDarrick J. Wong 794860a05dSDarrick J. Wong struct xchk_health_map { 804860a05dSDarrick J. Wong enum xchk_health_group group; 814860a05dSDarrick J. Wong unsigned int sick_mask; 824860a05dSDarrick J. Wong }; 834860a05dSDarrick J. Wong 844860a05dSDarrick J. Wong static const struct xchk_health_map type_to_health_flag[XFS_SCRUB_TYPE_NR] = { 854860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_SB] = { XHG_AG, XFS_SICK_AG_SB }, 864860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_AGF] = { XHG_AG, XFS_SICK_AG_AGF }, 874860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_AGFL] = { XHG_AG, XFS_SICK_AG_AGFL }, 884860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_AGI] = { XHG_AG, XFS_SICK_AG_AGI }, 894860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BNOBT] = { XHG_AG, XFS_SICK_AG_BNOBT }, 904860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_CNTBT] = { XHG_AG, XFS_SICK_AG_CNTBT }, 914860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_INOBT] = { XHG_AG, XFS_SICK_AG_INOBT }, 924860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_FINOBT] = { XHG_AG, XFS_SICK_AG_FINOBT }, 934860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_RMAPBT] = { XHG_AG, XFS_SICK_AG_RMAPBT }, 944860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_REFCNTBT] = { XHG_AG, XFS_SICK_AG_REFCNTBT }, 954860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_INODE] = { XHG_INO, XFS_SICK_INO_CORE }, 964860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BMBTD] = { XHG_INO, XFS_SICK_INO_BMBTD }, 974860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BMBTA] = { XHG_INO, XFS_SICK_INO_BMBTA }, 984860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_BMBTC] = { XHG_INO, XFS_SICK_INO_BMBTC }, 994860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_DIR] = { XHG_INO, XFS_SICK_INO_DIR }, 1004860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_XATTR] = { XHG_INO, XFS_SICK_INO_XATTR }, 1014860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_SYMLINK] = { XHG_INO, XFS_SICK_INO_SYMLINK }, 1024860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_PARENT] = { XHG_INO, XFS_SICK_INO_PARENT }, 1034860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_RTBITMAP] = { XHG_RT, XFS_SICK_RT_BITMAP }, 1044860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_RTSUM] = { XHG_RT, XFS_SICK_RT_SUMMARY }, 1054860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_UQUOTA] = { XHG_FS, XFS_SICK_FS_UQUOTA }, 1064860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_GQUOTA] = { XHG_FS, XFS_SICK_FS_GQUOTA }, 1074860a05dSDarrick J. Wong [XFS_SCRUB_TYPE_PQUOTA] = { XHG_FS, XFS_SICK_FS_PQUOTA }, 10875efa57dSDarrick J. Wong [XFS_SCRUB_TYPE_FSCOUNTERS] = { XHG_FS, XFS_SICK_FS_COUNTERS }, 10948dd9117SDarrick J. Wong [XFS_SCRUB_TYPE_QUOTACHECK] = { XHG_FS, XFS_SICK_FS_QUOTACHECK }, 110f1184081SDarrick J. Wong [XFS_SCRUB_TYPE_NLINKS] = { XHG_FS, XFS_SICK_FS_NLINKS }, 1114860a05dSDarrick J. Wong }; 1124860a05dSDarrick J. Wong 1134860a05dSDarrick J. Wong /* Return the health status mask for this scrub type. */ 1144860a05dSDarrick J. Wong unsigned int 1154860a05dSDarrick J. Wong xchk_health_mask_for_scrub_type( 1164860a05dSDarrick J. Wong __u32 scrub_type) 1174860a05dSDarrick J. Wong { 1184860a05dSDarrick J. Wong return type_to_health_flag[scrub_type].sick_mask; 1194860a05dSDarrick J. Wong } 1204860a05dSDarrick J. Wong 1214860a05dSDarrick J. Wong /* 122d9041681SDarrick J. Wong * If the scrub state is clean, add @mask to the scrub sick mask to clear 123d9041681SDarrick J. Wong * additional sick flags from the metadata object's sick state. 124d9041681SDarrick J. Wong */ 125d9041681SDarrick J. Wong void 126d9041681SDarrick J. Wong xchk_mark_healthy_if_clean( 127d9041681SDarrick J. Wong struct xfs_scrub *sc, 128d9041681SDarrick J. Wong unsigned int mask) 129d9041681SDarrick J. Wong { 130d9041681SDarrick J. Wong if (!(sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | 131d9041681SDarrick J. Wong XFS_SCRUB_OFLAG_XCORRUPT))) 132d9041681SDarrick J. Wong sc->sick_mask |= mask; 133d9041681SDarrick J. Wong } 134d9041681SDarrick J. Wong 135d9041681SDarrick J. Wong /* 136d9041681SDarrick J. Wong * If we're scrubbing a piece of file metadata for the first time, does it look 137d9041681SDarrick J. Wong * like it has been zapped? Skip the check if we just repaired the metadata 138d9041681SDarrick J. Wong * and are revalidating it. 139d9041681SDarrick J. Wong */ 140d9041681SDarrick J. Wong bool 141d9041681SDarrick J. Wong xchk_file_looks_zapped( 142d9041681SDarrick J. Wong struct xfs_scrub *sc, 143d9041681SDarrick J. Wong unsigned int mask) 144d9041681SDarrick J. Wong { 145d9041681SDarrick J. Wong ASSERT((mask & ~XFS_SICK_INO_ZAPPED) == 0); 146d9041681SDarrick J. Wong 147d9041681SDarrick J. Wong if (sc->flags & XREP_ALREADY_FIXED) 148d9041681SDarrick J. Wong return false; 149d9041681SDarrick J. Wong 150d9041681SDarrick J. Wong return xfs_inode_has_sickness(sc->ip, mask); 151d9041681SDarrick J. Wong } 152d9041681SDarrick J. Wong 153d9041681SDarrick J. Wong /* 154*a1f3e0ccSDarrick J. Wong * Scrub gave the filesystem a clean bill of health, so clear all the indirect 155*a1f3e0ccSDarrick J. Wong * markers of past problems (at least for the fs and ags) so that we can be 156*a1f3e0ccSDarrick J. Wong * healthy again. 157*a1f3e0ccSDarrick J. Wong */ 158*a1f3e0ccSDarrick J. Wong STATIC void 159*a1f3e0ccSDarrick J. Wong xchk_mark_all_healthy( 160*a1f3e0ccSDarrick J. Wong struct xfs_mount *mp) 161*a1f3e0ccSDarrick J. Wong { 162*a1f3e0ccSDarrick J. Wong struct xfs_perag *pag; 163*a1f3e0ccSDarrick J. Wong xfs_agnumber_t agno; 164*a1f3e0ccSDarrick J. Wong 165*a1f3e0ccSDarrick J. Wong xfs_fs_mark_healthy(mp, XFS_SICK_FS_INDIRECT); 166*a1f3e0ccSDarrick J. Wong xfs_rt_mark_healthy(mp, XFS_SICK_RT_INDIRECT); 167*a1f3e0ccSDarrick J. Wong for_each_perag(mp, agno, pag) 168*a1f3e0ccSDarrick J. Wong xfs_ag_mark_healthy(pag, XFS_SICK_AG_INDIRECT); 169*a1f3e0ccSDarrick J. Wong } 170*a1f3e0ccSDarrick J. Wong 171*a1f3e0ccSDarrick J. Wong /* 1724860a05dSDarrick J. Wong * Update filesystem health assessments based on what we found and did. 1734860a05dSDarrick J. Wong * 1744860a05dSDarrick J. Wong * If the scrubber finds errors, we mark sick whatever's mentioned in 1754860a05dSDarrick J. Wong * sick_mask, no matter whether this is a first scan or an 1764860a05dSDarrick J. Wong * evaluation of repair effectiveness. 1774860a05dSDarrick J. Wong * 1784860a05dSDarrick J. Wong * Otherwise, no direct corruption was found, so mark whatever's in 1794860a05dSDarrick J. Wong * sick_mask as healthy. 1804860a05dSDarrick J. Wong */ 1814860a05dSDarrick J. Wong void 1824860a05dSDarrick J. Wong xchk_update_health( 1834860a05dSDarrick J. Wong struct xfs_scrub *sc) 1844860a05dSDarrick J. Wong { 1854860a05dSDarrick J. Wong struct xfs_perag *pag; 1864860a05dSDarrick J. Wong bool bad; 1874860a05dSDarrick J. Wong 188*a1f3e0ccSDarrick J. Wong /* 189*a1f3e0ccSDarrick J. Wong * The HEALTHY scrub type is a request from userspace to clear all the 190*a1f3e0ccSDarrick J. Wong * indirect flags after a clean scan of the entire filesystem. As such 191*a1f3e0ccSDarrick J. Wong * there's no sick flag defined for it, so we branch here ahead of the 192*a1f3e0ccSDarrick J. Wong * mask check. 193*a1f3e0ccSDarrick J. Wong */ 194*a1f3e0ccSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_HEALTHY && 195*a1f3e0ccSDarrick J. Wong !(sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) { 196*a1f3e0ccSDarrick J. Wong xchk_mark_all_healthy(sc->mp); 197*a1f3e0ccSDarrick J. Wong return; 198*a1f3e0ccSDarrick J. Wong } 199*a1f3e0ccSDarrick J. Wong 2004860a05dSDarrick J. Wong if (!sc->sick_mask) 2014860a05dSDarrick J. Wong return; 2024860a05dSDarrick J. Wong 2039de4b514SDarrick J. Wong bad = (sc->sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | 2049de4b514SDarrick J. Wong XFS_SCRUB_OFLAG_XCORRUPT)); 2054860a05dSDarrick J. Wong switch (type_to_health_flag[sc->sm->sm_type].group) { 2064860a05dSDarrick J. Wong case XHG_AG: 2074860a05dSDarrick J. Wong pag = xfs_perag_get(sc->mp, sc->sm->sm_agno); 2084860a05dSDarrick J. Wong if (bad) 2090b8686f1SDarrick J. Wong xfs_ag_mark_corrupt(pag, sc->sick_mask); 2104860a05dSDarrick J. Wong else 2114860a05dSDarrick J. Wong xfs_ag_mark_healthy(pag, sc->sick_mask); 2124860a05dSDarrick J. Wong xfs_perag_put(pag); 2134860a05dSDarrick J. Wong break; 2144860a05dSDarrick J. Wong case XHG_INO: 2154860a05dSDarrick J. Wong if (!sc->ip) 2164860a05dSDarrick J. Wong return; 2170e24ec3cSDarrick J. Wong if (bad) { 2180e24ec3cSDarrick J. Wong unsigned int mask = sc->sick_mask; 2190e24ec3cSDarrick J. Wong 2200e24ec3cSDarrick J. Wong /* 2210e24ec3cSDarrick J. Wong * If we're coming in for repairs then we don't want 2220e24ec3cSDarrick J. Wong * sickness flags to propagate to the incore health 2230e24ec3cSDarrick J. Wong * status if the inode gets inactivated before we can 2240e24ec3cSDarrick J. Wong * fix it. 2250e24ec3cSDarrick J. Wong */ 2260e24ec3cSDarrick J. Wong if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) 2270e24ec3cSDarrick J. Wong mask |= XFS_SICK_INO_FORGET; 2280e24ec3cSDarrick J. Wong xfs_inode_mark_corrupt(sc->ip, mask); 2290e24ec3cSDarrick J. Wong } else 2304860a05dSDarrick J. Wong xfs_inode_mark_healthy(sc->ip, sc->sick_mask); 2314860a05dSDarrick J. Wong break; 2324860a05dSDarrick J. Wong case XHG_FS: 2334860a05dSDarrick J. Wong if (bad) 2340b8686f1SDarrick J. Wong xfs_fs_mark_corrupt(sc->mp, sc->sick_mask); 2354860a05dSDarrick J. Wong else 2364860a05dSDarrick J. Wong xfs_fs_mark_healthy(sc->mp, sc->sick_mask); 2374860a05dSDarrick J. Wong break; 2384860a05dSDarrick J. Wong case XHG_RT: 2394860a05dSDarrick J. Wong if (bad) 2400b8686f1SDarrick J. Wong xfs_rt_mark_corrupt(sc->mp, sc->sick_mask); 2414860a05dSDarrick J. Wong else 2424860a05dSDarrick J. Wong xfs_rt_mark_healthy(sc->mp, sc->sick_mask); 2434860a05dSDarrick J. Wong break; 2444860a05dSDarrick J. Wong default: 2454860a05dSDarrick J. Wong ASSERT(0); 2464860a05dSDarrick J. Wong break; 2474860a05dSDarrick J. Wong } 2484860a05dSDarrick J. Wong } 2494fb7951fSDarrick J. Wong 2504fb7951fSDarrick J. Wong /* Is the given per-AG btree healthy enough for scanning? */ 2514fb7951fSDarrick J. Wong bool 2524fb7951fSDarrick J. Wong xchk_ag_btree_healthy_enough( 2534fb7951fSDarrick J. Wong struct xfs_scrub *sc, 2544fb7951fSDarrick J. Wong struct xfs_perag *pag, 2554fb7951fSDarrick J. Wong xfs_btnum_t btnum) 2564fb7951fSDarrick J. Wong { 2574fb7951fSDarrick J. Wong unsigned int mask = 0; 2584fb7951fSDarrick J. Wong 2594fb7951fSDarrick J. Wong /* 2604fb7951fSDarrick J. Wong * We always want the cursor if it's the same type as whatever we're 2614fb7951fSDarrick J. Wong * scrubbing, even if we already know the structure is corrupt. 2624fb7951fSDarrick J. Wong * 2634fb7951fSDarrick J. Wong * Otherwise, we're only interested in the btree for cross-referencing. 2644fb7951fSDarrick J. Wong * If we know the btree is bad then don't bother, just set XFAIL. 2654fb7951fSDarrick J. Wong */ 2664fb7951fSDarrick J. Wong switch (btnum) { 2674fb7951fSDarrick J. Wong case XFS_BTNUM_BNO: 2684fb7951fSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_BNOBT) 2694fb7951fSDarrick J. Wong return true; 2704fb7951fSDarrick J. Wong mask = XFS_SICK_AG_BNOBT; 2714fb7951fSDarrick J. Wong break; 2724fb7951fSDarrick J. Wong case XFS_BTNUM_CNT: 2734fb7951fSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_CNTBT) 2744fb7951fSDarrick J. Wong return true; 2754fb7951fSDarrick J. Wong mask = XFS_SICK_AG_CNTBT; 2764fb7951fSDarrick J. Wong break; 2774fb7951fSDarrick J. Wong case XFS_BTNUM_INO: 2784fb7951fSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_INOBT) 2794fb7951fSDarrick J. Wong return true; 2804fb7951fSDarrick J. Wong mask = XFS_SICK_AG_INOBT; 2814fb7951fSDarrick J. Wong break; 2824fb7951fSDarrick J. Wong case XFS_BTNUM_FINO: 2834fb7951fSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_FINOBT) 2844fb7951fSDarrick J. Wong return true; 2854fb7951fSDarrick J. Wong mask = XFS_SICK_AG_FINOBT; 2864fb7951fSDarrick J. Wong break; 2874fb7951fSDarrick J. Wong case XFS_BTNUM_RMAP: 2884fb7951fSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_RMAPBT) 2894fb7951fSDarrick J. Wong return true; 2904fb7951fSDarrick J. Wong mask = XFS_SICK_AG_RMAPBT; 2914fb7951fSDarrick J. Wong break; 2924fb7951fSDarrick J. Wong case XFS_BTNUM_REFC: 2934fb7951fSDarrick J. Wong if (sc->sm->sm_type == XFS_SCRUB_TYPE_REFCNTBT) 2944fb7951fSDarrick J. Wong return true; 2954fb7951fSDarrick J. Wong mask = XFS_SICK_AG_REFCNTBT; 2964fb7951fSDarrick J. Wong break; 2974fb7951fSDarrick J. Wong default: 2984fb7951fSDarrick J. Wong ASSERT(0); 2994fb7951fSDarrick J. Wong return true; 3004fb7951fSDarrick J. Wong } 3014fb7951fSDarrick J. Wong 302d65eb8a6SDarrick J. Wong /* 303d65eb8a6SDarrick J. Wong * If we just repaired some AG metadata, sc->sick_mask will reflect all 304d65eb8a6SDarrick J. Wong * the per-AG metadata types that were repaired. Exclude these from 305d65eb8a6SDarrick J. Wong * the filesystem health query because we have not yet updated the 306d65eb8a6SDarrick J. Wong * health status and we want everything to be scanned. 307d65eb8a6SDarrick J. Wong */ 308d65eb8a6SDarrick J. Wong if ((sc->flags & XREP_ALREADY_FIXED) && 309d65eb8a6SDarrick J. Wong type_to_health_flag[sc->sm->sm_type].group == XHG_AG) 310d65eb8a6SDarrick J. Wong mask &= ~sc->sick_mask; 311d65eb8a6SDarrick J. Wong 3124fb7951fSDarrick J. Wong if (xfs_ag_has_sickness(pag, mask)) { 3134fb7951fSDarrick J. Wong sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XFAIL; 3144fb7951fSDarrick J. Wong return false; 3154fb7951fSDarrick J. Wong } 3164fb7951fSDarrick J. Wong 3174fb7951fSDarrick J. Wong return true; 3184fb7951fSDarrick J. Wong } 319*a1f3e0ccSDarrick J. Wong 320*a1f3e0ccSDarrick J. Wong /* 321*a1f3e0ccSDarrick J. Wong * Quick scan to double-check that there isn't any evidence of lingering 322*a1f3e0ccSDarrick J. Wong * primary health problems. If we're still clear, then the health update will 323*a1f3e0ccSDarrick J. Wong * take care of clearing the indirect evidence. 324*a1f3e0ccSDarrick J. Wong */ 325*a1f3e0ccSDarrick J. Wong int 326*a1f3e0ccSDarrick J. Wong xchk_health_record( 327*a1f3e0ccSDarrick J. Wong struct xfs_scrub *sc) 328*a1f3e0ccSDarrick J. Wong { 329*a1f3e0ccSDarrick J. Wong struct xfs_mount *mp = sc->mp; 330*a1f3e0ccSDarrick J. Wong struct xfs_perag *pag; 331*a1f3e0ccSDarrick J. Wong xfs_agnumber_t agno; 332*a1f3e0ccSDarrick J. Wong 333*a1f3e0ccSDarrick J. Wong unsigned int sick; 334*a1f3e0ccSDarrick J. Wong unsigned int checked; 335*a1f3e0ccSDarrick J. Wong 336*a1f3e0ccSDarrick J. Wong xfs_fs_measure_sickness(mp, &sick, &checked); 337*a1f3e0ccSDarrick J. Wong if (sick & XFS_SICK_FS_PRIMARY) 338*a1f3e0ccSDarrick J. Wong xchk_set_corrupt(sc); 339*a1f3e0ccSDarrick J. Wong 340*a1f3e0ccSDarrick J. Wong xfs_rt_measure_sickness(mp, &sick, &checked); 341*a1f3e0ccSDarrick J. Wong if (sick & XFS_SICK_RT_PRIMARY) 342*a1f3e0ccSDarrick J. Wong xchk_set_corrupt(sc); 343*a1f3e0ccSDarrick J. Wong 344*a1f3e0ccSDarrick J. Wong for_each_perag(mp, agno, pag) { 345*a1f3e0ccSDarrick J. Wong xfs_ag_measure_sickness(pag, &sick, &checked); 346*a1f3e0ccSDarrick J. Wong if (sick & XFS_SICK_AG_PRIMARY) 347*a1f3e0ccSDarrick J. Wong xchk_set_corrupt(sc); 348*a1f3e0ccSDarrick J. Wong } 349*a1f3e0ccSDarrick J. Wong 350*a1f3e0ccSDarrick J. Wong return 0; 351*a1f3e0ccSDarrick J. Wong } 352