xfs_error.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. /*
  2. * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
  3. * All Rights Reserved.
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License as
  7. * published by the Free Software Foundation.
  8. *
  9. * This program is distributed in the hope that it would be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write the Free Software Foundation,
  16. * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef __XFS_ERROR_H__
  19. #define __XFS_ERROR_H__
  20. struct xfs_mount;
  21. extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
  22. const char *filename, int linenum,
  23. xfs_failaddr_t failaddr);
  24. extern void xfs_corruption_error(const char *tag, int level,
  25. struct xfs_mount *mp, void *p, const char *filename,
  26. int linenum, xfs_failaddr_t failaddr);
  27. extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
  28. const char *name, void *buf, size_t bufsz,
  29. xfs_failaddr_t failaddr);
  30. extern void xfs_verifier_error(struct xfs_buf *bp, int error,
  31. xfs_failaddr_t failaddr);
  32. extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
  33. const char *name, void *buf, size_t bufsz,
  34. xfs_failaddr_t failaddr);
  35. #define XFS_ERROR_REPORT(e, lvl, mp) \
  36. xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
  37. #define XFS_CORRUPTION_ERROR(e, lvl, mp, mem) \
  38. xfs_corruption_error(e, lvl, mp, mem, \
  39. __FILE__, __LINE__, __return_address)
  40. #define XFS_ERRLEVEL_OFF 0
  41. #define XFS_ERRLEVEL_LOW 1
  42. #define XFS_ERRLEVEL_HIGH 5
  43. /* Dump 128 bytes of any corrupt buffer */
  44. #define XFS_CORRUPTION_DUMP_LEN (128)
  45. /*
  46. * Macros to set EFSCORRUPTED & return/branch.
  47. */
  48. #define XFS_WANT_CORRUPTED_GOTO(mp, x, l) \
  49. { \
  50. int fs_is_ok = (x); \
  51. ASSERT(fs_is_ok); \
  52. if (unlikely(!fs_is_ok)) { \
  53. XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_GOTO", \
  54. XFS_ERRLEVEL_LOW, mp); \
  55. error = -EFSCORRUPTED; \
  56. goto l; \
  57. } \
  58. }
  59. #define XFS_WANT_CORRUPTED_RETURN(mp, x) \
  60. { \
  61. int fs_is_ok = (x); \
  62. ASSERT(fs_is_ok); \
  63. if (unlikely(!fs_is_ok)) { \
  64. XFS_ERROR_REPORT("XFS_WANT_CORRUPTED_RETURN", \
  65. XFS_ERRLEVEL_LOW, mp); \
  66. return -EFSCORRUPTED; \
  67. } \
  68. }
  69. #ifdef DEBUG
  70. extern int xfs_errortag_init(struct xfs_mount *mp);
  71. extern void xfs_errortag_del(struct xfs_mount *mp);
  72. extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression,
  73. const char *file, int line, unsigned int error_tag);
  74. #define XFS_TEST_ERROR(expr, mp, tag) \
  75. ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
  76. extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag);
  77. extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
  78. unsigned int tag_value);
  79. extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
  80. extern int xfs_errortag_clearall(struct xfs_mount *mp);
  81. #else
  82. #define xfs_errortag_init(mp) (0)
  83. #define xfs_errortag_del(mp)
  84. #define XFS_TEST_ERROR(expr, mp, tag) (expr)
  85. #define xfs_errortag_set(mp, tag, val) (ENOSYS)
  86. #define xfs_errortag_add(mp, tag) (ENOSYS)
  87. #define xfs_errortag_clearall(mp) (ENOSYS)
  88. #endif /* DEBUG */
  89. /*
  90. * XFS panic tags -- allow a call to xfs_alert_tag() be turned into
  91. * a panic by setting xfs_panic_mask in a sysctl.
  92. */
  93. #define XFS_NO_PTAG 0
  94. #define XFS_PTAG_IFLUSH 0x00000001
  95. #define XFS_PTAG_LOGRES 0x00000002
  96. #define XFS_PTAG_AILDELETE 0x00000004
  97. #define XFS_PTAG_ERROR_REPORT 0x00000008
  98. #define XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010
  99. #define XFS_PTAG_SHUTDOWN_IOERROR 0x00000020
  100. #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040
  101. #define XFS_PTAG_FSBLOCK_ZERO 0x00000080
  102. #endif /* __XFS_ERROR_H__ */