Merge tag 'v5.0-rockchip-dts32fixes-1' of git://git.kernel.org/pub/scm/linux/kernel...
[linux-2.6-block.git] / fs / xfs / scrub / scrub.h
CommitLineData
0b61f8a4 1// SPDX-License-Identifier: GPL-2.0+
36fd6e86
DW
2/*
3 * Copyright (C) 2017 Oracle. All Rights Reserved.
36fd6e86 4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
36fd6e86
DW
5 */
6#ifndef __XFS_SCRUB_SCRUB_H__
7#define __XFS_SCRUB_SCRUB_H__
8
1d8a748a 9struct xfs_scrub;
a5637186 10
8e630837 11/* Type info and names for the scrub types. */
c517b3aa 12enum xchk_type {
8e630837
ES
13 ST_NONE = 1, /* disabled */
14 ST_PERAG, /* per-AG metadata */
15 ST_FS, /* per-FS metadata */
16 ST_INODE, /* per-inode metadata */
17};
18
c517b3aa 19struct xchk_meta_ops {
a5637186 20 /* Acquire whatever resources are needed for the operation. */
1d8a748a 21 int (*setup)(struct xfs_scrub *,
a5637186
DW
22 struct xfs_inode *);
23
24 /* Examine metadata for errors. */
1d8a748a 25 int (*scrub)(struct xfs_scrub *);
a5637186 26
84d42ea6 27 /* Repair or optimize the metadata. */
1d8a748a 28 int (*repair)(struct xfs_scrub *);
84d42ea6 29
a5637186
DW
30 /* Decide if we even have this piece of metadata. */
31 bool (*has)(struct xfs_sb *);
8e630837
ES
32
33 /* type describing required/allowed inputs */
c517b3aa 34 enum xchk_type type;
a5637186
DW
35};
36
b6c1beb9 37/* Buffer pointers and btree cursors for an entire AG. */
c517b3aa 38struct xchk_ag {
032d91f9
DW
39 xfs_agnumber_t agno;
40 struct xfs_perag *pag;
b6c1beb9
DW
41
42 /* AG btree roots */
032d91f9
DW
43 struct xfs_buf *agf_bp;
44 struct xfs_buf *agfl_bp;
45 struct xfs_buf *agi_bp;
b6c1beb9
DW
46
47 /* AG btrees */
032d91f9
DW
48 struct xfs_btree_cur *bno_cur;
49 struct xfs_btree_cur *cnt_cur;
50 struct xfs_btree_cur *ino_cur;
51 struct xfs_btree_cur *fino_cur;
52 struct xfs_btree_cur *rmap_cur;
53 struct xfs_btree_cur *refc_cur;
b6c1beb9
DW
54};
55
1d8a748a 56struct xfs_scrub {
a5637186
DW
57 /* General scrub state. */
58 struct xfs_mount *mp;
59 struct xfs_scrub_metadata *sm;
c517b3aa 60 const struct xchk_meta_ops *ops;
a5637186
DW
61 struct xfs_trans *tp;
62 struct xfs_inode *ip;
eec0482e 63 void *buf;
80e4e126 64 uint ilock_flags;
a5637186 65 bool try_harder;
eb41c93f 66 bool has_quotaofflock;
b6c1beb9
DW
67
68 /* State tracking for single-AG operations. */
032d91f9 69 struct xchk_ag sa;
a5637186
DW
70};
71
36fd6e86 72/* Metadata scrubbers */
1d8a748a
DW
73int xchk_tester(struct xfs_scrub *sc);
74int xchk_superblock(struct xfs_scrub *sc);
75int xchk_agf(struct xfs_scrub *sc);
76int xchk_agfl(struct xfs_scrub *sc);
77int xchk_agi(struct xfs_scrub *sc);
78int xchk_bnobt(struct xfs_scrub *sc);
79int xchk_cntbt(struct xfs_scrub *sc);
80int xchk_inobt(struct xfs_scrub *sc);
81int xchk_finobt(struct xfs_scrub *sc);
82int xchk_rmapbt(struct xfs_scrub *sc);
83int xchk_refcountbt(struct xfs_scrub *sc);
84int xchk_inode(struct xfs_scrub *sc);
85int xchk_bmap_data(struct xfs_scrub *sc);
86int xchk_bmap_attr(struct xfs_scrub *sc);
87int xchk_bmap_cow(struct xfs_scrub *sc);
88int xchk_directory(struct xfs_scrub *sc);
89int xchk_xattr(struct xfs_scrub *sc);
90int xchk_symlink(struct xfs_scrub *sc);
91int xchk_parent(struct xfs_scrub *sc);
29b0767b 92#ifdef CONFIG_XFS_RT
1d8a748a
DW
93int xchk_rtbitmap(struct xfs_scrub *sc);
94int xchk_rtsummary(struct xfs_scrub *sc);
29b0767b
DW
95#else
96static inline int
1d8a748a 97xchk_rtbitmap(struct xfs_scrub *sc)
29b0767b
DW
98{
99 return -ENOENT;
100}
101static inline int
1d8a748a 102xchk_rtsummary(struct xfs_scrub *sc)
29b0767b
DW
103{
104 return -ENOENT;
105}
106#endif
c2fc338c 107#ifdef CONFIG_XFS_QUOTA
1d8a748a 108int xchk_quota(struct xfs_scrub *sc);
c2fc338c
DW
109#else
110static inline int
1d8a748a 111xchk_quota(struct xfs_scrub *sc)
c2fc338c
DW
112{
113 return -ENOENT;
114}
115#endif
36fd6e86 116
52dc4b44 117/* cross-referencing helpers */
032d91f9
DW
118void xchk_xref_is_used_space(struct xfs_scrub *sc, xfs_agblock_t agbno,
119 xfs_extlen_t len);
120void xchk_xref_is_not_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
121 xfs_extlen_t len);
122void xchk_xref_is_inode_chunk(struct xfs_scrub *sc, xfs_agblock_t agbno,
123 xfs_extlen_t len);
124void xchk_xref_is_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
66e3237e 125 xfs_extlen_t len, const struct xfs_owner_info *oinfo);
032d91f9 126void xchk_xref_is_not_owned_by(struct xfs_scrub *sc, xfs_agblock_t agbno,
66e3237e 127 xfs_extlen_t len, const struct xfs_owner_info *oinfo);
032d91f9
DW
128void xchk_xref_has_no_owner(struct xfs_scrub *sc, xfs_agblock_t agbno,
129 xfs_extlen_t len);
130void xchk_xref_is_cow_staging(struct xfs_scrub *sc, xfs_agblock_t bno,
131 xfs_extlen_t len);
132void xchk_xref_is_not_shared(struct xfs_scrub *sc, xfs_agblock_t bno,
133 xfs_extlen_t len);
46d9bfb5 134#ifdef CONFIG_XFS_RT
032d91f9
DW
135void xchk_xref_is_used_rt_space(struct xfs_scrub *sc, xfs_rtblock_t rtbno,
136 xfs_extlen_t len);
46d9bfb5 137#else
c517b3aa 138# define xchk_xref_is_used_rt_space(sc, rtbno, len) do { } while (0)
46d9bfb5 139#endif
52dc4b44 140
36fd6e86 141#endif /* __XFS_SCRUB_SCRUB_H__ */