Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 2 | * Copyright (c) 2000-2003,2005 Silicon Graphics, Inc. |
| 3 | * All Rights Reserved. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 5 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | * published by the Free Software Foundation. |
| 8 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 9 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 13 | * |
Nathan Scott | 7b71876 | 2005-11-02 14:58:39 +1100 | [diff] [blame] | 14 | * 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | */ |
Vlad Apostolov | 93c189c | 2006-11-11 18:03:49 +1100 | [diff] [blame] | 18 | #include <xfs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | #include "debug.h" |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 21 | /* 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 Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 25 | #include "xfs_mount.h" |
Felix Blyakher | da5309c | 2009-03-12 09:33:37 -0500 | [diff] [blame] | 26 | #include "xfs_error.h" |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 27 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 28 | void |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 29 | cmn_err( |
| 30 | const char *lvl, |
| 31 | const char *fmt, |
| 32 | ...) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 33 | { |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 34 | struct va_format vaf; |
| 35 | va_list args; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 36 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 37 | 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 Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | } |
| 46 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 47 | void |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 48 | xfs_fs_cmn_err( |
| 49 | const char *lvl, |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 50 | struct xfs_mount *mp, |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 51 | const char *fmt, |
| 52 | ...) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | { |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 54 | struct va_format vaf; |
| 55 | va_list args; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 56 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 57 | va_start(args, fmt); |
| 58 | vaf.fmt = fmt; |
| 59 | vaf.va = &args; |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 60 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 61 | printk("%sFilesystem %s: %pV", lvl, mp->m_fsname, &vaf); |
| 62 | va_end(args); |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 63 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 64 | BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0); |
| 65 | } |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 66 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 67 | /* All callers to xfs_cmn_err use CE_ALERT, so don't bother testing lvl */ |
| 68 | void |
| 69 | xfs_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 Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 83 | } |
| 84 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 85 | va_start(args, fmt); |
| 86 | vaf.fmt = fmt; |
| 87 | vaf.va = &args; |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 88 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 89 | printk(KERN_ALERT "Filesystem %s: %pV", mp->m_fsname, &vaf); |
| 90 | va_end(args); |
Christoph Hellwig | efc5575 | 2008-12-17 12:27:36 -0500 | [diff] [blame] | 91 | |
Dave Chinner | 73efe4a | 2011-01-12 00:35:42 +0000 | [diff] [blame^] | 92 | BUG_ON(panic); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 93 | } |
Nathan Scott | 3762ec6 | 2006-01-12 10:29:53 +1100 | [diff] [blame] | 94 | |
| 95 | void |
| 96 | assfail(char *expr, char *file, int line) |
| 97 | { |
Anton Blanchard | 65a84a0 | 2011-01-07 03:30:41 +0000 | [diff] [blame] | 98 | printk(KERN_CRIT "Assertion failed: %s, file: %s, line: %d\n", expr, |
| 99 | file, line); |
Nathan Scott | 3762ec6 | 2006-01-12 10:29:53 +1100 | [diff] [blame] | 100 | BUG(); |
| 101 | } |
Eric Sandeen | d4f3cc0 | 2007-10-12 11:13:08 +1000 | [diff] [blame] | 102 | |
| 103 | void |
| 104 | xfs_hex_dump(void *p, int length) |
| 105 | { |
Barry Naujok | 34519da | 2008-10-30 17:05:58 +1100 | [diff] [blame] | 106 | print_hex_dump(KERN_ALERT, "", DUMP_PREFIX_ADDRESS, 16, 1, p, length, 1); |
Eric Sandeen | d4f3cc0 | 2007-10-12 11:13:08 +1000 | [diff] [blame] | 107 | } |