^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0+
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * Copyright (C) 2017 Oracle. All Rights Reserved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) * Author: Darrick J. Wong <darrick.wong@oracle.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include "xfs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) #include "xfs_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "xfs_shared.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) #include "xfs_format.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) #include "xfs_trans_resv.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) #include "xfs_mount.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) #include "xfs_btree.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) #include "xfs_log_format.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) #include "xfs_trans.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) #include "xfs_inode.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) #include "xfs_ialloc.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #include "xfs_ialloc_btree.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) #include "xfs_icache.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) #include "xfs_rmap.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) #include "scrub/scrub.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) #include "scrub/common.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) #include "scrub/btree.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) #include "scrub/trace.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) * Set us up to scrub inode btrees.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) * If we detect a discrepancy between the inobt and the inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) * try again after forcing logged inode cores out to disk.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) xchk_setup_ag_iallocbt(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) struct xfs_inode *ip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) return xchk_setup_ag_btree(sc, ip, sc->flags & XCHK_TRY_HARDER);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) /* Inode btree scrubber. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40) struct xchk_iallocbt {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) /* Number of inodes we see while scanning inobt. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) unsigned long long inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) /* Expected next startino, for big block filesystems. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) xfs_agino_t next_startino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) /* Expected end of the current inode cluster. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) xfs_agino_t next_cluster_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) * If we're checking the finobt, cross-reference with the inobt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) * Otherwise we're checking the inobt; if there is an finobt, make sure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) * we have a record or not depending on freecount.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) xchk_iallocbt_chunk_xref_other(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) struct xfs_inobt_rec_incore *irec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) xfs_agino_t agino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) struct xfs_btree_cur **pcur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) bool has_irec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) if (sc->sm->sm_type == XFS_SCRUB_TYPE_FINOBT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) pcur = &sc->sa.ino_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) pcur = &sc->sa.fino_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) if (!(*pcur))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) error = xfs_ialloc_has_inode_record(*pcur, agino, agino, &has_irec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) if (!xchk_should_check_xref(sc, &error, pcur))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) if (((irec->ir_freecount > 0 && !has_irec) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) (irec->ir_freecount == 0 && has_irec)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) xchk_btree_xref_set_corrupt(sc, *pcur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /* Cross-reference with the other btrees. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) STATIC void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) xchk_iallocbt_chunk_xref(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) struct xfs_inobt_rec_incore *irec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85) xfs_agino_t agino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) xfs_agblock_t agbno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) xfs_extlen_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) xchk_xref_is_used_space(sc, agbno, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) xchk_iallocbt_chunk_xref_other(sc, irec, agino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) xchk_xref_is_owned_by(sc, agbno, len, &XFS_RMAP_OINFO_INODES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) xchk_xref_is_not_shared(sc, agbno, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /* Is this chunk worth checking? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) STATIC bool
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) xchk_iallocbt_chunk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) struct xchk_btree *bs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct xfs_inobt_rec_incore *irec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) xfs_agino_t agino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) xfs_extlen_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) struct xfs_mount *mp = bs->cur->bc_mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) xfs_agnumber_t agno = bs->cur->bc_ag.agno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) xfs_agblock_t bno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) bno = XFS_AGINO_TO_AGBNO(mp, agino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) if (bno + len <= bno ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) !xfs_verify_agbno(mp, agno, bno) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) !xfs_verify_agbno(mp, agno, bno + len - 1))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) xchk_iallocbt_chunk_xref(bs->sc, irec, agino, bno, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) /* Count the number of free inodes. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) static unsigned int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) xchk_iallocbt_freecount(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) xfs_inofree_t freemask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) BUILD_BUG_ON(sizeof(freemask) != sizeof(__u64));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) return hweight64(freemask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) * Check that an inode's allocation status matches ir_free in the inobt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) * record. First we try querying the in-core inode state, and if the inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) * isn't loaded we examine the on-disk inode directly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) * Since there can be 1:M and M:1 mappings between inobt records and inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) * clusters, we pass in the inode location information as an inobt record;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) * the index of an inode cluster within the inobt record (as well as the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) * cluster buffer itself); and the index of the inode within the cluster.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) * @irec is the inobt record.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) * @irec_ino is the inode offset from the start of the record.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) * @dip is the on-disk inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) xchk_iallocbt_check_cluster_ifree(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) struct xchk_btree *bs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) struct xfs_inobt_rec_incore *irec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) unsigned int irec_ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) struct xfs_dinode *dip)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct xfs_mount *mp = bs->cur->bc_mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) xfs_ino_t fsino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) xfs_agino_t agino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) bool irec_free;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) bool ino_inuse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) bool freemask_ok;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) if (xchk_should_terminate(bs->sc, &error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) * Given an inobt record and the offset of an inode from the start of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) * the record, compute which fs inode we're talking about.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) agino = irec->ir_startino + irec_ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_ag.agno, agino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) irec_free = (irec->ir_free & XFS_INOBT_MASK(irec_ino));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) (dip->di_version >= 3 && be64_to_cpu(dip->di_ino) != fsino)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) error = xfs_icache_inode_is_allocated(mp, bs->cur->bc_tp, fsino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) &ino_inuse);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) if (error == -ENODATA) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) /* Not cached, just read the disk buffer */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) freemask_ok = irec_free ^ !!(dip->di_mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) if (!(bs->sc->flags & XCHK_TRY_HARDER) && !freemask_ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) return -EDEADLOCK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) } else if (error < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) * Inode is only half assembled, or there was an IO error,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) * or the verifier failed, so don't bother trying to check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) * The inode scrubber can deal with this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) /* Inode is all there. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) freemask_ok = irec_free ^ ino_inuse;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) if (!freemask_ok)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) * Check that the holemask and freemask of a hypothetical inode cluster match
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) * what's actually on disk. If sparse inodes are enabled, the cluster does
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) * not actually have to map to inodes if the corresponding holemask bit is set.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) * @cluster_base is the first inode in the cluster within the @irec.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) xchk_iallocbt_check_cluster(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) struct xchk_btree *bs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) struct xfs_inobt_rec_incore *irec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) unsigned int cluster_base)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) struct xfs_imap imap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) struct xfs_mount *mp = bs->cur->bc_mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) struct xfs_dinode *dip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) struct xfs_buf *cluster_bp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) unsigned int nr_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) xfs_agnumber_t agno = bs->cur->bc_ag.agno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) xfs_agblock_t agbno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) unsigned int cluster_index;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) uint16_t cluster_mask = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) uint16_t ir_holemask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) nr_inodes = min_t(unsigned int, XFS_INODES_PER_CHUNK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) M_IGEO(mp)->inodes_per_cluster);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) /* Map this inode cluster */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino + cluster_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) /* Compute a bitmask for this cluster that can be used for holemask. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) for (cluster_index = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) cluster_index < nr_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) cluster_index += XFS_INODES_PER_HOLEMASK_BIT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) cluster_mask |= XFS_INOBT_MASK((cluster_base + cluster_index) /
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) XFS_INODES_PER_HOLEMASK_BIT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) * Map the first inode of this cluster to a buffer and offset.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) * Be careful about inobt records that don't align with the start of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) * the inode buffer when block sizes are large enough to hold multiple
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) * inode chunks. When this happens, cluster_base will be zero but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) * ir_startino can be large enough to make im_boffset nonzero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) ir_holemask = (irec->ir_holemask & cluster_mask);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) imap.im_blkno = XFS_AGB_TO_DADDR(mp, agno, agbno);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) imap.im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) mp->m_sb.sb_inodelog;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) if (imap.im_boffset != 0 && cluster_base != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) ASSERT(imap.im_boffset == 0 || cluster_base == 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) trace_xchk_iallocbt_check_cluster(mp, agno, irec->ir_startino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) imap.im_blkno, imap.im_len, cluster_base, nr_inodes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) cluster_mask, ir_holemask,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) XFS_INO_TO_OFFSET(mp, irec->ir_startino +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) cluster_base));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) /* The whole cluster must be a hole or not a hole. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) if (ir_holemask != cluster_mask && ir_holemask != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) /* If any part of this is a hole, skip it. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) if (ir_holemask) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) xchk_xref_is_not_owned_by(bs->sc, agbno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) M_IGEO(mp)->blocks_per_cluster,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) &XFS_RMAP_OINFO_INODES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) xchk_xref_is_owned_by(bs->sc, agbno, M_IGEO(mp)->blocks_per_cluster,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) &XFS_RMAP_OINFO_INODES);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) /* Grab the inode cluster buffer. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, &dip, &cluster_bp, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) if (!xchk_btree_xref_process_error(bs->sc, bs->cur, 0, &error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) /* Check free status of each inode within this cluster. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) for (cluster_index = 0; cluster_index < nr_inodes; cluster_index++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) struct xfs_dinode *dip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) if (imap.im_boffset >= BBTOB(cluster_bp->b_length)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) dip = xfs_buf_offset(cluster_bp, imap.im_boffset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) error = xchk_iallocbt_check_cluster_ifree(bs, irec,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) cluster_base + cluster_index, dip);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) imap.im_boffset += mp->m_sb.sb_inodesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) xfs_trans_brelse(bs->cur->bc_tp, cluster_bp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) * For all the inode clusters that could map to this inobt record, make sure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) * that the holemask makes sense and that the allocation status of each inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) * matches the freemask.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) xchk_iallocbt_check_clusters(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) struct xchk_btree *bs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) struct xfs_inobt_rec_incore *irec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) unsigned int cluster_base;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) * For the common case where this inobt record maps to multiple inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) * clusters this will call _check_cluster for each cluster.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) * For the case that multiple inobt records map to a single cluster,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) * this will call _check_cluster once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) for (cluster_base = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) cluster_base < XFS_INODES_PER_CHUNK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) cluster_base += M_IGEO(bs->sc->mp)->inodes_per_cluster) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) error = xchk_iallocbt_check_cluster(bs, irec, cluster_base);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) * Make sure this inode btree record is aligned properly. Because a fs block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) * contains multiple inodes, we check that the inobt record is aligned to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) * correct inode, not just the correct block on disk. This results in a finer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) * grained corruption check.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) STATIC void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) xchk_iallocbt_rec_alignment(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) struct xchk_btree *bs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) struct xfs_inobt_rec_incore *irec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) struct xfs_mount *mp = bs->sc->mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) struct xchk_iallocbt *iabt = bs->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) struct xfs_ino_geometry *igeo = M_IGEO(mp);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) * finobt records have different positioning requirements than inobt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) * records: each finobt record must have a corresponding inobt record.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) * That is checked in the xref function, so for now we only catch the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) * obvious case where the record isn't at all aligned properly.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) * Note that if a fs block contains more than a single chunk of inodes,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) * we will have finobt records only for those chunks containing free
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) * inodes, and therefore expect chunk alignment of finobt records.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) * Otherwise, we expect that the finobt record is aligned to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) * cluster alignment as told by the superblock.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) if (bs->cur->bc_btnum == XFS_BTNUM_FINO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) unsigned int imask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) imask = min_t(unsigned int, XFS_INODES_PER_CHUNK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) igeo->cluster_align_inodes) - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) if (irec->ir_startino & imask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) if (iabt->next_startino != NULLAGINO) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) * We're midway through a cluster of inodes that is mapped by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) * multiple inobt records. Did we get the record for the next
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) * irec in the sequence?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) if (irec->ir_startino != iabt->next_startino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) iabt->next_startino += XFS_INODES_PER_CHUNK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) /* Are we done with the cluster? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) if (iabt->next_startino >= iabt->next_cluster_ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) iabt->next_startino = NULLAGINO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) iabt->next_cluster_ino = NULLAGINO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /* inobt records must be aligned to cluster and inoalignmnt size. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) if (irec->ir_startino & (igeo->cluster_align_inodes - 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) if (irec->ir_startino & (igeo->inodes_per_cluster - 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) if (igeo->inodes_per_cluster <= XFS_INODES_PER_CHUNK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) * If this is the start of an inode cluster that can be mapped by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) * multiple inobt records, the next inobt record must follow exactly
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) * after this one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) iabt->next_startino = irec->ir_startino + XFS_INODES_PER_CHUNK;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) iabt->next_cluster_ino = irec->ir_startino + igeo->inodes_per_cluster;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) /* Scrub an inobt/finobt record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) xchk_iallocbt_rec(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) struct xchk_btree *bs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) union xfs_btree_rec *rec)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) struct xfs_mount *mp = bs->cur->bc_mp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) struct xchk_iallocbt *iabt = bs->private;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) struct xfs_inobt_rec_incore irec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) uint64_t holes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) xfs_agnumber_t agno = bs->cur->bc_ag.agno;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) xfs_agino_t agino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) xfs_extlen_t len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) int holecount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) int error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) unsigned int real_freecount;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) uint16_t holemask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) xfs_inobt_btrec_to_irec(mp, rec, &irec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) if (irec.ir_count > XFS_INODES_PER_CHUNK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) irec.ir_freecount > XFS_INODES_PER_CHUNK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) real_freecount = irec.ir_freecount +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) (XFS_INODES_PER_CHUNK - irec.ir_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) if (real_freecount != xchk_iallocbt_freecount(irec.ir_free))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) agino = irec.ir_startino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) /* Record has to be properly aligned within the AG. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) if (!xfs_verify_agino(mp, agno, agino) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) !xfs_verify_agino(mp, agno, agino + XFS_INODES_PER_CHUNK - 1)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) xchk_iallocbt_rec_alignment(bs, &irec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) iabt->inodes += irec.ir_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) /* Handle non-sparse inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) if (!xfs_inobt_issparse(irec.ir_holemask)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) len = XFS_B_TO_FSB(mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) XFS_INODES_PER_CHUNK * mp->m_sb.sb_inodesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) if (irec.ir_count != XFS_INODES_PER_CHUNK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) if (!xchk_iallocbt_chunk(bs, &irec, agino, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) goto check_clusters;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) /* Check each chunk of a sparse inode cluster. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) holemask = irec.ir_holemask;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) holecount = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) len = XFS_B_TO_FSB(mp,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) XFS_INODES_PER_HOLEMASK_BIT * mp->m_sb.sb_inodesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) holes = ~xfs_inobt_irec_to_allocmask(&irec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) if ((holes & irec.ir_free) != holes ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) irec.ir_freecount > irec.ir_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) for (i = 0; i < XFS_INOBT_HOLEMASK_BITS; i++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) if (holemask & 1)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) holecount += XFS_INODES_PER_HOLEMASK_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) else if (!xchk_iallocbt_chunk(bs, &irec, agino, len))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) holemask >>= 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) agino += XFS_INODES_PER_HOLEMASK_BIT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) if (holecount > XFS_INODES_PER_CHUNK ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) holecount + irec.ir_count != XFS_INODES_PER_CHUNK)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) xchk_btree_set_corrupt(bs->sc, bs->cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) check_clusters:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) error = xchk_iallocbt_check_clusters(bs, &irec);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) * Make sure the inode btrees are as large as the rmap thinks they are.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) * Don't bother if we're missing btree cursors, as we're already corrupt.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) STATIC void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) xchk_iallocbt_xref_rmap_btreeblks(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) int which)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) xfs_filblks_t blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) xfs_extlen_t inobt_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) xfs_extlen_t finobt_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) if (!sc->sa.ino_cur || !sc->sa.rmap_cur ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) (xfs_sb_version_hasfinobt(&sc->mp->m_sb) && !sc->sa.fino_cur) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) xchk_skip_xref(sc->sm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) /* Check that we saw as many inobt blocks as the rmap says. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) error = xfs_btree_count_blocks(sc->sa.ino_cur, &inobt_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) if (!xchk_process_error(sc, 0, 0, &error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) if (sc->sa.fino_cur) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) error = xfs_btree_count_blocks(sc->sa.fino_cur, &finobt_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) if (!xchk_process_error(sc, 0, 0, &error))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) &XFS_RMAP_OINFO_INOBT, &blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) if (blocks != inobt_blocks + finobt_blocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) xchk_btree_set_corrupt(sc, sc->sa.ino_cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) * Make sure that the inobt records point to the same number of blocks as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) * the rmap says are owned by inodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) STATIC void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) xchk_iallocbt_xref_rmap_inodes(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) int which,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) unsigned long long inodes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) xfs_filblks_t blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) xfs_filblks_t inode_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) /* Check that we saw as many inode blocks as the rmap knows about. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) &XFS_RMAP_OINFO_INODES, &blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) inode_blocks = XFS_B_TO_FSB(sc->mp, inodes * sc->mp->m_sb.sb_inodesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) if (blocks != inode_blocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) /* Scrub the inode btrees for some AG. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) STATIC int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) xchk_iallocbt(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) xfs_btnum_t which)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) struct xfs_btree_cur *cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) struct xchk_iallocbt iabt = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) .inodes = 0,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) .next_startino = NULLAGINO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) .next_cluster_ino = NULLAGINO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) cur = which == XFS_BTNUM_INO ? sc->sa.ino_cur : sc->sa.fino_cur;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) error = xchk_btree(sc, cur, xchk_iallocbt_rec, &XFS_RMAP_OINFO_INOBT,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) &iabt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) xchk_iallocbt_xref_rmap_btreeblks(sc, which);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) * If we're scrubbing the inode btree, inode_blocks is the number of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) * blocks pointed to by all the inode chunk records. Therefore, we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) * should compare to the number of inode chunk blocks that the rmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) * knows about. We can't do this for the finobt since it only points
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) * to inode chunks with free inodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) if (which == XFS_BTNUM_INO)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) xchk_iallocbt_xref_rmap_inodes(sc, which, iabt.inodes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) xchk_inobt(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) struct xfs_scrub *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) return xchk_iallocbt(sc, XFS_BTNUM_INO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) xchk_finobt(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) struct xfs_scrub *sc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) return xchk_iallocbt(sc, XFS_BTNUM_FINO);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) /* See if an inode btree has (or doesn't have) an inode chunk record. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) static inline void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) xchk_xref_inode_check(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) xfs_agblock_t agbno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) xfs_extlen_t len,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) struct xfs_btree_cur **icur,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) bool should_have_inodes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 629) bool has_inodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 630) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 631)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 632) if (!(*icur) || xchk_skip_xref(sc->sm))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 633) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 634)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 635) error = xfs_ialloc_has_inodes_at_extent(*icur, agbno, len, &has_inodes);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 636) if (!xchk_should_check_xref(sc, &error, icur))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 637) return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 638) if (has_inodes != should_have_inodes)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 639) xchk_btree_xref_set_corrupt(sc, *icur, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 640) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 641)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 642) /* xref check that the extent is not covered by inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 643) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 644) xchk_xref_is_not_inode_chunk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 645) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 646) xfs_agblock_t agbno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 647) xfs_extlen_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 648) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 649) xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 650) xchk_xref_inode_check(sc, agbno, len, &sc->sa.fino_cur, false);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 651) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 652)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 653) /* xref check that the extent is covered by inodes */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 654) void
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 655) xchk_xref_is_inode_chunk(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 656) struct xfs_scrub *sc,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 657) xfs_agblock_t agbno,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 658) xfs_extlen_t len)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 659) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 660) xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, true);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 661) }