2009-11-04 18:39:54

by fabian-buettner

[permalink] [raw]
Subject: Corrupt superblocks

Hello,

After updating my gentoo machine (new udev, lvm2) and rebooting, my initrd was
broken (i had CONFIG_SYSFS_DEPRECATED and CONFIG_SYSFS_DEPRECATEDV2 activated)
and the new udev didn't like these settings.
So I received a warning regarding this issue. Unfortunately I had set the init
bootparameter to init=/sbin/bootchartd. And when i was returning from getting
a cup of coffee. Bootchartd was spamming my console telling me: No space left
on the device (or similar). When i was seeing this i had instantly a VERY bad
feeling about what was going on there.

So i put in the rescuecd, chrooted into my old system, built a new kernel
without these deprecated options, rebooted again.

This time fsck.ext4 was telling me: No such file or directory while trying to
open /dev/vg/root, the superblock could not be read.

That's the story how I managed to corrupt my superblock and probably also it's
backups.
I have run e2fsck -b for several times (with different superblock backup
locations), also did a fsck manually and got spammed by a LOT of "Group
descriptor checksum is invalid" warnings, but the fsck.ext4 error message
remained.

For now I have set my filesystem in /etc/fstab to 0 0, but i REALLY want to get
this fixed.

So i googled around and found this thread:
http://markmail.org/message/3w5tbyaiho7os4fr where some guy as a similar
problem.
Theodore Tso asked him to execute several commands, which i did too.
It would be great if someone with more experience than me could check those
files, unfortunately they are huge.
Here is the link to the three logs:
http://www.file-upload.net/download-1989316/dumpe2fsfab.tar.gz.html

Thanks in advance,
fabian


2009-11-04 19:21:11

by Eric Sandeen

[permalink] [raw]
Subject: Re: Corrupt superblocks

[email protected] wrote:
> Hello,
>
> After updating my gentoo machine (new udev, lvm2) and rebooting, my initrd was
> broken (i had CONFIG_SYSFS_DEPRECATED and CONFIG_SYSFS_DEPRECATEDV2 activated)
> and the new udev didn't like these settings.
> So I received a warning regarding this issue. Unfortunately I had set the init
> bootparameter to init=/sbin/bootchartd. And when i was returning from getting
> a cup of coffee. Bootchartd was spamming my console telling me: No space left
> on the device (or similar). When i was seeing this i had instantly a VERY bad
> feeling about what was going on there.
>
> So i put in the rescuecd, chrooted into my old system, built a new kernel
> without these deprecated options, rebooted again.
>
> This time fsck.ext4 was telling me: No such file or directory while trying to
> open /dev/vg/root, the superblock could not be read.

This looks more like a storage problem tnan an ext4 problem.

> That's the story how I managed to corrupt my superblock and probably also it's
> backups.

Why do you say you have a corrupted superblock?

I suppose I'd try booting a live/rescue cd, and just manually run e2fsck
against your root device, as a starter - and capture any interesting output.

Any sort of kernel or fsck logs indicating more of what actually went
wrong would be Very helpful here.

-Eric


2009-11-04 20:40:03

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH] make unified logs on ext2

Hallo,
i trying to make messages produced by ext2 more unified. It should be
easy to parse.

dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]



dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]


Attachments:
ext2_dmesg.diff (14.60 kB)

2009-11-04 21:56:46

by fabian-buettner

[permalink] [raw]
Subject: Re: Corrupt superblocks

> Why do you say you have a corrupted superblock?

Because of this message: fsck.ext4: No such file or directory while trying to
open /dev/vg/root
/dev/vg/root: The superblock could not be read or does not describe a correct
ext2 filesystem ... at the end of this message i am told to run e2fsck -b
8193 <device>

> I suppose I'd try booting a live/rescue cd, and just manually run e2fsck
> against your root device, as a starter - and capture any interesting
> output.
>
> Any sort of kernel or fsck logs indicating more of what actually went
> wrong would be Very helpful here.

I just booted into a rescue cd and run e2fsck /dev/vg/root.
surprisingly it said: /dev/vg/root: clean

- fabian

2009-11-04 21:59:37

by Eric Sandeen

[permalink] [raw]
Subject: Re: Corrupt superblocks

[email protected] wrote:
>> Why do you say you have a corrupted superblock?
>
> Because of this message: fsck.ext4: No such file or directory while trying to
> open /dev/vg/root
> /dev/vg/root: The superblock could not be read or does not describe a correct
> ext2 filesystem ... at the end of this message i am told to run e2fsck -b
> 8193 <device>

Right, but:

# e2fsck /dev/a_file_that_i_made_up
e2fsck 1.41.4 (27-Jan-2009)
e2fsck: No such file or directory while trying to open
/dev/a_file_that_i_made_up

The superblock could not be read or does not describe a correct ext2
filesystem. If the device is valid and it really contains an ext2
filesystem (and not swap or ufs or something else), then the superblock
is corrupt, and you might try running e2fsck with an alternate superblock:
e2fsck -b 8193 <device>

all that means is /dev/vg/root doesn't exist and e2fsck can't even get
off the ground. Note the "if the device is valid" part ...

>> I suppose I'd try booting a live/rescue cd, and just manually run e2fsck
>> against your root device, as a starter - and capture any interesting
>> output.
>>
>> Any sort of kernel or fsck logs indicating more of what actually went
>> wrong would be Very helpful here.
>
> I just booted into a rescue cd and run e2fsck /dev/vg/root.
> surprisingly it said: /dev/vg/root: clean

so it sounds like your root vg isn't getting assembled properly in your
other situation, which is more of a block device / lvm problem than an
ext4 problem, I think.

-Eric

2009-11-04 22:07:37

by fabian-buettner

[permalink] [raw]
Subject: Re: Corrupt superblocks

On Wednesday 04 November 2009 22:59:39 you wrote:
> Right, but:
>
> # e2fsck /dev/a_file_that_i_made_up
> e2fsck 1.41.4 (27-Jan-2009)
> e2fsck: No such file or directory while trying to open
> /dev/a_file_that_i_made_up
>
> The superblock could not be read or does not describe a correct ext2
> filesystem. If the device is valid and it really contains an ext2
> filesystem (and not swap or ufs or something else), then the superblock
> is corrupt, and you might try running e2fsck with an alternate superblock:
> e2fsck -b 8193 <device>
>
> all that means is /dev/vg/root doesn't exist and e2fsck can't even get
> off the ground. Note the "if the device is valid" part ...

I see.

> so it sounds like your root vg isn't getting assembled properly in your
> other situation, which is more of a block device / lvm problem than an
> ext4 problem, I think.
>
> -Eric
>

So maybe i did harm my fs by running e2fsck -b?
Because running fsck afterwards gave me a lot of those Group descriptor
checksum fixing proposals?
I am surprised that e2fsck just told me that my fs is clean.

Do you have a clue why an entry in my /etc/fsab like
/dev/vg/root / ext4 noatime 0 0
works, while
/dev/vg/root / ext4 noatime 0 1
doesnt?

- fabian

2009-11-04 22:24:05

by Eric Sandeen

[permalink] [raw]
Subject: Re: Corrupt superblocks

[email protected] wrote:

> So maybe i did harm my fs by running e2fsck -b?

If /dev/vg/root didn't exist, no filesystem was harmed in the process I
am sure. :)

> Because running fsck afterwards gave me a lot of those Group descriptor
> checksum fixing proposals?
> I am surprised that e2fsck just told me that my fs is clean.
>
> Do you have a clue why an entry in my /etc/fsab like
> /dev/vg/root / ext4 noatime 0 0

This tells the initscripts not to try running fsck on /dev/vg/root at
all (see man fstab)

> works, while
> /dev/vg/root / ext4 noatime 0 1
> doesnt?

These are probably questions for your distribution; it sounds like the
initscripts are not able to point e2fsck at the proper device, at the
proper time...

-Eric

> - fabian


2009-11-05 04:50:53

by Andreas Dilger

[permalink] [raw]
Subject: Re: [PATCH] make unified logs on ext2

On 2009-11-04, at 13:40, Alexey Fisher wrote:
> i trying to make messages produced by ext2 more unified. It should be
> easy to parse.

This patch follows the ext4_msg() changes in ext4, so at least it is
not inventing something different.

Reviewed-by: Andreas Dilger <[email protected]>

Minor note:
> @@ -840,8 +858,9 @@ static int ext2_fill_super(struct super_block
> *sb, void *data, int silent)
> (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
> - printk("EXT2-fs warning: feature flags set on rev 0 fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: feature flags set on rev 0 fs, "
> + "running e2fsck is recommended");

It looks like you have an extra space before the ext2_msg() here.

Cheers, Andreas
--
Andreas Dilger
Sr. Staff Engineer, Lustre Group
Sun Microsystems of Canada, Inc.


2009-11-05 07:33:34

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH] Unify log messages in ext2

make messages produced by ext2 more unified. It should be
easy to parse.

dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

Signed-off-by: Alexey Fisher <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
---
fs/ext2/ext2.h | 2 +
fs/ext2/super.c | 151 +++++++++++++++++++++++++++++++------------------------
2 files changed, 88 insertions(+), 65 deletions(-)

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9a8a8e2..29f65c5 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -142,6 +142,8 @@ struct dentry *ext2_get_parent(struct dentry *child);
/* super.c */
extern void ext2_error (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
+extern void ext2_msg(struct super_block *, const char *, const char *, ...)
+ __attribute__ ((format (printf, 3, 4)));
extern void ext2_warning (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void ext2_update_dynamic_rev (struct super_block *sb);
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1a9ffee..105fcd1 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -58,26 +58,38 @@ void ext2_error (struct super_block * sb, const char * function,
}

va_start(args, fmt);
- printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
+ ext2_msg(sb, KERN_CRIT, "error %s", function);
vprintk(fmt, args);
printk("\n");
va_end(args);

if (test_opt(sb, ERRORS_PANIC))
- panic("EXT2-fs panic from previous error\n");
+ panic("EXT2-fs: panic from previous error\n");
if (test_opt(sb, ERRORS_RO)) {
- printk("Remounting filesystem read-only\n");
+ ext2_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
sb->s_flags |= MS_RDONLY;
}
}

+void ext2_msg(struct super_block *sb, const char *prefix,
+ const char *fmt, ...)
+{
+ va_list args;
+
+ va_start(args, fmt);
+ printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
+ vprintk(fmt, args);
+ printk("\n");
+ va_end(args);
+}
+
void ext2_warning (struct super_block * sb, const char * function,
const char * fmt, ...)
{
va_list args;

va_start(args, fmt);
- printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
+ printk(KERN_WARNING "EXT2-fs (%s) warning: %s: ",
sb->s_id, function);
vprintk(fmt, args);
printk("\n");
@@ -420,7 +432,7 @@ static const match_table_t tokens = {
};

static int parse_options (char * options,
- struct ext2_sb_info *sbi)
+ struct ext2_sb_info *sbi, struct super_block *sb)
{
char * p;
substring_t args[MAX_OPT_ARGS];
@@ -505,7 +517,8 @@ static int parse_options (char * options,
#else
case Opt_user_xattr:
case Opt_nouser_xattr:
- printk("EXT2 (no)user_xattr options not supported\n");
+ ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
+ "not supported");
break;
#endif
#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -518,14 +531,15 @@ static int parse_options (char * options,
#else
case Opt_acl:
case Opt_noacl:
- printk("EXT2 (no)acl options not supported\n");
+ ext2_msg(sb, KERN_INFO,
+ "(no)acl options not supported");
break;
#endif
case Opt_xip:
#ifdef CONFIG_EXT2_FS_XIP
set_opt (sbi->s_mount_opt, XIP);
#else
- printk("EXT2 xip option not supported\n");
+ ext2_msg(sb, KERN_INFO, "xip option not supported");
#endif
break;

@@ -542,19 +556,18 @@ static int parse_options (char * options,
case Opt_quota:
case Opt_usrquota:
case Opt_grpquota:
- printk(KERN_ERR
- "EXT2-fs: quota operations not supported.\n");
-
+ ext2_msg(sb, KERN_INFO,
+ "quota operations not supported");
break;
#endif

case Opt_reservation:
set_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations ON\n");
+ ext2_msg(sb, KERN_INFO, "reservations ON");
break;
case Opt_noreservation:
clear_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations OFF\n");
+ ext2_msg(sb, KERN_INFO, "reservations OFF");
break;
case Opt_ignore:
break;
@@ -573,34 +586,39 @@ static int ext2_setup_super (struct super_block * sb,
struct ext2_sb_info *sbi = EXT2_SB(sb);

if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
- printk ("EXT2-fs warning: revision level too high, "
- "forcing read-only mode\n");
+ ext2_msg(sb, KERN_ERR,
+ "revision level too high, forcing read-only mode");
res = MS_RDONLY;
}
if (read_only)
return res;
if (!(sbi->s_mount_state & EXT2_VALID_FS))
- printk ("EXT2-fs warning: mounting unchecked fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting unchecked fs, "
+ "running e2fsck is recommended");
else if ((sbi->s_mount_state & EXT2_ERROR_FS))
- printk ("EXT2-fs warning: mounting fs with errors, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting fs with errors, "
+ "running e2fsck is recommended");
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
le16_to_cpu(es->s_mnt_count) >=
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
- printk ("EXT2-fs warning: maximal mount count reached, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: maximal mount count reached, "
+ "running e2fsck is recommended");
else if (le32_to_cpu(es->s_checkinterval) &&
- (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
- printk ("EXT2-fs warning: checktime reached, "
- "running e2fsck is recommended\n");
+ (le32_to_cpu(es->s_lastcheck) +
+ le32_to_cpu(es->s_checkinterval) <= get_seconds()))
+ ext2_msg(sb, KERN_WARNING,
+ "warning: checktime reached, "
+ "running e2fsck is recommended");
if (!le16_to_cpu(es->s_max_mnt_count))
es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
le16_add_cpu(&es->s_mnt_count, 1);
ext2_write_super(sb);
if (test_opt (sb, DEBUG))
- printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
- "bpg=%lu, ipg=%lu, mo=%04lx]\n",
+ ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
+ "bpg=%lu, ipg=%lu, mo=%04lx]",
EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
sbi->s_frag_size,
sbi->s_groups_count,
@@ -767,7 +785,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
if (!blocksize) {
- printk ("EXT2-fs: unable to set blocksize\n");
+ ext2_msg(sb, KERN_ERR, "unable to set blocksize");
goto failed_sbi;
}

@@ -783,7 +801,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}

if (!(bh = sb_bread(sb, logic_sb_block))) {
- printk ("EXT2-fs: unable to read superblock\n");
+ ext2_msg(sb, KERN_ERR, "unable to read superblock");
goto failed_sbi;
}
/*
@@ -826,7 +844,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

set_opt(sbi->s_mount_opt, RESERVATION);

- if (!parse_options ((char *) data, sbi))
+ if (!parse_options((char *) data, sbi, sb))
goto failed_mount;

sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -840,8 +858,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
(EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
- printk("EXT2-fs warning: feature flags set on rev 0 fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: feature flags set on rev 0 fs, "
+ "running e2fsck is recommended");
/*
* Check feature flags regardless of the revision level, since we
* previously didn't change the revision level when setting the flags,
@@ -849,16 +868,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
if (features) {
- printk("EXT2-fs: %s: couldn't mount because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "couldn't mount because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}
if (!(sb->s_flags & MS_RDONLY) &&
(features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
- printk("EXT2-fs: %s: couldn't mount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "couldn't mount RDWR because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}

@@ -866,7 +885,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
if (!silent)
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_ERR, "XIP: Unsupported blocksize");
goto failed_mount;
}

@@ -875,7 +894,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
brelse(bh);

if (!sb_set_blocksize(sb, blocksize)) {
- printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
+ ext2_msg(sb, KERN_ERR, "blocksize too small");
goto failed_sbi;
}

@@ -883,14 +902,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
offset = (sb_block*BLOCK_SIZE) % blocksize;
bh = sb_bread(sb, logic_sb_block);
if(!bh) {
- printk("EXT2-fs: Couldn't read superblock on "
- "2nd try.\n");
+ ext2_msg(sb, KERN_ERR, "Couldn't read superblock on "
+ "2nd try");
goto failed_sbi;
}
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
sbi->s_es = es;
if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
- printk ("EXT2-fs: Magic mismatch, very weird !\n");
+ ext2_msg(sb, KERN_ERR, "Magic mismatch, very weird !");
goto failed_mount;
}
}
@@ -906,7 +925,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
!is_power_of_2(sbi->s_inode_size) ||
(sbi->s_inode_size > blocksize)) {
- printk ("EXT2-fs: unsupported inode size: %d\n",
+ ext2_msg(sb, KERN_ERR, "unsupported inode size: %d",
sbi->s_inode_size);
goto failed_mount;
}
@@ -943,29 +962,29 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (sb->s_blocksize != bh->b_size) {
if (!silent)
- printk ("VFS: Unsupported blocksize on dev "
- "%s.\n", sb->s_id);
+ ext2_msg(sb, KERN_ERR, "VFS: Unsupported blocksize");
goto failed_mount;
}

if (sb->s_blocksize != sbi->s_frag_size) {
- printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
+ ext2_msg(sb, KERN_ERR,
+ "fragsize %lu != blocksize %lu (not supported yet)",
sbi->s_frag_size, sb->s_blocksize);
goto failed_mount;
}

if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #blocks per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR, "#blocks per group too big: %lu",
sbi->s_blocks_per_group);
goto failed_mount;
}
if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #fragments per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR, "#fragments per group too big: %lu",
sbi->s_frags_per_group);
goto failed_mount;
}
if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #inodes per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR, "#inodes per group too big: %lu",
sbi->s_inodes_per_group);
goto failed_mount;
}
@@ -979,13 +998,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
if (sbi->s_group_desc == NULL) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "not enough memory");
goto failed_mount;
}
bgl_lock_init(sbi->s_blockgroup_lock);
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
if (!sbi->s_debts) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "not enough memory");
goto failed_mount_group_desc;
}
for (i = 0; i < db_count; i++) {
@@ -994,12 +1013,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (!sbi->s_group_desc[i]) {
for (j = 0; j < i; j++)
brelse (sbi->s_group_desc[j]);
- printk ("EXT2-fs: unable to read group descriptors\n");
+ ext2_msg(sb, KERN_ERR,
+ "unable to read group descriptors");
goto failed_mount_group_desc;
}
}
if (!ext2_check_descriptors (sb)) {
- printk ("EXT2-fs: group descriptors corrupted!\n");
+ ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
goto failed_mount2;
}
sbi->s_gdb_count = db_count;
@@ -1032,7 +1052,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
ext2_count_dirs(sb));
}
if (err) {
- printk(KERN_ERR "EXT2-fs: insufficient memory\n");
+ ext2_msg(sb, KERN_ERR, "insufficient memory");
goto failed_mount3;
}
/*
@@ -1048,27 +1068,27 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
iput(root);
- printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
+ ext2_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck");
goto failed_mount3;
}

sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
iput(root);
- printk(KERN_ERR "EXT2-fs: get root inode failed\n");
+ ext2_msg(sb, KERN_ERR, "get root inode failed");
ret = -ENOMEM;
goto failed_mount3;
}
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
- ext2_warning(sb, __func__,
- "mounting ext3 filesystem as ext2");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting ext3 filesystem as ext2");
ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
return 0;

cantfind_ext2:
if (!silent)
- printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
- sb->s_id);
+ ext2_msg(sb, KERN_ERR,
+ "VFS: Can't find an ext2 filesystem");
goto failed_mount;
failed_mount3:
percpu_counter_destroy(&sbi->s_freeblocks_counter);
@@ -1170,7 +1190,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options (data, sbi)) {
+ if (!parse_options(data, sbi, sb)) {
err = -EINVAL;
goto restore_opts;
}
@@ -1182,7 +1202,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
EXT2_MOUNT_XIP if not */

if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_WARNING, "XIP: Unsupported blocksize");
err = -EINVAL;
goto restore_opts;
}
@@ -1216,9 +1236,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
~EXT2_FEATURE_RO_COMPAT_SUPP);
if (ret) {
- printk("EXT2-fs: %s: couldn't remount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(ret));
+ ext2_msg(sb, KERN_WARNING,
+ "couldn't remount RDWR because of "
+ "unsupported optional features (%x).",
+ le32_to_cpu(ret));
err = -EROFS;
goto restore_opts;
}
--
1.6.3.3


2009-11-06 14:53:25

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH] Unify log messages in ext2

