Lines Matching +full:scrubber +full:- +full:done
1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017-2023 Oracle. All Rights Reserved.
59 * For non-verifier errors (e.g. ENOMEM) we return false to tell the
88 case -EDEADLOCK: in __xchk_process_error()
89 case -ECHRNG: in __xchk_process_error()
92 sc->ip ? sc->ip : XFS_I(file_inode(sc->file)), in __xchk_process_error()
93 sc->sm, *error); in __xchk_process_error()
95 case -ECANCELED: in __xchk_process_error()
104 case -EFSBADCRC: in __xchk_process_error()
105 case -EFSCORRUPTED: in __xchk_process_error()
107 sc->sm->sm_flags |= errflag; in __xchk_process_error()
163 case -EDEADLOCK: in __xchk_fblock_process_error()
164 case -ECHRNG: in __xchk_fblock_process_error()
166 trace_xchk_deadlock_retry(sc->ip, sc->sm, *error); in __xchk_fblock_process_error()
168 case -ECANCELED: in __xchk_fblock_process_error()
178 case -EFSBADCRC: in __xchk_fblock_process_error()
179 case -EFSCORRUPTED: in __xchk_fblock_process_error()
181 sc->sm->sm_flags |= errflag; in __xchk_fblock_process_error()
232 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN; in xchk_block_set_preen()
246 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_PREEN; in xchk_ino_set_preen()
255 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; in xchk_set_corrupt()
265 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; in xchk_block_set_corrupt()
277 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; in xchk_qcheck_set_corrupt()
282 /* Record a corruption while cross-referencing. */
288 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; in xchk_block_xref_set_corrupt()
302 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; in xchk_ino_set_corrupt()
306 /* Record a corruption while cross-referencing with an inode. */
312 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; in xchk_ino_xref_set_corrupt()
323 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; in xchk_fblock_set_corrupt()
327 /* Record a corruption while cross-referencing a fork block. */
334 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XCORRUPT; in xchk_fblock_xref_set_corrupt()
347 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING; in xchk_ino_set_warning()
358 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_WARNING; in xchk_fblock_set_warning()
367 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_INCOMPLETE; in xchk_set_incomplete()
372 * rmap scrubbing -- compute the number of blocks with a given owner,
391 irec_attr = rec->rm_flags & XFS_RMAP_ATTR_FORK; in xchk_count_rmap_ownedby_irec()
392 oinfo_attr = sroi->oinfo->oi_flags & XFS_OWNER_INFO_ATTR_FORK; in xchk_count_rmap_ownedby_irec()
394 if (rec->rm_owner != sroi->oinfo->oi_owner) in xchk_count_rmap_ownedby_irec()
397 if (XFS_RMAP_NON_INODE_OWNER(rec->rm_owner) || irec_attr == oinfo_attr) in xchk_count_rmap_ownedby_irec()
398 (*sroi->blocks) += rec->rm_blockcount; in xchk_count_rmap_ownedby_irec()
439 if (sc->sm->sm_type != XFS_SCRUB_TYPE_AGF && in want_ag_read_header_failure()
440 sc->sm->sm_type != XFS_SCRUB_TYPE_AGFL && in want_ag_read_header_failure()
441 sc->sm->sm_type != XFS_SCRUB_TYPE_AGI) in want_ag_read_header_failure()
446 * other headers to cross-check them, but this isn't required. in want_ag_read_header_failure()
448 if (sc->sm->sm_type == type) in want_ag_read_header_failure()
467 error = xfs_ialloc_read_agi(sa->pag, sc->tp, 0, &sa->agi_bp); in xchk_perag_read_headers()
471 error = xfs_alloc_read_agf(sa->pag, sc->tp, 0, &sa->agf_bp); in xchk_perag_read_headers()
486 struct xchk_ag *sa = &sc->sa; in xchk_perag_drain_and_lock()
489 ASSERT(sa->pag != NULL); in xchk_perag_drain_and_lock()
490 ASSERT(sa->agi_bp == NULL); in xchk_perag_drain_and_lock()
491 ASSERT(sa->agf_bp == NULL); in xchk_perag_drain_and_lock()
506 if (sc->ip) in xchk_perag_drain_and_lock()
517 * (which is why we don't need a per-AG lock), but scrub and in xchk_perag_drain_and_lock()
532 if (!xfs_group_intent_busy(pag_group(sa->pag))) in xchk_perag_drain_and_lock()
535 if (sa->agf_bp) { in xchk_perag_drain_and_lock()
536 xfs_trans_brelse(sc->tp, sa->agf_bp); in xchk_perag_drain_and_lock()
537 sa->agf_bp = NULL; in xchk_perag_drain_and_lock()
540 if (sa->agi_bp) { in xchk_perag_drain_and_lock()
541 xfs_trans_brelse(sc->tp, sa->agi_bp); in xchk_perag_drain_and_lock()
542 sa->agi_bp = NULL; in xchk_perag_drain_and_lock()
545 if (!(sc->flags & XCHK_FSGATES_DRAIN)) in xchk_perag_drain_and_lock()
546 return -ECHRNG; in xchk_perag_drain_and_lock()
547 error = xfs_group_intent_drain(pag_group(sa->pag)); in xchk_perag_drain_and_lock()
548 if (error == -ERESTARTSYS) in xchk_perag_drain_and_lock()
549 error = -EINTR; in xchk_perag_drain_and_lock()
556 * Grab the per-AG structure, grab all AG header buffers, and wait until there
557 * aren't any pending intents. Returns -ENOENT if we can't grab the perag
566 struct xfs_mount *mp = sc->mp; in xchk_ag_read_headers()
568 ASSERT(!sa->pag); in xchk_ag_read_headers()
569 sa->pag = xfs_perag_get(mp, agno); in xchk_ag_read_headers()
570 if (!sa->pag) in xchk_ag_read_headers()
571 return -ENOENT; in xchk_ag_read_headers()
581 if (sa->refc_cur) in xchk_ag_btcur_free()
582 xfs_btree_del_cursor(sa->refc_cur, XFS_BTREE_ERROR); in xchk_ag_btcur_free()
583 if (sa->rmap_cur) in xchk_ag_btcur_free()
584 xfs_btree_del_cursor(sa->rmap_cur, XFS_BTREE_ERROR); in xchk_ag_btcur_free()
585 if (sa->fino_cur) in xchk_ag_btcur_free()
586 xfs_btree_del_cursor(sa->fino_cur, XFS_BTREE_ERROR); in xchk_ag_btcur_free()
587 if (sa->ino_cur) in xchk_ag_btcur_free()
588 xfs_btree_del_cursor(sa->ino_cur, XFS_BTREE_ERROR); in xchk_ag_btcur_free()
589 if (sa->cnt_cur) in xchk_ag_btcur_free()
590 xfs_btree_del_cursor(sa->cnt_cur, XFS_BTREE_ERROR); in xchk_ag_btcur_free()
591 if (sa->bno_cur) in xchk_ag_btcur_free()
592 xfs_btree_del_cursor(sa->bno_cur, XFS_BTREE_ERROR); in xchk_ag_btcur_free()
594 sa->refc_cur = NULL; in xchk_ag_btcur_free()
595 sa->rmap_cur = NULL; in xchk_ag_btcur_free()
596 sa->fino_cur = NULL; in xchk_ag_btcur_free()
597 sa->ino_cur = NULL; in xchk_ag_btcur_free()
598 sa->bno_cur = NULL; in xchk_ag_btcur_free()
599 sa->cnt_cur = NULL; in xchk_ag_btcur_free()
608 struct xfs_mount *mp = sc->mp; in xchk_ag_btcur_init()
610 if (sa->agf_bp) { in xchk_ag_btcur_init()
611 /* Set up a bnobt cursor for cross-referencing. */ in xchk_ag_btcur_init()
612 sa->bno_cur = xfs_bnobt_init_cursor(mp, sc->tp, sa->agf_bp, in xchk_ag_btcur_init()
613 sa->pag); in xchk_ag_btcur_init()
614 xchk_ag_btree_del_cursor_if_sick(sc, &sa->bno_cur, in xchk_ag_btcur_init()
617 /* Set up a cntbt cursor for cross-referencing. */ in xchk_ag_btcur_init()
618 sa->cnt_cur = xfs_cntbt_init_cursor(mp, sc->tp, sa->agf_bp, in xchk_ag_btcur_init()
619 sa->pag); in xchk_ag_btcur_init()
620 xchk_ag_btree_del_cursor_if_sick(sc, &sa->cnt_cur, in xchk_ag_btcur_init()
623 /* Set up a rmapbt cursor for cross-referencing. */ in xchk_ag_btcur_init()
625 sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, in xchk_ag_btcur_init()
626 sa->agf_bp, sa->pag); in xchk_ag_btcur_init()
627 xchk_ag_btree_del_cursor_if_sick(sc, &sa->rmap_cur, in xchk_ag_btcur_init()
631 /* Set up a refcountbt cursor for cross-referencing. */ in xchk_ag_btcur_init()
633 sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp, in xchk_ag_btcur_init()
634 sa->agf_bp, sa->pag); in xchk_ag_btcur_init()
635 xchk_ag_btree_del_cursor_if_sick(sc, &sa->refc_cur, in xchk_ag_btcur_init()
640 if (sa->agi_bp) { in xchk_ag_btcur_init()
641 /* Set up a inobt cursor for cross-referencing. */ in xchk_ag_btcur_init()
642 sa->ino_cur = xfs_inobt_init_cursor(sa->pag, sc->tp, in xchk_ag_btcur_init()
643 sa->agi_bp); in xchk_ag_btcur_init()
644 xchk_ag_btree_del_cursor_if_sick(sc, &sa->ino_cur, in xchk_ag_btcur_init()
647 /* Set up a finobt cursor for cross-referencing. */ in xchk_ag_btcur_init()
649 sa->fino_cur = xfs_finobt_init_cursor(sa->pag, sc->tp, in xchk_ag_btcur_init()
650 sa->agi_bp); in xchk_ag_btcur_init()
651 xchk_ag_btree_del_cursor_if_sick(sc, &sa->fino_cur, in xchk_ag_btcur_init()
665 if (sa->agf_bp) { in xchk_ag_free()
666 xfs_trans_brelse(sc->tp, sa->agf_bp); in xchk_ag_free()
667 sa->agf_bp = NULL; in xchk_ag_free()
669 if (sa->agi_bp) { in xchk_ag_free()
670 xfs_trans_brelse(sc->tp, sa->agi_bp); in xchk_ag_free()
671 sa->agi_bp = NULL; in xchk_ag_free()
673 if (sa->pag) { in xchk_ag_free()
674 xfs_perag_put(sa->pag); in xchk_ag_free()
675 sa->pag = NULL; in xchk_ag_free()
704 * For scrubbing a realtime group, grab all the in-core resources we'll need to
707 * non-zero lockflags or concurrency problems will result. The @rtglock_flags
716 ASSERT(sr->rtg == NULL); in xchk_rtgroup_init()
717 ASSERT(sr->rtlock_flags == 0); in xchk_rtgroup_init()
719 sr->rtg = xfs_rtgroup_get(sc->mp, rgno); in xchk_rtgroup_init()
720 if (!sr->rtg) in xchk_rtgroup_init()
721 return -ENOENT; in xchk_rtgroup_init()
734 ASSERT(sr->rtg != NULL); in xchk_rtgroup_lock()
743 xfs_rtgroup_lock(sr->rtg, rtglock_flags); in xchk_rtgroup_lock()
744 sr->rtlock_flags = rtglock_flags; in xchk_rtgroup_lock()
752 xfs_rtgroup_lock(sr->rtg, rtglock_flags); in xchk_rtgroup_lock()
755 * If we've grabbed a non-metadata file for scrubbing, we in xchk_rtgroup_lock()
759 if (sc->ip && !xfs_is_internal_inode(sc->ip)) in xchk_rtgroup_lock()
781 if (!xfs_group_intent_busy(rtg_group(sr->rtg))) in xchk_rtgroup_lock()
784 xfs_rtgroup_unlock(sr->rtg, rtglock_flags); in xchk_rtgroup_lock()
786 if (!(sc->flags & XCHK_FSGATES_DRAIN)) in xchk_rtgroup_lock()
787 return -ECHRNG; in xchk_rtgroup_lock()
788 error = xfs_group_intent_drain(rtg_group(sr->rtg)); in xchk_rtgroup_lock()
790 if (error == -ERESTARTSYS) in xchk_rtgroup_lock()
791 error = -EINTR; in xchk_rtgroup_lock()
796 sr->rtlock_flags = rtglock_flags; in xchk_rtgroup_lock()
798 if (xfs_has_rtrmapbt(sc->mp) && (rtglock_flags & XFS_RTGLOCK_RMAP)) in xchk_rtgroup_lock()
799 sr->rmap_cur = xfs_rtrmapbt_init_cursor(sc->tp, sr->rtg); in xchk_rtgroup_lock()
801 if (xfs_has_rtreflink(sc->mp) && (rtglock_flags & XFS_RTGLOCK_REFCOUNT)) in xchk_rtgroup_lock()
802 sr->refc_cur = xfs_rtrefcountbt_init_cursor(sc->tp, sr->rtg); in xchk_rtgroup_lock()
809 * group. This has to be done /before/ committing (or cancelling) the scrub
816 if (sr->rmap_cur) in xchk_rtgroup_btcur_free()
817 xfs_btree_del_cursor(sr->rmap_cur, XFS_BTREE_ERROR); in xchk_rtgroup_btcur_free()
818 if (sr->refc_cur) in xchk_rtgroup_btcur_free()
819 xfs_btree_del_cursor(sr->refc_cur, XFS_BTREE_ERROR); in xchk_rtgroup_btcur_free()
821 sr->refc_cur = NULL; in xchk_rtgroup_btcur_free()
822 sr->rmap_cur = NULL; in xchk_rtgroup_btcur_free()
826 * Unlock the realtime group. This must be done /after/ committing (or
833 ASSERT(sr->rtg != NULL); in xchk_rtgroup_unlock()
835 if (sr->rtlock_flags) { in xchk_rtgroup_unlock()
836 xfs_rtgroup_unlock(sr->rtg, sr->rtlock_flags); in xchk_rtgroup_unlock()
837 sr->rtlock_flags = 0; in xchk_rtgroup_unlock()
842 * Unlock the realtime group and release its resources. This must be done
850 ASSERT(sr->rtg != NULL); in xchk_rtgroup_free()
854 xfs_rtgroup_put(sr->rtg); in xchk_rtgroup_free()
855 sr->rtg = NULL; in xchk_rtgroup_free()
859 /* Per-scrubber setup functions */
865 xfs_trans_cancel(sc->tp); in xchk_trans_cancel()
866 sc->tp = NULL; in xchk_trans_cancel()
873 sc->tp = xfs_trans_alloc_empty(sc->mp); in xchk_trans_alloc_empty()
877 * Grab an empty transaction so that we can re-grab locked buffers if
891 if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR) in xchk_trans_alloc()
892 return xfs_trans_alloc(sc->mp, &M_RES(sc->mp)->tr_itruncate, in xchk_trans_alloc()
893 resblks, 0, 0, &sc->tp); in xchk_trans_alloc()
924 struct xfs_mount *mp = sc->mp; in xchk_setup_ag_btree()
943 return xchk_ag_init(sc, sc->sm->sm_agno, &sc->sa); in xchk_setup_ag_btree()
956 xfs_ail_push_all_sync(mp->m_ail); in xchk_checkpoint_log()
967 ASSERT(sc->tp != NULL); in xchk_iget()
969 return xfs_iget(sc->mp, sc->tp, inum, XCHK_IGET_FLAGS, 0, ipp); in xchk_iget()
975 * can single-step the loading process to see where things went wrong.
981 * can include -EINVAL and -ENOENT for invalid inode numbers or inodes that are
986 * If a fatal signal is pending, return -EINTR, a NULL AGI, and a NULL inode.
995 struct xfs_mount *mp = sc->mp; in xchk_iget_agi()
996 struct xfs_trans *tp = sc->tp; in xchk_iget_agi()
1000 ASSERT(sc->tp != NULL); in xchk_iget_agi()
1022 if (error == -EAGAIN) { in xchk_iget_agi()
1062 ASSERT(sc->tp != NULL); in xchk_ino_dqattach()
1063 ASSERT(sc->ip != NULL); in xchk_ino_dqattach()
1078 if (VFS_I(ip)->i_generation != sc->sm->sm_gen) { in xchk_install_handle_inode()
1080 return -ENOENT; in xchk_install_handle_inode()
1083 sc->ip = ip; in xchk_install_handle_inode()
1088 * Install an already-referenced inode for scrubbing. Get our own reference to
1098 xchk_ino_set_corrupt(sc, ip->i_ino); in xchk_install_live_inode()
1099 return -EFSCORRUPTED; in xchk_install_live_inode()
1102 sc->ip = ip; in xchk_install_live_inode()
1118 struct xfs_mount *mp = sc->mp; in xchk_iget_for_scrubbing()
1121 struct xfs_inode *ip_in = XFS_I(file_inode(sc->file)); in xchk_iget_for_scrubbing()
1123 xfs_agnumber_t agno = XFS_INO_TO_AGNO(mp, sc->sm->sm_ino); in xchk_iget_for_scrubbing()
1126 ASSERT(sc->tp == NULL); in xchk_iget_for_scrubbing()
1129 if (sc->sm->sm_ino == 0 || sc->sm->sm_ino == ip_in->i_ino) in xchk_iget_for_scrubbing()
1133 * On pre-metadir filesystems, reject internal metadata files. For in xchk_iget_for_scrubbing()
1136 * validate the lack of parent pointers in the sb-root metadata inodes. in xchk_iget_for_scrubbing()
1138 if (!xfs_has_metadir(mp) && xfs_is_sb_inum(mp, sc->sm->sm_ino)) in xchk_iget_for_scrubbing()
1139 return -ENOENT; in xchk_iget_for_scrubbing()
1141 if (!xfs_verify_ino(sc->mp, sc->sm->sm_ino)) in xchk_iget_for_scrubbing()
1142 return -ENOENT; in xchk_iget_for_scrubbing()
1145 error = xchk_iget_safe(sc, sc->sm->sm_ino, &ip); in xchk_iget_for_scrubbing()
1148 if (error == -ENOENT) in xchk_iget_for_scrubbing()
1150 if (error != -EINVAL) in xchk_iget_for_scrubbing()
1172 error = xchk_iget_agi(sc, sc->sm->sm_ino, &agi_bp, &ip); in xchk_iget_for_scrubbing()
1178 if (error == -ENOENT) in xchk_iget_for_scrubbing()
1180 if (error != -EINVAL) in xchk_iget_for_scrubbing()
1186 error = -ECANCELED; in xchk_iget_for_scrubbing()
1206 pag = xfs_perag_get(mp, XFS_INO_TO_AGNO(mp, sc->sm->sm_ino)); in xchk_iget_for_scrubbing()
1208 error = -EFSCORRUPTED; in xchk_iget_for_scrubbing()
1212 error = xfs_imap(pag, sc->tp, sc->sm->sm_ino, &imap, in xchk_iget_for_scrubbing()
1215 if (error == -EINVAL || error == -ENOENT) in xchk_iget_for_scrubbing()
1218 error = -EFSCORRUPTED; in xchk_iget_for_scrubbing()
1223 trace_xchk_op_error(sc, agno, XFS_INO_TO_AGBNO(mp, sc->sm->sm_ino), in xchk_iget_for_scrubbing()
1229 return -ENOENT; in xchk_iget_for_scrubbing()
1238 if (sc->tp) { in xchk_irele()
1251 spin_lock(&VFS_I(ip)->i_lock); in xchk_irele()
1252 VFS_I(ip)->i_state &= ~I_DONTCACHE; in xchk_irele()
1253 spin_unlock(&VFS_I(ip)->i_lock); in xchk_irele()
1261 * this to operate on user-accessible regular file data because the MMAPLOCK is
1301 xfs_ilock(sc->ip, ilock_flags); in xchk_ilock()
1302 sc->ilock_flags |= ilock_flags; in xchk_ilock()
1310 if (xfs_ilock_nowait(sc->ip, ilock_flags)) { in xchk_ilock_nowait()
1311 sc->ilock_flags |= ilock_flags; in xchk_ilock_nowait()
1323 sc->ilock_flags &= ~ilock_flags; in xchk_iunlock()
1324 xfs_iunlock(sc->ip, ilock_flags); in xchk_iunlock()
1328 * Predicate that decides if we need to evaluate the cross-reference check.
1329 * If there was an error accessing the cross-reference btree, just delete
1339 if (xchk_skip_xref(sc->sm)) in xchk_should_check_xref()
1355 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_XFAIL; in xchk_should_check_xref()
1359 * Errors encountered during cross-referencing with another in xchk_should_check_xref()
1360 * data structure should not cause this scrubber to abort. in xchk_should_check_xref()
1366 /* Run the structure verifiers on in-memory buffers to detect bad memory. */
1374 if (bp->b_ops == NULL) { in xchk_buffer_recheck()
1378 if (bp->b_ops->verify_struct == NULL) { in xchk_buffer_recheck()
1382 fa = bp->b_ops->verify_struct(bp); in xchk_buffer_recheck()
1385 sc->sm->sm_flags |= XFS_SCRUB_OFLAG_CORRUPT; in xchk_buffer_recheck()
1398 error = sub->sc.ops->scrub(&sub->sc); in xchk_metadata_inode_subtype()
1405 * pointed to by sc->ip and the ILOCK must be held.
1414 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_metadata_inode_forks()
1419 if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) in xchk_metadata_inode_forks()
1423 if (sc->ip->i_diflags & XFS_DIFLAG_REALTIME) { in xchk_metadata_inode_forks()
1424 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_metadata_inode_forks()
1429 if (xfs_is_reflink_inode(sc->ip)) { in xchk_metadata_inode_forks()
1430 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_metadata_inode_forks()
1434 /* Invoke the data fork scrubber. */ in xchk_metadata_inode_forks()
1436 if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) in xchk_metadata_inode_forks()
1440 if (xfs_has_reflink(sc->mp)) { in xchk_metadata_inode_forks()
1441 error = xfs_reflink_inode_has_shared_extents(sc->tp, sc->ip, in xchk_metadata_inode_forks()
1447 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_metadata_inode_forks()
1454 if (xfs_inode_hasattr(sc->ip)) { in xchk_metadata_inode_forks()
1455 if (!xfs_has_metadir(sc->mp)) { in xchk_metadata_inode_forks()
1456 xchk_ino_set_corrupt(sc, sc->ip->i_ino); in xchk_metadata_inode_forks()
1461 if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) in xchk_metadata_inode_forks()
1480 ASSERT(!(sc->flags & scrub_fsgates)); in xchk_fsgates_enable()
1496 sc->flags |= scrub_fsgates; in xchk_fsgates_enable()
1505 * is invalid, return -EINVAL. If the inode is not in cache, return -ENODATA.
1506 * If the inode is being reclaimed, return -ENODATA because we know the inode
1521 struct xfs_mount *mp = sc->mp; in xchk_inode_is_allocated()
1522 struct xfs_perag *pag = sc->sa.pag; in xchk_inode_is_allocated()
1530 return -EINVAL; in xchk_inode_is_allocated()
1534 if (sc->sa.agi_bp == NULL) { in xchk_inode_is_allocated()
1535 ASSERT(sc->sa.agi_bp != NULL); in xchk_inode_is_allocated()
1536 return -EINVAL; in xchk_inode_is_allocated()
1542 return -EINVAL; in xchk_inode_is_allocated()
1544 error = -ENODATA; in xchk_inode_is_allocated()
1546 ip = radix_tree_lookup(&pag->pag_ici_root, agino); in xchk_inode_is_allocated()
1557 spin_lock(&ip->i_flags_lock); in xchk_inode_is_allocated()
1558 if (ip->i_ino != ino) in xchk_inode_is_allocated()
1576 if (!(ip->i_flags & (XFS_NEED_INACTIVE | XFS_INEW | XFS_IRECLAIMABLE | in xchk_inode_is_allocated()
1579 ASSERT(VFS_I(ip)->i_mode != 0); in xchk_inode_is_allocated()
1593 if (ip->i_flags & XFS_INEW) { in xchk_inode_is_allocated()
1595 ASSERT(VFS_I(ip)->i_mode != 0); in xchk_inode_is_allocated()
1602 if ((ip->i_flags & XFS_NEED_INACTIVE) && in xchk_inode_is_allocated()
1603 !(ip->i_flags & XFS_INACTIVATING)) { in xchk_inode_is_allocated()
1605 ASSERT(VFS_I(ip)->i_mode != 0); in xchk_inode_is_allocated()
1641 *inuse = VFS_I(ip)->i_mode != 0; in xchk_inode_is_allocated()
1645 spin_unlock(&ip->i_flags_lock); in xchk_inode_is_allocated()
1655 struct xfs_mount *mp = ip->i_mount; in xchk_inode_is_dirtree_root()
1657 return ip == mp->m_rootip || in xchk_inode_is_dirtree_root()
1658 (xfs_has_metadir(mp) && ip == mp->m_metadirip); in xchk_inode_is_dirtree_root()
1666 xfs_is_sb_inum(ip->i_mount, ip->i_ino); in xchk_inode_is_sb_rooted()
1673 struct xfs_mount *mp = ip->i_mount; in xchk_inode_rootdir_inum()
1676 return mp->m_metadirip->i_ino; in xchk_inode_rootdir_inum()
1677 return mp->m_rootip->i_ino; in xchk_inode_rootdir_inum()
1689 if (!sc->sr.rtg) { in xchk_meta_btree_count_blocks()
1691 return -EFSCORRUPTED; in xchk_meta_btree_count_blocks()
1694 switch (sc->ip->i_metatype) { in xchk_meta_btree_count_blocks()
1696 cur = xfs_rtrmapbt_init_cursor(sc->tp, sc->sr.rtg); in xchk_meta_btree_count_blocks()
1699 cur = xfs_rtrefcountbt_init_cursor(sc->tp, sc->sr.rtg); in xchk_meta_btree_count_blocks()
1703 return -EFSCORRUPTED; in xchk_meta_btree_count_blocks()
1710 (*count)--; /* don't count the btree iroot */ in xchk_meta_btree_count_blocks()
1723 struct xfs_ifork *ifp = xfs_ifork_ptr(sc->ip, whichfork); in xchk_inode_count_blocks()
1731 if (ifp->if_format == XFS_DINODE_FMT_META_BTREE) { in xchk_inode_count_blocks()
1736 return xfs_bmap_count_blocks(sc->tp, sc->ip, whichfork, nextents, in xchk_inode_count_blocks()