Lines Matching +full:scrubber +full:- +full:done

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 2021-2024 Oracle. All Rights Reserved.
44 error = xchk_rtgroup_init(sc, sc->sm->sm_agno, &sc->sr); in xchk_setup_rtrefcountbt()
52 error = xchk_install_live_inode(sc, rtg_refcount(sc->sr.rtg)); in xchk_setup_rtrefcountbt()
56 return xchk_rtgroup_lock(sc, &sc->sr, XCHK_RTGLOCK_ALL); in xchk_setup_rtrefcountbt()
59 /* Realtime Reference count btree scrubber. */
78 * need to find ($refcount - $seen) owners for every block in the
134 if (xchk_should_terminate(refchk->sc, &error)) in xchk_rtrefcountbt_rmap_check()
137 rm_last = rec->rm_startblock + rec->rm_blockcount - 1; in xchk_rtrefcountbt_rmap_check()
138 rc_last = refchk->bno + refchk->len - 1; in xchk_rtrefcountbt_rmap_check()
140 /* Confirm that a single-owner refc extent is a CoW stage. */ in xchk_rtrefcountbt_rmap_check()
141 if (refchk->refcount == 1 && rec->rm_owner != XFS_RMAP_OWN_COW) { in xchk_rtrefcountbt_rmap_check()
142 xchk_btree_xref_set_corrupt(refchk->sc, cur, 0); in xchk_rtrefcountbt_rmap_check()
146 if (rec->rm_startblock <= refchk->bno && rm_last >= rc_last) { in xchk_rtrefcountbt_rmap_check()
151 refchk->seen++; in xchk_rtrefcountbt_rmap_check()
162 return -ENOMEM; in xchk_rtrefcountbt_rmap_check()
163 memcpy(&frag->rm, rec, sizeof(frag->rm)); in xchk_rtrefcountbt_rmap_check()
164 list_add_tail(&frag->list, &refchk->fragments); in xchk_rtrefcountbt_rmap_check()
190 target_nr = refchk->refcount - refchk->seen; in xchk_rtrefcountbt_process_rmap_fragments()
195 * There are (refchk->rc.rc_refcount - refchk->nr refcount) in xchk_rtrefcountbt_process_rmap_fragments()
207 list_for_each_entry(frag, &refchk->fragments, list) { in xchk_rtrefcountbt_process_rmap_fragments()
208 if (frag->rm.rm_startblock < bno) in xchk_rtrefcountbt_process_rmap_fragments()
209 goto done; in xchk_rtrefcountbt_process_rmap_fragments()
210 bno = frag->rm.rm_startblock; in xchk_rtrefcountbt_process_rmap_fragments()
218 list_for_each_entry_safe(frag, n, &refchk->fragments, list) { in xchk_rtrefcountbt_process_rmap_fragments()
219 if (frag->rm.rm_startblock > refchk->bno || nr > target_nr) in xchk_rtrefcountbt_process_rmap_fragments()
221 bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; in xchk_rtrefcountbt_process_rmap_fragments()
224 list_move_tail(&frag->list, &worklist); in xchk_rtrefcountbt_process_rmap_fragments()
233 goto done; in xchk_rtrefcountbt_process_rmap_fragments()
235 while (!list_empty(&refchk->fragments)) { in xchk_rtrefcountbt_process_rmap_fragments()
240 bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; in xchk_rtrefcountbt_process_rmap_fragments()
246 list_del(&frag->list); in xchk_rtrefcountbt_process_rmap_fragments()
252 list_for_each_entry_safe(frag, n, &refchk->fragments, list) { in xchk_rtrefcountbt_process_rmap_fragments()
253 bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; in xchk_rtrefcountbt_process_rmap_fragments()
254 if (frag->rm.rm_startblock != rbno) in xchk_rtrefcountbt_process_rmap_fragments()
255 goto done; in xchk_rtrefcountbt_process_rmap_fragments()
256 list_move_tail(&frag->list, &worklist); in xchk_rtrefcountbt_process_rmap_fragments()
259 nr--; in xchk_rtrefcountbt_process_rmap_fragments()
268 * required refcount. Something is wrong, so we're done. in xchk_rtrefcountbt_process_rmap_fragments()
271 goto done; in xchk_rtrefcountbt_process_rmap_fragments()
280 if (rbno < refchk->bno + refchk->len) in xchk_rtrefcountbt_process_rmap_fragments()
281 goto done; in xchk_rtrefcountbt_process_rmap_fragments()
284 refchk->seen = refchk->refcount; in xchk_rtrefcountbt_process_rmap_fragments()
285 done: in xchk_rtrefcountbt_process_rmap_fragments()
288 list_del(&frag->list); in xchk_rtrefcountbt_process_rmap_fragments()
291 list_for_each_entry_safe(frag, n, &refchk->fragments, list) { in xchk_rtrefcountbt_process_rmap_fragments()
292 list_del(&frag->list); in xchk_rtrefcountbt_process_rmap_fragments()
305 .bno = irec->rc_startblock, in xchk_rtrefcountbt_xref_rmap()
306 .len = irec->rc_blockcount, in xchk_rtrefcountbt_xref_rmap()
307 .refcount = irec->rc_refcount, in xchk_rtrefcountbt_xref_rmap()
316 if (!sc->sr.rmap_cur || xchk_skip_xref(sc->sm)) in xchk_rtrefcountbt_xref_rmap()
319 /* Cross-reference with the rmapbt to confirm the refcount. */ in xchk_rtrefcountbt_xref_rmap()
321 low.rm_startblock = irec->rc_startblock; in xchk_rtrefcountbt_xref_rmap()
323 high.rm_startblock = irec->rc_startblock + irec->rc_blockcount - 1; in xchk_rtrefcountbt_xref_rmap()
326 error = xfs_rmap_query_range(sc->sr.rmap_cur, &low, &high, in xchk_rtrefcountbt_xref_rmap()
328 if (!xchk_should_check_xref(sc, &error, &sc->sr.rmap_cur)) in xchk_rtrefcountbt_xref_rmap()
332 if (irec->rc_refcount != refchk.seen) in xchk_rtrefcountbt_xref_rmap()
333 xchk_btree_xref_set_corrupt(sc, sc->sr.rmap_cur, 0); in xchk_rtrefcountbt_xref_rmap()
337 list_del(&frag->list); in xchk_rtrefcountbt_xref_rmap()
342 /* Cross-reference with the other btrees. */
348 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_rtrefcountbt_xref()
352 xfs_rgbno_to_rtb(sc->sr.rtg, irec->rc_startblock), in xchk_rtrefcountbt_xref()
353 irec->rc_blockcount); in xchk_rtrefcountbt_xref()
376 const struct xfs_refcount_irec *r1 = &rrc->prev_rec; in xchk_rtrefcount_mergeable()
379 if (r1->rc_blockcount > 0) in xchk_rtrefcount_mergeable()
382 if (r1->rc_startblock + r1->rc_blockcount != r2->rc_startblock) in xchk_rtrefcount_mergeable()
384 if (r1->rc_refcount != r2->rc_refcount) in xchk_rtrefcount_mergeable()
386 if ((unsigned long long)r1->rc_blockcount + r2->rc_blockcount > in xchk_rtrefcount_mergeable()
400 if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_rtrefcountbt_check_mergeable()
404 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_rtrefcountbt_check_mergeable()
406 memcpy(&rrc->prev_rec, irec, sizeof(struct xfs_refcount_irec)); in xchk_rtrefcountbt_check_mergeable()
417 if (*next_bno != NULLRGBLOCK && rec->rm_startblock < *next_bno) in xchk_rtrefcountbt_rmap_check_gap()
418 return -ECANCELED; in xchk_rtrefcountbt_rmap_check_gap()
420 *next_bno = rec->rm_startblock + rec->rm_blockcount; in xchk_rtrefcountbt_rmap_check_gap()
439 if (bno <= rrc->next_unshared_rgbno || !sc->sr.rmap_cur || in xchk_rtrefcountbt_xref_gaps()
440 xchk_skip_xref(sc->sm)) in xchk_rtrefcountbt_xref_gaps()
444 low.rm_startblock = rrc->next_unshared_rgbno; in xchk_rtrefcountbt_xref_gaps()
446 high.rm_startblock = bno - 1; in xchk_rtrefcountbt_xref_gaps()
448 error = xfs_rmap_query_range(sc->sr.rmap_cur, &low, &high, in xchk_rtrefcountbt_xref_gaps()
450 if (error == -ECANCELED) in xchk_rtrefcountbt_xref_gaps()
451 xchk_btree_xref_set_corrupt(sc, sc->sr.rmap_cur, 0); in xchk_rtrefcountbt_xref_gaps()
453 xchk_should_check_xref(sc, &error, &sc->sr.rmap_cur); in xchk_rtrefcountbt_xref_gaps()
462 struct xfs_mount *mp = bs->cur->bc_mp; in xchk_rtrefcountbt_rec()
463 struct xchk_rtrefcbt_records *rrc = bs->private; in xchk_rtrefcountbt_rec()
468 if (xfs_rtrefcount_check_irec(to_rtg(bs->cur->bc_group), &irec) != in xchk_rtrefcountbt_rec()
470 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_rtrefcountbt_rec()
477 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_rtrefcountbt_rec()
480 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_rtrefcountbt_rec()
483 rrc->cow_blocks += irec.rc_blockcount; in xchk_rtrefcountbt_rec()
487 rrc->prev_domain == XFS_REFC_DOMAIN_COW) in xchk_rtrefcountbt_rec()
488 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_rtrefcountbt_rec()
489 rrc->prev_domain = irec.rc_domain; in xchk_rtrefcountbt_rec()
492 xchk_rtrefcountbt_xref(bs->sc, &irec); in xchk_rtrefcountbt_rec()
500 xchk_rtrefcountbt_xref_gaps(bs->sc, rrc, irec.rc_startblock); in xchk_rtrefcountbt_rec()
501 rrc->next_unshared_rgbno = irec.rc_startblock + in xchk_rtrefcountbt_rec()
519 if (!sc->sr.rmap_cur || !sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) in xchk_refcount_xref_rmap()
523 error = xfs_btree_count_blocks(sc->sr.refc_cur, &refcbt_blocks); in xchk_refcount_xref_rmap()
524 if (!xchk_btree_process_error(sc, sc->sr.refc_cur, 0, &error)) in xchk_refcount_xref_rmap()
526 error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, btree_oinfo, in xchk_refcount_xref_rmap()
528 if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) in xchk_refcount_xref_rmap()
531 xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); in xchk_refcount_xref_rmap()
534 error = xchk_count_rmap_ownedby_ag(sc, sc->sr.rmap_cur, in xchk_refcount_xref_rmap()
536 if (!xchk_should_check_xref(sc, &error, &sc->sr.rmap_cur)) in xchk_refcount_xref_rmap()
539 xchk_btree_xref_set_corrupt(sc, sc->sr.rmap_cur, 0); in xchk_refcount_xref_rmap()
556 if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) in xchk_rtrefcountbt()
559 xfs_rmap_ino_bmbt_owner(&btree_oinfo, rtg_refcount(sc->sr.rtg)->i_ino, in xchk_rtrefcountbt()
561 error = xchk_btree(sc, sc->sr.refc_cur, xchk_rtrefcountbt_rec, in xchk_rtrefcountbt()
563 if (error || (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT)) in xchk_rtrefcountbt()
570 xchk_rtrefcountbt_xref_gaps(sc, &rrc, sc->mp->m_sb.sb_rblocks); in xchk_rtrefcountbt()
588 if (!sc->sr.refc_cur || xchk_skip_xref(sc->sm)) in xchk_xref_is_rt_cow_staging()
592 error = xfs_refcount_lookup_le(sc->sr.refc_cur, XFS_REFC_DOMAIN_COW, in xchk_xref_is_rt_cow_staging()
594 if (!xchk_should_check_xref(sc, &error, &sc->sr.refc_cur)) in xchk_xref_is_rt_cow_staging()
597 xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0); in xchk_xref_is_rt_cow_staging()
601 error = xfs_refcount_get_rec(sc->sr.refc_cur, &rc, &has_refcount); in xchk_xref_is_rt_cow_staging()
602 if (!xchk_should_check_xref(sc, &error, &sc->sr.refc_cur)) in xchk_xref_is_rt_cow_staging()
605 xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0); in xchk_xref_is_rt_cow_staging()
611 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_rt_cow_staging()
615 xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0); in xchk_xref_is_rt_cow_staging()
631 if (!sc->sr.refc_cur || xchk_skip_xref(sc->sm)) in xchk_xref_is_not_rt_shared()
634 error = xfs_refcount_has_records(sc->sr.refc_cur, in xchk_xref_is_not_rt_shared()
636 if (!xchk_should_check_xref(sc, &error, &sc->sr.refc_cur)) in xchk_xref_is_not_rt_shared()
639 xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0); in xchk_xref_is_not_rt_shared()
652 if (!sc->sr.refc_cur || xchk_skip_xref(sc->sm)) in xchk_xref_is_not_rt_cow_staging()
655 error = xfs_refcount_has_records(sc->sr.refc_cur, XFS_REFC_DOMAIN_COW, in xchk_xref_is_not_rt_cow_staging()
657 if (!xchk_should_check_xref(sc, &error, &sc->sr.refc_cur)) in xchk_xref_is_not_rt_cow_staging()
660 xchk_btree_xref_set_corrupt(sc, sc->sr.refc_cur, 0); in xchk_xref_is_not_rt_cow_staging()