Index: FreeBSD/sys/cam/scsi/scsi_da.c =================================================================== --- FreeBSD/sys/cam/scsi/scsi_da.c +++ FreeBSD/sys/cam/scsi/scsi_da.c @@ -309,7 +309,7 @@ struct cam_iosched_softc *cam_iosched; struct bio_queue_head delete_run_queue; LIST_HEAD(, ccb_hdr) pending_ccbs; - int refcount; /* Active xpt_action() calls */ + int refcount; /* Active CCBs */ da_state state; da_flags flags; da_quirks quirks; @@ -3243,7 +3243,6 @@ cam_periph_unlock(periph); xpt_action(start_ccb); cam_periph_lock(periph); - softc->refcount--; /* May have more work to do, so ensure we stay scheduled */ daschedule(periph); @@ -4402,6 +4401,13 @@ */ cam_iosched_bio_complete(softc->cam_iosched, bp, done_ccb); xpt_release_ccb(done_ccb); + + /* + * Release the periph refcount taken in dastart() for each CCB. + */ + KASSERT(softc->refcount >= 1, ("dadone softc %p refcount %d", softc, softc->refcount)); + softc->refcount--; + if (state == DA_CCB_DELETE) { TAILQ_HEAD(, bio) queue;