Date: Wed, 28 Mar 2007 18:03:57 GMT From: Scott Long <scottl@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 116756 for review Message-ID: <200703281803.l2SI3vL8016048@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=116756 Change 116756 by scottl@scottl-x64 on 2007/03/28 18:03:28 Start scsi_sa locking. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#11 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#11 (text+ko) ==== @@ -451,17 +451,12 @@ unit = SAUNIT(dev); periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) { - return (ENXIO); - } - softc = (struct sa_softc *)periph->softc; - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { - cam_periph_unlock(periph); return (ENXIO); } cam_periph_lock(periph); + softc = (struct sa_softc *)periph->softc; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, ("saopen(%d): dev=0x%x softc=0x%x\n", unit, unit, softc->flags)); @@ -672,7 +667,6 @@ { struct cam_periph *periph; struct sa_softc *softc; - int s; bp->bio_resid = bp->bio_bcount; if (SA_IS_CTRL(bp->bio_dev)) { @@ -686,16 +680,16 @@ } softc = (struct sa_softc *)periph->softc; - s = splsoftcam(); + cam_periph_lock(periph); if (softc->flags & SA_FLAG_INVALID) { - splx(s); + cam_periph_unlock(periph); biofinish(bp, NULL, ENXIO); return; } if (softc->flags & SA_FLAG_TAPE_FROZEN) { - splx(s); + cam_periph_unlock(periph); biofinish(bp, NULL, EPERM); return; } @@ -706,16 +700,15 @@ * file descriptor. */ if (bp->bio_cmd == BIO_WRITE && softc->open_rdonly) { - splx(s); + cam_periph_unlock(periph); biofinish(bp, NULL, EBADF); return; } - splx(s); - if (softc->open_pending_mount) { int error = samount(periph, 0, bp->bio_dev); if (error) { + cam_periph_unlock(periph); biofinish(bp, NULL, ENXIO); return; } @@ -728,6 +721,7 @@ * If it's a null transfer, return immediately */ if (bp->bio_bcount == 0) { + cam_periph_unlock(periph); biodone(bp); return; } @@ -745,6 +739,7 @@ xpt_print(periph->path, "Invalid request. Fixed block " "device requests must be a multiple of %d bytes\n", softc->min_blk); + cam_periph_unlock(periph); biofinish(bp, NULL, EINVAL); return; } @@ -760,18 +755,12 @@ } printf("between %d and %d bytes\n", softc->min_blk, softc->max_blk); + cam_periph_unlock(periph); biofinish(bp, NULL, EINVAL); return; } /* - * Mask interrupts so that the device cannot be invalidated until - * after we are in the queue. Otherwise, we might not properly - * clean up one of the buffers. - */ - s = splbio(); - - /* * Place it at the end of the queue. */ bioq_insert_tail(&softc->bio_queue, bp); @@ -786,12 +775,12 @@ CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastrategy: queue count now %d\n", softc->queue_count)); } - splx(s); /* * Schedule ourselves for performing the work. */ xpt_schedule(periph, 1); + cam_periph_unlock(periph); return; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200703281803.l2SI3vL8016048>