First set of changes to eliminate the ad-hoc device buffer queues,

replacing them with TAILQ's as appropriate.  The SCSI code is the
first to be changed -- until the changes are complete, both b_act and
b_actf will be in the buf structure.  b_actf will eventually be removed.
This commit is contained in:
John Dyson 1995-11-19 22:22:35 +00:00
parent fb9ca17e1e
commit 68a2196fad
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=12408
9 changed files with 71 additions and 81 deletions

View File

@ -14,7 +14,7 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
*
* $Id: cd.c,v 1.42 1995/10/21 23:13:06 phk Exp $
* $Id: cd.c,v 1.43 1995/11/15 03:27:14 asami Exp $
*/
#define SPLCD splbio
@ -83,7 +83,7 @@ struct scsi_data {
#define CDOPEN 0x01
u_int32 openparts; /* one bit for each open partition */
u_int32 xfer_block_wait;
struct buf buf_queue;
struct buf_queue_head buf_queue;
int dkunit;
};
@ -180,6 +180,7 @@ cdattach(struct scsi_link *sc_link)
unit = sc_link->dev_unit;
dp = &(cd->params);
TAILQ_INIT(&cd->buf_queue);
if (sc_link->opennings > CDOUTSTANDING)
sc_link->opennings = CDOUTSTANDING;
/*
@ -359,7 +360,6 @@ cd_close(dev_t dev, int flag, int fmt, struct proc *p,
void
cd_strategy(struct buf *bp, struct scsi_link *sc_link)
{
struct buf *dp;
u_int32 opri;
u_int32 unit = CDUNIT((bp->b_dev));
struct scsi_data *cd = sc_link->sd;
@ -396,7 +396,6 @@ cd_strategy(struct buf *bp, struct scsi_link *sc_link)
bp->b_resid = 0;
}
opri = SPLCD();
dp = &cd->buf_queue;
/*
* Use a bounce buffer if necessary
@ -409,7 +408,7 @@ cd_strategy(struct buf *bp, struct scsi_link *sc_link)
/*
* Place it in the queue of disk activities for this disk
*/
disksort(dp, bp);
TAILQ_INSERT_TAIL(&cd->buf_queue, bp, b_act);
/*
* Tell the device to get going on the transfer if it's
@ -453,7 +452,6 @@ cdstart(unit, flags)
u_int32 flags;
{
register struct buf *bp = 0;
register struct buf *dp;
struct scsi_rw_big cmd;
u_int32 blkno, nblk;
struct partition *p;
@ -471,12 +469,13 @@ cdstart(unit, flags)
if (sc_link->flags & SDEV_WAITING) { /* is room, but a special waits */
return; /* give the special that's waiting a chance to run */
}
dp = &cd->buf_queue;
if ((bp = dp->b_actf) != NULL) { /* yes, an assign */
dp->b_actf = bp->b_actf;
} else {
bp = cd->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
TAILQ_REMOVE( &cd->buf_queue, bp, b_act);
/*
* Should reject all queued entries if SDEV_MEDIA_LOADED is not true.
*/

View File

@ -28,7 +28,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
* $Id: od.c,v 1.7 1995/07/04 15:12:53 shun Exp $
* $Id: od.c,v 1.1 1995/10/31 17:25:58 joerg Exp $
*/
/*
@ -93,7 +93,7 @@ struct scsi_data {
u_int32 disksize; /* total number sectors */
} params;
struct diskslices *dk_slices; /* virtual drives */
struct buf buf_queue;
struct buf_queue_head buf_queue;
int dkunit; /* disk stats unit number */
};
@ -191,6 +191,8 @@ odattach(struct scsi_link *sc_link)
if (sc_link->opennings > ODOUTSTANDING)
sc_link->opennings = ODOUTSTANDING;
TAILQ_INIT(&od->buf_queue);
/*
* Use the subdriver to request information regarding
* the drive. We cannot use interrupts yet, so the
@ -381,7 +383,6 @@ od_close(dev, fflag, fmt, p, sc_link)
void
od_strategy(struct buf *bp, struct scsi_link *sc_link)
{
struct buf *dp;
u_int32 opri;
struct scsi_data *od;
u_int32 unit;
@ -412,7 +413,6 @@ od_strategy(struct buf *bp, struct scsi_link *sc_link)
goto done; /* XXX check b_resid */
opri = SPLOD();
dp = &od->buf_queue;
/*
* Use a bounce buffer if necessary
@ -425,7 +425,7 @@ od_strategy(struct buf *bp, struct scsi_link *sc_link)
/*
* Place it in the queue of disk activities for this disk
*/
disksort(dp, bp);
TAILQ_INSERT_TAIL(&od->buf_queue, bp, b_act);
/*
* Tell the device to get going on the transfer if it's
@ -479,7 +479,6 @@ odstart(u_int32 unit, u_int32 flags)
register struct scsi_link *sc_link = SCSI_LINK(&od_switch, unit);
register struct scsi_data *od = sc_link->sd;
struct buf *bp = 0;
struct buf *dp;
struct scsi_rw_big cmd;
u_int32 blkno, nblk;
@ -500,11 +499,11 @@ odstart(u_int32 unit, u_int32 flags)
/*
* See if there is a buf with work for us to do..
*/
dp = &od->buf_queue;
if ((bp = dp->b_actf) == NULL) { /* yes, an assign */
bp = od->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
dp->b_actf = bp->b_actf;
TAILQ_REMOVE( &od->buf_queue, bp, b_act);
/*
* If the device has become invalid, abort all the

View File

@ -37,7 +37,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: pt.c,v 1.4 1995/05/03 18:09:09 dufault Exp $
* $Id: pt.c,v 1.5 1995/05/30 08:13:23 rgrimes Exp $
*/
/*
@ -54,7 +54,7 @@
#include <scsi/scsiconf.h>
struct scsi_data {
struct buf *buf_queue; /* the queue of pending IO operations */
struct buf_queue_head buf_queue;
};
void ptstart(u_int32 unit, u_int32 flags);
@ -131,10 +131,12 @@ ptstart(unit, flags)
wakeup((caddr_t)sc_link);
return;
}
if ((bp = pt->buf_queue) == NULL) {
return; /* no work to bother with */
bp = pt->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
pt->buf_queue = bp->b_actf;
TAILQ_REMOVE( &pt->buf_queue, bp, b_act);
/*
* Fill out the scsi command
@ -196,12 +198,7 @@ pt_strategy(struct buf *bp, struct scsi_link *sc_link)
* at the end (a bit silly because we only have one user..
* (but it could fork() ))
*/
dp = &(pt->buf_queue);
while (*dp) {
dp = &((*dp)->b_actf);
}
*dp = bp;
bp->b_actf = NULL;
TAILQ_INSERT_TAIL( &pt->buf_queue, bp, b_act);
/*
* Tell the device to get going on the transfer if it's

View File

@ -37,7 +37,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: sctarg.c,v 1.3 1995/05/30 08:13:49 rgrimes Exp $
* $Id: sctarg.c,v 1.4 1995/07/13 16:08:57 bde Exp $
*/
/*
@ -56,7 +56,7 @@
#define OPEN 0x01
struct scsi_data {
struct buf *buf_queue; /* the queue of pending IO operations */
struct buf_queue_head buf_queue;
int flags; /* Already open */
};
@ -189,10 +189,12 @@ sctargstart(unit, unused_flags)
wakeup((caddr_t)sc_link);
return;
}
if ((bp = sctarg->buf_queue) == NULL) {
return; /* no work to bother with */
bp = sctarg->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
sctarg->buf_queue = bp->b_actf;
TAILQ_REMOVE( &pt->buf_queue, bp, b_act);
/*
* Fill out the scsi command
@ -253,12 +255,7 @@ sctarg_strategy(struct buf *bp, struct scsi_link *sc_link)
/*
* Place it at the end of the queue of activities for this device.
*/
dp = &(sctarg->buf_queue);
while (*dp) {
dp = &((*dp)->b_actf);
}
*dp = bp;
bp->b_actf = NULL;
TAILQ_INSERT_TAIL( &sctarg->buf_queue, bp, b_act);
/*
* Tell the device to get going on the transfer if it's

View File

@ -14,7 +14,7 @@
*
* Ported to run under 386BSD by Julian Elischer (julian@dialix.oz.au) Sept 1992
*
* $Id: sd.c,v 1.68 1995/10/21 23:13:09 phk Exp $
* $Id: sd.c,v 1.69 1995/11/06 08:19:24 davidg Exp $
*/
#define SPLSD splbio
@ -74,7 +74,7 @@ struct scsi_data {
u_int32 disksize; /* total number sectors */
} params;
struct diskslices *dk_slices; /* virtual drives */
struct buf buf_queue;
struct buf_queue_head buf_queue;
int dkunit; /* disk stats unit number */
};
@ -172,6 +172,8 @@ sdattach(struct scsi_link *sc_link)
if (sc_link->opennings > SDOUTSTANDING)
sc_link->opennings = SDOUTSTANDING;
TAILQ_INIT(&sd->buf_queue);
/*
* Use the subdriver to request information regarding
* the drive. We cannot use interrupts yet, so the
@ -357,7 +359,6 @@ sd_close(dev, fflag, fmt, p, sc_link)
void
sd_strategy(struct buf *bp, struct scsi_link *sc_link)
{
struct buf *dp;
u_int32 opri;
struct scsi_data *sd;
u_int32 unit;
@ -392,8 +393,6 @@ sd_strategy(struct buf *bp, struct scsi_link *sc_link)
goto done; /* XXX check b_resid */
opri = SPLSD();
dp = &sd->buf_queue;
/*
* Use a bounce buffer if necessary
*/
@ -405,7 +404,7 @@ sd_strategy(struct buf *bp, struct scsi_link *sc_link)
/*
* Place it in the queue of disk activities for this disk
*/
disksort(dp, bp);
TAILQ_INSERT_TAIL(&sd->buf_queue, bp, b_act);
/*
* Tell the device to get going on the transfer if it's
@ -459,7 +458,6 @@ sdstart(u_int32 unit, u_int32 flags)
register struct scsi_link *sc_link = SCSI_LINK(&sd_switch, unit);
register struct scsi_data *sd = sc_link->sd;
struct buf *bp = 0;
struct buf *dp;
struct scsi_rw_big cmd;
u_int32 blkno, nblk;
@ -480,12 +478,12 @@ sdstart(u_int32 unit, u_int32 flags)
/*
* See if there is a buf with work for us to do..
*/
dp = &sd->buf_queue;
if ((bp = dp->b_actf) == NULL) { /* yes, an assign */
bp = sd->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
dp->b_actf = bp->b_actf;
bp->b_actf = NULL;
TAILQ_REMOVE( &sd->buf_queue, bp, b_act);
/*
* If the device has become invalid, abort all the

View File

@ -12,7 +12,7 @@
* on the understanding that TFS is not responsible for the correct
* functioning of this software in any circumstances.
*
* $Id: st.c,v 1.41 1995/10/21 23:13:10 phk Exp $
* $Id: st.c,v 1.42 1995/11/04 13:25:23 bde Exp $
*/
/*
@ -218,7 +218,7 @@ struct scsi_data {
* additional sense data needed
* for mode sense/select.
*/
struct buf *buf_queue; /* the queue of pending IO operations */
struct buf_queue_head buf_queue;
struct scsi_xfer scsi_xfer; /* scsi xfer struct for this drive */
u_int32 xfer_block_wait; /* is a process waiting? */
};
@ -328,6 +328,7 @@ stattach(struct scsi_link *sc_link)
unit = sc_link->dev_unit;
TAILQ_INIT(&st->buf_queue);
/*
* Check if the drive is a known criminal and take
* Any steps needed to bring it into line
@ -362,7 +363,6 @@ stattach(struct scsi_link *sc_link)
/*
* Set up the buf queue for this device
*/
st->buf_queue = 0;
st->flags |= ST_INITIALIZED;
st_registerdev(unit);
@ -899,7 +899,6 @@ done:
void
st_strategy(struct buf *bp, struct scsi_link *sc_link)
{
struct buf **dp;
unsigned char unit; /* XXX Everywhere else unit is "u_int32". Please int? */
u_int32 opri;
struct scsi_data *st;
@ -962,12 +961,7 @@ st_strategy(struct buf *bp, struct scsi_link *sc_link)
* at the end (a bit silly because we only have on user..
* (but it could fork() ))
*/
dp = &(st->buf_queue);
while (*dp) {
dp = &((*dp)->b_actf);
}
*dp = bp;
bp->b_actf = NULL;
TAILQ_INSERT_TAIL(&st->buf_queue, bp, b_act);
/*
* Tell the device to get going on the transfer if it's
@ -1025,10 +1019,12 @@ ststart(unit, flags)
wakeup((caddr_t)sc_link);
return;
}
if ((bp = st->buf_queue) == NULL) {
return; /* no work to bother with */
bp = st->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
st->buf_queue = bp->b_actf;
TAILQ_REMOVE( &st->buf_queue, bp, b_act);
/*
* if the device has been unmounted by the user

View File

@ -37,7 +37,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* $Id: worm.c,v 1.8 1995/10/09 15:15:01 joerg Exp $
* $Id: worm.c,v 1.9 1995/10/21 23:13:11 phk Exp $
*/
/* XXX This is PRELIMINARY.
@ -60,8 +60,7 @@
#include <scsi/scsi_disk.h>
struct scsi_data {
struct buf *buf_queue; /* the queue of pending IO operations */
struct buf_queue_head buf_queue;
u_int32 n_blks; /* Number of blocks (0 for bogus) */
u_int32 blk_size; /* Size of each blocks */
};
@ -131,6 +130,8 @@ wormattach(struct scsi_link *sc_link)
{
struct scsi_data *worm = sc_link->sd;
TAILQ_INIT(&worm->buf_queue);
printf("- UNTESTED ");
if (worm_size(sc_link, SCSI_NOSLEEP | SCSI_NOMASK) == 0)
@ -204,10 +205,12 @@ wormstart(unit, flags)
wakeup(sc_link);
return;
}
if ((bp = worm->buf_queue) == NULL) {
return; /* no work to bother with */
bp = worm->buf_queue.tqh_first;
if (bp == NULL) { /* yes, an assign */
return;
}
worm->buf_queue = bp->b_actf;
TAILQ_REMOVE( &worm->buf_queue, bp, b_act);
/*
* Fill out the scsi command
@ -289,12 +292,7 @@ worm_strategy(struct buf *bp, struct scsi_link *sc_link)
* Place it in the queue of activities for this device
* at the end.
*/
dp = &(worm->buf_queue);
while (*dp) {
dp = &((*dp)->b_actf);
}
*dp = bp;
bp->b_actf = NULL;
TAILQ_INSERT_TAIL(&worm->buf_queue, bp, b_act);
wormstart(unit, 0);

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)buf.h 8.7 (Berkeley) 1/21/94
* $Id: buf.h,v 1.21 1995/08/24 12:57:17 davidg Exp $
* $Id: buf.h,v 1.22 1995/11/19 19:54:31 dyson Exp $
*/
#ifndef _SYS_BUF_H_
@ -57,6 +57,8 @@ struct iodone_chain {
} ic_args[5];
};
typedef TAILQ_HEAD(buf_queue_head, buf) buf_queue_head, *buf_queue_head_t;
/*
* The buffer header describes an I/O operation in the kernel.
*/
@ -64,7 +66,8 @@ struct buf {
LIST_ENTRY(buf) b_hash; /* Hash chain. */
LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
struct buf *b_actf, **b_actb; /* Device driver queue when active. */
struct buf *b_actf, **b_actb; /* Device driver queue when active. *depricated* XXX */
TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
struct proc *b_proc; /* Associated proc; NULL if kernel. */
volatile long b_flags; /* B_* flags. */
int b_qindex; /* buffer queue index */

View File

@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)buf.h 8.7 (Berkeley) 1/21/94
* $Id: buf.h,v 1.21 1995/08/24 12:57:17 davidg Exp $
* $Id: buf.h,v 1.22 1995/11/19 19:54:31 dyson Exp $
*/
#ifndef _SYS_BUF_H_
@ -57,6 +57,8 @@ struct iodone_chain {
} ic_args[5];
};
typedef TAILQ_HEAD(buf_queue_head, buf) buf_queue_head, *buf_queue_head_t;
/*
* The buffer header describes an I/O operation in the kernel.
*/
@ -64,7 +66,8 @@ struct buf {
LIST_ENTRY(buf) b_hash; /* Hash chain. */
LIST_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
struct buf *b_actf, **b_actb; /* Device driver queue when active. */
struct buf *b_actf, **b_actb; /* Device driver queue when active. *depricated* XXX */
TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */
struct proc *b_proc; /* Associated proc; NULL if kernel. */
volatile long b_flags; /* B_* flags. */
int b_qindex; /* buffer queue index */