aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorJosef Whiter <jwhiter@redhat.com>2007-02-23 12:49:51 -0500
committerSteven Whitehouse <swhiteho@redhat.com>2007-03-07 13:58:02 -0500
commita13cbe375303585fec1425135ed54adb62be41fc (patch)
tree47e048bf645f370622776e75a8dd388cea4e89b8 /fs
parenta7d2b2bdc9a0b55d5b08e15756c7e65c48c4bca5 (diff)
[GFS2] 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. Signed-off-by: Josef Whiter <jwhiter@redhat.com> Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
Diffstat (limited to 'fs')
-rw-r--r--fs/gfs2/ops_address.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 56e33590b656..b3b7e8475359 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -266,9 +266,11 @@ skip_lock:
266out: 266out:
267 return error; 267 return error;
268out_unlock: 268out_unlock:
269 if (error == GLR_TRYFAILED)
270 error = AOP_TRUNCATED_PAGE;
271 unlock_page(page); 269 unlock_page(page);
270 if (error == GLR_TRYFAILED) {
271 error = AOP_TRUNCATED_PAGE;
272 yield();
273 }
272 if (do_unlock) 274 if (do_unlock)
273 gfs2_holder_uninit(&gh); 275 gfs2_holder_uninit(&gh);
274 goto out; 276 goto out;
@@ -364,6 +366,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
364 if (error == GLR_TRYFAILED) { 366 if (error == GLR_TRYFAILED) {
365 unlock_page(page); 367 unlock_page(page);
366 error = AOP_TRUNCATED_PAGE; 368 error = AOP_TRUNCATED_PAGE;
369 yield();
367 } 370 }
368 goto out_uninit; 371 goto out_uninit;
369 } 372 }