Any comments for this patch?

Alexey


Am Donnerstag, den 05.11.2009, 08:33 +0100 schrieb Alexey Fisher:
> make messages produced by ext2 more unified. It should be
> easy to parse.
>
> dmesg before patch:
> [ 4893.684892] reservations ON
> [ 4893.684896] xip option not supported
> [ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
> [ 4893.684964] EXT2-fs warning: maximal mount count reached, running
> e2fsck is recommended
> [ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> dmesg after patch:
> [ 4893.684892] EXT2-fs (loop0): reservations ON
> [ 4893.684896] EXT2-fs (loop0): xip option not supported
> [ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
> ext2
> [ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
> running e2fsck is recommended
> [ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> Signed-off-by: Alexey Fisher <[email protected]>
> Reviewed-by: Andreas Dilger <[email protected]>
> ---
> fs/ext2/ext2.h | 2 +
> fs/ext2/super.c | 151 +++++++++++++++++++++++++++++++------------------------
> 2 files changed, 88 insertions(+), 65 deletions(-)
>
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 9a8a8e2..29f65c5 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -142,6 +142,8 @@ struct dentry *ext2_get_parent(struct dentry *child);
> /* super.c */
> extern void ext2_error (struct super_block *, const char *, const char *, ...)
> __attribute__ ((format (printf, 3, 4)));
> +extern void ext2_msg(struct super_block *, const char *, const char *, ...)
> + __attribute__ ((format (printf, 3, 4)));
> extern void ext2_warning (struct super_block *, const char *, const char *, ...)
> __attribute__ ((format (printf, 3, 4)));
> extern void ext2_update_dynamic_rev (struct super_block *sb);
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 1a9ffee..105fcd1 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -58,26 +58,38 @@ void ext2_error (struct super_block * sb, const char * function,
> }
>
> va_start(args, fmt);
> - printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
> + ext2_msg(sb, KERN_CRIT, "error %s", function);
> vprintk(fmt, args);
> printk("\n");
> va_end(args);
>
> if (test_opt(sb, ERRORS_PANIC))
> - panic("EXT2-fs panic from previous error\n");
> + panic("EXT2-fs: panic from previous error\n");
> if (test_opt(sb, ERRORS_RO)) {
> - printk("Remounting filesystem read-only\n");
> + ext2_msg(sb, KERN_CRIT, "Remounting filesystem read-only");
> sb->s_flags |= MS_RDONLY;
> }
> }
>
> +void ext2_msg(struct super_block *sb, const char *prefix,
> + const char *fmt, ...)
> +{
> + va_list args;
> +
> + va_start(args, fmt);
> + printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
> + vprintk(fmt, args);
> + printk("\n");
> + va_end(args);
> +}
> +
> void ext2_warning (struct super_block * sb, const char * function,
> const char * fmt, ...)
> {
> va_list args;
>
> va_start(args, fmt);
> - printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
> + printk(KERN_WARNING "EXT2-fs (%s) warning: %s: ",
> sb->s_id, function);
> vprintk(fmt, args);
> printk("\n");
> @@ -420,7 +432,7 @@ static const match_table_t tokens = {
> };
>
> static int parse_options (char * options,
> - struct ext2_sb_info *sbi)
> + struct ext2_sb_info *sbi, struct super_block *sb)
> {
> char * p;
> substring_t args[MAX_OPT_ARGS];
> @@ -505,7 +517,8 @@ static int parse_options (char * options,
> #else
> case Opt_user_xattr:
> case Opt_nouser_xattr:
> - printk("EXT2 (no)user_xattr options not supported\n");
> + ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
> + "not supported");
> break;
> #endif
> #ifdef CONFIG_EXT2_FS_POSIX_ACL
> @@ -518,14 +531,15 @@ static int parse_options (char * options,
> #else
> case Opt_acl:
> case Opt_noacl:
> - printk("EXT2 (no)acl options not supported\n");
> + ext2_msg(sb, KERN_INFO,
> + "(no)acl options not supported");
> break;
> #endif
> case Opt_xip:
> #ifdef CONFIG_EXT2_FS_XIP
> set_opt (sbi->s_mount_opt, XIP);
> #else
> - printk("EXT2 xip option not supported\n");
> + ext2_msg(sb, KERN_INFO, "xip option not supported");
> #endif
> break;
>
> @@ -542,19 +556,18 @@ static int parse_options (char * options,
> case Opt_quota:
> case Opt_usrquota:
> case Opt_grpquota:
> - printk(KERN_ERR
> - "EXT2-fs: quota operations not supported.\n");
> -
> + ext2_msg(sb, KERN_INFO,
> + "quota operations not supported");
> break;
> #endif
>
> case Opt_reservation:
> set_opt(sbi->s_mount_opt, RESERVATION);
> - printk("reservations ON\n");
> + ext2_msg(sb, KERN_INFO, "reservations ON");
> break;
> case Opt_noreservation:
> clear_opt(sbi->s_mount_opt, RESERVATION);
> - printk("reservations OFF\n");
> + ext2_msg(sb, KERN_INFO, "reservations OFF");
> break;
> case Opt_ignore:
> break;
> @@ -573,34 +586,39 @@ static int ext2_setup_super (struct super_block * sb,
> struct ext2_sb_info *sbi = EXT2_SB(sb);
>
> if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
> - printk ("EXT2-fs warning: revision level too high, "
> - "forcing read-only mode\n");
> + ext2_msg(sb, KERN_ERR,
> + "revision level too high, forcing read-only mode");
> res = MS_RDONLY;
> }
> if (read_only)
> return res;
> if (!(sbi->s_mount_state & EXT2_VALID_FS))
> - printk ("EXT2-fs warning: mounting unchecked fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting unchecked fs, "
> + "running e2fsck is recommended");
> else if ((sbi->s_mount_state & EXT2_ERROR_FS))
> - printk ("EXT2-fs warning: mounting fs with errors, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting fs with errors, "
> + "running e2fsck is recommended");
> else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
> le16_to_cpu(es->s_mnt_count) >=
> (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
> - printk ("EXT2-fs warning: maximal mount count reached, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: maximal mount count reached, "
> + "running e2fsck is recommended");
> else if (le32_to_cpu(es->s_checkinterval) &&
> - (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
> - printk ("EXT2-fs warning: checktime reached, "
> - "running e2fsck is recommended\n");
> + (le32_to_cpu(es->s_lastcheck) +
> + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
> + ext2_msg(sb, KERN_WARNING,
> + "warning: checktime reached, "
> + "running e2fsck is recommended");
> if (!le16_to_cpu(es->s_max_mnt_count))
> es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
> le16_add_cpu(&es->s_mnt_count, 1);
> ext2_write_super(sb);
> if (test_opt (sb, DEBUG))
> - printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
> - "bpg=%lu, ipg=%lu, mo=%04lx]\n",
> + ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
> + "bpg=%lu, ipg=%lu, mo=%04lx]",
> EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
> sbi->s_frag_size,
> sbi->s_groups_count,
> @@ -767,7 +785,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> */
> blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
> if (!blocksize) {
> - printk ("EXT2-fs: unable to set blocksize\n");
> + ext2_msg(sb, KERN_ERR, "unable to set blocksize");
> goto failed_sbi;
> }
>
> @@ -783,7 +801,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> }
>
> if (!(bh = sb_bread(sb, logic_sb_block))) {
> - printk ("EXT2-fs: unable to read superblock\n");
> + ext2_msg(sb, KERN_ERR, "unable to read superblock");
> goto failed_sbi;
> }
> /*
> @@ -826,7 +844,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> set_opt(sbi->s_mount_opt, RESERVATION);
>
> - if (!parse_options ((char *) data, sbi))
> + if (!parse_options((char *) data, sbi, sb))
> goto failed_mount;
>
> sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
> @@ -840,8 +858,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
> - printk("EXT2-fs warning: feature flags set on rev 0 fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: feature flags set on rev 0 fs, "
> + "running e2fsck is recommended");
> /*
> * Check feature flags regardless of the revision level, since we
> * previously didn't change the revision level when setting the flags,
> @@ -849,16 +868,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> */
> features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
> if (features) {
> - printk("EXT2-fs: %s: couldn't mount because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(features));
> + ext2_msg(sb, KERN_ERR, "couldn't mount because of "
> + "unsupported optional features (%x)",
> + le32_to_cpu(features));
> goto failed_mount;
> }
> if (!(sb->s_flags & MS_RDONLY) &&
> (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
> - printk("EXT2-fs: %s: couldn't mount RDWR because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(features));
> + ext2_msg(sb, KERN_ERR, "couldn't mount RDWR because of "
> + "unsupported optional features (%x)",
> + le32_to_cpu(features));
> goto failed_mount;
> }
>
> @@ -866,7 +885,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
> if (!silent)
> - printk("XIP: Unsupported blocksize\n");
> + ext2_msg(sb, KERN_ERR, "XIP: Unsupported blocksize");
> goto failed_mount;
> }
>
> @@ -875,7 +894,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> brelse(bh);
>
> if (!sb_set_blocksize(sb, blocksize)) {
> - printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
> + ext2_msg(sb, KERN_ERR, "blocksize too small");
> goto failed_sbi;
> }
>
> @@ -883,14 +902,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> offset = (sb_block*BLOCK_SIZE) % blocksize;
> bh = sb_bread(sb, logic_sb_block);
> if(!bh) {
> - printk("EXT2-fs: Couldn't read superblock on "
> - "2nd try.\n");
> + ext2_msg(sb, KERN_ERR, "Couldn't read superblock on "
> + "2nd try");
> goto failed_sbi;
> }
> es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
> sbi->s_es = es;
> if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
> - printk ("EXT2-fs: Magic mismatch, very weird !\n");
> + ext2_msg(sb, KERN_ERR, "Magic mismatch, very weird !");
> goto failed_mount;
> }
> }
> @@ -906,7 +925,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
> !is_power_of_2(sbi->s_inode_size) ||
> (sbi->s_inode_size > blocksize)) {
> - printk ("EXT2-fs: unsupported inode size: %d\n",
> + ext2_msg(sb, KERN_ERR, "unsupported inode size: %d",
> sbi->s_inode_size);
> goto failed_mount;
> }
> @@ -943,29 +962,29 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> if (sb->s_blocksize != bh->b_size) {
> if (!silent)
> - printk ("VFS: Unsupported blocksize on dev "
> - "%s.\n", sb->s_id);
> + ext2_msg(sb, KERN_ERR, "VFS: Unsupported blocksize");
> goto failed_mount;
> }
>
> if (sb->s_blocksize != sbi->s_frag_size) {
> - printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
> + ext2_msg(sb, KERN_ERR,
> + "fragsize %lu != blocksize %lu (not supported yet)",
> sbi->s_frag_size, sb->s_blocksize);
> goto failed_mount;
> }
>
> if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #blocks per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR, "#blocks per group too big: %lu",
> sbi->s_blocks_per_group);
> goto failed_mount;
> }
> if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #fragments per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR, "#fragments per group too big: %lu",
> sbi->s_frags_per_group);
> goto failed_mount;
> }
> if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #inodes per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR, "#inodes per group too big: %lu",
> sbi->s_inodes_per_group);
> goto failed_mount;
> }
> @@ -979,13 +998,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> EXT2_DESC_PER_BLOCK(sb);
> sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
> if (sbi->s_group_desc == NULL) {
> - printk ("EXT2-fs: not enough memory\n");
> + ext2_msg(sb, KERN_ERR, "not enough memory");
> goto failed_mount;
> }
> bgl_lock_init(sbi->s_blockgroup_lock);
> sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
> if (!sbi->s_debts) {
> - printk ("EXT2-fs: not enough memory\n");
> + ext2_msg(sb, KERN_ERR, "not enough memory");
> goto failed_mount_group_desc;
> }
> for (i = 0; i < db_count; i++) {
> @@ -994,12 +1013,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> if (!sbi->s_group_desc[i]) {
> for (j = 0; j < i; j++)
> brelse (sbi->s_group_desc[j]);
> - printk ("EXT2-fs: unable to read group descriptors\n");
> + ext2_msg(sb, KERN_ERR,
> + "unable to read group descriptors");
> goto failed_mount_group_desc;
> }
> }
> if (!ext2_check_descriptors (sb)) {
> - printk ("EXT2-fs: group descriptors corrupted!\n");
> + ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
> goto failed_mount2;
> }
> sbi->s_gdb_count = db_count;
> @@ -1032,7 +1052,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> ext2_count_dirs(sb));
> }
> if (err) {
> - printk(KERN_ERR "EXT2-fs: insufficient memory\n");
> + ext2_msg(sb, KERN_ERR, "insufficient memory");
> goto failed_mount3;
> }
> /*
> @@ -1048,27 +1068,27 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> }
> if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
> iput(root);
> - printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
> + ext2_msg(sb, KERN_ERR, "corrupt root inode, run e2fsck");
> goto failed_mount3;
> }
>
> sb->s_root = d_alloc_root(root);
> if (!sb->s_root) {
> iput(root);
> - printk(KERN_ERR "EXT2-fs: get root inode failed\n");
> + ext2_msg(sb, KERN_ERR, "get root inode failed");
> ret = -ENOMEM;
> goto failed_mount3;
> }
> if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
> - ext2_warning(sb, __func__,
> - "mounting ext3 filesystem as ext2");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting ext3 filesystem as ext2");
> ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
> return 0;
>
> cantfind_ext2:
> if (!silent)
> - printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
> - sb->s_id);
> + ext2_msg(sb, KERN_ERR,
> + "VFS: Can't find an ext2 filesystem");
> goto failed_mount;
> failed_mount3:
> percpu_counter_destroy(&sbi->s_freeblocks_counter);
> @@ -1170,7 +1190,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> /*
> * Allow the "check" option to be passed as a remount option.
> */
> - if (!parse_options (data, sbi)) {
> + if (!parse_options(data, sbi, sb)) {
> err = -EINVAL;
> goto restore_opts;
> }
> @@ -1182,7 +1202,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> EXT2_MOUNT_XIP if not */
>
> if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
> - printk("XIP: Unsupported blocksize\n");
> + ext2_msg(sb, KERN_WARNING, "XIP: Unsupported blocksize");
> err = -EINVAL;
> goto restore_opts;
> }
> @@ -1216,9 +1236,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
> ~EXT2_FEATURE_RO_COMPAT_SUPP);
> if (ret) {
> - printk("EXT2-fs: %s: couldn't remount RDWR because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(ret));
> + ext2_msg(sb, KERN_WARNING,
> + "couldn't remount RDWR because of "
> + "unsupported optional features (%x).",
> + le32_to_cpu(ret));
> err = -EROFS;
> goto restore_opts;
> }



2009-11-09 20:36:06

by fabian-buettner

[permalink] [raw]
Subject: Re: Corrupt superblocks

On Wednesday 04 November 2009 23:24:04 you wrote:
> This tells the initscripts not to try running fsck on /dev/vg/root at
> all (see man fstab)
>
> > works, while
> > /dev/vg/root / ext4 noatime 0
> > 1 doesnt?
>
> These are probably questions for your distribution; it sounds like the
> initscripts are not able to point e2fsck at the proper device, at the
> proper time...

Thank you for pointing me in the right direction. I had to upgrade to
baselayout 2 to get it working correctly.

- fabian

2009-11-17 21:23:09

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH] Unify log messages in ext2

Hi,

overall I like the patch. A few comments are below. When you fix them,
I can take care of merging the patch (please CC me on the posting so
that I don't miss it in the mailing list).

> Am Donnerstag, den 05.11.2009, 08:33 +0100 schrieb Alexey Fisher:
> > make messages produced by ext2 more unified. It should be
> > easy to parse.
> >
> > dmesg before patch:
> > [ 4893.684892] reservations ON
> > [ 4893.684896] xip option not supported
> > [ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
> > [ 4893.684964] EXT2-fs warning: maximal mount count reached, running
> > e2fsck is recommended
> > [ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> > bpg=8192, ipg=1280, mo=80010]
> >
> > dmesg after patch:
> > [ 4893.684892] EXT2-fs (loop0): reservations ON
> > [ 4893.684896] EXT2-fs (loop0): xip option not supported
> > [ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
> > ext2
> > [ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
> > running e2fsck is recommended
> > [ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> > bpg=8192, ipg=1280, mo=80010]
> >
> > Signed-off-by: Alexey Fisher <[email protected]>
> > Reviewed-by: Andreas Dilger <[email protected]>
> > ---
> > fs/ext2/ext2.h | 2 +
> > fs/ext2/super.c | 151 +++++++++++++++++++++++++++++++------------------------
> > 2 files changed, 88 insertions(+), 65 deletions(-)
> >
> > diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> > index 9a8a8e2..29f65c5 100644
> > --- a/fs/ext2/ext2.h
> > +++ b/fs/ext2/ext2.h
> > @@ -142,6 +142,8 @@ struct dentry *ext2_get_parent(struct dentry *child);
> > /* super.c */
> > extern void ext2_error (struct super_block *, const char *, const char *, ...)
> > __attribute__ ((format (printf, 3, 4)));
> > +extern void ext2_msg(struct super_block *, const char *, const char *, ...)
> > + __attribute__ ((format (printf, 3, 4)));
> > extern void ext2_warning (struct super_block *, const char *, const char *, ...)
> > __attribute__ ((format (printf, 3, 4)));
> > extern void ext2_update_dynamic_rev (struct super_block *sb);
> > diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> > index 1a9ffee..105fcd1 100644
> > --- a/fs/ext2/super.c
> > +++ b/fs/ext2/super.c
> > @@ -58,26 +58,38 @@ void ext2_error (struct super_block * sb, const char * function,
> > }
> >
> > va_start(args, fmt);
> > - printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
> > + ext2_msg(sb, KERN_CRIT, "error %s", function);
So this will be:
EXT2-fs (sda6): error function_foo
error message
Not quite what we want I think. Besides that I'd like a bit more
messages like:
EXT2-fs error (device): function: message

And for other warnings:
EXT2-fs warning (device): function: message

It's still easy to parse by grep and IMHO nicer to read.

> > @@ -420,7 +432,7 @@ static const match_table_t tokens = {
> > };
> >
> > static int parse_options (char * options,
> > - struct ext2_sb_info *sbi)
> > + struct ext2_sb_info *sbi, struct super_block *sb)
> > {
> > char * p;
> > substring_t args[MAX_OPT_ARGS];
When you pass in 'sb', there's no need to pass in 'sbi' since than can
be obtained as EXT2_SB(sb).

> > cantfind_ext2:
> > if (!silent)
> > - printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
> > - sb->s_id);
> > + ext2_msg(sb, KERN_ERR,
> > + "VFS: Can't find an ext2 filesystem");
> > goto failed_mount;
This message will be strange:
EXT2-fs (device): VFS: Can't find an ext2 filesystem

I'd maybe drop the "VFS:" and leave "on dev ..." in the message. I
know the device name will be duplicated but without that the sentence
just doesn't quite make sence.

Honza
--
Jan Kara <[email protected]>
SuSE CR Labs

2009-11-18 19:26:06

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH] Unify log messages in ext2

Hi,

Am Dienstag, den 17.11.2009, 22:23 +0100 schrieb Jan Kara:
> Hi,
>
> overall I like the patch. A few comments are below. When you fix them,
> I can take care of merging the patch (please CC me on the posting so
> that I don't miss it in the mailing list).
>
> > Am Donnerstag, den 05.11.2009, 08:33 +0100 schrieb Alexey Fisher:
> > > make messages produced by ext2 more unified. It should be
> > > easy to parse.
> > >
> > > dmesg before patch:
> > > [ 4893.684892] reservations ON
> > > [ 4893.684896] xip option not supported
> > > [ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
> > > [ 4893.684964] EXT2-fs warning: maximal mount count reached, running
> > > e2fsck is recommended
> > > [ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> > > bpg=8192, ipg=1280, mo=80010]
> > >
> > > dmesg after patch:
> > > [ 4893.684892] EXT2-fs (loop0): reservations ON
> > > [ 4893.684896] EXT2-fs (loop0): xip option not supported
> > > [ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
> > > ext2
> > > [ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
> > > running e2fsck is recommended
> > > [ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> > > bpg=8192, ipg=1280, mo=80010]
> > >
> > > Signed-off-by: Alexey Fisher <[email protected]>
> > > Reviewed-by: Andreas Dilger <[email protected]>
> > > ---
> > > fs/ext2/ext2.h | 2 +
> > > fs/ext2/super.c | 151 +++++++++++++++++++++++++++++++------------------------
> > > 2 files changed, 88 insertions(+), 65 deletions(-)
> > >
> > > diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> > > index 9a8a8e2..29f65c5 100644
> > > --- a/fs/ext2/ext2.h
> > > +++ b/fs/ext2/ext2.h
> > > @@ -142,6 +142,8 @@ struct dentry *ext2_get_parent(struct dentry *child);
> > > /* super.c */
> > > extern void ext2_error (struct super_block *, const char *, const char *, ...)
> > > __attribute__ ((format (printf, 3, 4)));
> > > +extern void ext2_msg(struct super_block *, const char *, const char *, ...)
> > > + __attribute__ ((format (printf, 3, 4)));
> > > extern void ext2_warning (struct super_block *, const char *, const char *, ...)
> > > __attribute__ ((format (printf, 3, 4)));
> > > extern void ext2_update_dynamic_rev (struct super_block *sb);
> > > diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> > > index 1a9ffee..105fcd1 100644
> > > --- a/fs/ext2/super.c
> > > +++ b/fs/ext2/super.c
> > > @@ -58,26 +58,38 @@ void ext2_error (struct super_block * sb, const char * function,
> > > }
> > >
> > > va_start(args, fmt);
> > > - printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
> > > + ext2_msg(sb, KERN_CRIT, "error %s", function);
> So this will be:
> EXT2-fs (sda6): error function_foo
> error message
> Not quite what we want I think. Besides that I'd like a bit more
> messages like:
> EXT2-fs error (device): function: message
>
> And for other warnings:
> EXT2-fs warning (device): function: message
>
> It's still easy to parse by grep and IMHO nicer to read.

Hmm... there is currently 3 functions to inform user: ext2_error,
ext2_msg and ext2_warning

ext2_error used only on critical errors, so it will remount ro or panic
ext2_warning will print way you like "EXT2-fs warning (device):
function: message"
ext2_msg is sort all around, you can warn or inform but this do not
include __function__ and this will looks like: "EXT2-fs warning
(device): warning: message"

IMHO not all warnings need function to be printed, for example:
"warning: mounting unchecked fs, running e2fsck is recommended" so if i
use ext2_msg this looks like "EXT2-fs (sda6): warning: mounting
unchecked fs, running e2fsck is recommended"

So the question is: do we actually need print __function__ in warnings?
If not, we do not need ext2_warning but this will not look the way you
like ;)

instead of
EXT2-fs error (device): function: message
EXT2-fs warning (device): function: message

will be:
EXT2-fs (device): error: message
EXT2-fs (device): warning: message
EXT2-fs (device): message

If we do ext2_warning we can make all messages consequent. Some of them
will use ext2_warning
EXT2-fs warning (device): function: message

and some ext2_msg
EXT2-fs (device): warning: message

> > > @@ -420,7 +432,7 @@ static const match_table_t tokens = {
> > > };
> > >
> > > static int parse_options (char * options,
> > > - struct ext2_sb_info *sbi)
> > > + struct ext2_sb_info *sbi, struct super_block *sb)
> > > {
> > > char * p;
> > > substring_t args[MAX_OPT_ARGS];
> When you pass in 'sb', there's no need to pass in 'sbi' since than can
> be obtained as EXT2_SB(sb).
>
> > > cantfind_ext2:
> > > if (!silent)
> > > - printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
> > > - sb->s_id);
> > > + ext2_msg(sb, KERN_ERR,
> > > + "VFS: Can't find an ext2 filesystem");
> > > goto failed_mount;
> This message will be strange:
> EXT2-fs (device): VFS: Can't find an ext2 filesystem
>
> I'd maybe drop the "VFS:" and leave "on dev ..." in the message. I
> know the device name will be duplicated but without that the sentence
> just doesn't quite make sence.
>
> Honza

Alexey



2009-11-19 11:18:04

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH v2] Unify log messages in ext2

make messages produced by ext2 more unified. It should be
easy to parse.

dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

Signed-off-by: Alexey Fisher <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
---
fs/ext2/ext2.h | 2 +-
fs/ext2/inode.c | 6 +-
fs/ext2/super.c | 165 ++++++++++++++++++++++++++++++-------------------------
fs/ext2/xip.c | 5 +-
4 files changed, 99 insertions(+), 79 deletions(-)

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9a8a8e2..da318b0 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -142,7 +142,7 @@ struct dentry *ext2_get_parent(struct dentry *child);
/* super.c */
extern void ext2_error (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
-extern void ext2_warning (struct super_block *, const char *, const char *, ...)
+extern void ext2_msg(struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void ext2_update_dynamic_rev (struct super_block *sb);
extern void ext2_write_super (struct super_block *);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ade6340..2725f5d 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -137,7 +137,8 @@ static int ext2_block_to_path(struct inode *inode,
int final = 0;

if (i_block < 0) {
- ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0");
+ ext2_msg (inode->i_sb, KERN_WARNING,
+ "warning: %s: block < 0", __func__);
} else if (i_block < direct_blocks) {
offsets[n++] = i_block;
final = direct_blocks;
@@ -157,7 +158,8 @@ static int ext2_block_to_path(struct inode *inode,
offsets[n++] = i_block & (ptrs - 1);
final = ptrs;
} else {
- ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big");
+ ext2_msg (inode->i_sb, KERN_WARNING,
+ "warning: %s: block is too big", __func__);
}
if (boundary)
*boundary = final - 1 - (i_block & (ptrs - 1));
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1a9ffee..0865bec 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function,
}

va_start(args, fmt);
- printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
+ printk(KERN_CRIT "EXT2-fs (%s): error: %s: ",sb->s_id, function);
vprintk(fmt, args);
printk("\n");
va_end(args);

if (test_opt(sb, ERRORS_PANIC))
- panic("EXT2-fs panic from previous error\n");
+ panic("EXT2-fs: panic from previous error\n");
if (test_opt(sb, ERRORS_RO)) {
- printk("Remounting filesystem read-only\n");
+ ext2_msg(sb, KERN_CRIT,
+ "error: remounting filesystem read-only");
sb->s_flags |= MS_RDONLY;
}
}

-void ext2_warning (struct super_block * sb, const char * function,
- const char * fmt, ...)
+void ext2_msg(struct super_block *sb, const char *prefix,
+ const char *fmt, ...)
{
va_list args;

va_start(args, fmt);
- printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
- sb->s_id, function);
+ printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
vprintk(fmt, args);
printk("\n");
va_end(args);
@@ -91,10 +91,10 @@ void ext2_update_dynamic_rev(struct super_block *sb)
if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
return;

- ext2_warning(sb, __func__,
- "updating to rev %d because of new feature flag, "
- "running e2fsck is recommended",
- EXT2_DYNAMIC_REV);
+ ext2_msg(sb, KERN_WARNING,
+ "warning: %s: updating to rev %d because of "
+ "new feature flag, running e2fsck is recommended",
+ __func__, EXT2_DYNAMIC_REV);

es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
@@ -420,7 +420,7 @@ static const match_table_t tokens = {
};

static int parse_options (char * options,
- struct ext2_sb_info *sbi)
+ struct ext2_sb_info *sbi, struct super_block *sb)
{
char * p;
substring_t args[MAX_OPT_ARGS];
@@ -505,7 +505,8 @@ static int parse_options (char * options,
#else
case Opt_user_xattr:
case Opt_nouser_xattr:
- printk("EXT2 (no)user_xattr options not supported\n");
+ ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
+ "not supported");
break;
#endif
#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -518,14 +519,15 @@ static int parse_options (char * options,
#else
case Opt_acl:
case Opt_noacl:
- printk("EXT2 (no)acl options not supported\n");
+ ext2_msg(sb, KERN_INFO,
+ "(no)acl options not supported");
break;
#endif
case Opt_xip:
#ifdef CONFIG_EXT2_FS_XIP
set_opt (sbi->s_mount_opt, XIP);
#else
- printk("EXT2 xip option not supported\n");
+ ext2_msg(sb, KERN_INFO, "xip option not supported");
#endif
break;

@@ -542,19 +544,18 @@ static int parse_options (char * options,
case Opt_quota:
case Opt_usrquota:
case Opt_grpquota:
- printk(KERN_ERR
- "EXT2-fs: quota operations not supported.\n");
-
+ ext2_msg(sb, KERN_INFO,
+ "quota operations not supported");
break;
#endif

case Opt_reservation:
set_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations ON\n");
+ ext2_msg(sb, KERN_INFO, "reservations ON");
break;
case Opt_noreservation:
clear_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations OFF\n");
+ ext2_msg(sb, KERN_INFO, "reservations OFF");
break;
case Opt_ignore:
break;
@@ -573,34 +574,40 @@ static int ext2_setup_super (struct super_block * sb,
struct ext2_sb_info *sbi = EXT2_SB(sb);

if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
- printk ("EXT2-fs warning: revision level too high, "
- "forcing read-only mode\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: revision level too high, "
+ "forcing read-only mode");
res = MS_RDONLY;
}
if (read_only)
return res;
if (!(sbi->s_mount_state & EXT2_VALID_FS))
- printk ("EXT2-fs warning: mounting unchecked fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting unchecked fs, "
+ "running e2fsck is recommended");
else if ((sbi->s_mount_state & EXT2_ERROR_FS))
- printk ("EXT2-fs warning: mounting fs with errors, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting fs with errors, "
+ "running e2fsck is recommended");
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
le16_to_cpu(es->s_mnt_count) >=
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
- printk ("EXT2-fs warning: maximal mount count reached, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: maximal mount count reached, "
+ "running e2fsck is recommended");
else if (le32_to_cpu(es->s_checkinterval) &&
- (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
- printk ("EXT2-fs warning: checktime reached, "
- "running e2fsck is recommended\n");
+ (le32_to_cpu(es->s_lastcheck) +
+ le32_to_cpu(es->s_checkinterval) <= get_seconds()))
+ ext2_msg(sb, KERN_WARNING,
+ "warning: checktime reached, "
+ "running e2fsck is recommended");
if (!le16_to_cpu(es->s_max_mnt_count))
es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
le16_add_cpu(&es->s_mnt_count, 1);
ext2_write_super(sb);
if (test_opt (sb, DEBUG))
- printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
- "bpg=%lu, ipg=%lu, mo=%04lx]\n",
+ ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
+ "bpg=%lu, ipg=%lu, mo=%04lx]",
EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
sbi->s_frag_size,
sbi->s_groups_count,
@@ -767,7 +774,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
if (!blocksize) {
- printk ("EXT2-fs: unable to set blocksize\n");
+ ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
goto failed_sbi;
}

@@ -783,7 +790,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}

if (!(bh = sb_bread(sb, logic_sb_block))) {
- printk ("EXT2-fs: unable to read superblock\n");
+ ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
goto failed_sbi;
}
/*
@@ -826,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

set_opt(sbi->s_mount_opt, RESERVATION);

- if (!parse_options ((char *) data, sbi))
+ if (!parse_options((char *) data, sbi, sb))
goto failed_mount;

sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -840,8 +847,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
(EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
- printk("EXT2-fs warning: feature flags set on rev 0 fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: feature flags set on rev 0 fs, "
+ "running e2fsck is recommended");
/*
* Check feature flags regardless of the revision level, since we
* previously didn't change the revision level when setting the flags,
@@ -849,16 +857,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
if (features) {
- printk("EXT2-fs: %s: couldn't mount because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}
if (!(sb->s_flags & MS_RDONLY) &&
(features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
- printk("EXT2-fs: %s: couldn't mount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}

@@ -866,7 +874,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
if (!silent)
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: unsupported blocksize for xip");
goto failed_mount;
}

@@ -875,7 +884,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
brelse(bh);

if (!sb_set_blocksize(sb, blocksize)) {
- printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
+ ext2_msg(sb, KERN_ERR, "error: blocksize is too small");
goto failed_sbi;
}

@@ -883,14 +892,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
offset = (sb_block*BLOCK_SIZE) % blocksize;
bh = sb_bread(sb, logic_sb_block);
if(!bh) {
- printk("EXT2-fs: Couldn't read superblock on "
- "2nd try.\n");
+ ext2_msg(sb, KERN_ERR, "error: couldn't read"
+ "superblock on 2nd try");
goto failed_sbi;
}
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
sbi->s_es = es;
if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
- printk ("EXT2-fs: Magic mismatch, very weird !\n");
+ ext2_msg(sb, KERN_ERR, "error: magic mismatch");
goto failed_mount;
}
}
@@ -906,7 +915,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
!is_power_of_2(sbi->s_inode_size) ||
(sbi->s_inode_size > blocksize)) {
- printk ("EXT2-fs: unsupported inode size: %d\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: unsupported inode size: %d",
sbi->s_inode_size);
goto failed_mount;
}
@@ -943,29 +953,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (sb->s_blocksize != bh->b_size) {
if (!silent)
- printk ("VFS: Unsupported blocksize on dev "
- "%s.\n", sb->s_id);
+ ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
goto failed_mount;
}

if (sb->s_blocksize != sbi->s_frag_size) {
- printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: fragsize %lu != blocksize %lu"
+ "(not supported yet)",
sbi->s_frag_size, sb->s_blocksize);
goto failed_mount;
}

if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #blocks per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #blocks per group too big: %lu",
sbi->s_blocks_per_group);
goto failed_mount;
}
if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #fragments per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #fragments per group too big: %lu",
sbi->s_frags_per_group);
goto failed_mount;
}
if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #inodes per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #inodes per group too big: %lu",
sbi->s_inodes_per_group);
goto failed_mount;
}
@@ -979,13 +993,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
if (sbi->s_group_desc == NULL) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "error: not enough memory");
goto failed_mount;
}
bgl_lock_init(sbi->s_blockgroup_lock);
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
if (!sbi->s_debts) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "error: not enough memory");
goto failed_mount_group_desc;
}
for (i = 0; i < db_count; i++) {
@@ -994,12 +1008,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (!sbi->s_group_desc[i]) {
for (j = 0; j < i; j++)
brelse (sbi->s_group_desc[j]);
- printk ("EXT2-fs: unable to read group descriptors\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: unable to read group descriptors");
goto failed_mount_group_desc;
}
}
if (!ext2_check_descriptors (sb)) {
- printk ("EXT2-fs: group descriptors corrupted!\n");
+ ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
goto failed_mount2;
}
sbi->s_gdb_count = db_count;
@@ -1032,7 +1047,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
ext2_count_dirs(sb));
}
if (err) {
- printk(KERN_ERR "EXT2-fs: insufficient memory\n");
+ ext2_msg(sb, KERN_ERR, "error: insufficient memory");
goto failed_mount3;
}
/*
@@ -1048,27 +1063,27 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
iput(root);
- printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
+ ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
goto failed_mount3;
}

sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
iput(root);
- printk(KERN_ERR "EXT2-fs: get root inode failed\n");
+ ext2_msg(sb, KERN_ERR, "error: get root inode failed");
ret = -ENOMEM;
goto failed_mount3;
}
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
- ext2_warning(sb, __func__,
- "mounting ext3 filesystem as ext2");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting ext3 filesystem as ext2");
ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
return 0;

cantfind_ext2:
if (!silent)
- printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
- sb->s_id);
+ ext2_msg(sb, KERN_ERR,
+ "error: can't find an ext2 filesystem");
goto failed_mount;
failed_mount3:
percpu_counter_destroy(&sbi->s_freeblocks_counter);
@@ -1170,7 +1185,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options (data, sbi)) {
+ if (!parse_options(data, sbi, sb)) {
err = -EINVAL;
goto restore_opts;
}
@@ -1182,7 +1197,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
EXT2_MOUNT_XIP if not */

if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_WARNING,
+ "wraning: unsupported blocksize for xip");
err = -EINVAL;
goto restore_opts;
}
@@ -1191,8 +1207,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
(old_mount_opt & EXT2_MOUNT_XIP)) &&
invalidate_inodes(sb)) {
- ext2_warning(sb, __func__, "refusing change of xip flag "
- "with busy inodes while remounting");
+ ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
+ "xip flag with busy inodes while remounting");
sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
}
@@ -1216,9 +1232,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
~EXT2_FEATURE_RO_COMPAT_SUPP);
if (ret) {
- printk("EXT2-fs: %s: couldn't remount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(ret));
+ ext2_msg(sb, KERN_WARNING,
+ "warning: couldn't remount RDWR because of "
+ "unsupported optional features (%x).",
+ le32_to_cpu(ret));
err = -EROFS;
goto restore_opts;
}
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index c18fbf3..8df7502 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -69,8 +69,9 @@ void ext2_xip_verify_sb(struct super_block *sb)
if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
!sb->s_bdev->bd_disk->fops->direct_access) {
sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
- ext2_warning(sb, __func__,
- "ignoring xip option - not supported by bdev");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: %s: ignoring xip option - "
+ "not supported by bdev", __func__);
}
}

--
1.6.3.3


2009-11-19 11:22:41

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH v2] Unify log messages in ext2

I removed in this patch ext2_warning, IMHO ext2_msg is more flexible.
"EXT2_fs warning (dev):" vs "EXT2_fs (dev): warning:" IMHO, first option
looks nice but it make code more complicated.


Am Donnerstag, den 19.11.2009, 12:17 +0100 schrieb Alexey Fisher:
> make messages produced by ext2 more unified. It should be
> easy to parse.
>
> dmesg before patch:
> [ 4893.684892] reservations ON
> [ 4893.684896] xip option not supported
> [ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
> [ 4893.684964] EXT2-fs warning: maximal mount count reached, running
> e2fsck is recommended
> [ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> dmesg after patch:
> [ 4893.684892] EXT2-fs (loop0): reservations ON
> [ 4893.684896] EXT2-fs (loop0): xip option not supported
> [ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
> ext2
> [ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
> running e2fsck is recommended
> [ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> Signed-off-by: Alexey Fisher <[email protected]>
> Reviewed-by: Andreas Dilger <[email protected]>
> ---
> fs/ext2/ext2.h | 2 +-
> fs/ext2/inode.c | 6 +-
> fs/ext2/super.c | 165 ++++++++++++++++++++++++++++++-------------------------
> fs/ext2/xip.c | 5 +-
> 4 files changed, 99 insertions(+), 79 deletions(-)
>
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 9a8a8e2..da318b0 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -142,7 +142,7 @@ struct dentry *ext2_get_parent(struct dentry *child);
> /* super.c */
> extern void ext2_error (struct super_block *, const char *, const char *, ...)
> __attribute__ ((format (printf, 3, 4)));
> -extern void ext2_warning (struct super_block *, const char *, const char *, ...)
> +extern void ext2_msg(struct super_block *, const char *, const char *, ...)
> __attribute__ ((format (printf, 3, 4)));
> extern void ext2_update_dynamic_rev (struct super_block *sb);
> extern void ext2_write_super (struct super_block *);
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index ade6340..2725f5d 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -137,7 +137,8 @@ static int ext2_block_to_path(struct inode *inode,
> int final = 0;
>
> if (i_block < 0) {
> - ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0");
> + ext2_msg (inode->i_sb, KERN_WARNING,
> + "warning: %s: block < 0", __func__);
> } else if (i_block < direct_blocks) {
> offsets[n++] = i_block;
> final = direct_blocks;
> @@ -157,7 +158,8 @@ static int ext2_block_to_path(struct inode *inode,
> offsets[n++] = i_block & (ptrs - 1);
> final = ptrs;
> } else {
> - ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big");
> + ext2_msg (inode->i_sb, KERN_WARNING,
> + "warning: %s: block is too big", __func__);
> }
> if (boundary)
> *boundary = final - 1 - (i_block & (ptrs - 1));
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 1a9ffee..0865bec 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function,
> }
>
> va_start(args, fmt);
> - printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
> + printk(KERN_CRIT "EXT2-fs (%s): error: %s: ",sb->s_id, function);
> vprintk(fmt, args);
> printk("\n");
> va_end(args);
>
> if (test_opt(sb, ERRORS_PANIC))
> - panic("EXT2-fs panic from previous error\n");
> + panic("EXT2-fs: panic from previous error\n");
> if (test_opt(sb, ERRORS_RO)) {
> - printk("Remounting filesystem read-only\n");
> + ext2_msg(sb, KERN_CRIT,
> + "error: remounting filesystem read-only");
> sb->s_flags |= MS_RDONLY;
> }
> }
>
> -void ext2_warning (struct super_block * sb, const char * function,
> - const char * fmt, ...)
> +void ext2_msg(struct super_block *sb, const char *prefix,
> + const char *fmt, ...)
> {
> va_list args;
>
> va_start(args, fmt);
> - printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
> - sb->s_id, function);
> + printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
> vprintk(fmt, args);
> printk("\n");
> va_end(args);
> @@ -91,10 +91,10 @@ void ext2_update_dynamic_rev(struct super_block *sb)
> if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
> return;
>
> - ext2_warning(sb, __func__,
> - "updating to rev %d because of new feature flag, "
> - "running e2fsck is recommended",
> - EXT2_DYNAMIC_REV);
> + ext2_msg(sb, KERN_WARNING,
> + "warning: %s: updating to rev %d because of "
> + "new feature flag, running e2fsck is recommended",
> + __func__, EXT2_DYNAMIC_REV);
>
> es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
> es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
> @@ -420,7 +420,7 @@ static const match_table_t tokens = {
> };
>
> static int parse_options (char * options,
> - struct ext2_sb_info *sbi)
> + struct ext2_sb_info *sbi, struct super_block *sb)
> {
> char * p;
> substring_t args[MAX_OPT_ARGS];
> @@ -505,7 +505,8 @@ static int parse_options (char * options,
> #else
> case Opt_user_xattr:
> case Opt_nouser_xattr:
> - printk("EXT2 (no)user_xattr options not supported\n");
> + ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
> + "not supported");
> break;
> #endif
> #ifdef CONFIG_EXT2_FS_POSIX_ACL
> @@ -518,14 +519,15 @@ static int parse_options (char * options,
> #else
> case Opt_acl:
> case Opt_noacl:
> - printk("EXT2 (no)acl options not supported\n");
> + ext2_msg(sb, KERN_INFO,
> + "(no)acl options not supported");
> break;
> #endif
> case Opt_xip:
> #ifdef CONFIG_EXT2_FS_XIP
> set_opt (sbi->s_mount_opt, XIP);
> #else
> - printk("EXT2 xip option not supported\n");
> + ext2_msg(sb, KERN_INFO, "xip option not supported");
> #endif
> break;
>
> @@ -542,19 +544,18 @@ static int parse_options (char * options,
> case Opt_quota:
> case Opt_usrquota:
> case Opt_grpquota:
> - printk(KERN_ERR
> - "EXT2-fs: quota operations not supported.\n");
> -
> + ext2_msg(sb, KERN_INFO,
> + "quota operations not supported");
> break;
> #endif
>
> case Opt_reservation:
> set_opt(sbi->s_mount_opt, RESERVATION);
> - printk("reservations ON\n");
> + ext2_msg(sb, KERN_INFO, "reservations ON");
> break;
> case Opt_noreservation:
> clear_opt(sbi->s_mount_opt, RESERVATION);
> - printk("reservations OFF\n");
> + ext2_msg(sb, KERN_INFO, "reservations OFF");
> break;
> case Opt_ignore:
> break;
> @@ -573,34 +574,40 @@ static int ext2_setup_super (struct super_block * sb,
> struct ext2_sb_info *sbi = EXT2_SB(sb);
>
> if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
> - printk ("EXT2-fs warning: revision level too high, "
> - "forcing read-only mode\n");
> + ext2_msg(sb, KERN_ERR,
> + "error: revision level too high, "
> + "forcing read-only mode");
> res = MS_RDONLY;
> }
> if (read_only)
> return res;
> if (!(sbi->s_mount_state & EXT2_VALID_FS))
> - printk ("EXT2-fs warning: mounting unchecked fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting unchecked fs, "
> + "running e2fsck is recommended");
> else if ((sbi->s_mount_state & EXT2_ERROR_FS))
> - printk ("EXT2-fs warning: mounting fs with errors, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting fs with errors, "
> + "running e2fsck is recommended");
> else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
> le16_to_cpu(es->s_mnt_count) >=
> (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
> - printk ("EXT2-fs warning: maximal mount count reached, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: maximal mount count reached, "
> + "running e2fsck is recommended");
> else if (le32_to_cpu(es->s_checkinterval) &&
> - (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
> - printk ("EXT2-fs warning: checktime reached, "
> - "running e2fsck is recommended\n");
> + (le32_to_cpu(es->s_lastcheck) +
> + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
> + ext2_msg(sb, KERN_WARNING,
> + "warning: checktime reached, "
> + "running e2fsck is recommended");
> if (!le16_to_cpu(es->s_max_mnt_count))
> es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
> le16_add_cpu(&es->s_mnt_count, 1);
> ext2_write_super(sb);
> if (test_opt (sb, DEBUG))
> - printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
> - "bpg=%lu, ipg=%lu, mo=%04lx]\n",
> + ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
> + "bpg=%lu, ipg=%lu, mo=%04lx]",
> EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
> sbi->s_frag_size,
> sbi->s_groups_count,
> @@ -767,7 +774,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> */
> blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
> if (!blocksize) {
> - printk ("EXT2-fs: unable to set blocksize\n");
> + ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
> goto failed_sbi;
> }
>
> @@ -783,7 +790,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> }
>
> if (!(bh = sb_bread(sb, logic_sb_block))) {
> - printk ("EXT2-fs: unable to read superblock\n");
> + ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
> goto failed_sbi;
> }
> /*
> @@ -826,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> set_opt(sbi->s_mount_opt, RESERVATION);
>
> - if (!parse_options ((char *) data, sbi))
> + if (!parse_options((char *) data, sbi, sb))
> goto failed_mount;
>
> sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
> @@ -840,8 +847,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
> - printk("EXT2-fs warning: feature flags set on rev 0 fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: feature flags set on rev 0 fs, "
> + "running e2fsck is recommended");
> /*
> * Check feature flags regardless of the revision level, since we
> * previously didn't change the revision level when setting the flags,
> @@ -849,16 +857,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> */
> features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
> if (features) {
> - printk("EXT2-fs: %s: couldn't mount because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(features));
> + ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
> + "unsupported optional features (%x)",
> + le32_to_cpu(features));
> goto failed_mount;
> }
> if (!(sb->s_flags & MS_RDONLY) &&
> (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
> - printk("EXT2-fs: %s: couldn't mount RDWR because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(features));
> + ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
> + "unsupported optional features (%x)",
> + le32_to_cpu(features));
> goto failed_mount;
> }
>
> @@ -866,7 +874,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
> if (!silent)
> - printk("XIP: Unsupported blocksize\n");
> + ext2_msg(sb, KERN_ERR,
> + "error: unsupported blocksize for xip");
> goto failed_mount;
> }
>
> @@ -875,7 +884,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> brelse(bh);
>
> if (!sb_set_blocksize(sb, blocksize)) {
> - printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
> + ext2_msg(sb, KERN_ERR, "error: blocksize is too small");
> goto failed_sbi;
> }
>
> @@ -883,14 +892,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> offset = (sb_block*BLOCK_SIZE) % blocksize;
> bh = sb_bread(sb, logic_sb_block);
> if(!bh) {
> - printk("EXT2-fs: Couldn't read superblock on "
> - "2nd try.\n");
> + ext2_msg(sb, KERN_ERR, "error: couldn't read"
> + "superblock on 2nd try");
> goto failed_sbi;
> }
> es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
> sbi->s_es = es;
> if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
> - printk ("EXT2-fs: Magic mismatch, very weird !\n");
> + ext2_msg(sb, KERN_ERR, "error: magic mismatch");
> goto failed_mount;
> }
> }
> @@ -906,7 +915,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
> !is_power_of_2(sbi->s_inode_size) ||
> (sbi->s_inode_size > blocksize)) {
> - printk ("EXT2-fs: unsupported inode size: %d\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: unsupported inode size: %d",
> sbi->s_inode_size);
> goto failed_mount;
> }
> @@ -943,29 +953,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> if (sb->s_blocksize != bh->b_size) {
> if (!silent)
> - printk ("VFS: Unsupported blocksize on dev "
> - "%s.\n", sb->s_id);
> + ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
> goto failed_mount;
> }
>
> if (sb->s_blocksize != sbi->s_frag_size) {
> - printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: fragsize %lu != blocksize %lu"
> + "(not supported yet)",
> sbi->s_frag_size, sb->s_blocksize);
> goto failed_mount;
> }
>
> if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #blocks per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: #blocks per group too big: %lu",
> sbi->s_blocks_per_group);
> goto failed_mount;
> }
> if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #fragments per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: #fragments per group too big: %lu",
> sbi->s_frags_per_group);
> goto failed_mount;
> }
> if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #inodes per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: #inodes per group too big: %lu",
> sbi->s_inodes_per_group);
> goto failed_mount;
> }
> @@ -979,13 +993,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> EXT2_DESC_PER_BLOCK(sb);
> sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
> if (sbi->s_group_desc == NULL) {
> - printk ("EXT2-fs: not enough memory\n");
> + ext2_msg(sb, KERN_ERR, "error: not enough memory");
> goto failed_mount;
> }
> bgl_lock_init(sbi->s_blockgroup_lock);
> sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
> if (!sbi->s_debts) {
> - printk ("EXT2-fs: not enough memory\n");
> + ext2_msg(sb, KERN_ERR, "error: not enough memory");
> goto failed_mount_group_desc;
> }
> for (i = 0; i < db_count; i++) {
> @@ -994,12 +1008,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> if (!sbi->s_group_desc[i]) {
> for (j = 0; j < i; j++)
> brelse (sbi->s_group_desc[j]);
> - printk ("EXT2-fs: unable to read group descriptors\n");
> + ext2_msg(sb, KERN_ERR,
> + "error: unable to read group descriptors");
> goto failed_mount_group_desc;
> }
> }
> if (!ext2_check_descriptors (sb)) {
> - printk ("EXT2-fs: group descriptors corrupted!\n");
> + ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
> goto failed_mount2;
> }
> sbi->s_gdb_count = db_count;
> @@ -1032,7 +1047,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> ext2_count_dirs(sb));
> }
> if (err) {
> - printk(KERN_ERR "EXT2-fs: insufficient memory\n");
> + ext2_msg(sb, KERN_ERR, "error: insufficient memory");
> goto failed_mount3;
> }
> /*
> @@ -1048,27 +1063,27 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> }
> if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
> iput(root);
> - printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
> + ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
> goto failed_mount3;
> }
>
> sb->s_root = d_alloc_root(root);
> if (!sb->s_root) {
> iput(root);
> - printk(KERN_ERR "EXT2-fs: get root inode failed\n");
> + ext2_msg(sb, KERN_ERR, "error: get root inode failed");
> ret = -ENOMEM;
> goto failed_mount3;
> }
> if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
> - ext2_warning(sb, __func__,
> - "mounting ext3 filesystem as ext2");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting ext3 filesystem as ext2");
> ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
> return 0;
>
> cantfind_ext2:
> if (!silent)
> - printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
> - sb->s_id);
> + ext2_msg(sb, KERN_ERR,
> + "error: can't find an ext2 filesystem");
> goto failed_mount;
> failed_mount3:
> percpu_counter_destroy(&sbi->s_freeblocks_counter);
> @@ -1170,7 +1185,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> /*
> * Allow the "check" option to be passed as a remount option.
> */
> - if (!parse_options (data, sbi)) {
> + if (!parse_options(data, sbi, sb)) {
> err = -EINVAL;
> goto restore_opts;
> }
> @@ -1182,7 +1197,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> EXT2_MOUNT_XIP if not */
>
> if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
> - printk("XIP: Unsupported blocksize\n");
> + ext2_msg(sb, KERN_WARNING,
> + "wraning: unsupported blocksize for xip");
> err = -EINVAL;
> goto restore_opts;
> }
> @@ -1191,8 +1207,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
> (old_mount_opt & EXT2_MOUNT_XIP)) &&
> invalidate_inodes(sb)) {
> - ext2_warning(sb, __func__, "refusing change of xip flag "
> - "with busy inodes while remounting");
> + ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
> + "xip flag with busy inodes while remounting");
> sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
> sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
> }
> @@ -1216,9 +1232,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
> ~EXT2_FEATURE_RO_COMPAT_SUPP);
> if (ret) {
> - printk("EXT2-fs: %s: couldn't remount RDWR because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(ret));
> + ext2_msg(sb, KERN_WARNING,
> + "warning: couldn't remount RDWR because of "
> + "unsupported optional features (%x).",
> + le32_to_cpu(ret));
> err = -EROFS;
> goto restore_opts;
> }
> diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
> index c18fbf3..8df7502 100644
> --- a/fs/ext2/xip.c
> +++ b/fs/ext2/xip.c
> @@ -69,8 +69,9 @@ void ext2_xip_verify_sb(struct super_block *sb)
> if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
> !sb->s_bdev->bd_disk->fops->direct_access) {
> sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
> - ext2_warning(sb, __func__,
> - "ignoring xip option - not supported by bdev");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: %s: ignoring xip option - "
> + "not supported by bdev", __func__);
> }
> }
>



