All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: "Theodore Ts'o" <tytso@mit.edu>,
	kernel list <linux-kernel@vger.kernel.org>,
	adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org
Subject: Re: ext4: media error but where?
Date: Sun, 6 Jul 2014 15:43:25 +0200	[thread overview]
Message-ID: <20140706134325.GA18955@amd.pavel.ucw.cz> (raw)
In-Reply-To: <20140706133247.GB18204@amd.pavel.ucw.cz>

Hi!

> Now I'm running fsck.new -cf. I don't think this filesystem has any
> bad blocks. Still, it says "rootfs: Updating bad block inode."
> ... "FILE SYSTEM WAS MODIFIED", "REBOOT LINUX".

And here's patch to fix this uglyness. Unfortunately, it makes it read
the inode... but perhaps it is good idea as we are able to print
before/after bad block counts...?

Signed-off-by: Pavel Machek <pavel@ucw.cz>

Thanks,
								Pavel

diff --git a/e2fsck/badblocks.c b/e2fsck/badblocks.c
index 7f3641b..32e08bf 100644
--- a/e2fsck/badblocks.c
+++ b/e2fsck/badblocks.c
@@ -30,6 +30,7 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
 	ext2_filsys fs = ctx->fs;
 	errcode_t	retval;
 	badblocks_list	bb_list = 0;
+	int		old_bb_count = -1;
 	FILE		*f;
 	char		buf[1024];
 
@@ -51,14 +52,16 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
 	 * If we're appending to the bad blocks inode, read in the
 	 * current bad blocks.
 	 */
-	if (!replace_bad_blocks) {
-		retval = ext2fs_read_bb_inode(fs, &bb_list);
-		if (retval) {
-			com_err("ext2fs_read_bb_inode", retval, "%s",
-				_("while reading the bad blocks inode"));
-			goto fatal;
-		}
+	retval = ext2fs_read_bb_inode(fs, &bb_list);
+	if (retval) {
+		com_err("ext2fs_read_bb_inode", retval, "%s",
+			_("while reading the bad blocks inode"));
+		goto fatal;
 	}
+	old_bb_count = ext2fs_u32_list_count(bb_list);
+	printf("%s: Currently %d bad blocks.\n", ctx->device_name, old_bb_count);
+	if (replace_bad_blocks)
+		bb_list = 0;
 
 	/*
 	 * Now read in the bad blocks from the file; if
@@ -95,10 +98,16 @@ void read_bad_blocks_file(e2fsck_t ctx, const char *bad_blocks_file,
 		goto fatal;
 	}
 
+	if ((ext2fs_u32_list_count(bb_list) == 0) &&
+	    ((!replace_bad_blocks) || (!old_bb_count))) {
+	  	printf("%s: No bad blocks found, no update neeeded.\n", ctx->device_name);
+		return;
+	}
+
 	/*
 	 * Finally, update the bad blocks from the bad_block_map
 	 */
-	printf("%s: Updating bad block inode.\n", ctx->device_name);
+	printf("%s: Updating bad block inode (%d bad blocks).\n", ctx->device_name, ext2fs_u32_list_count(bb_list));
 	retval = ext2fs_update_bb_inode(fs, bb_list);
 	if (retval) {
 		com_err("ext2fs_update_bb_inode", retval, "%s",

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

  reply	other threads:[~2014-07-06 13:43 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-26 20:20 ext4: total breakdown on USB hdd, 3.0 kernel Pavel Machek
2014-06-26 20:30 ` Pavel Machek
2014-06-26 20:50   ` Pavel Machek
2014-06-27  2:48     ` Theodore Ts'o
2014-06-27  2:46   ` Theodore Ts'o
2014-06-29 20:25     ` Pavel Machek
2014-06-29 21:04       ` Theodore Ts'o
2014-06-30  6:46         ` Pavel Machek
2014-06-30 13:43           ` Theodore Ts'o
2014-07-04 10:23             ` ext4: media error but where? Pavel Machek
2014-07-04 12:11               ` Theodore Ts'o
2014-07-04 17:21                 ` Pavel Machek
2014-07-04 18:06                   ` Pavel Machek
2014-07-04 18:56                   ` Theodore Ts'o
2014-07-06 13:32                     ` Pavel Machek
2014-07-06 13:43                       ` Pavel Machek [this message]
2014-07-06 18:29                         ` Theodore Ts'o
2014-07-06 21:37                           ` Pavel Machek
2014-07-07  1:00                             ` Theodore Ts'o
2014-07-07 18:55                               ` Pavel Machek
2014-07-07 23:18                                 ` 3.16-rc, ext4: oopses, OOMs after hard powerdown Pavel Machek
2014-07-07 23:21                                 ` ext4: media error but where? Theodore Ts'o
2014-07-04 19:17                   ` Andreas Dilger
2014-07-04 20:33                     ` Pavel Machek
2014-07-04 22:18                       ` Andreas Dilger
2014-07-05 22:17                       ` Theodore Ts'o
2014-06-27  8:23 ` ext4: total breakdown on USB hdd, 3.0 kernel Oliver Neukum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140706134325.GA18955@amd.pavel.ucw.cz \
    --to=pavel@ucw.cz \
    --cc=adilger.kernel@dilger.ca \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=tytso@mit.edu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.