diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-01-15 05:50:32 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2010-01-15 05:50:32 +0000 |
commit | d6bc3496210f7d19cc39810545baa806ca318143 (patch) | |
tree | 61c23c8e8e78a6445cd0d4faea08c75835dde879 /sys/scsi/scsi_base.c | |
parent | 2761e5bb53a1d6d65150c51d5f84dc68bb1daf49 (diff) |
Abstract and merge the manual buf queue manipulating functions into
one place for easier debugging and maintenance. No intended functional
changes.
ok dlg@
Diffstat (limited to 'sys/scsi/scsi_base.c')
-rw-r--r-- | sys/scsi/scsi_base.c | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/sys/scsi/scsi_base.c b/sys/scsi/scsi_base.c index ec175621dc5..e51e6489e0b 100644 --- a/sys/scsi/scsi_base.c +++ b/sys/scsi/scsi_base.c @@ -1,4 +1,4 @@ -/* $OpenBSD: scsi_base.c,v 1.164 2010/01/14 04:56:08 krw Exp $ */ +/* $OpenBSD: scsi_base.c,v 1.165 2010/01/15 05:50:31 krw Exp $ */ /* $NetBSD: scsi_base.c,v 1.43 1997/04/02 02:29:36 mycroft Exp $ */ /* @@ -1891,6 +1891,62 @@ scsi_decode_sense(struct scsi_sense_data *sense, int flag) return (rqsbuf); } +void +scsi_buf_enqueue(struct buf *head, struct buf *bp, struct mutex *mtx) +{ + struct buf *dp; + + mtx_enter(mtx); + dp = head; + bp->b_actf = NULL; + bp->b_actb = dp->b_actb; + *dp->b_actb = bp; + dp->b_actb = &bp->b_actf; + mtx_leave(mtx); +} + +struct buf * +scsi_buf_dequeue(struct buf *head, struct mutex *mtx) +{ + struct buf *bp; + + mtx_enter(mtx); + bp = head->b_actf; + if (bp != NULL) + head->b_actf = bp->b_actf; + if (head->b_actf == NULL) + head->b_actb = &head->b_actf; + mtx_leave(mtx); + + return (bp); +} + +void +scsi_buf_requeue(struct buf *head, struct buf *bp, struct mutex *mtx) +{ + mtx_enter(mtx); + bp->b_actf = head->b_actf; + head->b_actf = bp; + if (bp->b_actf == NULL) + head->b_actb = &bp->b_actf; + mtx_leave(mtx); +} + +void +scsi_buf_killqueue(struct buf *head, struct mutex *mtx) +{ + struct buf *bp; + int s; + + while ((bp = scsi_buf_dequeue(head, mtx)) != NULL) { + bp->b_error = ENXIO; + bp->b_flags |= B_ERROR; + s = splbio(); + biodone(bp); + splx(s); + } +} + #ifdef SCSIDEBUG /* * Given a scsi_xfer, dump the request, in all its glory |