linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: bugzilla-daemon@bugzilla.kernel.org
Cc: linux-ext4@vger.kernel.org, rockorequin@hotmail.com,
	stern@rowland.harvard.edu
Subject: Re: [Bug 25832] kernel crashes when a mounted ext3/4 file system is physically removed
Date: Fri, 9 Sep 2011 15:13:54 -0400	[thread overview]
Message-ID: <20110909191354.GC3818@thunk.org> (raw)
In-Reply-To: <201109051744.p85HiVYe013595@demeter1.kernel.org>

Bugzilla.kernel.org is down, so apologies to people who have
subscribed to this bug but which I didn't cc explicitly...

Rocko, Alan, could you try this patch and see what happens.  It may be
that we'll crash somewhere else; the problem is that Linux that the
low-level generic hd routines doesn't have a formal way of informing
the VFS and layers below that the disk has disappeared.  It just yanks
it out from under the file system, and we've been manually patching
around kernel crashes....

     	   	 	   	       	    - Ted

commit 6e478d46e58181ec4814f25a2fd91c6323e16ad4
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Fri Sep 9 15:02:54 2011 -0400

    ext4: add ext4-specific kludge to avoid an oops after the disk disappears
    
    The del_gendisk() function uninitializes the disk-specific data
    structures, including the bdi structure, without telling anyone
    else.  Once this happens, any attempt to call mark_buffer_dirty()
    (for example, by ext4_commit_super), will cause a kernel OOPS.
    
    Fix this for now until we can fix things in an architecturally correct
    way.
    
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index ee2f74a..48cb615 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -414,6 +414,22 @@ static void save_error_info(struct super_block *sb, const char *func,
 	ext4_commit_super(sb, 1);
 }
 
