public inbox for linux-ext4@vger.kernel.org
 help / color / mirror / Atom feed
From: Eric Sandeen <sandeen@redhat.com>
To: ext4 development <linux-ext4@vger.kernel.org>
Subject: [PATCH] e2fsprogs: exit from preenhalt if IO errors were encountered
Date: Fri, 10 Oct 2008 17:14:08 -0500	[thread overview]
Message-ID: <48EFD3B0.4060009@redhat.com> (raw)

Resolves RH Bug 465679- e2fsck -p crashes with read-only DM device (e.g. logical volume)  

If a block device is unwritable, e2fsck -p gets into an infinite loop
trying to preenhalt, close & flush the fs, which tries to flush the cache, 
which gets a write error and calls preenhalt which tries to close & flush
the fs ... ad infinitum.

Per Ted's suggestion just flag the ctx as "exiting" and short-circuit
the infinite loop.

Tested by running e2fsck -p on a block device set read-only by BLKROSET.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>

Index: e2fsprogs/e2fsck/e2fsck.h
===================================================================
--- e2fsprogs.orig/e2fsck/e2fsck.h
+++ e2fsprogs/e2fsck/e2fsck.h
@@ -174,6 +174,7 @@ struct resource_track {
 #define E2F_FLAG_RESTARTED	0x0200 /* E2fsck has been restarted */
 #define E2F_FLAG_RESIZE_INODE	0x0400 /* Request to recreate resize inode */
 #define E2F_FLAG_GOT_DEVSIZE	0x0800 /* Device size has been fetched */
+#define E2F_FLAG_EXITING	0x1000 /* E2fsck exiting due to errors */
 
 /*
  * Defines for indicating the e2fsck pass number
Index: e2fsprogs/e2fsck/ehandler.c
===================================================================
--- e2fsprogs.orig/e2fsck/ehandler.c
+++ e2fsprogs/e2fsck/ehandler.c
@@ -33,7 +33,8 @@ static errcode_t e2fsck_handle_read_erro
 	e2fsck_t ctx;
 
 	ctx = (e2fsck_t) fs->priv_data;
-
+	if (ctx->flags & E2F_FLAG_EXITING)
+		return 0;
 	/*
 	 * If more than one block was read, try reading each block
 	 * separately.  We could use the actual bytes read to figure
@@ -79,6 +80,8 @@ static errcode_t e2fsck_handle_write_err
 	e2fsck_t ctx;
 
 	ctx = (e2fsck_t) fs->priv_data;
+	if (ctx->flags & E2F_FLAG_EXITING)
+		return 0;
 
 	/*
 	 * If more than one block was written, try writing each block
Index: e2fsprogs/e2fsck/util.c
===================================================================
--- e2fsprogs.orig/e2fsck/util.c
+++ e2fsprogs/e2fsck/util.c
@@ -257,6 +257,7 @@ void preenhalt(e2fsck_t ctx)
 	fprintf(stderr, _("\n\n%s: UNEXPECTED INCONSISTENCY; "
 		"RUN fsck MANUALLY.\n\t(i.e., without -a or -p options)\n"),
 	       ctx->device_name);
+	ctx->flags |= E2F_FLAG_EXITING;
 	if (fs != NULL) {
 		fs->super->s_state |= EXT2_ERROR_FS;
 		ext2fs_mark_super_dirty(fs);


             reply	other threads:[~2008-10-10 22:14 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-10-10 22:14 Eric Sandeen [this message]
2008-10-10 22:39 ` [PATCH] e2fsprogs: exit from preenhalt if IO errors were encountered Eric Sandeen

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=48EFD3B0.4060009@redhat.com \
    --to=sandeen@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox