Re: [PATCH] ext4: add KERN_<LEVEL> for printk()

From: Joe Perches
Date: Wed May 25 2022 - 11:18:36 EST


On Wed, 2022-05-25 at 05:48 -0700, Yu Zhe wrote:
> printk() should include KERN_<LEVEL> facility level, add them.

NACK.

checkpatch is just a guide.

You have to inspect the code to determine if what checkpatch emits
should be followed or ignored.

> diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c
[]
> @@ -628,7 +628,7 @@ static struct stats dx_show_leaf(struct inode *dir,
> char *base = (char *) de;
> struct dx_hash_info h = *hinfo;
>
> - printk("names: ");
> + printk(KERN_WARNING "names: ");
> while ((char *) de < base + size)
> {
> if (de->inode)
> @@ -648,7 +648,7 @@ static struct stats dx_show_leaf(struct inode *dir,
> /* Directory is not encrypted */
> ext4fs_dirhash(dir, de->name,
> de->name_len, &h);
> - printk("%*.s:(U)%x.%u ", len,
> + printk(KERN_WARNING "%*.s:(U)%x.%u ", len,

_might_ use KERN_CONT,

> name, h.hash,
> (unsigned) ((char *) de
> - base));
> @@ -683,7 +683,7 @@ static struct stats dx_show_leaf(struct inode *dir,
> else
> ext4fs_dirhash(dir, de->name,
> de->name_len, &h);
> - printk("%*.s:(E)%x.%u ", len, name,
> + printk(KERN_WARNING "%*.s:(E)%x.%u ", len, name,

and here, etc...

[]

> diff --git a/fs/ext4/super.c b/fs/ext4/super.c
[]
> @@ -941,9 +941,9 @@ void __ext4_msg(struct super_block *sb,
> vaf.fmt = fmt;
> vaf.va = &args;
> if (sb)
> - printk("%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf);
> + printk(KERN_WARNING "%sEXT4-fs (%s): %pV\n", prefix, sb->s_id, &vaf);

You broke the logging here.

Did you check what prefix is and how it is used in ext4_msg ?

> else
> - printk("%sEXT4-fs: %pV\n", prefix, &vaf);
> + printk(KERN_WARNING "%sEXT4-fs: %pV\n", prefix, &vaf);
> va_end(args);
> }
>