From owner-svn-src-all@FreeBSD.ORG Fri Jan 14 11:12:56 2011 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 C296A106566C; Fri, 14 Jan 2011 11:12:56 +0000 (UTC) (envelope-from jh@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B17B88FC1A; Fri, 14 Jan 2011 11:12:56 +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 p0EBCuVW085863; Fri, 14 Jan 2011 11:12:56 GMT (envelope-from jh@svn.freebsd.org) Received: (from jh@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0EBCuGl085861; Fri, 14 Jan 2011 11:12:56 GMT (envelope-from jh@svn.freebsd.org) Message-Id: <201101141112.p0EBCuGl085861@svn.freebsd.org> From: Jaakko Heinonen Date: Fri, 14 Jan 2011 11:12:56 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217392 - stable/8/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: Fri, 14 Jan 2011 11:12:56 -0000 Author: jh Date: Fri Jan 14 11:12:56 2011 New Revision: 217392 URL: http://svn.freebsd.org/changeset/base/217392 Log: MFC r214748: Extend the g_eventlock mutex coverage in one_event() to include setting of the EV_DONE flag and use the mutex to protect against losing wakeups in g_waitfor_event(). 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 Fri Jan 14 10:56:44 2011 (r217391) +++ stable/8/sys/geom/geom_event.c Fri Jan 14 11:12:56 2011 (r217392) @@ -212,11 +212,12 @@ one_event(void) g_topology_assert(); mtx_lock(&g_eventlock); TAILQ_REMOVE(&g_events, ep, events); - mtx_unlock(&g_eventlock); if (ep->flag & EV_WAKEUP) { ep->flag |= EV_DONE; + mtx_unlock(&g_eventlock); wakeup(ep); } else { + mtx_unlock(&g_eventlock); g_free(ep); } g_topology_unlock(); @@ -355,11 +356,14 @@ g_waitfor_event(g_event_t *func, void *a va_end(ap); if (error) return (error); - do - tsleep(ep, PRIBIO, "g_waitfor_event", hz); - while (!(ep->flag & EV_DONE)); + + mtx_lock(&g_eventlock); + while (!(ep->flag & EV_DONE)) + msleep(ep, &g_eventlock, PRIBIO, "g_waitfor_event", hz); if (ep->flag & EV_CANCELED) error = EAGAIN; + mtx_unlock(&g_eventlock); + g_free(ep); return (error); }