Lines Matching full:rb

97 	struct xrep_bmap	*rb,  in xrep_bmap_discover_shared()  argument
101 struct xfs_scrub *sc = rb->sc; in xrep_bmap_discover_shared()
114 rb->reflink_scan = RLS_SET_IFLAG; in xrep_bmap_discover_shared()
122 struct xrep_bmap *rb, in xrep_bmap_from_rmap() argument
134 struct xfs_scrub *sc = rb->sc; in xrep_bmap_from_rmap()
142 if (rb->reflink_scan == RLS_UNKNOWN && !unwritten) { in xrep_bmap_from_rmap()
143 error = xrep_bmap_discover_shared(rb, startblock, blockcount); in xrep_bmap_from_rmap()
154 fa = xfs_bmap_validate_extent(sc->ip, rb->whichfork, &irec); in xrep_bmap_from_rmap()
160 trace_xrep_bmap_found(sc->ip, rb->whichfork, &irec); in xrep_bmap_from_rmap()
165 error = xfarray_append(rb->bmap_records, &rbe); in xrep_bmap_from_rmap()
169 rb->real_mappings++; in xrep_bmap_from_rmap()
182 struct xrep_bmap *rb, in xrep_bmap_check_fork_rmap() argument
186 struct xfs_scrub *sc = rb->sc; in xrep_bmap_check_fork_rmap()
239 struct xrep_bmap *rb = priv; in xrep_bmap_walk_rmap() local
244 if (xchk_should_terminate(rb->sc, &error)) in xrep_bmap_walk_rmap()
247 if (rec->rm_owner != rb->sc->ip->i_ino) in xrep_bmap_walk_rmap()
250 error = xrep_bmap_check_fork_rmap(rb, cur, rec); in xrep_bmap_walk_rmap()
258 rb->nblocks += rec->rm_blockcount; in xrep_bmap_walk_rmap()
261 if (rb->whichfork == XFS_DATA_FORK && in xrep_bmap_walk_rmap()
264 if (rb->whichfork == XFS_ATTR_FORK && in xrep_bmap_walk_rmap()
269 if ((rec->rm_flags & XFS_RMAP_UNWRITTEN) && !rb->allow_unwritten) in xrep_bmap_walk_rmap()
276 rb->old_bmbt_block_count += rec->rm_blockcount; in xrep_bmap_walk_rmap()
277 return xfsb_bitmap_set(&rb->old_bmbt_blocks, fsbno, in xrep_bmap_walk_rmap()
281 return xrep_bmap_from_rmap(rb, rec->rm_offset, fsbno, in xrep_bmap_walk_rmap()
313 struct xrep_bmap *rb) in xrep_bmap_sort_records() argument
320 error = xfarray_sort(rb->bmap_records, xrep_bmap_extent_cmp, in xrep_bmap_sort_records()
325 foreach_xfarray_idx(rb->bmap_records, array_cur) { in xrep_bmap_sort_records()
328 if (xchk_should_terminate(rb->sc, &error)) in xrep_bmap_sort_records()
331 error = xfarray_load(rb->bmap_records, array_cur, &rec); in xrep_bmap_sort_records()
349 struct xrep_bmap *rb, in xrep_bmap_scan_ag() argument
352 struct xfs_scrub *sc = rb->sc; in xrep_bmap_scan_ag()
359 error = xfs_rmap_query_all(sc->sa.rmap_cur, xrep_bmap_walk_rmap, rb); in xrep_bmap_scan_ag()
367 struct xrep_bmap *rb) in xrep_bmap_find_delalloc() argument
372 struct xfs_inode *ip = rb->sc->ip; in xrep_bmap_find_delalloc()
373 struct xfs_ifork *ifp = xfs_ifork_ptr(ip, rb->whichfork); in xrep_bmap_find_delalloc()
380 if (rb->whichfork == XFS_ATTR_FORK || ip->i_delayed_blks == 0) in xrep_bmap_find_delalloc()
389 trace_xrep_bmap_found(ip, rb->whichfork, &irec); in xrep_bmap_find_delalloc()
391 if (xchk_should_terminate(rb->sc, &error)) in xrep_bmap_find_delalloc()
394 error = xfarray_append(rb->bmap_records, &rbe); in xrep_bmap_find_delalloc()
409 struct xrep_bmap *rb) in xrep_bmap_find_mappings() argument
411 struct xfs_scrub *sc = rb->sc; in xrep_bmap_find_mappings()
418 error = xrep_bmap_scan_ag(rb, pag); in xrep_bmap_find_mappings()
425 return xrep_bmap_find_delalloc(rb); in xrep_bmap_find_mappings()
439 struct xrep_bmap *rb = priv; in xrep_bmap_get_records() local
446 error = xfarray_load(rb->bmap_records, rb->array_cur++, in xrep_bmap_get_records()
468 struct xrep_bmap *rb = priv; in xrep_bmap_claim_block() local
470 return xrep_newbt_claim_block(cur, &rb->new_bmapbt, ptr); in xrep_bmap_claim_block()
489 struct xrep_bmap *rb) in xrep_bmap_reset_counters() argument
491 struct xfs_scrub *sc = rb->sc; in xrep_bmap_reset_counters()
492 struct xbtree_ifakeroot *ifake = &rb->new_bmapbt.ifake; in xrep_bmap_reset_counters()
495 if (rb->reflink_scan == RLS_SET_IFLAG) in xrep_bmap_reset_counters()
502 delta = ifake->if_blocks - rb->old_bmbt_block_count; in xrep_bmap_reset_counters()
503 sc->ip->i_nblocks = rb->nblocks + delta; in xrep_bmap_reset_counters()
521 struct xrep_bmap *rb) in xrep_bmap_extents_load() argument
525 struct xfs_ifork *ifp = rb->new_bmapbt.ifake.if_fork; in xrep_bmap_extents_load()
533 foreach_xfarray_idx(rb->bmap_records, array_cur) { in xrep_bmap_extents_load()
536 error = xfarray_load(rb->bmap_records, array_cur, &rec); in xrep_bmap_extents_load()
549 return xrep_ino_ensure_extent_count(rb->sc, rb->whichfork, in xrep_bmap_extents_load()
559 struct xrep_bmap *rb, in xrep_bmap_btree_load() argument
562 struct xfs_scrub *sc = rb->sc; in xrep_bmap_btree_load()
567 &rb->new_bmapbt.bload, rb->real_mappings); in xrep_bmap_btree_load()
582 rb->new_bmapbt.bload.nr_blocks, 0, true); in xrep_bmap_btree_load()
587 error = xrep_newbt_alloc_blocks(&rb->new_bmapbt, in xrep_bmap_btree_load()
588 rb->new_bmapbt.bload.nr_blocks); in xrep_bmap_btree_load()
593 rb->array_cur = XFARRAY_CURSOR_INIT; in xrep_bmap_btree_load()
594 error = xfs_btree_bload(bmap_cur, &rb->new_bmapbt.bload, rb); in xrep_bmap_btree_load()
605 return xrep_bmap_extents_load(rb); in xrep_bmap_btree_load()
617 struct xrep_bmap *rb) in xrep_bmap_build_new_fork() argument
620 struct xfs_scrub *sc = rb->sc; in xrep_bmap_build_new_fork()
622 struct xbtree_ifakeroot *ifake = &rb->new_bmapbt.ifake; in xrep_bmap_build_new_fork()
625 error = xrep_bmap_sort_records(rb); in xrep_bmap_build_new_fork()
633 xfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, rb->whichfork); in xrep_bmap_build_new_fork()
634 error = xrep_newbt_init_inode(&rb->new_bmapbt, sc, rb->whichfork, in xrep_bmap_build_new_fork()
639 rb->new_bmapbt.bload.get_records = xrep_bmap_get_records; in xrep_bmap_build_new_fork()
640 rb->new_bmapbt.bload.claim_block = xrep_bmap_claim_block; in xrep_bmap_build_new_fork()
641 rb->new_bmapbt.bload.iroot_size = xrep_bmap_iroot_size; in xrep_bmap_build_new_fork()
655 if (rb->real_mappings <= XFS_IFORK_MAXEXT(sc->ip, rb->whichfork)) { in xrep_bmap_build_new_fork()
657 error = xrep_bmap_extents_load(rb); in xrep_bmap_build_new_fork()
660 error = xrep_bmap_btree_load(rb, bmap_cur); in xrep_bmap_build_new_fork()
671 xfs_bmbt_commit_staged_btree(bmap_cur, sc->tp, rb->whichfork); in xrep_bmap_build_new_fork()
675 error = xrep_bmap_reset_counters(rb); in xrep_bmap_build_new_fork()
680 error = xrep_newbt_commit(&rb->new_bmapbt); in xrep_bmap_build_new_fork()
690 xrep_newbt_cancel(&rb->new_bmapbt); in xrep_bmap_build_new_fork()
700 struct xrep_bmap *rb) in xrep_bmap_remove_old_tree() argument
702 struct xfs_scrub *sc = rb->sc; in xrep_bmap_remove_old_tree()
706 xfs_rmap_ino_bmbt_owner(&oinfo, sc->ip->i_ino, rb->whichfork); in xrep_bmap_remove_old_tree()
707 return xrep_reap_fsblocks(sc, &rb->old_bmbt_blocks, &oinfo); in xrep_bmap_remove_old_tree()
802 struct xrep_bmap *rb; in xrep_bmap() local
814 rb = kzalloc(sizeof(struct xrep_bmap), XCHK_GFP_FLAGS); in xrep_bmap()
815 if (!rb) in xrep_bmap()
817 rb->sc = sc; in xrep_bmap()
818 rb->whichfork = whichfork; in xrep_bmap()
819 rb->reflink_scan = xrep_bmap_init_reflink_scan(sc, whichfork); in xrep_bmap()
820 rb->allow_unwritten = allow_unwritten; in xrep_bmap()
828 sizeof(struct xfs_bmbt_rec), &rb->bmap_records); in xrep_bmap()
834 xfsb_bitmap_init(&rb->old_bmbt_blocks); in xrep_bmap()
835 error = xrep_bmap_find_mappings(rb); in xrep_bmap()
842 error = xrep_bmap_build_new_fork(rb); in xrep_bmap()
847 error = xrep_bmap_remove_old_tree(rb); in xrep_bmap()
852 xfsb_bitmap_destroy(&rb->old_bmbt_blocks); in xrep_bmap()
853 xfarray_destroy(rb->bmap_records); in xrep_bmap()
855 kfree(rb); in xrep_bmap()