All of lore.kernel.org
 help / color / mirror / Atom feed
From: Theodore Tso <tytso@mit.edu>
To: Andreas Sundstrom <sunkan@zappa.cx>
Cc: linux-kernel@vger.kernel.org
Subject: Re: 2.6.28 ext4, xen and lvm volume becomes ro after snapshot
Date: Thu, 1 Jan 2009 22:11:10 -0500	[thread overview]
Message-ID: <20090102031110.GF17821@mit.edu> (raw)
In-Reply-To: <4955F338.4020509@zappa.cx>

On Sat, Dec 27, 2008 at 10:19:52AM +0100, Andreas Sundstrom wrote:
> Theodore Tso wrote:
> > On Fri, Dec 26, 2008 at 11:00:11PM +0100, Andreas Sundstrom wrote:
> >> But I enabled debugfs and did
> >> "echo 3 > /sys/kernel/debug/jbd2/jbd2-debug" and reproduced the problem
> >> by taking a snapshot while the system was live.
> >> I hope this had the same effect as your proposed change.
> > 
> > Thanks, that was helpful.  Can you try applying this patch, and let me
> > know whether the printk triggers?
> 
> No problem
> 

Hi Andreas,

Can you try this patch?  This should (hopefully!) allow you to mount
ext4 in a Xen guest without needing to explicitly disable barriers.
If it works, it's what I plan to push to Linus.

         	     	       	      	      	 - Ted

jbd2: Add barrier not supported test to journal_wait_on_commit_record

Xen doesn't report that barriers are not supported until buffer I/O is
reported as completed, instead of when the buffer I/O is submitted.
Add a check and a fallback codepath to journal_wait_on_commit_record()
to detect this case, so that attempts to mount ext4 filesystems on
LVM/devicemapper devices on Xen guests don't blow up with an "Aborting
journal on device XXX"; "Remounting filesystem read-only" error.

Thanks to Andreas Sundstrom for reporting this issue.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
---

diff --git a/fs/jbd2/commit.c b/fs/jbd2/commit.c
index bd1fad0..4b87547 100644
--- a/fs/jbd2/commit.c
+++ b/fs/jbd2/commit.c
@@ -25,6 +25,7 @@
 #include <linux/crc32.h>
 #include <linux/writeback.h>
 #include <linux/backing-dev.h>
+#include <linux/bio.h>
 
 /*
  * Default IO end handler for temporary BJ_IO buffer_heads.
@@ -168,12 +169,34 @@ static int journal_submit_commit_record(journal_t *journal,
  * This function along with journal_submit_commit_record
  * allows to write the commit record asynchronously.
  */
-static int journal_wait_on_commit_record(struct buffer_head *bh)
+static int journal_wait_on_commit_record(journal_t *journal, 
+					 struct buffer_head *bh)
 {
 	int ret = 0;
 
+retry:
 	clear_buffer_dirty(bh);
 	wait_on_buffer(bh);
+	if (buffer_eopnotsupp(bh) && (journal->j_flags & JBD2_BARRIER)) {
+		printk(KERN_WARNING
+		       "JBD2: wait_on_commit_record: sync failed on %s - "
+		       "disabling barriers\n", journal->j_devname);
+		spin_lock(&journal->j_state_lock);
+		journal->j_flags &= ~JBD2_BARRIER;
+		spin_unlock(&journal->j_state_lock);
+
+		lock_buffer(bh);
+		clear_buffer_dirty(bh);
+		set_buffer_uptodate(bh);
+		bh->b_end_io = journal_end_buffer_io_sync;
+
+		ret = submit_bh(WRITE_SYNC, bh);
+		if (ret) {
+			unlock_buffer(bh);
+			return ret;
+		}
+		goto retry;
+	}
 
 	if (unlikely(!buffer_uptodate(bh)))
 		ret = -EIO;
@@ -802,7 +825,7 @@ wait_for_iobuf:
 			__jbd2_journal_abort_hard(journal);
 	}
 	if (!err && !is_journal_aborted(journal))
-		err = journal_wait_on_commit_record(cbh);
+		err = journal_wait_on_commit_record(journal, cbh);
 
 	if (err)
 		jbd2_journal_abort(journal, err);

  reply	other threads:[~2009-01-02  3:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-26 11:06 2.6.28 ext4, xen and lvm volume becomes ro after snapshot Andreas Sundstrom
2008-12-26 14:07 ` Theodore Tso
2008-12-26 15:42   ` Andreas Sundstrom
2008-12-26 18:21     ` Theodore Tso
2008-12-26 18:48       ` Andreas Sundstrom
2008-12-26 19:33         ` Theodore Tso
2008-12-26 22:00           ` Andreas Sundstrom
2008-12-27  3:06             ` Theodore Tso
2008-12-27  9:19               ` Andreas Sundstrom
2009-01-02  3:11                 ` Theodore Tso [this message]
2009-01-02  8:29                   ` Andreas Sundstrom
2009-01-02 14:10                     ` Theodore Tso
2009-01-03 10:25                       ` Andreas Sundstrom

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=20090102031110.GF17821@mit.edu \
    --to=tytso@mit.edu \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sunkan@zappa.cx \
    /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.