linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Ted Ts'o <tytso@mit.edu>
To: Jon Nelson <jnelson@jamponi.net>
Cc: Matt <jackdachef@gmail.com>, Chris Mason <chris.mason@oracle.com>,
	Andi Kleen <andi@firstfloor.org>,
	Mike Snitzer <snitzer@redhat.com>, Milan Broz <mbroz@redhat.com>,
	linux-btrfs <linux-btrfs@vger.kernel.org>,
	dm-devel <dm-devel@redhat.com>,
	Linux Kernel <linux-kernel@vger.kernel.org>,
	htd <htd@fancy-poultry.org>, htejun <htejun@gmail.com>,
	linux-ext4 <linux-ext4@vger.kernel.org>
Subject: Re: hunt for 2.6.37 dm-crypt+ext4 corruption? (was: Re: dm-crypt barrier support is effective)
Date: Sun, 12 Dec 2010 21:06:57 -0500	[thread overview]
Message-ID: <20101213020657.GB4513@thunk.org> (raw)
In-Reply-To: <AANLkTikZkCs7Wee2=uhe3bw96Pggcv0jsCkZ+nkWEQ+=@mail.gmail.com>

On Sun, Dec 12, 2010 at 07:11:28AM -0600, Jon Nelson wrote:
> I'm glad you've been able to reproduce the problem! If you should need
> any further assistance, please do not hesitate to ask.

This patch seems to fix the problem for me.  (Unless the partition is
mounted with mblk_io_submit.)

Could you confirm that it fixes it for you as well?

Thanks!

					- Ted

commit a8649d85bd0ab3be6014918bd9eae319a0ffc691
Author: Theodore Ts'o <tytso@mit.edu>
Date:   Sun Dec 12 20:57:19 2010 -0500

    ext4: Turn off multiple page-io submission by default
    
    Jon Nelson has found a test case which causes postgresql to fail with
    the error:
    
    psql:t.sql:4: ERROR: invalid page header in block 38269 of relation base/16384/16581
    
    Under memory pressure, it looks like part of a file can end up getting
    replaced by zero's.  Until we can figure out the cause, we'll roll
    back the change and use block_write_full_page() instead of
    ext4_bio_write_page().  The new, more efficient writing function can
    be used via the mount option mblk_io_submit, so we can test and fix
    the new page I/O code.
    
    To reproduce the problem, install postgres 8.4 or 9.0, and pin enough
    memory such that the system just at the end of triggering writeback
    before running the following sql script:
    
    begin;
    create temporary table foo as select x as a, ARRAY[x] as b FROM
    generate_series(1, 10000000 ) AS x;
    create index foo_a_idx on foo (a);
    create index foo_b_idx on foo USING GIN (b);
    rollback;
    
    If the temporary table is created on a hard drive partition which is
    encrypted using dm_crypt, then under memory pressure, approximately
    30-40% of the time, pgsql will issue the above failure.
    
    This patch should fix this problem, and the problem will come back if
    the file system is mounted with the mblk_io_submit mount option.
    
    Reported-by: Jon Nelson <jnelson@jamponi.net>
    Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>

diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
index 6a5edea..6eb598b 100644
--- a/fs/ext4/ext4.h
+++ b/fs/ext4/ext4.h
@@ -910,6 +910,7 @@ struct ext4_inode_info {
 #define EXT4_MOUNT_JOURNAL_CHECKSUM	0x800000 /* Journal checksums */
 #define EXT4_MOUNT_JOURNAL_ASYNC_COMMIT	0x1000000 /* Journal Async Commit */
 #define EXT4_MOUNT_I_VERSION            0x2000000 /* i_version support */
+#define EXT4_MOUNT_MBLK_IO_SUBMIT	0x4000000
 #define EXT4_MOUNT_DELALLOC		0x8000000 /* Delalloc support */
 #define EXT4_MOUNT_DATA_ERR_ABORT	0x10000000 /* Abort on file data write */
 #define EXT4_MOUNT_BLOCK_VALIDITY	0x20000000 /* Block validity checking */
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index bdbe699..e659597 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -2125,9 +2125,12 @@ static int mpage_da_submit_io(struct mpage_da_data *mpd,
 			 */
 			if (unlikely(journal_data && PageChecked(page)))
 				err = __ext4_journalled_writepage(page, len);
-			else
+			else if (test_opt(inode->i_sb, MBLK_IO_SUBMIT))
 				err = ext4_bio_write_page(&io_submit, page,
 							  len, mpd->wbc);
+			else
+				err = block_write_full_page(page,
+					noalloc_get_block_write, mpd->wbc);
 
 			if (!err)
 				mpd->pages_written++;
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index e32195d..fb15c9c 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -1026,6 +1026,8 @@ static int ext4_show_options(struct seq_file *seq, struct vfsmount *vfs)
 	    !(def_mount_opts & EXT4_DEFM_NODELALLOC))
 		seq_puts(seq, ",nodelalloc");
 
+	if (test_opt(sb, MBLK_IO_SUBMIT))
+		seq_puts(seq, ",mblk_io_submit");
 	if (sbi->s_stripe)
 		seq_printf(seq, ",stripe=%lu", sbi->s_stripe);
 	/*
@@ -1239,8 +1241,8 @@ enum {
 	Opt_jqfmt_vfsold, Opt_jqfmt_vfsv0, Opt_jqfmt_vfsv1, Opt_quota,
 	Opt_noquota, Opt_ignore, Opt_barrier, Opt_nobarrier, Opt_err,
 	Opt_resize, Opt_usrquota, Opt_grpquota, Opt_i_version,
-	Opt_stripe, Opt_delalloc, Opt_nodelalloc,
-	Opt_block_validity, Opt_noblock_validity,
+	Opt_stripe, Opt_delalloc, Opt_nodelalloc, Opt_mblk_io_submit,
+	Opt_nomblk_io_submit, Opt_block_validity, Opt_noblock_validity,
 	Opt_inode_readahead_blks, Opt_journal_ioprio,
 	Opt_dioread_nolock, Opt_dioread_lock,
 	Opt_discard, Opt_nodiscard,
@@ -1304,6 +1306,8 @@ static const match_table_t tokens = {
 	{Opt_resize, "resize"},
 	{Opt_delalloc, "delalloc"},
 	{Opt_nodelalloc, "nodelalloc"},
+	{Opt_mblk_io_submit, "mblk_io_submit"},
+	{Opt_nomblk_io_submit, "nomblk_io_submit"},
 	{Opt_block_validity, "block_validity"},
 	{Opt_noblock_validity, "noblock_validity"},
 	{Opt_inode_readahead_blks, "inode_readahead_blks=%u"},
@@ -1725,6 +1729,12 @@ set_qf_format:
 		case Opt_nodelalloc:
 			clear_opt(sbi->s_mount_opt, DELALLOC);
 			break;
+		case Opt_mblk_io_submit:
+			set_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT);
+			break;
+		case Opt_nomblk_io_submit:
+			clear_opt(sbi->s_mount_opt, MBLK_IO_SUBMIT);
+			break;
 		case Opt_stripe:
 			if (match_int(&args[0], &option))
 				return 0;

  reply	other threads:[~2010-12-13  2:06 UTC|newest]

Thread overview: 104+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <AANLkTim6WTCChWGbTb-PUGd2AERGibeRtgan-WDznf2s@mail.gmail.com>
     [not found] ` <4CD6B7FA.3050005@redhat.com>
     [not found]   ` <AANLkTikbsU+SGAaoq_oek=7tfDdjg+0wFoydhA+K9ZU+@mail.gmail.com>
     [not found]     ` <AANLkTinna7BiGHogXnn1iEG6ccUAjFM3p3S3aHpv=h-E@mail.gmail.com>
     [not found]       ` <20101107194547.GA12521@basil.fritz.box>
     [not found]         ` <4CD71C8B.1050604@redhat.com>
     [not found]           ` <20101107230508.GB17592@basil.fritz.box>
2010-11-08 14:58             ` DM-CRYPT: Scale to multiple CPUs v3 on 2.6.37-rc* ? Mike Snitzer
2010-11-08 17:59               ` Chris Mason
2010-11-14 20:59                 ` dm-crypt barrier support is effective (was: Re: DM-CRYPT: Scale to multiple CPUs v3 on 2.6.37-rc* ?) Mike Snitzer
2010-11-14 21:49                   ` Matt
2010-11-14 21:54                     ` dm-crypt barrier support is effective Milan Broz
2010-11-14 23:24                       ` Matt
2010-12-01 16:05                         ` Matt
2010-12-01 16:52                           ` Mike Snitzer
2010-12-01 17:35                             ` Matt
2010-12-01 18:24                               ` Milan Broz
2010-12-01 19:34                                 ` Jon Nelson
2010-12-01 20:45                                   ` Milan Broz
2010-12-01 21:23                                     ` hunt for 2.6.37 dm-crypt+ext4 corruption? (was: Re: dm-crypt barrier support is effective) Mike Snitzer
2010-12-02 21:30                                       ` Matt
2010-12-04 19:18                                       ` Matt
2010-12-04 19:38                                         ` Mike Snitzer
2010-12-04 23:47                                           ` Matt
2010-12-07 14:21                                             ` Chris Mason
2010-12-07 18:10                                               ` Jon Nelson
2010-12-07 18:10                                               ` Jon Nelson
2010-12-07 18:15                                                 ` Chris Mason
2010-12-07 18:22                                                 ` Mike Snitzer
2010-12-07 18:45                                                   ` Jon Nelson
2010-12-07 18:52                                                     ` Chris Mason
2010-12-07 19:34                                                       ` Jon Nelson
2010-12-07 20:02                                                         ` Chris Mason
2010-12-07 20:25                                                           ` Jon Nelson
2010-12-07 20:33                                                             ` Chris Mason
2010-12-07 20:36                                                               ` Jon Nelson
2010-12-07 20:41                                                             ` Chris Mason
2010-12-07 20:48                                                               ` Jon Nelson
2010-12-07 21:02                                                                 ` Chris Mason
2010-12-08  3:29                                                                   ` Jon Nelson
2010-12-08  8:03                                                                     ` hunt for 2.6.37 dm-crypt+ext4 corruption? Milan Broz
2010-12-08 12:20                                                                     ` hunt for 2.6.37 dm-crypt+ext4 corruption? (was: Re: dm-crypt barrier support is effective) Chris Mason
2010-12-16  3:37                                                                       ` Dave Chinner
2010-12-16 12:29                                                                         ` Chris Mason
2010-12-08  3:55                                                               ` Jon Nelson
2010-12-07 19:35                                                   ` Ted Ts'o
2010-12-07 21:01                                                     ` Jon Nelson
2010-12-07 21:01                                                     ` Jon Nelson
2010-12-08  3:37                                                     ` Jon Nelson
2010-12-08 15:26                                                       ` Jon Nelson
2010-12-08 15:26                                                       ` Jon Nelson
2010-12-09 18:01                                                       ` Ted Ts'o
2010-12-09 18:10                                                         ` Jon Nelson
2010-12-09 20:13                                                           ` Ted Ts'o
2010-12-09 20:38                                                             ` Jon Nelson
2010-12-09 20:38                                                             ` Jon Nelson
2010-12-09 23:16                                                               ` Andi Kleen
2010-12-10  1:38                                                                 ` Chris Mason
2010-12-10  1:53                                                                   ` Matt
2010-12-10  2:38                                                                     ` Ted Ts'o
2010-12-10  6:52                                                                       ` Jon Nelson
2010-12-10  6:52                                                                       ` Jon Nelson
2010-12-10 14:58                                                                         ` Jon Nelson
2010-12-10 14:58                                                                         ` Jon Nelson
2010-12-10 16:54                                                                           ` Jon Nelson
2010-12-11  2:14                                                                             ` Jon Nelson
2010-12-11  2:14                                                                             ` Jon Nelson
2010-12-12  1:40                                                                               ` Ted Ts'o
2010-12-12  2:34                                                                               ` Ted Ts'o
2010-12-12  3:16                                                                                 ` Jon Nelson
2010-12-12 10:18                                                                                   ` Jon Nelson
2010-12-12 10:18                                                                                   ` Jon Nelson
2010-12-12 12:43                                                                                     ` Ted Ts'o
2010-12-12 13:11                                                                                       ` Jon Nelson
2010-12-12 13:11                                                                                       ` Jon Nelson
2010-12-13  2:06                                                                                         ` Ted Ts'o [this message]
2010-12-13 18:56                                                                                           ` Jon Nelson
2010-12-15 19:15                                                                                             ` Matt
2010-12-15 19:16                                                                                               ` Andi Kleen
2010-12-15 19:25                                                                                                 ` Matt
2010-12-15 19:28                                                                                                   ` Matt
2010-12-13 18:56                                                                                           ` Jon Nelson
2010-12-12  3:16                                                                                 ` Jon Nelson
2010-12-10 16:54                                                                           ` Jon Nelson
2010-12-10  1:58                                                                   ` Mike Fedyk
2010-12-10  2:00                                                                     ` Chris Mason
2010-12-10  2:05                                                                       ` Jon Nelson
2010-12-09 18:10                                                         ` Jon Nelson
2010-12-08  3:37                                                     ` Jon Nelson
2010-12-04 23:52                                           ` Matt
2010-12-05 10:09                                             ` Heinz Diehl
2010-12-05 10:21                                               ` hunt for 2.6.37 dm-crypt+ext4 corruption? Milan Broz
2010-12-05 12:49                                                 ` Heinz Diehl
2010-12-05 13:24                                                 ` [dm-devel] " Theodore Tso
2010-12-05 13:44                                                   ` Matt
2010-12-05 14:02                                                     ` Ted Ts'o
2010-12-05 14:33                                                   ` Heinz Diehl
2010-12-05 20:17                                                     ` Daniel J Blueman
2010-12-06  7:08                                                       ` Heinz Diehl
2010-12-05 20:28                                                   ` Andi Kleen
2010-12-05 21:15                                                     ` Mike Snitzer
2010-12-05 21:42                                                     ` [dm-devel] " Milan Broz
2010-12-06  2:37                                                   ` Valdis.Kletnieks
2011-01-06 15:56                                                 ` Heinz Diehl
2011-01-07 16:45                                                   ` Matt
2010-12-05 13:30                                               ` hunt for 2.6.37 dm-crypt+ext4 corruption? (was: Re: dm-crypt barrier support is effective) Matt
2010-12-05  0:57                                           ` Matt
2010-12-04 20:51                                         ` Heinz Diehl
2010-12-01 19:59                                 ` dm-crypt barrier support is effective Heinz Diehl
2010-11-15  7:25                       ` Heinz Diehl
2010-11-15  8:41                         ` Milan Broz

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=20101213020657.GB4513@thunk.org \
    --to=tytso@mit.edu \
    --cc=andi@firstfloor.org \
    --cc=chris.mason@oracle.com \
    --cc=dm-devel@redhat.com \
    --cc=htd@fancy-poultry.org \
    --cc=htejun@gmail.com \
    --cc=jackdachef@gmail.com \
    --cc=jnelson@jamponi.net \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-ext4@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mbroz@redhat.com \
    --cc=snitzer@redhat.com \
    /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).