Lines Matching refs:bs
138 struct xchk_btree *bs) in xchk_btree_rec() argument
140 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_rec()
152 trace_xchk_btree_rec(bs->sc, cur, 0); in xchk_btree_rec()
155 if (bs->lastrec_valid && in xchk_btree_rec()
156 !cur->bc_ops->recs_inorder(cur, &bs->lastrec, rec)) in xchk_btree_rec()
157 xchk_btree_set_corrupt(bs->sc, cur, 0); in xchk_btree_rec()
158 memcpy(&bs->lastrec, rec, cur->bc_ops->rec_len); in xchk_btree_rec()
159 bs->lastrec_valid = true; in xchk_btree_rec()
169 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_rec()
178 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_rec()
187 struct xchk_btree *bs, in xchk_btree_key() argument
190 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_key()
200 trace_xchk_btree_key(bs->sc, cur, level); in xchk_btree_key()
203 if (bs->lastkey[level - 1].valid && in xchk_btree_key()
204 !cur->bc_ops->keys_inorder(cur, &bs->lastkey[level - 1].key, key)) in xchk_btree_key()
205 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_key()
206 memcpy(&bs->lastkey[level - 1].key, key, cur->bc_ops->key_len); in xchk_btree_key()
207 bs->lastkey[level - 1].valid = true; in xchk_btree_key()
216 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_key()
226 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_key()
235 struct xchk_btree *bs, in xchk_btree_ptr_ok() argument
240 if (bs->cur->bc_ops->type == XFS_BTREE_TYPE_INODE && in xchk_btree_ptr_ok()
241 level == bs->cur->bc_nlevels) in xchk_btree_ptr_ok()
245 if (__xfs_btree_check_ptr(bs->cur, ptr, 0, level)) { in xchk_btree_ptr_ok()
246 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_ptr_ok()
256 struct xchk_btree *bs, in xchk_btree_block_check_sibling() argument
261 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_check_sibling()
270 if (!xchk_btree_process_error(bs->sc, cur, level + 1, &error) || in xchk_btree_block_check_sibling()
284 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_block_check_sibling()
294 if (!xchk_btree_process_error(bs->sc, cur, level + 1, &error)) in xchk_btree_block_check_sibling()
297 xchk_btree_set_corrupt(bs->sc, cur, level + 1); in xchk_btree_block_check_sibling()
304 if (!xchk_btree_ptr_ok(bs, level + 1, pp)) in xchk_btree_block_check_sibling()
307 xchk_buffer_recheck(bs->sc, pbp); in xchk_btree_block_check_sibling()
310 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_block_check_sibling()
319 struct xchk_btree *bs, in xchk_btree_block_check_siblings() argument
322 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_check_siblings()
336 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_block_check_siblings()
345 error = xchk_btree_block_check_sibling(bs, level, -1, &leftsib); in xchk_btree_block_check_siblings()
348 error = xchk_btree_block_check_sibling(bs, level, 1, &rightsib); in xchk_btree_block_check_siblings()
367 struct xchk_btree *bs, in xchk_btree_check_block_owner() argument
376 if (!bs->cur) in xchk_btree_check_block_owner()
379 agno = xfs_daddr_to_agno(bs->cur->bc_mp, daddr); in xchk_btree_check_block_owner()
380 agbno = xfs_daddr_to_agbno(bs->cur->bc_mp, daddr); in xchk_btree_check_block_owner()
387 init_sa = bs->cur->bc_ops->type != XFS_BTREE_TYPE_AG; in xchk_btree_check_block_owner()
389 error = xchk_ag_init_existing(bs->sc, agno, &bs->sc->sa); in xchk_btree_check_block_owner()
390 if (!xchk_btree_xref_process_error(bs->sc, bs->cur, in xchk_btree_check_block_owner()
395 xchk_xref_is_used_space(bs->sc, agbno, 1); in xchk_btree_check_block_owner()
401 if (!bs->sc->sa.bno_cur && xfs_btree_is_bno(bs->cur->bc_ops)) in xchk_btree_check_block_owner()
402 bs->cur = NULL; in xchk_btree_check_block_owner()
404 xchk_xref_is_only_owned_by(bs->sc, agbno, 1, bs->oinfo); in xchk_btree_check_block_owner()
405 if (!bs->sc->sa.rmap_cur && xfs_btree_is_rmap(bs->cur->bc_ops)) in xchk_btree_check_block_owner()
406 bs->cur = NULL; in xchk_btree_check_block_owner()
410 xchk_ag_free(bs->sc, &bs->sc->sa); in xchk_btree_check_block_owner()
418 struct xchk_btree *bs, in xchk_btree_check_owner() argument
422 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_check_owner()
432 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_check_owner()
454 list_add_tail(&co->list, &bs->to_check); in xchk_btree_check_owner()
458 return xchk_btree_check_block_owner(bs, level, xfs_buf_daddr(bp)); in xchk_btree_check_owner()
464 struct xchk_btree *bs) in xchk_btree_check_iroot_minrecs() argument
477 if (xfs_btree_is_bmap(bs->cur->bc_ops) && in xchk_btree_check_iroot_minrecs()
478 bs->cur->bc_ino.whichfork == XFS_DATA_FORK && in xchk_btree_check_iroot_minrecs()
479 xfs_inode_has_attr_fork(bs->sc->ip)) in xchk_btree_check_iroot_minrecs()
491 struct xchk_btree *bs, in xchk_btree_check_minrecs() argument
495 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_check_minrecs()
518 if (xchk_btree_check_iroot_minrecs(bs) && in xchk_btree_check_minrecs()
521 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_check_minrecs()
530 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_check_minrecs()
539 struct xchk_btree *bs, in xchk_btree_block_check_keys() argument
546 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_check_keys()
560 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_block_check_keys()
572 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_block_check_keys()
581 struct xchk_btree *bs, in xchk_btree_get_block() argument
592 error = xfs_btree_lookup_get_block(bs->cur, level, pp, pblock); in xchk_btree_get_block()
593 if (!xchk_btree_process_error(bs->sc, bs->cur, level, &error) || in xchk_btree_get_block()
597 xfs_btree_get_block(bs->cur, level, pbp); in xchk_btree_get_block()
598 if (__xfs_btree_check_block(bs->cur, *pblock, level, *pbp)) { in xchk_btree_get_block()
599 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_get_block()
603 xchk_buffer_recheck(bs->sc, *pbp); in xchk_btree_get_block()
605 xchk_btree_check_minrecs(bs, level, *pblock); in xchk_btree_get_block()
611 error = xchk_btree_check_owner(bs, level, *pbp); in xchk_btree_get_block()
619 error = xchk_btree_block_check_siblings(bs, *pblock); in xchk_btree_get_block()
623 xchk_btree_block_check_keys(bs, level, *pblock); in xchk_btree_get_block()
633 struct xchk_btree *bs, in xchk_btree_block_keys() argument
638 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_keys()
657 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_block_keys()
668 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_block_keys()
685 struct xchk_btree *bs; in xchk_btree() local
706 bs = kzalloc(cur_sz, XCHK_GFP_FLAGS); in xchk_btree()
707 if (!bs) in xchk_btree()
709 bs->cur = cur; in xchk_btree()
710 bs->scrub_rec = scrub_fn; in xchk_btree()
711 bs->oinfo = oinfo; in xchk_btree()
712 bs->private = private; in xchk_btree()
713 bs->sc = sc; in xchk_btree()
716 INIT_LIST_HEAD(&bs->to_check); in xchk_btree()
724 if (!xchk_btree_ptr_ok(bs, cur->bc_nlevels, &ptr)) in xchk_btree()
726 error = xchk_btree_get_block(bs, level, &ptr, &block, &bp); in xchk_btree()
739 xchk_btree_block_keys(bs, level, block); in xchk_btree()
747 xchk_btree_rec(bs); in xchk_btree()
752 error = bs->scrub_rec(bs, recp); in xchk_btree()
766 xchk_btree_block_keys(bs, level, block); in xchk_btree()
774 xchk_btree_key(bs, level); in xchk_btree()
778 if (!xchk_btree_ptr_ok(bs, level, pp)) { in xchk_btree()
783 error = xchk_btree_get_block(bs, level, pp, &block, &bp); in xchk_btree()
792 list_for_each_entry_safe(co, n, &bs->to_check, list) { in xchk_btree()
793 if (!error && bs->cur) in xchk_btree()
794 error = xchk_btree_check_block_owner(bs, co->level, in xchk_btree()
799 kfree(bs); in xchk_btree()