[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] [GFS2 patch] fix hangup when multiple processes are trying to write to the same file



This fixes a problem I encountered while running bonnie++.  When you have one
thread that opens a file and starts to write to it, and then another thread that
tries to open and write to the same file, the second thread will loop forever
trying to grab the inode lock for that inode.  Basically we come in through
generic_buffered_file_write, which calls gfs2_prepare_write, which then attempts
to grab the glock.  Because we don't own the lock, gfs2_prepare_write gets
GLR_TRYFAILED, which returns AOP_TRUNCATED_PAGE to generic_buffered_file_write.
At this point generic_buffered_file_write loops around again and immediately
retries the prepare_write.  This means that the second process never gets off of
the processor in order to allow the process that holds the lock to finish its
work and let go of the lock.  This patch makes gfs2_glock_nq schedule() if it
gets back a GLR_TRYFAILED, which resolves this problem.  Please let me know if
this is in the wrong place, ie if it should go in gfs2_prepare_write instead of
gfs2_glock_nq, or if its completely wrong :).

Signed-off-by: Josef Whiter <jwhiter redhat com>

--- linux-2.6/fs/gfs2/glock.c.josef	2007-02-20 17:54:36.000000000 -0500
+++ linux-2.6/fs/gfs2/glock.c	2007-02-22 17:27:09.000000000 -0500
@@ -1185,7 +1185,8 @@
 		if (error == GLR_CANCELED) {
 			msleep(100);
 			goto restart;
-		}
+		} else if (error == GLR_TRYFAILED) 
+			schedule();
 	}
 
 	return error;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]