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 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 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 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; 62 void *buf; 63 uint ilock_flags; 64 bool try_harder; 65 66 /* State tracking for single-AG operations. */ 67 struct xfs_scrub_ag sa; 68 }; 69 70 /* Metadata scrubbers */ 71 int xfs_scrub_tester(struct xfs_scrub_context *sc); 72 int xfs_scrub_superblock(struct xfs_scrub_context *sc); 73 int xfs_scrub_agf(struct xfs_scrub_context *sc); 74 int xfs_scrub_agfl(struct xfs_scrub_context *sc); 75 int xfs_scrub_agi(struct xfs_scrub_context *sc); 76 int xfs_scrub_bnobt(struct xfs_scrub_context *sc); 77 int xfs_scrub_cntbt(struct xfs_scrub_context *sc); 78 int xfs_scrub_inobt(struct xfs_scrub_context *sc); 79 int xfs_scrub_finobt(struct xfs_scrub_context *sc); 80 int xfs_scrub_rmapbt(struct xfs_scrub_context *sc); 81 int xfs_scrub_refcountbt(struct xfs_scrub_context *sc); 82 int xfs_scrub_inode(struct xfs_scrub_context *sc); 83 int xfs_scrub_bmap_data(struct xfs_scrub_context *sc); 84 int xfs_scrub_bmap_attr(struct xfs_scrub_context *sc); 85 int xfs_scrub_bmap_cow(struct xfs_scrub_context *sc); 86 int xfs_scrub_directory(struct xfs_scrub_context *sc); 87 int xfs_scrub_xattr(struct xfs_scrub_context *sc); 88 int xfs_scrub_symlink(struct xfs_scrub_context *sc); 89 int xfs_scrub_parent(struct xfs_scrub_context *sc); 90 #ifdef CONFIG_XFS_RT 91 int xfs_scrub_rtbitmap(struct xfs_scrub_context *sc); 92 int xfs_scrub_rtsummary(struct xfs_scrub_context *sc); 93 #else 94 static inline int 95 xfs_scrub_rtbitmap(struct xfs_scrub_context *sc) 96 { 97 return -ENOENT; 98 } 99 static inline int 100 xfs_scrub_rtsummary(struct xfs_scrub_context *sc) 101 { 102 return -ENOENT; 103 } 104 #endif 105 #ifdef CONFIG_XFS_QUOTA 106 int xfs_scrub_quota(struct xfs_scrub_context *sc); 107 #else 108 static inline int 109 xfs_scrub_quota(struct xfs_scrub_context *sc) 110 { 111 return -ENOENT; 112 } 113 #endif 114 115 #endif /* __XFS_SCRUB_SCRUB_H__ */ 116