]>
Commit | Line | Data |
---|---|---|
0b61f8a4 | 1 | // SPDX-License-Identifier: GPL-2.0+ |
dcb660f9 DW |
2 | /* |
3 | * Copyright (C) 2017 Oracle. All Rights Reserved. | |
dcb660f9 | 4 | * Author: Darrick J. Wong <[email protected]> |
dcb660f9 DW |
5 | */ |
6 | #ifndef __XFS_SCRUB_COMMON_H__ | |
7 | #define __XFS_SCRUB_COMMON_H__ | |
8 | ||
9 | /* | |
10 | * We /could/ terminate a scrub/repair operation early. If we're not | |
11 | * in a good place to continue (fatal signal, etc.) then bail out. | |
12 | * Note that we're careful not to make any judgements about *error. | |
13 | */ | |
14 | static inline bool | |
c517b3aa | 15 | xchk_should_terminate( |
1d8a748a | 16 | struct xfs_scrub *sc, |
dcb660f9 DW |
17 | int *error) |
18 | { | |
19 | if (fatal_signal_pending(current)) { | |
20 | if (*error == 0) | |
21 | *error = -EAGAIN; | |
22 | return true; | |
23 | } | |
24 | return false; | |
25 | } | |
26 | ||
1d8a748a DW |
27 | int xchk_trans_alloc(struct xfs_scrub *sc, uint resblks); |
28 | bool xchk_process_error(struct xfs_scrub *sc, xfs_agnumber_t agno, | |
4700d229 | 29 | xfs_agblock_t bno, int *error); |
1d8a748a | 30 | bool xchk_fblock_process_error(struct xfs_scrub *sc, int whichfork, |
4700d229 DW |
31 | xfs_fileoff_t offset, int *error); |
32 | ||
1d8a748a | 33 | bool xchk_xref_process_error(struct xfs_scrub *sc, |
64b12563 | 34 | xfs_agnumber_t agno, xfs_agblock_t bno, int *error); |
1d8a748a | 35 | bool xchk_fblock_xref_process_error(struct xfs_scrub *sc, |
64b12563 DW |
36 | int whichfork, xfs_fileoff_t offset, int *error); |
37 | ||
1d8a748a | 38 | void xchk_block_set_preen(struct xfs_scrub *sc, |
4700d229 | 39 | struct xfs_buf *bp); |
1d8a748a | 40 | void xchk_ino_set_preen(struct xfs_scrub *sc, xfs_ino_t ino); |
4700d229 | 41 | |
1d8a748a | 42 | void xchk_block_set_corrupt(struct xfs_scrub *sc, |
4700d229 | 43 | struct xfs_buf *bp); |
1d8a748a DW |
44 | void xchk_ino_set_corrupt(struct xfs_scrub *sc, xfs_ino_t ino); |
45 | void xchk_fblock_set_corrupt(struct xfs_scrub *sc, int whichfork, | |
4700d229 DW |
46 | xfs_fileoff_t offset); |
47 | ||
1d8a748a | 48 | void xchk_block_xref_set_corrupt(struct xfs_scrub *sc, |
64b12563 | 49 | struct xfs_buf *bp); |
1d8a748a | 50 | void xchk_ino_xref_set_corrupt(struct xfs_scrub *sc, |
7e56d9ea | 51 | xfs_ino_t ino); |
1d8a748a | 52 | void xchk_fblock_xref_set_corrupt(struct xfs_scrub *sc, |
64b12563 DW |
53 | int whichfork, xfs_fileoff_t offset); |
54 | ||
1d8a748a DW |
55 | void xchk_ino_set_warning(struct xfs_scrub *sc, xfs_ino_t ino); |
56 | void xchk_fblock_set_warning(struct xfs_scrub *sc, int whichfork, | |
4700d229 DW |
57 | xfs_fileoff_t offset); |
58 | ||
1d8a748a | 59 | void xchk_set_incomplete(struct xfs_scrub *sc); |
c517b3aa | 60 | int xchk_checkpoint_log(struct xfs_mount *mp); |
4700d229 | 61 | |
64b12563 | 62 | /* Are we set up for a cross-referencing check? */ |
1d8a748a | 63 | bool xchk_should_check_xref(struct xfs_scrub *sc, int *error, |
64b12563 DW |
64 | struct xfs_btree_cur **curpp); |
65 | ||
dcb660f9 | 66 | /* Setup functions */ |
1d8a748a DW |
67 | int xchk_setup_fs(struct xfs_scrub *sc, struct xfs_inode *ip); |
68 | int xchk_setup_ag_allocbt(struct xfs_scrub *sc, | |
efa7a99c | 69 | struct xfs_inode *ip); |
1d8a748a | 70 | int xchk_setup_ag_iallocbt(struct xfs_scrub *sc, |
3daa6641 | 71 | struct xfs_inode *ip); |
1d8a748a | 72 | int xchk_setup_ag_rmapbt(struct xfs_scrub *sc, |
c7e693d9 | 73 | struct xfs_inode *ip); |
1d8a748a | 74 | int xchk_setup_ag_refcountbt(struct xfs_scrub *sc, |
edc09b52 | 75 | struct xfs_inode *ip); |
1d8a748a | 76 | int xchk_setup_inode(struct xfs_scrub *sc, |
80e4e126 | 77 | struct xfs_inode *ip); |
1d8a748a | 78 | int xchk_setup_inode_bmap(struct xfs_scrub *sc, |
99d9d8d0 | 79 | struct xfs_inode *ip); |
1d8a748a | 80 | int xchk_setup_inode_bmap_data(struct xfs_scrub *sc, |
99d9d8d0 | 81 | struct xfs_inode *ip); |
1d8a748a | 82 | int xchk_setup_directory(struct xfs_scrub *sc, |
a5c46e5e | 83 | struct xfs_inode *ip); |
1d8a748a | 84 | int xchk_setup_xattr(struct xfs_scrub *sc, |
eec0482e | 85 | struct xfs_inode *ip); |
1d8a748a | 86 | int xchk_setup_symlink(struct xfs_scrub *sc, |
2a721dbb | 87 | struct xfs_inode *ip); |
1d8a748a | 88 | int xchk_setup_parent(struct xfs_scrub *sc, |
0f28b257 | 89 | struct xfs_inode *ip); |
29b0767b | 90 | #ifdef CONFIG_XFS_RT |
1d8a748a | 91 | int xchk_setup_rt(struct xfs_scrub *sc, struct xfs_inode *ip); |
29b0767b DW |
92 | #else |
93 | static inline int | |
1d8a748a | 94 | xchk_setup_rt(struct xfs_scrub *sc, struct xfs_inode *ip) |
c2fc338c DW |
95 | { |
96 | return -ENOENT; | |
97 | } | |
98 | #endif | |
99 | #ifdef CONFIG_XFS_QUOTA | |
1d8a748a | 100 | int xchk_setup_quota(struct xfs_scrub *sc, struct xfs_inode *ip); |
c2fc338c DW |
101 | #else |
102 | static inline int | |
1d8a748a | 103 | xchk_setup_quota(struct xfs_scrub *sc, struct xfs_inode *ip) |
29b0767b DW |
104 | { |
105 | return -ENOENT; | |
106 | } | |
107 | #endif | |
dcb660f9 | 108 | |
1d8a748a DW |
109 | void xchk_ag_free(struct xfs_scrub *sc, struct xchk_ag *sa); |
110 | int xchk_ag_init(struct xfs_scrub *sc, xfs_agnumber_t agno, | |
032d91f9 | 111 | struct xchk_ag *sa); |
c517b3aa | 112 | void xchk_perag_get(struct xfs_mount *mp, struct xchk_ag *sa); |
1d8a748a | 113 | int xchk_ag_read_headers(struct xfs_scrub *sc, xfs_agnumber_t agno, |
032d91f9 DW |
114 | struct xfs_buf **agi, struct xfs_buf **agf, |
115 | struct xfs_buf **agfl); | |
c517b3aa | 116 | void xchk_ag_btcur_free(struct xchk_ag *sa); |
032d91f9 DW |
117 | int xchk_ag_btcur_init(struct xfs_scrub *sc, struct xchk_ag *sa); |
118 | int xchk_count_rmap_ownedby_ag(struct xfs_scrub *sc, struct xfs_btree_cur *cur, | |
66e3237e | 119 | const struct xfs_owner_info *oinfo, xfs_filblks_t *blocks); |
b6c1beb9 | 120 | |
032d91f9 DW |
121 | int xchk_setup_ag_btree(struct xfs_scrub *sc, struct xfs_inode *ip, |
122 | bool force_log); | |
1d8a748a | 123 | int xchk_get_inode(struct xfs_scrub *sc, struct xfs_inode *ip_in); |
032d91f9 DW |
124 | int xchk_setup_inode_contents(struct xfs_scrub *sc, struct xfs_inode *ip, |
125 | unsigned int resblks); | |
1d8a748a | 126 | void xchk_buffer_recheck(struct xfs_scrub *sc, struct xfs_buf *bp); |
efa7a99c | 127 | |
8389f3ff DW |
128 | /* |
129 | * Don't bother cross-referencing if we already found corruption or cross | |
130 | * referencing discrepancies. | |
131 | */ | |
c517b3aa | 132 | static inline bool xchk_skip_xref(struct xfs_scrub_metadata *sm) |
8389f3ff DW |
133 | { |
134 | return sm->sm_flags & (XFS_SCRUB_OFLAG_CORRUPT | | |
135 | XFS_SCRUB_OFLAG_XCORRUPT); | |
136 | } | |
137 | ||
1d8a748a | 138 | int xchk_metadata_inode_forks(struct xfs_scrub *sc); |
c517b3aa | 139 | int xchk_ilock_inverted(struct xfs_inode *ip, uint lock_mode); |
87d9d609 | 140 | |
dcb660f9 | 141 | #endif /* __XFS_SCRUB_COMMON_H__ */ |