diff options
-rw-r--r-- | fs/xfs/linux-2.6/xfs_sysctl.c | 23 | ||||
-rw-r--r-- | fs/xfs/support/debug.c | 109 | ||||
-rw-r--r-- | fs/xfs/support/debug.h | 25 | ||||
-rw-r--r-- | fs/xfs/xfs_error.c | 31 | ||||
-rw-r--r-- | fs/xfs/xfs_error.h | 18 | ||||
-rw-r--r-- | fs/xfs/xfs_log.c | 2 | ||||
-rw-r--r-- | fs/xfs/xfs_log_recover.c | 2 |
7 files changed, 96 insertions, 114 deletions
diff --git a/fs/xfs/linux-2.6/xfs_sysctl.c b/fs/xfs/linux-2.6/xfs_sysctl.c index 7bb5092d6ae4..ee3cee097e7e 100644 --- a/fs/xfs/linux-2.6/xfs_sysctl.c +++ b/fs/xfs/linux-2.6/xfs_sysctl.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include "xfs.h" | 18 | #include "xfs.h" |
19 | #include <linux/sysctl.h> | 19 | #include <linux/sysctl.h> |
20 | #include <linux/proc_fs.h> | 20 | #include <linux/proc_fs.h> |
21 | #include "xfs_error.h" | ||
21 | 22 | ||
22 | static struct ctl_table_header *xfs_table_header; | 23 | static struct ctl_table_header *xfs_table_header; |
23 | 24 | ||
@@ -51,6 +52,26 @@ xfs_stats_clear_proc_handler( | |||
51 | 52 | ||
52 | return ret; | 53 | return ret; |
53 | } | 54 | } |
55 | |||
56 | STATIC int | ||
57 | xfs_panic_mask_proc_handler( | ||
58 | ctl_table *ctl, | ||
59 | int write, | ||
60 | void __user *buffer, | ||
61 | size_t *lenp, | ||
62 | loff_t *ppos) | ||
63 | { | ||
64 | int ret, *valp = ctl->data; | ||
65 | |||
66 | ret = proc_dointvec_minmax(ctl, write, buffer, lenp, ppos); | ||
67 | if (!ret && write) { | ||
68 | xfs_panic_mask = *valp; | ||
69 | #ifdef DEBUG | ||
70 | xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES); | ||
71 | #endif | ||
72 | } | ||
73 | return ret; | ||
74 | } | ||
54 | #endif /* CONFIG_PROC_FS */ | 75 | #endif /* CONFIG_PROC_FS */ |
55 | 76 | ||
56 | static ctl_table xfs_table[] = { | 77 | static ctl_table xfs_table[] = { |
@@ -77,7 +98,7 @@ static ctl_table xfs_table[] = { | |||
77 | .data = &xfs_params.panic_mask.val, | 98 | .data = &xfs_params.panic_mask.val, |
78 | .maxlen = sizeof(int), | 99 | .maxlen = sizeof(int), |
79 | .mode = 0644, | 100 | .mode = 0644, |
80 | .proc_handler = proc_dointvec_minmax, | 101 | .proc_handler = xfs_panic_mask_proc_handler, |
81 | .extra1 = &xfs_params.panic_mask.min, | 102 | .extra1 = &xfs_params.panic_mask.min, |
82 | .extra2 = &xfs_params.panic_mask.max | 103 | .extra2 = &xfs_params.panic_mask.max |
83 | }, | 104 | }, |
diff --git a/fs/xfs/support/debug.c b/fs/xfs/support/debug.c index 86162e5f9a21..e6cf955ec0fc 100644 --- a/fs/xfs/support/debug.c +++ b/fs/xfs/support/debug.c | |||
@@ -25,80 +25,71 @@ | |||
25 | #include "xfs_mount.h" | 25 | #include "xfs_mount.h" |
26 | #include "xfs_error.h" | 26 | #include "xfs_error.h" |
27 | 27 | ||
28 | static char message[1024]; /* keep it off the stack */ | ||
29 | static DEFINE_SPINLOCK(xfs_err_lock); | ||
30 | |||
31 | /* Translate from CE_FOO to KERN_FOO, err_level(CE_FOO) == KERN_FOO */ | ||
32 | #define XFS_MAX_ERR_LEVEL 7 | ||
33 | #define XFS_ERR_MASK ((1 << 3) - 1) | ||
34 | static const char * const err_level[XFS_MAX_ERR_LEVEL+1] = | ||
35 | {KERN_EMERG, KERN_ALERT, KERN_CRIT, | ||
36 | KERN_ERR, KERN_WARNING, KERN_NOTICE, | ||
37 | KERN_INFO, KERN_DEBUG}; | ||
38 | |||
39 | void | 28 | void |
40 | cmn_err(register int level, char *fmt, ...) | 29 | cmn_err( |
30 | const char *lvl, | ||
31 | const char *fmt, | ||
32 | ...) | ||
41 | { | 33 | { |
42 | char *fp = fmt; | 34 | struct va_format vaf; |
43 | int len; | 35 | va_list args; |
44 | ulong flags; | 36 | |
45 | va_list ap; | 37 | va_start(args, fmt); |
46 | 38 | vaf.fmt = fmt; | |
47 | level &= XFS_ERR_MASK; | 39 | vaf.va = &args; |
48 | if (level > XFS_MAX_ERR_LEVEL) | 40 | |
49 | level = XFS_MAX_ERR_LEVEL; | 41 | printk("%s%pV", lvl, &vaf); |
50 | spin_lock_irqsave(&xfs_err_lock,flags); | 42 | va_end(args); |
51 | va_start(ap, fmt); | 43 | |
52 | if (*fmt == '!') fp++; | 44 | BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0); |
53 | len = vsnprintf(message, sizeof(message), fp, ap); | ||
54 | if (len >= sizeof(message)) | ||
55 | len = sizeof(message) - 1; | ||
56 | if (message[len-1] == '\n') | ||
57 | message[len-1] = 0; | ||
58 | printk("%s%s\n", err_level[level], message); | ||
59 | va_end(ap); | ||
60 | spin_unlock_irqrestore(&xfs_err_lock,flags); | ||
61 | BUG_ON(level == CE_PANIC); | ||
62 | } | 45 | } |
63 | 46 | ||
64 | void | 47 | void |
65 | xfs_fs_vcmn_err( | 48 | xfs_fs_cmn_err( |
66 | int level, | 49 | const char *lvl, |
67 | struct xfs_mount *mp, | 50 | struct xfs_mount *mp, |
68 | char *fmt, | 51 | const char *fmt, |
69 | va_list ap) | 52 | ...) |
70 | { | 53 | { |
71 | unsigned long flags; | 54 | struct va_format vaf; |
72 | int len = 0; | 55 | va_list args; |
73 | 56 | ||
74 | level &= XFS_ERR_MASK; | 57 | va_start(args, fmt); |
75 | if (level > XFS_MAX_ERR_LEVEL) | 58 | vaf.fmt = fmt; |
76 | level = XFS_MAX_ERR_LEVEL; | 59 | vaf.va = &args; |
77 | 60 | ||
78 | spin_lock_irqsave(&xfs_err_lock,flags); | 61 | printk("%sFilesystem %s: %pV", lvl, mp->m_fsname, &vaf); |
62 | va_end(args); | ||
79 | 63 | ||
80 | if (mp) { | 64 | BUG_ON(strncmp(lvl, KERN_EMERG, strlen(KERN_EMERG)) == 0); |
81 | len = sprintf(message, "Filesystem \"%s\": ", mp->m_fsname); | 65 | } |
66 | |||
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; | ||
82 | 79 | ||
83 | /* | 80 | if (xfs_panic_mask && (xfs_panic_mask & panic_tag)) { |
84 | * Skip the printk if we can't print anything useful | 81 | printk(KERN_ALERT "XFS: Transforming an alert into a BUG."); |
85 | * due to an over-long device name. | 82 | panic = 1; |
86 | */ | ||
87 | if (len >= sizeof(message)) | ||
88 | goto out; | ||
89 | } | 83 | } |
90 | 84 | ||
91 | len = vsnprintf(message + len, sizeof(message) - len, fmt, ap); | 85 | va_start(args, fmt); |
92 | if (len >= sizeof(message)) | 86 | vaf.fmt = fmt; |
93 | len = sizeof(message) - 1; | 87 | vaf.va = &args; |
94 | if (message[len-1] == '\n') | ||
95 | message[len-1] = 0; | ||
96 | 88 | ||
97 | printk("%s%s\n", err_level[level], message); | 89 | printk(KERN_ALERT "Filesystem %s: %pV", mp->m_fsname, &vaf); |
98 | out: | 90 | va_end(args); |
99 | spin_unlock_irqrestore(&xfs_err_lock,flags); | ||
100 | 91 | ||
101 | BUG_ON(level == CE_PANIC); | 92 | BUG_ON(panic); |
102 | } | 93 | } |
103 | 94 | ||
104 | void | 95 | void |
diff --git a/fs/xfs/support/debug.h b/fs/xfs/support/debug.h index d2d20462fd4f..05699f67d475 100644 --- a/fs/xfs/support/debug.h +++ b/fs/xfs/support/debug.h | |||
@@ -20,15 +20,22 @@ | |||
20 | 20 | ||
21 | #include <stdarg.h> | 21 | #include <stdarg.h> |
22 | 22 | ||
23 | #define CE_DEBUG 7 /* debug */ | 23 | struct xfs_mount; |
24 | #define CE_CONT 6 /* continuation */ | 24 | |
25 | #define CE_NOTE 5 /* notice */ | 25 | #define CE_DEBUG KERN_DEBUG |
26 | #define CE_WARN 4 /* warning */ | 26 | #define CE_CONT KERN_INFO |
27 | #define CE_ALERT 1 /* alert */ | 27 | #define CE_NOTE KERN_NOTICE |
28 | #define CE_PANIC 0 /* panic */ | 28 | #define CE_WARN KERN_WARNING |
29 | 29 | #define CE_ALERT KERN_ALERT | |
30 | extern void cmn_err(int, char *, ...) | 30 | #define CE_PANIC KERN_EMERG |
31 | __attribute__ ((format (printf, 2, 3))); | 31 | |
32 | void cmn_err(const char *lvl, const char *fmt, ...) | ||
33 | __attribute__ ((format (printf, 2, 3))); | ||
34 | void xfs_fs_cmn_err( const char *lvl, struct xfs_mount *mp, | ||
35 | const char *fmt, ...) __attribute__ ((format (printf, 3, 4))); | ||
36 | void xfs_cmn_err( int panic_tag, const char *lvl, struct xfs_mount *mp, | ||
37 | const char *fmt, ...) __attribute__ ((format (printf, 4, 5))); | ||
38 | |||
32 | extern void assfail(char *expr, char *f, int l); | 39 | extern void assfail(char *expr, char *f, int l); |
33 | 40 | ||
34 | #define ASSERT_ALWAYS(expr) \ | 41 | #define ASSERT_ALWAYS(expr) \ |
diff --git a/fs/xfs/xfs_error.c b/fs/xfs/xfs_error.c index c78cc6a3d87c..4c7db74a05f7 100644 --- a/fs/xfs/xfs_error.c +++ b/fs/xfs/xfs_error.c | |||
@@ -152,37 +152,6 @@ xfs_errortag_clearall(xfs_mount_t *mp, int loud) | |||
152 | } | 152 | } |
153 | #endif /* DEBUG */ | 153 | #endif /* DEBUG */ |
154 | 154 | ||
155 | |||
156 | void | ||
157 | xfs_fs_cmn_err(int level, xfs_mount_t *mp, char *fmt, ...) | ||
158 | { | ||
159 | va_list ap; | ||
160 | |||
161 | va_start(ap, fmt); | ||
162 | xfs_fs_vcmn_err(level, mp, fmt, ap); | ||
163 | va_end(ap); | ||
164 | } | ||
165 | |||
166 | void | ||
167 | xfs_cmn_err(int panic_tag, int level, xfs_mount_t *mp, char *fmt, ...) | ||
168 | { | ||
169 | va_list ap; | ||
170 | |||
171 | #ifdef DEBUG | ||
172 | xfs_panic_mask |= (XFS_PTAG_SHUTDOWN_CORRUPT | XFS_PTAG_LOGRES); | ||
173 | #endif | ||
174 | |||
175 | if (xfs_panic_mask && (xfs_panic_mask & panic_tag) | ||
176 | && (level & CE_ALERT)) { | ||
177 | level &= ~CE_ALERT; | ||
178 | level |= CE_PANIC; | ||
179 | cmn_err(CE_ALERT, "XFS: Transforming an alert into a BUG."); | ||
180 | } | ||
181 | va_start(ap, fmt); | ||
182 | xfs_fs_vcmn_err(level, mp, fmt, ap); | ||
183 | va_end(ap); | ||
184 | } | ||
185 | |||
186 | void | 155 | void |
187 | xfs_error_report( | 156 | xfs_error_report( |
188 | const char *tag, | 157 | const char *tag, |
diff --git a/fs/xfs/xfs_error.h b/fs/xfs/xfs_error.h index f338847f80b8..10dce5475f02 100644 --- a/fs/xfs/xfs_error.h +++ b/fs/xfs/xfs_error.h | |||
@@ -136,8 +136,8 @@ extern int xfs_error_test(int, int *, char *, int, char *, unsigned long); | |||
136 | xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \ | 136 | xfs_error_test((tag), (mp)->m_fixedfsid, "expr", __LINE__, __FILE__, \ |
137 | (rf)))) | 137 | (rf)))) |
138 | 138 | ||
139 | extern int xfs_errortag_add(int error_tag, xfs_mount_t *mp); | 139 | extern int xfs_errortag_add(int error_tag, struct xfs_mount *mp); |
140 | extern int xfs_errortag_clearall(xfs_mount_t *mp, int loud); | 140 | extern int xfs_errortag_clearall(struct xfs_mount *mp, int loud); |
141 | #else | 141 | #else |
142 | #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) | 142 | #define XFS_TEST_ERROR(expr, mp, tag, rf) (expr) |
143 | #define xfs_errortag_add(tag, mp) (ENOSYS) | 143 | #define xfs_errortag_add(tag, mp) (ENOSYS) |
@@ -162,21 +162,15 @@ extern int xfs_errortag_clearall(xfs_mount_t *mp, int loud); | |||
162 | 162 | ||
163 | struct xfs_mount; | 163 | struct xfs_mount; |
164 | 164 | ||
165 | extern void xfs_fs_vcmn_err(int level, struct xfs_mount *mp, | ||
166 | char *fmt, va_list ap) | ||
167 | __attribute__ ((format (printf, 3, 0))); | ||
168 | extern void xfs_cmn_err(int panic_tag, int level, struct xfs_mount *mp, | ||
169 | char *fmt, ...) | ||
170 | __attribute__ ((format (printf, 4, 5))); | ||
171 | extern void xfs_fs_cmn_err(int level, struct xfs_mount *mp, char *fmt, ...) | ||
172 | __attribute__ ((format (printf, 3, 4))); | ||
173 | |||
174 | extern void xfs_hex_dump(void *p, int length); | 165 | extern void xfs_hex_dump(void *p, int length); |
175 | 166 | ||
176 | #define xfs_fs_repair_cmn_err(level, mp, fmt, args...) \ | 167 | #define xfs_fs_repair_cmn_err(level, mp, fmt, args...) \ |
177 | xfs_fs_cmn_err(level, mp, fmt " Unmount and run xfs_repair.", ## args) | 168 | xfs_fs_cmn_err(level, mp, fmt " Unmount and run xfs_repair.", ## args) |
178 | 169 | ||
179 | #define xfs_fs_mount_cmn_err(f, fmt, args...) \ | 170 | #define xfs_fs_mount_cmn_err(f, fmt, args...) \ |
180 | ((f & XFS_MFSI_QUIET)? (void)0 : cmn_err(CE_WARN, "XFS: " fmt, ## args)) | 171 | do { \ |
172 | if (!(f & XFS_MFSI_QUIET)) \ | ||
173 | cmn_err(CE_WARN, "XFS: " fmt, ## args); \ | ||
174 | } while (0) | ||
181 | 175 | ||
182 | #endif /* __XFS_ERROR_H__ */ | 176 | #endif /* __XFS_ERROR_H__ */ |
diff --git a/fs/xfs/xfs_log.c b/fs/xfs/xfs_log.c index 0bf24b11d0c4..ae6fef1ff563 100644 --- a/fs/xfs/xfs_log.c +++ b/fs/xfs/xfs_log.c | |||
@@ -377,7 +377,7 @@ xfs_log_mount( | |||
377 | cmn_err(CE_NOTE, "XFS mounting filesystem %s", mp->m_fsname); | 377 | cmn_err(CE_NOTE, "XFS mounting filesystem %s", mp->m_fsname); |
378 | else { | 378 | else { |
379 | cmn_err(CE_NOTE, | 379 | cmn_err(CE_NOTE, |
380 | "!Mounting filesystem \"%s\" in no-recovery mode. Filesystem will be inconsistent.", | 380 | "Mounting filesystem \"%s\" in no-recovery mode. Filesystem will be inconsistent.", |
381 | mp->m_fsname); | 381 | mp->m_fsname); |
382 | ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); | 382 | ASSERT(mp->m_flags & XFS_MOUNT_RDONLY); |
383 | } | 383 | } |
diff --git a/fs/xfs/xfs_log_recover.c b/fs/xfs/xfs_log_recover.c index 204d8e5fa7fa..aa0ebb776903 100644 --- a/fs/xfs/xfs_log_recover.c +++ b/fs/xfs/xfs_log_recover.c | |||
@@ -3800,7 +3800,7 @@ xlog_recover_finish( | |||
3800 | log->l_flags &= ~XLOG_RECOVERY_NEEDED; | 3800 | log->l_flags &= ~XLOG_RECOVERY_NEEDED; |
3801 | } else { | 3801 | } else { |
3802 | cmn_err(CE_DEBUG, | 3802 | cmn_err(CE_DEBUG, |
3803 | "!Ending clean XFS mount for filesystem: %s\n", | 3803 | "Ending clean XFS mount for filesystem: %s\n", |
3804 | log->l_mp->m_fsname); | 3804 | log->l_mp->m_fsname); |
3805 | } | 3805 | } |
3806 | return 0; | 3806 | return 0; |