Darrick J. Wong | 36fd6e8 | 2017-10-17 21:37:34 -0700 | [diff] [blame] | 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 | |
Darrick J. Wong | a563718 | 2017-10-17 21:37:35 -0700 | [diff] [blame] | 23 | struct xfs_scrub_context; |
| 24 | |
| 25 | struct 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. Wong | b6c1beb | 2017-10-17 21:37:38 -0700 | [diff] [blame] | 37 | /* Buffer pointers and btree cursors for an entire AG. */ |
| 38 | struct 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. Wong | a563718 | 2017-10-17 21:37:35 -0700 | [diff] [blame] | 55 | struct 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. Wong | 80e4e12 | 2017-10-17 21:37:42 -0700 | [diff] [blame^] | 62 | uint ilock_flags; |
Darrick J. Wong | a563718 | 2017-10-17 21:37:35 -0700 | [diff] [blame] | 63 | bool try_harder; |
Darrick J. Wong | b6c1beb | 2017-10-17 21:37:38 -0700 | [diff] [blame] | 64 | |
| 65 | /* State tracking for single-AG operations. */ |
| 66 | struct xfs_scrub_ag sa; |
Darrick J. Wong | a563718 | 2017-10-17 21:37:35 -0700 | [diff] [blame] | 67 | }; |
| 68 | |
Darrick J. Wong | 36fd6e8 | 2017-10-17 21:37:34 -0700 | [diff] [blame] | 69 | /* Metadata scrubbers */ |
Darrick J. Wong | dcb660f | 2017-10-17 21:37:36 -0700 | [diff] [blame] | 70 | int xfs_scrub_tester(struct xfs_scrub_context *sc); |
Darrick J. Wong | 21fb4cb | 2017-10-17 21:37:38 -0700 | [diff] [blame] | 71 | int xfs_scrub_superblock(struct xfs_scrub_context *sc); |
Darrick J. Wong | ab9d5dc | 2017-10-17 21:37:39 -0700 | [diff] [blame] | 72 | int xfs_scrub_agf(struct xfs_scrub_context *sc); |
| 73 | int xfs_scrub_agfl(struct xfs_scrub_context *sc); |
Darrick J. Wong | a12890a | 2017-10-17 21:37:39 -0700 | [diff] [blame] | 74 | int xfs_scrub_agi(struct xfs_scrub_context *sc); |
Darrick J. Wong | efa7a99 | 2017-10-17 21:37:40 -0700 | [diff] [blame] | 75 | int xfs_scrub_bnobt(struct xfs_scrub_context *sc); |
| 76 | int xfs_scrub_cntbt(struct xfs_scrub_context *sc); |
Darrick J. Wong | 3daa664 | 2017-10-17 21:37:40 -0700 | [diff] [blame] | 77 | int xfs_scrub_inobt(struct xfs_scrub_context *sc); |
| 78 | int xfs_scrub_finobt(struct xfs_scrub_context *sc); |
Darrick J. Wong | c7e693d | 2017-10-17 21:37:41 -0700 | [diff] [blame] | 79 | int xfs_scrub_rmapbt(struct xfs_scrub_context *sc); |
Darrick J. Wong | edc09b5 | 2017-10-17 21:37:41 -0700 | [diff] [blame] | 80 | int xfs_scrub_refcountbt(struct xfs_scrub_context *sc); |
Darrick J. Wong | 80e4e12 | 2017-10-17 21:37:42 -0700 | [diff] [blame^] | 81 | int xfs_scrub_inode(struct xfs_scrub_context *sc); |
Darrick J. Wong | 36fd6e8 | 2017-10-17 21:37:34 -0700 | [diff] [blame] | 82 | |
| 83 | #endif /* __XFS_SCRUB_SCRUB_H__ */ |