xfs_error.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #define prdev(fmt,targ,args...) \
  35. printk("XFS: device %s- " fmt "\n", XFS_BUFTARG_NAME(targ), ## args)
  36. #define XFS_ERECOVER 1 /* Failure to recover log */
  37. #define XFS_ELOGSTAT 2 /* Failure to stat log in user space */
  38. #define XFS_ENOLOGSPACE 3 /* Reservation too large */
  39. #define XFS_ENOTSUP 4 /* Operation not supported */
  40. #define XFS_ENOLSN 5 /* Can't find the lsn you asked for */
  41. #define XFS_ENOTFOUND 6
  42. #define XFS_ENOTXFS 7 /* Not XFS filesystem */
  43. #ifdef DEBUG
  44. #define XFS_ERROR_NTRAP 10
  45. extern int xfs_etrap[XFS_ERROR_NTRAP];
  46. extern int xfs_error_trap(int);
  47. #define XFS_ERROR(e) xfs_error_trap(e)
  48. #else
  49. #define XFS_ERROR(e) (e)
  50. #endif
  51. struct xfs_mount;
  52. extern void xfs_error_report(char *tag, int level, struct xfs_mount *mp,
  53. char *fname, int linenum, inst_t *ra);
  54. extern void xfs_corruption_error(char *tag, int level, struct xfs_mount *mp,
  55. void *p, char *fname, int linenum, inst_t *ra);
  56. #define XFS_ERROR_REPORT(e, lvl, mp) \
  57. xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
  58. #define XFS_CORRUPTION_ERROR(e, lvl, mp, mem) \
  59. xfs_corruption_error(e, lvl, mp, mem, \
  60. __FILE__, __LINE__, __return_address)
  61. #define XFS_ERRLEVEL_OFF 0
  62. #define XFS_ERRLEVEL_LOW 1
  63. #define XFS_ERRLEVEL_HIGH 5
  64. /*
  65. * Macros to set EFSCORRUPTED & return/branch.
  66. */
  67. #define XFS_WANT_CORRUPTED_GOTO(x,l) \
  68. { \
  69. int fs_is_ok = (x); \
  70. ASSERT(fs_is_ok); \
  71. if (unlikely(!fs_is_ok)) { \
  72. XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
  73. XFS_ERRLEVEL_LOW, NULL); \
  74. error = XFS_ERROR(EFSCORRUPTED); \
  75. goto l; \
  76. } \
  77. }
  78. #define XFS_WANT_CORRUPTED_RETURN(x) \
  79. { \
  80. int fs_is_ok = (x); \
  81. ASSERT(fs_is_ok); \
  82. if (unlikely(!fs_is_ok)) { \
  83. XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
  84. XFS_ERRLEVEL_LOW, NULL); \
  85. return XFS_ERROR(EFSCORRUPTED); \
  86. } \
  87. }
  88. /*
  89. * error injection tags - the labels can be anything you want
  90. * but each tag should have its own unique number
  91. */
  92. #define XFS_ERRTAG_NOERROR 0
  93. #define XFS_ERRTAG_IFLUSH_1 1
  94. #define XFS_ERRTAG_IFLUSH_2 2
  95. #define XFS_ERRTAG_IFLUSH_3 3
  96. #define XFS_ERRTAG_IFLUSH_4 4
  97. #define XFS_ERRTAG_IFLUSH_5 5
  98. #define XFS_ERRTAG_IFLUSH_6 6
  99. #define XFS_ERRTAG_DA_READ_BUF 7
  100. #define XFS_ERRTAG_BTREE_CHECK_LBLOCK 8
  101. #define XFS_ERRTAG_BTREE_CHECK_SBLOCK 9
  102. #define XFS_ERRTAG_ALLOC_READ_AGF 10
  103. #define XFS_ERRTAG_IALLOC_READ_AGI 11
  104. #define XFS_ERRTAG_ITOBP_INOTOBP 12
  105. #define XFS_ERRTAG_IUNLINK 13
  106. #define XFS_ERRTAG_IUNLINK_REMOVE 14
  107. #define XFS_ERRTAG_DIR_INO_VALIDATE 15
  108. #define XFS_ERRTAG_BULKSTAT_READ_CHUNK 16
  109. #define XFS_ERRTAG_IODONE_IOERR 17
  110. #define XFS_ERRTAG_STRATREAD_IOERR 18
  111. #define XFS_ERRTAG_STRATCMPL_IOERR 19
  112. #define XFS_ERRTAG_DIOWRITE_IOERR 20
  113. #define XFS_ERRTAG_BMAPIFORMAT 21
  114. #define XFS_ERRTAG_MAX 22
  115. /*
  116. * Random factors for above tags, 1 means always, 2 means 1/2 time, etc.
  117. */
  118. #define XFS_RANDOM_DEFAULT 100
  119. #define XFS_RANDOM_IFLUSH_1 XFS_RANDOM_DEFAULT
  120. #define XFS_RANDOM_IFLUSH_2 XFS_RANDOM_DEFAULT
  121. #define XFS_RANDOM_IFLUSH_3 XFS_RANDOM_DEFAULT
  122. #define XFS_RANDOM_IFLUSH_4 XFS_RANDOM_DEFAULT
  123. #define XFS_RANDOM_IFLUSH_5 XFS_RANDOM_DEFAULT
  124. #define XFS_RANDOM_IFLUSH_6 XFS_RANDOM_DEFAULT
  125. #define XFS_RANDOM_DA_READ_BUF XFS_RANDOM_DEFAULT
  126. #define XFS_RANDOM_BTREE_CHECK_LBLOCK (XFS_RANDOM_DEFAULT/4)
  127. #define XFS_RANDOM_BTREE_CHECK_SBLOCK XFS_RANDOM_DEFAULT
  128. #define XFS_RANDOM_ALLOC_READ_AGF XFS_RANDOM_DEFAULT
  129. #define XFS_RANDOM_IALLOC_READ_AGI XFS_RANDOM_DEFAULT
  130. #define XFS_RANDOM_ITOBP_INOTOBP XFS_RANDOM_DEFAULT
  131. #define XFS_RANDOM_IUNLINK XFS_RANDOM_DEFAULT
  132. #define XFS_RANDOM_IUNLINK_REMOVE XFS_RANDOM_DEFAULT
  133. #define XFS_RANDOM_DIR_INO_VALIDATE XFS_RANDOM_DEFAULT
  134. #define XFS_RANDOM_BULKSTAT_READ_CHUNK XFS_RANDOM_DEFAULT
  135. #define XFS_RANDOM_IODONE_IOERR (XFS_RANDOM_DEFAULT/10)
  136. #define XFS_RANDOM_STRATREAD_IOERR (XFS_RANDOM_DEFAULT/10)
  137. #define XFS_RANDOM_STRATCMPL_IOERR (XFS_RANDOM_DEFAULT/10)
  138. #define XFS_RANDOM_DIOWRITE_IOERR (XFS_RANDOM_DEFAULT/10)
  139. #define XFS_RANDOM_BMAPIFORMAT XFS_RANDOM_DEFAULT
  140. #if (defined(DEBUG) || defined(INDUCE_IO_ERROR))
  141. extern int xfs_error_test(int, int *, char *, int, char *, unsigned long);
  142. extern void xfs_error_test_init(void);
  143. #define XFS_NUM_INJECT_ERROR 10
  144. #ifdef __ANSI_CPP__
  145. #define XFS_TEST_ERROR(expr, mp, tag, rf) \
  146. ((expr) || \
  147. xfs_error_test((tag), (mp)->m_fixedfsid, #expr, __LINE__, __FILE__, \
  148. (rf)))
  149. #else
  150. #define XFS_TEST_ERROR(expr, mp, tag, rf) \
  151. ((expr) || \
  152. xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \
  153. (rf)))
  154. #endif /* __ANSI_CPP__ */
  155. extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp);
  156. extern int xfs_errortag_clear(int error_tag, xfs_mount_t *mp);
  157. extern int xfs_errortag_clearall(xfs_mount_t *mp);
  158. extern int xfs_errortag_clearall_umount(int64_t fsid, char *fsname, int loud);
  159. #else
  160. #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr)
  161. #define xfs_errortag_add(tag, mp) (ENOSYS)
  162. #define xfs_errortag_clearall(mp) (ENOSYS)
  163. #endif /* (DEBUG || INDUCE_IO_ERROR) */
  164. /*
  165. * XFS panic tags -- allow a call to xfs_cmn_err() be turned into
  166. * a panic by setting xfs_panic_mask in a
  167. * sysctl. update xfs_max[XFS_PARAM] if
  168. * more are added.
  169. */
  170. #define XFS_NO_PTAG 0
  171. #define XFS_PTAG_IFLUSH 0x00000001
  172. #define XFS_PTAG_LOGRES 0x00000002
  173. #define XFS_PTAG_AILDELETE 0x00000004
  174. #define XFS_PTAG_ERROR_REPORT 0x00000008
  175. #define XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010
  176. #define XFS_PTAG_SHUTDOWN_IOERROR 0x00000020
  177. #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040
  178. struct xfs_mount;
  179. /* PRINTFLIKE4 */
  180. extern void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp,
  181. char *fmt, ...);
  182. /* PRINTFLIKE3 */
  183. extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...);
  184. #endif /* __XFS_ERROR_H__ */