From owner-p4-projects@FreeBSD.ORG Thu Jan 17 01:45:23 2008 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 4D0D116A419; Thu, 17 Jan 2008 01:45:23 +0000 (UTC) Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12D7716A417 for ; Thu, 17 Jan 2008 01:45:23 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [IPv6:2001:4f8:fff6::29]) by mx1.freebsd.org (Postfix) with ESMTP id 0548F13C447 for ; Thu, 17 Jan 2008 01:45:23 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.14.1/8.14.1) with ESMTP id m0H1jM59085745 for ; Thu, 17 Jan 2008 01:45:22 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.14.1/8.14.1/Submit) id m0H1jM3w085742 for perforce@freebsd.org; Thu, 17 Jan 2008 01:45:22 GMT (envelope-from scottl@freebsd.org) Date: Thu, 17 Jan 2008 01:45:22 GMT Message-Id: <200801170145.m0H1jM3w085742@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to scottl@freebsd.org using -f From: Scott Long To: Perforce Change Reviews Cc: Subject: PERFORCE change 133449 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Jan 2008 01:45:23 -0000 http://perforce.freebsd.org/chv.cgi?CH=133449 Change 133449 by scottl@scottl-ix on 2008/01/17 01:44:35 Fix locking in the blkfront driver. There's still probably a locking hole in the resume code, but that'll be looked at later. Also to be looked at later is the single global lock. Affected files ... .. //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#11 edit Differences ... ==== //depot/projects/xen31/sys/dev/xen/blkfront/blkfront.c#11 (text+ko) ==== @@ -170,7 +170,7 @@ xb_diskinfo[sc->xb_unit].device, sc->xb_unit, sc->xb_disk->d_mediasize); #endif - sc->xb_disk->d_flags = DISKFLAG_NEEDSGIANT; + sc->xb_disk->d_flags = 0; disk_create(sc->xb_disk, DISK_VERSION_00); bioq_init(&sc->xb_bioq); @@ -195,7 +195,6 @@ xb_strategy(struct bio *bp) { struct xb_softc *sc = (struct xb_softc *)bp->bio_disk->d_drv1; - int flags; /* bogus disk? */ if (sc == NULL) { @@ -206,14 +205,14 @@ DPRINTK(""); - flags = splbio(); /* * Place it in the queue of disk activities for this disk */ + mtx_lock(&blkif_io_lock); bioq_disksort(&sc->xb_bioq, bp); - splx(flags); xb_startio(sc); + mtx_unlock(&blkif_io_lock); return; bad: @@ -378,8 +377,8 @@ info->ring_ref = err; err = bind_listening_port_to_irqhandler(dev->otherend_id, - "xbd", (driver_intr_t *)blkif_int, - info, INTR_TYPE_BIO, NULL); + "xbd", (driver_intr_t *)blkif_int, info, + INTR_TYPE_BIO | INTR_MPSAFE, NULL); if (err <= 0) { xenbus_dev_fatal(dev, err, "bind_evtchn_to_irqhandler failed"); @@ -767,24 +766,20 @@ xb_startio(struct xb_softc *sc) { struct bio *bp; - int flags, queued = 0; + int queued = 0; struct blkfront_info *info = sc->xb_info; DPRINTK(""); - flags = splbio(); + mtx_assert(&blkif_io_lock, MA_OWNED); while ((bp = bioq_takefirst(&sc->xb_bioq)) != NULL) { if (RING_FULL(&info->ring)) goto wait; - splx(flags); - if (blkif_queue_request(bp)) { - flags = splbio(); wait: bioq_insert_head(&sc->xb_bioq, bp); - splx(flags); break; } queued++; @@ -968,10 +963,10 @@ mtx_unlock(&blkif_io_lock); /* Send off requeued requests */ + mtx_lock(&blkif_io_lock); flush_requests(info); /* Kick any other new requests queued since we resumed */ - mtx_lock(&blkif_io_lock); kick_pending_request_queues(info); mtx_unlock(&blkif_io_lock); }