Lines Matching +full:sub +full:- +full:blocks

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved.
57 * told us to fix it. This function returns -EAGAIN to mean "re-run scrub",
68 trace_xrep_attempt(XFS_I(file_inode(sc->file)), sc->sm, error); in xrep_attempt()
70 xchk_ag_btcur_free(&sc->sa); in xrep_attempt()
71 xchk_rtgroup_btcur_free(&sc->sr); in xrep_attempt()
74 ASSERT(sc->ops->repair); in xrep_attempt()
75 run->repair_attempted = true; in xrep_attempt()
77 error = sc->ops->repair(sc); in xrep_attempt()
78 trace_xrep_done(XFS_I(file_inode(sc->file)), sc->sm, error); in xrep_attempt()
79 run->repair_ns += xchk_stats_elapsed_ns(repair_start); in xrep_attempt()
86 sc->sm->sm_flags &= ~XFS_SCRUB_FLAGS_OUT; in xrep_attempt()
87 sc->flags |= XREP_ALREADY_FIXED; in xrep_attempt()
88 run->repair_succeeded = true; in xrep_attempt()
89 return -EAGAIN; in xrep_attempt()
90 case -ECHRNG: in xrep_attempt()
91 sc->flags |= XCHK_NEED_DRAIN; in xrep_attempt()
92 run->retries++; in xrep_attempt()
93 return -EAGAIN; in xrep_attempt()
94 case -EDEADLOCK: in xrep_attempt()
96 if (!(sc->flags & XCHK_TRY_HARDER)) { in xrep_attempt()
97 sc->flags |= XCHK_TRY_HARDER; in xrep_attempt()
98 run->retries++; in xrep_attempt()
99 return -EAGAIN; in xrep_attempt()
109 * EAGAIN tells the caller to re-scrub, so we cannot return in xrep_attempt()
112 ASSERT(error != -EAGAIN); in xrep_attempt()
121 * administrator isn't running xfs_scrub in no-repairs mode.
135 * Repair probe -- userspace uses this to probe if we're willing to repair a
169 if (sc->sa.agi_bp) { in xrep_roll_ag_trans()
170 xfs_ialloc_log_agi(sc->tp, sc->sa.agi_bp, XFS_AGI_MAGICNUM); in xrep_roll_ag_trans()
171 xfs_trans_bhold(sc->tp, sc->sa.agi_bp); in xrep_roll_ag_trans()
174 if (sc->sa.agf_bp) { in xrep_roll_ag_trans()
175 xfs_alloc_log_agf(sc->tp, sc->sa.agf_bp, XFS_AGF_MAGICNUM); in xrep_roll_ag_trans()
176 xfs_trans_bhold(sc->tp, sc->sa.agf_bp); in xrep_roll_ag_trans()
185 error = xfs_trans_roll(&sc->tp); in xrep_roll_ag_trans()
190 if (sc->sa.agi_bp) in xrep_roll_ag_trans()
191 xfs_trans_bjoin(sc->tp, sc->sa.agi_bp); in xrep_roll_ag_trans()
192 if (sc->sa.agf_bp) in xrep_roll_ag_trans()
193 xfs_trans_bjoin(sc->tp, sc->sa.agf_bp); in xrep_roll_ag_trans()
203 if (!sc->ip) in xrep_roll_trans()
205 return xfs_trans_roll_inode(&sc->tp, sc->ip); in xrep_roll_trans()
224 if (sc->sa.agi_bp) { in xrep_defer_finish()
225 xfs_ialloc_log_agi(sc->tp, sc->sa.agi_bp, XFS_AGI_MAGICNUM); in xrep_defer_finish()
226 xfs_trans_bhold(sc->tp, sc->sa.agi_bp); in xrep_defer_finish()
229 if (sc->sa.agf_bp) { in xrep_defer_finish()
230 xfs_alloc_log_agf(sc->tp, sc->sa.agf_bp, XFS_AGF_MAGICNUM); in xrep_defer_finish()
231 xfs_trans_bhold(sc->tp, sc->sa.agf_bp); in xrep_defer_finish()
241 error = xfs_defer_finish(&sc->tp); in xrep_defer_finish()
250 if (sc->sa.agi_bp) in xrep_defer_finish()
251 xfs_trans_bhold_release(sc->tp, sc->sa.agi_bp); in xrep_defer_finish()
252 if (sc->sa.agf_bp) in xrep_defer_finish()
253 xfs_trans_bhold_release(sc->tp, sc->sa.agf_bp); in xrep_defer_finish()
271 pag->pagf_freeblks > xfs_ag_resv_needed(pag, type) + nr_blocks; in xrep_ag_has_space()
275 * Figure out how many blocks to reserve for an AG repair. We calculate the
276 * worst case estimate for the number of blocks we'd need to rebuild one of
277 * any type of per-AG btree.
283 struct xfs_mount *mp = sc->mp; in xrep_calc_ag_resblks()
284 struct xfs_scrub_metadata *sm = sc->sm; in xrep_calc_ag_resblks()
297 if (!(sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) in xrep_calc_ag_resblks()
300 pag = xfs_perag_get(mp, sm->sm_agno); in xrep_calc_ag_resblks()
302 /* Use in-core icount if possible. */ in xrep_calc_ag_resblks()
303 icount = pag->pagi_count; in xrep_calc_ag_resblks()
308 icount = pag->pagi_count; in xrep_calc_ag_resblks()
316 aglen = pag_group(pag)->xg_block_count; in xrep_calc_ag_resblks()
320 struct xfs_agf *agf = bp->b_addr; in xrep_calc_ag_resblks()
322 aglen = be32_to_cpu(agf->agf_length); in xrep_calc_ag_resblks()
323 freelen = be32_to_cpu(agf->agf_freeblks); in xrep_calc_ag_resblks()
324 usedlen = aglen - freelen; in xrep_calc_ag_resblks()
328 /* If the icount is impossible, make some worst-case assumptions. */ in xrep_calc_ag_resblks()
331 icount = pag->agino_max - pag->agino_min + 1; in xrep_calc_ag_resblks()
334 /* If the block counts are impossible, make worst-case assumptions. */ in xrep_calc_ag_resblks()
336 aglen != pag_group(pag)->xg_block_count || in xrep_calc_ag_resblks()
338 aglen = pag_group(pag)->xg_block_count; in xrep_calc_ag_resblks()
346 * Figure out how many blocks we'd need worst case to rebuild in xrep_calc_ag_resblks()
365 * Guess how many blocks we need to rebuild the rmapbt. in xrep_calc_ag_resblks()
366 * For non-reflink filesystems we can't have more records than in xrep_calc_ag_resblks()
367 * used blocks. However, with reflink it's possible to have in xrep_calc_ag_resblks()
370 * what we hope is an generous over-estimation. in xrep_calc_ag_resblks()
390 * Figure out how many blocks to reserve for a rtgroup repair. We calculate
391 * the worst case estimate for the number of blocks we'd need to rebuild one of
392 * any type of per-rtgroup btree.
398 struct xfs_mount *mp = sc->mp; in xrep_calc_rtgroup_resblks()
399 struct xfs_scrub_metadata *sm = sc->sm; in xrep_calc_rtgroup_resblks()
403 if (!(sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR)) in xrep_calc_rtgroup_resblks()
407 return -EFSCORRUPTED; in xrep_calc_rtgroup_resblks()
410 usedlen = xfs_rtbxlen_to_blen(mp, xfs_rtgroup_extents(mp, sm->sm_agno)); in xrep_calc_rtgroup_resblks()
416 trace_xrep_calc_rtgroup_resblks_btsize(mp, sm->sm_agno, usedlen, in xrep_calc_rtgroup_resblks()
424 * Reconstructing per-AG Btrees
437 * derive the blocks that were used by the old btree. These blocks can be
445 * result (since the rmapbt lives in the free space) are the blocks from the
457 args.mp = sc->mp; in xrep_fix_freelist()
458 args.tp = sc->tp; in xrep_fix_freelist()
459 args.agno = pag_agno(sc->sa.pag); in xrep_fix_freelist()
461 args.pag = sc->sa.pag; in xrep_fix_freelist()
467 * Finding per-AG Btree Roots for AGF/AGI Reconstruction
509 return (*agbno == bno) ? -ECANCELED : 0; in xrep_findroot_agfl_walk()
521 struct xfs_mount *mp = ri->sc->mp; in xrep_findroot_block()
528 daddr = xfs_agbno_to_daddr(ri->sc->sa.pag, agbno); in xrep_findroot_block()
531 * Blocks in the AGFL have stale contents that might just happen to in xrep_findroot_block()
532 * have a matching magic and uuid. We don't want to pull these blocks in xrep_findroot_block()
537 error = xfs_agfl_walk(mp, ri->agf, ri->agfl_bp, in xrep_findroot_block()
539 if (error == -ECANCELED) in xrep_findroot_block()
563 error = xfs_trans_read_buf(mp, ri->sc->tp, mp->m_ddev_targp, daddr, in xrep_findroot_block()
564 mp->m_bsize, 0, &bp, NULL); in xrep_findroot_block()
570 ASSERT(fab->buf_ops->magic[1] != 0); in xrep_findroot_block()
571 if (btblock->bb_magic != fab->buf_ops->magic[1]) in xrep_findroot_block()
588 if (bp->b_ops) { in xrep_findroot_block()
589 if (bp->b_ops != fab->buf_ops) in xrep_findroot_block()
593 if (!uuid_equal(&btblock->bb_u.s.bb_uuid, in xrep_findroot_block()
594 &mp->m_sb.sb_meta_uuid)) in xrep_findroot_block()
601 bp->b_ops = fab->buf_ops; in xrep_findroot_block()
602 fab->buf_ops->verify_read(bp); in xrep_findroot_block()
603 if (bp->b_error) { in xrep_findroot_block()
604 bp->b_ops = NULL; in xrep_findroot_block()
605 bp->b_error = 0; in xrep_findroot_block()
626 * blocks because there can't be two candidate roots. in xrep_findroot_block()
632 if (block_level + 1 == fab->height) { in xrep_findroot_block()
633 fab->root = NULLAGBLOCK; in xrep_findroot_block()
635 } else if (block_level < fab->height) { in xrep_findroot_block()
644 fab->height = block_level + 1; in xrep_findroot_block()
651 if (btblock->bb_u.s.bb_leftsib == cpu_to_be32(NULLAGBLOCK) && in xrep_findroot_block()
652 btblock->bb_u.s.bb_rightsib == cpu_to_be32(NULLAGBLOCK)) in xrep_findroot_block()
653 fab->root = agbno; in xrep_findroot_block()
655 fab->root = NULLAGBLOCK; in xrep_findroot_block()
657 trace_xrep_findroot_block(ri->sc->sa.pag, agbno, in xrep_findroot_block()
658 be32_to_cpu(btblock->bb_magic), fab->height - 1); in xrep_findroot_block()
660 xfs_trans_brelse(ri->sc->tp, bp); in xrep_findroot_block()
665 * Do any of the blocks in this rmap record match one of the btrees we're
681 if (!XFS_RMAP_NON_INODE_OWNER(rec->rm_owner)) in xrep_findroot_rmap()
685 for (b = 0; b < rec->rm_blockcount; b++) { in xrep_findroot_rmap()
687 for (fab = ri->btree_info; fab->buf_ops; fab++) { in xrep_findroot_rmap()
688 if (rec->rm_owner != fab->rmap_owner) in xrep_findroot_rmap()
691 rec->rm_owner, rec->rm_startblock + b, in xrep_findroot_rmap()
703 /* Find the roots of the per-AG btrees described in btree_info. */
711 struct xfs_mount *mp = sc->mp; in xrep_find_ag_btree_roots()
722 ri.agf = agf_bp->b_addr; in xrep_find_ag_btree_roots()
724 for (fab = btree_info; fab->buf_ops; fab++) { in xrep_find_ag_btree_roots()
725 ASSERT(agfl_bp || fab->rmap_owner != XFS_RMAP_OWN_AG); in xrep_find_ag_btree_roots()
726 ASSERT(XFS_RMAP_NON_INODE_OWNER(fab->rmap_owner)); in xrep_find_ag_btree_roots()
727 fab->root = NULLAGBLOCK; in xrep_find_ag_btree_roots()
728 fab->height = 0; in xrep_find_ag_btree_roots()
731 cur = xfs_rmapbt_init_cursor(mp, sc->tp, agf_bp, sc->sa.pag); in xrep_find_ag_btree_roots()
746 struct xfs_mount *mp = sc->mp; in xrep_update_qflags()
749 mutex_lock(&mp->m_quotainfo->qi_quotaofflock); in xrep_update_qflags()
750 if ((mp->m_qflags & clear_flags) == 0 && in xrep_update_qflags()
751 (mp->m_qflags & set_flags) == set_flags) in xrep_update_qflags()
754 mp->m_qflags &= ~clear_flags; in xrep_update_qflags()
755 mp->m_qflags |= set_flags; in xrep_update_qflags()
757 spin_lock(&mp->m_sb_lock); in xrep_update_qflags()
758 mp->m_sb.sb_qflags &= ~clear_flags; in xrep_update_qflags()
759 mp->m_sb.sb_qflags |= set_flags; in xrep_update_qflags()
760 spin_unlock(&mp->m_sb_lock); in xrep_update_qflags()
768 bp = xfs_trans_getsb(sc->tp); in xrep_update_qflags()
769 xfs_sb_to_disk(bp->b_addr, &mp->m_sb); in xrep_update_qflags()
770 xfs_trans_buf_set_type(sc->tp, bp, XFS_BLFT_SB_BUF); in xrep_update_qflags()
771 xfs_trans_log_buf(sc->tp, bp, 0, sizeof(struct xfs_dsb) - 1); in xrep_update_qflags()
774 mutex_unlock(&mp->m_quotainfo->qi_quotaofflock); in xrep_update_qflags()
786 if (!(flag & sc->mp->m_qflags)) in xrep_force_quotacheck()
796 * We cannot allow the dquot code to allocate an on-disk dquot block here
797 * because we're already in transaction context. The on-disk dquot should
808 ASSERT(sc->tp != NULL); in xrep_ino_dqattach()
809 ASSERT(sc->ip != NULL); in xrep_ino_dqattach()
811 error = xfs_qm_dqattach(sc->ip); in xrep_ino_dqattach()
813 case -EFSBADCRC: in xrep_ino_dqattach()
814 case -EFSCORRUPTED: in xrep_ino_dqattach()
815 case -ENOENT: in xrep_ino_dqattach()
816 xfs_err_ratelimited(sc->mp, in xrep_ino_dqattach()
818 (unsigned long long)sc->ip->i_ino, error); in xrep_ino_dqattach()
819 if (XFS_IS_UQUOTA_ON(sc->mp) && !sc->ip->i_udquot) in xrep_ino_dqattach()
821 if (XFS_IS_GQUOTA_ON(sc->mp) && !sc->ip->i_gdquot) in xrep_ino_dqattach()
823 if (XFS_IS_PQUOTA_ON(sc->mp) && !sc->ip->i_pdquot) in xrep_ino_dqattach()
826 case -ESRCH: in xrep_ino_dqattach()
851 inode_has_nrext64 = xfs_inode_has_large_extent_counts(sc->ip); in xrep_ino_ensure_extent_count()
856 return -EFSCORRUPTED; in xrep_ino_ensure_extent_count()
857 if (!xfs_has_large_extent_counts(sc->mp)) in xrep_ino_ensure_extent_count()
858 return -EFSCORRUPTED; in xrep_ino_ensure_extent_count()
862 return -EFSCORRUPTED; in xrep_ino_ensure_extent_count()
864 sc->ip->i_diflags2 |= XFS_DIFLAG2_NREXT64; in xrep_ino_ensure_extent_count()
865 xfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE); in xrep_ino_ensure_extent_count()
878 struct xfs_mount *mp = sc->mp; in xrep_ag_btcur_init()
880 /* Set up a bnobt cursor for cross-referencing. */ in xrep_ag_btcur_init()
881 if (sc->sm->sm_type != XFS_SCRUB_TYPE_BNOBT && in xrep_ag_btcur_init()
882 sc->sm->sm_type != XFS_SCRUB_TYPE_CNTBT) { in xrep_ag_btcur_init()
883 sa->bno_cur = xfs_bnobt_init_cursor(mp, sc->tp, sa->agf_bp, in xrep_ag_btcur_init()
884 sc->sa.pag); in xrep_ag_btcur_init()
885 sa->cnt_cur = xfs_cntbt_init_cursor(mp, sc->tp, sa->agf_bp, in xrep_ag_btcur_init()
886 sc->sa.pag); in xrep_ag_btcur_init()
889 /* Set up a inobt cursor for cross-referencing. */ in xrep_ag_btcur_init()
890 if (sc->sm->sm_type != XFS_SCRUB_TYPE_INOBT && in xrep_ag_btcur_init()
891 sc->sm->sm_type != XFS_SCRUB_TYPE_FINOBT) { in xrep_ag_btcur_init()
892 sa->ino_cur = xfs_inobt_init_cursor(sc->sa.pag, sc->tp, in xrep_ag_btcur_init()
893 sa->agi_bp); in xrep_ag_btcur_init()
895 sa->fino_cur = xfs_finobt_init_cursor(sc->sa.pag, in xrep_ag_btcur_init()
896 sc->tp, sa->agi_bp); in xrep_ag_btcur_init()
899 /* Set up a rmapbt cursor for cross-referencing. */ in xrep_ag_btcur_init()
900 if (sc->sm->sm_type != XFS_SCRUB_TYPE_RMAPBT && in xrep_ag_btcur_init()
902 sa->rmap_cur = xfs_rmapbt_init_cursor(mp, sc->tp, sa->agf_bp, in xrep_ag_btcur_init()
903 sc->sa.pag); in xrep_ag_btcur_init()
905 /* Set up a refcountbt cursor for cross-referencing. */ in xrep_ag_btcur_init()
906 if (sc->sm->sm_type != XFS_SCRUB_TYPE_REFCNTBT && in xrep_ag_btcur_init()
908 sa->refc_cur = xfs_refcountbt_init_cursor(mp, sc->tp, in xrep_ag_btcur_init()
909 sa->agf_bp, sc->sa.pag); in xrep_ag_btcur_init()
913 * Reinitialize the in-core AG state after a repair by rereading the AGF
921 struct xfs_perag *pag = sc->sa.pag; in xrep_reinit_pagf()
928 clear_bit(XFS_AGSTATE_AGF_INIT, &pag->pag_opstate); in xrep_reinit_pagf()
929 error = xfs_alloc_read_agf(pag, sc->tp, 0, &bp); in xrep_reinit_pagf()
933 if (bp != sc->sa.agf_bp) { in xrep_reinit_pagf()
934 ASSERT(bp == sc->sa.agf_bp); in xrep_reinit_pagf()
935 return -EFSCORRUPTED; in xrep_reinit_pagf()
942 * Reinitialize the in-core AG state after a repair by rereading the AGI
950 struct xfs_perag *pag = sc->sa.pag; in xrep_reinit_pagi()
957 clear_bit(XFS_AGSTATE_AGI_INIT, &pag->pag_opstate); in xrep_reinit_pagi()
958 error = xfs_ialloc_read_agi(pag, sc->tp, 0, &bp); in xrep_reinit_pagi()
962 if (bp != sc->sa.agi_bp) { in xrep_reinit_pagi()
963 ASSERT(bp == sc->sa.agi_bp); in xrep_reinit_pagi()
964 return -EFSCORRUPTED; in xrep_reinit_pagi()
972 * This should only be called to scan an AG while repairing file-based metadata.
982 ASSERT(!sa->pag); in xrep_ag_init()
984 error = xfs_ialloc_read_agi(pag, sc->tp, 0, &sa->agi_bp); in xrep_ag_init()
988 error = xfs_alloc_read_agf(pag, sc->tp, 0, &sa->agf_bp); in xrep_ag_init()
993 sa->pag = xfs_perag_hold(pag); in xrep_ag_init()
1005 struct xfs_mount *mp = sc->mp; in xrep_rtgroup_btcur_init()
1007 ASSERT(sr->rtg != NULL); in xrep_rtgroup_btcur_init()
1009 if (sc->sm->sm_type != XFS_SCRUB_TYPE_RTRMAPBT && in xrep_rtgroup_btcur_init()
1010 (sr->rtlock_flags & XFS_RTGLOCK_RMAP) && in xrep_rtgroup_btcur_init()
1012 sr->rmap_cur = xfs_rtrmapbt_init_cursor(sc->tp, sr->rtg); in xrep_rtgroup_btcur_init()
1014 if (sc->sm->sm_type != XFS_SCRUB_TYPE_RTREFCBT && in xrep_rtgroup_btcur_init()
1015 (sr->rtlock_flags & XFS_RTGLOCK_REFCOUNT) && in xrep_rtgroup_btcur_init()
1017 sr->refc_cur = xfs_rtrefcountbt_init_cursor(sc->tp, sr->rtg); in xrep_rtgroup_btcur_init()
1031 ASSERT(sr->rtg == NULL); in xrep_rtgroup_init()
1034 sr->rtlock_flags = rtglock_flags; in xrep_rtgroup_init()
1037 sr->rtg = xfs_rtgroup_hold(rtg); in xrep_rtgroup_init()
1042 /* Ensure that all rt blocks in the given range are not marked free. */
1049 struct xfs_mount *mp = sc->mp; in xrep_require_rtext_inuse()
1056 endrtx = xfs_rgbno_to_rtx(mp, rgbno + len - 1); in xrep_require_rtext_inuse()
1058 error = xfs_rtalloc_extent_is_free(sc->sr.rtg, sc->tp, startrtx, in xrep_require_rtext_inuse()
1059 endrtx - startrtx + 1, &is_free); in xrep_require_rtext_inuse()
1063 return -EFSCORRUPTED; in xrep_require_rtext_inuse()
1069 /* Reinitialize the per-AG block reservation for the AG we just fixed. */
1076 if (!(sc->flags & XREP_RESET_PERAG_RESV)) in xrep_reset_perag_resv()
1079 ASSERT(sc->sa.pag != NULL); in xrep_reset_perag_resv()
1080 ASSERT(sc->ops->type == ST_PERAG); in xrep_reset_perag_resv()
1081 ASSERT(sc->tp); in xrep_reset_perag_resv()
1083 sc->flags &= ~XREP_RESET_PERAG_RESV; in xrep_reset_perag_resv()
1084 xfs_ag_resv_free(sc->sa.pag); in xrep_reset_perag_resv()
1085 error = xfs_ag_resv_init(sc->sa.pag, sc->tp); in xrep_reset_perag_resv()
1086 if (error == -ENOSPC) { in xrep_reset_perag_resv()
1087 xfs_err(sc->mp, in xrep_reset_perag_resv()
1088 "Insufficient free space to reset per-AG reservation for AG %u after repair.", in xrep_reset_perag_resv()
1089 pag_agno(sc->sa.pag)); in xrep_reset_perag_resv()
1102 if (sc->sm->sm_flags & XFS_SCRUB_IFLAG_FORCE_REBUILD) in xrep_will_attempt()
1106 if (XFS_TEST_ERROR(false, sc->mp, XFS_ERRTAG_FORCE_SCRUB_REPAIR)) in xrep_will_attempt()
1109 /* Metadata is corrupt or failed cross-referencing. */ in xrep_will_attempt()
1110 if (xchk_needs_repair(sc->sm)) in xrep_will_attempt()
1122 struct xfs_scrub_subord *sub; in xrep_metadata_inode_subtype() local
1131 sub = xchk_scrub_create_subord(sc, scrub_type); in xrep_metadata_inode_subtype()
1132 error = sub->sc.ops->scrub(&sub->sc); in xrep_metadata_inode_subtype()
1135 if (!xrep_will_attempt(&sub->sc)) in xrep_metadata_inode_subtype()
1142 error = sub->sc.ops->repair(&sub->sc); in xrep_metadata_inode_subtype()
1151 error = xfs_defer_finish(&sub->sc.tp); in xrep_metadata_inode_subtype()
1154 error = xfs_trans_roll(&sub->sc.tp); in xrep_metadata_inode_subtype()
1159 * Clear the corruption flags and re-check the metadata that we just in xrep_metadata_inode_subtype()
1162 sub->sc.sm->sm_flags &= ~XFS_SCRUB_FLAGS_OUT; in xrep_metadata_inode_subtype()
1163 error = sub->sc.ops->scrub(&sub->sc); in xrep_metadata_inode_subtype()
1168 if (xchk_needs_repair(sub->sc.sm)) { in xrep_metadata_inode_subtype()
1169 error = -EFSCORRUPTED; in xrep_metadata_inode_subtype()
1173 xchk_scrub_free_subord(sub); in xrep_metadata_inode_subtype()
1179 * sc->ip points to the metadata inode and the ILOCK is held on that inode.
1202 * For a non-metadir filesystem, make sure the attr fork looks ok in xrep_metadata_inode_forks()
1205 if (xfs_inode_hasattr(sc->ip)) { in xrep_metadata_inode_forks()
1212 if (xfs_is_reflink_inode(sc->ip)) { in xrep_metadata_inode_forks()
1214 xfs_trans_ijoin(sc->tp, sc->ip, 0); in xrep_metadata_inode_forks()
1215 error = xfs_reflink_clear_inode_flag(sc->ip, &sc->tp); in xrep_metadata_inode_forks()
1221 * Metadata files on non-metadir filesystems cannot have attr forks, in xrep_metadata_inode_forks()
1224 if (xfs_inode_hasattr(sc->ip) && !xfs_has_metadir(sc->mp)) { in xrep_metadata_inode_forks()
1227 xfs_trans_ijoin(sc->tp, sc->ip, 0); in xrep_metadata_inode_forks()
1239 error = xfs_trans_roll(&sc->tp); in xrep_metadata_inode_forks()
1249 * Set up an in-memory buffer cache so that we can use the xfbtree. Allocating
1259 ASSERT(sc->tp == NULL); in xrep_setup_xfbtree()
1261 return xmbuf_alloc(sc->mp, descr, &sc->xmbtp); in xrep_setup_xfbtree()
1277 *cookiep = current->journal_info; in xrep_trans_alloc_hook_dummy()
1278 current->journal_info = NULL; in xrep_trans_alloc_hook_dummy()
1284 current->journal_info = *cookiep; in xrep_trans_alloc_hook_dummy()
1296 current->journal_info = *cookiep; in xrep_trans_cancel_hook_dummy()
1301 * See if this buffer can pass the given ->verify_struct() function.
1313 const struct xfs_buf_ops *old_ops = bp->b_ops; in xrep_buf_verify_struct()
1322 old_error = bp->b_error; in xrep_buf_verify_struct()
1323 bp->b_ops = ops; in xrep_buf_verify_struct()
1324 fa = bp->b_ops->verify_struct(bp); in xrep_buf_verify_struct()
1325 bp->b_ops = old_ops; in xrep_buf_verify_struct()
1326 bp->b_error = old_error; in xrep_buf_verify_struct()
1341 * Metadata btree inodes never have extended attributes, and all blocks in xrep_check_ino_btree_mapping()
1344 if ((rec->rm_flags & XFS_RMAP_ATTR_FORK) || in xrep_check_ino_btree_mapping()
1345 !(rec->rm_flags & XFS_RMAP_BMBT_BLOCK)) in xrep_check_ino_btree_mapping()
1346 return -EFSCORRUPTED; in xrep_check_ino_btree_mapping()
1349 if (!xfs_verify_agbext(sc->sa.pag, rec->rm_startblock, in xrep_check_ino_btree_mapping()
1350 rec->rm_blockcount)) in xrep_check_ino_btree_mapping()
1351 return -EFSCORRUPTED; in xrep_check_ino_btree_mapping()
1354 error = xfs_alloc_has_records(sc->sa.bno_cur, rec->rm_startblock, in xrep_check_ino_btree_mapping()
1355 rec->rm_blockcount, &outcome); in xrep_check_ino_btree_mapping()
1359 return -EFSCORRUPTED; in xrep_check_ino_btree_mapping()
1374 new_blocks - sc->ip->i_nblocks; in xrep_inode_set_nblocks()
1376 sc->ip->i_nblocks = new_blocks; in xrep_inode_set_nblocks()
1378 xfs_trans_log_inode(sc->tp, sc->ip, XFS_ILOG_CORE); in xrep_inode_set_nblocks()
1380 xfs_trans_mod_dquot_byino(sc->tp, sc->ip, XFS_TRANS_DQ_BCOUNT, in xrep_inode_set_nblocks()
1389 struct xfs_inode *ip = sc->ip; in xrep_reset_metafile_resv()
1393 delta = ip->i_nblocks + ip->i_delayed_blks - ip->i_meta_resv_asked; in xrep_reset_metafile_resv()
1398 * Too many blocks have been reserved, transfer some from the incore in xrep_reset_metafile_resv()
1404 give_back = min_t(uint64_t, delta, ip->i_delayed_blks); in xrep_reset_metafile_resv()
1406 xfs_mod_delalloc(ip, 0, -give_back); in xrep_reset_metafile_resv()
1407 xfs_add_fdblocks(ip->i_mount, give_back); in xrep_reset_metafile_resv()
1408 ip->i_delayed_blks -= give_back; in xrep_reset_metafile_resv()
1415 * Not enough reservation; try to take some blocks from the filesystem in xrep_reset_metafile_resv()
1418 delta = -delta; in xrep_reset_metafile_resv()
1419 error = xfs_dec_fdblocks(sc->mp, delta, true); in xrep_reset_metafile_resv()
1420 while (error == -ENOSPC) { in xrep_reset_metafile_resv()
1421 delta--; in xrep_reset_metafile_resv()
1423 xfs_warn(sc->mp, in xrep_reset_metafile_resv()
1425 ip->i_ino); in xrep_reset_metafile_resv()
1428 error = xfs_dec_fdblocks(sc->mp, delta, true); in xrep_reset_metafile_resv()
1434 ip->i_delayed_blks += delta; in xrep_reset_metafile_resv()