Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 6 Mar 2011 18:43:59 +0000 (UTC)
From:      Jaakko Heinonen <jh@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r219345 - stable/8/sys/geom
Message-ID:  <201103061843.p26Ihx8S006515@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jh
Date: Sun Mar  6 18:43:59 2011
New Revision: 219345
URL: http://svn.freebsd.org/changeset/base/219345

Log:
  MFC r208927 by mjacob:
  
  Try and narrow the gap in which you act on an event that has been canceled.

Modified:
  stable/8/sys/geom/geom_event.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)

Modified: stable/8/sys/geom/geom_event.c
==============================================================================
--- stable/8/sys/geom/geom_event.c	Sun Mar  6 17:46:06 2011	(r219344)
+++ stable/8/sys/geom/geom_event.c	Sun Mar  6 18:43:59 2011	(r219345)
@@ -76,6 +76,7 @@ struct g_event {
 #define EV_DONE		0x80000
 #define EV_WAKEUP	0x40000
 #define EV_CANCELED	0x20000
+#define EV_INPROGRESS	0x10000
 
 void
 g_waitidle(void)
@@ -206,12 +207,19 @@ one_event(void)
 		g_topology_unlock();
 		return (0);
 	}
+	if (ep->flag & EV_INPROGRESS) {
+		mtx_unlock(&g_eventlock);
+		g_topology_unlock();
+		return (1);
+	}
+	ep->flag |= EV_INPROGRESS;
 	mtx_unlock(&g_eventlock);
 	g_topology_assert();
 	ep->func(ep->arg, 0);
 	g_topology_assert();
 	mtx_lock(&g_eventlock);
 	TAILQ_REMOVE(&g_events, ep, events);
+	ep->flag &= ~EV_INPROGRESS;
 	if (ep->flag & EV_WAKEUP) {
 		ep->flag |= EV_DONE;
 		mtx_unlock(&g_eventlock);
@@ -256,6 +264,8 @@ g_cancel_event(void *ref)
 		break;
 	}
 	TAILQ_FOREACH_SAFE(ep, &g_events, events, epn) {
+		if (ep->flag & EV_INPROGRESS)
+			continue;
 		for (n = 0; n < G_N_EVENTREFS; n++) {
 			if (ep->ref[n] == NULL)
 				break;



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201103061843.p26Ihx8S006515>