From owner-svn-src-stable-7@FreeBSD.ORG Sun Mar 1 16:28:18 2009 Return-Path: Delivered-To: svn-src-stable-7@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0301E106564A; Sun, 1 Mar 2009 16:28:18 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id CA3FD8FC13; Sun, 1 Mar 2009 16:28:17 +0000 (UTC) (envelope-from scottl@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n21GSH5P048423; Sun, 1 Mar 2009 16:28:17 GMT (envelope-from scottl@svn.freebsd.org) Received: (from scottl@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n21GSH8g048420; Sun, 1 Mar 2009 16:28:17 GMT (envelope-from scottl@svn.freebsd.org) Message-Id: <200903011628.n21GSH8g048420@svn.freebsd.org> From: Scott Long Date: Sun, 1 Mar 2009 16:28:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r189241 - in stable/7/sys: . cam/scsi contrib/pf dev/cxgb X-BeenThere: svn-src-stable-7@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 7-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 Mar 2009 16:28:18 -0000 Author: scottl Date: Sun Mar 1 16:28:17 2009 New Revision: 189241 URL: http://svn.freebsd.org/changeset/base/189241 Log: Merge 186371: Fix refcount locking in cd, pass, and sg periphs. Modified: stable/7/sys/ (props changed) stable/7/sys/cam/scsi/scsi_cd.c stable/7/sys/cam/scsi/scsi_pass.c stable/7/sys/cam/scsi/scsi_sg.c stable/7/sys/contrib/pf/ (props changed) stable/7/sys/dev/cxgb/ (props changed) Modified: stable/7/sys/cam/scsi/scsi_cd.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_cd.c Sun Mar 1 16:26:38 2009 (r189240) +++ stable/7/sys/cam/scsi/scsi_cd.c Sun Mar 1 16:28:17 2009 (r189241) @@ -996,12 +996,6 @@ cdopen(struct disk *dp) return (error); } - /* Closes aren't symmetrical with opens, so fix up the refcounting. */ - if (softc->flags & CD_FLAG_OPEN) - cam_periph_release(periph); - else - softc->flags |= CD_FLAG_OPEN; - /* * Check for media, and set the appropriate flags. We don't bail * if we don't have media, but then we don't allow anything but the @@ -1011,7 +1005,15 @@ cdopen(struct disk *dp) CAM_DEBUG(periph->path, CAM_DEBUG_TRACE, ("leaving cdopen\n")); cam_periph_unhold(periph); - cam_periph_unlock(periph); + + /* Closes aren't symmetrical with opens, so fix up the refcounting. */ + if ((softc->flags & CD_FLAG_OPEN) == 0) { + softc->flags |= CD_FLAG_OPEN; + cam_periph_unlock(periph); + } else { + cam_periph_unlock(periph); + cam_periph_release(periph); + } return (0); } Modified: stable/7/sys/cam/scsi/scsi_pass.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_pass.c Sun Mar 1 16:26:38 2009 (r189240) +++ stable/7/sys/cam/scsi/scsi_pass.c Sun Mar 1 16:28:17 2009 (r189241) @@ -345,13 +345,13 @@ passopen(struct cdev *dev, int flags, in if ((softc->flags & PASS_FLAG_OPEN) == 0) { softc->flags |= PASS_FLAG_OPEN; + cam_periph_unlock(periph); } else { /* Device closes aren't symmertical, so fix up the refcount */ + cam_periph_unlock(periph); cam_periph_release(periph); } - cam_periph_unlock(periph); - return (error); } Modified: stable/7/sys/cam/scsi/scsi_sg.c ============================================================================== --- stable/7/sys/cam/scsi/scsi_sg.c Sun Mar 1 16:26:38 2009 (r189240) +++ stable/7/sys/cam/scsi/scsi_sg.c Sun Mar 1 16:28:17 2009 (r189241) @@ -400,13 +400,13 @@ sgopen(struct cdev *dev, int flags, int if ((softc->flags & SG_FLAG_OPEN) == 0) { softc->flags |= SG_FLAG_OPEN; + cam_periph_unlock(periph); } else { /* Device closes aren't symmetrical, fix up the refcount. */ + cam_periph_unlock(periph); cam_periph_release(periph); } - cam_periph_unlock(periph); - return (error); }