0001
0002
0003
0004
0005
0006 #ifndef __XFS_SCRUB_SCRUB_H__
0007 #define __XFS_SCRUB_SCRUB_H__
0008
0009 struct xfs_scrub;
0010
0011
0012 enum xchk_type {
0013 ST_NONE = 1,
0014 ST_PERAG,
0015 ST_FS,
0016 ST_INODE,
0017 };
0018
0019 struct xchk_meta_ops {
0020
0021 int (*setup)(struct xfs_scrub *sc);
0022
0023
0024 int (*scrub)(struct xfs_scrub *);
0025
0026
0027 int (*repair)(struct xfs_scrub *);
0028
0029
0030 bool (*has)(struct xfs_mount *);
0031
0032
0033 enum xchk_type type;
0034 };
0035
0036
0037 struct xchk_ag {
0038 struct xfs_perag *pag;
0039
0040
0041 struct xfs_buf *agf_bp;
0042 struct xfs_buf *agfl_bp;
0043 struct xfs_buf *agi_bp;
0044
0045
0046 struct xfs_btree_cur *bno_cur;
0047 struct xfs_btree_cur *cnt_cur;
0048 struct xfs_btree_cur *ino_cur;
0049 struct xfs_btree_cur *fino_cur;
0050 struct xfs_btree_cur *rmap_cur;
0051 struct xfs_btree_cur *refc_cur;
0052 };
0053
0054 struct xfs_scrub {
0055
0056 struct xfs_mount *mp;
0057 struct xfs_scrub_metadata *sm;
0058 const struct xchk_meta_ops *ops;
0059 struct xfs_trans *tp;
0060
0061
0062 struct file *file;
0063
0064
0065
0066
0067
0068
0069
0070 struct xfs_inode *ip;
0071
0072 void *buf;
0073 uint ilock_flags;
0074
0075
0076 unsigned int flags;
0077
0078
0079
0080
0081
0082
0083 unsigned int sick_mask;
0084
0085
0086 struct xchk_ag sa;
0087 };
0088
0089
0090 #define XCHK_TRY_HARDER (1 << 0)
0091 #define XCHK_REAPING_DISABLED (1 << 2)
0092 #define XREP_ALREADY_FIXED (1 << 31)
0093
0094
0095 int xchk_tester(struct xfs_scrub *sc);
0096 int xchk_superblock(struct xfs_scrub *sc);
0097 int xchk_agf(struct xfs_scrub *sc);
0098 int xchk_agfl(struct xfs_scrub *sc);
0099 int xchk_agi(struct xfs_scrub *sc);
0100 int xchk_bnobt(struct xfs_scrub *sc);
0101 int xchk_cntbt(struct xfs_scrub *sc);
0102 int xchk_inobt(struct xfs_scrub *sc);
0103 int xchk_finobt(struct xfs_scrub *sc);
0104 int xchk_rmapbt(struct xfs_scrub *sc);
0105 int xchk_refcountbt(struct xfs_scrub *sc);
0106 int xchk_inode(struct xfs_scrub *sc);
0107 int xchk_bmap_data(struct xfs_scrub *sc);
0108 int xchk_bmap_attr(struct xfs_scrub *sc);
0109 int xchk_bmap_cow(struct xfs_scrub *sc);
0110 int xchk_directory(struct xfs_scrub *sc);
0111 int xchk_xattr(struct xfs_scrub *sc);
0112 int xchk_symlink(struct xfs_scrub *sc);
0113 int xchk_parent(struct xfs_scrub *sc);
0114 #ifdef CONFIG_XFS_RT
0115 int xchk_rtbitmap(struct xfs_scrub *sc);
0116 int xchk_rtsummary(struct xfs_scrub *sc);
0117 #else
0118 static inline int
0119 xchk_rtbitmap(struct xfs_scrub *sc)
0120 {
0121 return -ENOENT;
0122 }
0123 static inline int
0124 xchk_rtsummary(struct xfs_scrub *sc)
0125 {
0126 return -ENOENT;
0127 }
0128 #endif
0129 #ifdef CONFIG_XFS_QUOTA
0130 int xchk_quota(struct xfs_scrub *sc);
0131 #else
0132 static inline int
0133 xchk_quota(struct xfs_scrub *sc)
0134 {
0135 return -ENOENT;
0136 }
0137 #endif
0138 int xchk_fscounters(struct xfs_scrub *sc);
0139
0140
0141 void xchk_xref_is_used_space(struct xfs_scrub *sc, xfs_agblock_t agbno,
0142 xfs_extlen_t len);
0143 void xchk_xref_is_not_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
0144 xfs_extlen_t len);
0145 void xchk_xref_is_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
0146 xfs_extlen_t len);
0147 void xchk_xref_is_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
0148 xfs_extlen_t len, const struct xfs_owner_info *oinfo);
0149 void xchk_xref_is_not_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
0150 xfs_extlen_t len, const struct xfs_owner_info *oinfo);
0151 void xchk_xref_has_no_owner(struct xfs_scrub *sc, xfs_agblock_t agbno,
0152 xfs_extlen_t len);
0153 void xchk_xref_is_cow_staging(struct xfs_scrub *sc, xfs_agblock_t bno,
0154 xfs_extlen_t len);
0155 void xchk_xref_is_not_shared(struct xfs_scrub *sc, xfs_agblock_t bno,
0156 xfs_extlen_t len);
0157 #ifdef CONFIG_XFS_RT
0158 void xchk_xref_is_used_rt_space(struct xfs_scrub *sc, xfs_rtblock_t rtbno,
0159 xfs_extlen_t len);
0160 #else
0161 # define xchk_xref_is_used_rt_space(sc, rtbno, len) do { } while (0)
0162 #endif
0163
0164 struct xchk_fscounters {
0165 uint64_t icount;
0166 uint64_t ifree;
0167 uint64_t fdblocks;
0168 unsigned long long icount_min;
0169 unsigned long long icount_max;
0170 };
0171
0172 #endif