ext4: fix ext4_flush_completed_IO wait semantics

Message ID 20121005132853.GC21358@thunk.org
State Superseded, archived
Headers show

Commit Message

Theodore Y. Ts'o Oct. 5, 2012, 1:28 p.m.
On Fri, Oct 05, 2012 at 05:01:30PM +0400, Dmitry Monakhov wrote:
> > This WARN_ON is triggering on the truncate path...
> Yeap, this is false positive one. We skip i_mutex on ext4_evict_inode
> This is strange xfsstress 269'th should caught that for me.
> I'll try to prepare workaround ASAP.

This is the patch which I'm currently testing.  If it passes I'll fold
it into your patch.  Anyone see any problems with it?

   	     	     	       	    	     - Ted

To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index f18e786..cd171dd 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -238,8 +238,10 @@  void ext4_evict_inode(struct inode *inode)
 	 * protection against it
+	mutex_lock(&inode->i_mutex);
 	handle = ext4_journal_start(inode, ext4_blocks_for_truncate(inode)+3);
 	if (IS_ERR(handle)) {
+		mutex_unlock(&inode->i_mutex);
 		ext4_std_error(inode->i_sb, PTR_ERR(handle));
 		 * If we're going to skip the normal cleanup, we still need to
@@ -256,12 +258,14 @@  void ext4_evict_inode(struct inode *inode)
 	inode->i_size = 0;
 	err = ext4_mark_inode_dirty(handle, inode);
 	if (err) {
+		mutex_unlock(&inode->i_mutex);
 			     "couldn't mark inode dirty (err %d)", err);
 		goto stop_handle;
 	if (inode->i_blocks)
+	mutex_unlock(&inode->i_mutex);
 	 * ext4_ext_truncate() doesn't reserve any slop when it