Skip to content

Commit

Permalink
nilfs2: add nilfs_msg() message interface
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
konis authored and torvalds committed Aug 2, 2016
1 parent cae3d4c commit a66dfb0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions fs/nilfs2/nilfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ static inline int nilfs_mark_inode_dirty_sync(struct inode *inode)
extern struct inode *nilfs_alloc_inode(struct super_block *);
extern void nilfs_destroy_inode(struct inode *);

extern __printf(3, 4)
void __nilfs_msg(struct super_block *sb, const char *level,
const char *fmt, ...);
extern __printf(3, 4)
void __nilfs_error(struct super_block *sb, const char *function,
const char *fmt, ...);
Expand All @@ -308,11 +311,15 @@ void nilfs_warning(struct super_block *, const char *, const char *, ...);

#ifdef CONFIG_PRINTK

#define nilfs_msg(sb, level, fmt, ...) \
__nilfs_msg(sb, level, fmt, ##__VA_ARGS__)
#define nilfs_error(sb, fmt, ...) \
__nilfs_error(sb, __func__, fmt, ##__VA_ARGS__)

#else

#define nilfs_msg(sb, level, fmt, ...) \
no_printk(fmt, ##__VA_ARGS__)
#define nilfs_error(sb, fmt, ...) \
do { \
no_printk(fmt, ##__VA_ARGS__); \
Expand Down
16 changes: 16 additions & 0 deletions fs/nilfs2/super.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,22 @@ struct kmem_cache *nilfs_btree_path_cache;
static int nilfs_setup_super(struct super_block *sb, int is_mount);
static int nilfs_remount(struct super_block *sb, int *flags, char *data);

void __nilfs_msg(struct super_block *sb, const char *level, const char *fmt,
...)
{
struct va_format vaf;
va_list args;

va_start(args, fmt);
vaf.fmt = fmt;
vaf.va = &args;
if (sb)
printk("%sNILFS (%s): %pV\n", level, sb->s_id, &vaf);
else
printk("%sNILFS: %pV\n", level, &vaf);
va_end(args);
}

static void nilfs_set_error(struct super_block *sb)
{
struct the_nilfs *nilfs = sb->s_fs_info;
Expand Down

0 comments on commit a66dfb0

Please sign in to comment.