* [PATCH] ext4: Fix deadlock in ext4_write_begin() and ext4_da_write_begin()
@ 2009-02-19 14:24 Jan Kara
2009-02-23 2:16 ` Theodore Tso
0 siblings, 1 reply; 2+ messages in thread
From: Jan Kara @ 2009-02-19 14:24 UTC (permalink / raw)
To: linux-ext4; +Cc: tytso, Jan Kara
Functions ext4_write_begin() and ext4_da_write_begin() call
grab_cache_page_write_begin() without AOP_FLAG_NOFS. Thus it
can happen that page reclaim is triggered in that function
and it recurses back into the filesystem (or some other filesystem).
But this can lead to various problems as a transaction is already
started at that point. Add the necessary flag.
(Reported in http://bugzilla.kernel.org/show_bug.cgi?id=11688)
Signed-off-by: Jan Kara <jack@suse.cz>
---
fs/ext4/inode.c | 9 ++++++++-
1 files changed, 8 insertions(+), 1 deletions(-)
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 03ba20b..e62e6e4 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -1366,6 +1366,10 @@ retry:
goto out;
}
+ /* We cannot recurse into the filesystem as the transaction is already
+ * started */
+ flags |= AOP_FLAG_NOFS;
+
page = grab_cache_page_write_begin(mapping, index, flags);
if (!page) {
ext4_journal_stop(handle);
@@ -1375,7 +1379,7 @@ retry:
*pagep = page;
ret = block_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
- ext4_get_block);
+ ext4_get_block);
if (!ret && ext4_should_journal_data(inode)) {
ret = walk_page_buffers(handle, page_buffers(page),
@@ -2648,6 +2652,9 @@ retry:
ret = PTR_ERR(handle);
goto out;
}
+ /* We cannot recurse into the filesystem as the transaction is already
+ * started */
+ flags |= AOP_FLAG_NOFS;
page = grab_cache_page_write_begin(mapping, index, flags);
if (!page) {
--
1.6.0.2
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] ext4: Fix deadlock in ext4_write_begin() and ext4_da_write_begin()
2009-02-19 14:24 [PATCH] ext4: Fix deadlock in ext4_write_begin() and ext4_da_write_begin() Jan Kara
@ 2009-02-23 2:16 ` Theodore Tso
0 siblings, 0 replies; 2+ messages in thread
From: Theodore Tso @ 2009-02-23 2:16 UTC (permalink / raw)
To: Jan Kara; +Cc: linux-ext4
On Thu, Feb 19, 2009 at 03:24:48PM +0100, Jan Kara wrote:
> Functions ext4_write_begin() and ext4_da_write_begin() call
> grab_cache_page_write_begin() without AOP_FLAG_NOFS. Thus it
> can happen that page reclaim is triggered in that function
> and it recurses back into the filesystem (or some other filesystem).
> But this can lead to various problems as a transaction is already
> started at that point. Add the necessary flag.
>
> (Reported in http://bugzilla.kernel.org/show_bug.cgi?id=11688)
>
> Signed-off-by: Jan Kara <jack@suse.cz>
Thanks, queued.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
- Ted
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-02-23 2:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-02-19 14:24 [PATCH] ext4: Fix deadlock in ext4_write_begin() and ext4_da_write_begin() Jan Kara
2009-02-23 2:16 ` Theodore Tso
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).