From owner-p4-projects@FreeBSD.ORG Wed Mar 28 18:04:08 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 50B7316A40E; Wed, 28 Mar 2007 18:03:58 +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 23DDE16A4E6 for ; Wed, 28 Mar 2007 18:03:57 +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 75FFF13C46C for ; Wed, 28 Mar 2007 18:03:57 +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 l2SI3vLb016058 for ; Wed, 28 Mar 2007 18:03:57 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l2SI3vL8016048 for perforce@freebsd.org; Wed, 28 Mar 2007 18:03:57 GMT (envelope-from scottl@freebsd.org) Date: Wed, 28 Mar 2007 18:03:57 GMT Message-Id: <200703281803.l2SI3vL8016048@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 116756 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: Wed, 28 Mar 2007 18:04:08 -0000 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; }