Merge tag 'xtensa-20180225' of git://github.com/jcmvbkbc/linux-xtensa
[cris-mirror.git] / fs / xfs / scrub / common.h
blobddb65d22c76acdf4ad447164efa2ffc2c66c76c5
1 /*
2 * Copyright (C) 2017 Oracle. All Rights Reserved.
4 * Author: Darrick J. Wong <darrick.wong@oracle.com>
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.
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.
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.
20 #ifndef __XFS_SCRUB_COMMON_H__
21 #define __XFS_SCRUB_COMMON_H__
24 * We /could/ terminate a scrub/repair operation early. If we're not
25 * in a good place to continue (fatal signal, etc.) then bail out.
26 * Note that we're careful not to make any judgements about *error.
28 static inline bool
29 xfs_scrub_should_terminate(
30 struct xfs_scrub_context *sc,
31 int *error)
33 if (fatal_signal_pending(current)) {
34 if (*error == 0)
35 *error = -EAGAIN;
36 return true;
38 return false;
42 * Grab an empty transaction so that we can re-grab locked buffers if
43 * one of our btrees turns out to be cyclic.
45 static inline int
46 xfs_scrub_trans_alloc(
47 struct xfs_scrub_metadata *sm,
48 struct xfs_mount *mp,
49 struct xfs_trans **tpp)
51 return xfs_trans_alloc_empty(mp, tpp);
54 bool xfs_scrub_process_error(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
55 xfs_agblock_t bno, int *error);
56 bool xfs_scrub_fblock_process_error(struct xfs_scrub_context *sc, int whichfork,
57 xfs_fileoff_t offset, int *error);
59 bool xfs_scrub_xref_process_error(struct xfs_scrub_context *sc,
60 xfs_agnumber_t agno, xfs_agblock_t bno, int *error);
61 bool xfs_scrub_fblock_xref_process_error(struct xfs_scrub_context *sc,
62 int whichfork, xfs_fileoff_t offset, int *error);
64 void xfs_scrub_block_set_preen(struct xfs_scrub_context *sc,
65 struct xfs_buf *bp);
66 void xfs_scrub_ino_set_preen(struct xfs_scrub_context *sc, xfs_ino_t ino,
67 struct xfs_buf *bp);
69 void xfs_scrub_block_set_corrupt(struct xfs_scrub_context *sc,
70 struct xfs_buf *bp);
71 void xfs_scrub_ino_set_corrupt(struct xfs_scrub_context *sc, xfs_ino_t ino,
72 struct xfs_buf *bp);
73 void xfs_scrub_fblock_set_corrupt(struct xfs_scrub_context *sc, int whichfork,
74 xfs_fileoff_t offset);
76 void xfs_scrub_block_xref_set_corrupt(struct xfs_scrub_context *sc,
77 struct xfs_buf *bp);
78 void xfs_scrub_ino_xref_set_corrupt(struct xfs_scrub_context *sc, xfs_ino_t ino,
79 struct xfs_buf *bp);
80 void xfs_scrub_fblock_xref_set_corrupt(struct xfs_scrub_context *sc,
81 int whichfork, xfs_fileoff_t offset);
83 void xfs_scrub_ino_set_warning(struct xfs_scrub_context *sc, xfs_ino_t ino,
84 struct xfs_buf *bp);
85 void xfs_scrub_fblock_set_warning(struct xfs_scrub_context *sc, int whichfork,
86 xfs_fileoff_t offset);
88 void xfs_scrub_set_incomplete(struct xfs_scrub_context *sc);
89 int xfs_scrub_checkpoint_log(struct xfs_mount *mp);
91 /* Are we set up for a cross-referencing check? */
92 bool xfs_scrub_should_check_xref(struct xfs_scrub_context *sc, int *error,
93 struct xfs_btree_cur **curpp);
95 /* Setup functions */
96 int xfs_scrub_setup_fs(struct xfs_scrub_context *sc, struct xfs_inode *ip);
97 int xfs_scrub_setup_ag_allocbt(struct xfs_scrub_context *sc,
98 struct xfs_inode *ip);
99 int xfs_scrub_setup_ag_iallocbt(struct xfs_scrub_context *sc,
100 struct xfs_inode *ip);
101 int xfs_scrub_setup_ag_rmapbt(struct xfs_scrub_context *sc,
102 struct xfs_inode *ip);
103 int xfs_scrub_setup_ag_refcountbt(struct xfs_scrub_context *sc,
104 struct xfs_inode *ip);
105 int xfs_scrub_setup_inode(struct xfs_scrub_context *sc,
106 struct xfs_inode *ip);
107 int xfs_scrub_setup_inode_bmap(struct xfs_scrub_context *sc,
108 struct xfs_inode *ip);
109 int xfs_scrub_setup_inode_bmap_data(struct xfs_scrub_context *sc,
110 struct xfs_inode *ip);
111 int xfs_scrub_setup_directory(struct xfs_scrub_context *sc,
112 struct xfs_inode *ip);
113 int xfs_scrub_setup_xattr(struct xfs_scrub_context *sc,
114 struct xfs_inode *ip);
115 int xfs_scrub_setup_symlink(struct xfs_scrub_context *sc,
116 struct xfs_inode *ip);
117 int xfs_scrub_setup_parent(struct xfs_scrub_context *sc,
118 struct xfs_inode *ip);
119 #ifdef CONFIG_XFS_RT
120 int xfs_scrub_setup_rt(struct xfs_scrub_context *sc, struct xfs_inode *ip);
121 #else
122 static inline int
123 xfs_scrub_setup_rt(struct xfs_scrub_context *sc, struct xfs_inode *ip)
125 return -ENOENT;
127 #endif
128 #ifdef CONFIG_XFS_QUOTA
129 int xfs_scrub_setup_quota(struct xfs_scrub_context *sc, struct xfs_inode *ip);
130 #else
131 static inline int
132 xfs_scrub_setup_quota(struct xfs_scrub_context *sc, struct xfs_inode *ip)
134 return -ENOENT;
136 #endif
138 void xfs_scrub_ag_free(struct xfs_scrub_context *sc, struct xfs_scrub_ag *sa);
139 int xfs_scrub_ag_init(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
140 struct xfs_scrub_ag *sa);
141 int xfs_scrub_ag_read_headers(struct xfs_scrub_context *sc, xfs_agnumber_t agno,
142 struct xfs_buf **agi, struct xfs_buf **agf,
143 struct xfs_buf **agfl);
144 void xfs_scrub_ag_btcur_free(struct xfs_scrub_ag *sa);
145 int xfs_scrub_ag_btcur_init(struct xfs_scrub_context *sc,
146 struct xfs_scrub_ag *sa);
147 int xfs_scrub_walk_agfl(struct xfs_scrub_context *sc,
148 int (*fn)(struct xfs_scrub_context *, xfs_agblock_t bno,
149 void *),
150 void *priv);
151 int xfs_scrub_count_rmap_ownedby_ag(struct xfs_scrub_context *sc,
152 struct xfs_btree_cur *cur,
153 struct xfs_owner_info *oinfo,
154 xfs_filblks_t *blocks);
156 int xfs_scrub_setup_ag_btree(struct xfs_scrub_context *sc,
157 struct xfs_inode *ip, bool force_log);
158 int xfs_scrub_get_inode(struct xfs_scrub_context *sc, struct xfs_inode *ip_in);
159 int xfs_scrub_setup_inode_contents(struct xfs_scrub_context *sc,
160 struct xfs_inode *ip, unsigned int resblks);
161 void xfs_scrub_buffer_recheck(struct xfs_scrub_context *sc, struct xfs_buf *bp);
163 #endif /* __XFS_SCRUB_COMMON_H__ */