0001
0002
0003
0004
0005
0006 #include "xfs.h"
0007 #include "xfs_fs.h"
0008 #include "xfs_error.h"
0009 #include "xfs_shared.h"
0010 #include "xfs_format.h"
0011 #include "xfs_trans_resv.h"
0012 #include "xfs_mount.h"
0013
0014
0015
0016
0017 static void
0018 __xfs_printk(
0019 const char *level,
0020 const struct xfs_mount *mp,
0021 struct va_format *vaf)
0022 {
0023 if (mp && mp->m_super) {
0024 printk("%sXFS (%s): %pV\n", level, mp->m_super->s_id, vaf);
0025 return;
0026 }
0027 printk("%sXFS: %pV\n", level, vaf);
0028 }
0029
0030 void
0031 xfs_printk_level(
0032 const char *kern_level,
0033 const struct xfs_mount *mp,
0034 const char *fmt, ...)
0035 {
0036 struct va_format vaf;
0037 va_list args;
0038 int level;
0039
0040 va_start(args, fmt);
0041 vaf.fmt = fmt;
0042 vaf.va = &args;
0043
0044 __xfs_printk(kern_level, mp, &vaf);
0045
0046 va_end(args);
0047
0048 if (!kstrtoint(kern_level, 0, &level) &&
0049 level <= LOGLEVEL_ERR &&
0050 xfs_error_level >= XFS_ERRLEVEL_HIGH)
0051 xfs_stack_trace();
0052 }
0053
0054 void
0055 _xfs_alert_tag(
0056 const struct xfs_mount *mp,
0057 uint32_t panic_tag,
0058 const char *fmt, ...)
0059 {
0060 struct va_format vaf;
0061 va_list args;
0062 int do_panic = 0;
0063
0064 if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) {
0065 xfs_alert(mp, "Transforming an alert into a BUG.");
0066 do_panic = 1;
0067 }
0068
0069 va_start(args, fmt);
0070
0071 vaf.fmt = fmt;
0072 vaf.va = &args;
0073
0074 __xfs_printk(KERN_ALERT, mp, &vaf);
0075 va_end(args);
0076
0077 BUG_ON(do_panic);
0078 }
0079
0080 void
0081 asswarn(
0082 struct xfs_mount *mp,
0083 char *expr,
0084 char *file,
0085 int line)
0086 {
0087 xfs_warn(mp, "Assertion failed: %s, file: %s, line: %d",
0088 expr, file, line);
0089 WARN_ON(1);
0090 }
0091
0092 void
0093 assfail(
0094 struct xfs_mount *mp,
0095 char *expr,
0096 char *file,
0097 int line)
0098 {
0099 xfs_emerg(mp, "Assertion failed: %s, file: %s, line: %d",
0100 expr, file, line);
0101 if (xfs_globals.bug_on_assert)
0102 BUG();
0103 else
0104 WARN_ON(1);
0105 }
0106
0107 void
0108 xfs_hex_dump(const void *p, int length)
0109 {
0110 print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_OFFSET, 16, 1, p, length, 1);
0111 }
0112
0113 void
0114 xfs_buf_alert_ratelimited(
0115 struct xfs_buf *bp,
0116 const char *rlmsg,
0117 const char *fmt,
0118 ...)
0119 {
0120 struct xfs_mount *mp = bp->b_mount;
0121 struct va_format vaf;
0122 va_list args;
0123
0124
0125 if (!___ratelimit(&bp->b_target->bt_ioerror_rl, rlmsg))
0126 return;
0127
0128 va_start(args, fmt);
0129 vaf.fmt = fmt;
0130 vaf.va = &args;
0131 __xfs_printk(KERN_ALERT, mp, &vaf);
0132 va_end(args);
0133 }