blob: 1385295438e8f83df26ebadac5868fc1a09ce975 [file] [log] [blame]
Darrick J. Wong36fd6e82017-10-17 21:37:34 -07001/*
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
Darrick J. Wonga5637182017-10-17 21:37:35 -070023struct xfs_scrub_context;
24
25struct xfs_scrub_meta_ops {
26 /* Acquire whatever resources are needed for the operation. */
27 int (*setup)(struct xfs_scrub_context *,
28 struct xfs_inode *);
29
30 /* Examine metadata for errors. */
31 int (*scrub)(struct xfs_scrub_context *);
32
33 /* Decide if we even have this piece of metadata. */
34 bool (*has)(struct xfs_sb *);
35};
36
Darrick J. Wongb6c1beb2017-10-17 21:37:38 -070037/* Buffer pointers and btree cursors for an entire AG. */
38struct xfs_scrub_ag {
39 xfs_agnumber_t agno;
40
41 /* AG btree roots */
42 struct xfs_buf *agf_bp;
43 struct xfs_buf *agfl_bp;
44 struct xfs_buf *agi_bp;
45
46 /* AG btrees */
47 struct xfs_btree_cur *bno_cur;
48 struct xfs_btree_cur *cnt_cur;
49 struct xfs_btree_cur *ino_cur;
50 struct xfs_btree_cur *fino_cur;
51 struct xfs_btree_cur *rmap_cur;
52 struct xfs_btree_cur *refc_cur;
53};
54
Darrick J. Wonga5637182017-10-17 21:37:35 -070055struct xfs_scrub_context {
56 /* General scrub state. */
57 struct xfs_mount *mp;
58 struct xfs_scrub_metadata *sm;
59 const struct xfs_scrub_meta_ops *ops;
60 struct xfs_trans *tp;
61 struct xfs_inode *ip;
62 bool try_harder;
Darrick J. Wongb6c1beb2017-10-17 21:37:38 -070063
64 /* State tracking for single-AG operations. */
65 struct xfs_scrub_ag sa;
Darrick J. Wonga5637182017-10-17 21:37:35 -070066};
67
Darrick J. Wong36fd6e82017-10-17 21:37:34 -070068/* Metadata scrubbers */
Darrick J. Wongdcb660f2017-10-17 21:37:36 -070069int xfs_scrub_tester(struct xfs_scrub_context *sc);
Darrick J. Wong36fd6e82017-10-17 21:37:34 -070070
71#endif /* __XFS_SCRUB_SCRUB_H__ */