| .. | .. |
|---|
| 9 | 9 | #include "xfs_format.h" |
|---|
| 10 | 10 | #include "xfs_trans_resv.h" |
|---|
| 11 | 11 | #include "xfs_mount.h" |
|---|
| 12 | | -#include "xfs_defer.h" |
|---|
| 13 | 12 | #include "xfs_btree.h" |
|---|
| 14 | | -#include "xfs_bit.h" |
|---|
| 15 | | -#include "xfs_log_format.h" |
|---|
| 16 | | -#include "xfs_trans.h" |
|---|
| 17 | | -#include "xfs_sb.h" |
|---|
| 18 | | -#include "xfs_inode.h" |
|---|
| 19 | | -#include "xfs_alloc.h" |
|---|
| 20 | 13 | #include "scrub/scrub.h" |
|---|
| 21 | 14 | #include "scrub/common.h" |
|---|
| 22 | 15 | #include "scrub/btree.h" |
|---|
| .. | .. |
|---|
| 415 | 408 | struct xfs_btree_cur *cur = bs->cur; |
|---|
| 416 | 409 | struct check_owner *co; |
|---|
| 417 | 410 | |
|---|
| 418 | | - if ((cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && bp == NULL) |
|---|
| 411 | + /* |
|---|
| 412 | + * In theory, xfs_btree_get_block should only give us a null buffer |
|---|
| 413 | + * pointer for the root of a root-in-inode btree type, but we need |
|---|
| 414 | + * to check defensively here in case the cursor state is also screwed |
|---|
| 415 | + * up. |
|---|
| 416 | + */ |
|---|
| 417 | + if (bp == NULL) { |
|---|
| 418 | + if (!(cur->bc_flags & XFS_BTREE_ROOT_IN_INODE)) |
|---|
| 419 | + xchk_btree_set_corrupt(bs->sc, bs->cur, level); |
|---|
| 419 | 420 | return 0; |
|---|
| 421 | + } |
|---|
| 420 | 422 | |
|---|
| 421 | 423 | /* |
|---|
| 422 | 424 | * We want to cross-reference each btree block with the bnobt |
|---|
| .. | .. |
|---|
| 592 | 594 | */ |
|---|
| 593 | 595 | int |
|---|
| 594 | 596 | xchk_btree( |
|---|
| 595 | | - struct xfs_scrub *sc, |
|---|
| 596 | | - struct xfs_btree_cur *cur, |
|---|
| 597 | | - xchk_btree_rec_fn scrub_fn, |
|---|
| 598 | | - struct xfs_owner_info *oinfo, |
|---|
| 599 | | - void *private) |
|---|
| 597 | + struct xfs_scrub *sc, |
|---|
| 598 | + struct xfs_btree_cur *cur, |
|---|
| 599 | + xchk_btree_rec_fn scrub_fn, |
|---|
| 600 | + const struct xfs_owner_info *oinfo, |
|---|
| 601 | + void *private) |
|---|
| 600 | 602 | { |
|---|
| 601 | | - struct xchk_btree bs = { NULL }; |
|---|
| 602 | | - union xfs_btree_ptr ptr; |
|---|
| 603 | | - union xfs_btree_ptr *pp; |
|---|
| 604 | | - union xfs_btree_rec *recp; |
|---|
| 605 | | - struct xfs_btree_block *block; |
|---|
| 606 | | - int level; |
|---|
| 607 | | - struct xfs_buf *bp; |
|---|
| 608 | | - struct check_owner *co; |
|---|
| 609 | | - struct check_owner *n; |
|---|
| 610 | | - int i; |
|---|
| 611 | | - int error = 0; |
|---|
| 603 | + struct xchk_btree bs = { |
|---|
| 604 | + .cur = cur, |
|---|
| 605 | + .scrub_rec = scrub_fn, |
|---|
| 606 | + .oinfo = oinfo, |
|---|
| 607 | + .firstrec = true, |
|---|
| 608 | + .private = private, |
|---|
| 609 | + .sc = sc, |
|---|
| 610 | + }; |
|---|
| 611 | + union xfs_btree_ptr ptr; |
|---|
| 612 | + union xfs_btree_ptr *pp; |
|---|
| 613 | + union xfs_btree_rec *recp; |
|---|
| 614 | + struct xfs_btree_block *block; |
|---|
| 615 | + int level; |
|---|
| 616 | + struct xfs_buf *bp; |
|---|
| 617 | + struct check_owner *co; |
|---|
| 618 | + struct check_owner *n; |
|---|
| 619 | + int i; |
|---|
| 620 | + int error = 0; |
|---|
| 612 | 621 | |
|---|
| 613 | 622 | /* Initialize scrub state */ |
|---|
| 614 | | - bs.cur = cur; |
|---|
| 615 | | - bs.scrub_rec = scrub_fn; |
|---|
| 616 | | - bs.oinfo = oinfo; |
|---|
| 617 | | - bs.firstrec = true; |
|---|
| 618 | | - bs.private = private; |
|---|
| 619 | | - bs.sc = sc; |
|---|
| 620 | 623 | for (i = 0; i < XFS_BTREE_MAXLEVELS; i++) |
|---|
| 621 | 624 | bs.firstkey[i] = true; |
|---|
| 622 | 625 | INIT_LIST_HEAD(&bs.to_check); |
|---|