blob: e6cf955ec0fca16f714812e9edef6c6c150a7762 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Nathan Scott7b718762005-11-02 14:58:39 +11002 * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc.
3 * All Rights Reserved.
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Nathan Scott7b718762005-11-02 14:58:39 +11005 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
Linus Torvalds1da177e2005-04-16 15:20:36 -07007 * published by the Free Software Foundation.
8 *
Nathan Scott7b718762005-11-02 14:58:39 +11009 * This program is distributed in the hope that it would be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
Linus Torvalds1da177e2005-04-16 15:20:36 -070013 *
Nathan Scott7b718762005-11-02 14:58:39 +110014 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write the Free Software Foundation,
16 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 */
Vlad Apostolov93c189c2006-11-11 18:03:49 +110018#include <xfs.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070019#include "debug.h"
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
Christoph Hellwigefc55752008-12-17 12:27:36 -050021/* xfs_mount.h drags a lot of crap in, sorry.. */
22#include "xfs_sb.h"
23#include "xfs_inum.h"
24#include "xfs_ag.h"
Christoph Hellwigefc55752008-12-17 12:27:36 -050025#include "xfs_mount.h"
Felix Blyakherda5309c2009-03-12 09:33:37 -050026#include "xfs_error.h"
Christoph Hellwigefc55752008-12-17 12:27:36 -050027
Linus Torvalds1da177e2005-04-16 15:20:36 -070028void
Dave Chinner73efe4a2011-01-12 00:35:42 +000029cmn_err(
30 const char *lvl,
31 const char *fmt,
32 ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070033{
Dave Chinner73efe4a2011-01-12 00:35:42 +000034 struct va_format vaf;
35 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036
Dave Chinner73efe4a2011-01-12 00:35:42 +000037 va_start(args, fmt);
38 vaf.fmt = fmt;
39 vaf.va = &args;
40
41 printk("%s%pV", lvl, &vaf);
42 va_end(args);
43
44 BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -070045}
46
Linus Torvalds1da177e2005-04-16 15:20:36 -070047void
Dave Chinner73efe4a2011-01-12 00:35:42 +000048xfs_fs_cmn_err(
49 const char *lvl,
Christoph Hellwigefc55752008-12-17 12:27:36 -050050 struct xfs_mount *mp,
Dave Chinner73efe4a2011-01-12 00:35:42 +000051 const char *fmt,
52 ...)
Linus Torvalds1da177e2005-04-16 15:20:36 -070053{
Dave Chinner73efe4a2011-01-12 00:35:42 +000054 struct va_format vaf;
55 va_list args;
Linus Torvalds1da177e2005-04-16 15:20:36 -070056
Dave Chinner73efe4a2011-01-12 00:35:42 +000057 va_start(args, fmt);
58 vaf.fmt = fmt;
59 vaf.va = &args;
Christoph Hellwigefc55752008-12-17 12:27:36 -050060
Dave Chinner73efe4a2011-01-12 00:35:42 +000061 printk("%sFilesystem %s: %pV", lvl, mp->m_fsname, &vaf);
62 va_end(args);
Christoph Hellwigefc55752008-12-17 12:27:36 -050063
Dave Chinner73efe4a2011-01-12 00:35:42 +000064 BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0);
65}
Christoph Hellwigefc55752008-12-17 12:27:36 -050066
Dave Chinner73efe4a2011-01-12 00:35:42 +000067/* All callers to xfs_cmn_err use CE_ALERT, so don't bother testing lvl */
68void
69xfs_cmn_err(
70 int panic_tag,
71 const char *lvl,
72 struct xfs_mount *mp,
73 const char *fmt,
74 ...)
75{
76 struct va_format vaf;
77 va_list args;
78 int panic = 0;
79
80 if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) {
81 printk(KERN_ALERT "XFS: Transforming an alert into a BUG.");
82 panic = 1;
Christoph Hellwigefc55752008-12-17 12:27:36 -050083 }
84
Dave Chinner73efe4a2011-01-12 00:35:42 +000085 va_start(args, fmt);
86 vaf.fmt = fmt;
87 vaf.va = &args;
Christoph Hellwigefc55752008-12-17 12:27:36 -050088
Dave Chinner73efe4a2011-01-12 00:35:42 +000089 printk(KERN_ALERT "Filesystem %s: %pV", mp->m_fsname, &vaf);
90 va_end(args);
Christoph Hellwigefc55752008-12-17 12:27:36 -050091
Dave Chinner73efe4a2011-01-12 00:35:42 +000092 BUG_ON(panic);
Linus Torvalds1da177e2005-04-16 15:20:36 -070093}
Nathan Scott3762ec62006-01-12 10:29:53 +110094
95void
96assfail(char *expr, char *file, int line)
97{
Anton Blanchard65a84a02011-01-07 03:30:41 +000098 printk(KERN_CRIT "Assertion failed: %s, file: %s, line: %d\n", expr,
99 file, line);
Nathan Scott3762ec62006-01-12 10:29:53 +1100100 BUG();
101}
Eric Sandeend4f3cc02007-10-12 11:13:08 +1000102
103void
104xfs_hex_dump(void *p, int length)
105{
Barry Naujok34519da2008-10-30 17:05:58 +1100106 print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1);
Eric Sandeend4f3cc02007-10-12 11:13:08 +1000107}