diff options
author | Fabian Frederick <fabf@skynet.be> | 2014-04-07 18:36:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-04-07 19:35:49 -0400 |
commit | 87c1b497c299e48e681f041de4dd6ce4831aaf75 (patch) | |
tree | d91b138e1601db9e06377649515dc4aa4d3f8186 /fs/ntfs/debug.c | |
parent | 2b3a8fd735f86ebeb2b9d061054003000c36b654 (diff) |
ntfs: logging clean-up
- Convert spinlock/static array to va_format (inspired by Joe Perches
help on previous logging patches).
- Convert printk(KERN_ERR to pr_warn in __ntfs_warning.
- Convert printk(KERN_ERR to pr_err in __ntfs_error.
- Convert printk(KERN_DEBUG to pr_debug in __ntfs_debug. (Note that
__ntfs_debug is still guarded by #if DEBUG)
- Improve !DEBUG to parse all arguments (Joe Perches).
- Sparse pr_foo() conversions in super.c
NTFS, NTFS-fs prefixes as well as 'warning' and 'error' were removed :
pr_foo() automatically adds module name and error level is already
specified.
Signed-off-by: Fabian Frederick <fabf@skynet.be>
Cc: Anton Altaparmakov <anton@tuxera.com>
Cc: Joe Perches <joe@perches.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/ntfs/debug.c')
-rw-r--r-- | fs/ntfs/debug.c | 58 |
1 files changed, 24 insertions, 34 deletions
diff --git a/fs/ntfs/debug.c b/fs/ntfs/debug.c index 807150e2c2b9..dd6103cc93c1 100644 --- a/fs/ntfs/debug.c +++ b/fs/ntfs/debug.c | |||
@@ -18,16 +18,9 @@ | |||
18 | * distribution in the file COPYING); if not, write to the Free Software | 18 | * distribution in the file COPYING); if not, write to the Free Software |
19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | 19 | * Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
20 | */ | 20 | */ |
21 | 21 | #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt | |
22 | #include "debug.h" | 22 | #include "debug.h" |
23 | 23 | ||
24 | /* | ||
25 | * A static buffer to hold the error string being displayed and a spinlock | ||
26 | * to protect concurrent accesses to it. | ||
27 | */ | ||
28 | static char err_buf[1024]; | ||
29 | static DEFINE_SPINLOCK(err_buf_lock); | ||
30 | |||
31 | /** | 24 | /** |
32 | * __ntfs_warning - output a warning to the syslog | 25 | * __ntfs_warning - output a warning to the syslog |
33 | * @function: name of function outputting the warning | 26 | * @function: name of function outputting the warning |
@@ -50,6 +43,7 @@ static DEFINE_SPINLOCK(err_buf_lock); | |||
50 | void __ntfs_warning(const char *function, const struct super_block *sb, | 43 | void __ntfs_warning(const char *function, const struct super_block *sb, |
51 | const char *fmt, ...) | 44 | const char *fmt, ...) |
52 | { | 45 | { |
46 | struct va_format vaf; | ||
53 | va_list args; | 47 | va_list args; |
54 | int flen = 0; | 48 | int flen = 0; |
55 | 49 | ||
@@ -59,17 +53,15 @@ void __ntfs_warning(const char *function, const struct super_block *sb, | |||
59 | #endif | 53 | #endif |
60 | if (function) | 54 | if (function) |
61 | flen = strlen(function); | 55 | flen = strlen(function); |
62 | spin_lock(&err_buf_lock); | ||
63 | va_start(args, fmt); | 56 | va_start(args, fmt); |
64 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 57 | vaf.fmt = fmt; |
65 | va_end(args); | 58 | vaf.va = &args; |
66 | if (sb) | 59 | if (sb) |
67 | printk(KERN_ERR "NTFS-fs warning (device %s): %s(): %s\n", | 60 | pr_warn("(device %s): %s(): %pV\n", |
68 | sb->s_id, flen ? function : "", err_buf); | 61 | sb->s_id, flen ? function : "", &vaf); |
69 | else | 62 | else |
70 | printk(KERN_ERR "NTFS-fs warning: %s(): %s\n", | 63 | pr_warn("%s(): %pV\n", flen ? function : "", &vaf); |
71 | flen ? function : "", err_buf); | 64 | va_end(args); |
72 | spin_unlock(&err_buf_lock); | ||
73 | } | 65 | } |
74 | 66 | ||
75 | /** | 67 | /** |
@@ -94,6 +86,7 @@ void __ntfs_warning(const char *function, const struct super_block *sb, | |||
94 | void __ntfs_error(const char *function, const struct super_block *sb, | 86 | void __ntfs_error(const char *function, const struct super_block *sb, |
95 | const char *fmt, ...) | 87 | const char *fmt, ...) |
96 | { | 88 | { |
89 | struct va_format vaf; | ||
97 | va_list args; | 90 | va_list args; |
98 | int flen = 0; | 91 | int flen = 0; |
99 | 92 | ||
@@ -103,17 +96,15 @@ void __ntfs_error(const char *function, const struct super_block *sb, | |||
103 | #endif | 96 | #endif |
104 | if (function) | 97 | if (function) |
105 | flen = strlen(function); | 98 | flen = strlen(function); |
106 | spin_lock(&err_buf_lock); | ||
107 | va_start(args, fmt); | 99 | va_start(args, fmt); |
108 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 100 | vaf.fmt = fmt; |
109 | va_end(args); | 101 | vaf.va = &args; |
110 | if (sb) | 102 | if (sb) |
111 | printk(KERN_ERR "NTFS-fs error (device %s): %s(): %s\n", | 103 | pr_err("(device %s): %s(): %pV\n", |
112 | sb->s_id, flen ? function : "", err_buf); | 104 | sb->s_id, flen ? function : "", &vaf); |
113 | else | 105 | else |
114 | printk(KERN_ERR "NTFS-fs error: %s(): %s\n", | 106 | pr_err("%s(): %pV\n", flen ? function : "", &vaf); |
115 | flen ? function : "", err_buf); | 107 | va_end(args); |
116 | spin_unlock(&err_buf_lock); | ||
117 | } | 108 | } |
118 | 109 | ||
119 | #ifdef DEBUG | 110 | #ifdef DEBUG |
@@ -124,6 +115,7 @@ int debug_msgs = 0; | |||
124 | void __ntfs_debug (const char *file, int line, const char *function, | 115 | void __ntfs_debug (const char *file, int line, const char *function, |
125 | const char *fmt, ...) | 116 | const char *fmt, ...) |
126 | { | 117 | { |
118 | struct va_format vaf; | ||
127 | va_list args; | 119 | va_list args; |
128 | int flen = 0; | 120 | int flen = 0; |
129 | 121 | ||
@@ -131,13 +123,11 @@ void __ntfs_debug (const char *file, int line, const char *function, | |||
131 | return; | 123 | return; |
132 | if (function) | 124 | if (function) |
133 | flen = strlen(function); | 125 | flen = strlen(function); |
134 | spin_lock(&err_buf_lock); | ||
135 | va_start(args, fmt); | 126 | va_start(args, fmt); |
136 | vsnprintf(err_buf, sizeof(err_buf), fmt, args); | 127 | vaf.fmt = fmt; |
128 | vaf.va = &args; | ||
129 | pr_debug("(%s, %d): %s(): %pV", file, line, flen ? function : "", &vaf); | ||
137 | va_end(args); | 130 | va_end(args); |
138 | printk(KERN_DEBUG "NTFS-fs DEBUG (%s, %d): %s(): %s\n", file, line, | ||
139 | flen ? function : "", err_buf); | ||
140 | spin_unlock(&err_buf_lock); | ||
141 | } | 131 | } |
142 | 132 | ||
143 | /* Dump a runlist. Caller has to provide synchronisation for @rl. */ | 133 | /* Dump a runlist. Caller has to provide synchronisation for @rl. */ |
@@ -149,12 +139,12 @@ void ntfs_debug_dump_runlist(const runlist_element *rl) | |||
149 | 139 | ||
150 | if (!debug_msgs) | 140 | if (!debug_msgs) |
151 | return; | 141 | return; |
152 | printk(KERN_DEBUG "NTFS-fs DEBUG: Dumping runlist (values in hex):\n"); | 142 | pr_debug("Dumping runlist (values in hex):\n"); |
153 | if (!rl) { | 143 | if (!rl) { |
154 | printk(KERN_DEBUG "Run list not present.\n"); | 144 | pr_debug("Run list not present.\n"); |
155 | return; | 145 | return; |
156 | } | 146 | } |
157 | printk(KERN_DEBUG "VCN LCN Run length\n"); | 147 | pr_debug("VCN LCN Run length\n"); |
158 | for (i = 0; ; i++) { | 148 | for (i = 0; ; i++) { |
159 | LCN lcn = (rl + i)->lcn; | 149 | LCN lcn = (rl + i)->lcn; |
160 | 150 | ||
@@ -163,13 +153,13 @@ void ntfs_debug_dump_runlist(const runlist_element *rl) | |||
163 | 153 | ||
164 | if (index > -LCN_ENOENT - 1) | 154 | if (index > -LCN_ENOENT - 1) |
165 | index = 3; | 155 | index = 3; |
166 | printk(KERN_DEBUG "%-16Lx %s %-16Lx%s\n", | 156 | pr_debug("%-16Lx %s %-16Lx%s\n", |
167 | (long long)(rl + i)->vcn, lcn_str[index], | 157 | (long long)(rl + i)->vcn, lcn_str[index], |
168 | (long long)(rl + i)->length, | 158 | (long long)(rl + i)->length, |
169 | (rl + i)->length ? "" : | 159 | (rl + i)->length ? "" : |
170 | " (runlist end)"); | 160 | " (runlist end)"); |
171 | } else | 161 | } else |
172 | printk(KERN_DEBUG "%-16Lx %-16Lx %-16Lx%s\n", | 162 | pr_debug("%-16Lx %-16Lx %-16Lx%s\n", |
173 | (long long)(rl + i)->vcn, | 163 | (long long)(rl + i)->vcn, |
174 | (long long)(rl + i)->lcn, | 164 | (long long)(rl + i)->lcn, |
175 | (long long)(rl + i)->length, | 165 | (long long)(rl + i)->length, |