diff options
author | phk <phk@FreeBSD.org> | 2003-03-15 11:00:56 +0000 |
---|---|---|
committer | phk <phk@FreeBSD.org> | 2003-03-15 11:00:56 +0000 |
commit | b122ce59431db328d6fbeef096c4e29e5eb6694a (patch) | |
tree | 323e3442188e65695b34aebf707adb17eb2a897e /sys/cam | |
parent | c187fd5ee8a272ca72c5d876b4594125a35e41fd (diff) | |
download | FreeBSD-src-b122ce59431db328d6fbeef096c4e29e5eb6694a.zip FreeBSD-src-b122ce59431db328d6fbeef096c4e29e5eb6694a.tar.gz |
Don't use the devstat->busy_count for state decisions in the device
drivers. Doing so imposes atomicity and locking constraints on the
devstat API.
By: ken
Diffstat (limited to 'sys/cam')
-rw-r--r-- | sys/cam/scsi/scsi_cd.c | 11 | ||||
-rw-r--r-- | sys/cam/scsi/scsi_da.c | 10 |
2 files changed, 13 insertions, 8 deletions
diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index bbe33ec..bda6b7b 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -151,6 +151,7 @@ struct cd_softc { dev_t dev; eventhandler_tag clonetag; int minimum_command_size; + int outstanding_cmds; struct sysctl_ctx_list sysctl_ctx; struct sysctl_oid *sysctl_tree; STAILQ_HEAD(, cd_mode_params) mode_queue; @@ -1088,7 +1089,7 @@ cdshorttimeout(void *arg) * this device. If not, move it out of the active slot. */ if ((bioq_first(&changer->cur_device->bio_queue) == NULL) - && (changer->cur_device->device_stats->busy_count == 0)) { + && (changer->cur_device->outstanding_cmds == 0)) { changer->flags |= CHANGER_MANUAL_CALL; cdrunchangerqueue(changer); } @@ -1187,10 +1188,10 @@ cdrunchangerqueue(void *arg) */ if (changer->devq.qfrozen_cnt > 0) { - if (changer->cur_device->device_stats->busy_count > 0) { + if (changer->cur_device->outstanding_cmds > 0) { changer->cur_device->flags |= CD_FLAG_SCHED_ON_COMP; changer->cur_device->bufs_left = - changer->cur_device->device_stats->busy_count; + changer->cur_device->outstanding_cmds; if (called_from_timeout) { changer->long_handle = timeout(cdrunchangerqueue, changer, @@ -1297,7 +1298,7 @@ cdchangerschedule(struct cd_softc *softc) cdrunchangerqueue(softc->changer); } } else if ((bioq_first(&softc->bio_queue) == NULL) - && (softc->device_stats->busy_count == 0)) { + && (softc->outstanding_cmds == 0)) { softc->changer->flags |= CHANGER_MANUAL_CALL; cdrunchangerqueue(softc->changer); } @@ -1533,6 +1534,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb) oldspl = splcam(); LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h, periph_links.le); + softc->outstanding_cmds++; splx(oldspl); /* We expect a unit attention from this device */ @@ -1661,6 +1663,7 @@ cddone(struct cam_periph *periph, union ccb *done_ccb) */ oldspl = splcam(); LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); + softc->outstanding_cmds--; splx(oldspl); if (softc->flags & CD_FLAG_CHANGER) diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index 20e93c2..4007d29 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -123,6 +123,7 @@ struct da_softc { da_quirks quirks; int minimum_cmd_size; int ordered_tag_count; + int outstanding_cmds; struct disk_params params; struct disk disk; union ccb saved_ccb; @@ -1298,6 +1299,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb) oldspl = splcam(); LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h, periph_links.le); + softc->outstanding_cmds++; splx(oldspl); /* We expect a unit attention from this device */ @@ -1499,10 +1501,10 @@ dadone(struct cam_periph *periph, union ccb *done_ccb) */ oldspl = splcam(); LIST_REMOVE(&done_ccb->ccb_h, periph_links.le); - splx(oldspl); - - if (softc->disk.d_devstat->busy_count == 0) + softc->outstanding_cmds--; + if (softc->outstanding_cmds == 0) softc->flags |= DA_FLAG_WENT_IDLE; + splx(oldspl); biodone(bp); break; @@ -1781,7 +1783,7 @@ dasendorderedtag(void *arg) && ((softc->flags & DA_FLAG_WENT_IDLE) == 0)) { softc->flags |= DA_FLAG_NEED_OTAG; } - if (softc->disk.d_devstat->busy_count > 0) + if (softc->outstanding_cmds > 0) softc->flags &= ~DA_FLAG_WENT_IDLE; softc->ordered_tag_count = 0; |