]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
btrfs: use printk_get_level and printk_skip_level, add __printf, fix fallout
authorJoe Perches <joe@perches.com>
Mon, 30 Jul 2012 21:40:13 +0000 (14:40 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 31 Jul 2012 00:25:14 +0000 (17:25 -0700)
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>
fs/btrfs/ctree.h
fs/btrfs/disk-io.c
fs/btrfs/relocation.c
fs/btrfs/super.c

index adb1cd7ceb9b954af34457efc2d119fb422c6f4f..4bab807227ad938c87039ea2aa1ef8f94fe46146 100644 (file)
@@ -3342,10 +3342,22 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
 /* super.c */
 int btrfs_parse_options(struct btrfs_root *root, char *options);
 int btrfs_sync_fs(struct super_block *sb, int wait);
+
+#ifdef CONFIG_PRINTK
+__printf(2, 3)
 void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...);
+#else
+static inline __printf(2, 3)
+void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...)
+{
+}
+#endif
+
+__printf(5, 6)
 void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
                     unsigned int line, int errno, const char *fmt, ...);
 
+
 void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
                               struct btrfs_root *root, const char *function,
                               unsigned int line, int errno);
@@ -3386,6 +3398,7 @@ do {                                                              \
                          (errno), fmt, ##args);                \
 } while (0)
 
+__printf(5, 6)
 void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
                   unsigned int line, int errno, const char *fmt, ...);
 
index 502b20c56e848f4df3ede188a408d535de5b4173..fadeba6a5db964c61ab7d795feb18f31347671c2 100644 (file)
@@ -1114,7 +1114,7 @@ void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
                                spin_unlock(&root->fs_info->delalloc_lock);
                                btrfs_panic(root->fs_info, -EOVERFLOW,
                                          "Can't clear %lu bytes from "
-                                         " dirty_mdatadata_bytes (%lu)",
+                                         " dirty_mdatadata_bytes (%llu)",
                                          buf->len,
                                          root->fs_info->dirty_metadata_bytes);
                        }
index c5dbd91496790a3279b8044552f6664666b68a52..4da08652004d5dc2803dba510c0f9b015607b4a1 100644 (file)
@@ -1241,7 +1241,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
        if (rb_node) {
                btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
                            "for start=%llu while inserting into relocation "
-                           "tree\n");
+                           "tree\n", node->bytenr);
                kfree(node);
                return -EEXIST;
        }
index fa61ef59cd61aadf7582ce8f73cdff298331b47f..8c6e61d6eed5b754945930fbaaaaf21d6f98d028 100644 (file)
@@ -125,6 +125,7 @@ static void btrfs_handle_error(struct btrfs_fs_info *fs_info)
        }
 }
 
+#ifdef CONFIG_PRINTK
 /*
  * __btrfs_std_error decodes expected errors from the caller and
  * invokes the approciate error response.
@@ -167,7 +168,7 @@ void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
        va_end(args);
 }
 
-const char *logtypes[] = {
+static const char * const logtypes[] = {
        "emergency",
        "alert",
        "critical",
@@ -185,22 +186,50 @@ void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...)
        struct va_format vaf;
        va_list args;
        const char *type = logtypes[4];
+       int kern_level;
 
        va_start(args, fmt);
 
-       if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') {
-               memcpy(lvl, fmt, 3);
-               lvl[3] = '\0';
-               fmt += 3;
-               type = logtypes[fmt[1] - '0'];
+       kern_level = printk_get_level(fmt);
+       if (kern_level) {
+               size_t size = printk_skip_level(fmt) - fmt;
+               memcpy(lvl, fmt,  size);
+               lvl[size] = '\0';
+               fmt += size;
+               type = logtypes[kern_level - '0'];
        } else
                *lvl = '\0';
 
        vaf.fmt = fmt;
        vaf.va = &args;
+
        printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf);
+
+       va_end(args);
 }
 
+#else
+
+void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
+                      unsigned int line, int errno, const char *fmt, ...)
+{
+       struct super_block *sb = fs_info->sb;
+
+       /*
+        * Special case: if the error is EROFS, and we're already
+        * under MS_RDONLY, then it is safe here.
+        */
+       if (errno == -EROFS && (sb->s_flags & MS_RDONLY))
+               return;
+
+       /* Don't go through full error handling during mount */
+       if (sb->s_flags & MS_BORN) {
+               save_error_info(fs_info);
+               btrfs_handle_error(fs_info);
+       }
+}
+#endif
+
 /*
  * We only mark the transaction aborted and then set the file system read-only.
  * This will prevent new transactions from starting or trying to join this