From: Jan Kara <jack@suse.cz>
To: Jiaying Zhang <jiayingz@google.com>
Cc: Dave Chinner <david@fromorbit.com>, Tao Ma <tm@tao.ma>,
Jan Kara <jack@suse.cz>, Michael Tokarev <mjt@tls.msk.ru>,
linux-ext4@vger.kernel.org, sandeen@redhat.com
Subject: Re: DIO process stuck apparently due to dioread_nolock (3.0)
Date: Wed, 17 Aug 2011 11:04:15 +0200 [thread overview]
Message-ID: <20110817090415.GA9959@quack.suse.cz> (raw)
In-Reply-To: <CAFgt=MD4EmeEXNQGinMJHyZ-DOoWPnBbYdzdcw2YRm+yYjodpw@mail.gmail.com>
On Tue 16-08-11 17:08:42, Jiaying Zhang wrote:
> On Tue, Aug 16, 2011 at 4:59 PM, Dave Chinner <david@fromorbit.com> wrote:
> > On Tue, Aug 16, 2011 at 02:32:12PM -0700, Jiaying Zhang wrote:
> >> On Tue, Aug 16, 2011 at 8:03 AM, Tao Ma <tm@tao.ma> wrote:
> >> > On 08/16/2011 09:53 PM, Jan Kara wrote:
> >> I wonder whether the following patch will solve the problem:
> >>
> >> diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
> >> index 6c27111..ca90d73 100644
> >> --- a/fs/ext4/indirect.c
> >> +++ b/fs/ext4/indirect.c
> >> @@ -800,12 +800,17 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
> >> }
> >>
> >> retry:
> >> - if (rw == READ && ext4_should_dioread_nolock(inode))
> >> + if (rw == READ && ext4_should_dioread_nolock(inode)) {
> >> + if (unlikely(!list_empty(&ei->i_completed_io_list))) {
> >> + mutex_lock(&inode->i_mutex);
> >> + ext4_flush_completed_IO(inode);
> >> + mutex_unlock(&inode->i_mutex);
> >> + }
> >> ret = __blockdev_direct_IO(rw, iocb, inode,
> >> inode->i_sb->s_bdev, iov,
> >> offset, nr_segs,
> >> ext4_get_block, NULL, NULL, 0);
> >> - else {
> >> + } else {
> >> ret = blockdev_direct_IO(rw, iocb, inode,
> >> inode->i_sb->s_bdev, iov,
> >> offset, nr_segs,
> >>
> >> I tested the patch a little bit and it seems to resolve the race
> >> on dioread_nolock in my case. Michael, I would very appreciate
> >> if you can try this patch with your test case and see whether it works.
> >
> > Just my 2c worth here: this is a data corruption bug so the root
> > cause neeeds to be fixed. The above patch does not address the root
> > cause.
> >
> >> > You are absolutely right. The really problem is that ext4_direct_IO
> >> > begins to work *after* we clear the page writeback flag and *before* we
> >> > convert unwritten extent to a valid state. Some of my trace does show
> >> > that. I am working on it now.
> >
> > And that's the root cause - think about what that means for a
> > minute. It means that extent conversion can race with anything that
> > requires IO to complete first. e.g. truncate or fsync. It can then
> > race with other subsequent operations, which can have even nastier
> > effects. IOWs, there is a data-corruption landmine just sitting
> > there waiting for the next person to trip over it.
> You are right that extent conversion can race with truncate and fsync
> as well. That is why we already need to call ext4_flush_completed_IO()
> in those places as well. I agree this is a little nasty and there can be
> some other corner cases that we haven't covered.
Exactly. I agree with Dave here that it is asking for serious trouble to
clear PageWriteback bit before really completing the IO.
> The problem is we can not do extent conversion during the end_io time. I
> haven't thought of a better approach to deal with these races. I am
> curious how xfs deals with this problem.
Well, XFS cannot do extent conversion in end_io for AIO+DIO either. So it
clears PageWriteback bit only after extent conversion has happened in the
worker thread. ext4 has problems with this (deadlocks) because of unlucky
locking of extent tree using i_mutex. So I believe we have to find a better
locking for extent tree so that ext4 can clear PageWriteback bit from the
worker thread...
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2011-08-17 9:04 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-08-10 10:51 DIO process stuck apparently due to dioread_nolock (3.0) Michael Tokarev
2011-08-11 11:59 ` Jan Kara
2011-08-11 12:21 ` Michael Tokarev
2011-08-11 14:01 ` Jan Kara
2011-08-11 20:05 ` Michael Tokarev
2011-08-12 2:46 ` Jiaying Zhang
2011-08-12 6:23 ` Michael Tokarev
2011-08-12 7:07 ` Michael Tokarev
2011-08-12 13:07 ` Jan Kara
2011-08-12 15:55 ` Michael Tokarev
2011-08-12 17:01 ` Eric Sandeen
2011-08-12 17:34 ` Michael Tokarev
2011-08-13 16:02 ` Tao Ma
2011-08-14 20:57 ` Michael Tokarev
2011-08-14 21:07 ` Michael Tokarev
2011-08-15 2:36 ` Tao Ma
2011-08-15 8:00 ` Michael Tokarev
2011-08-15 8:56 ` Michael Tokarev
2011-08-15 9:03 ` Michael Tokarev
2011-08-15 10:28 ` Tao Ma
2011-08-15 23:53 ` Jiaying Zhang
2011-08-16 4:15 ` Tao Ma
2011-08-16 8:38 ` Michael Tokarev
2011-08-16 13:53 ` Jan Kara
2011-08-16 15:03 ` Tao Ma
2011-08-16 21:32 ` Jiaying Zhang
2011-08-16 22:28 ` Michael Tokarev
2011-08-16 23:07 ` Jiaying Zhang
2011-08-17 17:02 ` Ted Ts'o
2011-08-18 6:49 ` Michael Tokarev
2011-08-18 18:54 ` Jiaying Zhang
2011-08-19 3:20 ` Tao Ma
2011-08-19 3:18 ` Tao Ma
2011-08-19 7:05 ` Michael Tokarev
2011-08-19 17:55 ` Jiaying Zhang
2011-08-16 23:59 ` Dave Chinner
2011-08-17 0:08 ` Jiaying Zhang
2011-08-17 2:22 ` Tao Ma
2011-08-17 9:04 ` Jan Kara [this message]
2011-08-15 16:08 ` Eric Sandeen
2011-08-16 4:12 ` Tao Ma
2011-08-16 6:15 ` Tao Ma
2011-08-12 21:19 ` Jan Kara
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=20110817090415.GA9959@quack.suse.cz \
--to=jack@suse.cz \
--cc=david@fromorbit.com \
--cc=jiayingz@google.com \
--cc=linux-ext4@vger.kernel.org \
--cc=mjt@tls.msk.ru \
--cc=sandeen@redhat.com \
--cc=tm@tao.ma \
/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).