xref: /openbmc/linux/fs/xfs/scrub/repair.h (revision 95777591)
1 // SPDX-License-Identifier: GPL-2.0+
2 /*
3  * Copyright (C) 2018 Oracle.  All Rights Reserved.
4  * Author: Darrick J. Wong <darrick.wong@oracle.com>
5  */
6 #ifndef __XFS_SCRUB_REPAIR_H__
7 #define __XFS_SCRUB_REPAIR_H__
8 
9 static inline int xrep_notsupported(struct xfs_scrub *sc)
10 {
11 	return -EOPNOTSUPP;
12 }
13 
14 #ifdef CONFIG_XFS_ONLINE_REPAIR
15 
16 /* Repair helpers */
17 
18 int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, bool *fixed);
19 void xrep_failure(struct xfs_mount *mp);
20 int xrep_roll_ag_trans(struct xfs_scrub *sc);
21 bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
22 		enum xfs_ag_resv_type type);
23 xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
24 int xrep_alloc_ag_block(struct xfs_scrub *sc,
25 		const struct xfs_owner_info *oinfo, xfs_fsblock_t *fsbno,
26 		enum xfs_ag_resv_type resv);
27 int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
28 		struct xfs_buf **bpp, xfs_btnum_t btnum,
29 		const struct xfs_buf_ops *ops);
30 
31 struct xfs_bitmap;
32 
33 int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
34 int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xfs_bitmap *btlist);
35 int xrep_reap_extents(struct xfs_scrub *sc, struct xfs_bitmap *exlist,
36 		const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
37 
38 struct xrep_find_ag_btree {
39 	/* in: rmap owner of the btree we're looking for */
40 	uint64_t			rmap_owner;
41 
42 	/* in: buffer ops */
43 	const struct xfs_buf_ops	*buf_ops;
44 
45 	/* in: magic number of the btree */
46 	uint32_t			magic;
47 
48 	/* out: the highest btree block found and the tree height */
49 	xfs_agblock_t			root;
50 	unsigned int			height;
51 };
52 
53 int xrep_find_ag_btree_roots(struct xfs_scrub *sc, struct xfs_buf *agf_bp,
54 		struct xrep_find_ag_btree *btree_info, struct xfs_buf *agfl_bp);
55 void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype);
56 int xrep_ino_dqattach(struct xfs_scrub *sc);
57 
58 /* Metadata repairers */
59 
60 int xrep_probe(struct xfs_scrub *sc);
61 int xrep_superblock(struct xfs_scrub *sc);
62 int xrep_agf(struct xfs_scrub *sc);
63 int xrep_agfl(struct xfs_scrub *sc);
64 int xrep_agi(struct xfs_scrub *sc);
65 
66 #else
67 
68 static inline int xrep_attempt(
69 	struct xfs_inode	*ip,
70 	struct xfs_scrub	*sc,
71 	bool			*fixed)
72 {
73 	return -EOPNOTSUPP;
74 }
75 
76 static inline void xrep_failure(struct xfs_mount *mp) {}
77 
78 static inline xfs_extlen_t
79 xrep_calc_ag_resblks(
80 	struct xfs_scrub	*sc)
81 {
82 	ASSERT(!(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR));
83 	return 0;
84 }
85 
86 #define xrep_probe			xrep_notsupported
87 #define xrep_superblock			xrep_notsupported
88 #define xrep_agf			xrep_notsupported
89 #define xrep_agfl			xrep_notsupported
90 #define xrep_agi			xrep_notsupported
91 
92 #endif /* CONFIG_XFS_ONLINE_REPAIR */
93 
94 #endif	/* __XFS_SCRUB_REPAIR_H__ */
95