| 1 |
// SPDX-License-Identifier: GPL-2.0 |
| 2 |
/* |
| 3 |
* Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. |
| 4 |
* All Rights Reserved. |
| 5 |
*/ |
| 6 |
#ifndef __XFS_ERROR_H__ |
| 7 |
#define __XFS_ERROR_H__ |
| 8 |
|
| 9 |
struct xfs_mount; |
| 10 |
|
| 11 |
void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, |
| 12 |
const char *filename, int linenum, xfs_failaddr_t failaddr); |
| 13 |
void xfs_corruption_error(const char *tag, int level, struct xfs_mount *mp, |
| 14 |
const void *buf, size_t bufsize, const char *filename, |
| 15 |
int linenum, xfs_failaddr_t failaddr); |
| 16 |
void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); |
| 17 |
void xfs_buf_verifier_error(struct xfs_buf *bp, int error, const char *name, |
| 18 |
const void *buf, size_t bufsz, xfs_failaddr_t failaddr); |
| 19 |
void xfs_verifier_error(struct xfs_buf *bp, int error, xfs_failaddr_t failaddr); |
| 20 |
void xfs_inode_verifier_error(struct xfs_inode *ip, int error, const char *name, |
| 21 |
const void *buf, size_t bufsz, xfs_failaddr_t failaddr); |
| 22 |
|
| 23 |
#define XFS_ERROR_REPORT(e, lvl, mp) \ |
| 24 |
xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) |
| 25 |
#define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) \ |
| 26 |
xfs_corruption_error(e, lvl, mp, buf, bufsize, \ |
| 27 |
__FILE__, __LINE__, __return_address) |
| 28 |
|
| 29 |
#define XFS_ERRLEVEL_OFF 0 |
| 30 |
#define XFS_ERRLEVEL_LOW 1 |
| 31 |
#define XFS_ERRLEVEL_HIGH 5 |
| 32 |
|
| 33 |
/* Dump 128 bytes of any corrupt buffer */ |
| 34 |
#define XFS_CORRUPTION_DUMP_LEN (128) |
| 35 |
|
| 36 |
#ifdef DEBUG |
| 37 |
int xfs_errortag_init(struct xfs_mount *mp); |
| 38 |
void xfs_errortag_del(struct xfs_mount *mp); |
| 39 |
bool xfs_errortag_test(struct xfs_mount *mp, const char *file, int line, |
| 40 |
unsigned int error_tag); |
| 41 |
#define XFS_TEST_ERROR(mp, tag) \ |
| 42 |
xfs_errortag_test((mp), __FILE__, __LINE__, (tag)) |
| 43 |
void xfs_errortag_delay(struct xfs_mount *mp, const char *file, int line, |
| 44 |
unsigned int error_tag); |
| 45 |
#define XFS_ERRORTAG_DELAY(mp, tag) \ |
| 46 |
xfs_errortag_delay((mp), __FILE__, __LINE__, (tag)) |
| 47 |
int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); |
| 48 |
int xfs_errortag_add_name(struct xfs_mount *mp, const char *tag_name); |
| 49 |
void xfs_errortag_copy(struct xfs_mount *dst_mp, struct xfs_mount *src_mp); |
| 50 |
int xfs_errortag_clearall(struct xfs_mount *mp); |
| 51 |
#else |
| 52 |
#define xfs_errortag_init(mp) (0) |
| 53 |
#define xfs_errortag_del(mp) |
| 54 |
#define XFS_TEST_ERROR(mp, tag) (false) |
| 55 |
#define XFS_ERRORTAG_DELAY(mp, tag) ((void)0) |
| 56 |
#define xfs_errortag_add(mp, tag) (-ENOSYS) |
| 57 |
#define xfs_errortag_copy(dst_mp, src_mp) ((void)0) |
| 58 |
#define xfs_errortag_add_name(mp, tag_name) (-ENOSYS) |
| 59 |
#define xfs_errortag_clearall(mp) (-ENOSYS) |
| 60 |
#endif /* DEBUG */ |
| 61 |
|
| 62 |
/* |
| 63 |
* XFS panic tags -- allow a call to xfs_alert_tag() be turned into |
| 64 |
* a panic by setting fs.xfs.panic_mask in a sysctl. |
| 65 |
*/ |
| 66 |
#define XFS_NO_PTAG 0u |
| 67 |
#define XFS_PTAG_IFLUSH (1u << 0) |
| 68 |
#define XFS_PTAG_LOGRES (1u << 1) |
| 69 |
#define XFS_PTAG_AILDELETE (1u << 2) |
| 70 |
#define XFS_PTAG_ERROR_REPORT (1u << 3) |
| 71 |
#define XFS_PTAG_SHUTDOWN_CORRUPT (1u << 4) |
| 72 |
#define XFS_PTAG_SHUTDOWN_IOERROR (1u << 5) |
| 73 |
#define XFS_PTAG_SHUTDOWN_LOGERROR (1u << 6) |
| 74 |
#define XFS_PTAG_FSBLOCK_ZERO (1u << 7) |
| 75 |
#define XFS_PTAG_VERIFIER_ERROR (1u << 8) |
| 76 |
|
| 77 |
#define XFS_PTAG_MASK (XFS_PTAG_IFLUSH | \ |
| 78 |
XFS_PTAG_LOGRES | \ |
| 79 |
XFS_PTAG_AILDELETE | \ |
| 80 |
XFS_PTAG_ERROR_REPORT | \ |
| 81 |
XFS_PTAG_SHUTDOWN_CORRUPT | \ |
| 82 |
XFS_PTAG_SHUTDOWN_IOERROR | \ |
| 83 |
XFS_PTAG_SHUTDOWN_LOGERROR | \ |
| 84 |
XFS_PTAG_FSBLOCK_ZERO | \ |
| 85 |
XFS_PTAG_VERIFIER_ERROR) |
| 86 |
|
| 87 |
#define XFS_PTAG_STRINGS \ |
| 88 |
{ XFS_NO_PTAG, "none" }, \ |
| 89 |
{ XFS_PTAG_IFLUSH, "iflush" }, \ |
| 90 |
{ XFS_PTAG_LOGRES, "logres" }, \ |
| 91 |
{ XFS_PTAG_AILDELETE, "aildelete" }, \ |
| 92 |
{ XFS_PTAG_ERROR_REPORT , "error_report" }, \ |
| 93 |
{ XFS_PTAG_SHUTDOWN_CORRUPT, "corrupt" }, \ |
| 94 |
{ XFS_PTAG_SHUTDOWN_IOERROR, "ioerror" }, \ |
| 95 |
{ XFS_PTAG_SHUTDOWN_LOGERROR, "logerror" }, \ |
| 96 |
{ XFS_PTAG_FSBLOCK_ZERO, "fsb_zero" }, \ |
| 97 |
{ XFS_PTAG_VERIFIER_ERROR, "verifier" } |
| 98 |
|
| 99 |
#endif /* __XFS_ERROR_H__ */ |