Merge tag 'drm-next-2019-01-05' of git://anongit.freedesktop.org/drm/drm
[linux-2.6-block.git] / fs / xfs / scrub / repair.h
CommitLineData
0b61f8a4 1// SPDX-License-Identifier: GPL-2.0+
84d42ea6
DW
2/*
3 * Copyright (C) 2018 Oracle. All Rights Reserved.
84d42ea6 4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
84d42ea6
DW
5 */
6#ifndef __XFS_SCRUB_REPAIR_H__
7#define __XFS_SCRUB_REPAIR_H__
8
1d8a748a 9static inline int xrep_notsupported(struct xfs_scrub *sc)
84d42ea6
DW
10{
11 return -EOPNOTSUPP;
12}
13
14#ifdef CONFIG_XFS_ONLINE_REPAIR
15
16/* Repair helpers */
17
032d91f9 18int xrep_attempt(struct xfs_inode *ip, struct xfs_scrub *sc, bool *fixed);
b5e2196e 19void xrep_failure(struct xfs_mount *mp);
1d8a748a 20int xrep_roll_ag_trans(struct xfs_scrub *sc);
b5e2196e 21bool xrep_ag_has_space(struct xfs_perag *pag, xfs_extlen_t nr_blocks,
0a9633fa 22 enum xfs_ag_resv_type type);
1d8a748a 23xfs_extlen_t xrep_calc_ag_resblks(struct xfs_scrub *sc);
66e3237e
DW
24int 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);
1d8a748a 27int xrep_init_btblock(struct xfs_scrub *sc, xfs_fsblock_t fsb,
73d6b42a
DW
28 struct xfs_buf **bpp, xfs_btnum_t btnum,
29 const struct xfs_buf_ops *ops);
84d42ea6 30
86d969b4 31struct xfs_bitmap;
64a39d87 32
1d8a748a 33int xrep_fix_freelist(struct xfs_scrub *sc, bool can_shrink);
86d969b4
DW
34int xrep_invalidate_blocks(struct xfs_scrub *sc, struct xfs_bitmap *btlist);
35int xrep_reap_extents(struct xfs_scrub *sc, struct xfs_bitmap *exlist,
66e3237e 36 const struct xfs_owner_info *oinfo, enum xfs_ag_resv_type type);
64a39d87 37
b5e2196e 38struct xrep_find_ag_btree {
04a2b7b2
DW
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
032d91f9
DW
53int 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);
1d8a748a
DW
55void xrep_force_quotacheck(struct xfs_scrub *sc, uint dqtype);
56int xrep_ino_dqattach(struct xfs_scrub *sc);
04a2b7b2 57
84d42ea6
DW
58/* Metadata repairers */
59
1d8a748a
DW
60int xrep_probe(struct xfs_scrub *sc);
61int xrep_superblock(struct xfs_scrub *sc);
f9ed6deb 62int xrep_agf(struct xfs_scrub *sc);
0e93d3f4 63int xrep_agfl(struct xfs_scrub *sc);
13942aa9 64int xrep_agi(struct xfs_scrub *sc);
84d42ea6
DW
65
66#else
67
b5e2196e 68static inline int xrep_attempt(
032d91f9 69 struct xfs_inode *ip,
1d8a748a 70 struct xfs_scrub *sc,
032d91f9 71 bool *fixed)
84d42ea6
DW
72{
73 return -EOPNOTSUPP;
74}
75
b5e2196e 76static inline void xrep_failure(struct xfs_mount *mp) {}
84d42ea6 77
0a9633fa 78static inline xfs_extlen_t
b5e2196e 79xrep_calc_ag_resblks(
1d8a748a 80 struct xfs_scrub *sc)
0a9633fa
DW
81{
82 ASSERT(!(sc->sm->sm_flags & XFS_SCRUB_IFLAG_REPAIR));
83 return 0;
84}
85
b5e2196e
DW
86#define xrep_probe xrep_notsupported
87#define xrep_superblock xrep_notsupported
f9ed6deb 88#define xrep_agf xrep_notsupported
0e93d3f4 89#define xrep_agfl xrep_notsupported
13942aa9 90#define xrep_agi xrep_notsupported
84d42ea6
DW
91
92#endif /* CONFIG_XFS_ONLINE_REPAIR */
93
94#endif /* __XFS_SCRUB_REPAIR_H__ */