2009-11-19 11:30:20

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH v3] Unify log messages in ext2

make messages produced by ext2 more unified. It should be
easy to parse.

dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

Signed-off-by: Alexey Fisher <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
---
fs/ext2/ext2.h | 2 +-
fs/ext2/inode.c | 6 +-
fs/ext2/super.c | 165 ++++++++++++++++++++++++++++++-------------------------
fs/ext2/xip.c | 5 +-
4 files changed, 99 insertions(+), 79 deletions(-)

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9a8a8e2..da318b0 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -142,7 +142,7 @@ struct dentry *ext2_get_parent(struct dentry *child);
/* super.c */
extern void ext2_error (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
-extern void ext2_warning (struct super_block *, const char *, const char *, ...)
+extern void ext2_msg(struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void ext2_update_dynamic_rev (struct super_block *sb);
extern void ext2_write_super (struct super_block *);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ade6340..71b032c 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -137,7 +137,8 @@ static int ext2_block_to_path(struct inode *inode,
int final = 0;

if (i_block < 0) {
- ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0");
+ ext2_msg(inode->i_sb, KERN_WARNING,
+ "warning: %s: block < 0", __func__);
} else if (i_block < direct_blocks) {
offsets[n++] = i_block;
final = direct_blocks;
@@ -157,7 +158,8 @@ static int ext2_block_to_path(struct inode *inode,
offsets[n++] = i_block & (ptrs - 1);
final = ptrs;
} else {
- ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big");
+ ext2_msg(inode->i_sb, KERN_WARNING,
+ "warning: %s: block is too big", __func__);
}
if (boundary)
*boundary = final - 1 - (i_block & (ptrs - 1));
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1a9ffee..25e8b3c 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function,
}

va_start(args, fmt);
- printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
+ printk(KERN_CRIT "EXT2-fs (%s): error: %s: ", sb->s_id, function);
vprintk(fmt, args);
printk("\n");
va_end(args);

if (test_opt(sb, ERRORS_PANIC))
- panic("EXT2-fs panic from previous error\n");
+ panic("EXT2-fs: panic from previous error\n");
if (test_opt(sb, ERRORS_RO)) {
- printk("Remounting filesystem read-only\n");
+ ext2_msg(sb, KERN_CRIT,
+ "error: remounting filesystem read-only");
sb->s_flags |= MS_RDONLY;
}
}

-void ext2_warning (struct super_block * sb, const char * function,
- const char * fmt, ...)
+void ext2_msg(struct super_block *sb, const char *prefix,
+ const char *fmt, ...)
{
va_list args;

va_start(args, fmt);
- printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
- sb->s_id, function);
+ printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
vprintk(fmt, args);
printk("\n");
va_end(args);
@@ -91,10 +91,10 @@ void ext2_update_dynamic_rev(struct super_block *sb)
if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
return;

- ext2_warning(sb, __func__,
- "updating to rev %d because of new feature flag, "
- "running e2fsck is recommended",
- EXT2_DYNAMIC_REV);
+ ext2_msg(sb, KERN_WARNING,
+ "warning: %s: updating to rev %d because of "
+ "new feature flag, running e2fsck is recommended",
+ __func__, EXT2_DYNAMIC_REV);

es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
@@ -420,7 +420,7 @@ static const match_table_t tokens = {
};

static int parse_options (char * options,
- struct ext2_sb_info *sbi)
+ struct ext2_sb_info *sbi, struct super_block *sb)
{
char * p;
substring_t args[MAX_OPT_ARGS];
@@ -505,7 +505,8 @@ static int parse_options (char * options,
#else
case Opt_user_xattr:
case Opt_nouser_xattr:
- printk("EXT2 (no)user_xattr options not supported\n");
+ ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
+ "not supported");
break;
#endif
#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -518,14 +519,15 @@ static int parse_options (char * options,
#else
case Opt_acl:
case Opt_noacl:
- printk("EXT2 (no)acl options not supported\n");
+ ext2_msg(sb, KERN_INFO,
+ "(no)acl options not supported");
break;
#endif
case Opt_xip:
#ifdef CONFIG_EXT2_FS_XIP
set_opt (sbi->s_mount_opt, XIP);
#else
- printk("EXT2 xip option not supported\n");
+ ext2_msg(sb, KERN_INFO, "xip option not supported");
#endif
break;

@@ -542,19 +544,18 @@ static int parse_options (char * options,
case Opt_quota:
case Opt_usrquota:
case Opt_grpquota:
- printk(KERN_ERR
- "EXT2-fs: quota operations not supported.\n");
-
+ ext2_msg(sb, KERN_INFO,
+ "quota operations not supported");
break;
#endif

case Opt_reservation:
set_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations ON\n");
+ ext2_msg(sb, KERN_INFO, "reservations ON");
break;
case Opt_noreservation:
clear_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations OFF\n");
+ ext2_msg(sb, KERN_INFO, "reservations OFF");
break;
case Opt_ignore:
break;
@@ -573,34 +574,40 @@ static int ext2_setup_super (struct super_block * sb,
struct ext2_sb_info *sbi = EXT2_SB(sb);

if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
- printk ("EXT2-fs warning: revision level too high, "
- "forcing read-only mode\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: revision level too high, "
+ "forcing read-only mode");
res = MS_RDONLY;
}
if (read_only)
return res;
if (!(sbi->s_mount_state & EXT2_VALID_FS))
- printk ("EXT2-fs warning: mounting unchecked fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting unchecked fs, "
+ "running e2fsck is recommended");
else if ((sbi->s_mount_state & EXT2_ERROR_FS))
- printk ("EXT2-fs warning: mounting fs with errors, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting fs with errors, "
+ "running e2fsck is recommended");
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
le16_to_cpu(es->s_mnt_count) >=
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
- printk ("EXT2-fs warning: maximal mount count reached, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: maximal mount count reached, "
+ "running e2fsck is recommended");
else if (le32_to_cpu(es->s_checkinterval) &&
- (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
- printk ("EXT2-fs warning: checktime reached, "
- "running e2fsck is recommended\n");
+ (le32_to_cpu(es->s_lastcheck) +
+ le32_to_cpu(es->s_checkinterval) <= get_seconds()))
+ ext2_msg(sb, KERN_WARNING,
+ "warning: checktime reached, "
+ "running e2fsck is recommended");
if (!le16_to_cpu(es->s_max_mnt_count))
es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
le16_add_cpu(&es->s_mnt_count, 1);
ext2_write_super(sb);
if (test_opt (sb, DEBUG))
- printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
- "bpg=%lu, ipg=%lu, mo=%04lx]\n",
+ ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
+ "bpg=%lu, ipg=%lu, mo=%04lx]",
EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
sbi->s_frag_size,
sbi->s_groups_count,
@@ -767,7 +774,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
if (!blocksize) {
- printk ("EXT2-fs: unable to set blocksize\n");
+ ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
goto failed_sbi;
}

@@ -783,7 +790,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}

if (!(bh = sb_bread(sb, logic_sb_block))) {
- printk ("EXT2-fs: unable to read superblock\n");
+ ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
goto failed_sbi;
}
/*
@@ -826,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

set_opt(sbi->s_mount_opt, RESERVATION);

- if (!parse_options ((char *) data, sbi))
+ if (!parse_options((char *) data, sbi, sb))
goto failed_mount;

sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -840,8 +847,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
(EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
- printk("EXT2-fs warning: feature flags set on rev 0 fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: feature flags set on rev 0 fs, "
+ "running e2fsck is recommended");
/*
* Check feature flags regardless of the revision level, since we
* previously didn't change the revision level when setting the flags,
@@ -849,16 +857,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
if (features) {
- printk("EXT2-fs: %s: couldn't mount because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}
if (!(sb->s_flags & MS_RDONLY) &&
(features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
- printk("EXT2-fs: %s: couldn't mount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}

@@ -866,7 +874,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
if (!silent)
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: unsupported blocksize for xip");
goto failed_mount;
}

@@ -875,7 +884,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
brelse(bh);

if (!sb_set_blocksize(sb, blocksize)) {
- printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
+ ext2_msg(sb, KERN_ERR, "error: blocksize is too small");
goto failed_sbi;
}

@@ -883,14 +892,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
offset = (sb_block*BLOCK_SIZE) % blocksize;
bh = sb_bread(sb, logic_sb_block);
if(!bh) {
- printk("EXT2-fs: Couldn't read superblock on "
- "2nd try.\n");
+ ext2_msg(sb, KERN_ERR, "error: couldn't read"
+ "superblock on 2nd try");
goto failed_sbi;
}
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
sbi->s_es = es;
if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
- printk ("EXT2-fs: Magic mismatch, very weird !\n");
+ ext2_msg(sb, KERN_ERR, "error: magic mismatch");
goto failed_mount;
}
}
@@ -906,7 +915,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
!is_power_of_2(sbi->s_inode_size) ||
(sbi->s_inode_size > blocksize)) {
- printk ("EXT2-fs: unsupported inode size: %d\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: unsupported inode size: %d",
sbi->s_inode_size);
goto failed_mount;
}
@@ -943,29 +953,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (sb->s_blocksize != bh->b_size) {
if (!silent)
- printk ("VFS: Unsupported blocksize on dev "
- "%s.\n", sb->s_id);
+ ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
goto failed_mount;
}

if (sb->s_blocksize != sbi->s_frag_size) {
- printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: fragsize %lu != blocksize %lu"
+ "(not supported yet)",
sbi->s_frag_size, sb->s_blocksize);
goto failed_mount;
}

if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #blocks per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #blocks per group too big: %lu",
sbi->s_blocks_per_group);
goto failed_mount;
}
if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #fragments per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #fragments per group too big: %lu",
sbi->s_frags_per_group);
goto failed_mount;
}
if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #inodes per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #inodes per group too big: %lu",
sbi->s_inodes_per_group);
goto failed_mount;
}
@@ -979,13 +993,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
if (sbi->s_group_desc == NULL) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "error: not enough memory");
goto failed_mount;
}
bgl_lock_init(sbi->s_blockgroup_lock);
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
if (!sbi->s_debts) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "error: not enough memory");
goto failed_mount_group_desc;
}
for (i = 0; i < db_count; i++) {
@@ -994,12 +1008,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (!sbi->s_group_desc[i]) {
for (j = 0; j < i; j++)
brelse (sbi->s_group_desc[j]);
- printk ("EXT2-fs: unable to read group descriptors\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: unable to read group descriptors");
goto failed_mount_group_desc;
}
}
if (!ext2_check_descriptors (sb)) {
- printk ("EXT2-fs: group descriptors corrupted!\n");
+ ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
goto failed_mount2;
}
sbi->s_gdb_count = db_count;
@@ -1032,7 +1047,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
ext2_count_dirs(sb));
}
if (err) {
- printk(KERN_ERR "EXT2-fs: insufficient memory\n");
+ ext2_msg(sb, KERN_ERR, "error: insufficient memory");
goto failed_mount3;
}
/*
@@ -1048,27 +1063,27 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
iput(root);
- printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
+ ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
goto failed_mount3;
}

sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
iput(root);
- printk(KERN_ERR "EXT2-fs: get root inode failed\n");
+ ext2_msg(sb, KERN_ERR, "error: get root inode failed");
ret = -ENOMEM;
goto failed_mount3;
}
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
- ext2_warning(sb, __func__,
- "mounting ext3 filesystem as ext2");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting ext3 filesystem as ext2");
ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
return 0;

cantfind_ext2:
if (!silent)
- printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
- sb->s_id);
+ ext2_msg(sb, KERN_ERR,
+ "error: can't find an ext2 filesystem");
goto failed_mount;
failed_mount3:
percpu_counter_destroy(&sbi->s_freeblocks_counter);
@@ -1170,7 +1185,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options (data, sbi)) {
+ if (!parse_options(data, sbi, sb)) {
err = -EINVAL;
goto restore_opts;
}
@@ -1182,7 +1197,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
EXT2_MOUNT_XIP if not */

if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_WARNING,
+ "wraning: unsupported blocksize for xip");
err = -EINVAL;
goto restore_opts;
}
@@ -1191,8 +1207,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
(old_mount_opt & EXT2_MOUNT_XIP)) &&
invalidate_inodes(sb)) {
- ext2_warning(sb, __func__, "refusing change of xip flag "
- "with busy inodes while remounting");
+ ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
+ "xip flag with busy inodes while remounting");
sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
}
@@ -1216,9 +1232,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
~EXT2_FEATURE_RO_COMPAT_SUPP);
if (ret) {
- printk("EXT2-fs: %s: couldn't remount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(ret));
+ ext2_msg(sb, KERN_WARNING,
+ "warning: couldn't remount RDWR because of "
+ "unsupported optional features (%x).",
+ le32_to_cpu(ret));
err = -EROFS;
goto restore_opts;
}
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index c18fbf3..8df7502 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -69,8 +69,9 @@ void ext2_xip_verify_sb(struct super_block *sb)
if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
!sb->s_bdev->bd_disk->fops->direct_access) {
sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
- ext2_warning(sb, __func__,
- "ignoring xip option - not supported by bdev");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: %s: ignoring xip option - "
+ "not supported by bdev", __func__);
}
}

