2 * Copyright (C) 2017 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
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.
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.
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.
20 #ifndef __XFS_SCRUB_SCRUB_H__
21 #define __XFS_SCRUB_SCRUB_H__
23 struct xfs_scrub_context
;
25 /* Type info and names for the scrub types. */
27 ST_NONE
= 1, /* disabled */
28 ST_PERAG
, /* per-AG metadata */
29 ST_FS
, /* per-FS metadata */
30 ST_INODE
, /* per-inode metadata */
33 struct xfs_scrub_meta_ops
{
34 /* Acquire whatever resources are needed for the operation. */
35 int (*setup
)(struct xfs_scrub_context
*,
38 /* Examine metadata for errors. */
39 int (*scrub
)(struct xfs_scrub_context
*);
41 /* Decide if we even have this piece of metadata. */
42 bool (*has
)(struct xfs_sb
*);
44 /* type describing required/allowed inputs */
45 enum xfs_scrub_type type
;
48 /* Buffer pointers and btree cursors for an entire AG. */
53 struct xfs_buf
*agf_bp
;
54 struct xfs_buf
*agfl_bp
;
55 struct xfs_buf
*agi_bp
;
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
;
66 struct xfs_scrub_context
{
67 /* General scrub state. */
69 struct xfs_scrub_metadata
*sm
;
70 const struct xfs_scrub_meta_ops
*ops
;
77 /* State tracking for single-AG operations. */
78 struct xfs_scrub_ag sa
;
81 /* Metadata scrubbers */
82 int xfs_scrub_tester(struct xfs_scrub_context
*sc
);
83 int xfs_scrub_superblock(struct xfs_scrub_context
*sc
);
84 int xfs_scrub_agf(struct xfs_scrub_context
*sc
);
85 int xfs_scrub_agfl(struct xfs_scrub_context
*sc
);
86 int xfs_scrub_agi(struct xfs_scrub_context
*sc
);
87 int xfs_scrub_bnobt(struct xfs_scrub_context
*sc
);
88 int xfs_scrub_cntbt(struct xfs_scrub_context
*sc
);
89 int xfs_scrub_inobt(struct xfs_scrub_context
*sc
);
90 int xfs_scrub_finobt(struct xfs_scrub_context
*sc
);
91 int xfs_scrub_rmapbt(struct xfs_scrub_context
*sc
);
92 int xfs_scrub_refcountbt(struct xfs_scrub_context
*sc
);
93 int xfs_scrub_inode(struct xfs_scrub_context
*sc
);
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
);
97 int xfs_scrub_directory(struct xfs_scrub_context
*sc
);
98 int xfs_scrub_xattr(struct xfs_scrub_context
*sc
);
99 int xfs_scrub_symlink(struct xfs_scrub_context
*sc
);
100 int xfs_scrub_parent(struct xfs_scrub_context
*sc
);
102 int xfs_scrub_rtbitmap(struct xfs_scrub_context
*sc
);
103 int xfs_scrub_rtsummary(struct xfs_scrub_context
*sc
);
106 xfs_scrub_rtbitmap(struct xfs_scrub_context
*sc
)
111 xfs_scrub_rtsummary(struct xfs_scrub_context
*sc
)
116 #ifdef CONFIG_XFS_QUOTA
117 int xfs_scrub_quota(struct xfs_scrub_context
*sc
);
120 xfs_scrub_quota(struct xfs_scrub_context
*sc
)
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
);
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
);
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
);
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
);
146 void xfs_scrub_xref_is_used_rt_space(struct xfs_scrub_context
*sc
,
147 xfs_rtblock_t rtbno
, xfs_extlen_t len
);
149 # define xfs_scrub_xref_is_used_rt_space(sc, rtbno, len) do { } while (0)
152 #endif /* __XFS_SCRUB_SCRUB_H__ */