162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc. 462306a36Sopenharmony_ci * All Rights Reserved. 562306a36Sopenharmony_ci */ 662306a36Sopenharmony_ci#ifndef __XFS_ERROR_H__ 762306a36Sopenharmony_ci#define __XFS_ERROR_H__ 862306a36Sopenharmony_ci 962306a36Sopenharmony_cistruct xfs_mount; 1062306a36Sopenharmony_ci 1162306a36Sopenharmony_ciextern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp, 1262306a36Sopenharmony_ci const char *filename, int linenum, 1362306a36Sopenharmony_ci xfs_failaddr_t failaddr); 1462306a36Sopenharmony_ciextern void xfs_corruption_error(const char *tag, int level, 1562306a36Sopenharmony_ci struct xfs_mount *mp, const void *buf, size_t bufsize, 1662306a36Sopenharmony_ci const char *filename, int linenum, 1762306a36Sopenharmony_ci xfs_failaddr_t failaddr); 1862306a36Sopenharmony_civoid xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa); 1962306a36Sopenharmony_ciextern void xfs_buf_verifier_error(struct xfs_buf *bp, int error, 2062306a36Sopenharmony_ci const char *name, const void *buf, size_t bufsz, 2162306a36Sopenharmony_ci xfs_failaddr_t failaddr); 2262306a36Sopenharmony_ciextern void xfs_verifier_error(struct xfs_buf *bp, int error, 2362306a36Sopenharmony_ci xfs_failaddr_t failaddr); 2462306a36Sopenharmony_ciextern void xfs_inode_verifier_error(struct xfs_inode *ip, int error, 2562306a36Sopenharmony_ci const char *name, const void *buf, size_t bufsz, 2662306a36Sopenharmony_ci xfs_failaddr_t failaddr); 2762306a36Sopenharmony_ci 2862306a36Sopenharmony_ci#define XFS_ERROR_REPORT(e, lvl, mp) \ 2962306a36Sopenharmony_ci xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address) 3062306a36Sopenharmony_ci#define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) \ 3162306a36Sopenharmony_ci xfs_corruption_error(e, lvl, mp, buf, bufsize, \ 3262306a36Sopenharmony_ci __FILE__, __LINE__, __return_address) 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ci#define XFS_ERRLEVEL_OFF 0 3562306a36Sopenharmony_ci#define XFS_ERRLEVEL_LOW 1 3662306a36Sopenharmony_ci#define XFS_ERRLEVEL_HIGH 5 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci/* Dump 128 bytes of any corrupt buffer */ 3962306a36Sopenharmony_ci#define XFS_CORRUPTION_DUMP_LEN (128) 4062306a36Sopenharmony_ci 4162306a36Sopenharmony_ci#ifdef DEBUG 4262306a36Sopenharmony_ciextern int xfs_errortag_init(struct xfs_mount *mp); 4362306a36Sopenharmony_ciextern void xfs_errortag_del(struct xfs_mount *mp); 4462306a36Sopenharmony_ciextern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression, 4562306a36Sopenharmony_ci const char *file, int line, unsigned int error_tag); 4662306a36Sopenharmony_ci#define XFS_TEST_ERROR(expr, mp, tag) \ 4762306a36Sopenharmony_ci ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag))) 4862306a36Sopenharmony_cibool xfs_errortag_enabled(struct xfs_mount *mp, unsigned int tag); 4962306a36Sopenharmony_ci#define XFS_ERRORTAG_DELAY(mp, tag) \ 5062306a36Sopenharmony_ci do { \ 5162306a36Sopenharmony_ci might_sleep(); \ 5262306a36Sopenharmony_ci if (!xfs_errortag_enabled((mp), (tag))) \ 5362306a36Sopenharmony_ci break; \ 5462306a36Sopenharmony_ci xfs_warn_ratelimited((mp), \ 5562306a36Sopenharmony_ci"Injecting %ums delay at file %s, line %d, on filesystem \"%s\"", \ 5662306a36Sopenharmony_ci (mp)->m_errortag[(tag)], __FILE__, __LINE__, \ 5762306a36Sopenharmony_ci (mp)->m_super->s_id); \ 5862306a36Sopenharmony_ci mdelay((mp)->m_errortag[(tag)]); \ 5962306a36Sopenharmony_ci } while (0) 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ciextern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag); 6262306a36Sopenharmony_ciextern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag, 6362306a36Sopenharmony_ci unsigned int tag_value); 6462306a36Sopenharmony_ciextern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag); 6562306a36Sopenharmony_ciextern int xfs_errortag_clearall(struct xfs_mount *mp); 6662306a36Sopenharmony_ci#else 6762306a36Sopenharmony_ci#define xfs_errortag_init(mp) (0) 6862306a36Sopenharmony_ci#define xfs_errortag_del(mp) 6962306a36Sopenharmony_ci#define XFS_TEST_ERROR(expr, mp, tag) (expr) 7062306a36Sopenharmony_ci#define XFS_ERRORTAG_DELAY(mp, tag) ((void)0) 7162306a36Sopenharmony_ci#define xfs_errortag_set(mp, tag, val) (ENOSYS) 7262306a36Sopenharmony_ci#define xfs_errortag_add(mp, tag) (ENOSYS) 7362306a36Sopenharmony_ci#define xfs_errortag_clearall(mp) (ENOSYS) 7462306a36Sopenharmony_ci#endif /* DEBUG */ 7562306a36Sopenharmony_ci 7662306a36Sopenharmony_ci/* 7762306a36Sopenharmony_ci * XFS panic tags -- allow a call to xfs_alert_tag() be turned into 7862306a36Sopenharmony_ci * a panic by setting fs.xfs.panic_mask in a sysctl. 7962306a36Sopenharmony_ci */ 8062306a36Sopenharmony_ci#define XFS_NO_PTAG 0u 8162306a36Sopenharmony_ci#define XFS_PTAG_IFLUSH (1u << 0) 8262306a36Sopenharmony_ci#define XFS_PTAG_LOGRES (1u << 1) 8362306a36Sopenharmony_ci#define XFS_PTAG_AILDELETE (1u << 2) 8462306a36Sopenharmony_ci#define XFS_PTAG_ERROR_REPORT (1u << 3) 8562306a36Sopenharmony_ci#define XFS_PTAG_SHUTDOWN_CORRUPT (1u << 4) 8662306a36Sopenharmony_ci#define XFS_PTAG_SHUTDOWN_IOERROR (1u << 5) 8762306a36Sopenharmony_ci#define XFS_PTAG_SHUTDOWN_LOGERROR (1u << 6) 8862306a36Sopenharmony_ci#define XFS_PTAG_FSBLOCK_ZERO (1u << 7) 8962306a36Sopenharmony_ci#define XFS_PTAG_VERIFIER_ERROR (1u << 8) 9062306a36Sopenharmony_ci 9162306a36Sopenharmony_ci#define XFS_PTAG_MASK (XFS_PTAG_IFLUSH | \ 9262306a36Sopenharmony_ci XFS_PTAG_LOGRES | \ 9362306a36Sopenharmony_ci XFS_PTAG_AILDELETE | \ 9462306a36Sopenharmony_ci XFS_PTAG_ERROR_REPORT | \ 9562306a36Sopenharmony_ci XFS_PTAG_SHUTDOWN_CORRUPT | \ 9662306a36Sopenharmony_ci XFS_PTAG_SHUTDOWN_IOERROR | \ 9762306a36Sopenharmony_ci XFS_PTAG_SHUTDOWN_LOGERROR | \ 9862306a36Sopenharmony_ci XFS_PTAG_FSBLOCK_ZERO | \ 9962306a36Sopenharmony_ci XFS_PTAG_VERIFIER_ERROR) 10062306a36Sopenharmony_ci 10162306a36Sopenharmony_ci#define XFS_PTAG_STRINGS \ 10262306a36Sopenharmony_ci { XFS_NO_PTAG, "none" }, \ 10362306a36Sopenharmony_ci { XFS_PTAG_IFLUSH, "iflush" }, \ 10462306a36Sopenharmony_ci { XFS_PTAG_LOGRES, "logres" }, \ 10562306a36Sopenharmony_ci { XFS_PTAG_AILDELETE, "aildelete" }, \ 10662306a36Sopenharmony_ci { XFS_PTAG_ERROR_REPORT , "error_report" }, \ 10762306a36Sopenharmony_ci { XFS_PTAG_SHUTDOWN_CORRUPT, "corrupt" }, \ 10862306a36Sopenharmony_ci { XFS_PTAG_SHUTDOWN_IOERROR, "ioerror" }, \ 10962306a36Sopenharmony_ci { XFS_PTAG_SHUTDOWN_LOGERROR, "logerror" }, \ 11062306a36Sopenharmony_ci { XFS_PTAG_FSBLOCK_ZERO, "fsb_zero" }, \ 11162306a36Sopenharmony_ci { XFS_PTAG_VERIFIER_ERROR, "verifier" } 11262306a36Sopenharmony_ci 11362306a36Sopenharmony_ci#endif /* __XFS_ERROR_H__ */ 114