All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Zarochentsev <zam@namesys.com>
To: reiserfs-list@namesys.com
Cc: Laurent Riffard <laurent.riffard@free.fr>,
	"Vladimir V. Saveliev" <vs@namesys.com>
Subject: Re: reiser4-2.6.18-rc2-mm1: possible circular locking dependency detected in txn_end
Date: Thu, 3 Aug 2006 10:09:17 +0400	[thread overview]
Message-ID: <200608031009.18204.zam@namesys.com> (raw)
In-Reply-To: <44CE761E.8080809@free.fr>

On Tuesday 01 August 2006 01:29, Laurent Riffard wrote:
> Le 31.07.2006 21:55, Vladimir V. Saveliev a écrit :
> > Hello
> >
> > What kind of load did you run on reiser4 at that time?
>
> I just formatted a new 2GB Reiser4 FS, then I moved a whole ccache
> cache tree to this new FS (cache size was about 20~30 Mbytes).
> Something like:
>
> # mkfs.reiser4 /dev/vglinux1/ccache
> # mount -tauto -onoatime /dev/vglinux1/ccache /mnt/disk
> # mv ~laurent/.ccache/* /mnt/disk/

I was not able to reproduce it.  Can you please try the following patch?


lock validator friendly locking of new atom in 
atom_begin_and_assign_to_txnh and locking of two atoms.

Signed-off-by: Alexander Zarochentsev <zam@namesys.com>
---

 fs/reiser4/txnmgr.c |   14 ++++++++------
 fs/reiser4/txnmgr.h |   15 +++++++++++++++
 2 files changed, 23 insertions(+), 6 deletions(-)

Index: linux-2.6-git/fs/reiser4/txnmgr.c
===================================================================
--- linux-2.6-git.orig/fs/reiser4/txnmgr.c
+++ linux-2.6-git/fs/reiser4/txnmgr.c
@@ -730,10 +730,12 @@ static int atom_begin_and_assign_to_txnh
 	assert("jmacd-17", atom_isclean(atom));
 
         /*
-	 * do not use spin_lock_atom because we have broken lock ordering here
-	 * which is ok, as long as @atom is new and inaccessible for others.
+	 * lock ordering is broken here. It is ok, as long as @atom is new
+	 * and inaccessible for others. We can't use spin_lock_atom or
+	 * spin_lock(&atom->alock) because they care about locking
+	 * dependencies. spin_trylock_lock doesn't.
 	 */
-	spin_lock(&(atom->alock));
+	check_me("", spin_trylock_atom(atom));
 
 	/* add atom to the end of transaction manager's list of atoms */
 	list_add_tail(&atom->atom_link, &mgr->atoms_list);
@@ -749,7 +751,7 @@ static int atom_begin_and_assign_to_txnh
 	atom->super = reiser4_get_current_sb();
 	capture_assign_txnh_nolock(atom, txnh);
 
-	spin_unlock(&(atom->alock));
+	spin_unlock_atom(atom);
 	spin_unlock_txnh(txnh);
 
 	return -E_REPEAT;
@@ -2791,10 +2793,10 @@ static void lock_two_atoms(txn_atom * on
 	/* lock the atom with lesser address first */
 	if (one < two) {
 		spin_lock_atom(one);
-		spin_lock_atom(two);
+		spin_lock_atom_nested(two);
 	} else {
 		spin_lock_atom(two);
-		spin_lock_atom(one);
+		spin_lock_atom_nested(one);
 	}
 }
 
Index: linux-2.6-git/fs/reiser4/txnmgr.h
===================================================================
--- linux-2.6-git.orig/fs/reiser4/txnmgr.h
+++ linux-2.6-git/fs/reiser4/txnmgr.h
@@ -502,6 +502,7 @@ static inline void spin_lock_atom(txn_at
 {
 	/* check that spinlocks of lower priorities are not held */
 	assert("", (LOCK_CNT_NIL(spin_locked_txnh) &&
+		    LOCK_CNT_NIL(spin_locked_atom) &&
 		    LOCK_CNT_NIL(spin_locked_jnode) &&
 		    LOCK_CNT_NIL(spin_locked_zlock) &&
 		    LOCK_CNT_NIL(rw_locked_dk) &&
@@ -513,6 +514,20 @@ static inline void spin_lock_atom(txn_at
 	LOCK_CNT_INC(spin_locked);
 }
 
+static inline void spin_lock_atom_nested(txn_atom *atom)
+{
+	assert("", (LOCK_CNT_NIL(spin_locked_txnh) &&
+		    LOCK_CNT_NIL(spin_locked_jnode) &&
+		    LOCK_CNT_NIL(spin_locked_zlock) &&
+		    LOCK_CNT_NIL(rw_locked_dk) &&
+		    LOCK_CNT_NIL(rw_locked_tree)));
+
+	spin_lock_nested(&(atom->alock), SINGLE_DEPTH_NESTING);
+
+	LOCK_CNT_INC(spin_locked_atom);
+	LOCK_CNT_INC(spin_locked);
+}
+
 static inline int spin_trylock_atom(txn_atom *atom)
 {
 	if (spin_trylock(&(atom->alock))) {




  reply	other threads:[~2006-08-03  6:09 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-30 18:57 reiser4-2.6.18-rc2-mm1: possible circular locking dependency detected in txn_end Laurent Riffard
2006-07-31 19:55 ` Vladimir V. Saveliev
2006-07-31 21:29   ` Laurent Riffard
2006-08-03  6:09     ` Alexander Zarochentsev [this message]
2006-08-03 15:07       ` Laurent Riffard
2006-08-12 13:26         ` Laurent Riffard
2006-08-14 11:50           ` Vladimir V. Saveliev
2006-08-14 13:02             ` Laurent Riffard
2006-08-22 13:08           ` Alexander Zarochentsev
2006-08-23 23:46             ` Laurent Riffard
2006-08-01 19:18 ` Alexander Zarochentsev

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=200608031009.18204.zam@namesys.com \
    --to=zam@namesys.com \
    --cc=laurent.riffard@free.fr \
    --cc=reiserfs-list@namesys.com \
    --cc=vs@namesys.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 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.