aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2012-07-30 17:40:13 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2012-07-30 20:25:14 -0400
commit533574c6bc30cf526cc1c41bde050c854a945efb (patch)
tree0e019132044f1c8b4a46c33adba3445a2730c5a7
parent0cc41e4a21d43695154fe6a151abf3b6f27b0bb0 (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>
-rw-r--r--fs/btrfs/ctree.h13
-rw-r--r--fs/btrfs/disk-io.c2
-rw-r--r--fs/btrfs/relocation.c2
-rw-r--r--fs/btrfs/super.c41
4 files changed, 50 insertions, 8 deletions
diff --git a/fs/btrfs/ctree.h b/fs/btrfs/ctree.h
index adb1cd7ceb9..4bab807227a 100644
--- a/fs/btrfs/ctree.h
+++ b/fs/btrfs/ctree.h
@@ -3342,10 +3342,22 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
3342/* super.c */ 3342/* super.c */
3343int btrfs_parse_options(struct btrfs_root *root, char *options); 3343int btrfs_parse_options(struct btrfs_root *root, char *options);
3344int btrfs_sync_fs(struct super_block *sb, int wait); 3344int btrfs_sync_fs(struct super_block *sb, int wait);
3345
3346#ifdef CONFIG_PRINTK
3347__printf(2, 3)
3345void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...); 3348void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...);
3349#else
3350static inline __printf(2, 3)
3351void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...)
3352{
3353}
3354#endif
3355
3356__printf(5, 6)
3346void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function, 3357void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
3347 unsigned int line, int errno, const char *fmt, ...); 3358 unsigned int line, int errno, const char *fmt, ...);
3348 3359
3360
3349void __btrfs_abort_transaction(struct btrfs_trans_handle *trans, 3361void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
3350 struct btrfs_root *root, const char *function, 3362 struct btrfs_root *root, const char *function,
3351 unsigned int line, int errno); 3363 unsigned int line, int errno);
@@ -3386,6 +3398,7 @@ do { \
3386 (errno), fmt, ##args); \ 3398 (errno), fmt, ##args); \
3387} while (0) 3399} while (0)
3388 3400
3401__printf(5, 6)
3389void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function, 3402void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
3390 unsigned int line, int errno, const char *fmt, ...); 3403 unsigned int line, int errno, const char *fmt, ...);
3391 3404
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 502b20c56e8..fadeba6a5db 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -1114,7 +1114,7 @@ void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
1114 spin_unlock(&root->fs_info->delalloc_lock); 1114 spin_unlock(&root->fs_info->delalloc_lock);
1115 btrfs_panic(root->fs_info, -EOVERFLOW, 1115 btrfs_panic(root->fs_info, -EOVERFLOW,
1116 "Can't clear %lu bytes from " 1116 "Can't clear %lu bytes from "
1117 " dirty_mdatadata_bytes (%lu)", 1117 " dirty_mdatadata_bytes (%llu)",
1118 buf->len, 1118 buf->len,
1119 root->fs_info->dirty_metadata_bytes); 1119 root->fs_info->dirty_metadata_bytes);
1120 } 1120 }
diff --git a/fs/btrfs/relocation.c b/fs/btrfs/relocation.c
index c5dbd914967..4da08652004 100644
--- a/fs/btrfs/relocation.c
+++ b/fs/btrfs/relocation.c
@@ -1241,7 +1241,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
1241 if (rb_node) { 1241 if (rb_node) {
1242 btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found " 1242 btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
1243 "for start=%llu while inserting into relocation " 1243 "for start=%llu while inserting into relocation "
1244 "tree\n"); 1244 "tree\n", node->bytenr);
1245 kfree(node); 1245 kfree(node);
1246 return -EEXIST; 1246 return -EEXIST;
1247 } 1247 }
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c
index fa61ef59cd6..8c6e61d6eed 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
170const char *logtypes[] = { 171static 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
213void __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