From: Andrew Morton <akpm@linux-foundation.org>
To: Jan Kara <jack@suse.cz>
Cc: linux-ext4@vger.kernel.org, tytso@mit.edu, jack@suse.cz
Subject: Re: [PATCH 2/4] ext3: Fix possible deadlock between ext3_truncate() and ext3_get_blocks()
Date: Fri, 14 Aug 2009 16:41:05 -0700 [thread overview]
Message-ID: <20090814164105.9923f8f8.akpm@linux-foundation.org> (raw)
In-Reply-To: <1250252772-13302-3-git-send-email-jack@suse.cz>
On Fri, 14 Aug 2009 14:26:10 +0200
Jan Kara <jack@suse.cz> wrote:
> During truncate we are sometimes forced to start a new transaction as the
> amount of blocks to be journaled is both quite large and hard to predict. So
> far we restarted a transaction while holding truncate_mutex and that violates
> lock ordering because truncate_mutex ranks below transaction start (and it
> can lead to a real deadlock with ext3_get_blocks() allocating new blocks
> from ext3_writepage()).
>
> Luckily, the problem is easy to fix: We just drop the truncate_mutex before
> restarting the transaction and acquire it afterwards. We are safe to do this as
> by the time ext3_truncate() is called, all the page cache for the truncated
> part of the file is dropped and so writepage() cannot come and allocate new
> blocks in the part of the file we are truncating. The rest of writers is
> stopped by us holding i_mutex.
For ext2 we have the comment:
/*
* truncate_mutex is for serialising ext2_truncate() against
* ext2_getblock(). It also protects the internals of the inode's
* reservation data structures: ext2_reserve_window and
* ext2_reserve_window_node.
*/
does truncate_mutex also protect ext3's reservation data? If so, is
that impacted by this patch?
next prev parent reply other threads:[~2009-08-14 23:41 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-14 12:26 [PATCH 0/4] ext[34]: Fix deadlock between truncate and get_block() Jan Kara
2009-08-14 12:26 ` [PATCH 1/4] jbd: Annotate transaction start also for journal_restart() Jan Kara
2009-08-14 12:26 ` [PATCH 2/4] ext3: Fix possible deadlock between ext3_truncate() and ext3_get_blocks() Jan Kara
2009-08-14 23:41 ` Andrew Morton [this message]
2009-08-17 14:45 ` Jan Kara
2009-08-14 12:26 ` [PATCH 3/4] jbd2: Annotate transaction start also for jbd2_journal_restart() Jan Kara
2009-08-18 2:16 ` Theodore Tso
2009-08-14 12:26 ` [PATCH 4/4] ext4: Fix possible deadlock between ext4_truncate() and ext4_get_blocks() Jan Kara
2009-08-18 2:17 ` Theodore Tso
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=20090814164105.9923f8f8.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--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).