]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - fs/xfs/xfs_error.h
[XFS] Remove xfs_macros.c, xfs_macros.h, rework headers a whole lot.
[linux-2.6-omap-h63xx.git] / fs / xfs / xfs_error.h
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 xfs_error_report(char *tag, int level, struct xfs_mount *mp,
58                                 char *fname, int linenum, inst_t *ra);
59 extern void xfs_corruption_error(char *tag, int level, struct xfs_mount *mp,
60                                 void *p, char *fname, int linenum, inst_t *ra);
61
62 #define XFS_ERROR_REPORT(e, lvl, mp)    \
63         xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
64 #define XFS_CORRUPTION_ERROR(e, lvl, mp, mem)   \
65         xfs_corruption_error(e, lvl, mp, mem, \
66                              __FILE__, __LINE__, __return_address)
67
68 #define XFS_ERRLEVEL_OFF        0
69 #define XFS_ERRLEVEL_LOW        1
70 #define XFS_ERRLEVEL_HIGH       5
71
72 /*
73  * Macros to set EFSCORRUPTED & return/branch.
74  */
75 #define XFS_WANT_CORRUPTED_GOTO(x,l)    \
76         { \
77                 int fs_is_ok = (x); \
78                 ASSERT(fs_is_ok); \
79                 if (unlikely(!fs_is_ok)) { \
80                         XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
81                                          XFS_ERRLEVEL_LOW, NULL); \
82                         error = XFS_ERROR(EFSCORRUPTED); \
83                         goto l; \
84                 } \
85         }
86
87 #define XFS_WANT_CORRUPTED_RETURN(x)    \
88         { \
89                 int fs_is_ok = (x); \
90                 ASSERT(fs_is_ok); \
91                 if (unlikely(!fs_is_ok)) { \
92                         XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
93                                          XFS_ERRLEVEL_LOW, NULL); \
94                         return XFS_ERROR(EFSCORRUPTED); \
95                 } \
96         }
97
98 /*
99  * error injection tags - the labels can be anything you want
100  * but each tag should have its own unique number
101  */
102
103 #define XFS_ERRTAG_NOERROR                              0
104 #define XFS_ERRTAG_IFLUSH_1                             1
105 #define XFS_ERRTAG_IFLUSH_2                             2
106 #define XFS_ERRTAG_IFLUSH_3                             3
107 #define XFS_ERRTAG_IFLUSH_4                             4
108 #define XFS_ERRTAG_IFLUSH_5                             5
109 #define XFS_ERRTAG_IFLUSH_6                             6
110 #define XFS_ERRTAG_DA_READ_BUF                          7
111 #define XFS_ERRTAG_BTREE_CHECK_LBLOCK                   8
112 #define XFS_ERRTAG_BTREE_CHECK_SBLOCK                   9
113 #define XFS_ERRTAG_ALLOC_READ_AGF                       10
114 #define XFS_ERRTAG_IALLOC_READ_AGI                      11
115 #define XFS_ERRTAG_ITOBP_INOTOBP                        12
116 #define XFS_ERRTAG_IUNLINK                              13
117 #define XFS_ERRTAG_IUNLINK_REMOVE                       14
118 #define XFS_ERRTAG_DIR_INO_VALIDATE                     15
119 #define XFS_ERRTAG_BULKSTAT_READ_CHUNK                  16
120 #define XFS_ERRTAG_IODONE_IOERR                         17
121 #define XFS_ERRTAG_STRATREAD_IOERR                      18
122 #define XFS_ERRTAG_STRATCMPL_IOERR                      19
123 #define XFS_ERRTAG_DIOWRITE_IOERR                       20
124 #define XFS_ERRTAG_BMAPIFORMAT                          21
125 #define XFS_ERRTAG_MAX                                  22
126
127 /*
128  * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
129  */
130 #define XFS_RANDOM_DEFAULT                              100
131 #define XFS_RANDOM_IFLUSH_1                             XFS_RANDOM_DEFAULT
132 #define XFS_RANDOM_IFLUSH_2                             XFS_RANDOM_DEFAULT
133 #define XFS_RANDOM_IFLUSH_3                             XFS_RANDOM_DEFAULT
134 #define XFS_RANDOM_IFLUSH_4                             XFS_RANDOM_DEFAULT
135 #define XFS_RANDOM_IFLUSH_5                             XFS_RANDOM_DEFAULT
136 #define XFS_RANDOM_IFLUSH_6                             XFS_RANDOM_DEFAULT
137 #define XFS_RANDOM_DA_READ_BUF                          XFS_RANDOM_DEFAULT
138 #define XFS_RANDOM_BTREE_CHECK_LBLOCK                   (XFS_RANDOM_DEFAULT/4)
139 #define XFS_RANDOM_BTREE_CHECK_SBLOCK                   XFS_RANDOM_DEFAULT
140 #define XFS_RANDOM_ALLOC_READ_AGF                       XFS_RANDOM_DEFAULT
141 #define XFS_RANDOM_IALLOC_READ_AGI                      XFS_RANDOM_DEFAULT
142 #define XFS_RANDOM_ITOBP_INOTOBP                        XFS_RANDOM_DEFAULT
143 #define XFS_RANDOM_IUNLINK                              XFS_RANDOM_DEFAULT
144 #define XFS_RANDOM_IUNLINK_REMOVE                       XFS_RANDOM_DEFAULT
145 #define XFS_RANDOM_DIR_INO_VALIDATE                     XFS_RANDOM_DEFAULT
146 #define XFS_RANDOM_BULKSTAT_READ_CHUNK                  XFS_RANDOM_DEFAULT
147 #define XFS_RANDOM_IODONE_IOERR                         (XFS_RANDOM_DEFAULT/10)
148 #define XFS_RANDOM_STRATREAD_IOERR                      (XFS_RANDOM_DEFAULT/10)
149 #define XFS_RANDOM_STRATCMPL_IOERR                      (XFS_RANDOM_DEFAULT/10)
150 #define XFS_RANDOM_DIOWRITE_IOERR                       (XFS_RANDOM_DEFAULT/10)
151 #define XFS_RANDOM_BMAPIFORMAT                          XFS_RANDOM_DEFAULT
152
153 #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
154 extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
155 extern void xfs_error_test_init(void);
156
157 #define XFS_NUM_INJECT_ERROR                            10
158
159 #ifdef __ANSI_CPP__
160 #define XFS_TEST_ERROR(expr, mp, tag, rf)               \
161         ((expr) || \
162          xfs_error_test((tag), (mp)->m_fixedfsid, #expr, __LINE__, __FILE__, \
163                          (rf)))
164 #else
165 #define XFS_TEST_ERROR(expr, mp, tag, rf)               \
166         ((expr) || \
167          xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \
168                         (rf)))
169 #endif /* __ANSI_CPP__ */
170
171 extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp);
172 extern int xfs_errortag_clear(int error_tag, xfs_mount_t *mp);
173 extern int xfs_errortag_clearall(xfs_mount_t *mp);
174 extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud);
175 #else
176 #define XFS_TEST_ERROR(expr, mp, tag, rf)       (expr)
177 #define xfs_errortag_add(tag, mp)               (ENOSYS)
178 #define xfs_errortag_clearall(mp)               (ENOSYS)
179 #endif /* (DEBUG || INDUCE_IO_ERROR) */
180
181 /*
182  * XFS panic tags -- allow a call to xfs_cmn_err() be turned into
183  *                      a panic by setting xfs_panic_mask in a
184  *                      sysctl.  update xfs_max[XFS_PARAM] if
185  *                      more are added.
186  */
187 #define         XFS_NO_PTAG                     0
188 #define         XFS_PTAG_IFLUSH                 0x00000001
189 #define         XFS_PTAG_LOGRES                 0x00000002
190 #define         XFS_PTAG_AILDELETE              0x00000004
191 #define         XFS_PTAG_ERROR_REPORT           0x00000008
192 #define         XFS_PTAG_SHUTDOWN_CORRUPT       0x00000010
193 #define         XFS_PTAG_SHUTDOWN_IOERROR       0x00000020
194 #define         XFS_PTAG_SHUTDOWN_LOGERROR      0x00000040
195
196 struct xfs_mount;
197 /* PRINTFLIKE4 */
198 extern void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp,
199                             char *fmt, ...);
200 /* PRINTFLIKE3 */
201 extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...);
202
203 #endif  /* __XFS_ERROR_H__ */