From: Jan Kara <jack@suse.cz>
To: Zheng Liu <gnehzuil.liu@gmail.com>
Cc: Jan Kara <jack@suse.cz>, Dmitry Monakhov <dmonakhov@openvz.org>,
Ted Tso <tytso@mit.edu>,
linux-ext4@vger.kernel.org
Subject: Re: [PATCH 03/12] ext4: Remove bogus wait for unwritten extents in ext4_ind_direct_IO
Date: Wed, 23 Jan 2013 10:42:48 +0100 [thread overview]
Message-ID: <20130123094248.GA9821@quack.suse.cz> (raw)
In-Reply-To: <20130123061141.GA10440@gmail.com>
On Wed 23-01-13 14:11:41, Zheng Liu wrote:
> On Wed, Jan 23, 2013 at 12:14:32AM +0100, Jan Kara wrote:
> > On Wed 23-01-13 00:00:17, Zheng Liu wrote:
> > > On Tue, Jan 22, 2013 at 04:22:43PM +0100, Jan Kara wrote:
> > > > On Tue 22-01-13 22:22:21, Zheng Liu wrote:
> > > > > On Tue, Jan 22, 2013 at 02:44:00PM +0100, Jan Kara wrote:
> > > > > > On Tue 22-01-13 15:11:24, Dmitry Monakhov wrote:
> > > > > > > On Fri, 18 Jan 2013 13:00:37 +0100, Jan Kara <jack@suse.cz> wrote:
> > > > > > > > When using indirect blocks there is no possibility to have any unwritten
> > > > > > > > extents. So wait for them in ext4_ind_direct_IO() is just bogus.
> > > > > > > But as soon as i remember indirect implementation may also be used by
> > > > > > > extents based inodes 3074: ext4_ext_direct_IO
> > > > > > > /* Use the old path for reads and writes beyond i_size. */
> > > > > > > if (rw != WRITE || final_size > inode->i_size)
> > > > > > > return ext4_ind_direct_IO(rw, iocb, iov, offset, nr_segs);
> > > > > > >
> > > > > > > Am I missing ?
> > > > > > Ah, that's a catch. Thanks for pointing that out! So my patch is wrong
> > > > > > and that code path needs some cleaning and commenting. In particular I'm
> > > > > > afraid using dioread_nolock for inodes with indirect map causes data
> > > > > > exposure bugs when unlocked DIO read races with DIO write because such
> > > > > > inodes don't support uninitialized extents.
> > > > >
> > > > > Sorry, but I am still confused. dioread_nolock is only for extent-based
> > > > > file. So when a file system without extent feature, dioread_nolock
> > > > > couldn't be enabled. It seems that we don't need to worry about
> > > > > exposing stale data here.
> > > > Well, you can have fs with extent feature enabled but still with inodes
> > > > using indirect map. But as Dmitry pointed out, ext4_should_dioread_nolock()
> > > > handles that correctly. So there's not a bug I was suspecting.
> > >
> > > Yep, the patch itself is fine. But that would be great if a comment is
> > > added here.
> > No, the patch is wrong. The code before the patch is correct. We can get
> > to that code for extent based inode which has unwritten conversions pending
> > and we need to wait for those as otherwise we could return 0s in places
> > where we acknowledged successful write just a while ago. Or am I missing
> > something?
>
> Ah, I see. I guess that the problem is that the dio read races with buffered
> write.
>
> dio read buffered write
> ->ext4_file_write
> ->ext4_da_write_begin
> ->ext4_da_write_end
> [buffered write has finished, but the data
> and metadata has not been flushed]
> ->generic_file_aio_read
> ->filemap_write_and_wait_range
> ->do_writepages
> ->ext4_da_writepages
> ->filemap_fdatawait_range
> ->wait_on_page_writeback
> ->ext4_end_bio
> ->end_page_writeback
> [unwritten extent has not been
> converted]
> ->ext4_ind_direct_IO
> [here we need to flush unwritten io]
Yes, exactly.
> So it seems that this patch could be applied after reworking unwritten extent
> conversion.
Yes. When PageWriteback is cleared after extent conversion, this waiting
can go away and everything should be fine.
> FWIW, after applied this patch, the latency of dio read could be reduced
> dramatically. So that would be great if this patch can be applied when it
> doesn't break something.
Sure, I'll have that in mind.
Honza
--
Jan Kara <jack@suse.cz>
SUSE Labs, CR
next prev parent reply other threads:[~2013-01-23 9:42 UTC|newest]
Thread overview: 53+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-18 12:00 [PATCH 0/12 v2] ext4: Several simplifications and fixes Jan Kara
2013-01-18 12:00 ` [PATCH 01/12] ext4: Always use ext4_bio_write_page() for writeout Jan Kara
2013-01-28 14:31 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 02/12] ext4: Use redirty_page_for_writepage() in ext4_bio_write_page() Jan Kara
2013-01-28 14:34 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 03/12] ext4: Remove bogus wait for unwritten extents in ext4_ind_direct_IO Jan Kara
2013-01-22 11:11 ` Dmitry Monakhov
2013-01-22 13:44 ` Jan Kara
2013-01-22 14:12 ` Dmitry Monakhov
2013-01-22 15:21 ` Jan Kara
2013-01-22 14:22 ` Zheng Liu
2013-01-22 15:22 ` Jan Kara
2013-01-22 16:00 ` Zheng Liu
2013-01-22 23:14 ` Jan Kara
2013-01-23 6:11 ` Zheng Liu
2013-01-23 9:42 ` Jan Kara [this message]
2013-01-18 12:00 ` [PATCH 04/12] ext4: Disable merging of uninitialized extents Jan Kara
2013-01-24 9:49 ` Dmitry Monakhov
2013-01-24 15:12 ` Jan Kara
2013-01-24 15:32 ` Dmitry Monakhov
2013-01-28 14:36 ` Theodore Ts'o
2013-01-28 15:02 ` Dmitry Monakhov
2013-01-28 15:38 ` Theodore Ts'o
2013-01-29 7:41 ` Dmitry Monakhov
2013-01-29 8:37 ` Zheng Liu
2013-01-31 7:47 ` Dmitry Monakhov
2013-01-31 12:39 ` Jan Kara
2013-01-31 14:09 ` Dmitry Monakhov
2013-01-31 16:54 ` Theodore Ts'o
2013-02-09 17:10 ` REGRESSION: " Theodore Ts'o
2013-02-12 21:58 ` Jan Kara
2013-02-13 4:57 ` Theodore Ts'o
2013-02-13 7:26 ` Dmitry Monakhov
2013-02-13 15:08 ` Merge window planning for ext4 and Ted's vacation Theodore Ts'o
2013-02-14 10:47 ` REGRESSION: [PATCH 04/12] ext4: Disable merging of uninitialized extents Jan Kara
2013-02-14 16:11 ` Jan Kara
2013-02-14 19:05 ` Theodore Ts'o
2013-02-14 21:32 ` Jan Kara
2013-01-18 12:00 ` [PATCH 05/12] ext4: Remove unnecessary wait for extent conversion in ext4_fallocate() Jan Kara
2013-01-18 12:00 ` [PATCH 06/12] ext4: Move work from io_end to inode Jan Kara
2013-01-28 14:45 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 07/12] ext4: Simplify list handling in ext4_do_flush_completed_IO() Jan Kara
2013-01-28 14:51 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 08/12] ext4: Remove __ext4_journalled_writepage() from mpage_da_submit_io() Jan Kara
2013-01-28 14:40 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 09/12] ext4: Dirty page has always buffers attached Jan Kara
2013-01-28 17:55 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 10/12] ext4: Simplify mpage_add_bh_to_extent() Jan Kara
2013-01-28 18:06 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 11/12] ext4: Make ext4_bio_writepage() handle unprepared buffers Jan Kara
2013-01-29 1:59 ` Theodore Ts'o
2013-01-18 12:00 ` [PATCH 12/12] ext4: Fix ext4_writepage() to achieve data=ordered guarantees Jan Kara
2013-01-29 2:08 ` Theodore Ts'o
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=20130123094248.GA9821@quack.suse.cz \
--to=jack@suse.cz \
--cc=dmonakhov@openvz.org \
--cc=gnehzuil.liu@gmail.com \
--cc=linux-ext4@vger.kernel.org \
--cc=tytso@mit.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).