From owner-svn-src-all@FreeBSD.ORG Tue Jun 8 22:40:03 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 798EC1065675; Tue, 8 Jun 2010 22:40:03 +0000 (UTC) (envelope-from mjacob@FreeBSD.org) Received: from svn.freebsd.org (unknown [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 2C71A8FC15; Tue, 8 Jun 2010 22:40:03 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o58Me3VO034933; Tue, 8 Jun 2010 22:40:03 GMT (envelope-from mjacob@svn.freebsd.org) Received: (from mjacob@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o58Me3Xv034931; Tue, 8 Jun 2010 22:40:03 GMT (envelope-from mjacob@svn.freebsd.org) Message-Id: <201006082240.o58Me3Xv034931@svn.freebsd.org> From: Matt Jacob Date: Tue, 8 Jun 2010 22:40:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r208927 - head/sys/geom X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 08 Jun 2010 22:40:03 -0000 Author: mjacob Date: Tue Jun 8 22:40:02 2010 New Revision: 208927 URL: http://svn.freebsd.org/changeset/base/208927 Log: Try and narrow the gap in which you act on an event that has been canceled. Obtained from: Jaako Heinonen MFC after: 1 month Modified: head/sys/geom/geom_event.c Modified: head/sys/geom/geom_event.c ============================================================================== --- head/sys/geom/geom_event.c Tue Jun 8 22:26:47 2010 (r208926) +++ head/sys/geom/geom_event.c Tue Jun 8 22:40:02 2010 (r208927) @@ -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; mtx_unlock(&g_eventlock); if (ep->flag & EV_WAKEUP) { ep->flag |= EV_DONE; @@ -255,6 +263,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;