Dave Chinner | 0b61f8a | 2018-06-05 19:42:14 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 3 | * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
| 4 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
| 6 | #ifndef __XFS_ERROR_H__ |
| 7 | #define __XFS_ERROR_H__ |
| 8 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | struct xfs_mount; |
| 10 | |
Alex Elder | a0e856b | 2010-04-13 15:22:08 +1000 | [diff] [blame] | 11 | extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, |
Darrick J. Wong | d9418ed | 2018-01-08 10:51:25 -0800 | [diff] [blame] | 12 | const char *filename, int linenum, |
| 13 | xfs_failaddr_t failaddr); |
Alex Elder | a0e856b | 2010-04-13 15:22:08 +1000 | [diff] [blame] | 14 | extern void xfs_corruption_error(const char *tag, int level, |
Darrick J. Wong | d243b89 | 2019-11-02 09:40:36 -0700 | [diff] [blame] | 15 | struct xfs_mount *mp, const void *buf, size_t bufsize, |
Darrick J. Wong | 2551a53 | 2018-06-04 10:23:54 -0700 | [diff] [blame] | 16 | const char *filename, int linenum, |
| 17 | xfs_failaddr_t failaddr); |
Darrick J. Wong | e83cf87 | 2020-03-11 10:37:54 -0700 | [diff] [blame] | 18 | void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); |
Darrick J. Wong | 6edb181 | 2018-03-23 10:06:53 -0700 | [diff] [blame] | 19 | extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error, |
Darrick J. Wong | d243b89 | 2019-11-02 09:40:36 -0700 | [diff] [blame] | 20 | const char *name, const void *buf, size_t bufsz, |
Darrick J. Wong | 6edb181 | 2018-03-23 10:06:53 -0700 | [diff] [blame] | 21 | xfs_failaddr_t failaddr); |
Darrick J. Wong | bc1a09b | 2018-01-08 10:51:03 -0800 | [diff] [blame] | 22 | extern void xfs_verifier_error(struct xfs_buf *bp, int error, |
| 23 | xfs_failaddr_t failaddr); |
Darrick J. Wong | 22431bf | 2018-01-22 18:09:48 -0800 | [diff] [blame] | 24 | extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error, |
Darrick J. Wong | d243b89 | 2019-11-02 09:40:36 -0700 | [diff] [blame] | 25 | const char *name, const void *buf, size_t bufsz, |
Darrick J. Wong | 22431bf | 2018-01-22 18:09:48 -0800 | [diff] [blame] | 26 | xfs_failaddr_t failaddr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | #define XFS_ERROR_REPORT(e, lvl, mp) \ |
| 29 | xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) |
Darrick J. Wong | 2551a53 | 2018-06-04 10:23:54 -0700 | [diff] [blame] | 30 | #define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) \ |
| 31 | xfs_corruption_error(e, lvl, mp, buf, bufsize, \ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | __FILE__, __LINE__, __return_address) |
| 33 | |
| 34 | #define XFS_ERRLEVEL_OFF 0 |
| 35 | #define XFS_ERRLEVEL_LOW 1 |
| 36 | #define XFS_ERRLEVEL_HIGH 5 |
| 37 | |
Darrick J. Wong | 9c712a1 | 2018-01-08 10:51:26 -0800 | [diff] [blame] | 38 | /* Dump 128 bytes of any corrupt buffer */ |
| 39 | #define XFS_CORRUPTION_DUMP_LEN (128) |
| 40 | |
Christoph Hellwig | 1550d0b | 2008-08-13 16:17:37 +1000 | [diff] [blame] | 41 | #ifdef DEBUG |
Darrick J. Wong | 31965ef | 2017-06-20 17:54:46 -0700 | [diff] [blame] | 42 | extern int xfs_errortag_init(struct xfs_mount *mp); |
| 43 | extern void xfs_errortag_del(struct xfs_mount *mp); |
| 44 | extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression, |
| 45 | const char *file, int line, unsigned int error_tag); |
Darrick J. Wong | 9e24cfd | 2017-06-20 17:54:47 -0700 | [diff] [blame] | 46 | #define XFS_TEST_ERROR(expr, mp, tag) \ |
Darrick J. Wong | 31965ef | 2017-06-20 17:54:46 -0700 | [diff] [blame] | 47 | ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag))) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
Darrick J. Wong | c684010 | 2017-06-20 17:54:47 -0700 | [diff] [blame] | 49 | extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag); |
Darrick J. Wong | 31965ef | 2017-06-20 17:54:46 -0700 | [diff] [blame] | 50 | extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag, |
| 51 | unsigned int tag_value); |
| 52 | extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); |
| 53 | extern int xfs_errortag_clearall(struct xfs_mount *mp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | #else |
Darrick J. Wong | 31965ef | 2017-06-20 17:54:46 -0700 | [diff] [blame] | 55 | #define xfs_errortag_init(mp) (0) |
| 56 | #define xfs_errortag_del(mp) |
Darrick J. Wong | 9e24cfd | 2017-06-20 17:54:47 -0700 | [diff] [blame] | 57 | #define XFS_TEST_ERROR(expr, mp, tag) (expr) |
Darrick J. Wong | 31965ef | 2017-06-20 17:54:46 -0700 | [diff] [blame] | 58 | #define xfs_errortag_set(mp, tag, val) (ENOSYS) |
| 59 | #define xfs_errortag_add(mp, tag) (ENOSYS) |
| 60 | #define xfs_errortag_clearall(mp) (ENOSYS) |
Christoph Hellwig | 1550d0b | 2008-08-13 16:17:37 +1000 | [diff] [blame] | 61 | #endif /* DEBUG */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | |
| 63 | /* |
Dave Chinner | 6a19d93 | 2011-03-07 10:02:35 +1100 | [diff] [blame] | 64 | * XFS panic tags -- allow a call to xfs_alert_tag() be turned into |
| 65 | * a panic by setting xfs_panic_mask in a sysctl. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | */ |
| 67 | #define XFS_NO_PTAG 0 |
| 68 | #define XFS_PTAG_IFLUSH 0x00000001 |
| 69 | #define XFS_PTAG_LOGRES 0x00000002 |
| 70 | #define XFS_PTAG_AILDELETE 0x00000004 |
| 71 | #define XFS_PTAG_ERROR_REPORT 0x00000008 |
| 72 | #define XFS_PTAG_SHUTDOWN_CORRUPT 0x00000010 |
| 73 | #define XFS_PTAG_SHUTDOWN_IOERROR 0x00000020 |
| 74 | #define XFS_PTAG_SHUTDOWN_LOGERROR 0x00000040 |
Nathan Scott | 572d95f | 2006-09-28 11:03:20 +1000 | [diff] [blame] | 75 | #define XFS_PTAG_FSBLOCK_ZERO 0x00000080 |
Marco Benatto | d519da4 | 2019-02-01 09:12:20 -0800 | [diff] [blame] | 76 | #define XFS_PTAG_VERIFIER_ERROR 0x00000100 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 77 | |
Darrick J. Wong | 7f89c83 | 2021-08-10 17:00:54 -0700 | [diff] [blame] | 78 | #define XFS_PTAG_STRINGS \ |
| 79 | { XFS_NO_PTAG, "none" }, \ |
| 80 | { XFS_PTAG_IFLUSH, "iflush" }, \ |
| 81 | { XFS_PTAG_LOGRES, "logres" }, \ |
| 82 | { XFS_PTAG_AILDELETE, "aildelete" }, \ |
| 83 | { XFS_PTAG_ERROR_REPORT , "error_report" }, \ |
| 84 | { XFS_PTAG_SHUTDOWN_CORRUPT, "corrupt" }, \ |
| 85 | { XFS_PTAG_SHUTDOWN_IOERROR, "ioerror" }, \ |
| 86 | { XFS_PTAG_SHUTDOWN_LOGERROR, "logerror" }, \ |
| 87 | { XFS_PTAG_FSBLOCK_ZERO, "fsb_zero" }, \ |
| 88 | { XFS_PTAG_VERIFIER_ERROR, "verifier" } |
| 89 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 90 | #endif /* __XFS_ERROR_H__ */ |