1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2017 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
6 #ifndef __XFS_SCRUB_COMMON_H__
7 #define __XFS_SCRUB_COMMON_H__
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.
15 xchk_should_terminate(
20 * If preemption is disabled, we need to yield to the scheduler every
21 * few seconds so that we don't run afoul of the soft lockup watchdog
22 * or RCU stall detector.
26 if (fatal_signal_pending(current
)) {
34 int xchk_trans_alloc(struct xfs_scrub
*sc
, uint resblks
);
35 bool xchk_process_error(struct xfs_scrub
*sc
, xfs_agnumber_t agno
,
36 xfs_agblock_t bno
, int *error
);
37 bool xchk_fblock_process_error(struct xfs_scrub
*sc
, int whichfork
,
38 xfs_fileoff_t offset
, int *error
);
40 bool xchk_xref_process_error(struct xfs_scrub
*sc
,
41 xfs_agnumber_t agno
, xfs_agblock_t bno
, int *error
);
42 bool xchk_fblock_xref_process_error(struct xfs_scrub
*sc
,
43 int whichfork
, xfs_fileoff_t offset
, int *error
);
45 void xchk_block_set_preen(struct xfs_scrub
*sc
,
47 void xchk_ino_set_preen(struct xfs_scrub
*sc
, xfs_ino_t ino
);
49 void xchk_set_corrupt(struct xfs_scrub
*sc
);
50 void xchk_block_set_corrupt(struct xfs_scrub
*sc
,
52 void xchk_ino_set_corrupt(struct xfs_scrub
*sc
, xfs_ino_t ino
);
53 void xchk_fblock_set_corrupt(struct xfs_scrub
*sc
, int whichfork
,
54 xfs_fileoff_t offset
);
56 void xchk_block_xref_set_corrupt(struct xfs_scrub
*sc
,
58 void xchk_ino_xref_set_corrupt(struct xfs_scrub
*sc
,
60 void xchk_fblock_xref_set_corrupt(struct xfs_scrub
*sc
,
61 int whichfork
, xfs_fileoff_t offset
);
63 void xchk_ino_set_warning(struct xfs_scrub
*sc
, xfs_ino_t ino
);
64 void xchk_fblock_set_warning(struct xfs_scrub
*sc
, int whichfork
,
65 xfs_fileoff_t offset
);
67 void xchk_set_incomplete(struct xfs_scrub
*sc
);
68 int xchk_checkpoint_log(struct xfs_mount
*mp
);
70 /* Are we set up for a cross-referencing check? */
71 bool xchk_should_check_xref(struct xfs_scrub
*sc
, int *error
,
72 struct xfs_btree_cur
**curpp
);
75 int xchk_setup_fs(struct xfs_scrub
*sc
, struct xfs_inode
*ip
);
76 int xchk_setup_ag_allocbt(struct xfs_scrub
*sc
,
77 struct xfs_inode
*ip
);
78 int xchk_setup_ag_iallocbt(struct xfs_scrub
*sc
,
79 struct xfs_inode
*ip
);
80 int xchk_setup_ag_rmapbt(struct xfs_scrub
*sc
,
81 struct xfs_inode
*ip
);
82 int xchk_setup_ag_refcountbt(struct xfs_scrub
*sc
,
83 struct xfs_inode
*ip
);
84 int xchk_setup_inode(struct xfs_scrub
*sc
,
85 struct xfs_inode
*ip
);
86 int xchk_setup_inode_bmap(struct xfs_scrub
*sc
,
87 struct xfs_inode
*ip
);
88 int xchk_setup_inode_bmap_data(struct xfs_scrub
*sc
,
89 struct xfs_inode
*ip
);
90 int xchk_setup_directory(struct xfs_scrub
*sc
,
91 struct xfs_inode
*ip
);
92 int xchk_setup_xattr(struct xfs_scrub
*sc
,
93 struct xfs_inode
*ip
);
94 int xchk_setup_symlink(struct xfs_scrub
*sc
,
95 struct xfs_inode
*ip
);
96 int xchk_setup_parent(struct xfs_scrub
*sc
,
97 struct xfs_inode
*ip
);
99 int xchk_setup_rt(struct xfs_scrub
*sc
, struct xfs_inode
*ip
);
102 xchk_setup_rt(struct xfs_scrub
*sc
, struct xfs_inode
*ip
)
107 #ifdef CONFIG_XFS_QUOTA
108 int xchk_setup_quota(struct xfs_scrub
*sc
, struct xfs_inode
*ip
);
111 xchk_setup_quota(struct xfs_scrub
*sc
, struct xfs_inode
*ip
)
116 int xchk_setup_fscounters(struct xfs_scrub
*sc
, struct xfs_inode
*ip
);
118 void xchk_ag_free(struct xfs_scrub
*sc
, struct xchk_ag
*sa
);
119 int xchk_ag_init(struct xfs_scrub
*sc
, xfs_agnumber_t agno
,
121 void xchk_perag_get(struct xfs_mount
*mp
, struct xchk_ag
*sa
);
122 int xchk_ag_read_headers(struct xfs_scrub
*sc
, xfs_agnumber_t agno
,
123 struct xfs_buf
**agi
, struct xfs_buf
**agf
,
124 struct xfs_buf
**agfl
);
125 void xchk_ag_btcur_free(struct xchk_ag
*sa
);
126 int xchk_ag_btcur_init(struct xfs_scrub
*sc
, struct xchk_ag
*sa
);
127 int xchk_count_rmap_ownedby_ag(struct xfs_scrub
*sc
, struct xfs_btree_cur
*cur
,
128 const struct xfs_owner_info
*oinfo
, xfs_filblks_t
*blocks
);
130 int xchk_setup_ag_btree(struct xfs_scrub
*sc
, struct xfs_inode
*ip
,
132 int xchk_get_inode(struct xfs_scrub
*sc
, struct xfs_inode
*ip_in
);
133 int xchk_setup_inode_contents(struct xfs_scrub
*sc
, struct xfs_inode
*ip
,
134 unsigned int resblks
);
135 void xchk_buffer_recheck(struct xfs_scrub
*sc
, struct xfs_buf
*bp
);
138 * Don't bother cross-referencing if we already found corruption or cross
139 * referencing discrepancies.
141 static inline bool xchk_skip_xref(struct xfs_scrub_metadata
*sm
)
143 return sm
->sm_flags
& (XFS_SCRUB_OFLAG_CORRUPT
|
144 XFS_SCRUB_OFLAG_XCORRUPT
);
147 int xchk_metadata_inode_forks(struct xfs_scrub
*sc
);
148 int xchk_ilock_inverted(struct xfs_inode
*ip
, uint lock_mode
);
149 void xchk_stop_reaping(struct xfs_scrub
*sc
);
150 void xchk_start_reaping(struct xfs_scrub
*sc
);
152 #endif /* __XFS_SCRUB_COMMON_H__ */