aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>2016-08-02 17:05:02 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2016-08-02 19:35:16 -0400
commita66dfb0a91c211c77b5d4e503d3e760e2e566189 (patch)
treedfb792395b32499bd1c9e7175e103a5b1c693bb0
parentcae3d4ca6fd6872d8e9c21eff0e56398c938100a (diff)
nilfs2: add nilfs_msg() message interface
Define an own output routine to replace bare use of printk() function. The output routine is implemented with a macro and a helper function, which are named nilfs_msg() and __nilfs_msg(), respectively. __nilfs_msg() formats a message like "NILFS (<device-name>): <message>", prefixing it with a given log level, and terminates the statement with a newline. The "device-name" is optional to make it available in early stages; it will be omitted if a NULL pointer is passed to super block instance argument. nilfs_msg() wraps __nilfs_msg() and is removed if CONFIG_PRINTK is not set. Link: http://lkml.kernel.org/r/1464875891-5443-3-git-send-email-konishi.ryusuke@lab.ntt.co.jp Signed-off-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/nilfs2/nilfs.h7
-rw-r--r--fs/nilfs2/super.c16
2 files changed, 23 insertions, 0 deletions
diff --git a/fs/nilfs2/nilfs.h b/fs/nilfs2/nilfs.h
index e482c78bcc86..b57ce41e8a1a 100644
--- a/fs/nilfs2/nilfs.h
+++ b/fs/nilfs2/nilfs.h
@@ -301,6 +301,9 @@ extern struct inode *nilfs_alloc_inode(struct super_block *);
301extern void nilfs_destroy_inode(struct inode *); 301extern void nilfs_destroy_inode(struct inode *);
302 302
303extern __printf(3, 4) 303extern __printf(3, 4)
304void __nilfs_msg(struct super_block *sb, const char *level,
305 const char *fmt, ...);
306extern __printf(3, 4)
304void __nilfs_error(struct super_block *sb, const char *function, 307void __nilfs_error(struct super_block *sb, const char *function,
305 const char *fmt, ...); 308 const char *fmt, ...);
306extern __printf(3, 4) 309extern __printf(3, 4)
@@ -308,11 +311,15 @@ void nilfs_warning(struct super_block *, const char *, const char *, ...);
308 311
309#ifdef CONFIG_PRINTK 312#ifdef CONFIG_PRINTK
310 313
314#define nilfs_msg(sb, level, fmt, ...) \
315 __nilfs_msg(sb, level, fmt, ##__VA_ARGS__)
311#define nilfs_error(sb, fmt, ...) \ 316#define nilfs_error(sb, fmt, ...) \
312 __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__) 317 __nilfs_error(sb, __func__, fmt, ##__VA_ARGS__)
313 318
314#else 319#else
315 320
321#define nilfs_msg(sb, level, fmt, ...) \
322 no_printk(fmt, ##__VA_ARGS__)
316#define nilfs_error(sb, fmt, ...) \ 323#define nilfs_error(sb, fmt, ...) \
317 do { \ 324 do { \
318 no_printk(fmt, ##__VA_ARGS__); \ 325 no_printk(fmt, ##__VA_ARGS__); \
diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c
index 7fe497eb2181..86e3c00994e2 100644
--- a/fs/nilfs2/super.c
+++ b/fs/nilfs2/super.c
@@ -71,6 +71,22 @@ struct kmem_cache *nilfs_btree_path_cache;
71static int nilfs_setup_super(struct super_block *sb, int is_mount); 71static int nilfs_setup_super(struct super_block *sb, int is_mount);
72static int nilfs_remount(struct super_block *sb, int *flags, char *data); 72static int nilfs_remount(struct super_block *sb, int *flags, char *data);
73 73
74void __nilfs_msg(struct super_block *sb, const char *level, const char *fmt,
75 ...)
76{
77 struct va_format vaf;
78 va_list args;
79
80 va_start(args, fmt);
81 vaf.fmt = fmt;
82 vaf.va = &args;
83 if (sb)
84 printk("%sNILFS (%s): %pV\n", level, sb->s_id, &vaf);
85 else
86 printk("%sNILFS: %pV\n", level, &vaf);
87 va_end(args);
88}
89
74static void nilfs_set_error(struct super_block *sb) 90static void nilfs_set_error(struct super_block *sb)
75{ 91{
76 struct the_nilfs *nilfs = sb->s_fs_info; 92 struct the_nilfs *nilfs = sb->s_fs_info;