blob: 5735d5ea87ee2a1ff4c5615563639baa2b90af26 [file] [log] [blame]
Dave Chinner0b61f8a2018-06-05 19:42:14 -07001// SPDX-License-Identifier: GPL-2.0
Linus Torvalds1da177e2005-04-16 15:20:36 -07002/*
Nathan Scott7b718762005-11-02 14:58:39 +11003 * Copyright (c) 2000-2002,2005 Silicon Graphics, Inc.
4 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07005 */
6#ifndef __XFS_ERROR_H__
7#define __XFS_ERROR_H__
8
Linus Torvalds1da177e2005-04-16 15:20:36 -07009struct xfs_mount;
10
Alex Eldera0e856b2010-04-13 15:22:08 +100011extern void xfs_error_report(const char *tag, int level, struct xfs_mount *mp,
Darrick J. Wongd9418ed2018-01-08 10:51:25 -080012 const char *filename, int linenum,
13 xfs_failaddr_t failaddr);
Alex Eldera0e856b2010-04-13 15:22:08 +100014extern void xfs_corruption_error(const char *tag, int level,
Darrick J. Wongd243b892019-11-02 09:40:36 -070015 struct xfs_mount *mp, const void *buf, size_t bufsize,
Darrick J. Wong2551a532018-06-04 10:23:54 -070016 const char *filename, int linenum,
17 xfs_failaddr_t failaddr);
Darrick J. Wonge83cf872020-03-11 10:37:54 -070018void xfs_buf_corruption_error(struct xfs_buf *bp, xfs_failaddr_t fa);
Darrick J. Wong6edb1812018-03-23 10:06:53 -070019extern void xfs_buf_verifier_error(struct xfs_buf *bp, int error,
Darrick J. Wongd243b892019-11-02 09:40:36 -070020 const char *name, const void *buf, size_t bufsz,
Darrick J. Wong6edb1812018-03-23 10:06:53 -070021 xfs_failaddr_t failaddr);
Darrick J. Wongbc1a09b2018-01-08 10:51:03 -080022extern void xfs_verifier_error(struct xfs_buf *bp, int error,
23 xfs_failaddr_t failaddr);
Darrick J. Wong22431bf2018-01-22 18:09:48 -080024extern void xfs_inode_verifier_error(struct xfs_inode *ip, int error,
Darrick J. Wongd243b892019-11-02 09:40:36 -070025 const char *name, const void *buf, size_t bufsz,
Darrick J. Wong22431bf2018-01-22 18:09:48 -080026 xfs_failaddr_t failaddr);
Linus Torvalds1da177e2005-04-16 15:20:36 -070027
Linus Torvalds1da177e2005-04-16 15:20:36 -070028#define XFS_ERROR_REPORT(e, lvl, mp) \
29 xfs_error_report(e, lvl, mp, __FILE__, __LINE__, __return_address)
Darrick J. Wong2551a532018-06-04 10:23:54 -070030#define XFS_CORRUPTION_ERROR(e, lvl, mp, buf, bufsize) \
31 xfs_corruption_error(e, lvl, mp, buf, bufsize, \
Linus Torvalds1da177e2005-04-16 15:20:36 -070032 __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. Wong9c712a12018-01-08 10:51:26 -080038/* Dump 128 bytes of any corrupt buffer */
39#define XFS_CORRUPTION_DUMP_LEN (128)
40
Christoph Hellwig1550d0b2008-08-13 16:17:37 +100041#ifdef DEBUG
Darrick J. Wong31965ef2017-06-20 17:54:46 -070042extern int xfs_errortag_init(struct xfs_mount *mp);
43extern void xfs_errortag_del(struct xfs_mount *mp);
44extern bool xfs_errortag_test(struct xfs_mount *mp, const char *expression,
45 const char *file, int line, unsigned int error_tag);
Darrick J. Wong9e24cfd2017-06-20 17:54:47 -070046#define XFS_TEST_ERROR(expr, mp, tag) \
Darrick J. Wong31965ef2017-06-20 17:54:46 -070047 ((expr) || xfs_errortag_test((mp), #expr, __FILE__, __LINE__, (tag)))
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
Darrick J. Wongc6840102017-06-20 17:54:47 -070049extern int xfs_errortag_get(struct xfs_mount *mp, unsigned int error_tag);
Darrick J. Wong31965ef2017-06-20 17:54:46 -070050extern int xfs_errortag_set(struct xfs_mount *mp, unsigned int error_tag,
51 unsigned int tag_value);
52extern int xfs_errortag_add(struct xfs_mount *mp, unsigned int error_tag);
53extern int xfs_errortag_clearall(struct xfs_mount *mp);
Linus Torvalds1da177e2005-04-16 15:20:36 -070054#else
Darrick J. Wong31965ef2017-06-20 17:54:46 -070055#define xfs_errortag_init(mp) (0)
56#define xfs_errortag_del(mp)
Darrick J. Wong9e24cfd2017-06-20 17:54:47 -070057#define XFS_TEST_ERROR(expr, mp, tag) (expr)
Darrick J. Wong31965ef2017-06-20 17:54:46 -070058#define xfs_errortag_set(mp, tag, val) (ENOSYS)
59#define xfs_errortag_add(mp, tag) (ENOSYS)
60#define xfs_errortag_clearall(mp) (ENOSYS)
Christoph Hellwig1550d0b2008-08-13 16:17:37 +100061#endif /* DEBUG */
Linus Torvalds1da177e2005-04-16 15:20:36 -070062
63/*
Dave Chinner6a19d932011-03-07 10:02:35 +110064 * 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 Torvalds1da177e2005-04-16 15:20:36 -070066 */
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 Scott572d95f2006-09-28 11:03:20 +100075#define XFS_PTAG_FSBLOCK_ZERO 0x00000080
Marco Benattod519da42019-02-01 09:12:20 -080076#define XFS_PTAG_VERIFIER_ERROR 0x00000100
Linus Torvalds1da177e2005-04-16 15:20:36 -070077
Darrick J. Wong7f89c832021-08-10 17:00:54 -070078#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 Torvalds1da177e2005-04-16 15:20:36 -070090#endif /* __XFS_ERROR_H__ */