Commit | Line | Data |
---|---|---|
36fd6e86 DW |
1 | /* |
2 | * Copyright (C) 2017 Oracle. All Rights Reserved. | |
3 | * | |
4 | * Author: Darrick J. Wong <darrick.wong@oracle.com> | |
5 | * | |
6 | * This program is free software; you can redistribute it and/or | |
7 | * modify it under the terms of the GNU General Public License | |
8 | * as published by the Free Software Foundation; either version 2 | |
9 | * of the License, or (at your option) any later version. | |
10 | * | |
11 | * This program is distributed in the hope that it would be useful, | |
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | * GNU General Public License for more details. | |
15 | * | |
16 | * You should have received a copy of the GNU General Public License | |
17 | * along with this program; if not, write the Free Software Foundation, | |
18 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | */ | |
20 | #ifndef __XFS_SCRUB_SCRUB_H__ | |
21 | #define __XFS_SCRUB_SCRUB_H__ | |
22 | ||
a5637186 DW |
23 | struct xfs_scrub_context; |
24 | ||
8e630837 ES |
25 | /* Type info and names for the scrub types. */ |
26 | enum xfs_scrub_type { | |
27 | ST_NONE = 1, /* disabled */ | |
28 | ST_PERAG, /* per-AG metadata */ | |
29 | ST_FS, /* per-FS metadata */ | |
30 | ST_INODE, /* per-inode metadata */ | |
31 | }; | |
32 | ||
a5637186 DW |
33 | struct xfs_scrub_meta_ops { |
34 | /* Acquire whatever resources are needed for the operation. */ | |
35 | int (*setup)(struct xfs_scrub_context *, | |
36 | struct xfs_inode *); | |
37 | ||
38 | /* Examine metadata for errors. */ | |
39 | int (*scrub)(struct xfs_scrub_context *); | |
40 | ||
41 | /* Decide if we even have this piece of metadata. */ | |
42 | bool (*has)(struct xfs_sb *); | |
8e630837 ES |
43 | |
44 | /* type describing required/allowed inputs */ | |
45 | enum xfs_scrub_type type; | |
a5637186 DW |
46 | }; |
47 | ||
b6c1beb9 DW |
48 | /* Buffer pointers and btree cursors for an entire AG. */ |
49 | struct xfs_scrub_ag { | |
50 | xfs_agnumber_t agno; | |
51 | ||
52 | /* AG btree roots */ | |
53 | struct xfs_buf *agf_bp; | |
54 | struct xfs_buf *agfl_bp; | |
55 | struct xfs_buf *agi_bp; | |
56 | ||
57 | /* AG btrees */ | |
58 | struct xfs_btree_cur *bno_cur; | |
59 | struct xfs_btree_cur *cnt_cur; | |
60 | struct xfs_btree_cur *ino_cur; | |
61 | struct xfs_btree_cur *fino_cur; | |
62 | struct xfs_btree_cur *rmap_cur; | |
63 | struct xfs_btree_cur *refc_cur; | |
64 | }; | |
65 | ||
a5637186 DW |
66 | struct xfs_scrub_context { |
67 | /* General scrub state. */ | |
68 | struct xfs_mount *mp; | |
69 | struct xfs_scrub_metadata *sm; | |
70 | const struct xfs_scrub_meta_ops *ops; | |
71 | struct xfs_trans *tp; | |
72 | struct xfs_inode *ip; | |
eec0482e | 73 | void *buf; |
80e4e126 | 74 | uint ilock_flags; |
a5637186 | 75 | bool try_harder; |
b6c1beb9 DW |
76 | |
77 | /* State tracking for single-AG operations. */ | |
78 | struct xfs_scrub_ag sa; | |
a5637186 DW |
79 | }; |
80 | ||
36fd6e86 | 81 | /* Metadata scrubbers */ |
dcb660f9 | 82 | int xfs_scrub_tester(struct xfs_scrub_context *sc); |
21fb4cb1 | 83 | int xfs_scrub_superblock(struct xfs_scrub_context *sc); |
ab9d5dc5 DW |
84 | int xfs_scrub_agf(struct xfs_scrub_context *sc); |
85 | int xfs_scrub_agfl(struct xfs_scrub_context *sc); | |
a12890ae | 86 | int xfs_scrub_agi(struct xfs_scrub_context *sc); |
efa7a99c DW |
87 | int xfs_scrub_bnobt(struct xfs_scrub_context *sc); |
88 | int xfs_scrub_cntbt(struct xfs_scrub_context *sc); | |
3daa6641 DW |
89 | int xfs_scrub_inobt(struct xfs_scrub_context *sc); |
90 | int xfs_scrub_finobt(struct xfs_scrub_context *sc); | |
c7e693d9 | 91 | int xfs_scrub_rmapbt(struct xfs_scrub_context *sc); |
edc09b52 | 92 | int xfs_scrub_refcountbt(struct xfs_scrub_context *sc); |
80e4e126 | 93 | int xfs_scrub_inode(struct xfs_scrub_context *sc); |
99d9d8d0 DW |
94 | int xfs_scrub_bmap_data(struct xfs_scrub_context *sc); |
95 | int xfs_scrub_bmap_attr(struct xfs_scrub_context *sc); | |
96 | int xfs_scrub_bmap_cow(struct xfs_scrub_context *sc); | |
a5c46e5e | 97 | int xfs_scrub_directory(struct xfs_scrub_context *sc); |
eec0482e | 98 | int xfs_scrub_xattr(struct xfs_scrub_context *sc); |
2a721dbb | 99 | int xfs_scrub_symlink(struct xfs_scrub_context *sc); |
0f28b257 | 100 | int xfs_scrub_parent(struct xfs_scrub_context *sc); |
29b0767b DW |
101 | #ifdef CONFIG_XFS_RT |
102 | int xfs_scrub_rtbitmap(struct xfs_scrub_context *sc); | |
103 | int xfs_scrub_rtsummary(struct xfs_scrub_context *sc); | |
104 | #else | |
105 | static inline int | |
106 | xfs_scrub_rtbitmap(struct xfs_scrub_context *sc) | |
107 | { | |
108 | return -ENOENT; | |
109 | } | |
110 | static inline int | |
111 | xfs_scrub_rtsummary(struct xfs_scrub_context *sc) | |
112 | { | |
113 | return -ENOENT; | |
114 | } | |
115 | #endif | |
c2fc338c DW |
116 | #ifdef CONFIG_XFS_QUOTA |
117 | int xfs_scrub_quota(struct xfs_scrub_context *sc); | |
118 | #else | |
119 | static inline int | |
120 | xfs_scrub_quota(struct xfs_scrub_context *sc) | |
121 | { | |
122 | return -ENOENT; | |
123 | } | |
124 | #endif | |
36fd6e86 | 125 | |
52dc4b44 DW |
126 | /* cross-referencing helpers */ |
127 | void xfs_scrub_xref_is_used_space(struct xfs_scrub_context *sc, | |
128 | xfs_agblock_t agbno, xfs_extlen_t len); | |
2e6f2756 DW |
129 | void xfs_scrub_xref_is_not_inode_chunk(struct xfs_scrub_context *sc, |
130 | xfs_agblock_t agbno, xfs_extlen_t len); | |
131 | void xfs_scrub_xref_is_inode_chunk(struct xfs_scrub_context *sc, | |
132 | xfs_agblock_t agbno, xfs_extlen_t len); | |
d852657c DW |
133 | void xfs_scrub_xref_is_owned_by(struct xfs_scrub_context *sc, |
134 | xfs_agblock_t agbno, xfs_extlen_t len, | |
135 | struct xfs_owner_info *oinfo); | |
136 | void xfs_scrub_xref_is_not_owned_by(struct xfs_scrub_context *sc, | |
137 | xfs_agblock_t agbno, xfs_extlen_t len, | |
138 | struct xfs_owner_info *oinfo); | |
139 | void xfs_scrub_xref_has_no_owner(struct xfs_scrub_context *sc, | |
140 | xfs_agblock_t agbno, xfs_extlen_t len); | |
f6d5fc21 DW |
141 | void xfs_scrub_xref_is_cow_staging(struct xfs_scrub_context *sc, |
142 | xfs_agblock_t bno, xfs_extlen_t len); | |
143 | void xfs_scrub_xref_is_not_shared(struct xfs_scrub_context *sc, | |
144 | xfs_agblock_t bno, xfs_extlen_t len); | |
46d9bfb5 DW |
145 | #ifdef CONFIG_XFS_RT |
146 | void xfs_scrub_xref_is_used_rt_space(struct xfs_scrub_context *sc, | |
147 | xfs_rtblock_t rtbno, xfs_extlen_t len); | |
148 | #else | |
149 | # define xfs_scrub_xref_is_used_rt_space(sc, rtbno, len) do { } while (0) | |
150 | #endif | |
52dc4b44 | 151 | |
36fd6e86 | 152 | #endif /* __XFS_SCRUB_SCRUB_H__ */ |