Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | /* |
2 | * Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. | |
3 | * | |
4 | * This program is free software; you can redistribute it and/or modify it | |
5 | * under the terms of version 2 of the GNU General Public License as | |
6 | * published by the Free Software Foundation. | |
7 | * | |
8 | * This program is distributed in the hope that it would be useful, but | |
9 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
11 | * | |
12 | * Further, this software is distributed without any warranty that it is | |
13 | * free of the rightful claim of any third person regarding infringement | |
14 | * or the like. Any license provided herein, whether implied or | |
15 | * otherwise, applies only to this software file. Patent licenses, if | |
16 | * any, provided herein do not apply to combinations of this program with | |
17 | * other software, or any other product whatsoever. | |
18 | * | |
19 | * You should have received a copy of the GNU General Public License along | |
20 | * with this program; if not, write the Free Software Foundation, Inc., 59 | |
21 | * Temple Place - Suite 330, Boston MA 02111-1307, USA. | |
22 | * | |
23 | * Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy, | |
24 | * Mountain View, CA 94043, or: | |
25 | * | |
26 | * http://www.sgi.com | |
27 | * | |
28 | * For further information regarding this notice, see: | |
29 | * | |
30 | * http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/ | |
31 | */ | |
32 | #ifndef __XFS_ERROR_H__ | |
33 | #define __XFS_ERROR_H__ | |
34 | ||
35 | #define prdev(fmt,targ,args...) \ | |
36 | printk("XFS: device %s- " fmt "\n", XFS_BUFTARG_NAME(targ), ## args) | |
37 | ||
38 | #define XFS_ERECOVER 1 /* Failure to recover log */ | |
39 | #define XFS_ELOGSTAT 2 /* Failure to stat log in user space */ | |
40 | #define XFS_ENOLOGSPACE 3 /* Reservation too large */ | |
41 | #define XFS_ENOTSUP 4 /* Operation not supported */ | |
42 | #define XFS_ENOLSN 5 /* Can't find the lsn you asked for */ | |
43 | #define XFS_ENOTFOUND 6 | |
44 | #define XFS_ENOTXFS 7 /* Not XFS filesystem */ | |
45 | ||
46 | #ifdef DEBUG | |
47 | #define XFS_ERROR_NTRAP 10 | |
48 | extern int xfs_etrap[XFS_ERROR_NTRAP]; | |
49 | extern int xfs_error_trap(int); | |
50 | #define XFS_ERROR(e) xfs_error_trap(e) | |
51 | #else | |
52 | #define XFS_ERROR(e) (e) | |
53 | #endif | |
54 | ||
55 | struct xfs_mount; | |
56 | ||
57 | extern void | |
58 | xfs_error_report( | |
59 | char *tag, | |
60 | int level, | |
61 | struct xfs_mount *mp, | |
62 | char *fname, | |
63 | int linenum, | |
64 | inst_t *ra); | |
65 | ||
66 | extern void | |
67 | xfs_corruption_error( | |
68 | char *tag, | |
69 | int level, | |
70 | struct xfs_mount *mp, | |
71 | void *p, | |
72 | char *fname, | |
73 | int linenum, | |
74 | inst_t *ra); | |
75 | ||
76 | extern void | |
77 | xfs_hex_dump(void *p, int length); | |
78 | ||
79 | #define XFS_ERROR_REPORT(e, lvl, mp) \ | |
80 | xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) | |
81 | #define XFS_CORRUPTION_ERROR(e, lvl, mp, mem) \ | |
82 | xfs_corruption_error(e, lvl, mp, mem, \ | |
83 | __FILE__, __LINE__, __return_address) | |
84 | ||
85 | #define XFS_ERRLEVEL_OFF 0 | |
86 | #define XFS_ERRLEVEL_LOW 1 | |
87 | #define XFS_ERRLEVEL_HIGH 5 | |
88 | ||
89 | /* | |
90 | * error injection tags - the labels can be anything you want | |
91 | * but each tag should have its own unique number | |
92 | */ | |
93 | ||
94 | #define XFS_ERRTAG_NOERROR 0 | |
95 | #define XFS_ERRTAG_IFLUSH_1 1 | |
96 | #define XFS_ERRTAG_IFLUSH_2 2 | |
97 | #define XFS_ERRTAG_IFLUSH_3 3 | |
98 | #define XFS_ERRTAG_IFLUSH_4 4 | |
99 | #define XFS_ERRTAG_IFLUSH_5 5 | |
100 | #define XFS_ERRTAG_IFLUSH_6 6 | |
101 | #define XFS_ERRTAG_DA_READ_BUF 7 | |
102 | #define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8 | |
103 | #define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9 | |
104 | #define XFS_ERRTAG_ALLOC_READ_AGF 10 | |
105 | #define XFS_ERRTAG_IALLOC_READ_AGI 11 | |
106 | #define XFS_ERRTAG_ITOBP_INOTOBP 12 | |
107 | #define XFS_ERRTAG_IUNLINK 13 | |
108 | #define XFS_ERRTAG_IUNLINK_REMOVE 14 | |
109 | #define XFS_ERRTAG_DIR_INO_VALIDATE 15 | |
110 | #define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16 | |
111 | #define XFS_ERRTAG_IODONE_IOERR 17 | |
112 | #define XFS_ERRTAG_STRATREAD_IOERR 18 | |
113 | #define XFS_ERRTAG_STRATCMPL_IOERR 19 | |
114 | #define XFS_ERRTAG_DIOWRITE_IOERR 20 | |
115 | #define XFS_ERRTAG_BMAPIFORMAT 21 | |
116 | #define XFS_ERRTAG_MAX 22 | |
117 | ||
118 | /* | |
119 | * Random factors for above tags, 1 means always, 2 means 1/2 time, etc. | |
120 | */ | |
121 | #define XFS_RANDOM_DEFAULT 100 | |
122 | #define XFS_RANDOM_IFLUSH_1 XFS_RANDOM_DEFAULT | |
123 | #define XFS_RANDOM_IFLUSH_2 XFS_RANDOM_DEFAULT | |
124 | #define XFS_RANDOM_IFLUSH_3 XFS_RANDOM_DEFAULT | |
125 | #define XFS_RANDOM_IFLUSH_4 XFS_RANDOM_DEFAULT | |
126 | #define XFS_RANDOM_IFLUSH_5 XFS_RANDOM_DEFAULT | |
127 | #define XFS_RANDOM_IFLUSH_6 XFS_RANDOM_DEFAULT | |
128 | #define XFS_RANDOM_DA_READ_BUF XFS_RANDOM_DEFAULT | |
129 | #define XFS_RANDOM_BTREE_CHECK_LBLOCK (XFS_RANDOM_DEFAULT/4) | |
130 | #define XFS_RANDOM_BTREE_CHECK_SBLOCK XFS_RANDOM_DEFAULT | |
131 | #define XFS_RANDOM_ALLOC_READ_AGF XFS_RANDOM_DEFAULT | |
132 | #define XFS_RANDOM_IALLOC_READ_AGI XFS_RANDOM_DEFAULT | |
133 | #define XFS_RANDOM_ITOBP_INOTOBP XFS_RANDOM_DEFAULT | |
134 | #define XFS_RANDOM_IUNLINK XFS_RANDOM_DEFAULT | |
135 | #define XFS_RANDOM_IUNLINK_REMOVE XFS_RANDOM_DEFAULT | |
136 | #define XFS_RANDOM_DIR_INO_VALIDATE XFS_RANDOM_DEFAULT | |
137 | #define XFS_RANDOM_BULKSTAT_READ_CHUNK XFS_RANDOM_DEFAULT | |
138 | #define XFS_RANDOM_IODONE_IOERR (XFS_RANDOM_DEFAULT/10) | |
139 | #define XFS_RANDOM_STRATREAD_IOERR (XFS_RANDOM_DEFAULT/10) | |
140 | #define XFS_RANDOM_STRATCMPL_IOERR (XFS_RANDOM_DEFAULT/10) | |
141 | #define XFS_RANDOM_DIOWRITE_IOERR (XFS_RANDOM_DEFAULT/10) | |
142 | #define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT | |
143 | ||
144 | #if (defined(DEBUG) || defined(INDUCE_IO_ERROR)) | |
145 | extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); | |
146 | void xfs_error_test_init(void); | |
147 | ||
148 | #define XFS_NUM_INJECT_ERROR 10 | |
149 | ||
150 | #ifdef __ANSI_CPP__ | |
151 | #define XFS_TEST_ERROR(expr, mp, tag, rf) \ | |
152 | ((expr) || \ | |
153 | xfs_error_test((tag), (mp)->m_fixedfsid, #expr, __LINE__, __FILE__, \ | |
154 | (rf))) | |
155 | #else | |
156 | #define XFS_TEST_ERROR(expr, mp, tag, rf) \ | |
157 | ((expr) || \ | |
158 | xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \ | |
159 | (rf))) | |
160 | #endif /* __ANSI_CPP__ */ | |
161 | ||
162 | int xfs_errortag_add(int error_tag, xfs_mount_t *mp); | |
163 | int xfs_errortag_clear(int error_tag, xfs_mount_t *mp); | |
164 | ||
165 | int xfs_errortag_clearall(xfs_mount_t *mp); | |
166 | int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, | |
167 | int loud); | |
168 | #else | |
169 | #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) | |
170 | #define xfs_errortag_add(tag, mp) (ENOSYS) | |
171 | #define xfs_errortag_clearall(mp) (ENOSYS) | |
172 | #endif /* (DEBUG || INDUCE_IO_ERROR) */ | |
173 | ||
174 | /* | |
175 | * XFS panic tags -- allow a call to xfs_cmn_err() be turned into | |
176 | * a panic by setting xfs_panic_mask in a | |
177 | * sysctl. update xfs_max[XFS_PARAM] if | |
178 | * more are added. | |
179 | */ | |
180 | #define XFS_NO_PTAG 0 | |
181 | #define XFS_PTAG_IFLUSH 0x00000001 | |
182 | #define XFS_PTAG_LOGRES 0x00000002 | |
183 | #define XFS_PTAG_AILDELETE 0x00000004 | |
184 | #define XFS_PTAG_ERROR_REPORT 0x00000008 | |
185 | #define XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010 | |
186 | #define XFS_PTAG_SHUTDOWN_IOERROR 0x00000020 | |
187 | #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 | |
188 | ||
189 | struct xfs_mount; | |
190 | /* PRINTFLIKE4 */ | |
191 | void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp, | |
192 | char *fmt, ...); | |
193 | /* PRINTFLIKE3 */ | |
194 | void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...); | |
195 | ||
196 | #endif /* __XFS_ERROR_H__ */ |