From owner-p4-projects@FreeBSD.ORG Tue Mar 27 05:01:20 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 3C79816A408; Tue, 27 Mar 2007 05:01:20 +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 13CE616A406 for ; Tue, 27 Mar 2007 05:01:20 +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 0477F13C4AE for ; Tue, 27 Mar 2007 05:01:20 +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 l2R51J1I074001 for ; Tue, 27 Mar 2007 05:01:19 GMT (envelope-from scottl@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.8/8.13.8/Submit) id l2R51Jdu073966 for perforce@freebsd.org; Tue, 27 Mar 2007 05:01:19 GMT (envelope-from scottl@freebsd.org) Date: Tue, 27 Mar 2007 05:01:19 GMT Message-Id: <200703270501.l2R51Jdu073966@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 116625 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: Tue, 27 Mar 2007 05:01:20 -0000 http://perforce.freebsd.org/chv.cgi?CH=116625 Change 116625 by scottl@scottl-x64 on 2007/03/27 05:01:18 Fix up refcounting in the pass driver. Affected files ... .. //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#19 edit Differences ... ==== //depot/projects/scottl-camlock/src/sys/cam/scsi/scsi_pass.c#19 (text+ko) ==== @@ -331,7 +331,7 @@ error = 0; /* default to no error */ periph = (struct cam_periph *)dev->si_drv1; - if (periph == NULL) + if (cam_periph_acquire(periph) != CAM_REQ_CMP) return (ENXIO); cam_periph_lock(periph); @@ -342,6 +342,7 @@ if (softc->flags & PASS_FLAG_INVALID) { splx(s); cam_periph_unlock(periph); + cam_periph_release(periph); return(ENXIO); } @@ -352,6 +353,7 @@ if (error) { splx(s); cam_periph_unlock(periph); + cam_periph_release(periph); return(error); } @@ -361,6 +363,7 @@ if (((flags & FWRITE) == 0) || ((flags & FREAD) == 0)) { splx(s); cam_periph_unlock(periph); + cam_periph_release(periph); return(EPERM); } @@ -371,17 +374,17 @@ xpt_print(periph->path, "can't do nonblocking access\n"); splx(s); cam_periph_unlock(periph); + cam_periph_release(periph); return(EINVAL); } splx(s); if ((softc->flags & PASS_FLAG_OPEN) == 0) { - if (cam_periph_acquire(periph) != CAM_REQ_CMP) { - cam_periph_unlock(periph); - return(ENXIO); - } softc->flags |= PASS_FLAG_OPEN; + } else { + /* Device closes aren't symmertical, so fix up the refcount */ + cam_periph_release(periph); } cam_periph_unlock(periph); @@ -404,8 +407,8 @@ softc = (struct pass_softc *)periph->softc; softc->flags &= ~PASS_FLAG_OPEN; + cam_periph_unlock(periph); cam_periph_release(periph); - cam_periph_unlock(periph); return (0); } @@ -526,7 +529,7 @@ break; } - cam_periph_lock(periph); + cam_periph_unlock(periph); return(error); }