--
1.6.3.3


2009-11-19 14:32:03

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH v3] Unify log messages in ext2

Hi,

On Thu 19-11-09 12:30:11, Alexey Fisher wrote:
> make messages produced by ext2 more unified. It should be
> easy to parse.
>
> dmesg before patch:
> [ 4893.684892] reservations ON
> [ 4893.684896] xip option not supported
> [ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
> [ 4893.684964] EXT2-fs warning: maximal mount count reached, running
> e2fsck is recommended
> [ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> dmesg after patch:
> [ 4893.684892] EXT2-fs (loop0): reservations ON
> [ 4893.684896] EXT2-fs (loop0): xip option not supported
> [ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
> ext2
> [ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
> running e2fsck is recommended
> [ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> Signed-off-by: Alexey Fisher <[email protected]>
> Reviewed-by: Andreas Dilger <[email protected]>
OK, the patch is almost fine. I have slightly changed a few things -
please have a look below. With them I'm fine with merging the patch.

Honza
--
Jan Kara <[email protected]>
SUSE Labs, CR
--

>From 3e8f76349a9a3288a24e3ab9e68c16ea31e13b8a Mon Sep 17 00:00:00 2001
From: Jan Kara <[email protected]>
Date: Thu, 19 Nov 2009 15:26:11 +0100
Subject: [PATCH] ext2: Fixup ext2 messages

Signed-off-by: Jan Kara <[email protected]>
---
fs/ext2/super.c | 19 ++++++++++---------
fs/ext2/xip.c | 4 ++--
2 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 25e8b3c..d3be602 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -92,9 +92,9 @@ void ext2_update_dynamic_rev(struct super_block *sb)
return;

ext2_msg(sb, KERN_WARNING,
- "warning: %s: updating to rev %d because of "
+ "warning: updating to rev %d because of "
"new feature flag, running e2fsck is recommended",
- __func__, EXT2_DYNAMIC_REV);
+ EXT2_DYNAMIC_REV);

es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
es->s_inode_size = cpu_to_le16(EXT2_GOOD_OLD_INODE_SIZE);
@@ -419,10 +419,10 @@ static const match_table_t tokens = {
{Opt_err, NULL}
};

-static int parse_options (char * options,
- struct ext2_sb_info *sbi, struct super_block *sb)
+static int parse_options(char * options, struct super_block *sb)
{
- char * p;
+ char *p;
+ struct ext2_sb_info *sbi = EXT2_SB(sb);
substring_t args[MAX_OPT_ARGS];
int option;

@@ -833,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

set_opt(sbi->s_mount_opt, RESERVATION);

- if (!parse_options((char *) data, sbi, sb))
+ if (!parse_options((char *) data, sb))
goto failed_mount;

sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -1083,7 +1083,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
cantfind_ext2:
if (!silent)
ext2_msg(sb, KERN_ERR,
- "error: can't find an ext2 filesystem");
+ "error: can't find an ext2 filesystem on dev %s.",
+ sb->s_id);
goto failed_mount;
failed_mount3:
percpu_counter_destroy(&sbi->s_freeblocks_counter);
@@ -1185,7 +1186,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options(data, sbi, sb)) {
+ if (!parse_options(data, sb)) {
err = -EINVAL;
goto restore_opts;
}
@@ -1198,7 +1199,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)

if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
ext2_msg(sb, KERN_WARNING,
- "wraning: unsupported blocksize for xip");
+ "warning: unsupported blocksize for xip");
err = -EINVAL;
goto restore_opts;
}
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index 8df7502..322a56b 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -70,8 +70,8 @@ void ext2_xip_verify_sb(struct super_block *sb)
!sb->s_bdev->bd_disk->fops->direct_access) {
sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
ext2_msg(sb, KERN_WARNING,
- "warning: %s: ignoring xip option - "
- "not supported by bdev", __func__);
+ "warning: ignoring xip option - "
+ "not supported by bdev");
}
}

