From: Theodore Ts'o <tytso@mit.edu>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org,
Ross Zwisler <ross.zwisler@linux.intel.com>,
stable@vger.kernel.org
Subject: Re: [PATCH] ext4: Fix data corruption with EXT4_GET_BLOCKS_ZERO
Date: Fri, 26 May 2017 17:44:56 -0400 [thread overview]
Message-ID: <20170526214456.4dihz6evugpfrlff@thunk.org> (raw)
In-Reply-To: <20170525084313.29894-1-jack@suse.cz>
On Thu, May 25, 2017 at 10:43:13AM +0200, Jan Kara wrote:
> When ext4_map_blocks() is called with EXT4_GET_BLOCKS_ZERO to zero-out
> allocated blocks and these blocks are actually converted from unwritten
> extent the following race can happen:
>
> CPU0 CPU1
>
> page fault page fault
> ... ...
> ext4_map_blocks()
> ext4_ext_map_blocks()
> ext4_ext_handle_unwritten_extents()
> ext4_ext_convert_to_initialized()
> - zero out converted extent
> ext4_zeroout_es()
> - inserts extent as initialized in status tree
>
> ext4_map_blocks()
> ext4_es_lookup_extent()
> - finds initialized extent
> write data
> ext4_issue_zeroout()
> - zeroes out new extent overwriting data
>
> This problem can be reproduced by generic/340 for the fallocated case
> for the last block in the file.
>
> Fix the problem by avoiding zeroing out the area we are mapping with
> ext4_map_blocks() in ext4_ext_convert_to_initialized(). It is pointless
> to zero out this area in the first place as the caller asked us to
> convert the area to initialized because he is just going to write data
> there before the transaction finishes. To achieve this we delete the
> special case of zeroing out full extent as that will be handled by the
> cases below zeroing only the part of the extent that needs it. We also
> instruct ext4_split_extent() that the middle of extent being split
> contains data so that ext4_split_extent_at() cannot zero out full extent
> in case of ENOSPC.
>
> CC: stable@vger.kernel.org
> Fixes: 12735f881952c32b31bc4e433768f18489f79ec9
> Signed-off-by: Jan Kara <jack@suse.cz>
Thanks, applied.
- Ted
prev parent reply other threads:[~2017-05-26 21:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-05-25 8:43 [PATCH] ext4: Fix data corruption with EXT4_GET_BLOCKS_ZERO Jan Kara
2017-05-26 21:44 ` Theodore Ts'o [this message]
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=20170526214456.4dihz6evugpfrlff@thunk.org \
--to=tytso@mit.edu \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=ross.zwisler@linux.intel.com \
--cc=stable@vger.kernel.org \
/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