cluster-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Steven Whitehouse <swhiteho@redhat.com>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] [GFS2] fix hangup when multiple processes are trying to write to the same file [4/12]
Date: Wed, 07 Mar 2007 14:28:49 +0000	[thread overview]
Message-ID: <1173277729.11001.760.camel@quoit.chygwyn.com> (raw)
In-Reply-To: <1173277501.11001.752.camel@quoit.chygwyn.com>

From a13cbe375303585fec1425135ed54adb62be41fc Mon Sep 17 00:00:00 2001
From: Josef Whiter <jwhiter@redhat.com>
Date: Fri, 23 Feb 2007 12:49:51 -0500
Subject: [PATCH] [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>

diff --git a/fs/gfs2/ops_address.c b/fs/gfs2/ops_address.c
index 56e3359..b3b7e84 100644
--- a/fs/gfs2/ops_address.c
+++ b/fs/gfs2/ops_address.c
@@ -266,9 +266,11 @@ skip_lock:
 out:
 	return error;
 out_unlock:
-	if (error == GLR_TRYFAILED)
-		error = AOP_TRUNCATED_PAGE;
 	unlock_page(page);
+	if (error == GLR_TRYFAILED) {
+		error = AOP_TRUNCATED_PAGE;
+		yield();
+	}
 	if (do_unlock)
 		gfs2_holder_uninit(&gh);
 	goto out;
@@ -364,6 +366,7 @@ static int gfs2_prepare_write(struct file *file, struct page *page,
 		if (error == GLR_TRYFAILED) {
 			unlock_page(page);
 			error = AOP_TRUNCATED_PAGE;
+			yield();
 		}
 		goto out_uninit;
 	}
-- 
1.4.4.2





  parent reply	other threads:[~2007-03-07 14:28 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-07 14:25 [Cluster-devel] [GFS2/DLM] Bug fixes [0/12] Steven Whitehouse
2007-03-07 14:26 ` [Cluster-devel] [GFS2] fix locking mistake [1/12] Steven Whitehouse
2007-03-07 14:27 ` [Cluster-devel] [GFS2] add newline to printk message [2/12] Steven Whitehouse
2007-03-07 14:27 ` [Cluster-devel] [GFS2] NFS filehandle check [3/12] Steven Whitehouse
2007-03-07 14:28 ` Steven Whitehouse [this message]
2007-03-07 14:29 ` [Cluster-devel] [DLM] fs/dlm/user.c should #include "user.h" [5/12] Steven Whitehouse
2007-03-07 14:30 ` [Cluster-devel] [GFS2] pass formal ino in do_filldir_main [6/12] Steven Whitehouse
2007-03-07 14:31 ` [Cluster-devel] [GFS2] Fix bz 230143, incorrect flushing of rgrps [7/12] Steven Whitehouse
2007-03-07 14:31 ` [Cluster-devel] [GFS2] Fix bz 229831, lookup returns wrong inode [8/12] Steven Whitehouse
2007-03-07 14:32 ` [Cluster-devel] [GFS2] Remove unused variable [9/12] Steven Whitehouse
2007-03-07 14:32 ` [Cluster-devel] [GFS2] go_drop_bh is never used, so remove it [10/12] Steven Whitehouse
2007-03-07 14:33 ` [Cluster-devel] [GFS2] build fix [11/12] Steven Whitehouse
2007-03-07 14:34 ` [Cluster-devel] [GFS2] Fix bz 229873, alternate test: assertion "!ip->i_inode.i_mapping->nrpages" failed [12/12] Steven Whitehouse
2007-03-07 14:43 ` [Cluster-devel] [GFS2/DLM] Pull request Steven Whitehouse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1173277729.11001.760.camel@quoit.chygwyn.com \
    --to=swhiteho@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).