blob: ec635d4b0c5acc28d8d877c2f36ed20e5be40186 [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;
Darrick J. Wong80e4e122017-10-17 21:37:42 -070062 uint ilock_flags;
Darrick J. Wonga5637182017-10-17 21:37:35 -070063 bool try_harder;
Darrick J. Wongb6c1beb2017-10-17 21:37:38 -070064
65 /* State tracking for single-AG operations. */
66 struct xfs_scrub_ag sa;
Darrick J. Wonga5637182017-10-17 21:37:35 -070067};
68
Darrick J. Wong36fd6e82017-10-17 21:37:34 -070069/* Metadata scrubbers */
Darrick J. Wongdcb660f2017-10-17 21:37:36 -070070int xfs_scrub_tester(struct xfs_scrub_context *sc);
Darrick J. Wong21fb4cb2017-10-17 21:37:38 -070071int xfs_scrub_superblock(struct xfs_scrub_context *sc);
Darrick J. Wongab9d5dc2017-10-17 21:37:39 -070072int xfs_scrub_agf(struct xfs_scrub_context *sc);
73int xfs_scrub_agfl(struct xfs_scrub_context *sc);
Darrick J. Wonga12890a2017-10-17 21:37:39 -070074int xfs_scrub_agi(struct xfs_scrub_context *sc);
Darrick J. Wongefa7a992017-10-17 21:37:40 -070075int xfs_scrub_bnobt(struct xfs_scrub_context *sc);
76int xfs_scrub_cntbt(struct xfs_scrub_context *sc);
Darrick J. Wong3daa6642017-10-17 21:37:40 -070077int xfs_scrub_inobt(struct xfs_scrub_context *sc);
78int xfs_scrub_finobt(struct xfs_scrub_context *sc);
Darrick J. Wongc7e693d2017-10-17 21:37:41 -070079int xfs_scrub_rmapbt(struct xfs_scrub_context *sc);
Darrick J. Wongedc09b52017-10-17 21:37:41 -070080int xfs_scrub_refcountbt(struct xfs_scrub_context *sc);
Darrick J. Wong80e4e122017-10-17 21:37:42 -070081int xfs_scrub_inode(struct xfs_scrub_context *sc);
Darrick J. Wong36fd6e82017-10-17 21:37:34 -070082
83#endif /* __XFS_SCRUB_SCRUB_H__ */