Line data Source code
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 : 11 276670606 : static inline int xrep_notsupported(struct xfs_scrub *sc) 12 : { 13 276670606 : return -EOPNOTSUPP; 14 : } 15 : 16 : #ifdef CONFIG_XFS_ONLINE_REPAIR 17 : 18 : /* Repair helpers */ 19 : 20 : int xrep_attempt(struct xfs_scrub *sc); 21 : void xrep_failure(struct xfs_mount *mp); 22 : int xrep_roll_ag_trans(struct xfs_scrub *sc); 23 : bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks, 24 : enum xfs_ag_resv_type type); 25 : xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc); 26 : int xrep_alloc_ag_block(struct xfs_scrub *sc, 27 : const struct xfs_owner_info *oinfo, xfs_fsblock_t *fsbno, 28 : enum xfs_ag_resv_type resv); 29 : int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb, 30 : struct xfs_buf **bpp, xfs_btnum_t btnum, 31 : const struct xfs_buf_ops *ops); 32 : 33 : struct xbitmap; 34 : struct xagb_bitmap; 35 : 36 : int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink); 37 : int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xbitmap *btlist); 38 : int xrep_reap_extents(struct xfs_scrub *sc, struct xbitmap *exlist, 39 : const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type); 40 : 41 : struct xrep_find_ag_btree { 42 : /* in: rmap owner of the btree we're looking for */ 43 : uint64_t rmap_owner; 44 : 45 : /* in: buffer ops */ 46 : const struct xfs_buf_ops *buf_ops; 47 : 48 : /* in: maximum btree height */ 49 : unsigned int maxlevels; 50 : 51 : /* out: the highest btree block found and the tree height */ 52 : xfs_agblock_t root; 53 : unsigned int height; 54 : }; 55 : 56 : int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp, 57 : struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp); 58 : void xrep_force_quotacheck(struct xfs_scrub *sc, xfs_dqtype_t type); 59 : int xrep_ino_dqattach(struct xfs_scrub *sc); 60 : 61 : /* Metadata repairers */ 62 : 63 : int xrep_probe(struct xfs_scrub *sc); 64 : int xrep_superblock(struct xfs_scrub *sc); 65 : int xrep_agf(struct xfs_scrub *sc); 66 : int xrep_agfl(struct xfs_scrub *sc); 67 : int xrep_agi(struct xfs_scrub *sc); 68 : 69 : #else 70 : 71 : static inline int 72 : xrep_attempt( 73 : struct xfs_scrub *sc) 74 : { 75 : return -EOPNOTSUPP; 76 : } 77 : 78 : static inline void xrep_failure(struct xfs_mount *mp) {} 79 : 80 : static inline xfs_extlen_t 81 : xrep_calc_ag_resblks( 82 : struct xfs_scrub *sc) 83 : { 84 : return 0; 85 : } 86 : 87 : #define xrep_probe xrep_notsupported 88 : #define xrep_superblock xrep_notsupported 89 : #define xrep_agf xrep_notsupported 90 : #define xrep_agfl xrep_notsupported 91 : #define xrep_agi xrep_notsupported 92 : 93 : #endif /* CONFIG_XFS_ONLINE_REPAIR */ 94 : 95 : #endif /* __XFS_SCRUB_REPAIR_H__ */