mirror of
https://github.com/torvalds/linux.git
synced 2026-05-28 17:13:52 +02:00
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>
This commit is contained in:
parent
0cc41e4a21
commit
533574c6bc
|
|
@ -3342,10 +3342,22 @@ ssize_t btrfs_listxattr(struct dentry *dentry, char *buffer, size_t size);
|
||||||
/* super.c */
|
/* super.c */
|
||||||
int btrfs_parse_options(struct btrfs_root *root, char *options);
|
int btrfs_parse_options(struct btrfs_root *root, char *options);
|
||||||
int btrfs_sync_fs(struct super_block *sb, int wait);
|
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, ...);
|
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,
|
void __btrfs_std_error(struct btrfs_fs_info *fs_info, const char *function,
|
||||||
unsigned int line, int errno, const char *fmt, ...);
|
unsigned int line, int errno, const char *fmt, ...);
|
||||||
|
|
||||||
|
|
||||||
void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
|
void __btrfs_abort_transaction(struct btrfs_trans_handle *trans,
|
||||||
struct btrfs_root *root, const char *function,
|
struct btrfs_root *root, const char *function,
|
||||||
unsigned int line, int errno);
|
unsigned int line, int errno);
|
||||||
|
|
@ -3386,6 +3398,7 @@ do { \
|
||||||
(errno), fmt, ##args); \
|
(errno), fmt, ##args); \
|
||||||
} while (0)
|
} while (0)
|
||||||
|
|
||||||
|
__printf(5, 6)
|
||||||
void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
|
void __btrfs_panic(struct btrfs_fs_info *fs_info, const char *function,
|
||||||
unsigned int line, int errno, const char *fmt, ...);
|
unsigned int line, int errno, const char *fmt, ...);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1114,7 +1114,7 @@ void clean_tree_block(struct btrfs_trans_handle *trans, struct btrfs_root *root,
|
||||||
spin_unlock(&root->fs_info->delalloc_lock);
|
spin_unlock(&root->fs_info->delalloc_lock);
|
||||||
btrfs_panic(root->fs_info, -EOVERFLOW,
|
btrfs_panic(root->fs_info, -EOVERFLOW,
|
||||||
"Can't clear %lu bytes from "
|
"Can't clear %lu bytes from "
|
||||||
" dirty_mdatadata_bytes (%lu)",
|
" dirty_mdatadata_bytes (%llu)",
|
||||||
buf->len,
|
buf->len,
|
||||||
root->fs_info->dirty_metadata_bytes);
|
root->fs_info->dirty_metadata_bytes);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1241,7 +1241,7 @@ static int __must_check __add_reloc_root(struct btrfs_root *root)
|
||||||
if (rb_node) {
|
if (rb_node) {
|
||||||
btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
|
btrfs_panic(root->fs_info, -EEXIST, "Duplicate root found "
|
||||||
"for start=%llu while inserting into relocation "
|
"for start=%llu while inserting into relocation "
|
||||||
"tree\n");
|
"tree\n", node->bytenr);
|
||||||
kfree(node);
|
kfree(node);
|
||||||
return -EEXIST;
|
return -EEXIST;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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
|
* __btrfs_std_error decodes expected errors from the caller and
|
||||||
* invokes the approciate error response.
|
* 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);
|
va_end(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *logtypes[] = {
|
static const char * const logtypes[] = {
|
||||||
"emergency",
|
"emergency",
|
||||||
"alert",
|
"alert",
|
||||||
"critical",
|
"critical",
|
||||||
|
|
@ -185,22 +186,50 @@ void btrfs_printk(struct btrfs_fs_info *fs_info, const char *fmt, ...)
|
||||||
struct va_format vaf;
|
struct va_format vaf;
|
||||||
va_list args;
|
va_list args;
|
||||||
const char *type = logtypes[4];
|
const char *type = logtypes[4];
|
||||||
|
int kern_level;
|
||||||
|
|
||||||
va_start(args, fmt);
|
va_start(args, fmt);
|
||||||
|
|
||||||
if (fmt[0] == '<' && isdigit(fmt[1]) && fmt[2] == '>') {
|
kern_level = printk_get_level(fmt);
|
||||||
memcpy(lvl, fmt, 3);
|
if (kern_level) {
|
||||||
lvl[3] = '\0';
|
size_t size = printk_skip_level(fmt) - fmt;
|
||||||
fmt += 3;
|
memcpy(lvl, fmt, size);
|
||||||
type = logtypes[fmt[1] - '0'];
|
lvl[size] = '\0';
|
||||||
|
fmt += size;
|
||||||
|
type = logtypes[kern_level - '0'];
|
||||||
} else
|
} else
|
||||||
*lvl = '\0';
|
*lvl = '\0';
|
||||||
|
|
||||||
vaf.fmt = fmt;
|
vaf.fmt = fmt;
|
||||||
vaf.va = &args;
|
vaf.va = &args;
|
||||||
|
|
||||||
printk("%sBTRFS %s (device %s): %pV", lvl, type, sb->s_id, &vaf);
|
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.
|
* 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
|
* This will prevent new transactions from starting or trying to join this
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user