diff options
author | David Gwynne <dlg@cvs.openbsd.org> | 2010-09-20 00:19:48 +0000 |
---|---|---|
committer | David Gwynne <dlg@cvs.openbsd.org> | 2010-09-20 00:19:48 +0000 |
commit | 6b8b19aaaf22e601e0194faef24d942d6e6b3f72 (patch) | |
tree | 70cf697997dafb3ee56b119f5967985f40325d97 /sys/scsi/scsi_base.c | |
parent | 44d3d4bd8a4729216da78a7465817d5f4421156b (diff) |
bring back scsi_base.c r1.195 and scsiconf.h r1.138 now that
src/sys/dev/ata/atascsi.c r1.92 solves the problem that my scsi_link
change tickled.
tested by josh elsasser who reported the problem in pr6470
deraadt@ is letting it in again so it can get widespread testing
Diffstat (limited to 'sys/scsi/scsi_base.c')
-rw-r--r-- | sys/scsi/scsi_base.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index ca804c9b368..7fee8d1b5de 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.196 2010/09/17 23:19:02 dlg Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.197 2010/09/20 00:19:47 dlg Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -527,7 +527,9 @@ scsi_xsh_del(struct scsi_xshandler *xsh) break; case RUNQ_POOLQ: TAILQ_REMOVE(&link->pool->queue, &xsh->ioh, q_entry); - link->openings++; + link->pending--; + if (ISSET(link->state, SDEV_S_DYING) && link->pending == 0) + wakeup_one(&link->pending); break; default: panic("unexpected xsh state %u", xsh->ioh.q_state); @@ -552,9 +554,10 @@ scsi_xsh_runqueue(struct scsi_link *link) runq = 0; mtx_enter(&link->pool->mtx); - while (!ISSET(link->state, SDEV_S_DYING) && link->openings && + while (!ISSET(link->state, SDEV_S_DYING) && + link->pending < link->openings && ((ioh = TAILQ_FIRST(&link->queue)) != NULL)) { - link->openings--; + link->pending++; TAILQ_REMOVE(&link->queue, ioh, q_entry); TAILQ_INSERT_TAIL(&link->pool->queue, ioh, q_entry); @@ -681,11 +684,14 @@ scsi_link_shutdown(struct scsi_link *link) xsh->link == link) { TAILQ_REMOVE(&iopl->queue, &xsh->ioh, q_entry); xsh->ioh.q_state = RUNQ_IDLE; - link->openings++; + link->pending--; TAILQ_INSERT_TAIL(&sleepers, &xsh->ioh, q_entry); } } + + while (link->pending > 0) + msleep(&link->pending, &iopl->mtx, PRIBIO, "pendxs", 0); mtx_leave(&iopl->mtx); while ((ioh = TAILQ_FIRST(&sleepers)) != NULL) { @@ -700,8 +706,8 @@ scsi_link_open(struct scsi_link *link) int open = 0; mtx_enter(&link->pool->mtx); - if (link->openings) { - link->openings--; + if (link->pending < link->openings) { + link->pending++; open = 1; } mtx_leave(&link->pool->mtx); @@ -713,7 +719,9 @@ void scsi_link_close(struct scsi_link *link) { mtx_enter(&link->pool->mtx); - link->openings++; + link->pending--; + if (ISSET(link->state, SDEV_S_DYING) && link->pending == 0) + wakeup_one(&link->pending); mtx_leave(&link->pool->mtx); scsi_xsh_runqueue(link); |