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.
45 /* Reference count btree scrubber. */
64 * need to find ($refcount - $seen) owners for every block in the
120 if (xchk_should_terminate(refchk->sc, &error)) in xchk_refcountbt_rmap_check()
123 rm_last = rec->rm_startblock + rec->rm_blockcount - 1; in xchk_refcountbt_rmap_check()
124 rc_last = refchk->bno + refchk->len - 1; in xchk_refcountbt_rmap_check()
126 /* Confirm that a single-owner refc extent is a CoW stage. */ in xchk_refcountbt_rmap_check()
127 if (refchk->refcount == 1 && rec->rm_owner != XFS_RMAP_OWN_COW) { in xchk_refcountbt_rmap_check()
128 xchk_btree_xref_set_corrupt(refchk->sc, cur, 0); in xchk_refcountbt_rmap_check()
132 if (rec->rm_startblock <= refchk->bno && rm_last >= rc_last) { in xchk_refcountbt_rmap_check()
137 refchk->seen++; in xchk_refcountbt_rmap_check()
148 return -ENOMEM; in xchk_refcountbt_rmap_check()
149 memcpy(&frag->rm, rec, sizeof(frag->rm)); in xchk_refcountbt_rmap_check()
150 list_add_tail(&frag->list, &refchk->fragments); in xchk_refcountbt_rmap_check()
176 target_nr = refchk->refcount - refchk->seen; in xchk_refcountbt_process_rmap_fragments()
181 * There are (refchk->rc.rc_refcount - refchk->nr refcount) in xchk_refcountbt_process_rmap_fragments()
193 list_for_each_entry(frag, &refchk->fragments, list) { in xchk_refcountbt_process_rmap_fragments()
194 if (frag->rm.rm_startblock < bno) in xchk_refcountbt_process_rmap_fragments()
195 goto done; in xchk_refcountbt_process_rmap_fragments()
196 bno = frag->rm.rm_startblock; in xchk_refcountbt_process_rmap_fragments()
204 list_for_each_entry_safe(frag, n, &refchk->fragments, list) { in xchk_refcountbt_process_rmap_fragments()
205 if (frag->rm.rm_startblock > refchk->bno || nr > target_nr) in xchk_refcountbt_process_rmap_fragments()
207 bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; in xchk_refcountbt_process_rmap_fragments()
210 list_move_tail(&frag->list, &worklist); in xchk_refcountbt_process_rmap_fragments()
219 goto done; in xchk_refcountbt_process_rmap_fragments()
221 while (!list_empty(&refchk->fragments)) { in xchk_refcountbt_process_rmap_fragments()
226 bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; in xchk_refcountbt_process_rmap_fragments()
232 list_del(&frag->list); in xchk_refcountbt_process_rmap_fragments()
238 list_for_each_entry_safe(frag, n, &refchk->fragments, list) { in xchk_refcountbt_process_rmap_fragments()
239 bno = frag->rm.rm_startblock + frag->rm.rm_blockcount; in xchk_refcountbt_process_rmap_fragments()
240 if (frag->rm.rm_startblock != rbno) in xchk_refcountbt_process_rmap_fragments()
241 goto done; in xchk_refcountbt_process_rmap_fragments()
242 list_move_tail(&frag->list, &worklist); in xchk_refcountbt_process_rmap_fragments()
245 nr--; in xchk_refcountbt_process_rmap_fragments()
254 * required refcount. Something is wrong, so we're done. in xchk_refcountbt_process_rmap_fragments()
257 goto done; in xchk_refcountbt_process_rmap_fragments()
266 if (rbno < refchk->bno + refchk->len) in xchk_refcountbt_process_rmap_fragments()
267 goto done; in xchk_refcountbt_process_rmap_fragments()
270 refchk->seen = refchk->refcount; in xchk_refcountbt_process_rmap_fragments()
271 done: in xchk_refcountbt_process_rmap_fragments()
274 list_del(&frag->list); in xchk_refcountbt_process_rmap_fragments()
277 list_for_each_entry_safe(frag, n, &refchk->fragments, list) { in xchk_refcountbt_process_rmap_fragments()
278 list_del(&frag->list); in xchk_refcountbt_process_rmap_fragments()
291 .bno = irec->rc_startblock, in xchk_refcountbt_xref_rmap()
292 .len = irec->rc_blockcount, in xchk_refcountbt_xref_rmap()
293 .refcount = irec->rc_refcount, in xchk_refcountbt_xref_rmap()
302 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) in xchk_refcountbt_xref_rmap()
305 /* Cross-reference with the rmapbt to confirm the refcount. */ in xchk_refcountbt_xref_rmap()
307 low.rm_startblock = irec->rc_startblock; in xchk_refcountbt_xref_rmap()
309 high.rm_startblock = irec->rc_startblock + irec->rc_blockcount - 1; in xchk_refcountbt_xref_rmap()
312 error = xfs_rmap_query_range(sc->sa.rmap_cur, &low, &high, in xchk_refcountbt_xref_rmap()
314 if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) in xchk_refcountbt_xref_rmap()
318 if (irec->rc_refcount != refchk.seen) { in xchk_refcountbt_xref_rmap()
319 trace_xchk_refcount_incorrect(sc->sa.pag, irec, refchk.seen); in xchk_refcountbt_xref_rmap()
320 xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); in xchk_refcountbt_xref_rmap()
325 list_del(&frag->list); in xchk_refcountbt_xref_rmap()
330 /* Cross-reference with the other btrees. */
336 if (sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_refcountbt_xref()
339 xchk_xref_is_used_space(sc, irec->rc_startblock, irec->rc_blockcount); in xchk_refcountbt_xref()
340 xchk_xref_is_not_inode_chunk(sc, irec->rc_startblock, in xchk_refcountbt_xref()
341 irec->rc_blockcount); in xchk_refcountbt_xref()
367 if (*next_bno != NULLAGBLOCK && rec->rm_startblock < *next_bno) in xchk_refcountbt_rmap_check_gap()
368 return -ECANCELED; in xchk_refcountbt_rmap_check_gap()
370 *next_bno = rec->rm_startblock + rec->rm_blockcount; in xchk_refcountbt_rmap_check_gap()
389 if (bno <= rrc->next_unshared_agbno || !sc->sa.rmap_cur || in xchk_refcountbt_xref_gaps()
390 xchk_skip_xref(sc->sm)) in xchk_refcountbt_xref_gaps()
394 low.rm_startblock = rrc->next_unshared_agbno; in xchk_refcountbt_xref_gaps()
396 high.rm_startblock = bno - 1; in xchk_refcountbt_xref_gaps()
398 error = xfs_rmap_query_range(sc->sa.rmap_cur, &low, &high, in xchk_refcountbt_xref_gaps()
400 if (error == -ECANCELED) in xchk_refcountbt_xref_gaps()
401 xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); in xchk_refcountbt_xref_gaps()
403 xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur); in xchk_refcountbt_xref_gaps()
411 const struct xfs_refcount_irec *r1 = &rrc->prev_rec; in xchk_refcount_mergeable()
414 if (r1->rc_blockcount > 0) in xchk_refcount_mergeable()
417 if (r1->rc_domain != r2->rc_domain) in xchk_refcount_mergeable()
419 if (r1->rc_startblock + r1->rc_blockcount != r2->rc_startblock) in xchk_refcount_mergeable()
421 if (r1->rc_refcount != r2->rc_refcount) in xchk_refcount_mergeable()
423 if ((unsigned long long)r1->rc_blockcount + r2->rc_blockcount > in xchk_refcount_mergeable()
437 if (bs->sc->sm->sm_flags & XFS_SCRUB_OFLAG_CORRUPT) in xchk_refcountbt_check_mergeable()
441 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_refcountbt_check_mergeable()
443 memcpy(&rrc->prev_rec, irec, sizeof(struct xfs_refcount_irec)); in xchk_refcountbt_check_mergeable()
453 struct xchk_refcbt_records *rrc = bs->private; in xchk_refcountbt_rec()
456 if (xfs_refcount_check_irec(to_perag(bs->cur->bc_group), &irec) != in xchk_refcountbt_rec()
458 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_refcountbt_rec()
463 rrc->cow_blocks += irec.rc_blockcount; in xchk_refcountbt_rec()
467 rrc->prev_domain == XFS_REFC_DOMAIN_COW) in xchk_refcountbt_rec()
468 xchk_btree_set_corrupt(bs->sc, bs->cur, 0); in xchk_refcountbt_rec()
469 rrc->prev_domain = irec.rc_domain; in xchk_refcountbt_rec()
472 xchk_refcountbt_xref(bs->sc, &irec); in xchk_refcountbt_rec()
480 xchk_refcountbt_xref_gaps(bs->sc, rrc, irec.rc_startblock); in xchk_refcountbt_rec()
481 rrc->next_unshared_agbno = irec.rc_startblock + in xchk_refcountbt_rec()
498 if (!sc->sa.rmap_cur || xchk_skip_xref(sc->sm)) in xchk_refcount_xref_rmap()
502 error = xfs_btree_count_blocks(sc->sa.refc_cur, &refcbt_blocks); in xchk_refcount_xref_rmap()
503 if (!xchk_btree_process_error(sc, sc->sa.refc_cur, 0, &error)) in xchk_refcount_xref_rmap()
505 error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, in xchk_refcount_xref_rmap()
507 if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) in xchk_refcount_xref_rmap()
510 xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); in xchk_refcount_xref_rmap()
513 error = xchk_count_rmap_ownedby_ag(sc, sc->sa.rmap_cur, in xchk_refcount_xref_rmap()
515 if (!xchk_should_check_xref(sc, &error, &sc->sa.rmap_cur)) in xchk_refcount_xref_rmap()
518 xchk_btree_xref_set_corrupt(sc, sc->sa.rmap_cur, 0); in xchk_refcount_xref_rmap()
533 error = xchk_btree(sc, sc->sa.refc_cur, xchk_refcountbt_rec, in xchk_refcountbt()
542 xchk_refcountbt_xref_gaps(sc, &rrc, sc->mp->m_sb.sb_agblocks); in xchk_refcountbt()
560 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm)) in xchk_xref_is_cow_staging()
564 error = xfs_refcount_lookup_le(sc->sa.refc_cur, XFS_REFC_DOMAIN_COW, in xchk_xref_is_cow_staging()
566 if (!xchk_should_check_xref(sc, &error, &sc->sa.refc_cur)) in xchk_xref_is_cow_staging()
569 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_cow_staging()
573 error = xfs_refcount_get_rec(sc->sa.refc_cur, &rc, &has_refcount); in xchk_xref_is_cow_staging()
574 if (!xchk_should_check_xref(sc, &error, &sc->sa.refc_cur)) in xchk_xref_is_cow_staging()
577 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_cow_staging()
583 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_cow_staging()
587 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_cow_staging()
603 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm)) in xchk_xref_is_not_shared()
606 error = xfs_refcount_has_records(sc->sa.refc_cur, in xchk_xref_is_not_shared()
608 if (!xchk_should_check_xref(sc, &error, &sc->sa.refc_cur)) in xchk_xref_is_not_shared()
611 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_not_shared()
624 if (!sc->sa.refc_cur || xchk_skip_xref(sc->sm)) in xchk_xref_is_not_cow_staging()
627 error = xfs_refcount_has_records(sc->sa.refc_cur, XFS_REFC_DOMAIN_COW, in xchk_xref_is_not_cow_staging()
629 if (!xchk_should_check_xref(sc, &error, &sc->sa.refc_cur)) in xchk_xref_is_not_cow_staging()
632 xchk_btree_xref_set_corrupt(sc, sc->sa.refc_cur, 0); in xchk_xref_is_not_cow_staging()