diff options
author | Eric Sandeen <sandeen@redhat.com> | 2012-02-20 23:06:18 -0500 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2012-05-21 12:40:04 -0400 |
commit | 797c09ed348c2e22715cbfaeb3ab658436753570 (patch) | |
tree | 4eb315399081d9cb3ab64775a82c15045daaf594 /fs | |
parent | 2743d7a6612be25a93c009a17f2a6d5db0f6fc36 (diff) |
ext4: avoid deadlock on sync-mounted FS w/o journal
commit c1bb05a657fb3d8c6179a4ef7980261fae4521d7 upstream.
Processes hang forever on a sync-mounted ext2 file system that
is mounted with the ext4 module (default in Fedora 16).
I can reproduce this reliably by mounting an ext2 partition with
"-o sync" and opening a new file an that partition with vim. vim
will hang in "D" state forever. The same happens on ext4 without
a journal.
I am attaching a small patch here that solves this issue for me.
In the sync mounted case without a journal,
ext4_handle_dirty_metadata() may call sync_dirty_buffer(), which
can't be called with buffer lock held.
Also move mb_cache_entry_release inside lock to avoid race
fixed previously by 8a2bfdcb ext[34]: EA block reference count racing fix
Note too that ext2 fixed this same problem in 2006 with
b2f49033 [PATCH] fix deadlock in ext2
Signed-off-by: Martin.Wilck@ts.fujitsu.com
[sandeen@redhat.com: move mb_cache_entry_release before unlock, edit commit msg]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/xattr.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c index 19fe4e3d39e..c2865cc3101 100644 --- a/fs/ext4/xattr.c +++ b/fs/ext4/xattr.c | |||
@@ -487,18 +487,19 @@ ext4_xattr_release_block(handle_t *handle, struct inode *inode, | |||
487 | ext4_free_blocks(handle, inode, bh, 0, 1, | 487 | ext4_free_blocks(handle, inode, bh, 0, 1, |
488 | EXT4_FREE_BLOCKS_METADATA | | 488 | EXT4_FREE_BLOCKS_METADATA | |
489 | EXT4_FREE_BLOCKS_FORGET); | 489 | EXT4_FREE_BLOCKS_FORGET); |
490 | unlock_buffer(bh); | ||
490 | } else { | 491 | } else { |
491 | le32_add_cpu(&BHDR(bh)->h_refcount, -1); | 492 | le32_add_cpu(&BHDR(bh)->h_refcount, -1); |
493 | if (ce) | ||
494 | mb_cache_entry_release(ce); | ||
495 | unlock_buffer(bh); | ||
492 | error = ext4_handle_dirty_metadata(handle, inode, bh); | 496 | error = ext4_handle_dirty_metadata(handle, inode, bh); |
493 | if (IS_SYNC(inode)) | 497 | if (IS_SYNC(inode)) |
494 | ext4_handle_sync(handle); | 498 | ext4_handle_sync(handle); |
495 | dquot_free_block(inode, 1); | 499 | dquot_free_block(inode, 1); |
496 | ea_bdebug(bh, "refcount now=%d; releasing", | 500 | ea_bdebug(bh, "refcount now=%d; releasing", |
497 | le32_to_cpu(BHDR(bh)->h_refcount)); | 501 | le32_to_cpu(BHDR(bh)->h_refcount)); |
498 | if (ce) | ||
499 | mb_cache_entry_release(ce); | ||
500 | } | 502 | } |
501 | unlock_buffer(bh); | ||
502 | out: | 503 | out: |
503 | ext4_std_error(inode->i_sb, error); | 504 | ext4_std_error(inode->i_sb, error); |
504 | return; | 505 | return; |