Date: Thu, 17 Jan 2008 01:45:22 GMT From: Scott Long <scottl@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 133449 for review Message-ID: <200801170145.m0H1jM3w085742@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200801170145.m0H1jM3w085742>