From owner-p4-projects@FreeBSD.ORG Sun Apr 15 08:00:29 2007 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id CA20316A40E; Sun, 15 Apr 2007 08:00:28 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 8DC7C16A403 for ; Sun, 15 Apr 2007 08:00:28 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [69.147.83.41]) by mx1.freebsd.org (Postfix) with ESMTP id 7E67013C48A for ; Sun, 15 Apr 2007 08:00:28 +0000 (UTC) (envelope-from scottl@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.8/8.13.8) with ESMTP id l3F80ShV019744 for ; Sun, 15 Apr 2007 08:00:28 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l3F80S5s019741 for perforce@freebsd.org; Sun, 15 Apr 2007 08:00:28 GMT (envelope-from scottl@freebsd.org) Date: Sun, 15 Apr 2007 08:00:28 GMT Message-Id: <200704150800.l3F80S5s019741@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 118145 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: Sun, 15 Apr 2007 08:00:29 -0000 http://perforce.freebsd.org/chv.cgi?CH=118145 Change 118145 by scottl@scottl-x64 on 2007/04/15 07:59:43 Finish locking the scsi_sa periph, remove spls. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#12 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_sa.c#12 (text+ko) ==== @@ -456,6 +456,7 @@ } cam_periph_lock(periph); + softc = (struct sa_softc *)periph->softc; CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, @@ -467,6 +468,12 @@ return (0); } + if ((error = cam_periph_hold(periph, PRIBIO|PCATCH)) != 0) { + cam_periph_unlock(periph); + cam_periph_release(periph); + return (error); + } + if (softc->flags & SA_FLAG_OPEN) { error = EBUSY; } else if (softc->flags & SA_FLAG_INVALID) { @@ -488,12 +495,14 @@ if (error && (flags & O_NONBLOCK)) { softc->flags |= SA_FLAG_OPEN; softc->open_pending_mount = 1; + cam_periph_unhold(periph); cam_periph_unlock(periph); return (0); } } if (error) { + cam_periph_unhold(periph); cam_periph_unlock(periph); cam_periph_release(periph); return (error); @@ -502,6 +511,7 @@ saprevent(periph, PR_PREVENT); softc->flags |= SA_FLAG_OPEN; + cam_periph_unhold(periph); cam_periph_unlock(periph); return (error); } @@ -520,10 +530,10 @@ if (periph == NULL) return (ENXIO); + cam_periph_lock(periph); + softc = (struct sa_softc *)periph->softc; - cam_periph_lock(periph); - CAM_DEBUG(periph->path, CAM_DEBUG_TRACE|CAM_DEBUG_INFO, ("saclose(%d): dev=0x%x softc=0x%x\n", unit, unit, softc->flags)); @@ -544,6 +554,11 @@ return (0); } + if ((error = cam_periph_hold(periph, PRIBIO)) != 0) { + cam_periph_unlock(periph); + return (error); + } + /* * Were we writing the tape? */ @@ -651,6 +666,7 @@ if ((softc->flags & SA_FLAG_TAPE_MOUNTED) == 0) sareservereleaseunit(periph, FALSE); + cam_periph_unhold(periph); cam_periph_unlock(periph); cam_periph_release(periph); @@ -678,10 +694,10 @@ biofinish(bp, NULL, ENXIO); return; } + cam_periph_lock(periph); + softc = (struct sa_softc *)periph->softc; - cam_periph_lock(periph); - if (softc->flags & SA_FLAG_INVALID) { cam_periph_unlock(periph); biofinish(bp, NULL, ENXIO); @@ -803,7 +819,6 @@ struct sa_softc *softc; scsi_space_code spaceop; int didlockperiph = 0; - int s; int mode; int error = 0; @@ -815,6 +830,7 @@ if (periph == NULL) return (ENXIO); + cam_periph_lock(periph); softc = (struct sa_softc *)periph->softc; /* @@ -840,9 +856,10 @@ * other thread that has this device open to do * an MTIOCERRSTAT that would clear latched status. */ - s = splsoftcam(); if ((periph->flags & CAM_PERIPH_LOCKED) == 0) { - cam_periph_lock(periph); + error = cam_periph_hold(periph, PRIBIO|PCATCH); + if (error != 0) + return (error); didlockperiph = 1; } break; @@ -875,8 +892,9 @@ * than at open time because we are sharing writable * access to data structures. */ - s = splsoftcam(); - cam_periph_lock(periph); + error = cam_periph_hold(periph, PRIBIO|PCATCH); + if (error != 0) + return (error); didlockperiph = 1; break; @@ -1303,8 +1321,9 @@ } } if (didlockperiph) { - cam_periph_unlock(periph); + cam_periph_unhold(periph); } + cam_periph_unlock(periph); return (error); } @@ -1347,7 +1366,6 @@ { struct sa_softc *softc; struct ccb_setasync csa; - int s; softc = (struct sa_softc *)periph->softc; @@ -1365,20 +1383,12 @@ softc->flags |= SA_FLAG_INVALID; /* - * Although the oninvalidate() routines are always called at - * splsoftcam, we need to be at splbio() here to keep the buffer - * queue from being modified while we traverse it. - */ - s = splbio(); - - /* * Return all queued I/O with ENXIO. * XXX Handle any transactions queued to the card * with XPT_ABORT_CCB. */ bioq_flush(&softc->bio_queue, NULL, ENXIO); softc->queue_count = 0; - splx(s); xpt_print(periph->path, "lost device\n"); @@ -1585,12 +1595,10 @@ { /* Pull a buffer from the queue and get going on it */ struct bio *bp; - int s; /* * See if there is a buf with work for us to do.. */ - s = splbio(); bp = bioq_first(&softc->bio_queue); if (periph->immediate_priority <= periph->pinfo.priority) { CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE, @@ -1599,10 +1607,8 @@ SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h, periph_links.sle); periph->immediate_priority = CAM_PRIORITY_NONE; - splx(s); wakeup(&periph->ccb_list); } else if (bp == NULL) { - splx(s); xpt_release_ccb(start_ccb); } else if ((softc->flags & SA_FLAG_ERR_PENDING) != 0) { struct bio *done_bp; @@ -1645,7 +1651,6 @@ "%d more buffers queued up\n", (softc->flags & SA_FLAG_ERR_PENDING), (bp != NULL)? "not " : " ", softc->queue_count)); - splx(s); xpt_release_ccb(start_ccb); biodone(done_bp); } else { @@ -1665,7 +1670,6 @@ bp->bio_error = EIO; xpt_print(periph->path, "zero blocksize" " for FIXED length writes?\n"); - splx(s); biodone(bp); break; } @@ -1716,7 +1720,6 @@ Set_CCB_Type(start_ccb, SA_CCB_BUFFER_IO); start_ccb->ccb_h.ccb_bp = bp; bp = bioq_first(&softc->bio_queue); - splx(s); xpt_action(start_ccb); } @@ -1761,7 +1764,6 @@ } if (error == EIO) { - int s; /* * Catastrophic error. Mark the tape as frozen @@ -1774,10 +1776,8 @@ * */ - s = splbio(); softc->flags |= SA_FLAG_TAPE_FROZEN; bioq_flush(&softc->bio_queue, NULL, EIO); - splx(s); } if (error != 0) { bp->bio_resid = bp->bio_bcount;