All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2] ext4: avoid deadlock on sync-mounted FS w/o journal
@ 2012-02-16 23:41 Eric Sandeen
  2012-02-21  4:08 ` Ted Ts'o
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Sandeen @ 2012-02-16 23:41 UTC (permalink / raw)
  To: ext4 development; +Cc: Martin.Wilck

From: Martin.Wilck@ts.fujitsu.com

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
Nonte 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>
---

diff --git a/fs/ext4/xattr.c b/fs/ext4/xattr.c
index 93a00d8..4410ae7 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,
 		ext4_free_blocks(handle, inode, bh, 0, 1,
 				 EXT4_FREE_BLOCKS_METADATA |
 				 EXT4_FREE_BLOCKS_FORGET);
+		unlock_buffer(bh);
 	} else {
 		le32_add_cpu(&BHDR(bh)->h_refcount, -1);
+		if (ce)
+			mb_cache_entry_release(ce);
+		unlock_buffer(bh);
 		error = ext4_handle_dirty_metadata(handle, inode, bh);
 		if (IS_SYNC(inode))
 			ext4_handle_sync(handle);
 		dquot_free_block(inode, 1);
 		ea_bdebug(bh, "refcount now=%d; releasing",
 			  le32_to_cpu(BHDR(bh)->h_refcount));
-		if (ce)
-			mb_cache_entry_release(ce);
 	}
-	unlock_buffer(bh);
 out:
 	ext4_std_error(inode->i_sb, error);
 	return;


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH V2] ext4: avoid deadlock on sync-mounted FS w/o journal
  2012-02-16 23:41 [PATCH V2] ext4: avoid deadlock on sync-mounted FS w/o journal Eric Sandeen
@ 2012-02-21  4:08 ` Ted Ts'o
  0 siblings, 0 replies; 2+ messages in thread
From: Ted Ts'o @ 2012-02-21  4:08 UTC (permalink / raw)
  To: Eric Sandeen; +Cc: ext4 development, Martin.Wilck

On Thu, Feb 16, 2012 at 03:41:45PM -0800, Eric Sandeen wrote:
> From: Martin.Wilck@ts.fujitsu.com
> 
> 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
> Nonte 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>

Thanks, applied.

						- Ted

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2012-02-21  4:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-16 23:41 [PATCH V2] ext4: avoid deadlock on sync-mounted FS w/o journal Eric Sandeen
2012-02-21  4:08 ` Ted Ts'o

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.