diff options
author | Joe Perches <joe@perches.com> | 2012-07-30 17:40:13 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-07-30 20:25:14 -0400 |
commit | 533574c6bc30cf526cc1c41bde050c854a945efb (patch) | |
tree | 0e019132044f1c8b4a46c33adba3445a2730c5a7 /fs/btrfs/super.c | |
parent | 0cc41e4a21d43695154fe6a151abf3b6f27b0bb0 (diff) |
btrfs: use printk_get_level and printk_skip_level, add __printf, fix fallout
Use the generic printk_get_level() to search a message for a kern_level.
Add __printf to verify format and arguments. Fix a few messages that
had mismatches in format and arguments. Add #ifdef CONFIG_PRINTK blocks
to shrink the object size a bit when not using printk.
[akpm@linux-foundation.org: whitespace tweak]
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Kay Sievers <kay.sievers@vrfy.org>
Cc: Chris Mason <chris.mason@oracle.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 41 |
1 files changed, 35 insertions, 6 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index fa61ef59cd61..8c6e61d6eed5 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -125,6 +125,7 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info) | |||
125 | } | 125 | } |
126 | } | 126 | } |
127 | 127 | ||
128 | #ifdef CONFIG_PRINTK | ||
128 | /* | 129 | /* |
129 | * __btrfs_std_error decodes expected errors from the caller and | 130 | * __btrfs_std_error decodes expected errors from the caller and |
130 | * invokes the approciate error response. | 131 | * invokes the approciate error response. |
@@ -167,7 +168,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | |||
167 | va_end(args); | 168 | va_end(args); |
168 | } | 169 | } |
169 | 170 | ||
170 | const char *logtypes[] = { | 171 | static const char * const logtypes[] = { |
171 | "emergency", | 172 | "emergency", |
172 | "alert", | 173 | "alert", |
173 | "critical", | 174 | "critical", |
@@ -185,22 +186,50 @@ void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...) | |||
185 | struct va_format vaf; | 186 | struct va_format vaf; |
186 | va_list args; | 187 | va_list args; |
187 | const char *type = logtypes[4]; | 188 | const char *type = logtypes[4]; |
189 | int kern_level; | ||
188 | 190 | ||
189 | va_start(args, fmt); | 191 | va_start(args, fmt); |
190 | 192 | ||
191 | if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') { | 193 | kern_level = printk_get_level(fmt); |
192 | memcpy(lvl, fmt, 3); | 194 | if (kern_level) { |
193 | lvl[3] = '\0'; | 195 | size_t size = printk_skip_level(fmt) - fmt; |
194 | fmt += 3; | 196 | memcpy(lvl, fmt, size); |
195 | type = logtypes[fmt[1] - '0']; | 197 | lvl[size] = '\0'; |
198 | fmt += size; | ||
199 | type = logtypes[kern_level - '0']; | ||
196 | } else | 200 | } else |
197 | *lvl = '\0'; | 201 | *lvl = '\0'; |
198 | 202 | ||
199 | vaf.fmt = fmt; | 203 | vaf.fmt = fmt; |
200 | vaf.va = &args; | 204 | vaf.va = &args; |
205 | |||
201 | printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf); | 206 | printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf); |
207 | |||
208 | va_end(args); | ||
202 | } | 209 | } |
203 | 210 | ||
211 | #else | ||
212 | |||
213 | void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, | ||
214 | unsigned int line, int errno, const char *fmt, ...) | ||
215 | { | ||
216 | struct super_block *sb = fs_info->sb; | ||
217 | |||
218 | /* | ||
219 | * Special case: if the error is EROFS, and we're already | ||
220 | * under MS_RDONLY, then it is safe here. | ||
221 | */ | ||
222 | if (errno == -EROFS && (sb->s_flags & MS_RDONLY)) | ||
223 | return; | ||
224 | |||
225 | /* Don't go through full error handling during mount */ | ||
226 | if (sb->s_flags & MS_BORN) { | ||
227 | save_error_info(fs_info); | ||
228 | btrfs_handle_error(fs_info); | ||
229 | } | ||
230 | } | ||
231 | #endif | ||
232 | |||
204 | /* | 233 | /* |
205 | * We only mark the transaction aborted and then set the file system read-only. | 234 | * We only mark the transaction aborted and then set the file system read-only. |
206 | * This will prevent new transactions from starting or trying to join this | 235 | * This will prevent new transactions from starting or trying to join this |