All of lore.kernel.org
 help / color / mirror / Atom feed
From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/group/dlm_controld deadlock.c
Date: 7 Aug 2007 19:20:55 -0000	[thread overview]
Message-ID: <20070807192055.27267.qmail@sourceware.org> (raw)

CVSROOT:	/cvs/cluster
Module name:	cluster
Changes by:	teigland at sourceware.org	2007-08-07 19:20:55

Modified files:
	group/dlm_controld: deadlock.c 

Log message:
	don't add the same transaction to a waitfor list more than once

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/dlm_controld/deadlock.c.diff?cvsroot=cluster&r1=1.2&r2=1.3

--- cluster/group/dlm_controld/deadlock.c	2007/08/06 21:50:26	1.2
+++ cluster/group/dlm_controld/deadlock.c	2007/08/07 19:20:54	1.3
@@ -732,7 +732,8 @@
 		return;
 	}
 
-	log_group(ls, "write_checkpoint: open ckpt handle %llx", (long long)h);
+	log_group(ls, "write_checkpoint: open ckpt handle %llx",
+		  (unsigned long long)h);
 	ls->lock_ckpt_handle = (uint64_t) h;
 
 	list_for_each_entry(r, &ls->resources, list) {
@@ -791,7 +792,7 @@
 	}
 	if (error != CPG_OK) {
 		log_error("cpg_mcast_joined error %d handle %llx",
-			  (int)error, (long long)h);
+			  (int)error, (unsigned long long)h);
 		disable_deadlock();
 		return -1;
 	}
@@ -1232,7 +1233,7 @@
 
 	if (waiting_lkb->trans->xid == granted_lkb->trans->xid) {
 		log_debug("waiting and granted same trans %llx",
-			  (long long)waiting_lkb->trans->xid);
+			  (unsigned long long)waiting_lkb->trans->xid);
 		return 0;
 	}
 
@@ -1240,19 +1241,35 @@
 				waiting_lkb->lock.rqmode);
 }
 
-/* TODO: don't add new waitfor trans if we're already waiting for the same
-   trans for another lock */
+static int in_waitfor(struct trans *tr, struct trans *add_tr)
+{
+	int i;
+
+	for (i = 0; i < tr->waitfor_alloc; i++) {
+		if (!tr->waitfor[i])
+			continue;
+		if (tr->waitfor[i] == add_tr)
+			return 1;
+	}
+	return 0;
+}
 
-static void add_waitfor(struct dlm_lkb *waiting_lkb,
+static void add_waitfor(struct lockspace *ls, struct dlm_lkb *waiting_lkb,
 			struct dlm_lkb *granted_lkb)
 {
-	struct trans *tr;
+	struct trans *tr = waiting_lkb->trans;
 	int old_alloc, i;
 
 	if (locks_compat(waiting_lkb, granted_lkb))
 		return;
 
-	tr = waiting_lkb->trans;
+	/* don't add the same trans to the waitfor list multiple times */
+	if (tr->waitfor_count && in_waitfor(tr, granted_lkb->trans)) {
+		log_group(ls, "trans %llx already waiting for trans %llx",
+			  (unsigned long long)tr->xid,
+			  (unsigned long long)granted_lkb->trans->xid);
+		return;
+	}
 
 	if (tr->waitfor_count == tr->waitfor_alloc) {
 		old_alloc = tr->waitfor_alloc;
@@ -1289,7 +1306,7 @@
 				if (granted_lkb->lock.status==DLM_LKSTS_WAITING)
 					continue;
 				/* granted_lkb status is GRANTED or CONVERT */
-				add_waitfor(waiting_lkb, granted_lkb);
+				add_waitfor(ls, waiting_lkb, granted_lkb);
 			}
 		}
 	}



             reply	other threads:[~2007-08-07 19:20 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-08-07 19:20 teigland [this message]
  -- strict thread matches above, loose matches on Subject: below --
2007-08-13 15:32 [Cluster-devel] cluster/group/dlm_controld deadlock.c teigland
2007-08-23 19:08 teigland

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=20070807192055.27267.qmail@sourceware.org \
    --to=teigland@sourceware.org \
    /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.