linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Theodore Ts'o <tytso@mit.edu>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org, stable@vger.kernel.org
Subject: Re: [PATCH] ext4: Fix data corruption caused by unwritten and delayed extents
Date: Sat, 2 May 2015 22:31:06 -0400	[thread overview]
Message-ID: <20150503023106.GE10014@thunk.org> (raw)
In-Reply-To: <1429711576-15006-1-git-send-email-lczerner@redhat.com>

On Wed, Apr 22, 2015 at 04:06:16PM +0200, Lukas Czerner wrote:
> Currently it is possible to lose whole file system block worth of data
> when we hit the specific interaction with unwritten and delayed extents
> in status extent tree.
> 
> The problem is that when we insert delayed extent into extent status
> tree the only way to get rid of it is when we write out delayed buffer.
> However there is a limitation in the extent status tree implementation
> so that when inserting unwritten extent should there be even a single
> delayed block the whole unwritten extent would be marked as delayed.
> 
> At this point, there is no way to get rid of the delayed extents,
> because there are no delayed buffers to write out. So when a we write
> into said unwritten extent we will convert it to written, but it still
> remains delayed.
> 
> When we try to write into that block later ext4_da_map_blocks() will set
> the buffer new and delayed and map it to invalid block which causes
> the rest of the block to be zeroed loosing already written data.
> 
> For now we can fix this by simply not allowing to set delayed status on
> written extent in the extent status tree. Also add WARN_ON() to make
> sure that we notice if this happens in the future.
> 
> This problem can be easily reproduced by running the following xfs_io.
> 
> xfs_io -f -c "pwrite -S 0xaa 4096 2048" \
>           -c "falloc 0 131072" \
>           -c "pwrite -S 0xbb 65536 2048" \
>           -c "fsync" /mnt/test/fff
> 
> echo 3 > /proc/sys/vm/drop_caches
> xfs_io -c "pwrite -S 0xdd 67584 2048" /mnt/test/fff
> 
> This can be theoretically also reproduced by at random by running fsx,
> but it's not very reliable, though on machines with bigger page size
> (like ppc) this can be seen more often (especially xfstest generic/127)
> 
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
> Cc: stable@vger.kernel.org

Applied, thanks.

						- Ted

      reply	other threads:[~2015-05-03  2:31 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-22 14:06 [PATCH] ext4: Fix data corruption caused by unwritten and delayed extents Lukas Czerner
2015-05-03  2:31 ` 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=20150503023106.GE10014@thunk.org \
    --to=tytso@mit.edu \
    --cc=lczerner@redhat.com \
    --cc=linux-ext4@vger.kernel.org \
    --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;
as well as URLs for NNTP newsgroup(s).