kernel - Change ccb state with lock held
authorMatthew Dillon <dillon@apollo.backplane.com>
Fri, 15 Apr 2011 15:24:55 +0000 (08:24 -0700)
committerMatthew Dillon <dillon@apollo.backplane.com>
Fri, 15 Apr 2011 15:24:55 +0000 (08:24 -0700)
* When putting a CCB back into the ap_ccb_free list do not
  change the state until after ap_ccb_lock has been acquired.

sys/dev/disk/ahci/ahci.c
sys/dev/disk/sili/sili.c

index ee86b1c..6ce365d 100644 (file)
@@ -3091,8 +3091,8 @@ ahci_put_ccb(struct ahci_ccb *ccb)
 {
        struct ahci_port                *ap = ccb->ccb_port;
 
-       ccb->ccb_xa.state = ATA_S_PUT;
        lockmgr(&ap->ap_ccb_lock, LK_EXCLUSIVE);
+       ccb->ccb_xa.state = ATA_S_PUT;
        TAILQ_INSERT_TAIL(&ap->ap_ccb_free, ccb, ccb_entry);
        lockmgr(&ap->ap_ccb_lock, LK_RELEASE);
 }
index a3c2c65..cec896d 100644 (file)
@@ -2022,8 +2022,8 @@ sili_put_ccb(struct sili_ccb *ccb)
 {
        struct sili_port                *ap = ccb->ccb_port;
 
-       ccb->ccb_xa.state = ATA_S_PUT;
        lockmgr(&ap->ap_ccb_lock, LK_EXCLUSIVE);
+       ccb->ccb_xa.state = ATA_S_PUT;
        TAILQ_INSERT_TAIL(&ap->ap_ccb_free, ccb, ccb_entry);
        lockmgr(&ap->ap_ccb_lock, LK_RELEASE);
 }