From: Dave Jones <davej@redhat.com>
To: "Theodore Ts'o" <tytso@mit.edu>
Cc: Jan Kara <jack@suse.cz>,
linux-ext4@vger.kernel.org, Zheng Liu <gnehzuil.liu@gmail.com>,
Linus Torvalds <torvalds@linux-foundation.org>
Subject: Re: [PATCH 4/4] ext4: Fix lost truncate due to race with writeback
Date: Mon, 26 Aug 2013 15:01:48 -0400 [thread overview]
Message-ID: <20130826190137.GA27768@redhat.com> (raw)
In-Reply-To: <20130817141227.GG30769@thunk.org>
On Sat, Aug 17, 2013 at 10:12:27AM -0400, Theodore Ts'o wrote:
> On Mon, Aug 05, 2013 at 03:52:24PM +0200, Jan Kara wrote:
> > The following race can lead to a loss of i_disksize update from truncate
> > thus resulting in a wrong inode size if the inode size isn't updated
> > again before inode is reclaimed:
> >
> > ext4_setattr() mpage_map_and_submit_extent()
> > EXT4_I(inode)->i_disksize = attr->ia_size;
> > ... ...
> > disksize = ((loff_t)mpd->first_page) << PAGE_CACHE_SHIFT
> > /* False because i_size isn't
> > * updated yet */
> > if (disksize > i_size_read(inode))
> > /* True, because i_disksize is
> > * already truncated */
> > if (disksize > EXT4_I(inode)->i_disksize)
> > /* Overwrite i_disksize
> > * update from truncate */
> > ext4_update_i_disksize()
> > i_size_write(inode, attr->ia_size);
> >
> > For other places updating i_disksize such race cannot happen because
> > i_mutex prevents these races. Writeback is the only place where we do
> > not hold i_mutex and we cannot grab it there because of lock ordering.
> >
> > We fix the race by doing both i_disksize and i_size update in truncate
> > atomically under i_data_sem and in mpage_map_and_submit_extent() we move
> > the check against i_size under i_data_sem as well.
> >
> > Signed-off-by: Jan Kara <jack@suse.cz>
>
> Applied, thanks.
Is this queued for 3.11 ? 1k blocksize fs's are still broken in rc7.
Dave
next prev parent reply other threads:[~2013-08-26 19:02 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-05 13:52 [PATCH 0/4 v2] ext4: Fix races between writeback and truncate Jan Kara
2013-08-05 13:52 ` [PATCH 1/4] ext4: Move test whether extent to map can be extended to one place Jan Kara
2013-08-17 13:59 ` Theodore Ts'o
2013-08-05 13:52 ` [PATCH 2/4] ext4: Fix ext4_writepages() in presence of truncate Jan Kara
2013-08-17 14:08 ` Theodore Ts'o
2013-08-05 13:52 ` [PATCH 3/4] ext4: Simplify truncation code in ext4_setattr() Jan Kara
2013-08-17 14:08 ` Theodore Ts'o
2013-08-05 13:52 ` [PATCH 4/4] ext4: Fix lost truncate due to race with writeback Jan Kara
2013-08-17 14:12 ` Theodore Ts'o
2013-08-26 19:01 ` Dave Jones [this message]
2013-08-28 22:55 ` Theodore Ts'o
2013-08-28 23:01 ` Dave Jones
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=20130826190137.GA27768@redhat.com \
--to=davej@redhat.com \
--cc=gnehzuil.liu@gmail.com \
--cc=jack@suse.cz \
--cc=linux-ext4@vger.kernel.org \
--cc=torvalds@linux-foundation.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).