Skip to content

Commit a66dfb0

Browse files
konistorvalds
authored andcommitted
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/[email protected] Signed-off-by: Ryusuke Konishi <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent cae3d4c commit a66dfb0

File tree

2 files changed

+23
-0
lines changed

2 files changed

+23
-0
lines changed

fs/nilfs2/nilfs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ static inline int nilfs_mark_inode_dirty_sync(struct inode *inode)
300300
extern struct inode *nilfs_alloc_inode(struct super_block *);
301301
extern void nilfs_destroy_inode(struct inode *);
302302

303+
extern __printf(3, 4)
304+
void __nilfs_msg(struct super_block *sb, const char *level,
305+
const char *fmt, ...);
303306
extern __printf(3, 4)
304307
void __nilfs_error(struct super_block *sb, const char *function,
305308
const char *fmt, ...);
@@ -308,11 +311,15 @@ void nilfs_warning(struct super_block *, const char *, const char *, ...);
308311

309312
#ifdef CONFIG_PRINTK
310313

314+
#define nilfs_msg(sb, level, fmt, ...) \
315+
__nilfs_msg(sb, level, fmt, ##__VA_ARGS__)
311316
#define nilfs_error(sb, fmt, ...) \
312317
__nilfs_error(sb, __func__, fmt, ##__VA_ARGS__)
313318

314319
#else
315320

321+
#define nilfs_msg(sb, level, fmt, ...) \
322+
no_printk(fmt, ##__VA_ARGS__)
316323
#define nilfs_error(sb, fmt, ...) \
317324
do { \
318325
no_printk(fmt, ##__VA_ARGS__); \

fs/nilfs2/super.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,22 @@ struct kmem_cache *nilfs_btree_path_cache;
7171
static int nilfs_setup_super(struct super_block *sb, int is_mount);
7272
static int nilfs_remount(struct super_block *sb, int *flags, char *data);
7373

74+
void __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+
7490
static void nilfs_set_error(struct super_block *sb)
7591
{
7692
struct the_nilfs *nilfs = sb->s_fs_info;

0 commit comments

Comments
 (0)