Lines Matching refs:bs

127 	struct xchk_btree	*bs)  in xchk_btree_rec()  argument
129 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_rec()
141 trace_xchk_btree_rec(bs->sc, cur, 0); in xchk_btree_rec()
145 !cur->bc_ops->recs_inorder(cur, &bs->lastrec, rec)) in xchk_btree_rec()
146 xchk_btree_set_corrupt(bs->sc, cur, 0); in xchk_btree_rec()
147 memcpy(&bs->lastrec, rec, cur->bc_ops->rec_len); in xchk_btree_rec()
157 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_rec()
166 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_rec()
175 struct xchk_btree *bs, in xchk_btree_key() argument
178 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_key()
188 trace_xchk_btree_key(bs->sc, cur, level); in xchk_btree_key()
192 !cur->bc_ops->keys_inorder(cur, &bs->lastkey[level - 1], key)) in xchk_btree_key()
193 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_key()
194 memcpy(&bs->lastkey[level - 1], key, cur->bc_ops->key_len); in xchk_btree_key()
203 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_key()
213 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_key()
222 struct xchk_btree *bs, in xchk_btree_ptr_ok() argument
229 if ((bs->cur->bc_flags & XFS_BTREE_ROOT_IN_INODE) && in xchk_btree_ptr_ok()
230 level == bs->cur->bc_nlevels) in xchk_btree_ptr_ok()
234 if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS) in xchk_btree_ptr_ok()
235 res = xfs_btree_check_lptr(bs->cur, be64_to_cpu(ptr->l), level); in xchk_btree_ptr_ok()
237 res = xfs_btree_check_sptr(bs->cur, be32_to_cpu(ptr->s), level); in xchk_btree_ptr_ok()
239 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_ptr_ok()
247 struct xchk_btree *bs, in xchk_btree_block_check_sibling() argument
252 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_check_sibling()
261 if (!xchk_btree_process_error(bs->sc, cur, level + 1, &error) || in xchk_btree_block_check_sibling()
275 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_block_check_sibling()
285 if (!xchk_btree_process_error(bs->sc, cur, level + 1, &error)) in xchk_btree_block_check_sibling()
288 xchk_btree_set_corrupt(bs->sc, cur, level + 1); in xchk_btree_block_check_sibling()
295 if (!xchk_btree_ptr_ok(bs, level + 1, pp)) in xchk_btree_block_check_sibling()
298 xchk_buffer_recheck(bs->sc, pbp); in xchk_btree_block_check_sibling()
301 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_block_check_sibling()
310 struct xchk_btree *bs, in xchk_btree_block_check_siblings() argument
313 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_check_siblings()
327 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_block_check_siblings()
336 error = xchk_btree_block_check_sibling(bs, level, -1, &leftsib); in xchk_btree_block_check_siblings()
339 error = xchk_btree_block_check_sibling(bs, level, 1, &rightsib); in xchk_btree_block_check_siblings()
358 struct xchk_btree *bs, in xchk_btree_check_block_owner() argument
368 if (!bs->cur) in xchk_btree_check_block_owner()
371 btnum = bs->cur->bc_btnum; in xchk_btree_check_block_owner()
372 agno = xfs_daddr_to_agno(bs->cur->bc_mp, daddr); in xchk_btree_check_block_owner()
373 agbno = xfs_daddr_to_agbno(bs->cur->bc_mp, daddr); in xchk_btree_check_block_owner()
375 init_sa = bs->cur->bc_flags & XFS_BTREE_LONG_PTRS; in xchk_btree_check_block_owner()
377 error = xchk_ag_init_existing(bs->sc, agno, &bs->sc->sa); in xchk_btree_check_block_owner()
378 if (!xchk_btree_xref_process_error(bs->sc, bs->cur, in xchk_btree_check_block_owner()
383 xchk_xref_is_used_space(bs->sc, agbno, 1); in xchk_btree_check_block_owner()
389 if (!bs->sc->sa.bno_cur && btnum == XFS_BTNUM_BNO) in xchk_btree_check_block_owner()
390 bs->cur = NULL; in xchk_btree_check_block_owner()
392 xchk_xref_is_owned_by(bs->sc, agbno, 1, bs->oinfo); in xchk_btree_check_block_owner()
393 if (!bs->sc->sa.rmap_cur && btnum == XFS_BTNUM_RMAP) in xchk_btree_check_block_owner()
394 bs->cur = NULL; in xchk_btree_check_block_owner()
398 xchk_ag_free(bs->sc, &bs->sc->sa); in xchk_btree_check_block_owner()
406 struct xchk_btree *bs, in xchk_btree_check_owner() argument
410 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_check_owner()
421 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_check_owner()
440 list_add_tail(&co->list, &bs->to_check); in xchk_btree_check_owner()
444 return xchk_btree_check_block_owner(bs, level, xfs_buf_daddr(bp)); in xchk_btree_check_owner()
450 struct xchk_btree *bs) in xchk_btree_check_iroot_minrecs() argument
463 if (bs->cur->bc_btnum == XFS_BTNUM_BMAP && in xchk_btree_check_iroot_minrecs()
464 bs->cur->bc_ino.whichfork == XFS_DATA_FORK && in xchk_btree_check_iroot_minrecs()
465 XFS_IFORK_Q(bs->sc->ip)) in xchk_btree_check_iroot_minrecs()
477 struct xchk_btree *bs, in xchk_btree_check_minrecs() argument
481 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_check_minrecs()
504 if (xchk_btree_check_iroot_minrecs(bs) && in xchk_btree_check_minrecs()
507 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_check_minrecs()
516 xchk_btree_set_corrupt(bs->sc, cur, level); in xchk_btree_check_minrecs()
525 struct xchk_btree *bs, in xchk_btree_get_block() argument
537 error = xfs_btree_lookup_get_block(bs->cur, level, pp, pblock); in xchk_btree_get_block()
538 if (!xchk_btree_process_error(bs->sc, bs->cur, level, &error) || in xchk_btree_get_block()
542 xfs_btree_get_block(bs->cur, level, pbp); in xchk_btree_get_block()
543 if (bs->cur->bc_flags & XFS_BTREE_LONG_PTRS) in xchk_btree_get_block()
544 failed_at = __xfs_btree_check_lblock(bs->cur, *pblock, in xchk_btree_get_block()
547 failed_at = __xfs_btree_check_sblock(bs->cur, *pblock, in xchk_btree_get_block()
550 xchk_btree_set_corrupt(bs->sc, bs->cur, level); in xchk_btree_get_block()
554 xchk_buffer_recheck(bs->sc, *pbp); in xchk_btree_get_block()
556 xchk_btree_check_minrecs(bs, level, *pblock); in xchk_btree_get_block()
562 error = xchk_btree_check_owner(bs, level, *pbp); in xchk_btree_get_block()
570 return xchk_btree_block_check_siblings(bs, *pblock); in xchk_btree_get_block()
579 struct xchk_btree *bs, in xchk_btree_block_keys() argument
584 struct xfs_btree_cur *cur = bs->cur; in xchk_btree_block_keys()
603 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_block_keys()
614 xchk_btree_set_corrupt(bs->sc, cur, 1); in xchk_btree_block_keys()
631 struct xchk_btree *bs; in xchk_btree() local
652 bs = kmem_zalloc(cur_sz, KM_NOFS | KM_MAYFAIL); in xchk_btree()
653 if (!bs) in xchk_btree()
655 bs->cur = cur; in xchk_btree()
656 bs->scrub_rec = scrub_fn; in xchk_btree()
657 bs->oinfo = oinfo; in xchk_btree()
658 bs->private = private; in xchk_btree()
659 bs->sc = sc; in xchk_btree()
662 INIT_LIST_HEAD(&bs->to_check); in xchk_btree()
670 if (!xchk_btree_ptr_ok(bs, cur->bc_nlevels, &ptr)) in xchk_btree()
672 error = xchk_btree_get_block(bs, level, &ptr, &block, &bp); in xchk_btree()
685 xchk_btree_block_keys(bs, level, block); in xchk_btree()
693 xchk_btree_rec(bs); in xchk_btree()
698 error = bs->scrub_rec(bs, recp); in xchk_btree()
712 xchk_btree_block_keys(bs, level, block); in xchk_btree()
720 xchk_btree_key(bs, level); in xchk_btree()
724 if (!xchk_btree_ptr_ok(bs, level, pp)) { in xchk_btree()
729 error = xchk_btree_get_block(bs, level, pp, &block, &bp); in xchk_btree()
738 list_for_each_entry_safe(co, n, &bs->to_check, list) { in xchk_btree()
739 if (!error && bs->cur) in xchk_btree()
740 error = xchk_btree_check_block_owner(bs, co->level, in xchk_btree()
745 kmem_free(bs); in xchk_btree()