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);
 }
 
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to