From owner-svn-src-projects@FreeBSD.ORG Wed Jan 12 08:09:29 2011 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C2BD4106564A; Wed, 12 Jan 2011 08:09:29 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id B1F3B8FC0C; Wed, 12 Jan 2011 08:09:29 +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 p0C89TWP062981; Wed, 12 Jan 2011 08:09:29 GMT (envelope-from imp@svn.freebsd.org) Received: (from imp@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0C89T4R062979; Wed, 12 Jan 2011 08:09:29 GMT (envelope-from imp@svn.freebsd.org) Message-Id: <201101120809.p0C89T4R062979@svn.freebsd.org> From: Warner Losh Date: Wed, 12 Jan 2011 08:09:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217301 - projects/graid/head/sys/geom/raid X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2011 08:09:29 -0000 Author: imp Date: Wed Jan 12 08:09:29 2011 New Revision: 217301 URL: http://svn.freebsd.org/changeset/base/217301 Log: Document ugly race mav@ pointed out, fix bug I noticed at the same time in moving blocked bios back to sc_queue. Modified: projects/graid/head/sys/geom/raid/g_raid.c Modified: projects/graid/head/sys/geom/raid/g_raid.c ============================================================================== --- projects/graid/head/sys/geom/raid/g_raid.c Wed Jan 12 07:38:48 2011 (r217300) +++ projects/graid/head/sys/geom/raid/g_raid.c Wed Jan 12 08:09:29 2011 (r217301) @@ -827,6 +827,16 @@ g_raid_iodone(struct bio *bp, int error) /* * XXX this structure forces serialization of all * XXX pending requests before any are allowed through. + * + * XXX Also, if there is a pending request that overlaps one + * XXX locked area and another locked area comes along that also + * XXX overlaps that area, we wind up double counting it, but + * XXX not double uncounting it, so we hit deadlock. Ouch. + * Most likely, we should add pending counts to struct + * g_raid_lock and recompute v_pending_lock in lock_range() + * and here, which would eliminate the doubel counting. Heck, + * if we wanted to burn the cylces here, we could look at the + * inflight queue and the v_locks and just recompute here. */ G_RAID_LOGREQ(3, bp, "Write to locking zone complete: %d writes outstanding", @@ -896,9 +906,12 @@ g_raid_unlock_range(struct g_raid_volume * and hope for the best. We hope this because any * locked ranges will go right back on this list * when the worker thread runs. + * XXX + * Also, see note above about deadlock and how it + * doth sucketh... */ mtx_lock(&sc->sc_queue_mtx); - while ((bp = bioq_takefirst(&sc->sc_queue)) != NULL) + while ((bp = bioq_takefirst(&vol->v_locked)) != NULL) bioq_disksort(&sc->sc_queue, bp); mtx_unlock(&sc->sc_queue_mtx); free(lp, M_RAID);