From: Zheng Liu <gnehzuil.liu@gmail.com>
To: Jan Kara <jack@suse.cz>
Cc: Ted Tso <tytso@mit.edu>, linux-ext4@vger.kernel.org
Subject: Re: [PATCH] ext4: Fix data corruption with direct IO read in dioread_nolock mode
Date: Thu, 11 Apr 2013 21:20:36 +0800 [thread overview]
Message-ID: <20130411132036.GA3448@gmail.com> (raw)
In-Reply-To: <1365438463-23025-1-git-send-email-jack@suse.cz>
On Mon, Apr 08, 2013 at 06:27:43PM +0200, Jan Kara wrote:
> When ext4 is mounted in dioread_nolock mode, it calls
> __blockdev_direct_IO() without DIO_LOCKING flag which also means mapping
> is not synced before direct IO starts. As a result consistency between
> buffered writes and following direct IO reads is broken. More
> importantly, if the file is truncated, and extented back, zeroing of the
> tail page is not visible to the following direct IO read which will return
> stale data.
>
> Fix the problem by flushing dirty pages before issuing direct IO read.
>
> Signed-off-by: Jan Kara <jack@suse.cz>
> ---
> fs/ext4/indirect.c | 4 ++++
> 1 files changed, 4 insertions(+), 0 deletions(-)
>
> diff --git a/fs/ext4/indirect.c b/fs/ext4/indirect.c
> index b505a14..c18bf1c 100644
> --- a/fs/ext4/indirect.c
> +++ b/fs/ext4/indirect.c
> @@ -809,6 +809,10 @@ ssize_t ext4_ind_direct_IO(int rw, struct kiocb *iocb,
>
> retry:
> if (rw == READ && ext4_should_dioread_nolock(inode)) {
> + ret = filemap_write_and_wait_range(inode->i_mapping, offset,
> + offset + count - 1);
> + if (ret)
> + goto out;
> if (unlikely(atomic_read(&EXT4_I(inode)->i_unwritten))) {
> mutex_lock(&inode->i_mutex);
> ext4_flush_unwritten_io(inode);
Hi Jan,
Sorry for the late reply. I have a question about this patch. In your
patch, we flush dirty pages befoer issuing a dio read. But we have
flushed dirty pages in generic_file_aio_read(). So is it really
necessary to flush dirty pages again?
Regards,
- Zheng
next prev parent reply other threads:[~2013-04-11 13:03 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-04-08 16:27 [PATCH] ext4: Fix data corruption with direct IO read in dioread_nolock mode Jan Kara
2013-04-10 21:08 ` Jan Kara
2013-04-11 0:47 ` Theodore Ts'o
2013-04-11 13:20 ` Zheng Liu [this message]
2013-04-11 21:07 ` Jan Kara
2013-04-12 3:18 ` 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=20130411132036.GA3448@gmail.com \
--to=gnehzuil.liu@gmail.com \
--cc=jack@suse.cz \
--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).