1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (C) 2018-2023 Oracle. All Rights Reserved. 4 * Author: Darrick J. Wong <djwong@kernel.org> 5 */ 6#ifndef __XFS_SCRUB_REPAIR_H__ 7#define __XFS_SCRUB_REPAIR_H__ 8 9#include "xfs_quota_defs.h" 10 11struct xchk_stats_run; 12 13static inline int xrep_notsupported(struct xfs_scrub *sc) 14{ 15 return -EOPNOTSUPP; 16} 17 18#ifdef CONFIG_XFS_ONLINE_REPAIR 19 20/* 21 * This is the maximum number of deferred extent freeing item extents (EFIs) 22 * that we'll attach to a transaction without rolling the transaction to avoid 23 * overrunning a tr_itruncate reservation. 24 */ 25#define XREP_MAX_ITRUNCATE_EFIS (128) 26 27 28/* Repair helpers */ 29 30int xrep_attempt(struct xfs_scrub *sc, struct xchk_stats_run *run); 31void xrep_failure(struct xfs_mount *mp); 32int xrep_roll_ag_trans(struct xfs_scrub *sc); 33int xrep_defer_finish(struct xfs_scrub *sc); 34bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks, 35 enum xfs_ag_resv_type type); 36xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc); 37 38struct xbitmap; 39struct xagb_bitmap; 40 41int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink); 42 43struct xrep_find_ag_btree { 44 /* in: rmap owner of the btree we're looking for */ 45 uint64_t rmap_owner; 46 47 /* in: buffer ops */ 48 const struct xfs_buf_ops *buf_ops; 49 50 /* in: maximum btree height */ 51 unsigned int maxlevels; 52 53 /* out: the highest btree block found and the tree height */ 54 xfs_agblock_t root; 55 unsigned int height; 56}; 57 58int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp, 59 struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp); 60void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type); 61int xrep_ino_dqattach(struct xfs_scrub *sc); 62 63/* Metadata repairers */ 64 65int xrep_probe(struct xfs_scrub *sc); 66int xrep_superblock(struct xfs_scrub *sc); 67int xrep_agf(struct xfs_scrub *sc); 68int xrep_agfl(struct xfs_scrub *sc); 69int xrep_agi(struct xfs_scrub *sc); 70 71#else 72 73static inline int 74xrep_attempt( 75 struct xfs_scrub *sc, 76 struct xchk_stats_run *run) 77{ 78 return -EOPNOTSUPP; 79} 80 81static inline void xrep_failure(struct xfs_mount *mp) {} 82 83static inline xfs_extlen_t 84xrep_calc_ag_resblks( 85 struct xfs_scrub *sc) 86{ 87 return 0; 88} 89 90#define xrep_probe xrep_notsupported 91#define xrep_superblock xrep_notsupported 92#define xrep_agf xrep_notsupported 93#define xrep_agfl xrep_notsupported 94#define xrep_agi xrep_notsupported 95 96#endif /* CONFIG_XFS_ONLINE_REPAIR */ 97 98#endif /* __XFS_SCRUB_REPAIR_H__ */ 99