--
1.6.4.2


2009-11-19 18:13:14

by Oleksij Rempel

[permalink] [raw]
Subject: [PATCH v4] Unify log messages in ext2

make messages produced by ext2 more unified. It should be
easy to parse.

dmesg before patch:
[ 4893.684892] reservations ON
[ 4893.684896] xip option not supported
[ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
[ 4893.684964] EXT2-fs warning: maximal mount count reached, running
e2fsck is recommended
[ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

dmesg after patch:
[ 4893.684892] EXT2-fs (loop0): reservations ON
[ 4893.684896] EXT2-fs (loop0): xip option not supported
[ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
ext2
[ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
running e2fsck is recommended
[ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
bpg=8192, ipg=1280, mo=80010]

Signed-off-by: Alexey Fisher <[email protected]>
Reviewed-by: Andreas Dilger <[email protected]>
---
fs/ext2/ext2.h | 2 +-
fs/ext2/inode.c | 6 +-
fs/ext2/super.c | 168 ++++++++++++++++++++++++++++++------------------------
fs/ext2/xip.c | 5 +-
4 files changed, 101 insertions(+), 80 deletions(-)

diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
index 9a8a8e2..da318b0 100644
--- a/fs/ext2/ext2.h
+++ b/fs/ext2/ext2.h
@@ -142,7 +142,7 @@ struct dentry *ext2_get_parent(struct dentry *child);
/* super.c */
extern void ext2_error (struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
-extern void ext2_warning (struct super_block *, const char *, const char *, ...)
+extern void ext2_msg(struct super_block *, const char *, const char *, ...)
__attribute__ ((format (printf, 3, 4)));
extern void ext2_update_dynamic_rev (struct super_block *sb);
extern void ext2_write_super (struct super_block *);
diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
index ade6340..71b032c 100644
--- a/fs/ext2/inode.c
+++ b/fs/ext2/inode.c
@@ -137,7 +137,8 @@ static int ext2_block_to_path(struct inode *inode,
int final = 0;

if (i_block < 0) {
- ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0");
+ ext2_msg(inode->i_sb, KERN_WARNING,
+ "warning: %s: block < 0", __func__);
} else if (i_block < direct_blocks) {
offsets[n++] = i_block;
final = direct_blocks;
@@ -157,7 +158,8 @@ static int ext2_block_to_path(struct inode *inode,
offsets[n++] = i_block & (ptrs - 1);
final = ptrs;
} else {
- ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big");
+ ext2_msg(inode->i_sb, KERN_WARNING,
+ "warning: %s: block is too big", __func__);
}
if (boundary)
*boundary = final - 1 - (i_block & (ptrs - 1));
diff --git a/fs/ext2/super.c b/fs/ext2/super.c
index 1a9ffee..6591dcc 100644
--- a/fs/ext2/super.c
+++ b/fs/ext2/super.c
@@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function,
}

va_start(args, fmt);
- printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
+ printk(KERN_CRIT "EXT2-fs (%s): error: %s: ", sb->s_id, function);
vprintk(fmt, args);
printk("\n");
va_end(args);

if (test_opt(sb, ERRORS_PANIC))
- panic("EXT2-fs panic from previous error\n");
+ panic("EXT2-fs: panic from previous error\n");
if (test_opt(sb, ERRORS_RO)) {
- printk("Remounting filesystem read-only\n");
+ ext2_msg(sb, KERN_CRIT,
+ "error: remounting filesystem read-only");
sb->s_flags |= MS_RDONLY;
}
}

-void ext2_warning (struct super_block * sb, const char * function,
- const char * fmt, ...)
+void ext2_msg(struct super_block *sb, const char *prefix,
+ const char *fmt, ...)
{
va_list args;

va_start(args, fmt);
- printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
- sb->s_id, function);
+ printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
vprintk(fmt, args);
printk("\n");
va_end(args);
@@ -91,9 +91,9 @@ void ext2_update_dynamic_rev(struct super_block *sb)
if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
return;

- ext2_warning(sb, __func__,
- "updating to rev %d because of new feature flag, "
- "running e2fsck is recommended",
+ ext2_msg(sb, KERN_WARNING,
+ "warning: updating to rev %d because of "
+ "new feature flag, running e2fsck is recommended",
EXT2_DYNAMIC_REV);

es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
@@ -419,10 +419,10 @@ static const match_table_t tokens = {
{Opt_err, NULL}
};

-static int parse_options (char * options,
- struct ext2_sb_info *sbi)
+static int parse_options(char *options, struct super_block *sb)
{
- char * p;
+ char *p;
+ struct ext2_sb_info *sbi = EXT2_SB(sb);
substring_t args[MAX_OPT_ARGS];
int option;

@@ -505,7 +505,8 @@ static int parse_options (char * options,
#else
case Opt_user_xattr:
case Opt_nouser_xattr:
- printk("EXT2 (no)user_xattr options not supported\n");
+ ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
+ "not supported");
break;
#endif
#ifdef CONFIG_EXT2_FS_POSIX_ACL
@@ -518,14 +519,15 @@ static int parse_options (char * options,
#else
case Opt_acl:
case Opt_noacl:
- printk("EXT2 (no)acl options not supported\n");
+ ext2_msg(sb, KERN_INFO,
+ "(no)acl options not supported");
break;
#endif
case Opt_xip:
#ifdef CONFIG_EXT2_FS_XIP
set_opt (sbi->s_mount_opt, XIP);
#else
- printk("EXT2 xip option not supported\n");
+ ext2_msg(sb, KERN_INFO, "xip option not supported");
#endif
break;

@@ -542,19 +544,18 @@ static int parse_options (char * options,
case Opt_quota:
case Opt_usrquota:
case Opt_grpquota:
- printk(KERN_ERR
- "EXT2-fs: quota operations not supported.\n");
-
+ ext2_msg(sb, KERN_INFO,
+ "quota operations not supported");
break;
#endif

case Opt_reservation:
set_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations ON\n");
+ ext2_msg(sb, KERN_INFO, "reservations ON");
break;
case Opt_noreservation:
clear_opt(sbi->s_mount_opt, RESERVATION);
- printk("reservations OFF\n");
+ ext2_msg(sb, KERN_INFO, "reservations OFF");
break;
case Opt_ignore:
break;
@@ -573,34 +574,40 @@ static int ext2_setup_super (struct super_block * sb,
struct ext2_sb_info *sbi = EXT2_SB(sb);

if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
- printk ("EXT2-fs warning: revision level too high, "
- "forcing read-only mode\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: revision level too high, "
+ "forcing read-only mode");
res = MS_RDONLY;
}
if (read_only)
return res;
if (!(sbi->s_mount_state & EXT2_VALID_FS))
- printk ("EXT2-fs warning: mounting unchecked fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting unchecked fs, "
+ "running e2fsck is recommended");
else if ((sbi->s_mount_state & EXT2_ERROR_FS))
- printk ("EXT2-fs warning: mounting fs with errors, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting fs with errors, "
+ "running e2fsck is recommended");
else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
le16_to_cpu(es->s_mnt_count) >=
(unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
- printk ("EXT2-fs warning: maximal mount count reached, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: maximal mount count reached, "
+ "running e2fsck is recommended");
else if (le32_to_cpu(es->s_checkinterval) &&
- (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
- printk ("EXT2-fs warning: checktime reached, "
- "running e2fsck is recommended\n");
+ (le32_to_cpu(es->s_lastcheck) +
+ le32_to_cpu(es->s_checkinterval) <= get_seconds()))
+ ext2_msg(sb, KERN_WARNING,
+ "warning: checktime reached, "
+ "running e2fsck is recommended");
if (!le16_to_cpu(es->s_max_mnt_count))
es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
le16_add_cpu(&es->s_mnt_count, 1);
ext2_write_super(sb);
if (test_opt (sb, DEBUG))
- printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
- "bpg=%lu, ipg=%lu, mo=%04lx]\n",
+ ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
+ "bpg=%lu, ipg=%lu, mo=%04lx]",
EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
sbi->s_frag_size,
sbi->s_groups_count,
@@ -767,7 +774,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
if (!blocksize) {
- printk ("EXT2-fs: unable to set blocksize\n");
+ ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
goto failed_sbi;
}

@@ -783,7 +790,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}

if (!(bh = sb_bread(sb, logic_sb_block))) {
- printk ("EXT2-fs: unable to read superblock\n");
+ ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
goto failed_sbi;
}
/*
@@ -826,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

set_opt(sbi->s_mount_opt, RESERVATION);

- if (!parse_options ((char *) data, sbi))
+ if (!parse_options((char *) data, sb))
goto failed_mount;

sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
@@ -840,8 +847,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
(EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
- printk("EXT2-fs warning: feature flags set on rev 0 fs, "
- "running e2fsck is recommended\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: feature flags set on rev 0 fs, "
+ "running e2fsck is recommended");
/*
* Check feature flags regardless of the revision level, since we
* previously didn't change the revision level when setting the flags,
@@ -849,16 +857,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
*/
features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
if (features) {
- printk("EXT2-fs: %s: couldn't mount because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}
if (!(sb->s_flags & MS_RDONLY) &&
(features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
- printk("EXT2-fs: %s: couldn't mount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(features));
+ ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
+ "unsupported optional features (%x)",
+ le32_to_cpu(features));
goto failed_mount;
}

@@ -866,7 +874,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
if (!silent)
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: unsupported blocksize for xip");
goto failed_mount;
}

@@ -875,7 +884,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
brelse(bh);

if (!sb_set_blocksize(sb, blocksize)) {
- printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
+ ext2_msg(sb, KERN_ERR, "error: blocksize is too small");
goto failed_sbi;
}

@@ -883,14 +892,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
offset = (sb_block*BLOCK_SIZE) % blocksize;
bh = sb_bread(sb, logic_sb_block);
if(!bh) {
- printk("EXT2-fs: Couldn't read superblock on "
- "2nd try.\n");
+ ext2_msg(sb, KERN_ERR, "error: couldn't read"
+ "superblock on 2nd try");
goto failed_sbi;
}
es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
sbi->s_es = es;
if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
- printk ("EXT2-fs: Magic mismatch, very weird !\n");
+ ext2_msg(sb, KERN_ERR, "error: magic mismatch");
goto failed_mount;
}
}
@@ -906,7 +915,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
!is_power_of_2(sbi->s_inode_size) ||
(sbi->s_inode_size > blocksize)) {
- printk ("EXT2-fs: unsupported inode size: %d\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: unsupported inode size: %d",
sbi->s_inode_size);
goto failed_mount;
}
@@ -943,29 +953,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)

if (sb->s_blocksize != bh->b_size) {
if (!silent)
- printk ("VFS: Unsupported blocksize on dev "
- "%s.\n", sb->s_id);
+ ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
goto failed_mount;
}

if (sb->s_blocksize != sbi->s_frag_size) {
- printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: fragsize %lu != blocksize %lu"
+ "(not supported yet)",
sbi->s_frag_size, sb->s_blocksize);
goto failed_mount;
}

if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #blocks per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #blocks per group too big: %lu",
sbi->s_blocks_per_group);
goto failed_mount;
}
if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #fragments per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #fragments per group too big: %lu",
sbi->s_frags_per_group);
goto failed_mount;
}
if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
- printk ("EXT2-fs: #inodes per group too big: %lu\n",
+ ext2_msg(sb, KERN_ERR,
+ "error: #inodes per group too big: %lu",
sbi->s_inodes_per_group);
goto failed_mount;
}
@@ -979,13 +993,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
EXT2_DESC_PER_BLOCK(sb);
sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
if (sbi->s_group_desc == NULL) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "error: not enough memory");
goto failed_mount;
}
bgl_lock_init(sbi->s_blockgroup_lock);
sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
if (!sbi->s_debts) {
- printk ("EXT2-fs: not enough memory\n");
+ ext2_msg(sb, KERN_ERR, "error: not enough memory");
goto failed_mount_group_desc;
}
for (i = 0; i < db_count; i++) {
@@ -994,12 +1008,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
if (!sbi->s_group_desc[i]) {
for (j = 0; j < i; j++)
brelse (sbi->s_group_desc[j]);
- printk ("EXT2-fs: unable to read group descriptors\n");
+ ext2_msg(sb, KERN_ERR,
+ "error: unable to read group descriptors");
goto failed_mount_group_desc;
}
}
if (!ext2_check_descriptors (sb)) {
- printk ("EXT2-fs: group descriptors corrupted!\n");
+ ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
goto failed_mount2;
}
sbi->s_gdb_count = db_count;
@@ -1032,7 +1047,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
ext2_count_dirs(sb));
}
if (err) {
- printk(KERN_ERR "EXT2-fs: insufficient memory\n");
+ ext2_msg(sb, KERN_ERR, "error: insufficient memory");
goto failed_mount3;
}
/*
@@ -1048,27 +1063,28 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
}
if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
iput(root);
- printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
+ ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
goto failed_mount3;
}

sb->s_root = d_alloc_root(root);
if (!sb->s_root) {
iput(root);
- printk(KERN_ERR "EXT2-fs: get root inode failed\n");
+ ext2_msg(sb, KERN_ERR, "error: get root inode failed");
ret = -ENOMEM;
goto failed_mount3;
}
if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
- ext2_warning(sb, __func__,
- "mounting ext3 filesystem as ext2");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: mounting ext3 filesystem as ext2");
ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
return 0;

cantfind_ext2:
if (!silent)
- printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
- sb->s_id);
+ ext2_msg(sb, KERN_ERR,
+ "error: can't find an ext2 filesystem on dev %s.",
+ sb->s_id);
goto failed_mount;
failed_mount3:
percpu_counter_destroy(&sbi->s_freeblocks_counter);
@@ -1170,7 +1186,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
/*
* Allow the "check" option to be passed as a remount option.
*/
- if (!parse_options (data, sbi)) {
+ if (!parse_options(data, sb)) {
err = -EINVAL;
goto restore_opts;
}
@@ -1182,7 +1198,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
EXT2_MOUNT_XIP if not */

if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
- printk("XIP: Unsupported blocksize\n");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: unsupported blocksize for xip");
err = -EINVAL;
goto restore_opts;
}
@@ -1191,8 +1208,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
(old_mount_opt & EXT2_MOUNT_XIP)) &&
invalidate_inodes(sb)) {
- ext2_warning(sb, __func__, "refusing change of xip flag "
- "with busy inodes while remounting");
+ ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
+ "xip flag with busy inodes while remounting");
sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
}
@@ -1216,9 +1233,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
__le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
~EXT2_FEATURE_RO_COMPAT_SUPP);
if (ret) {
- printk("EXT2-fs: %s: couldn't remount RDWR because of "
- "unsupported optional features (%x).\n",
- sb->s_id, le32_to_cpu(ret));
+ ext2_msg(sb, KERN_WARNING,
+ "warning: couldn't remount RDWR because of "
+ "unsupported optional features (%x).",
+ le32_to_cpu(ret));
err = -EROFS;
goto restore_opts;
}
diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
index c18fbf3..322a56b 100644
--- a/fs/ext2/xip.c
+++ b/fs/ext2/xip.c
@@ -69,8 +69,9 @@ void ext2_xip_verify_sb(struct super_block *sb)
if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
!sb->s_bdev->bd_disk->fops->direct_access) {
sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
- ext2_warning(sb, __func__,
- "ignoring xip option - not supported by bdev");
+ ext2_msg(sb, KERN_WARNING,
+ "warning: ignoring xip option - "
+ "not supported by bdev");
}
}

