Lines Matching +full:scrubber +full:- +full:done
1 // SPDX-License-Identifier: GPL-2.0+
35 return xchk_setup_ag_btree(sc, ip, sc->flags & XCHK_TRY_HARDER); in xchk_setup_ag_iallocbt()
38 /* Inode btree scrubber. */
52 * If we're checking the finobt, cross-reference with the inobt.
66 if (sc->sm->sm_type == XFS_SCRUB_TYPE_FINOBT) in xchk_iallocbt_chunk_xref_other()
67 pcur = &sc->sa.ino_cur; in xchk_iallocbt_chunk_xref_other()
69 pcur = &sc->sa.fino_cur; in xchk_iallocbt_chunk_xref_other()
75 if (((irec->ir_freecount > 0 && !has_irec) || in xchk_iallocbt_chunk_xref_other()
76 (irec->ir_freecount == 0 && has_irec))) in xchk_iallocbt_chunk_xref_other()
80 /* Cross-reference with the other btrees. */
89 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_iallocbt_chunk_xref()
106 struct xfs_mount *mp = bs->cur->bc_mp; in xchk_iallocbt_chunk()
107 xfs_agnumber_t agno = bs->cur->bc_ag.agno; in xchk_iallocbt_chunk()
113 !xfs_verify_agbno(mp, agno, bno + len - 1)) in xchk_iallocbt_chunk()
114 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_chunk()
116 xchk_iallocbt_chunk_xref(bs->sc, irec, agino, bno, len); in xchk_iallocbt_chunk()
132 * record. First we try querying the in-core inode state, and if the inode
133 * isn't loaded we examine the on-disk inode directly.
142 * @dip is the on-disk inode.
151 struct xfs_mount *mp = bs->cur->bc_mp; in xchk_iallocbt_check_cluster_ifree()
159 if (xchk_should_terminate(bs->sc, &error)) in xchk_iallocbt_check_cluster_ifree()
166 agino = irec->ir_startino + irec_ino; in xchk_iallocbt_check_cluster_ifree()
167 fsino = XFS_AGINO_TO_INO(mp, bs->cur->bc_ag.agno, agino); in xchk_iallocbt_check_cluster_ifree()
168 irec_free = (irec->ir_free & XFS_INOBT_MASK(irec_ino)); in xchk_iallocbt_check_cluster_ifree()
170 if (be16_to_cpu(dip->di_magic) != XFS_DINODE_MAGIC || in xchk_iallocbt_check_cluster_ifree()
171 (dip->di_version >= 3 && be64_to_cpu(dip->di_ino) != fsino)) { in xchk_iallocbt_check_cluster_ifree()
172 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_check_cluster_ifree()
176 error = xfs_icache_inode_is_allocated(mp, bs->cur->bc_tp, fsino, in xchk_iallocbt_check_cluster_ifree()
178 if (error == -ENODATA) { in xchk_iallocbt_check_cluster_ifree()
180 freemask_ok = irec_free ^ !!(dip->di_mode); in xchk_iallocbt_check_cluster_ifree()
181 if (!(bs->sc->flags & XCHK_TRY_HARDER) && !freemask_ok) in xchk_iallocbt_check_cluster_ifree()
182 return -EDEADLOCK; in xchk_iallocbt_check_cluster_ifree()
187 * The inode scrubber can deal with this. in xchk_iallocbt_check_cluster_ifree()
195 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_check_cluster_ifree()
214 struct xfs_mount *mp = bs->cur->bc_mp; in xchk_iallocbt_check_cluster()
218 xfs_agnumber_t agno = bs->cur->bc_ag.agno; in xchk_iallocbt_check_cluster()
226 M_IGEO(mp)->inodes_per_cluster); in xchk_iallocbt_check_cluster()
229 agbno = XFS_AGINO_TO_AGBNO(mp, irec->ir_startino + cluster_base); in xchk_iallocbt_check_cluster()
245 ir_holemask = (irec->ir_holemask & cluster_mask); in xchk_iallocbt_check_cluster()
247 imap.im_len = XFS_FSB_TO_BB(mp, M_IGEO(mp)->blocks_per_cluster); in xchk_iallocbt_check_cluster()
248 imap.im_boffset = XFS_INO_TO_OFFSET(mp, irec->ir_startino) << in xchk_iallocbt_check_cluster()
249 mp->m_sb.sb_inodelog; in xchk_iallocbt_check_cluster()
253 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_check_cluster()
257 trace_xchk_iallocbt_check_cluster(mp, agno, irec->ir_startino, in xchk_iallocbt_check_cluster()
260 XFS_INO_TO_OFFSET(mp, irec->ir_startino + in xchk_iallocbt_check_cluster()
265 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_check_cluster()
271 xchk_xref_is_not_owned_by(bs->sc, agbno, in xchk_iallocbt_check_cluster()
272 M_IGEO(mp)->blocks_per_cluster, in xchk_iallocbt_check_cluster()
277 xchk_xref_is_owned_by(bs->sc, agbno, M_IGEO(mp)->blocks_per_cluster, in xchk_iallocbt_check_cluster()
281 error = xfs_imap_to_bp(mp, bs->cur->bc_tp, &imap, &dip, &cluster_bp, 0); in xchk_iallocbt_check_cluster()
282 if (!xchk_btree_xref_process_error(bs->sc, bs->cur, 0, &error)) in xchk_iallocbt_check_cluster()
289 if (imap.im_boffset >= BBTOB(cluster_bp->b_length)) { in xchk_iallocbt_check_cluster()
290 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_check_cluster()
299 imap.im_boffset += mp->m_sb.sb_inodesize; in xchk_iallocbt_check_cluster()
302 xfs_trans_brelse(bs->cur->bc_tp, cluster_bp); in xchk_iallocbt_check_cluster()
328 cluster_base += M_IGEO(bs->sc->mp)->inodes_per_cluster) { in xchk_iallocbt_check_clusters()
348 struct xfs_mount *mp = bs->sc->mp; in xchk_iallocbt_rec_alignment()
349 struct xchk_iallocbt *iabt = bs->private; in xchk_iallocbt_rec_alignment()
364 if (bs->cur->bc_btnum == XFS_BTNUM_FINO) { in xchk_iallocbt_rec_alignment()
368 igeo->cluster_align_inodes) - 1; in xchk_iallocbt_rec_alignment()
369 if (irec->ir_startino & imask) in xchk_iallocbt_rec_alignment()
370 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec_alignment()
374 if (iabt->next_startino != NULLAGINO) { in xchk_iallocbt_rec_alignment()
380 if (irec->ir_startino != iabt->next_startino) { in xchk_iallocbt_rec_alignment()
381 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec_alignment()
385 iabt->next_startino += XFS_INODES_PER_CHUNK; in xchk_iallocbt_rec_alignment()
387 /* Are we done with the cluster? */ in xchk_iallocbt_rec_alignment()
388 if (iabt->next_startino >= iabt->next_cluster_ino) { in xchk_iallocbt_rec_alignment()
389 iabt->next_startino = NULLAGINO; in xchk_iallocbt_rec_alignment()
390 iabt->next_cluster_ino = NULLAGINO; in xchk_iallocbt_rec_alignment()
396 if (irec->ir_startino & (igeo->cluster_align_inodes - 1)) { in xchk_iallocbt_rec_alignment()
397 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec_alignment()
401 if (irec->ir_startino & (igeo->inodes_per_cluster - 1)) { in xchk_iallocbt_rec_alignment()
402 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec_alignment()
406 if (igeo->inodes_per_cluster <= XFS_INODES_PER_CHUNK) in xchk_iallocbt_rec_alignment()
414 iabt->next_startino = irec->ir_startino + XFS_INODES_PER_CHUNK; in xchk_iallocbt_rec_alignment()
415 iabt->next_cluster_ino = irec->ir_startino + igeo->inodes_per_cluster; in xchk_iallocbt_rec_alignment()
424 struct xfs_mount *mp = bs->cur->bc_mp; in xchk_iallocbt_rec()
425 struct xchk_iallocbt *iabt = bs->private; in xchk_iallocbt_rec()
428 xfs_agnumber_t agno = bs->cur->bc_ag.agno; in xchk_iallocbt_rec()
441 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec()
444 (XFS_INODES_PER_CHUNK - irec.ir_count); in xchk_iallocbt_rec()
446 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec()
451 !xfs_verify_agino(mp, agno, agino + XFS_INODES_PER_CHUNK - 1)) { in xchk_iallocbt_rec()
452 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec()
457 if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_iallocbt_rec()
460 iabt->inodes += irec.ir_count; in xchk_iallocbt_rec()
462 /* Handle non-sparse inodes */ in xchk_iallocbt_rec()
465 XFS_INODES_PER_CHUNK * mp->m_sb.sb_inodesize); in xchk_iallocbt_rec()
467 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec()
478 XFS_INODES_PER_HOLEMASK_BIT * mp->m_sb.sb_inodesize); in xchk_iallocbt_rec()
482 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec()
495 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_iallocbt_rec()
520 if (!sc->sa.ino_cur || !sc->sa.rmap_cur || in xchk_iallocbt_xref_rmap_btreeblks()
521 (xfs_sb_version_hasfinobt(&sc->mp->m_sb) && !sc->sa.fino_cur) || in xchk_iallocbt_xref_rmap_btreeblks()
522 xchk_skip_xref(sc->sm)) in xchk_iallocbt_xref_rmap_btreeblks()
526 error = xfs_btree_count_blocks(sc->sa.ino_cur, &inobt_blocks); in xchk_iallocbt_xref_rmap_btreeblks()
530 if (sc->sa.fino_cur) { in xchk_iallocbt_xref_rmap_btreeblks()
531 error = xfs_btree_count_blocks(sc->sa.fino_cur, &finobt_blocks); in xchk_iallocbt_xref_rmap_btreeblks()
536 error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, in xchk_iallocbt_xref_rmap_btreeblks()
538 if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) in xchk_iallocbt_xref_rmap_btreeblks()
541 xchk_btree_set_corrupt(sc, sc->sa.ino_cur, 0); in xchk_iallocbt_xref_rmap_btreeblks()
558 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) in xchk_iallocbt_xref_rmap_inodes()
562 error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, in xchk_iallocbt_xref_rmap_inodes()
564 if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) in xchk_iallocbt_xref_rmap_inodes()
566 inode_blocks = XFS_B_TO_FSB(sc->mp, inodes * sc->mp->m_sb.sb_inodesize); in xchk_iallocbt_xref_rmap_inodes()
568 xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); in xchk_iallocbt_xref_rmap_inodes()
585 cur = which == XFS_BTNUM_INO ? sc->sa.ino_cur : sc->sa.fino_cur; in xchk_iallocbt()
632 if (!(*icur) || xchk_skip_xref(sc->sm)) in xchk_xref_inode_check()
649 xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, false); in xchk_xref_is_not_inode_chunk()
650 xchk_xref_inode_check(sc, agbno, len, &sc->sa.fino_cur, false); in xchk_xref_is_not_inode_chunk()
660 xchk_xref_inode_check(sc, agbno, len, &sc->sa.ino_cur, true); in xchk_xref_is_inode_chunk()