+/*
+ * The del_gendisk() function deactivates the inode and deactivates
+ * the bdi without telling the file system.  Once this happens, any
+ * attempt to call mark_buffer_dirty() (for example, by
+ * ext4_commit_super), will cause a kernel OOPS.  This is a kludge to
+ * prevent these oops until we can put in a proper hook in
+ * del_gendisk() to inform the VFS and file system layers.
+ */
+static int block_device_ejected(struct super_block *sb)
+{
+	struct inode *bd_inode = sb->s_bdev->bd_inode;
+	struct backing_dev_info *bdi = bd_inode->i_mapping->backing_dev_info;
+
+	return bdi->dev == NULL;
+}
+
 
 /* Deal with the reporting of failure conditions on a filesystem such as
  * inconsistencies detected or read IO failures.
@@ -4072,7 +4088,7 @@ static int ext4_commit_super(struct super_block *sb, int sync)
 	struct buffer_head *sbh = EXT4_SB(sb)->s_sbh;
 	int error = 0;
 
-	if (!sbh)
+	if (!sbh || block_device_ejected(sb))
 		return error;
 	if (buffer_write_io_error(sbh)) {
 		/*

  reply	other threads:[~2011-09-09 19:13 UTC|newest]

Thread overview: 97+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-25832-13602@https.bugzilla.kernel.org/>
2011-02-03 17:09 ` [Bug 25832] kernel crashes upon resume if usb devices are removed when suspended bugzilla-daemon
2011-02-03 18:22 ` bugzilla-daemon
2011-02-04  6:28 ` bugzilla-daemon
2011-02-04  6:30 ` bugzilla-daemon
2011-02-04 15:31 ` bugzilla-daemon
2011-02-05  8:31 ` bugzilla-daemon
2011-02-05  8:53 ` bugzilla-daemon
2011-02-05 19:12 ` bugzilla-daemon
2011-02-05 19:56 ` bugzilla-daemon
2011-02-05 19:58 ` bugzilla-daemon
2011-02-05 20:53 ` bugzilla-daemon
2011-02-05 23:10 ` bugzilla-daemon
2011-02-06  2:54 ` bugzilla-daemon
2011-02-06  3:44 ` bugzilla-daemon
2011-02-06  4:26 ` bugzilla-daemon
2011-02-06  6:43 ` bugzilla-daemon
2011-02-06  9:00 ` bugzilla-daemon
2011-02-07  1:20 ` bugzilla-daemon
2011-02-07  3:11 ` bugzilla-daemon
2011-02-07  3:32 ` bugzilla-daemon
2011-02-07  3:33 ` bugzilla-daemon
2011-02-07  4:24 ` bugzilla-daemon
2011-02-07 15:36 ` bugzilla-daemon
2011-02-07 23:49 ` bugzilla-daemon
2011-02-19 12:36 ` bugzilla-daemon
2011-02-19 15:55 ` bugzilla-daemon
2011-02-20  0:16 ` bugzilla-daemon
2011-02-21  4:02 ` bugzilla-daemon
2011-02-21  4:08 ` bugzilla-daemon
2011-02-21  8:59 ` bugzilla-daemon
2011-02-21 16:48 ` bugzilla-daemon
2011-02-22  7:03 ` bugzilla-daemon
2011-03-03 15:23 ` bugzilla-daemon
2011-03-06 10:25 ` bugzilla-daemon
2011-03-06 15:59 ` bugzilla-daemon
2011-03-12  6:03 ` bugzilla-daemon
2011-03-12 12:12 ` bugzilla-daemon
2011-03-12 15:51 ` bugzilla-daemon
2011-03-13  0:41 ` bugzilla-daemon
2011-03-13  2:26 ` bugzilla-daemon
2011-03-13  2:45 ` bugzilla-daemon
2011-03-13  3:01 ` bugzilla-daemon
2011-03-13 21:17 ` bugzilla-daemon
2011-03-14  4:10 ` bugzilla-daemon
2011-03-14 14:18 ` bugzilla-daemon
2011-03-24 23:06 ` bugzilla-daemon
2011-03-31  0:44 ` bugzilla-daemon
2011-03-31  0:49 ` bugzilla-daemon
2011-04-01 15:09 ` bugzilla-daemon
2011-04-01 23:58 ` bugzilla-daemon
2011-04-04  2:32 ` bugzilla-daemon
2011-04-04 14:11 ` bugzilla-daemon
2011-04-05 15:17 ` bugzilla-daemon
2011-04-06 23:01 ` bugzilla-daemon
2011-04-22  6:00 ` bugzilla-daemon
2011-04-22 10:13 ` bugzilla-daemon
2011-04-22 10:37 ` bugzilla-daemon
2011-04-22 11:58 ` bugzilla-daemon
2011-04-22 13:42 ` [Bug 25832] kernel crashes when a mounted ext3/4 file system is physically removed bugzilla-daemon
2011-04-22 15:00 ` bugzilla-daemon
2011-04-23  0:32 ` bugzilla-daemon
2011-04-23  4:12 ` bugzilla-daemon
2011-04-23 19:31 ` bugzilla-daemon
2011-04-24  1:35 ` bugzilla-daemon
2011-04-25  0:36 ` bugzilla-daemon
2011-04-25  0:37 ` bugzilla-daemon
2011-04-25  0:39 ` bugzilla-daemon
2011-04-25 20:28 ` bugzilla-daemon
2011-04-26  0:28 ` bugzilla-daemon
2011-04-26  0:44 ` bugzilla-daemon
2011-04-26  1:22 ` bugzilla-daemon
2011-04-26  3:29 ` bugzilla-daemon
2011-04-26  4:02 ` bugzilla-daemon
2011-04-26 18:15 ` bugzilla-daemon
2011-05-03  2:19 ` bugzilla-daemon
2011-05-04  7:36 ` bugzilla-daemon
2011-05-10 23:27 ` bugzilla-daemon
2011-05-26  6:44 ` bugzilla-daemon
2011-05-26 14:27 ` bugzilla-daemon
2011-07-13  7:52 ` bugzilla-daemon
2011-08-31  5:00 ` bugzilla-daemon
2011-08-31  5:07 ` bugzilla-daemon
2011-08-31 14:36 ` bugzilla-daemon
2011-08-31 23:43 ` bugzilla-daemon
2011-09-01  1:30 ` bugzilla-daemon
2011-09-04  3:53 ` bugzilla-daemon
2011-09-04 13:55 ` bugzilla-daemon
2011-09-04 14:00 ` bugzilla-daemon
2011-09-05 17:44 ` bugzilla-daemon
2011-09-09 19:13   ` Ted Ts'o [this message]
2011-09-09 22:10     ` Alan Stern
     [not found]       ` <BAY151-W6176D929049AA9E2BDBAEBA1000@phx.gbl>
2011-09-10 14:06         ` Ted Ts'o
2011-09-10 18:07     ` Alan Stern
2011-09-12  1:58     ` Alan Stern
2012-07-02 13:24 ` bugzilla-daemon
     [not found] <BAY151-W3498E8491E671BDAE90421A1070@phx.gbl>
2011-09-16 16:28 ` Alan Stern
     [not found] <BAY151-W1224E6C1A20D179965A149A1090@phx.gbl>
2011-09-17 13:21 ` Alan Stern

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=20110909191354.GC3818@thunk.org \
    --to=tytso@mit.edu \
    --cc=bugzilla-daemon@bugzilla.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=rockorequin@hotmail.com \
    --cc=stern@rowland.harvard.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).