--
1.6.3.3


2009-11-20 09:56:34

by Jan Kara

[permalink] [raw]
Subject: Re: [PATCH v4] Unify log messages in ext2

On Thu 19-11-09 19:12:51, Alexey Fisher wrote:
> make messages produced by ext2 more unified. It should be
> easy to parse.
>
> dmesg before patch:
> [ 4893.684892] reservations ON
> [ 4893.684896] xip option not supported
> [ 4893.684961] EXT2-fs warning: mounting ext3 filesystem as ext2
> [ 4893.684964] EXT2-fs warning: maximal mount count reached, running
> e2fsck is recommended
> [ 4893.684990] EXT II FS: 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> dmesg after patch:
> [ 4893.684892] EXT2-fs (loop0): reservations ON
> [ 4893.684896] EXT2-fs (loop0): xip option not supported
> [ 4893.684961] EXT2-fs (loop0): warning: mounting ext3 filesystem as
> ext2
> [ 4893.684964] EXT2-fs (loop0): warning: maximal mount count reached,
> running e2fsck is recommended
> [ 4893.684990] EXT2-fs (loop0): 0.5b, 95/08/09, bs=1024, fs=1024, gc=2,
> bpg=8192, ipg=1280, mo=80010]
>
> Signed-off-by: Alexey Fisher <[email protected]>
> Reviewed-by: Andreas Dilger <[email protected]>
OK, merged the patch into my tree. It should go in the next merge
window.

Honza
> ---
> fs/ext2/ext2.h | 2 +-
> fs/ext2/inode.c | 6 +-
> fs/ext2/super.c | 168 ++++++++++++++++++++++++++++++------------------------
> fs/ext2/xip.c | 5 +-
> 4 files changed, 101 insertions(+), 80 deletions(-)
>
> diff --git a/fs/ext2/ext2.h b/fs/ext2/ext2.h
> index 9a8a8e2..da318b0 100644
> --- a/fs/ext2/ext2.h
> +++ b/fs/ext2/ext2.h
> @@ -142,7 +142,7 @@ struct dentry *ext2_get_parent(struct dentry *child);
> /* super.c */
> extern void ext2_error (struct super_block *, const char *, const char *, ...)
> __attribute__ ((format (printf, 3, 4)));
> -extern void ext2_warning (struct super_block *, const char *, const char *, ...)
> +extern void ext2_msg(struct super_block *, const char *, const char *, ...)
> __attribute__ ((format (printf, 3, 4)));
> extern void ext2_update_dynamic_rev (struct super_block *sb);
> extern void ext2_write_super (struct super_block *);
> diff --git a/fs/ext2/inode.c b/fs/ext2/inode.c
> index ade6340..71b032c 100644
> --- a/fs/ext2/inode.c
> +++ b/fs/ext2/inode.c
> @@ -137,7 +137,8 @@ static int ext2_block_to_path(struct inode *inode,
> int final = 0;
>
> if (i_block < 0) {
> - ext2_warning (inode->i_sb, "ext2_block_to_path", "block < 0");
> + ext2_msg(inode->i_sb, KERN_WARNING,
> + "warning: %s: block < 0", __func__);
> } else if (i_block < direct_blocks) {
> offsets[n++] = i_block;
> final = direct_blocks;
> @@ -157,7 +158,8 @@ static int ext2_block_to_path(struct inode *inode,
> offsets[n++] = i_block & (ptrs - 1);
> final = ptrs;
> } else {
> - ext2_warning (inode->i_sb, "ext2_block_to_path", "block > big");
> + ext2_msg(inode->i_sb, KERN_WARNING,
> + "warning: %s: block is too big", __func__);
> }
> if (boundary)
> *boundary = final - 1 - (i_block & (ptrs - 1));
> diff --git a/fs/ext2/super.c b/fs/ext2/super.c
> index 1a9ffee..6591dcc 100644
> --- a/fs/ext2/super.c
> +++ b/fs/ext2/super.c
> @@ -58,27 +58,27 @@ void ext2_error (struct super_block * sb, const char * function,
> }
>
> va_start(args, fmt);
> - printk(KERN_CRIT "EXT2-fs error (device %s): %s: ",sb->s_id, function);
> + printk(KERN_CRIT "EXT2-fs (%s): error: %s: ", sb->s_id, function);
> vprintk(fmt, args);
> printk("\n");
> va_end(args);
>
> if (test_opt(sb, ERRORS_PANIC))
> - panic("EXT2-fs panic from previous error\n");
> + panic("EXT2-fs: panic from previous error\n");
> if (test_opt(sb, ERRORS_RO)) {
> - printk("Remounting filesystem read-only\n");
> + ext2_msg(sb, KERN_CRIT,
> + "error: remounting filesystem read-only");
> sb->s_flags |= MS_RDONLY;
> }
> }
>
> -void ext2_warning (struct super_block * sb, const char * function,
> - const char * fmt, ...)
> +void ext2_msg(struct super_block *sb, const char *prefix,
> + const char *fmt, ...)
> {
> va_list args;
>
> va_start(args, fmt);
> - printk(KERN_WARNING "EXT2-fs warning (device %s): %s: ",
> - sb->s_id, function);
> + printk("%sEXT2-fs (%s): ", prefix, sb->s_id);
> vprintk(fmt, args);
> printk("\n");
> va_end(args);
> @@ -91,9 +91,9 @@ void ext2_update_dynamic_rev(struct super_block *sb)
> if (le32_to_cpu(es->s_rev_level) > EXT2_GOOD_OLD_REV)
> return;
>
> - ext2_warning(sb, __func__,
> - "updating to rev %d because of new feature flag, "
> - "running e2fsck is recommended",
> + ext2_msg(sb, KERN_WARNING,
> + "warning: updating to rev %d because of "
> + "new feature flag, running e2fsck is recommended",
> EXT2_DYNAMIC_REV);
>
> es->s_first_ino = cpu_to_le32(EXT2_GOOD_OLD_FIRST_INO);
> @@ -419,10 +419,10 @@ static const match_table_t tokens = {
> {Opt_err, NULL}
> };
>
> -static int parse_options (char * options,
> - struct ext2_sb_info *sbi)
> +static int parse_options(char *options, struct super_block *sb)
> {
> - char * p;
> + char *p;
> + struct ext2_sb_info *sbi = EXT2_SB(sb);
> substring_t args[MAX_OPT_ARGS];
> int option;
>
> @@ -505,7 +505,8 @@ static int parse_options (char * options,
> #else
> case Opt_user_xattr:
> case Opt_nouser_xattr:
> - printk("EXT2 (no)user_xattr options not supported\n");
> + ext2_msg(sb, KERN_INFO, "(no)user_xattr options"
> + "not supported");
> break;
> #endif
> #ifdef CONFIG_EXT2_FS_POSIX_ACL
> @@ -518,14 +519,15 @@ static int parse_options (char * options,
> #else
> case Opt_acl:
> case Opt_noacl:
> - printk("EXT2 (no)acl options not supported\n");
> + ext2_msg(sb, KERN_INFO,
> + "(no)acl options not supported");
> break;
> #endif
> case Opt_xip:
> #ifdef CONFIG_EXT2_FS_XIP
> set_opt (sbi->s_mount_opt, XIP);
> #else
> - printk("EXT2 xip option not supported\n");
> + ext2_msg(sb, KERN_INFO, "xip option not supported");
> #endif
> break;
>
> @@ -542,19 +544,18 @@ static int parse_options (char * options,
> case Opt_quota:
> case Opt_usrquota:
> case Opt_grpquota:
> - printk(KERN_ERR
> - "EXT2-fs: quota operations not supported.\n");
> -
> + ext2_msg(sb, KERN_INFO,
> + "quota operations not supported");
> break;
> #endif
>
> case Opt_reservation:
> set_opt(sbi->s_mount_opt, RESERVATION);
> - printk("reservations ON\n");
> + ext2_msg(sb, KERN_INFO, "reservations ON");
> break;
> case Opt_noreservation:
> clear_opt(sbi->s_mount_opt, RESERVATION);
> - printk("reservations OFF\n");
> + ext2_msg(sb, KERN_INFO, "reservations OFF");
> break;
> case Opt_ignore:
> break;
> @@ -573,34 +574,40 @@ static int ext2_setup_super (struct super_block * sb,
> struct ext2_sb_info *sbi = EXT2_SB(sb);
>
> if (le32_to_cpu(es->s_rev_level) > EXT2_MAX_SUPP_REV) {
> - printk ("EXT2-fs warning: revision level too high, "
> - "forcing read-only mode\n");
> + ext2_msg(sb, KERN_ERR,
> + "error: revision level too high, "
> + "forcing read-only mode");
> res = MS_RDONLY;
> }
> if (read_only)
> return res;
> if (!(sbi->s_mount_state & EXT2_VALID_FS))
> - printk ("EXT2-fs warning: mounting unchecked fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting unchecked fs, "
> + "running e2fsck is recommended");
> else if ((sbi->s_mount_state & EXT2_ERROR_FS))
> - printk ("EXT2-fs warning: mounting fs with errors, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting fs with errors, "
> + "running e2fsck is recommended");
> else if ((__s16) le16_to_cpu(es->s_max_mnt_count) >= 0 &&
> le16_to_cpu(es->s_mnt_count) >=
> (unsigned short) (__s16) le16_to_cpu(es->s_max_mnt_count))
> - printk ("EXT2-fs warning: maximal mount count reached, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: maximal mount count reached, "
> + "running e2fsck is recommended");
> else if (le32_to_cpu(es->s_checkinterval) &&
> - (le32_to_cpu(es->s_lastcheck) + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
> - printk ("EXT2-fs warning: checktime reached, "
> - "running e2fsck is recommended\n");
> + (le32_to_cpu(es->s_lastcheck) +
> + le32_to_cpu(es->s_checkinterval) <= get_seconds()))
> + ext2_msg(sb, KERN_WARNING,
> + "warning: checktime reached, "
> + "running e2fsck is recommended");
> if (!le16_to_cpu(es->s_max_mnt_count))
> es->s_max_mnt_count = cpu_to_le16(EXT2_DFL_MAX_MNT_COUNT);
> le16_add_cpu(&es->s_mnt_count, 1);
> ext2_write_super(sb);
> if (test_opt (sb, DEBUG))
> - printk ("[EXT II FS %s, %s, bs=%lu, fs=%lu, gc=%lu, "
> - "bpg=%lu, ipg=%lu, mo=%04lx]\n",
> + ext2_msg(sb, KERN_INFO, "%s, %s, bs=%lu, fs=%lu, gc=%lu, "
> + "bpg=%lu, ipg=%lu, mo=%04lx]",
> EXT2FS_VERSION, EXT2FS_DATE, sb->s_blocksize,
> sbi->s_frag_size,
> sbi->s_groups_count,
> @@ -767,7 +774,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> */
> blocksize = sb_min_blocksize(sb, BLOCK_SIZE);
> if (!blocksize) {
> - printk ("EXT2-fs: unable to set blocksize\n");
> + ext2_msg(sb, KERN_ERR, "error: unable to set blocksize");
> goto failed_sbi;
> }
>
> @@ -783,7 +790,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> }
>
> if (!(bh = sb_bread(sb, logic_sb_block))) {
> - printk ("EXT2-fs: unable to read superblock\n");
> + ext2_msg(sb, KERN_ERR, "error: unable to read superblock");
> goto failed_sbi;
> }
> /*
> @@ -826,7 +833,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> set_opt(sbi->s_mount_opt, RESERVATION);
>
> - if (!parse_options ((char *) data, sbi))
> + if (!parse_options((char *) data, sb))
> goto failed_mount;
>
> sb->s_flags = (sb->s_flags & ~MS_POSIXACL) |
> @@ -840,8 +847,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> (EXT2_HAS_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_RO_COMPAT_FEATURE(sb, ~0U) ||
> EXT2_HAS_INCOMPAT_FEATURE(sb, ~0U)))
> - printk("EXT2-fs warning: feature flags set on rev 0 fs, "
> - "running e2fsck is recommended\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: feature flags set on rev 0 fs, "
> + "running e2fsck is recommended");
> /*
> * Check feature flags regardless of the revision level, since we
> * previously didn't change the revision level when setting the flags,
> @@ -849,16 +857,16 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> */
> features = EXT2_HAS_INCOMPAT_FEATURE(sb, ~EXT2_FEATURE_INCOMPAT_SUPP);
> if (features) {
> - printk("EXT2-fs: %s: couldn't mount because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(features));
> + ext2_msg(sb, KERN_ERR, "error: couldn't mount because of "
> + "unsupported optional features (%x)",
> + le32_to_cpu(features));
> goto failed_mount;
> }
> if (!(sb->s_flags & MS_RDONLY) &&
> (features = EXT2_HAS_RO_COMPAT_FEATURE(sb, ~EXT2_FEATURE_RO_COMPAT_SUPP))){
> - printk("EXT2-fs: %s: couldn't mount RDWR because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(features));
> + ext2_msg(sb, KERN_ERR, "error: couldn't mount RDWR because of "
> + "unsupported optional features (%x)",
> + le32_to_cpu(features));
> goto failed_mount;
> }
>
> @@ -866,7 +874,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> if (ext2_use_xip(sb) && blocksize != PAGE_SIZE) {
> if (!silent)
> - printk("XIP: Unsupported blocksize\n");
> + ext2_msg(sb, KERN_ERR,
> + "error: unsupported blocksize for xip");
> goto failed_mount;
> }
>
> @@ -875,7 +884,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> brelse(bh);
>
> if (!sb_set_blocksize(sb, blocksize)) {
> - printk(KERN_ERR "EXT2-fs: blocksize too small for device.\n");
> + ext2_msg(sb, KERN_ERR, "error: blocksize is too small");
> goto failed_sbi;
> }
>
> @@ -883,14 +892,14 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> offset = (sb_block*BLOCK_SIZE) % blocksize;
> bh = sb_bread(sb, logic_sb_block);
> if(!bh) {
> - printk("EXT2-fs: Couldn't read superblock on "
> - "2nd try.\n");
> + ext2_msg(sb, KERN_ERR, "error: couldn't read"
> + "superblock on 2nd try");
> goto failed_sbi;
> }
> es = (struct ext2_super_block *) (((char *)bh->b_data) + offset);
> sbi->s_es = es;
> if (es->s_magic != cpu_to_le16(EXT2_SUPER_MAGIC)) {
> - printk ("EXT2-fs: Magic mismatch, very weird !\n");
> + ext2_msg(sb, KERN_ERR, "error: magic mismatch");
> goto failed_mount;
> }
> }
> @@ -906,7 +915,8 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> if ((sbi->s_inode_size < EXT2_GOOD_OLD_INODE_SIZE) ||
> !is_power_of_2(sbi->s_inode_size) ||
> (sbi->s_inode_size > blocksize)) {
> - printk ("EXT2-fs: unsupported inode size: %d\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: unsupported inode size: %d",
> sbi->s_inode_size);
> goto failed_mount;
> }
> @@ -943,29 +953,33 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
>
> if (sb->s_blocksize != bh->b_size) {
> if (!silent)
> - printk ("VFS: Unsupported blocksize on dev "
> - "%s.\n", sb->s_id);
> + ext2_msg(sb, KERN_ERR, "error: unsupported blocksize");
> goto failed_mount;
> }
>
> if (sb->s_blocksize != sbi->s_frag_size) {
> - printk ("EXT2-fs: fragsize %lu != blocksize %lu (not supported yet)\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: fragsize %lu != blocksize %lu"
> + "(not supported yet)",
> sbi->s_frag_size, sb->s_blocksize);
> goto failed_mount;
> }
>
> if (sbi->s_blocks_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #blocks per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: #blocks per group too big: %lu",
> sbi->s_blocks_per_group);
> goto failed_mount;
> }
> if (sbi->s_frags_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #fragments per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: #fragments per group too big: %lu",
> sbi->s_frags_per_group);
> goto failed_mount;
> }
> if (sbi->s_inodes_per_group > sb->s_blocksize * 8) {
> - printk ("EXT2-fs: #inodes per group too big: %lu\n",
> + ext2_msg(sb, KERN_ERR,
> + "error: #inodes per group too big: %lu",
> sbi->s_inodes_per_group);
> goto failed_mount;
> }
> @@ -979,13 +993,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> EXT2_DESC_PER_BLOCK(sb);
> sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
> if (sbi->s_group_desc == NULL) {
> - printk ("EXT2-fs: not enough memory\n");
> + ext2_msg(sb, KERN_ERR, "error: not enough memory");
> goto failed_mount;
> }
> bgl_lock_init(sbi->s_blockgroup_lock);
> sbi->s_debts = kcalloc(sbi->s_groups_count, sizeof(*sbi->s_debts), GFP_KERNEL);
> if (!sbi->s_debts) {
> - printk ("EXT2-fs: not enough memory\n");
> + ext2_msg(sb, KERN_ERR, "error: not enough memory");
> goto failed_mount_group_desc;
> }
> for (i = 0; i < db_count; i++) {
> @@ -994,12 +1008,13 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> if (!sbi->s_group_desc[i]) {
> for (j = 0; j < i; j++)
> brelse (sbi->s_group_desc[j]);
> - printk ("EXT2-fs: unable to read group descriptors\n");
> + ext2_msg(sb, KERN_ERR,
> + "error: unable to read group descriptors");
> goto failed_mount_group_desc;
> }
> }
> if (!ext2_check_descriptors (sb)) {
> - printk ("EXT2-fs: group descriptors corrupted!\n");
> + ext2_msg(sb, KERN_ERR, "group descriptors corrupted");
> goto failed_mount2;
> }
> sbi->s_gdb_count = db_count;
> @@ -1032,7 +1047,7 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> ext2_count_dirs(sb));
> }
> if (err) {
> - printk(KERN_ERR "EXT2-fs: insufficient memory\n");
> + ext2_msg(sb, KERN_ERR, "error: insufficient memory");
> goto failed_mount3;
> }
> /*
> @@ -1048,27 +1063,28 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent)
> }
> if (!S_ISDIR(root->i_mode) || !root->i_blocks || !root->i_size) {
> iput(root);
> - printk(KERN_ERR "EXT2-fs: corrupt root inode, run e2fsck\n");
> + ext2_msg(sb, KERN_ERR, "error: corrupt root inode, run e2fsck");
> goto failed_mount3;
> }
>
> sb->s_root = d_alloc_root(root);
> if (!sb->s_root) {
> iput(root);
> - printk(KERN_ERR "EXT2-fs: get root inode failed\n");
> + ext2_msg(sb, KERN_ERR, "error: get root inode failed");
> ret = -ENOMEM;
> goto failed_mount3;
> }
> if (EXT2_HAS_COMPAT_FEATURE(sb, EXT3_FEATURE_COMPAT_HAS_JOURNAL))
> - ext2_warning(sb, __func__,
> - "mounting ext3 filesystem as ext2");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: mounting ext3 filesystem as ext2");
> ext2_setup_super (sb, es, sb->s_flags & MS_RDONLY);
> return 0;
>
> cantfind_ext2:
> if (!silent)
> - printk("VFS: Can't find an ext2 filesystem on dev %s.\n",
> - sb->s_id);
> + ext2_msg(sb, KERN_ERR,
> + "error: can't find an ext2 filesystem on dev %s.",
> + sb->s_id);
> goto failed_mount;
> failed_mount3:
> percpu_counter_destroy(&sbi->s_freeblocks_counter);
> @@ -1170,7 +1186,7 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> /*
> * Allow the "check" option to be passed as a remount option.
> */
> - if (!parse_options (data, sbi)) {
> + if (!parse_options(data, sb)) {
> err = -EINVAL;
> goto restore_opts;
> }
> @@ -1182,7 +1198,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> EXT2_MOUNT_XIP if not */
>
> if ((ext2_use_xip(sb)) && (sb->s_blocksize != PAGE_SIZE)) {
> - printk("XIP: Unsupported blocksize\n");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: unsupported blocksize for xip");
> err = -EINVAL;
> goto restore_opts;
> }
> @@ -1191,8 +1208,8 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> if (((sbi->s_mount_opt & EXT2_MOUNT_XIP) !=
> (old_mount_opt & EXT2_MOUNT_XIP)) &&
> invalidate_inodes(sb)) {
> - ext2_warning(sb, __func__, "refusing change of xip flag "
> - "with busy inodes while remounting");
> + ext2_msg(sb, KERN_WARNING, "warning: refusing change of "
> + "xip flag with busy inodes while remounting");
> sbi->s_mount_opt &= ~EXT2_MOUNT_XIP;
> sbi->s_mount_opt |= old_mount_opt & EXT2_MOUNT_XIP;
> }
> @@ -1216,9 +1233,10 @@ static int ext2_remount (struct super_block * sb, int * flags, char * data)
> __le32 ret = EXT2_HAS_RO_COMPAT_FEATURE(sb,
> ~EXT2_FEATURE_RO_COMPAT_SUPP);
> if (ret) {
> - printk("EXT2-fs: %s: couldn't remount RDWR because of "
> - "unsupported optional features (%x).\n",
> - sb->s_id, le32_to_cpu(ret));
> + ext2_msg(sb, KERN_WARNING,
> + "warning: couldn't remount RDWR because of "
> + "unsupported optional features (%x).",
> + le32_to_cpu(ret));
> err = -EROFS;
> goto restore_opts;
> }
> diff --git a/fs/ext2/xip.c b/fs/ext2/xip.c
> index c18fbf3..322a56b 100644
> --- a/fs/ext2/xip.c
> +++ b/fs/ext2/xip.c
> @@ -69,8 +69,9 @@ void ext2_xip_verify_sb(struct super_block *sb)
> if ((sbi->s_mount_opt & EXT2_MOUNT_XIP) &&
> !sb->s_bdev->bd_disk->fops->direct_access) {
> sbi->s_mount_opt &= (~EXT2_MOUNT_XIP);
> - ext2_warning(sb, __func__,
> - "ignoring xip option - not supported by bdev");
> + ext2_msg(sb, KERN_WARNING,
> + "warning: ignoring xip option - "
> + "not supported by bdev");
> }
> }
>
> --
> 1.6.3.3
>
--
Jan Kara <[email protected]>
SUSE Labs, CR

2009-11-21 10:27:33

by Oleksij Rempel

[permalink] [raw]
Subject: Re: [PATCH v4] Unify log messages in ext2

Am Freitag, den 20.11.2009, 10:56 +0100 schrieb Jan Kara:
> On Thu 19-11-09 19:12:51, Alexey Fisher wrote:
> > make messages produced by ext2 more unified. It should be
> > easy to parse.
> >
> > dmesg before patch:
> > Signed-off-by: Alexey Fisher <[email protected]>
> > Reviewed-by: Andreas Dilger <[email protected]>
> OK, merged the patch into my tree. It should go in the next merge
> window.

Thank you,
I send same patch for ext3 too.

Regards,
Alexey