Make the entire BUF/BIO system BIO-centric instead of BUF-centric. Vnode
authorMatthew Dillon <dillon@dragonflybsd.org>
Fri, 17 Feb 2006 19:18:08 +0000 (19:18 +0000)
committerMatthew Dillon <dillon@dragonflybsd.org>
Fri, 17 Feb 2006 19:18:08 +0000 (19:18 +0000)
and device strategy routines now take a BIO and must pass that BIO to
biodone().  All code which previously managed a BUF undergoing I/O now
manages a BIO.

The new BIO-centric algorithms allow BIOs to be stacked, where each layer
represents a block translation, completion callback, or caller or device
private data.  This information is no longer overloaded within the BUF.
Translation layer linkages remain intact as a 'cache' after I/O has completed.

The VOP and DEV strategy routines no longer make assumptions as to which
translated block number applies to them.  The use the block number in the
BIO specifically passed to them.

Change the 'untranslated' constant to NOOFFSET (for bio_offset), and
(daddr_t)-1 (for bio_blkno).  Rip out all code that previously set the
translated block number to the untranslated block number to indicate
that the translation had not been made.

Rip out all the cluster linkage fields for clustered VFS and clustered
paging operations.  Clustering now occurs in a private BIO layer using
private fields within the BIO.

Reformulate the vn_strategy() and dev_dstrategy() abstraction(s).  These
routines no longer assume that bp->b_vp == the vp of the VOP operation, and
the dev_t is no longer stored in the struct buf.  Instead, only the vp passed
to vn_strategy() (and related *_strategy() routines for VFS ops), and
the dev_t passed to dev_dstrateg() (and related *_strategy() routines for
device ops) is used by the VFS or DEV code.  This will allow an arbitrary
number of translation layers in the future.

Create an independant per-BIO tracking entity, struct bio_track, which
is used to determine when I/O is in-progress on the associated device
or vnode.

NOTE: Unlike FreeBSD's BIO work, our struct BUF is still used to hold
the fields describing the data buffer, resid, and error state.

Major-testing-by: Stefan Krueger
147 files changed:
sys/bus/cam/scsi/scsi_cd.c
sys/bus/cam/scsi/scsi_ch.c
sys/bus/cam/scsi/scsi_da.c
sys/bus/cam/scsi/scsi_pass.c
sys/bus/cam/scsi/scsi_pt.c
sys/bus/cam/scsi/scsi_sa.c
sys/bus/cam/scsi/scsi_ses.c
sys/bus/firewire/firewirereg.h
sys/bus/firewire/fwdev.c
sys/bus/firewire/fwmem.c
sys/contrib/dev/fla/fla.c
sys/dev/disk/ata/ata-disk.c
sys/dev/disk/ata/ata-disk.h
sys/dev/disk/ata/ata-raid.c
sys/dev/disk/ata/ata-raid.h
sys/dev/disk/ata/atapi-all.c
sys/dev/disk/ata/atapi-cd.c
sys/dev/disk/ata/atapi-cd.h
sys/dev/disk/ata/atapi-fd.c
sys/dev/disk/ata/atapi-fd.h
sys/dev/disk/ata/atapi-tape.c
sys/dev/disk/ata/atapi-tape.h
sys/dev/disk/ccd/ccd.c
sys/dev/disk/fd/fd.c
sys/dev/disk/fd/fdc.h
sys/dev/disk/mcd/mcd.c
sys/dev/disk/md/md.c
sys/dev/disk/scd/scd.c
sys/dev/disk/vn/vn.c
sys/dev/disk/wt/wt.c
sys/dev/misc/labpc/labpc.c
sys/dev/netif/de/if_de.c
sys/dev/netif/de/if_devar.h
sys/dev/raid/aac/aac.c
sys/dev/raid/aac/aac_compat.h
sys/dev/raid/aac/aac_disk.c
sys/dev/raid/aac/aacvar.h
sys/dev/raid/amr/amr.c
sys/dev/raid/amr/amr_compat.h
sys/dev/raid/amr/amr_disk.c
sys/dev/raid/amr/amrvar.h
sys/dev/raid/ida/ida.c
sys/dev/raid/ida/ida_disk.c
sys/dev/raid/ida/idavar.h
sys/dev/raid/ips/ips.h
sys/dev/raid/ips/ips_commands.c
sys/dev/raid/ips/ips_disk.c
sys/dev/raid/ips/ips_pci.c
sys/dev/raid/mlx/mlx.c
sys/dev/raid/mlx/mlx_compat.h
sys/dev/raid/mlx/mlx_disk.c
sys/dev/raid/mlx/mlxvar.h
sys/dev/raid/pst/pst-raid.c
sys/dev/raid/twe/twe.c
sys/dev/raid/twe/twe_compat.h
sys/dev/raid/twe/twe_freebsd.c
sys/dev/raid/twe/twevar.h
sys/dev/raid/vinum/.gdbinit.crash
sys/dev/raid/vinum/.gdbinit.kernel
sys/dev/raid/vinum/.gdbinit.vinum
sys/dev/raid/vinum/request.h
sys/dev/raid/vinum/vinumdaemon.c
sys/dev/raid/vinum/vinumext.h
sys/dev/raid/vinum/vinuminterrupt.c
sys/dev/raid/vinum/vinumio.c
sys/dev/raid/vinum/vinumlock.c
sys/dev/raid/vinum/vinumraid5.c
sys/dev/raid/vinum/vinumrequest.c
sys/dev/raid/vinum/vinumrevive.c
sys/dev/raid/vinum/vinumstate.c
sys/dev/raid/vinum/vinumvar.h
sys/i386/i386/machdep.c
sys/kern/kern_device.c
sys/kern/kern_physio.c
sys/kern/kern_shutdown.c
sys/kern/subr_disk.c
sys/kern/subr_diskmbr.c
sys/kern/subr_diskslice.c
sys/kern/subr_xxx.c
sys/kern/tty_cons.c
sys/kern/vfs_aio.c
sys/kern/vfs_bio.c
sys/kern/vfs_cluster.c
sys/kern/vfs_default.c
sys/kern/vfs_lock.c
sys/kern/vfs_subr.c
sys/kern/vfs_vopops.c
sys/platform/pc32/i386/machdep.c
sys/sys/bio.h
sys/sys/biotrack.h [new file with mode: 0644]
sys/sys/buf.h
sys/sys/buf2.h
sys/sys/conf.h
sys/sys/device.h
sys/sys/disklabel.h
sys/sys/disklabel32.h
sys/sys/diskslice.h
sys/sys/odisklabel.h
sys/sys/vfsops.h
sys/sys/vnode.h
sys/vfs/coda/coda_vnops.c
sys/vfs/coda/coda_vnops.h
sys/vfs/gnu/ext2fs/ext2_alloc.c
sys/vfs/gnu/ext2fs/ext2_balloc.c
sys/vfs/gnu/ext2fs/ext2_inode.c
sys/vfs/gnu/ext2fs/ext2_subr.c
sys/vfs/gnu/ext2fs/ext2_vnops.c
sys/vfs/hpfs/hpfs_vnops.c
sys/vfs/isofs/cd9660/cd9660_lookup.c
sys/vfs/isofs/cd9660/cd9660_vnops.c
sys/vfs/mfs/mfs_extern.h
sys/vfs/mfs/mfs_vfsops.c
sys/vfs/mfs/mfs_vnops.c
sys/vfs/mfs/mfsnode.h
sys/vfs/msdosfs/msdosfs_fat.c
sys/vfs/msdosfs/msdosfs_vfsops.c
sys/vfs/msdosfs/msdosfs_vnops.c
sys/vfs/nfs/nfs.h
sys/vfs/nfs/nfs_bio.c
sys/vfs/nfs/nfs_syscalls.c
sys/vfs/nfs/nfs_vfsops.c
sys/vfs/nfs/nfs_vnops.c
sys/vfs/nfs/nfsmount.h
sys/vfs/ntfs/ntfs_vnops.c
sys/vfs/nwfs/nwfs.h
sys/vfs/nwfs/nwfs_io.c
sys/vfs/nwfs/nwfs_vnops.c
sys/vfs/smbfs/smbfs.h
sys/vfs/smbfs/smbfs_io.c
sys/vfs/smbfs/smbfs_vnops.c
sys/vfs/specfs/spec_vnops.c
sys/vfs/udf/udf_vnops.c
sys/vfs/ufs/ffs_alloc.c
sys/vfs/ufs/ffs_balloc.c
sys/vfs/ufs/ffs_inode.c
sys/vfs/ufs/ffs_rawread.c
sys/vfs/ufs/ffs_softdep.c
sys/vfs/ufs/ffs_subr.c
sys/vfs/ufs/ffs_vfsops.c
sys/vfs/ufs/ufs_bmap.c
sys/vfs/ufs/ufs_vnops.c
sys/vfs/union/union_vnops.c
sys/vm/swap_pager.c
sys/vm/vm_pager.c
sys/vm/vm_pager.h
sys/vm/vm_swap.c
sys/vm/vnode_pager.c

index f06f982..0a910d6 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_cd.c,v 1.31.2.16 2003/10/21 22:26:11 thomas Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.19 2005/09/21 18:58:55 hsu Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.20 2006/02/17 19:17:42 dillon Exp $
  */
 /*
  * Portions of this driver taken from the original FreeBSD cd driver.
@@ -126,7 +126,7 @@ typedef enum {
 } cd_changer_flags;
 
 #define ccb_state ppriv_field0
-#define ccb_bp ppriv_ptr1
+#define ccb_bio ppriv_ptr1
 
 struct cd_tocdata {
        struct ioc_toc_header header;
@@ -147,7 +147,7 @@ struct cd_softc {
        cam_pinfo               pinfo;
        cd_state                state;
        volatile cd_flags       flags;
-       struct buf_queue_head   buf_queue;
+       struct bio_queue_head   bio_queue;
        LIST_HEAD(, ccb_hdr)    pending_ccbs;
        struct cd_params        params;
        struct disk             disk;
@@ -405,6 +405,7 @@ cdoninvalidate(struct cam_periph *periph)
 {
        struct cd_softc *softc;
        struct buf *q_bp;
+       struct bio *q_bio;
        struct ccb_setasync csa;
 
        softc = (struct cd_softc *)periph->softc;
@@ -434,12 +435,13 @@ cdoninvalidate(struct cam_periph *periph)
         * XXX Handle any transactions queued to the card
         *     with XPT_ABORT_CCB.
         */
-       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL){
-               bufq_remove(&softc->buf_queue, q_bp);
+       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL){
+               bioq_remove(&softc->bio_queue, q_bio);
+               q_bp = q_bio->bio_buf;
                q_bp->b_resid = q_bp->b_bcount;
                q_bp->b_error = ENXIO;
                q_bp->b_flags |= B_ERROR;
-               biodone(q_bp);
+               biodone(q_bio);
        }
        crit_exit();
 
@@ -705,7 +707,7 @@ cdregister(struct cam_periph *periph, void *arg)
        LIST_INIT(&softc->pending_ccbs);
        STAILQ_INIT(&softc->mode_queue);
        softc->state = CD_STATE_PROBE;
-       bufq_init(&softc->buf_queue);
+       bioq_init(&softc->bio_queue);
        if (SID_IS_REMOVABLE(&cgd->inq_data))
                softc->flags |= CD_FLAG_DISC_REMOVABLE;
        if ((cgd->inq_data.flags & SID_CmdQue) != 0)
@@ -1119,7 +1121,7 @@ cdshorttimeout(void *arg)
         * Check to see if there is any more pending or outstanding I/O for
         * this device.  If not, move it out of the active slot.
         */
-       if ((bufq_first(&changer->cur_device->buf_queue) == NULL)
+       if ((bioq_first(&changer->cur_device->bio_queue) == NULL)
         && (changer->cur_device->device_stats.busy_count == 0)) {
                changer->flags |= CHANGER_MANUAL_CALL;
                cdrunchangerqueue(changer);
@@ -1242,7 +1244,7 @@ cdrunchangerqueue(void *arg)
                 * to do.  If so, requeue it at the end of the queue.  If
                 * not, there is no need to requeue it.
                 */
-               if (bufq_first(&changer->cur_device->buf_queue) != NULL) {
+               if (bioq_first(&changer->cur_device->bio_queue) != NULL) {
 
                        changer->cur_device->pinfo.generation =
                                ++changer->devq.generation;
@@ -1323,7 +1325,7 @@ cdchangerschedule(struct cd_softc *softc)
                                softc->flags &= ~CD_FLAG_SCHED_ON_COMP;
                                cdrunchangerqueue(softc->changer);
                        }
-               } else if ((bufq_first(&softc->buf_queue) == NULL)
+               } else if ((bioq_first(&softc->bio_queue) == NULL)
                        && (softc->device_stats.busy_count == 0)) {
                        softc->changer->flags |= CHANGER_MANUAL_CALL;
                        cdrunchangerqueue(softc->changer);
@@ -1431,14 +1433,15 @@ cdgetccb(struct cam_periph *periph, u_int32_t priority)
  * only one physical transfer.
  */
 static void
-cdstrategy(struct buf *bp)
+cdstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct cam_periph *periph;
        struct cd_softc *softc;
        u_int  unit, part;
 
-       unit = dkunit(bp->b_dev);
-       part = dkpart(bp->b_dev);
+       unit = dkunit(dev);
+       part = dkpart(dev);
        periph = cam_extend_get(cdperiphs, unit);
        if (periph == NULL) {
                bp->b_error = ENXIO;
@@ -1483,7 +1486,7 @@ cdstrategy(struct buf *bp)
        /*
         * Place it in the queue of disk activities for this disk
         */
-       bufqdisksort(&softc->buf_queue, bp);
+       bioqdisksort(&softc->bio_queue, bio);
 
        crit_exit();
        
@@ -1503,14 +1506,14 @@ bad:
         * Correctly set the buf to indicate a completed xfer
         */
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
-       return;
+       biodone(bio);
 }
 
 static void
 cdstart(struct cam_periph *periph, union ccb *start_ccb)
 {
        struct cd_softc *softc;
+       struct bio *bio;
        struct buf *bp;
        struct ccb_scsiio *csio;
        struct scsi_read_capacity_data *rcap;
@@ -1523,7 +1526,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
        case CD_STATE_NORMAL:
        {
                crit_enter();
-               bp = bufq_first(&softc->buf_queue);
+               bio = bioq_first(&softc->bio_queue);
                if (periph->immediate_priority <= periph->pinfo.priority) {
                        start_ccb->ccb_h.ccb_state = CD_CCB_WAITING;
 
@@ -1532,11 +1535,12 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
                        periph->immediate_priority = CAM_PRIORITY_NONE;
                        crit_exit();
                        wakeup(&periph->ccb_list);
-               } else if (bp == NULL) {
+               } else if (bio == NULL) {
                        crit_exit();
                        xpt_release_ccb(start_ccb);
                } else {
-                       bufq_remove(&softc->buf_queue, bp);
+                       bp = bio->bio_buf;
+                       bioq_remove(&softc->bio_queue, bio);
 
                        devstat_start_transaction(&softc->device_stats);
 
@@ -1549,7 +1553,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
                                        /* read */bp->b_flags & B_READ,
                                        /* byte2 */ 0,
                                        /* minimum_cmd_size */ 10,
-                                       /* lba */ bp->b_pblkno,
+                                       /* lba */ bio->bio_blkno,
                                        bp->b_bcount / softc->params.blksize,
                                        /* data_ptr */ bp->b_data,
                                        /* dxfer_len */ bp->b_bcount,
@@ -1571,13 +1575,13 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
                                softc->flags &= ~CD_FLAG_RETRY_UA;
                        }
 
-                       start_ccb->ccb_h.ccb_bp = bp;
-                       bp = bufq_first(&softc->buf_queue);
+                       start_ccb->ccb_h.ccb_bio = bio;
+                       bio = bioq_first(&softc->bio_queue);
                        crit_exit();
 
                        xpt_action(start_ccb);
                }
-               if (bp != NULL) {
+               if (bio != NULL) {
                        /* Have more work to do, so ensure we stay scheduled */
                        xpt_schedule(periph, /* XXX priority */1);
                }
@@ -1595,7 +1599,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
                                   rcap,
                                   SSD_FULL_SIZE,
                                   /*timeout*/20000);
-               start_ccb->ccb_h.ccb_bp = NULL;
+               start_ccb->ccb_h.ccb_bio = NULL;
                start_ccb->ccb_h.ccb_state = CD_CCB_PROBE;
                xpt_action(start_ccb);
                break;
@@ -1618,9 +1622,11 @@ cddone(struct cam_periph *periph, union ccb *done_ccb)
        case CD_CCB_BUFFER_IO:
        {
                struct buf      *bp;
+               struct bio      *bio;
                int             error;
 
-               bp = (struct buf *)done_ccb->ccb_h.ccb_bp;
+               bio = (struct bio *)done_ccb->ccb_h.ccb_bio;
+               bp = bio->bio_buf;
                error = 0;
 
                if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
@@ -1644,17 +1650,19 @@ cddone(struct cam_periph *periph, union ccb *done_ccb)
                }
 
                if (error != 0) {
+                       struct bio *q_bio;
                        struct buf *q_bp;
 
                        xpt_print_path(periph->path);
                        printf("cddone: got error %#x back\n", error);
                        crit_enter();
-                       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL) {
-                               bufq_remove(&softc->buf_queue, q_bp);
+                       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL) {
+                               bioq_remove(&softc->bio_queue, q_bio);
+                               q_bp = q_bio->bio_buf;
                                q_bp->b_resid = q_bp->b_bcount;
                                q_bp->b_error = EIO;
                                q_bp->b_flags |= B_ERROR;
-                               biodone(q_bp);
+                               biodone(q_bio);
                        }
                        crit_exit();
                        bp->b_resid = bp->b_bcount;
@@ -1687,7 +1695,7 @@ cddone(struct cam_periph *periph, union ccb *done_ccb)
                        cdchangerschedule(softc);
 
                devstat_end_transaction_buf(&softc->device_stats, bp);
-               biodone(bp);
+               biodone(bio);
                break;
        }
        case CD_CCB_PROBE:
index 36cce36..e72ad5e 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_ch.c,v 1.20.2.2 2000/10/31 08:09:49 dwmalone Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_ch.c,v 1.12 2006/01/22 14:03:51 swildner Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_ch.c,v 1.13 2006/02/17 19:17:42 dillon Exp $
  */
 /*
  * Derived from the NetBSD SCSI changer driver.
@@ -131,7 +131,7 @@ typedef enum {
 } ch_quirks;
 
 #define ccb_state      ppriv_field0
-#define ccb_bp         ppriv_ptr1
+#define ccb_bio                ppriv_ptr1
 
 struct scsi_mode_sense_data {
        struct scsi_mode_header_6 header;
@@ -549,7 +549,7 @@ chstart(struct cam_periph *periph, union ccb *start_ccb)
                                /* sense_len */ SSD_FULL_SIZE,
                                /* timeout */ CH_TIMEOUT_MODE_SENSE);
 
-               start_ccb->ccb_h.ccb_bp = NULL;
+               start_ccb->ccb_h.ccb_bio = NULL;
                start_ccb->ccb_h.ccb_state = CH_CCB_PROBE;
                xpt_action(start_ccb);
                break;
index 45bfe72..a6890f5 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_da.c,v 1.42.2.46 2003/10/21 22:18:19 thomas Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_da.c,v 1.26 2006/01/22 14:03:51 swildner Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_da.c,v 1.27 2006/02/17 19:17:42 dillon Exp $
  */
 
 #ifdef _KERNEL
@@ -119,7 +119,7 @@ typedef enum {
 
 /* Offsets into our private area for storing information */
 #define ccb_state      ppriv_field0
-#define ccb_bp         ppriv_ptr1
+#define ccb_bio                ppriv_ptr1
 
 struct disk_params {
        u_int8_t  heads;
@@ -130,7 +130,7 @@ struct disk_params {
 };
 
 struct da_softc {
-       struct   buf_queue_head buf_queue;
+       struct   bio_queue_head bio_queue;
        struct   devstat device_stats;
        SLIST_ENTRY(da_softc) links;
        LIST_HEAD(, ccb_hdr) pending_ccbs;
@@ -573,7 +573,7 @@ daopen(dev_t dev, int flags, int fmt, struct thread *td)
                                   rcap,
                                   SSD_FULL_SIZE,
                                   /*timeout*/60000);
-               ccb->ccb_h.ccb_bp = NULL;
+               ccb->ccb_h.ccb_bio = NULL;
 
                error = cam_periph_runccb(ccb, daerror, /*cam_flags*/0,
                                          /*sense_flags*/SF_RETRY_UA |
@@ -736,15 +736,16 @@ daclose(dev_t dev, int flag, int fmt, struct thread *td)
  * only one physical transfer.
  */
 static void
-dastrategy(struct buf *bp)
+dastrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct cam_periph *periph;
        struct da_softc *softc;
        u_int  unit;
        u_int  part;
        
-       unit = dkunit(bp->b_dev);
-       part = dkpart(bp->b_dev);
+       unit = dkunit(dev);
+       part = dkpart(dev);
        periph = cam_extend_get(daperiphs, unit);
        if (periph == NULL) {
                bp->b_error = ENXIO;
@@ -755,7 +756,7 @@ dastrategy(struct buf *bp)
        /*
         * check it's not too big a transfer for our adapter
         */
-       scsi_minphys(bp,&sd_switch);
+       scsi_minphys(bp, &sd_switch);
 #endif
 
        /*
@@ -777,7 +778,7 @@ dastrategy(struct buf *bp)
        /*
         * Place it in the queue of disk activities for this disk
         */
-       bufqdisksort(&softc->buf_queue, bp);
+       bioqdisksort(&softc->bio_queue, bio);
 
        crit_exit();
        
@@ -794,8 +795,7 @@ bad:
         * Correctly set the buf to indicate a completed xfer
         */
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
-       return;
+       biodone(bio);
 }
 
 /* For 2.2-stable support */
@@ -1013,6 +1013,7 @@ static void
 daoninvalidate(struct cam_periph *periph)
 {
        struct da_softc *softc;
+       struct bio *q_bio;
        struct buf *q_bp;
        struct ccb_setasync csa;
 
@@ -1042,12 +1043,13 @@ daoninvalidate(struct cam_periph *periph)
         * XXX Handle any transactions queued to the card
         *     with XPT_ABORT_CCB.
         */
-       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL){
-               bufq_remove(&softc->buf_queue, q_bp);
+       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL){
+               bioq_remove(&softc->bio_queue, q_bio);
+               q_bp = q_bio->bio_buf;
                q_bp->b_resid = q_bp->b_bcount;
                q_bp->b_error = ENXIO;
                q_bp->b_flags |= B_ERROR;
-               biodone(q_bp);
+               biodone(q_bio);
        }
        crit_exit();
 
@@ -1233,7 +1235,7 @@ daregister(struct cam_periph *periph, void *arg)
        softc = malloc(sizeof(*softc), M_DEVBUF, M_INTWAIT | M_ZERO);
        LIST_INIT(&softc->pending_ccbs);
        softc->state = DA_STATE_PROBE;
-       bufq_init(&softc->buf_queue);
+       bioq_init(&softc->bio_queue);
        if (SID_IS_REMOVABLE(&cgd->inq_data))
                softc->flags |= DA_FLAG_PACK_REMOVABLE;
        if ((cgd->inq_data.flags & SID_CmdQue) != 0)
@@ -1354,13 +1356,14 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
        case DA_STATE_NORMAL:
        {
                /* Pull a buffer from the queue and get going on it */          
+               struct bio *bio;
                struct buf *bp;
 
                /*
                 * See if there is a buf with work for us to do..
                 */
                crit_enter();
-               bp = bufq_first(&softc->buf_queue);
+               bio = bioq_first(&softc->bio_queue);
                if (periph->immediate_priority <= periph->pinfo.priority) {
                        CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
                                        ("queuing for immediate ccb\n"));
@@ -1370,13 +1373,14 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
                        periph->immediate_priority = CAM_PRIORITY_NONE;
                        crit_exit();
                        wakeup(&periph->ccb_list);
-               } else if (bp == NULL) {
+               } else if (bio == NULL) {
                        crit_exit();
                        xpt_release_ccb(start_ccb);
                } else {
                        u_int8_t tag_code;
 
-                       bufq_remove(&softc->buf_queue, bp);
+                       bioq_remove(&softc->bio_queue, bio);
+                       bp = bio->bio_buf;
 
                        devstat_start_transaction(&softc->device_stats);
 
@@ -1395,7 +1399,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
                                        bp->b_flags & B_READ,
                                        /*byte2*/0,
                                        softc->minimum_cmd_size,
-                                       bp->b_pblkno,
+                                       bio->bio_blkno,
                                        bp->b_bcount / softc->params.secsize,
                                        bp->b_data,
                                        bp->b_bcount,
@@ -1416,14 +1420,14 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
                                softc->flags &= ~DA_FLAG_RETRY_UA;
                        }
 
-                       start_ccb->ccb_h.ccb_bp = bp;
-                       bp = bufq_first(&softc->buf_queue);
+                       start_ccb->ccb_h.ccb_bio = bio;
+                       bio = bioq_first(&softc->bio_queue);
                        crit_exit();
 
                        xpt_action(start_ccb);
                }
                
-               if (bp != NULL) {
+               if (bio != NULL) {
                        /* Have more work to do, so ensure we stay scheduled */
                        xpt_schedule(periph, /* XXX priority */1);
                }
@@ -1443,7 +1447,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
                                   rcap,
                                   SSD_FULL_SIZE,
                                   /*timeout*/5000);
-               start_ccb->ccb_h.ccb_bp = NULL;
+               start_ccb->ccb_h.ccb_bio = NULL;
                start_ccb->ccb_h.ccb_state = DA_CCB_PROBE;
                xpt_action(start_ccb);
                break;
@@ -1509,8 +1513,10 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
        case DA_CCB_BUFFER_IO:
        {
                struct buf *bp;
+               struct bio *bio;
 
-               bp = (struct buf *)done_ccb->ccb_h.ccb_bp;
+               bio = (struct bio *)done_ccb->ccb_h.ccb_bio;
+               bp = bio->bio_buf;
                if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
                        int error;
                        int sf;
@@ -1531,6 +1537,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
                                return;
                        }
                        if (error != 0) {
+                               struct bio *q_bio;
                                struct buf *q_bp;
 
                                crit_enter();
@@ -1553,13 +1560,14 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
                                 * the client can retry these I/Os in the
                                 * proper order should it attempt to recover.
                                 */
-                               while ((q_bp = bufq_first(&softc->buf_queue))
+                               while ((q_bio = bioq_first(&softc->bio_queue))
                                        != NULL) {
-                                       bufq_remove(&softc->buf_queue, q_bp);
+                                       bioq_remove(&softc->bio_queue, q_bio);
+                                       q_bp = q_bio->bio_buf;
                                        q_bp->b_resid = q_bp->b_bcount;
                                        q_bp->b_error = EIO;
                                        q_bp->b_flags |= B_ERROR;
-                                       biodone(q_bp);
+                                       biodone(q_bio);
                                }
                                crit_exit();
                                bp->b_error = error;
@@ -1595,7 +1603,7 @@ dadone(struct cam_periph *periph, union ccb *done_ccb)
                        softc->flags |= DA_FLAG_WENT_IDLE;
 
                devstat_end_transaction_buf(&softc->device_stats, bp);
-               biodone(bp);
+               biodone(bio);
                break;
        }
        case DA_CCB_PROBE:
index 1e73fc2..8be0a79 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_pass.c,v 1.19 2000/01/17 06:27:37 mjacob Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_pass.c,v 1.13 2005/06/02 20:40:31 dillon Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_pass.c,v 1.14 2006/02/17 19:17:42 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -73,13 +73,13 @@ typedef enum {
 } pass_ccb_types;
 
 #define ccb_type       ppriv_field0
-#define ccb_bp         ppriv_ptr1
+#define ccb_bio                ppriv_ptr1
 
 struct pass_softc {
        pass_state      state;
        pass_flags      flags;
        u_int8_t        pd_type;
-       struct          buf_queue_head buf_queue;
+       struct          bio_queue_head bio_queue;
        union ccb       saved_ccb;
        struct devstat  device_stats;
 };
@@ -181,6 +181,7 @@ passoninvalidate(struct cam_periph *periph)
 {
        struct pass_softc *softc;
        struct buf *q_bp;
+       struct bio *q_bio;
        struct ccb_setasync csa;
 
        softc = (struct pass_softc *)periph->softc;
@@ -209,12 +210,13 @@ passoninvalidate(struct cam_periph *periph)
         * XXX Handle any transactions queued to the card
         *     with XPT_ABORT_CCB.
         */
-       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL){
-               bufq_remove(&softc->buf_queue, q_bp);
+       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL){
+               bioq_remove(&softc->bio_queue, q_bio);
+               q_bp = q_bio->bio_buf;
                q_bp->b_resid = q_bp->b_bcount;
                q_bp->b_error = ENXIO;
                q_bp->b_flags |= B_ERROR;
-               biodone(q_bp);
+               biodone(q_bio);
        }
        crit_exit();
 
@@ -304,7 +306,7 @@ passregister(struct cam_periph *periph, void *arg)
        softc = malloc(sizeof(*softc), M_DEVBUF, M_INTWAIT | M_ZERO);
        softc->state = PASS_STATE_NORMAL;
        softc->pd_type = SID_TYPE(&cgd->inq_data);
-       bufq_init(&softc->buf_queue);
+       bioq_init(&softc->bio_queue);
 
        periph->softc = softc;
 
@@ -448,8 +450,9 @@ passclose(dev_t dev, int flag, int fmt, struct thread *td)
  * only one physical transfer.
  */
 static void
-passstrategy(struct buf *bp)
+passstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct cam_periph *periph;
        struct pass_softc *softc;
        u_int  unit;
@@ -462,9 +465,9 @@ passstrategy(struct buf *bp)
        bp->b_error = EINVAL;
        goto bad;
 
-       /* unit = dkunit(bp->b_dev); */
+       /* unit = dkunit(dev); */
        /* XXX KDM fix this */
-       unit = minor(bp->b_dev) & 0xff;
+       unit = minor(dev) & 0xff;
 
        periph = cam_extend_get(passperiphs, unit);
        if (periph == NULL) {
@@ -477,7 +480,7 @@ passstrategy(struct buf *bp)
         * Odd number of bytes or negative offset
         */
        /* valid request?  */
-       if (bp->b_blkno < 0) {
+       if (bio->bio_blkno < 0) {
                bp->b_error = EINVAL;
                goto bad;
         }
@@ -488,7 +491,7 @@ passstrategy(struct buf *bp)
         * clean up one of the buffers.
         */
        crit_enter();
-       bufq_insert_tail(&softc->buf_queue, bp);
+       bioq_insert_tail(&softc->bio_queue, bio);
        crit_exit();
        
        /*
@@ -504,8 +507,7 @@ bad:
         * Correctly set the buf to indicate a completed xfer
         */
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
-       return;
+       biodone(bio);
 }
 
 static void
@@ -519,9 +521,10 @@ passstart(struct cam_periph *periph, union ccb *start_ccb)
        case PASS_STATE_NORMAL:
        {
                struct buf *bp;
+               struct bio *bio;
 
                crit_enter();
-               bp = bufq_first(&softc->buf_queue);
+               bio = bioq_first(&softc->bio_queue);
                if (periph->immediate_priority <= periph->pinfo.priority) {
                        start_ccb->ccb_h.ccb_type = PASS_CCB_WAITING;                   
                        SLIST_INSERT_HEAD(&periph->ccb_list, &start_ccb->ccb_h,
@@ -529,12 +532,13 @@ passstart(struct cam_periph *periph, union ccb *start_ccb)
                        periph->immediate_priority = CAM_PRIORITY_NONE;
                        crit_exit();
                        wakeup(&periph->ccb_list);
-               } else if (bp == NULL) {
+               } else if (bio == NULL) {
                        crit_exit();
                        xpt_release_ccb(start_ccb);
                } else {
 
-                       bufq_remove(&softc->buf_queue, bp);
+                       bioq_remove(&softc->bio_queue, bio);
+                       bp = bio->bio_buf;
 
                        devstat_start_transaction(&softc->device_stats);
 
@@ -549,14 +553,14 @@ passstart(struct cam_periph *periph, union ccb *start_ccb)
                        bp->b_error = EIO;
                        bp->b_flags |= B_ERROR;
                        bp->b_resid = bp->b_bcount;
-                       biodone(bp);
-                       bp = bufq_first(&softc->buf_queue);
+                       biodone(bio);
+                       bio = bioq_first(&softc->bio_queue);
                        crit_exit();
   
                        xpt_action(start_ccb);
 
                }
-               if (bp != NULL) {
+               if (bio != NULL) {
                        /* Have more work to do, so ensure we stay scheduled */
                        xpt_schedule(periph, /* XXX priority */1);
                }
@@ -575,6 +579,7 @@ passdone(struct cam_periph *periph, union ccb *done_ccb)
        switch (csio->ccb_h.ccb_type) {
        case PASS_CCB_BUFFER_IO:
        {
+               struct bio              *bio;
                struct buf              *bp;
                cam_status              status;
                u_int8_t                scsi_status;
@@ -582,7 +587,9 @@ passdone(struct cam_periph *periph, union ccb *done_ccb)
 
                status = done_ccb->ccb_h.status;
                scsi_status = done_ccb->csio.scsi_status;
-               bp = (struct buf *)done_ccb->ccb_h.ccb_bp;
+               bio = (struct bio *)done_ccb->ccb_h.ccb_bio;
+               bp = bio->bio_buf;
+
                /* XXX handle errors */
                if (!(((status & CAM_STATUS_MASK) == CAM_REQ_CMP)
                  && (scsi_status == SCSI_STATUS_OK))) {
@@ -612,7 +619,7 @@ passdone(struct cam_periph *periph, union ccb *done_ccb)
                        ds_flags = DEVSTAT_NO_DATA;
 
                devstat_end_transaction_buf(&softc->device_stats, bp);
-               biodone(bp);
+               biodone(bio);
                break;
        }
        case PASS_CCB_WAITING:
index f7ec350..0c8c472 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/cam/scsi/scsi_pt.c,v 1.17 2000/01/17 06:27:37 mjacob Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_pt.c,v 1.12 2005/06/02 20:40:31 dillon Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_pt.c,v 1.13 2006/02/17 19:17:42 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -76,10 +76,10 @@ typedef enum {
 
 /* Offsets into our private area for storing information */
 #define ccb_state      ppriv_field0
-#define ccb_bp         ppriv_ptr1
+#define ccb_bio                ppriv_ptr1
 
 struct pt_softc {
-       struct   buf_queue_head buf_queue;
+       struct   bio_queue_head bio_queue;
        struct   devstat device_stats;
        LIST_HEAD(, ccb_hdr) pending_ccbs;
        pt_state state;
@@ -219,13 +219,14 @@ ptclose(dev_t dev, int flag, int fmt, struct thread *td)
  * only one physical transfer.
  */
 static void
-ptstrategy(struct buf *bp)
+ptstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct cam_periph *periph;
        struct pt_softc *softc;
        u_int  unit;
        
-       unit = minor(bp->b_dev);
+       unit = minor(dev);
        periph = cam_extend_get(ptperiphs, unit);
        if (periph == NULL) {
                bp->b_error = ENXIO;
@@ -252,7 +253,7 @@ ptstrategy(struct buf *bp)
        /*
         * Place it in the queue of disk activities for this disk
         */
-       bufq_insert_tail(&softc->buf_queue, bp);
+       bioq_insert_tail(&softc->bio_queue, bio);
 
        crit_exit();
        
@@ -269,7 +270,7 @@ bad:
         * Correctly set the buf to indicate a completed xfer
         */
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
+       biodone(bio);
 }
 
 static void
@@ -334,7 +335,7 @@ ptctor(struct cam_periph *periph, void *arg)
        softc = malloc(sizeof(*softc), M_DEVBUF, M_INTWAIT | M_ZERO);
        LIST_INIT(&softc->pending_ccbs);
        softc->state = PT_STATE_NORMAL;
-       bufq_init(&softc->buf_queue);
+       bioq_init(&softc->bio_queue);
 
        softc->io_timeout = SCSI_PT_DEFAULT_TIMEOUT * 1000;
 
@@ -377,6 +378,7 @@ static void
 ptoninvalidate(struct cam_periph *periph)
 {
        struct pt_softc *softc;
+       struct bio *q_bio;
        struct buf *q_bp;
        struct ccb_setasync csa;
 
@@ -406,12 +408,13 @@ ptoninvalidate(struct cam_periph *periph)
         * XXX Handle any transactions queued to the card
         *     with XPT_ABORT_CCB.
         */
-       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL){
-               bufq_remove(&softc->buf_queue, q_bp);
+       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL){
+               bioq_remove(&softc->bio_queue, q_bio);
+               q_bp = q_bio->bio_buf;
                q_bp->b_resid = q_bp->b_bcount;
                q_bp->b_error = ENXIO;
                q_bp->b_flags |= B_ERROR;
-               biodone(q_bp);
+               biodone(q_bio);
        }
 
        crit_exit();
@@ -499,6 +502,7 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb)
 {
        struct pt_softc *softc;
        struct buf *bp;
+       struct bio *bio;
 
        softc = (struct pt_softc *)periph->softc;
 
@@ -506,7 +510,7 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb)
         * See if there is a buf with work for us to do..
         */
        crit_enter();
-       bp = bufq_first(&softc->buf_queue);
+       bio = bioq_first(&softc->bio_queue);
        if (periph->immediate_priority <= periph->pinfo.priority) {
                CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
                                ("queuing for immediate ccb\n"));
@@ -516,11 +520,12 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb)
                periph->immediate_priority = CAM_PRIORITY_NONE;
                crit_exit();
                wakeup(&periph->ccb_list);
-       } else if (bp == NULL) {
+       } else if (bio == NULL) {
                crit_exit();
                xpt_release_ccb(start_ccb);
        } else {
-               bufq_remove(&softc->buf_queue, bp);
+               bioq_remove(&softc->bio_queue, bio);
+               bp = bio->bio_buf;
 
                devstat_start_transaction(&softc->device_stats);
 
@@ -544,13 +549,13 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb)
                LIST_INSERT_HEAD(&softc->pending_ccbs, &start_ccb->ccb_h,
                                 periph_links.le);
 
-               start_ccb->ccb_h.ccb_bp = bp;
-               bp = bufq_first(&softc->buf_queue);
+               start_ccb->ccb_h.ccb_bio = bio;
+               bio = bioq_first(&softc->bio_queue);
                crit_exit();
 
                xpt_action(start_ccb);
                
-               if (bp != NULL) {
+               if (bio != NULL) {
                        /* Have more work to do, so ensure we stay scheduled */
                        xpt_schedule(periph, /* XXX priority */1);
                }
@@ -570,8 +575,11 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb)
        case PT_CCB_BUFFER_IO_UA:
        {
                struct buf *bp;
+               struct bio *bio;
+
+               bio = (struct bio *)done_ccb->ccb_h.ccb_bio;
+               bp = bio->bio_buf;
 
-               bp = (struct buf *)done_ccb->ccb_h.ccb_bp;
                if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
                        int error;
                        int sf;
@@ -592,6 +600,7 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb)
                        }
                        if (error != 0) {
                                struct buf *q_bp;
+                               struct bio *q_bio;
 
                                crit_enter();
 
@@ -610,13 +619,14 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb)
                                 * the client can retry these I/Os in the
                                 * proper order should it attempt to recover.
                                 */
-                               while ((q_bp = bufq_first(&softc->buf_queue))
+                               while ((q_bio = bioq_first(&softc->bio_queue))
                                        != NULL) {
-                                       bufq_remove(&softc->buf_queue, q_bp);
+                                       bioq_remove(&softc->bio_queue, q_bio);
+                                       q_bp = q_bio->bio_buf;
                                        q_bp->b_resid = q_bp->b_bcount;
                                        q_bp->b_error = EIO;
                                        q_bp->b_flags |= B_ERROR;
-                                       biodone(q_bp);
+                                       biodone(q_bio);
                                }
                                crit_exit();
                                bp->b_error = error;
@@ -651,7 +661,7 @@ ptdone(struct cam_periph *periph, union ccb *done_ccb)
                crit_exit();
 
                devstat_end_transaction_buf(&softc->device_stats, bp);
-               biodone(bp);
+               biodone(bio);
                break;
        }
        case PT_CCB_WAITING:
index 97a75e7..cc4a328 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * $FreeBSD: src/sys/cam/scsi/scsi_sa.c,v 1.45.2.13 2002/12/17 17:08:50 trhodes Exp $
- * $DragonFly: src/sys/bus/cam/scsi/scsi_sa.c,v 1.14 2006/01/22 14:03:51 swildner Exp $
+ * $DragonFly: src/sys/bus/cam/scsi/scsi_sa.c,v 1.15 2006/02/17 19:17:42 dillon Exp $
  *
  * Implementation of SCSI Sequential Access Peripheral driver for CAM.
  *
@@ -113,7 +113,7 @@ typedef enum {
 } sa_state;
 
 #define ccb_pflags     ppriv_field0
-#define ccb_bp         ppriv_ptr1
+#define ccb_bio                ppriv_ptr1
 
 #define        SA_CCB_BUFFER_IO        0x0
 #define        SA_CCB_WAITING          0x1
@@ -205,7 +205,7 @@ struct sa_softc {
        sa_state        state;
        sa_flags        flags;
        sa_quirks       quirks;
-       struct          buf_queue_head buf_queue;
+       struct          bio_queue_head bio_queue;
        int             queue_count;
        struct          devstat device_stats;
        int             blk_gran;
@@ -661,17 +661,18 @@ saclose(dev_t dev, int flag, int fmt, struct thread *td)
  * only one physical transfer.
  */
 static void
-sastrategy(struct buf *bp)
+sastrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct cam_periph *periph;
        struct sa_softc *softc;
        u_int  unit;
        
-       if (SA_IS_CTRL(bp->b_dev)) {
+       if (SA_IS_CTRL(dev)) {
                bp->b_error = EINVAL;
                goto bad;
        }
-       unit = SAUNIT(bp->b_dev);
+       unit = SAUNIT(dev);
        periph = cam_extend_get(saperiphs, unit);
        if (periph == NULL) {
                bp->b_error = ENXIO;
@@ -744,7 +745,7 @@ sastrategy(struct buf *bp)
        /*
         * Place it at the end of the queue.
         */
-       bufq_insert_tail(&softc->buf_queue, bp);
+       bioq_insert_tail(&softc->bio_queue, bio);
 
        softc->queue_count++;
        CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastrategy: enqueuing a %d "
@@ -768,7 +769,7 @@ done:
         * Correctly set the buf to indicate a completed xfer
         */
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
+       biodone(bio);
 }
 
 static int
@@ -1307,6 +1308,7 @@ saoninvalidate(struct cam_periph *periph)
 {
        struct sa_softc *softc;
        struct buf *q_bp;
+       struct bio *q_bio;
        struct ccb_setasync csa;
 
        softc = (struct sa_softc *)periph->softc;
@@ -1335,12 +1337,13 @@ saoninvalidate(struct cam_periph *periph)
         * XXX Handle any transactions queued to the card
         *     with XPT_ABORT_CCB.
         */
-       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL){
-               bufq_remove(&softc->buf_queue, q_bp);
+       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL){
+               bioq_remove(&softc->bio_queue, q_bio);
+               q_bp = q_bio->bio_buf;
                q_bp->b_resid = q_bp->b_bcount;
                q_bp->b_error = ENXIO;
                q_bp->b_flags |= B_ERROR;
-               biodone(q_bp);
+               biodone(q_bio);
        }
        softc->queue_count = 0;
        crit_exit();
@@ -1434,7 +1437,7 @@ saregister(struct cam_periph *periph, void *arg)
        softc->fileno = (daddr_t) -1;
        softc->blkno = (daddr_t) -1;
 
-       bufq_init(&softc->buf_queue);
+       bioq_init(&softc->bio_queue);
        periph->softc = softc;
        cam_extend_set(saperiphs, periph->unit_number, periph);
 
@@ -1534,12 +1537,13 @@ sastart(struct cam_periph *periph, union ccb *start_ccb)
        {
                /* Pull a buffer from the queue and get going on it */          
                struct buf *bp;
+               struct bio *bio;
 
                /*
                 * See if there is a buf with work for us to do..
                 */
                crit_enter();
-               bp = bufq_first(&softc->buf_queue);
+               bio = bioq_first(&softc->bio_queue);
                if (periph->immediate_priority <= periph->pinfo.priority) {
                        CAM_DEBUG_PRINT(CAM_DEBUG_SUBTRACE,
                                        ("queuing for immediate ccb\n"));
@@ -1549,16 +1553,17 @@ sastart(struct cam_periph *periph, union ccb *start_ccb)
                        periph->immediate_priority = CAM_PRIORITY_NONE;
                        crit_exit();
                        wakeup(&periph->ccb_list);
-               } else if (bp == NULL) {
+               } else if (bio == NULL) {
                        crit_exit();
                        xpt_release_ccb(start_ccb);
                } else if ((softc->flags & SA_FLAG_ERR_PENDING) != 0) {
-                       struct buf *done_bp;
+                       struct bio *done_bio;
 again:
                        softc->queue_count--;
-                       bufq_remove(&softc->buf_queue, bp);
+                       bioq_remove(&softc->bio_queue, bio);
+                       bp = bio->bio_buf;
                        bp->b_resid = bp->b_bcount;
-                       done_bp = bp;
+                       done_bio = bio;
                        if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) {
                                /*
                                 * We now just clear errors in this case
@@ -1573,33 +1578,34 @@ again:
                                 * same way.
                                 */
                                bp->b_error = 0;
-                               if (bufq_first(&softc->buf_queue) != NULL) {
-                                       biodone(done_bp);
+                               if (bioq_first(&softc->bio_queue) != NULL) {
+                                       biodone(done_bio);
                                        goto again;
                                }
                        } else if ((softc->flags & SA_FLAG_EIO_PENDING) != 0) {
                                bp->b_error = EIO;
                                bp->b_flags |= B_ERROR;
                        }
-                       bp = bufq_first(&softc->buf_queue);
+                       bio = bioq_first(&softc->bio_queue);
                        /*
                         * Only if we have no other buffers queued up
                         * do we clear the pending error flag.
                         */
-                       if (bp == NULL)
+                       if (bio == NULL)
                                softc->flags &= ~SA_FLAG_ERR_PENDING;
                        CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
-                           ("sastart- ERR_PENDING now 0x%x, bp is %sNULL, "
+                           ("sastart- ERR_PENDING now 0x%x, bio is %sNULL, "
                            "%d more buffers queued up\n",
                            (softc->flags & SA_FLAG_ERR_PENDING),
-                           (bp != NULL)? "not " : " ", softc->queue_count));
+                           (bio != NULL)? "not " : " ", softc->queue_count));
                        crit_exit();
                        xpt_release_ccb(start_ccb);
-                       biodone(done_bp);
+                       biodone(done_bio);
                } else {
                        u_int32_t length;
 
-                       bufq_remove(&softc->buf_queue, bp);
+                       bioq_remove(&softc->bio_queue, bio);
+                       bp = bio->bio_buf;
                        softc->queue_count--;
 
                        if ((softc->flags & SA_FLAG_FIXED) != 0) {
@@ -1615,7 +1621,7 @@ again:
                                        printf("zero blocksize for "
                                            "FIXED length writes?\n");
                                        crit_exit();
-                                       biodone(bp);
+                                       biodone(bio);
                                        break;
                                }
                                CAM_DEBUG(periph->path, CAM_DEBUG_INFO,
@@ -1655,13 +1661,13 @@ again:
                            IO_TIMEOUT);
                        start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED;
                        Set_CCB_Type(start_ccb, SA_CCB_BUFFER_IO);
-                       start_ccb->ccb_h.ccb_bp = bp;
-                       bp = bufq_first(&softc->buf_queue);
+                       start_ccb->ccb_h.ccb_bio = bio;
+                       bio = bioq_first(&softc->bio_queue);
                        crit_exit();
                        xpt_action(start_ccb);
                }
                
-               if (bp != NULL) {
+               if (bio != NULL) {
                        /* Have more work to do, so ensure we stay scheduled */
                        xpt_schedule(periph, 1);
                }
@@ -1687,10 +1693,12 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
        case SA_CCB_BUFFER_IO:
        {
                struct buf *bp;
+               struct bio *bio;
                int error;
 
                softc->dsreg = MTIO_DSREG_REST;
-               bp = (struct buf *)done_ccb->ccb_h.ccb_bp;
+               bio = (struct bio *)done_ccb->ccb_h.ccb_bio;
+               bp = bio->bio_buf;
                error = 0;
                if ((done_ccb->ccb_h.status & CAM_STATUS_MASK) != CAM_REQ_CMP) {
                        if ((error = saerror(done_ccb, 0, 0)) == ERESTART) {
@@ -1703,6 +1711,7 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
 
                if (error == EIO) {
                        struct buf *q_bp;
+                       struct bio *q_bio;
 
                        /*
                         * Catastrophic error. Mark the tape as frozen
@@ -1717,12 +1726,13 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
 
                        crit_enter();
                        softc->flags |= SA_FLAG_TAPE_FROZEN;
-                       while ((q_bp = bufq_first(&softc->buf_queue)) != NULL) {
-                               bufq_remove(&softc->buf_queue, q_bp);
+                       while ((q_bio = bioq_first(&softc->bio_queue)) != NULL) {
+                               bioq_remove(&softc->bio_queue, q_bio);
+                               q_bp = q_bio->bio_buf;
                                q_bp->b_resid = q_bp->b_bcount;
                                q_bp->b_error = EIO;
                                q_bp->b_flags |= B_ERROR;
-                               biodone(q_bp);
+                               biodone(q_bio);
                        }
                        crit_exit();
                }
@@ -1774,7 +1784,7 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
                }
 #endif
                devstat_end_transaction_buf(&softc->device_stats, bp);
-               biodone(bp);
+               biodone(bio);
                break;
        }
        case SA_CCB_WAITING:
index c249bae..7fa821a 100644 (file)
@@ -1,5 +1,5 @@
 /* $FreeBSD: src/sys/cam/scsi/scsi_ses.c,v 1.8.2.2 2000/08/08 23:19:21 mjacob Exp $ */
-/* $DragonFly: src/sys/bus/cam/scsi/scsi_ses.c,v 1.13 2006/01/22 14:03:51 swildner Exp $ */
+/* $DragonFly: src/sys/bus/cam/scsi/scsi_ses.c,v 1.14 2006/02/17 19:17:42 dillon Exp $ */
 /*
  * Copyright (c) 2000 Matthew Jacob
  * All rights reserved.
@@ -139,7 +139,7 @@ static void ses_log(struct ses_softc *, const char *, ...);
 
 
 #define ccb_state      ppriv_field0
-#define ccb_bp         ppriv_ptr1
+#define ccb_bio                ppriv_ptr1
 
 struct ses_softc {
        enctyp          ses_type;       /* type of enclosure */
index 73f3a57..3d64bdc 100644 (file)
@@ -32,7 +32,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  * 
  * $FreeBSD: src/sys/dev/firewire/firewirereg.h,v 1.33 2004/01/06 14:30:46 simokawa Exp $
- * $DragonFly: src/sys/bus/firewire/firewirereg.h,v 1.8 2005/06/02 20:40:33 dillon Exp $
+ * $DragonFly: src/sys/bus/firewire/firewirereg.h,v 1.9 2006/02/17 19:17:44 dillon Exp $
  *
  */
 
@@ -317,21 +317,7 @@ extern devclass_t firewire_devclass;
 #define CALLOUT_INIT(x) callout_init(x, 0 /* mpsafe */)
 #endif
 
-#if defined(__DragonFly__) || __FreeBSD_version < 500000
-/* compatibility shim for 4.X */
-#define bio buf
-#define bio_bcount b_bcount
-#define bio_cmd b_flags
-#define bio_count b_count
-#define bio_data b_data
-#define bio_dev b_dev
-#define bio_error b_error
-#define bio_flags b_flags
-#define bio_offset b_offset
-#define bio_resid b_resid
-#define BIO_ERROR B_ERROR
-#define BIO_READ B_READ
-#define BIO_WRITE B_WRITE
+#if defined(__DragonFly__)
 #define MIN(a,b) (((a)<(b))?(a):(b))
 #define MAX(a,b) (((a)>(b))?(a):(b))
 #endif
index 4055688..93290e3 100644 (file)
@@ -32,7 +32,7 @@
  * POSSIBILITY OF SUCH DAMAGE.
  * 
  * $FreeBSD: src/sys/dev/firewire/fwdev.c,v 1.36 2004/01/22 14:41:17 simokawa Exp $
- * $DragonFly: src/sys/bus/firewire/fwdev.c,v 1.10 2005/06/02 20:40:33 dillon Exp $
+ * $DragonFly: src/sys/bus/firewire/fwdev.c,v 1.11 2006/02/17 19:17:44 dillon Exp $
  *
  */
 
@@ -771,20 +771,18 @@ fw_mmap (dev_t dev, vm_offset_t offset, vm_paddr_t *paddr, int nproto)
 }
 
 static void
-fw_strategy(struct bio *bp)
+fw_strategy(dev_t dev, struct bio *bio)
 {
-       dev_t dev;
+       struct buf *bp = bio->bio_buf;
 
-       dev = bp->bio_dev;
        if (DEV_FWMEM(dev)) {
-               fwmem_strategy(bp);
+               fwmem_strategy(dev, bio);
                return;
        }
-
-       bp->bio_error = EOPNOTSUPP;
-       bp->bio_flags |= BIO_ERROR;
-       bp->bio_resid = bp->bio_bcount;
-       biodone(bp);
+       bp->b_error = EOPNOTSUPP;
+       bp->b_flags |= B_ERROR;
+       bp->b_resid = bp->b_bcount;
+       biodone(bio);
 }
 
 int
index 331c91d..3d632d0 100644 (file)
@@ -31,7 +31,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  * 
- * $DragonFly: src/sys/bus/firewire/fwmem.c,v 1.7 2005/06/02 20:40:33 dillon Exp $
+ * $DragonFly: src/sys/bus/firewire/fwmem.c,v 1.8 2006/02/17 19:17:44 dillon Exp $
  */
 
 #ifndef __DragonFly__
@@ -322,33 +322,33 @@ fwmem_close (dev_t dev, int flags, int fmt, fw_proc *td)
 static void
 fwmem_biodone(struct fw_xfer *xfer)
 {
-       struct bio *bp;
+       struct bio *bio;
+       struct buf *bp;
 
-       bp = (struct bio *)xfer->sc;
-       bp->bio_error = xfer->resp;
+       bio = (struct bio *)xfer->sc;
+       bp = bio->bio_buf;
+       bp->b_error = xfer->resp;
 
-       if (bp->bio_error != 0) {
+       if (bp->b_error != 0) {
                if (fwmem_debug)
-                       printf("%s: err=%d\n", __func__, bp->bio_error);
-               bp->bio_flags |= BIO_ERROR;
-               bp->bio_resid = bp->bio_bcount;
+                       printf("%s: err=%d\n", __func__, bp->b_error);
+               bp->b_flags |= B_ERROR;
+               bp->b_resid = bp->b_bcount;
        }
-
        fw_xfer_free(xfer);
-       biodone(bp);
+       biodone(bio);
 }
 
 void
-fwmem_strategy(struct bio *bp)
+fwmem_strategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct firewire_softc *sc;
        struct fwmem_softc *fms;
        struct fw_device *fwdev;
        struct fw_xfer *xfer;
-       dev_t dev;
        int unit, err=0, iolen;
 
-       dev = bp->bio_dev;
        /* XXX check request length */
 
         unit = DEV2UNIT(dev);
@@ -364,46 +364,51 @@ fwmem_strategy(struct bio *bp)
                err = EINVAL;
                goto error;
        }
+       if (bio->bio_offset == NOOFFSET) {
+               printf("fwmem: offset was not set bp %p\n", bp);
+               err = EINVAL;
+               goto error;
+       }
 
-       iolen = MIN(bp->bio_bcount, MAXLEN);
-       if ((bp->bio_cmd & BIO_READ) == BIO_READ) {
-               if (iolen == 4 && (bp->bio_offset & 3) == 0)
+       iolen = MIN(bp->b_bcount, MAXLEN);
+       if (bp->b_flags & B_READ) {
+               if (iolen == 4 && (bio->bio_offset & 3) == 0)
                        xfer = fwmem_read_quad(fwdev,
-                           (void *) bp, fwmem_speed,
-                           bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
-                           bp->bio_data, fwmem_biodone);
+                           (void *) bio, fwmem_speed,
+                           bio->bio_offset >> 32, bio->bio_offset & 0xffffffff,
+                           bp->b_data, fwmem_biodone);
                else
                        xfer = fwmem_read_block(fwdev,
-                           (void *) bp, fwmem_speed,
-                           bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
-                           iolen, bp->bio_data, fwmem_biodone);
+                           (void *) bio, fwmem_speed,
+                           bio->bio_offset >> 32, bio->bio_offset & 0xffffffff,
+                           iolen, bp->b_data, fwmem_biodone);
        } else {
-               if (iolen == 4 && (bp->bio_offset & 3) == 0)
+               if (iolen == 4 && (bio->bio_offset & 3) == 0)
                        xfer = fwmem_write_quad(fwdev,
-                           (void *)bp, fwmem_speed,
-                           bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
-                           bp->bio_data, fwmem_biodone);
+                           (void *)bio, fwmem_speed,
+                           bio->bio_offset >> 32, bio->bio_offset & 0xffffffff,
+                           bp->b_data, fwmem_biodone);
                else
                        xfer = fwmem_write_block(fwdev,
-                           (void *)bp, fwmem_speed,
-                           bp->bio_offset >> 32, bp->bio_offset & 0xffffffff,
-                           iolen, bp->bio_data, fwmem_biodone);
+                           (void *)bio, fwmem_speed,
+                           bio->bio_offset >> 32, bio->bio_offset & 0xffffffff,
+                           iolen, bp->b_data, fwmem_biodone);
        }
        if (xfer == NULL) {
                err = EIO;
                goto error;
        }
        /* XXX */
-       bp->bio_resid = bp->bio_bcount - iolen;
+       bp->b_resid = bp->b_bcount - iolen;
 error:
        crit_exit();
        if (err != 0) {
                if (fwmem_debug)
                        printf("%s: err=%d\n", __func__, err);
-               bp->bio_error = err;
-               bp->bio_flags |= BIO_ERROR;
-               bp->bio_resid = bp->bio_bcount;
-               biodone(bp);
+               bp->b_error = err;
+               bp->b_flags |= B_ERROR;
+               bp->b_resid = bp->b_bcount;
+               biodone(bio);
        }
 }
 
index fe488a3..2a59d8d 100644 (file)
@@ -7,7 +7,7 @@
  * ----------------------------------------------------------------------------
  *
  * $FreeBSD: src/sys/contrib/dev/fla/fla.c,v 1.16 1999/12/08 04:45:16 ken Exp $ 
- * $DragonFly: src/sys/contrib/dev/fla/Attic/fla.c,v 1.9 2005/06/09 20:47:37 swildner Exp $ 
+ * $DragonFly: src/sys/contrib/dev/fla/Attic/fla.c,v 1.10 2006/02/17 19:17:52 dillon Exp $ 
  *
  */
 
@@ -122,7 +122,7 @@ static struct fla_s {
        int unit;
        unsigned nsect;
        struct doc2k_stat ds;
-       struct buf_queue_head buf_queue;
+       struct bio_queue_head bio_queue;
        struct devstat stats;
        struct disk disk;
        dev_t dev;
@@ -190,41 +190,42 @@ flaioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
 }
 
 static void
-flastrategy(struct buf *bp)
+flastrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        int unit, error;
        struct fla_s *sc;
        enum doc2k_work what;
 
-       if (fla_debug > 1)
+       if (fla_debug > 1) {
                printf("flastrategy(%p) %s %lx, %d, %ld, %p)\n",
-                   bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, 
+                   bp, devtoname(dev), bp->b_flags, bio->bio_blkno, 
                    bp->b_bcount / DEV_BSIZE, bp->b_data);
+       }
 
-       sc = bp->b_dev->si_drv1;
-
+       sc = dev->si_drv1;
+       bio->bio_driver_info = dev;
        crit_enter();
-
-       bufqdisksort(&sc->buf_queue, bp);
-
+       bioqdisksort(&sc->bio_queue, bio);
        if (sc->busy) {
                crit_exit();
                return;
        }
-
        sc->busy++;
        
        while (1) {
-               bp = bufq_first(&sc->buf_queue);
-               if (bp)
-                       bufq_remove(&sc->buf_queue, bp);
-               crit_exit();
-               if (!bp)
+               bio = bioq_first(&sc->bio_queue);
+               if (bio == NULL) {
+                       crit_exit();
                        break;
+               }
+               bioq_remove(&sc->bio_queue, bio);
+               bp = bio->bio_buf;
+               dev = bio->bio_driver_info;
 
                devstat_start_transaction(&sc->stats);
                bp->b_resid = bp->b_bcount;
-               unit = dkunit(bp->b_dev);
+               unit = dkunit(dev);
 
                if (bp->b_flags & B_FREEBUF)
                        what = DOC2K_ERASE;
@@ -235,14 +236,14 @@ flastrategy(struct buf *bp)
 
                LEAVE();
 
-               error = doc2k_rwe( unit, what, bp->b_pblkno,
-                   bp->b_bcount / DEV_BSIZE, bp->b_data);
+               error = doc2k_rwe(unit, what, bio->bio_blkno,
+                                 bp->b_bcount / DEV_BSIZE, bp->b_data);
 
                ENTER();
 
                if (fla_debug > 1 || error) {
                        printf("fla%d: %d = rwe(%p, %d, %d, %d, %ld, %p)\n",
-                           unit, error, bp, unit, what, bp->b_pblkno, 
+                           unit, error, bp, unit, what, bio->bio_blkno, 
                            bp->b_bcount / DEV_BSIZE, bp->b_data);
                }
                if (error) {
@@ -252,7 +253,7 @@ flastrategy(struct buf *bp)
                        bp->b_resid = 0;
                }
                devstat_end_transaction_buf(&sc->stats, bp);
-               biodone(bp);
+               biodone(bio);
 
                crit_enter();
        }
@@ -327,7 +328,7 @@ flaattach (device_t dev)
                    unit, sc->ds.type, sc->ds.unitSize, sc->ds.mediaSize, 
                    sc->ds.chipSize, sc->ds.interleaving, sc->ds.window);
 
-       bufq_init(&sc->buf_queue);
+       bioq_init(&sc->bio_queue);
 
        devstat_add_entry(&softc[unit].stats, "fla", unit, DEV_BSIZE,
                DEVSTAT_NO_ORDERED_TAGS, 
index 082985d..81a2348 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/ata-disk.c,v 1.60.2.24 2003/01/30 07:19:59 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/ata-disk.c,v 1.25 2005/08/26 14:26:45 hmp Exp $
+ * $DragonFly: src/sys/dev/disk/ata/ata-disk.c,v 1.26 2006/02/17 19:17:54 dillon Exp $
  */
 
 #include "opt_ata.h"
@@ -131,7 +131,7 @@ ad_attach(struct ata_device *atadev, int alreadylocked)
     adp->heads = atadev->param->heads;
     adp->sectors = atadev->param->sectors;
     adp->total_secs = atadev->param->cylinders * adp->heads * adp->sectors;    
-    bufq_init(&adp->queue);
+    bioq_init(&adp->bio_queue);
 
     /* does this device need oldstyle CHS addressing */
     if (!ad_version(atadev->param->version_major) || 
@@ -237,6 +237,7 @@ ad_detach(struct ata_device *atadev, int flush) /* get rid of flush XXX SOS */
 {
     struct ad_softc *adp = atadev->driver;
     struct ad_request *request;
+    struct bio *bio;
     struct buf *bp;
 
     atadev->flags |= ATA_D_DETACHING;
@@ -246,17 +247,18 @@ ad_detach(struct ata_device *atadev, int flush) /* get rid of flush XXX SOS */
        if (request->softc != adp)
            continue;
        TAILQ_REMOVE(&atadev->channel->ata_queue, request, chain);
-       request->bp->b_error = ENXIO;
-       request->bp->b_flags |= B_ERROR;
-       biodone(request->bp);
+       request->bio->bio_buf->b_error = ENXIO;
+       request->bio->bio_buf->b_flags |= B_ERROR;
+       biodone(request->bio);
        ad_free(request);
     }
     ata_dmafree(atadev);
-    while ((bp = bufq_first(&adp->queue))) {
-       bufq_remove(&adp->queue, bp); 
+    while ((bio = bioq_first(&adp->bio_queue))) {
+       bioq_remove(&adp->bio_queue, bio); 
+       bp = bio->bio_buf;
        bp->b_error = ENXIO;
        bp->b_flags |= B_ERROR;
-       biodone(bp);
+       biodone(bio);
     }
     disk_invalidate(&adp->disk);
     devstat_remove_entry(&adp->stats);
@@ -303,18 +305,20 @@ adclose(dev_t dev, int flags, int fmt, struct thread *td)
  * may have been translated through several layers.
  */
 static void 
-adstrategy(struct buf *bp)
+adstrategy(dev_t dev, struct bio *bio)
 {
-    struct ad_softc *adp = bp->b_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
+    struct ad_softc *adp = dev->si_drv1;
 
     if (adp->device->flags & ATA_D_DETACHING) {
        bp->b_error = ENXIO;
        bp->b_flags |= B_ERROR;
-       biodone(bp);
+       biodone(bio);
        return;
     }
+    bio->bio_driver_info = dev;
     crit_enter();
-    bufqdisksort(&adp->queue, bp);
+    bioqdisksort(&adp->bio_queue, bio);
     crit_exit();
     ata_start(adp->device->channel);
 }
@@ -390,12 +394,14 @@ void
 ad_start(struct ata_device *atadev)
 {
     struct ad_softc *adp = atadev->driver;
-    struct buf *bp = bufq_first(&adp->queue);
+    struct bio *bio = bioq_first(&adp->bio_queue);
+    struct buf *bp;
     struct ad_request *request;
     int tag = 0;
 
-    if (!bp)
+    if (bio == NULL)
        return;
+    bp = bio->bio_buf;
 
     /* if tagged queueing enabled get next free tag */
     if (adp->flags & AD_F_TAG_ENABLED) {
@@ -418,8 +424,8 @@ ad_start(struct ata_device *atadev)
 
     /* setup request */
     request->softc = adp;
-    request->bp = bp;
-    request->blockaddr = bp->b_pblkno;
+    request->bio = bio;
+    request->blockaddr = bio->bio_blkno;
     request->bytecount = bp->b_bcount;
     request->data = bp->b_data;
     request->tag = tag;
@@ -439,7 +445,7 @@ ad_start(struct ata_device *atadev)
     adp->tags[tag] = request;
 
     /* remove from drive queue */
-    bufq_remove(&adp->queue, bp); 
+    bioq_remove(&adp->bio_queue, bio); 
 
     /* link onto controller queue */
     TAILQ_INSERT_TAIL(&atadev->channel->ata_queue, request, chain);
@@ -611,11 +617,11 @@ transfer_failed:
        ad_requeue(adp->device->channel, request);
     else {
        /* retries all used up, return error */
-       request->bp->b_error = EIO;
-       request->bp->b_flags |= B_ERROR;
-       request->bp->b_resid = request->bytecount;
-       devstat_end_transaction_buf(&adp->stats, request->bp);
-       biodone(request->bp);
+       request->bio->bio_buf->b_error = EIO;
+       request->bio->bio_buf->b_flags |= B_ERROR;
+       request->bio->bio_buf->b_resid = request->bytecount;
+       devstat_end_transaction_buf(&adp->stats, request->bio->bio_buf);
+       biodone(request->bio);
        ad_free(request);
     }
     ata_reinit(adp->device->channel);
@@ -627,14 +633,16 @@ ad_interrupt(struct ad_request *request)
 {
     struct ad_softc *adp = request->softc;
     int dma_stat = 0;
+    dev_t dev;
 
     /* finish DMA transfer */
     if (request->flags & ADR_F_DMA_USED)
        dma_stat = ata_dmadone(adp->device);
 
+    dev = request->bio->bio_driver_info;
     /* do we have a corrected soft error ? */
     if (adp->device->channel->status & ATA_S_CORR)
-       diskerr(request->bp, request->bp->b_dev,
+       diskerr(request->bio, dev,
                "soft error (ECC corrected)", LOG_PRINTF,
                request->blockaddr + (request->donecount / DEV_BSIZE),
                &adp->disk.d_label);
@@ -644,7 +652,7 @@ ad_interrupt(struct ad_request *request)
        (request->flags & ADR_F_DMA_USED && dma_stat & ATA_BMSTAT_ERROR)) {
        adp->device->channel->error =
            ATA_INB(adp->device->channel->r_io, ATA_ERROR);
-       diskerr(request->bp, request->bp->b_dev,
+       diskerr(request->bio, dev,
                (adp->device->channel->error & ATA_E_ICRC) ?
                "UDMA ICRC error" : "hard error", LOG_PRINTF,
                request->blockaddr + (request->donecount / DEV_BSIZE),
@@ -713,8 +721,8 @@ ad_interrupt(struct ad_request *request)
 
     /* finish up transfer */
     if (request->flags & ADR_F_ERROR) {
-       request->bp->b_error = EIO;
-       request->bp->b_flags |= B_ERROR;
+       request->bio->bio_buf->b_error = EIO;
+       request->bio->bio_buf->b_flags |= B_ERROR;
     } 
     else {
        request->bytecount -= request->currentsize;
@@ -728,10 +736,10 @@ ad_interrupt(struct ad_request *request)
     /* disarm timeout for this transfer */
     callout_stop(&request->callout);
 
-    request->bp->b_resid = request->bytecount;
+    request->bio->bio_buf->b_resid = request->bytecount;
 
-    devstat_end_transaction_buf(&adp->stats, request->bp);
-    biodone(request->bp);
+    devstat_end_transaction_buf(&adp->stats, request->bio->bio_buf);
+    biodone(request->bio);
     ad_free(request);
     adp->outstanding--;
 
@@ -924,10 +932,10 @@ ad_timeout(struct ad_request *request)
     }
     else {
        /* retries all used up, return error */
-       request->bp->b_error = EIO;
-       request->bp->b_flags |= B_ERROR;
-       devstat_end_transaction_buf(&adp->stats, request->bp);
-       biodone(request->bp);
+       request->bio->bio_buf->b_error = EIO;
+       request->bio->bio_buf->b_flags |= B_ERROR;
+       devstat_end_transaction_buf(&adp->stats, request->bio->bio_buf);
+       biodone(request->bio);
        ad_free(request);
     }
     ata_reinit(adp->device->channel);
index 56a6346..499f0ae 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/ata-disk.h,v 1.22.2.7 2002/03/18 08:37:33 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/ata-disk.h,v 1.5 2004/09/18 18:33:38 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/ata/ata-disk.h,v 1.6 2006/02/17 19:17:54 dillon Exp $
  */
 
 /* structure describing an ATA disk request */
@@ -46,7 +46,7 @@ struct ad_request {
 #define                ADR_F_FORCE_PIO         0x0010
 
     caddr_t                    data;           /* pointer to data buf */
-    struct buf                 *bp;            /* associated bio ptr */
+    struct bio                 *bio;           /* associated bio ptr */
     u_int8_t                   tag;            /* tag ID of this request */
     int                                serv;           /* request had service */
     TAILQ_ENTRY(ad_request)    chain;          /* list management */
@@ -70,7 +70,7 @@ struct ad_softc {
 
     struct ad_request          *tags[32];      /* tag array of requests */
     int                                outstanding;    /* tags not serviced yet */
-    struct buf_queue_head      queue;          /* head of request queue */
+    struct bio_queue_head      bio_queue;      /* head of request queue */
     struct devstat             stats;          /* devstat entry */
     struct disk                        disk;           /* disklabel/slice stuff */
     dev_t                      dev;            /* device place holder */
index e404bba..84dc08b 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/ata-raid.c,v 1.3.2.19 2003/01/30 07:19:59 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/ata-raid.c,v 1.14 2005/08/03 16:36:33 hmp Exp $
+ * $DragonFly: src/sys/dev/disk/ata/ata-raid.c,v 1.15 2006/02/17 19:17:54 dillon Exp $
  */
 
 #include "opt_ata.h"
@@ -75,7 +75,7 @@ static struct cdevsw ar_cdevsw = {
 
 /* prototypes */
 static void ar_attach_raid(struct ar_softc *, int);
-static void ar_done(struct buf *);
+static void ar_done(struct bio *);
 static void ar_config_changed(struct ar_softc *, int);
 static int ar_rebuild(struct ar_softc *);
 static int ar_highpoint_read_conf(struct ad_softc *, struct ar_softc **);
@@ -480,9 +480,10 @@ aropen(dev_t dev, int flags, int fmt, struct thread *td)
 }
 
 static void
-arstrategy(struct buf *bp)
+arstrategy(dev_t dev, struct bio *bio)
 {
-    struct ar_softc *rdp = bp->b_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
+    struct ar_softc *rdp = dev->si_drv1;
     int blkno, count, chunk, lba, lbs, tmplba;
     int drv = 0, change = 0;
     caddr_t data;
@@ -490,12 +491,12 @@ arstrategy(struct buf *bp)
     if (!(rdp->flags & AR_F_READY)) {
        bp->b_flags |= B_ERROR;
        bp->b_error = EIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
     bp->b_resid = bp->b_bcount;
-    blkno = bp->b_pblkno;
+    blkno = bio->bio_blkno;
     data = bp->b_data;
     for (count = howmany(bp->b_bcount, DEV_BSIZE); count > 0; 
         count -= chunk, blkno += chunk, data += (chunk * DEV_BSIZE)) {
@@ -537,22 +538,23 @@ arstrategy(struct buf *bp)
            printf("ar%d: unknown array type in arstrategy\n", rdp->lun);
            bp->b_flags |= B_ERROR;
            bp->b_error = EIO;
-           biodone(bp);
+           biodone(bio);
            return;
        }
 
        buf1 = malloc(sizeof(struct ar_buf), M_AR, M_INTWAIT | M_ZERO);
        BUF_LOCKINIT(&buf1->bp);
        BUF_LOCK(&buf1->bp, LK_EXCLUSIVE);
-       buf1->bp.b_pblkno = lba;
+       initbufbio(&buf1->bp);
+       buf1->bp.b_bio1.bio_blkno = lba;
        if ((buf1->drive = drv) > 0)
-           buf1->bp.b_pblkno += rdp->offset;
-       buf1->bp.b_caller1 = (void *)rdp;
+           buf1->bp.b_bio1.bio_blkno += rdp->offset;
+       buf1->bp.b_bio1.bio_caller_info1.ptr = (void *)rdp;
        buf1->bp.b_bcount = chunk * DEV_BSIZE;
        buf1->bp.b_data = data;
        buf1->bp.b_flags = bp->b_flags;
-       buf1->bp.b_iodone = ar_done;
-       buf1->org = bp;
+       buf1->bp.b_bio1.bio_done = ar_done;
+       buf1->org = bio;
 
        switch (rdp->flags & (AR_F_RAID0 | AR_F_RAID1 | AR_F_SPAN)) {
        case AR_F_SPAN:
@@ -565,20 +567,20 @@ arstrategy(struct buf *bp)
                free(buf1, M_AR);
                bp->b_flags |= B_ERROR;
                bp->b_error = EIO;
-               biodone(bp);
+               biodone(bio);
                return;
            }
-           buf1->bp.b_dev = AD_SOFTC(rdp->disks[buf1->drive])->dev;
-           AR_STRATEGY((struct buf *)buf1);
+           dev_dstrategy(AD_SOFTC(rdp->disks[buf1->drive])->dev,
+                         &buf1->bp.b_bio1);
            break;
 
        case AR_F_RAID1:
        case AR_F_RAID0 | AR_F_RAID1:
            if ((rdp->flags & AR_F_REBUILDING) && !(bp->b_flags & B_READ)) {
-               if ((bp->b_pblkno >= rdp->lock_start &&
-                    bp->b_pblkno < rdp->lock_end) ||
-                   ((bp->b_pblkno + chunk) > rdp->lock_start &&
-                    (bp->b_pblkno + chunk) <= rdp->lock_end)) {
+               if ((bio->bio_blkno >= rdp->lock_start &&
+                    bio->bio_blkno < rdp->lock_end) ||
+                   ((bio->bio_blkno + chunk) > rdp->lock_start &&
+                    (bio->bio_blkno + chunk) <= rdp->lock_end)) {
                    tsleep(rdp, 0, "arwait", 0);
                }
            }
@@ -601,13 +603,13 @@ arstrategy(struct buf *bp)
                free(buf1, M_AR);
                bp->b_flags |= B_ERROR;
                bp->b_error = EIO;
-               biodone(bp);
+               biodone(bio);
                return;
            }
            if (bp->b_flags & B_READ) {
-               if ((buf1->bp.b_pblkno <
+               if ((buf1->bp.b_bio1.bio_blkno <
                     (rdp->disks[buf1->drive].last_lba - AR_PROXIMITY) ||
-                    buf1->bp.b_pblkno >
+                    buf1->bp.b_bio1.bio_blkno >
                     (rdp->disks[buf1->drive].last_lba + AR_PROXIMITY) ||
                     !(rdp->disks[buf1->drive].flags & AR_DF_ONLINE)) &&
                     (rdp->disks[buf1->drive+rdp->width].flags & AR_DF_ONLINE))
@@ -617,30 +619,31 @@ arstrategy(struct buf *bp)
                if ((rdp->disks[buf1->drive+rdp->width].flags & AR_DF_ONLINE) ||
                    ((rdp->flags & AR_F_REBUILDING) &&
                     (rdp->disks[buf1->drive+rdp->width].flags & AR_DF_SPARE) &&
-                    buf1->bp.b_pblkno < rdp->lock_start)) {
+                    buf1->bp.b_bio1.bio_blkno < rdp->lock_start)) {
                    if ((rdp->disks[buf1->drive].flags & AR_DF_ONLINE) ||
                        ((rdp->flags & AR_F_REBUILDING) &&
                         (rdp->disks[buf1->drive].flags & AR_DF_SPARE) &&
-                        buf1->bp.b_pblkno < rdp->lock_start)) {
+                        buf1->bp.b_bio1.bio_blkno < rdp->lock_start)) {
                        buf2 = malloc(sizeof(struct ar_buf), M_AR, M_INTWAIT);
                        bcopy(buf1, buf2, sizeof(struct ar_buf));
                        BUF_LOCKINIT(&buf2->bp);
                        BUF_LOCK(&buf2->bp, LK_EXCLUSIVE);
+                       initbufbio(&buf2->bp);
                        buf1->mirror = buf2;
                        buf2->mirror = buf1;
                        buf2->drive = buf1->drive + rdp->width;
-                       buf2->bp.b_dev = AD_SOFTC(rdp->disks[buf2->drive])->dev;
-                       AR_STRATEGY((struct buf *)buf2);
+                       dev_dstrategy(AD_SOFTC(rdp->disks[buf2->drive])->dev,
+                                     &buf2->bp.b_bio1);
                        rdp->disks[buf2->drive].last_lba =
-                           buf2->bp.b_pblkno + chunk;
+                           buf2->bp.b_bio1.bio_blkno + chunk;
                    }
                    else
                        buf1->drive = buf1->drive + rdp->width;
                }
            }
-           buf1->bp.b_dev = AD_SOFTC(rdp->disks[buf1->drive])->dev;
-           AR_STRATEGY((struct buf *)buf1);
-           rdp->disks[buf1->drive].last_lba = buf1->bp.b_pblkno + chunk;
+           dev_dstrategy(AD_SOFTC(rdp->disks[buf1->drive])->dev,
+                         &buf1->bp.b_bio1);
+           rdp->disks[buf1->drive].last_lba = buf1->bp.b_bio1.bio_blkno + chunk;
            break;
 
        default:
@@ -650,10 +653,10 @@ arstrategy(struct buf *bp)
 }
 
 static void
-ar_done(struct buf *bp)
+ar_done(struct bio *bio)
 {
-    struct ar_softc *rdp = (struct ar_softc *)bp->b_caller1;
-    struct ar_buf *buf = (struct ar_buf *)bp;
+    struct ar_softc *rdp = (struct ar_softc *)bio->bio_caller_info1.ptr;
+    struct ar_buf *buf = (struct ar_buf *)bio->bio_buf;
 
     switch (rdp->flags & (AR_F_RAID0 | AR_F_RAID1 | AR_F_SPAN)) {
     case AR_F_SPAN:
@@ -661,13 +664,13 @@ ar_done(struct buf *bp)
        if (buf->bp.b_flags & B_ERROR) {
            rdp->disks[buf->drive].flags &= ~AR_DF_ONLINE;
            ar_config_changed(rdp, 1);
-           buf->org->b_flags |= B_ERROR;
-           buf->org->b_error = EIO;
+           buf->org->bio_buf->b_flags |= B_ERROR;
+           buf->org->bio_buf->b_error = EIO;
            biodone(buf->org);
        }
        else {
-           buf->org->b_resid -= buf->bp.b_bcount;
-           if (buf->org->b_resid == 0)
+           buf->org->bio_buf->b_resid -= buf->bp.b_bcount;
+           if (buf->org->bio_buf->b_resid == 0)
                biodone(buf->org);
        }
        break;
@@ -683,16 +686,16 @@ ar_done(struct buf *bp)
                        buf->drive = buf->drive + rdp->width;
                    else
                        buf->drive = buf->drive - rdp->width;
-                   buf->bp.b_dev = AD_SOFTC(rdp->disks[buf->drive])->dev;
-                   buf->bp.b_flags = buf->org->b_flags;
+                   buf->bp.b_flags = buf->org->bio_buf->b_flags;
                    buf->bp.b_error = 0;
-                   AR_STRATEGY((struct buf *)buf);
+                   dev_dstrategy(AD_SOFTC(rdp->disks[buf->drive])->dev,
+                                 &buf->bp.b_bio1);
                    return;
                }
                else {
                    if (buf->flags & AB_F_DONE) {
-                       buf->org->b_resid -= buf->bp.b_bcount;
-                       if (buf->org->b_resid == 0)
+                       buf->org->bio_buf->b_resid -= buf->bp.b_bcount;
+                       if (buf->org->bio_buf->b_resid == 0)
                            biodone(buf->org);
                    }
                    else
@@ -700,8 +703,8 @@ ar_done(struct buf *bp)
                }
            }
            else {
-               buf->org->b_flags |= B_ERROR;
-               buf->org->b_error = EIO;
+               buf->org->bio_buf->b_flags |= B_ERROR;
+               buf->org->bio_buf->b_error = EIO;
                biodone(buf->org);
            }
        } 
@@ -712,8 +715,8 @@ ar_done(struct buf *bp)
                    break;
                }
            }
-           buf->org->b_resid -= buf->bp.b_bcount;
-           if (buf->org->b_resid == 0)
+           buf->org->bio_buf->b_resid -= buf->bp.b_bcount;
+           if (buf->org->bio_buf->b_resid == 0)
                biodone(buf->org);
        }
        break;
@@ -1367,8 +1370,10 @@ ar_promise_write_conf(struct ar_softc *rdp)
 }
 
 static void
-ar_rw_done(struct buf *bp)
+ar_rw_done(struct bio *bio)
 {
+    struct buf *bp = bio->bio_buf;
+
     free(bp->b_data, M_AR);
     free(bp, M_AR);
 }
@@ -1382,24 +1387,24 @@ ar_rw(struct ad_softc *adp, u_int32_t lba, int count, caddr_t data, int flags)
     bp = malloc(sizeof(struct buf), M_AR, M_INTWAIT|M_ZERO);
     BUF_LOCKINIT(bp);
     BUF_LOCK(bp, LK_EXCLUSIVE);
-    bp->b_dev = adp->dev;
+    initbufbio(bp);
     bp->b_data = data;
-    bp->b_pblkno = lba;
+    bp->b_bio1.bio_blkno = lba;
     bp->b_bcount = count;
     if (flags & AR_WAIT)
-       bp->b_iodone = (void *)wakeup;
+       bp->b_bio1.bio_done = (void *)wakeup;
     else
-       bp->b_iodone = ar_rw_done;
+       bp->b_bio1.bio_done = ar_rw_done;
     if (flags & AR_READ)
        bp->b_flags |= B_READ;
     if (flags & AR_WRITE)
        bp->b_flags |= B_WRITE;
 
-    AR_STRATEGY((struct buf *)bp);
+    dev_dstrategy(adp->dev, &bp->b_bio1);
 
     if (flags & AR_WAIT) {
        while ((retry++ < (15*hz/10)) && (error = !(bp->b_flags & B_DONE)))
-           error = tsleep(bp, 0, "arrw", 10);
+           error = tsleep(&bp->b_bio1, 0, "arrw", 10);
        if (!error && (bp->b_flags & B_ERROR))
            error = bp->b_error;
        free(bp, M_AR);
index cea51e5..e8ceaa1 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/ata-raid.h,v 1.2.2.8 2002/04/11 09:31:57 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/ata-raid.h,v 1.4 2004/05/19 22:52:40 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/ata/ata-raid.h,v 1.5 2006/02/17 19:17:54 dillon Exp $
  */
 
 /* misc defines */
@@ -36,7 +36,6 @@
 #define AR_READ                0x01
 #define AR_WRITE       0x02
 #define AR_WAIT                0x04
-#define AR_STRATEGY(x) dev_dstrategy((x)->b_dev, x)
 #define AD_SOFTC(x)    ((struct ad_softc *)(x.device->driver))
 #define ATA_MAGIC      "FreeBSD ATA driver RAID "
 
@@ -86,7 +85,7 @@ struct ar_softc {
 
 struct ar_buf {
     struct buf         bp;             /* must be first element! */
-    struct buf         *org;
+    struct bio         *org;
     struct ar_buf      *mirror;
     int                        drive;
     int                        flags;
index 67743ec..1628702 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-all.c,v 1.46.2.18 2002/10/31 23:10:33 thomas Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-all.c,v 1.15 2005/06/03 21:56:23 swildner Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-all.c,v 1.16 2006/02/17 19:17:54 dillon Exp $
  */
 
 #include "opt_ata.h"
@@ -158,10 +158,10 @@ atapi_detach(struct ata_device *atadev)
            continue;
        TAILQ_REMOVE(&atadev->channel->atapi_queue, request, chain);
        if (request->driver) {
-           struct buf *bp = (struct buf *) request->driver;
-           bp->b_flags |= B_ERROR;
-           bp->b_error = ENXIO;
-           biodone(bp);
+           struct bio *bio = (struct bio *) request->driver;
+           bio->bio_buf->b_flags |= B_ERROR;
+           bio->bio_buf->b_error = ENXIO;
+           biodone(bio);
        }
        ata_dmafree(atadev);
        free(request, M_ATAPI);
index ac58611..40fa8a7 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-cd.c,v 1.48.2.20 2002/11/25 05:30:31 njl Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.19 2005/06/03 21:56:23 swildner Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.20 2006/02/17 19:17:54 dillon Exp $
  */
 
 #include "opt_ata.h"
@@ -190,18 +190,18 @@ acddetach(struct ata_device *atadev)
 {   
     struct acd_softc *cdp = atadev->driver;
     struct acd_devlist *entry;
-    struct buf *bp;
+    struct bio *bio;
     int subdev;
     
     if (cdp->changer_info) {
        for (subdev = 0; subdev < cdp->changer_info->slots; subdev++) {
            if (cdp->driver[subdev] == cdp)
                continue;
-           while ((bp = bufq_first(&cdp->driver[subdev]->queue))) {
-               bufq_remove(&cdp->driver[subdev]->queue, bp);
-               bp->b_flags |= B_ERROR;
-               bp->b_error = ENXIO;
-               biodone(bp);
+           while ((bio = bioq_first(&cdp->driver[subdev]->bio_queue))) {
+               bioq_remove(&cdp->driver[subdev]->bio_queue, bio);
+               bio->bio_buf->b_flags |= B_ERROR;
+               bio->bio_buf->b_error = ENXIO;
+               biodone(bio);
            }
            release_dev(cdp->driver[subdev]->dev);
            while ((entry = TAILQ_FIRST(&cdp->driver[subdev]->dev_list))) {
@@ -217,10 +217,10 @@ acddetach(struct ata_device *atadev)
        free(cdp->driver, M_ACD);
        free(cdp->changer_info, M_ACD);
     }
-    while ((bp = bufq_first(&cdp->queue))) {
-       bp->b_flags |= B_ERROR;
-       bp->b_error = ENXIO;
-       biodone(bp);
+    while ((bio = bioq_first(&cdp->bio_queue))) {
+       bio->bio_buf->b_flags |= B_ERROR;
+       bio->bio_buf->b_error = ENXIO;
+       biodone(bio);
     }
     while ((entry = TAILQ_FIRST(&cdp->dev_list))) {
        release_dev(entry->dev);
@@ -244,7 +244,7 @@ acd_init_lun(struct ata_device *atadev)
 
     cdp = malloc(sizeof(struct acd_softc), M_ACD, M_WAITOK | M_ZERO);
     TAILQ_INIT(&cdp->dev_list);
-    bufq_init(&cdp->queue);
+    bioq_init(&cdp->bio_queue);
     cdp->device = atadev;
     cdp->lun = ata_get_lun(&acd_lun_map);
     cdp->block_size = 2048;
@@ -1085,29 +1085,31 @@ acdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
 }
 
 static void 
-acdstrategy(struct buf *bp)
+acdstrategy(dev_t dev, struct bio *bio)
 {
-    struct acd_softc *cdp = bp->b_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
+    struct acd_softc *cdp = dev->si_drv1;
 
     if (cdp->device->flags & ATA_D_DETACHING) {
        bp->b_flags |= B_ERROR;
        bp->b_error = ENXIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
     /* if it's a null transfer, return immediatly. */
     if (bp->b_bcount == 0) {
        bp->b_resid = 0;
-       biodone(bp);
+       biodone(bio);
        return;
     }
-    
-    bp->b_pblkno = bp->b_blkno;
+
+    KKASSERT(bio->bio_blkno != (daddr_t)-1);
+    bio->bio_driver_info = dev;
     bp->b_resid = bp->b_bcount;
 
     crit_enter();
-    bufqdisksort(&cdp->queue, bp);
+    bioqdisksort(&cdp->bio_queue, bio);
     crit_exit();
     ata_start(cdp->device->channel);
 }
@@ -1116,7 +1118,9 @@ void
 acd_start(struct ata_device *atadev)
 {
     struct acd_softc *cdp = atadev->driver;
-    struct buf *bp = bufq_first(&cdp->queue);
+    struct bio *bio = bioq_first(&cdp->bio_queue);
+    struct buf *bp;
+    dev_t dev;
     u_int32_t lba, lastlba, count;
     int8_t ccb[16];
     int track, blocksize;
@@ -1125,58 +1129,60 @@ acd_start(struct ata_device *atadev)
        int i;
 
        cdp = cdp->driver[cdp->changer_info->current_slot];
-       bp = bufq_first(&cdp->queue);
+       bio = bioq_first(&cdp->bio_queue);
 
        /* check for work pending on any other slot */
        for (i = 0; i < cdp->changer_info->slots; i++) {
            if (i == cdp->changer_info->current_slot)
                continue;
-           if (bufq_first(&(cdp->driver[i]->queue))) {
-               if (!bp || time_second > (cdp->timestamp + 10)) {
+           if (bioq_first(&(cdp->driver[i]->bio_queue))) {
+               if (bio == NULL || time_second > (cdp->timestamp + 10)) {
                    acd_select_slot(cdp->driver[i]);
                    return;
                }
            }
        }
     }
-    if (!bp)
+    if (bio == NULL)
        return;
-    bufq_remove(&cdp->queue, bp);
+    bioq_remove(&cdp->bio_queue, bio);
+    dev = bio->bio_driver_info;
+    bp = bio->bio_buf;
 
     /* reject all queued entries if media changed */
     if (cdp->device->flags & ATA_D_MEDIA_CHANGED) {
        bp->b_flags |= B_ERROR;
        bp->b_error = EIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
     bzero(ccb, sizeof(ccb));
 
-    track = (bp->b_dev->si_udev & 0x00ff0000) >> 16;
+    track = (dev->si_udev & 0x00ff0000) >> 16;
 
     if (track) {
        blocksize = (cdp->toc.tab[track - 1].control & 4) ? 2048 : 2352;
        lastlba = ntohl(cdp->toc.tab[track].addr.lba);
        if (bp->b_flags & B_PHYS)
-           lba = bp->b_offset / blocksize;
+           lba = bio->bio_offset / blocksize;
        else
-           lba = bp->b_blkno / (blocksize / DEV_BSIZE);
+           lba = bio->bio_blkno / (blocksize / DEV_BSIZE);
        lba += ntohl(cdp->toc.tab[track - 1].addr.lba);
     }
     else {
        blocksize = cdp->block_size;
        lastlba = cdp->disk_size;
        if (bp->b_flags & B_PHYS)
-           lba = bp->b_offset / blocksize;
+           lba = bio->bio_offset / blocksize;
        else
-           lba = bp->b_blkno / (blocksize / DEV_BSIZE);
+           lba = bio->bio_blkno / (blocksize / DEV_BSIZE);
     }
 
     if (bp->b_bcount % blocksize != 0) {
        bp->b_flags |= B_ERROR;
        bp->b_error = EINVAL;
-       biodone(bp);
+       biodone(bio);
        return;
     }
     count = bp->b_bcount / blocksize;
@@ -1187,7 +1193,7 @@ acd_start(struct ata_device *atadev)
            /* if we are entirely beyond EOM return EOF */
            if (lastlba <= lba) {
                bp->b_resid = bp->b_bcount;
-               biodone(bp);
+               biodone(bio);
                return;
            }
            count = lastlba - lba;
@@ -1220,26 +1226,27 @@ acd_start(struct ata_device *atadev)
     ccb[8] = count;
 
     devstat_start_transaction(cdp->stats);
-    bp->b_caller1 = cdp;
+    bio->bio_caller_info1.ptr = cdp;
     atapi_queue_cmd(cdp->device, ccb, bp->b_data, count * blocksize,
                    bp->b_flags & B_READ ? ATPR_F_READ : 0, 
-                   (ccb[0] == ATAPI_WRITE_BIG) ? 60 : 30, acd_done, bp);
+                   (ccb[0] == ATAPI_WRITE_BIG) ? 60 : 30, acd_done, bio);
 }
 
 static int 
 acd_done(struct atapi_request *request)
 {
-    struct buf *bp = request->driver;
-    struct acd_softc *cdp = bp->b_caller1;
+    struct bio *bio = request->driver;
+    struct buf *bp = bio->bio_buf;
+    struct acd_softc *cdp = bio->bio_caller_info1.ptr;
     
     if (request->error) {
        bp->b_error = request->error;
        bp->b_flags |= B_ERROR;
-    }  
-    else
+    } else {
        bp->b_resid = bp->b_bcount - request->donecount;
+    }
     devstat_end_transaction_buf(cdp->stats, bp);
-    biodone(bp);
+    biodone(bio);
     return 0;
 }
 
index e4f4351..5bd1bd0 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-cd.h,v 1.15.2.9 2002/03/18 08:37:34 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-cd.h,v 1.2 2003/06/17 04:28:22 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-cd.h,v 1.3 2006/02/17 19:17:54 dillon Exp $
  */
 
 /* CDROM Table Of Contents */
@@ -311,7 +311,7 @@ struct acd_softc {
     int                                flags;          /* device state flags */
 #define                F_LOCKED                0x0001  /* this unit is locked */
 
-    struct buf_queue_head      queue;          /* queue of i/o requests */
+    struct bio_queue_head      bio_queue;      /* queue of i/o requests */
     TAILQ_HEAD(, acd_devlist)  dev_list;       /* list of "track" devices */
     struct toc                 toc;            /* table of disc contents */
     struct audiopage           au;             /* audio page info */
index 91e1018..7ba44a7 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-fd.c,v 1.44.2.9 2002/07/31 11:19:26 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-fd.c,v 1.12 2005/06/03 21:56:23 swildner Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-fd.c,v 1.13 2006/02/17 19:17:54 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -100,7 +100,7 @@ afdattach(struct ata_device *atadev)
     fdp->device = atadev;
     fdp->lun = ata_get_lun(&afd_lun_map);
     ata_set_name(atadev, "afd", fdp->lun);
-    bufq_init(&fdp->queue);
+    bioq_init(&fdp->bio_queue);
 
     if (afd_sense(fdp)) {
        free(fdp, M_AFD);
@@ -131,13 +131,15 @@ void
 afddetach(struct ata_device *atadev)
 {   
     struct afd_softc *fdp = atadev->driver;
+    struct bio *bio;
     struct buf *bp;
     
-    while ((bp = bufq_first(&fdp->queue))) {
-       bufq_remove(&fdp->queue, bp);
+    while ((bio = bioq_first(&fdp->bio_queue))) {
+       bioq_remove(&fdp->bio_queue, bio);
+       bp = bio->bio_buf;
        bp->b_flags |= B_ERROR;
        bp->b_error = ENXIO;
-       biodone(bp);
+       biodone(bio);
     }
     disk_invalidate(&fdp->disk);
     disk_destroy(&fdp->disk);
@@ -292,26 +294,27 @@ afdioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 }
 
 static void 
-afdstrategy(struct buf *bp)
+afdstrategy(dev_t dev, struct bio *bio)
 {
-    struct afd_softc *fdp = bp->b_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
+    struct afd_softc *fdp = dev->si_drv1;
 
     if (fdp->device->flags & ATA_D_DETACHING) {
        bp->b_flags |= B_ERROR;
        bp->b_error = ENXIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
     /* if it's a null transfer, return immediatly. */
     if (bp->b_bcount == 0) {
        bp->b_resid = 0;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
     crit_enter();
-    bufqdisksort(&fdp->queue, bp);
+    bioqdisksort(&fdp->bio_queue, bio);
     crit_exit();
     ata_start(fdp->device->channel);
 }
@@ -320,26 +323,28 @@ void
 afd_start(struct ata_device *atadev)
 {
     struct afd_softc *fdp = atadev->driver;
-    struct buf *bp = bufq_first(&fdp->queue);
+    struct bio *bio = bioq_first(&fdp->bio_queue);
+    struct buf *bp;
     u_int32_t lba;
     u_int16_t count;
     int8_t ccb[16];
     caddr_t data_ptr;
 
-    if (!bp)
+    if (bio == NULL)
        return;
 
-    bufq_remove(&fdp->queue, bp);
+    bioq_remove(&fdp->bio_queue, bio);
+    bp = bio->bio_buf;
 
     /* should reject all queued entries if media have changed. */
     if (fdp->device->flags & ATA_D_MEDIA_CHANGED) {
        bp->b_flags |= B_ERROR;
        bp->b_error = EIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
-    lba = bp->b_pblkno;
+    lba = bio->bio_blkno;
     count = bp->b_bcount / fdp->cap.sector_size;
     data_ptr = bp->b_data;
     bp->b_resid = bp->b_bcount; 
@@ -362,13 +367,14 @@ afd_start(struct ata_device *atadev)
 
     atapi_queue_cmd(fdp->device, ccb, data_ptr, count * fdp->cap.sector_size,
                    (bp->b_flags & B_READ) ? ATPR_F_READ : 0, 30,
-                   afd_done, bp);
+                   afd_done, bio);
 }
 
 static int 
 afd_done(struct atapi_request *request)
 {
-    struct buf *bp = request->driver;
+    struct bio *bio = request->driver;
+    struct buf *bp = bio->bio_buf;
     struct afd_softc *fdp = request->device->driver;
 
     if (request->error || (bp->b_flags & B_ERROR)) {
@@ -378,7 +384,7 @@ afd_done(struct atapi_request *request)
     else
        bp->b_resid = bp->b_bcount - request->donecount;
     devstat_end_transaction_buf(&fdp->stats, bp);
-    biodone(bp);
+    biodone(bio);
     return 0;
 }
 
index d4ccfec..ebb103c 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-fd.h,v 1.10.2.5 2002/07/31 11:19:26 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-fd.h,v 1.2 2003/06/17 04:28:22 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-fd.h,v 1.3 2006/02/17 19:17:54 dillon Exp $
  */
 
 /* ATAPI Rewriteable drive Capabilities and Mechanical Status Page */
@@ -72,7 +72,7 @@ struct afd_cappage {
 struct afd_softc {
     struct ata_device          *device;        /* device softc */
     int                                lun;            /* logical device unit */
-    struct buf_queue_head      queue;          /* queue of i/o requests */
+    struct bio_queue_head      bio_queue;      /* queue of i/o requests */
     struct afd_cappage         cap;            /* capabilities page info */
     struct disk                        disk;           /* virtual drives */
     struct devstat             stats;
index d3b7e45..8764c43 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-tape.c,v 1.36.2.12 2002/07/31 11:19:26 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-tape.c,v 1.12 2005/06/03 21:56:23 swildner Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-tape.c,v 1.13 2006/02/17 19:17:54 dillon Exp $
  */
 
 #include "opt_ata.h"
@@ -110,7 +110,7 @@ astattach(struct ata_device *atadev)
     stp->device = atadev;
     stp->lun = ata_get_lun(&ast_lun_map);
     ata_set_name(atadev, "ast", stp->lun);
-    bufq_init(&stp->queue);
+    bioq_init(&stp->bio_queue);
 
     if (ast_sense(stp)) {
        free(stp, M_AST);
@@ -157,12 +157,14 @@ astdetach(struct ata_device *atadev)
 {   
     struct ast_softc *stp = atadev->driver;
     struct buf *bp;
+    struct bio *bio;
     
-    while ((bp = bufq_first(&stp->queue))) {
-       bufq_remove(&stp->queue, bp);
+    while ((bio = bioq_first(&stp->bio_queue))) {
+       bioq_remove(&stp->bio_queue, bio);
+       bp = bio->bio_buf;
        bp->b_flags |= B_ERROR;
        bp->b_error = ENXIO;
-       biodone(bp);
+       biodone(bio);
     }
     devstat_remove_entry(&stp->stats);
     cdevsw_remove(&ast_cdevsw, dkunitmask(), dkmakeunit(stp->lun));
@@ -417,27 +419,28 @@ astioctl(dev_t dev, u_long cmd, caddr_t addr, int flag, struct thread *td)
 }
 
 static void 
-aststrategy(struct buf *bp)
+aststrategy(dev_t dev, struct bio *bio)
 {
-    struct ast_softc *stp = bp->b_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
+    struct ast_softc *stp = dev->si_drv1;
 
     if (stp->device->flags & ATA_D_DETACHING) {
        bp->b_flags |= B_ERROR;
        bp->b_error = ENXIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
     /* if it's a null transfer, return immediatly. */
     if (bp->b_bcount == 0) {
        bp->b_resid = 0;
-       biodone(bp);
+       biodone(bio);
        return;
     }
     if (!(bp->b_flags & B_READ) && stp->flags & F_WRITEPROTECT) {
        bp->b_flags |= B_ERROR;
        bp->b_error = EPERM;
-       biodone(bp);
+       biodone(bio);
        return;
     }
        
@@ -447,7 +450,7 @@ aststrategy(struct buf *bp)
                   stp->blksize);
        bp->b_flags |= B_ERROR;
        bp->b_error = EIO;
-       biodone(bp);
+       biodone(bio);
        return;
     }
 
@@ -461,7 +464,7 @@ aststrategy(struct buf *bp)
     }
 
     crit_enter();
-    bufq_insert_tail(&stp->queue, bp);
+    bioq_insert_tail(&stp->bio_queue, bio);
     crit_exit();
     ata_start(stp->device->channel);
 }
@@ -470,21 +473,22 @@ void
 ast_start(struct ata_device *atadev)
 {
     struct ast_softc *stp = atadev->driver;
-    struct buf *bp = bufq_first(&stp->queue);
+    struct bio *bio = bioq_first(&stp->bio_queue);
+    struct buf *bp;
     u_int32_t blkcount;
     int8_t ccb[16];
     
-    if (!bp)
+    if (bio == NULL)
        return;
-
     bzero(ccb, sizeof(ccb));
 
+    bp = bio->bio_buf;
     if (bp->b_flags & B_READ)
        ccb[0] = ATAPI_READ;
     else
        ccb[0] = ATAPI_WRITE;
     
-    bufq_remove(&stp->queue, bp);
+    bioq_remove(&stp->bio_queue, bio);
     blkcount = bp->b_bcount / stp->blksize;
 
     ccb[1] = 1;
@@ -496,27 +500,27 @@ ast_start(struct ata_device *atadev)
 
     atapi_queue_cmd(stp->device, ccb, bp->b_data, blkcount * stp->blksize, 
                    (bp->b_flags & B_READ) ? ATPR_F_READ : 0,
-                   120, ast_done, bp);
+                   120, ast_done, bio);
 }
 
 static int 
 ast_done(struct atapi_request *request)
 {
-    struct buf *bp = request->driver;
+    struct bio *bio = request->driver;
+    struct buf *bp = bio->bio_buf;
     struct ast_softc *stp = request->device->driver;
 
     if (request->error) {
        bp->b_error = request->error;
        bp->b_flags |= B_ERROR;
-    }
-    else {
+    } else {
        if (!(bp->b_flags & B_READ))
            stp->flags |= F_DATA_WRITTEN;
        bp->b_resid = bp->b_bcount - request->donecount;
        ast_total += (bp->b_bcount - bp->b_resid);
     }
     devstat_end_transaction_buf(&stp->stats, bp);
-    biodone(bp);
+    biodone(bio);
     return 0;
 }
 
index c81ec63..8324343 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ata/atapi-tape.h,v 1.11.2.5 2002/03/18 08:37:34 sos Exp $
- * $DragonFly: src/sys/dev/disk/ata/atapi-tape.h,v 1.3 2004/05/19 22:52:41 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/ata/atapi-tape.h,v 1.4 2006/02/17 19:17:54 dillon Exp $
  */
 
 /* ATAPI tape drive Capabilities and Mechanical Status Page */
@@ -155,7 +155,7 @@ struct ast_softc {
 #define                F_ONSTREAM              0x0100  /* OnStream ADR device */
 
     int                                blksize;        /* block size (512 | 1024) */
-    struct buf_queue_head      queue;          /* queue of i/o requests */
+    struct bio_queue_head      bio_queue;      /* queue of i/o requests */
     struct atapi_params                *param;         /* drive parameters table */
     struct ast_cappage         cap;            /* capabilities page info */
     struct devstat             stats;          /* devstat entry */
index f36dceb..c87219b 100644 (file)
@@ -1,5 +1,5 @@
 /* $FreeBSD: src/sys/dev/ccd/ccd.c,v 1.73.2.1 2001/09/11 09:49:52 kris Exp $ */
-/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.21 2005/12/11 01:54:07 swildner Exp $ */
+/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.22 2006/02/17 19:17:55 dillon Exp $ */
 
 /*     $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */
 
@@ -149,7 +149,7 @@ SYSCTL_INT(_debug, OID_AUTO, ccddebug, CTLFLAG_RW, &ccddebug, 0, "");
 
 struct ccdbuf {
        struct buf      cb_buf;         /* new I/O buf */
-       struct buf      *cb_obp;        /* ptr. to original I/O buf */
+       struct bio      *cb_obio;       /* ptr. to original I/O buf */
        struct ccdbuf   *cb_freenext;   /* free list link */
        int             cb_unit;        /* target unit */
        int             cb_comp;        /* target component */
@@ -198,15 +198,15 @@ static    void ccdattach (void);
 static int ccd_modevent (module_t, int, void *);
 
 /* called by biodone() at interrupt time */
-static void ccdiodone (struct ccdbuf *cbp);
+static void ccdiodone (struct bio *bio);
 
-static void ccdstart (struct ccd_softc *, struct buf *);
+static void ccdstart (struct ccd_softc *, struct bio *);
 static void ccdinterleave (struct ccd_softc *, int);
-static void ccdintr (struct ccd_softc *, struct buf *);
+static void ccdintr (struct ccd_softc *, struct bio *);
 static int ccdinit (struct ccddevice *, char **, struct thread *);
 static int ccdlookup (char *, struct thread *td, struct vnode **);
 static void ccdbuffer (struct ccdbuf **ret, struct ccd_softc *,
-               struct buf *, daddr_t, caddr_t, long);
+               struct bio *, daddr_t, caddr_t, long);
 static void ccdgetdisklabel (dev_t);
 static void ccdmakedisklabel (struct ccd_softc *);
 static int ccdlock (struct ccd_softc *);
@@ -241,8 +241,10 @@ getccdbuf(struct ccdbuf *cpy)
        if ((cbp = ccdfreebufs) != NULL) {
                ccdfreebufs = cbp->cb_freenext;
                --numccdfreebufs;
+               reinitbufbio(&cbp->cb_buf);
        } else {
                cbp = malloc(sizeof(struct ccdbuf), M_DEVBUF, M_WAITOK);
+               initbufbio(&cbp->cb_buf);
        }
 
        /*
@@ -749,9 +751,11 @@ ccdclose(dev_t dev, int flags, int fmt, d_thread_t *td)
 }
 
 static void
-ccdstrategy(struct buf *bp)
+ccdstrategy(dev_t dev, struct bio *bio)
 {
-       int unit = ccdunit(bp->b_dev);
+       int unit = ccdunit(dev);
+       struct bio *nbio;
+       struct buf *bp = bio->bio_buf;
        struct ccd_softc *cs = &ccd_softc[unit];
        int wlabel;
        struct disklabel *lp;
@@ -777,14 +781,15 @@ ccdstrategy(struct buf *bp)
         * error, the bounds check will flag that for us.
         */
        wlabel = cs->sc_flags & (CCDF_WLABEL|CCDF_LABELLING);
-       if (ccdpart(bp->b_dev) != RAW_PART) {
-               if (bounds_check_with_label(bp, lp, wlabel) <= 0)
+       if (ccdpart(dev) != RAW_PART) {
+               nbio = bounds_check_with_label(dev, bio, lp, wlabel);
+               if (nbio == NULL)
                        goto done;
        } else {
                int pbn;        /* in sc_secsize chunks */
                long sz;        /* in sc_secsize chunks */
 
-               pbn = bp->b_blkno / (cs->sc_geom.ccg_secsize / DEV_BSIZE);
+               pbn = bio->bio_blkno / (cs->sc_geom.ccg_secsize / DEV_BSIZE);
                sz = howmany(bp->b_bcount, cs->sc_geom.ccg_secsize);
 
                /*
@@ -808,26 +813,34 @@ ccdstrategy(struct buf *bp)
                        bp->b_bcount = (cs->sc_size - pbn) * 
                            cs->sc_geom.ccg_secsize;
                }
+               nbio = bio;
        }
 
        bp->b_resid = bp->b_bcount;
+       nbio->bio_driver_info = dev;
 
        /*
         * "Start" the unit.
         */
        crit_enter();
-       ccdstart(cs, bp);
+       ccdstart(cs, nbio);
        crit_exit();
        return;
+
+       /*
+        * note: bio, not nbio, is valid at the done label.
+        */
 done:
-       biodone(bp);
+       biodone(bio);
 }
 
 static void
-ccdstart(struct ccd_softc *cs, struct buf *bp)
+ccdstart(struct ccd_softc *cs, struct bio *bio)
 {
        long bcount, rcount;
        struct ccdbuf *cbp[4];
+       struct buf *bp = bio->bio_buf;
+       dev_t dev = bio->bio_driver_info;
        /* XXX! : 2 reads and 2 writes for RAID 4/5 */
        caddr_t addr;
        daddr_t bn;
@@ -844,9 +857,9 @@ ccdstart(struct ccd_softc *cs, struct buf *bp)
        /*
         * Translate the partition-relative block number to an absolute.
         */
-       bn = bp->b_blkno;
-       if (ccdpart(bp->b_dev) != RAW_PART) {
-               pp = &cs->sc_label.d_partitions[ccdpart(bp->b_dev)];
+       bn = bio->bio_blkno;
+       if (ccdpart(dev) != RAW_PART) {
+               pp = &cs->sc_label.d_partitions[ccdpart(dev)];
                bn += pp->p_offset;
        }
 
@@ -855,7 +868,7 @@ ccdstart(struct ccd_softc *cs, struct buf *bp)
         */
        addr = bp->b_data;
        for (bcount = bp->b_bcount; bcount > 0; bcount -= rcount) {
-               ccdbuffer(cbp, cs, bp, bn, addr, bcount);
+               ccdbuffer(cbp, cs, bio, bn, addr, bcount);
                rcount = cbp[0]->cb_buf.b_bcount;
 
                if (cs->sc_cflags & CCDF_MIRROR) {
@@ -869,12 +882,10 @@ ccdstart(struct ccd_softc *cs, struct buf *bp)
                         * also try to avoid hogging.
                         */
                        if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) {
-                               cbp[0]->cb_buf.b_vp->v_numoutput++;
-                               cbp[1]->cb_buf.b_vp->v_numoutput++;
-                               VOP_STRATEGY(cbp[0]->cb_buf.b_vp, 
-                                   &cbp[0]->cb_buf);
-                               VOP_STRATEGY(cbp[1]->cb_buf.b_vp, 
-                                   &cbp[1]->cb_buf);
+                               vn_strategy(cbp[0]->cb_buf.b_vp, 
+                                   &cbp[0]->cb_buf.b_bio1);
+                               vn_strategy(cbp[1]->cb_buf.b_vp, 
+                                   &cbp[1]->cb_buf.b_bio1);
                        } else {
                                int pick = cs->sc_pick;
                                daddr_t range = cs->sc_size / 16;
@@ -885,16 +896,15 @@ ccdstart(struct ccd_softc *cs, struct buf *bp)
                                        cs->sc_pick = pick = 1 - pick;
                                }
                                cs->sc_blk[pick] = bn + btodb(rcount);
-                               VOP_STRATEGY(cbp[pick]->cb_buf.b_vp, 
-                                   &cbp[pick]->cb_buf);
+                               vn_strategy(cbp[pick]->cb_buf.b_vp, 
+                                   &cbp[pick]->cb_buf.b_bio1);
                        }
                } else {
                        /*
                         * Not mirroring
                         */
-                       if ((cbp[0]->cb_buf.b_flags & B_READ) == 0)
-                               cbp[0]->cb_buf.b_vp->v_numoutput++;
-                       VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf);
+                       vn_strategy(cbp[0]->cb_buf.b_vp,
+                                    &cbp[0]->cb_buf.b_bio1);
                }
                bn += btodb(rcount);
                addr += rcount;
@@ -905,7 +915,7 @@ ccdstart(struct ccd_softc *cs, struct buf *bp)
  * Build a component buffer header.
  */
 static void
-ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct buf *bp, daddr_t bn,
+ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct bio *bio, daddr_t bn,
          caddr_t addr, long bcount)
 {
        struct ccdcinfo *ci, *ci2 = NULL;       /* XXX */
@@ -1026,11 +1036,8 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct buf *bp, daddr_t bn,
         * Fill in the component buf structure.
         */
        cbp = getccdbuf(NULL);
-       cbp->cb_buf.b_flags = bp->b_flags;
-       cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone;
-       cbp->cb_buf.b_dev = ci->ci_dev;         /* XXX */
-       cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET;
-       cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET);
+       cbp->cb_buf.b_flags = bio->bio_buf->b_flags;
+       /*cbp->cb_buf.b_dev = ci->ci_dev; */
        cbp->cb_buf.b_data = addr;
        cbp->cb_buf.b_vp = ci->ci_vp;
        if (cs->sc_ileave == 0)
@@ -1040,17 +1047,23 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct buf *bp, daddr_t bn,
        cbp->cb_buf.b_bcount = (cbc < bcount) ? cbc : bcount;
        cbp->cb_buf.b_bufsize = cbp->cb_buf.b_bcount;
 
+       cbp->cb_buf.b_bio1.bio_done = ccdiodone;
+       cbp->cb_buf.b_bio1.bio_caller_info1.ptr = cbp;
+       cbp->cb_buf.b_bio1.bio_blkno = cbn + cboff + CCD_OFFSET;
+       cbp->cb_buf.b_bio1.bio_offset = dbtob(cbn + cboff + CCD_OFFSET);
+
        /*
         * context for ccdiodone
         */
-       cbp->cb_obp = bp;
+       cbp->cb_obio = bio;
        cbp->cb_unit = cs - ccd_softc;
        cbp->cb_comp = ci - cs->sc_cinfo;
 
 #ifdef DEBUG
        if (ccddebug & CCDB_IO)
                printf(" dev %x(u%d): cbp %x bn %d addr %x bcnt %d\n",
-                      ci->ci_dev, ci-cs->sc_cinfo, cbp, cbp->cb_buf.b_blkno,
+                      ci->ci_dev, ci-cs->sc_cinfo, cbp,
+                      cbp->cb_buf.b_bio1.bio_blkno,
                       cbp->cb_buf.b_data, cbp->cb_buf.b_bcount);
 #endif
        cb[0] = cbp;
@@ -1062,7 +1075,7 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct buf *bp, daddr_t bn,
        if (cs->sc_cflags & CCDF_MIRROR) {
                /* mirror, setup second I/O */
                cbp = getccdbuf(cb[0]);
-               cbp->cb_buf.b_dev = ci2->ci_dev;
+               /* cbp->cb_buf.b_dev = ci2->ci_dev; */
                cbp->cb_buf.b_vp = ci2->ci_vp;
                cbp->cb_comp = ci2 - cs->sc_cinfo;
                cb[1] = cbp;
@@ -1075,8 +1088,10 @@ ccdbuffer(struct ccdbuf **cb, struct ccd_softc *cs, struct buf *bp, daddr_t bn,
 }
 
 static void
-ccdintr(struct ccd_softc *cs, struct buf *bp)
+ccdintr(struct ccd_softc *cs, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
+
 #ifdef DEBUG
        if (ccddebug & CCDB_FOLLOW)
                printf("ccdintr(%x, %x)\n", cs, bp);
@@ -1087,7 +1102,7 @@ ccdintr(struct ccd_softc *cs, struct buf *bp)
        if (bp->b_flags & B_ERROR)
                bp->b_resid = bp->b_bcount;
        devstat_end_transaction_buf(&cs->device_stats, bp);
-       biodone(bp);
+       biodone(bio);
 }
 
 /*
@@ -1096,22 +1111,30 @@ ccdintr(struct ccd_softc *cs, struct buf *bp)
  * take a ccd interrupt.
  */
 static void
-ccdiodone(struct ccdbuf *cbp)
+ccdiodone(struct bio *bio)
 {
-       struct buf *bp = cbp->cb_obp;
+       struct ccdbuf *cbp = bio->bio_caller_info1.ptr;
+       struct bio *obio = cbp->cb_obio;
+       struct buf *obp = obio->bio_buf;
        int unit = cbp->cb_unit;
        int count;
 
+       /*
+        * Since we do not have exclusive access to underlying devices,
+        * we can't keep cache translations around.
+        */
+       clearbiocache(bio->bio_next);
+
        crit_enter();
 #ifdef DEBUG
        if (ccddebug & CCDB_FOLLOW)
                printf("ccdiodone(%x)\n", cbp);
        if (ccddebug & CCDB_IO) {
                printf("ccdiodone: bp %x bcount %d resid %d\n",
-                      bp, bp->b_bcount, bp->b_resid);
+                      obp, obp->b_bcount, obp->b_resid);
                printf(" dev %x(u%d), cbp %x bn %d addr %x bcnt %d\n",
                       cbp->cb_buf.b_dev, cbp->cb_comp, cbp,
-                      cbp->cb_buf.b_blkno, cbp->cb_buf.b_data,
+                      cbp->cb_buf.b_lblkno, cbp->cb_buf.b_data,
                       cbp->cb_buf.b_bcount);
        }
 #endif
@@ -1121,7 +1144,6 @@ ccdiodone(struct ccdbuf *cbp)
         * set the error in the bp yet because the second read may
         * succeed.
         */
-
        if (cbp->cb_buf.b_flags & B_ERROR) {
                const char *msg = "";
 
@@ -1138,15 +1160,16 @@ ccdiodone(struct ccdbuf *cbp)
 
                        msg = ", trying other disk";
                        cs->sc_pick = 1 - cs->sc_pick;
-                       cs->sc_blk[cs->sc_pick] = bp->b_blkno;
+                       cs->sc_blk[cs->sc_pick] = obio->bio_blkno;
                } else {
-                       bp->b_flags |= B_ERROR;
-                       bp->b_error = cbp->cb_buf.b_error ? 
+                       obp->b_flags |= B_ERROR;
+                       obp->b_error = cbp->cb_buf.b_error ? 
                            cbp->cb_buf.b_error : EIO;
                }
                printf("ccd%d: error %d on component %d block %d (ccd block %d)%s\n",
-                      unit, bp->b_error, cbp->cb_comp, 
-                      (int)cbp->cb_buf.b_blkno, bp->b_blkno, msg);
+                      unit, obp->b_error, cbp->cb_comp, 
+                      (int)cbp->cb_buf.b_bio2.bio_blkno, 
+                      obio->bio_blkno, msg);
        }
 
        /*
@@ -1181,9 +1204,9 @@ ccdiodone(struct ccdbuf *cbp)
                                if (cbp->cb_buf.b_flags & B_ERROR) {
                                        cbp->cb_mirror->cb_pflags |= 
                                            CCDPF_MIRROR_DONE;
-                                       VOP_STRATEGY(
+                                       vn_strategy(
                                            cbp->cb_mirror->cb_buf.b_vp, 
-                                           &cbp->cb_mirror->cb_buf
+                                           &cbp->cb_mirror->cb_buf.b_bio1
                                        );
                                        putccdbuf(cbp);
                                        crit_exit();
@@ -1211,11 +1234,11 @@ ccdiodone(struct ccdbuf *cbp)
        /*
         * If all done, "interrupt".
         */
-       bp->b_resid -= count;
-       if (bp->b_resid < 0)
+       obp->b_resid -= count;
+       if (obp->b_resid < 0)
                panic("ccdiodone: count");
-       if (bp->b_resid == 0)
-               ccdintr(&ccd_softc[unit], bp);
+       if (obp->b_resid == 0)
+               ccdintr(&ccd_softc[unit], obio);
        crit_exit();
 }
 
index 62bb50e..8ce8ffe 100644 (file)
@@ -51,7 +51,7 @@
  *
  *     from:   @(#)fd.c        7.4 (Berkeley) 5/25/91
  * $FreeBSD: src/sys/isa/fd.c,v 1.176.2.8 2002/05/15 21:56:14 joerg Exp $
- * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.24 2005/11/19 17:58:17 dillon Exp $
+ * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.25 2006/02/17 19:17:57 dillon Exp $
  *
  */
 
@@ -817,7 +817,7 @@ fdc_attach(device_t dev)
 
        /* reset controller, turn motor off, clear fdout mirror reg */
        fdout_wr(fdc, ((fdc->fdout = 0)));
-       bufq_init(&fdc->head);
+       bioq_init(&fdc->bio_queue);
 
        /*
         * Probe and attach any children.  We should probably detect
@@ -1381,19 +1381,20 @@ fdclose(dev_t dev, int flags, int mode, struct thread *td)
 /*                               fdstrategy                                 */
 /****************************************************************************/
 void
-fdstrategy(struct buf *bp)
+fdstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        unsigned nblocks, blknum, cando;
        fdu_t   fdu;
        fdc_p   fdc;
        fd_p    fd;
        size_t  fdblk;
 
-       fdu = FDUNIT(minor(bp->b_dev));
+       fdu = FDUNIT(minor(dev));
        fd = devclass_get_softc(fd_devclass, fdu);
        if (fd == 0)
                panic("fdstrategy: buf for nonexistent device (%#lx, %#lx)",
-                     (u_long)major(bp->b_dev), (u_long)minor(bp->b_dev));
+                     (u_long)major(dev), (u_long)minor(dev));
        fdc = fd->fdc;
        if (fd->type == NO_TYPE) {
                bp->b_error = ENXIO;
@@ -1403,10 +1404,10 @@ fdstrategy(struct buf *bp)
 
        fdblk = 128 << (fd->ft->secsize);
        if (!(bp->b_flags & B_FORMAT)) {
-               if (bp->b_blkno < 0) {
+               if (bio->bio_blkno < 0) {
                        printf(
                "fd%d: fdstrat: bad request blkno = %lu, bcount = %ld\n",
-                              fdu, (u_long)bp->b_blkno, bp->b_bcount);
+                              fdu, (u_long)bio->bio_blkno, bp->b_bcount);
                        bp->b_error = EINVAL;
                        bp->b_flags |= B_ERROR;
                        goto bad;
@@ -1421,7 +1422,7 @@ fdstrategy(struct buf *bp)
        /*
         * Set up block calculations.
         */
-       if (bp->b_blkno > 20000000) {
+       if (bio->bio_blkno > 20000000) {
                /*
                 * Reject unreasonably high block number, prevent the
                 * multiplication below from overflowing.
@@ -1430,7 +1431,7 @@ fdstrategy(struct buf *bp)
                bp->b_flags |= B_ERROR;
                goto bad;
        }
-       blknum = (unsigned) bp->b_blkno * DEV_BSIZE/fdblk;
+       blknum = (unsigned) bio->bio_blkno * DEV_BSIZE/fdblk;
        nblocks = fd->ft->size;
        bp->b_resid = 0;
        if (blknum + (bp->b_bcount / fdblk) > nblocks) {
@@ -1445,9 +1446,9 @@ fdstrategy(struct buf *bp)
                        goto bad;
                }
        }
-       bp->b_pblkno = bp->b_blkno;
        crit_enter();
-       bufqdisksort(&fdc->head, bp);
+       bio->bio_driver_info = dev;
+       bioqdisksort(&fdc->bio_queue, bio);
        callout_stop(&fd->toffhandle);
 
        /* Tell devstat we are starting on the transaction */
@@ -1459,7 +1460,7 @@ fdstrategy(struct buf *bp)
        return;
 
 bad:
-       biodone(bp);
+       biodone(bio);
 }
 
 /***************************************************************\
@@ -1575,19 +1576,21 @@ fdstate(fdc_p fdc)
        unsigned blknum = 0, b_cylinder = 0;
        fdu_t fdu = fdc->fdu;
        fd_p fd;
+       struct bio *bio;
        struct buf *bp;
        struct fd_formb *finfo = NULL;
        size_t fdblk;
-
-       bp = fdc->bp;
-       if (bp == NULL) {
-               bp = bufq_first(&fdc->head);
-               if (bp != NULL) {
-                       bufq_remove(&fdc->head, bp);
-                       fdc->bp = bp;
+       dev_t dev;
+
+       bio = fdc->bio;
+       if (bio == NULL) {
+               bio = bioq_first(&fdc->bio_queue);
+               if (bio != NULL) {
+                       bioq_remove(&fdc->bio_queue, bio);
+                       fdc->bio = bio;
                }
        }
-       if (bp == NULL) {
+       if (bio == NULL) {
                /***********************************************\
                * nothing left for this controller to do        *
                * Force into the IDLE state,                    *
@@ -1602,7 +1605,10 @@ fdstate(fdc_p fdc)
                TRACE1("[fdc%d IDLE]", fdc->fdcu);
                return (0);
        }
-       fdu = FDUNIT(minor(bp->b_dev));
+       bp = bio->bio_buf;
+       dev = bio->bio_driver_info;
+
+       fdu = FDUNIT(minor(dev));
        fd = devclass_get_softc(fd_devclass, fdu);
        fdblk = 128 << fd->ft->secsize;
        if (fdc->fd && (fd != fdc->fd))
@@ -1615,7 +1621,7 @@ fdstate(fdc_p fdc)
                        - (char *)finfo;
        }
        if (fdc->state == DOSEEK || fdc->state == SEEKCOMPLETE) {
-               blknum = (unsigned) bp->b_pblkno * DEV_BSIZE/fdblk +
+               blknum = (unsigned) bio->bio_blkno * DEV_BSIZE/fdblk +
                        fd->skip/fdblk;
                b_cylinder = blknum / (fd->ft->sectrac * fd->ft->heads);
        }
@@ -1958,10 +1964,10 @@ fdstate(fdc_p fdc)
                } else {
                        /* ALL DONE */
                        fd->skip = 0;
-                       fdc->bp = NULL;
+                       fdc->bio = NULL;
                        device_unbusy(fd->dev);
                        devstat_end_transaction_buf(&fd->device_stats, bp);
-                       biodone(bp);
+                       biodone(bio);
                        fdc->fd = (fd_p) 0;
                        fdc->fdu = -1;
                        fdc->state = FINDWORK;
@@ -2071,14 +2077,18 @@ fdstate(fdc_p fdc)
 static int
 retrier(struct fdc_data *fdc)
 {
+       struct bio *bio;
        struct buf *bp;
        struct fd_data *fd;
+       dev_t dev;
        int fdu;
 
-       bp = fdc->bp;
+       bio = fdc->bio;
+       bp = bio->bio_buf;
+       dev = bio->bio_driver_info;
 
        /* XXX shouldn't this be cached somewhere?  */
-       fdu = FDUNIT(minor(bp->b_dev));
+       fdu = FDUNIT(minor(dev));
        fd = devclass_get_softc(fd_devclass, fdu);
        if (fd->options & FDOPT_NORETRY)
                goto fail;
@@ -2107,9 +2117,9 @@ retrier(struct fdc_data *fdc)
                                 */
                                dev_t subdev;
 
-                               subdev = make_sub_dev(bp->b_dev,
-                                   (FDUNIT(minor(bp->b_dev))<<3)|RAW_PART);
-                               diskerr(bp, subdev,
+                               subdev = make_sub_dev(dev,
+                                   (FDUNIT(minor(dev))<<3)|RAW_PART);
+                               diskerr(bio, subdev,
                                        "hard error", LOG_PRINTF,
                                        fdc->fd->skip / DEV_BSIZE,
                                        (struct disklabel *)NULL);
@@ -2130,11 +2140,11 @@ retrier(struct fdc_data *fdc)
                bp->b_flags |= B_ERROR;
                bp->b_error = EIO;
                bp->b_resid += bp->b_bcount - fdc->fd->skip;
-               fdc->bp = NULL;
+               fdc->bio = NULL;
                fdc->fd->skip = 0;
                device_unbusy(fd->dev);
                devstat_end_transaction_buf(&fdc->fd->device_stats, bp);
-               biodone(bp);
+               biodone(bio);
                fdc->state = FINDWORK;
                fdc->flags |= FDC_NEEDS_RESET;
                fdc->fd = (fd_p) 0;
@@ -2162,26 +2172,24 @@ fdformat(dev_t dev, struct fd_formb *finfo, struct thread *td)
        /* set up a buffer header for fdstrategy() */
        bp = malloc(sizeof(struct buf), M_TEMP, M_WAITOK | M_ZERO);
 
-       /*
-        * keep the process from being swapped
-        */
        BUF_LOCKINIT(bp);
        BUF_LOCK(bp, LK_EXCLUSIVE);
+       initbufbio(bp);
        bp->b_flags = B_PHYS | B_FORMAT;
 
        /*
         * calculate a fake blkno, so fdstrategy() would initiate a
         * seek to the requested cylinder
         */
-       bp->b_blkno = (finfo->cyl * (fd->ft->sectrac * fd->ft->heads)
+       bp->b_bio1.bio_blkno = (finfo->cyl * (fd->ft->sectrac * fd->ft->heads)
                + finfo->head * fd->ft->sectrac) * fdblk / DEV_BSIZE;
+       bp->b_bio1.bio_driver_info = dev;
 
        bp->b_bcount = sizeof(struct fd_idfield_data) * finfo->fd_formb_nsecs;
        bp->b_data = (caddr_t)finfo;
 
        /* now do the format */
-       bp->b_dev = dev;
-       BUF_STRATEGY(bp, 0);
+       dev_dstrategy(dev, &bp->b_bio1);
 
        /* ...and wait for it to complete */
        crit_enter();
@@ -2196,7 +2204,7 @@ fdformat(dev_t dev, struct fd_formb *finfo, struct thread *td)
                /* timed out */
                rv = EIO;
                device_unbusy(fd->dev);
-               biodone(bp);
+               biodone(&bp->b_bio1);
        }
        if (bp->b_flags & B_ERROR)
                rv = bp->b_error;
index dd9a8e8..8c70dcf 100644 (file)
@@ -32,7 +32,7 @@
  *
  *     from:   @(#)fd.c        7.4 (Berkeley) 5/25/91
  * $FreeBSD: src/sys/isa/fdc.h,v 1.20.2.3 2002/02/03 14:08:46 nyan Exp $
- * $DragonFly: src/sys/dev/disk/fd/fdc.h,v 1.5 2005/03/05 18:31:52 swildner Exp $
+ * $DragonFly: src/sys/dev/disk/fd/fdc.h,v 1.6 2006/02/17 19:17:57 dillon Exp $
  *
  */
 
@@ -65,8 +65,8 @@ struct fdc_data
        u_int   status[7];      /* copy of the registers */
        enum    fdc_type fdct;  /* chip version of FDC */
        int     fdc_errs;       /* number of logged errors */
-       struct  buf_queue_head head;
-       struct  buf *bp;        /* active buffer */
+       struct  bio_queue_head bio_queue;
+       struct  bio *bio;       /* active buffer */
        int     dma_overruns;   /* number of DMA overruns */
        struct  resource *res_ioport, *res_ctl, *res_irq, *res_drq;
        int     rid_ioport, rid_ctl, rid_irq, rid_drq;
index d1ef48a..3b93a24 100644 (file)
@@ -41,7 +41,7 @@
  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/i386/isa/mcd.c,v 1.115 2000/01/29 16:17:34 peter Exp $
- * $DragonFly: src/sys/dev/disk/mcd/Attic/mcd.c,v 1.14 2005/10/13 08:50:33 sephe Exp $
+ * $DragonFly: src/sys/dev/disk/mcd/Attic/mcd.c,v 1.15 2006/02/17 19:17:59 dillon Exp $
  */
 static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore";
 
@@ -120,7 +120,7 @@ struct mcd_mbx {
        short           nblk;
        int             sz;
        u_long          skip;
-       struct buf      *bp;
+       struct bio      *bio;
        int             p_offset;
        short           count;
        short           mode;
@@ -145,7 +145,7 @@ static struct mcd_data {
        short   curr_mode;
        struct mcd_read2 lastpb;
        short   debug;
-       struct buf_queue_head head;             /* head of buf queue */
+       struct bio_queue_head bio_queue;        /* head of buf queue */
        struct mcd_mbx mbx;
        struct callout callout;
 } mcd_data[NMCD];
@@ -253,7 +253,7 @@ int mcd_attach(struct isa_device *dev)
        cd->flags |= MCDINIT;
        callout_init(&cd->callout);
        mcd_soft_reset(unit);
-       bufq_init(&cd->head);
+       bioq_init(&cd->bio_queue);
 
 #ifdef NOTYET
        /* wire controller for interrupts and dma */
@@ -389,20 +389,22 @@ int mcdclose(dev_t dev, int flags, int fmt, struct thread *td)
 }
 
 void
-mcdstrategy(struct buf *bp)
+mcdstrategy(dev_t dev, struct bio *bio)
 {
+       struct bio *nbio;
+       struct buf *bp = bio->bio_buf;
        struct mcd_data *cd;
-
-       int unit = mcd_unit(bp->b_dev);
+       int unit = mcd_unit(dev);
 
        cd = mcd_data + unit;
+       bio->bio_driver_info = dev;
 
        /* test validity */
 /*MCD_TRACE("strategy: buf=0x%lx, unit=%ld, block#=%ld bcount=%ld\n",
-       bp,unit,bp->b_blkno,bp->b_bcount);*/
-       if (unit >= NMCD || bp->b_blkno < 0) {
+       bp,unit,bio->bio_blkno,bp->b_bcount);*/
+       if (unit >= NMCD || bio->bio_blkno < 0) {
                printf("mcdstrategy: unit = %d, blkno = %ld, bcount = %ld\n",
-                       unit, (long)bp->b_blkno, bp->b_bcount);
+                       unit, (long)bio->bio_blkno, bp->b_bcount);
                printf("mcd: mcdstratregy failure");
                bp->b_error = EINVAL;
                bp->b_flags |= B_ERROR;
@@ -427,34 +429,37 @@ MCD_TRACE("strategy: drive not valid\n");
                goto done;
 
        /* for non raw access, check partition limits */
-       if (mcd_part(bp->b_dev) != RAW_PART) {
+       if (mcd_part(dev) != RAW_PART) {
                if (!(cd->flags & MCDLABEL)) {
                        bp->b_error = EIO;
                        goto bad;
                }
                /* adjust transfer if necessary */
-               if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0) {
+               nbio = bounds_check_with_label(dev, bio, &cd->dlabel, 1);
+               if (nbio == NULL)
                        goto done;
-               }
        } else {
-               bp->b_pblkno = bp->b_blkno;
+               nbio = bio;
                bp->b_resid = 0;
        }
 
        /* queue it */
        crit_enter();
-       bufqdisksort(&cd->head, bp);
+       bioqdisksort(&cd->bio_queue, nbio);
        crit_exit();
 
        /* now check whether we can perform processing */
        mcd_start(unit);
        return;
 
+       /*
+        * These cases occur before nbio is set, use bio.
+        */
 bad:
        bp->b_flags |= B_ERROR;
 done:
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
+       biodone(bio);
        return;
 }
 
@@ -462,7 +467,9 @@ static void mcd_start(int unit)
 {
        struct mcd_data *cd = mcd_data + unit;
        struct partition *p;
+       struct bio *bio;
        struct buf *bp;
+       dev_t dev;
 
        crit_enter();
        if (cd->flags & MCDMBXBSY) {
@@ -470,17 +477,19 @@ static void mcd_start(int unit)
                return;
        }
 
-       bp = bufq_first(&cd->head);
-       if (bp != 0) {
-               /* block found to process, dequeue */
-               /*MCD_TRACE("mcd_start: found block bp=0x%x\n",bp,0,0,0);*/
-               bufq_remove(&cd->head, bp);
-               crit_exit();
-       } else {
+       bio = bioq_first(&cd->bio_queue);
+       if (bio == NULL) {
                /* nothing to do */
                crit_exit();
                return;
        }
+       bp = bio->bio_buf;
+       dev = bio->bio_driver_info;
+
+       /* block found to process, dequeue */
+       /*MCD_TRACE("mcd_start: found block bp=0x%x\n",bp,0,0,0);*/
+       bioq_remove(&cd->bio_queue, bio);
+       crit_exit();
 
        /* changed media? */
        if (!(cd->flags & MCDVALID)) {
@@ -488,15 +497,15 @@ static void mcd_start(int unit)
                return;
        }
 
-       p = cd->dlabel.d_partitions + mcd_part(bp->b_dev);
+       p = cd->dlabel.d_partitions + mcd_part(dev);
 
        cd->flags |= MCDMBXBSY;
-       if (cd->partflags[mcd_part(bp->b_dev)] & MCDREADRAW)
+       if (cd->partflags[mcd_part(dev)] & MCDREADRAW)
                cd->flags |= MCDREADRAW;
        cd->mbx.unit = unit;
        cd->mbx.port = cd->iobase;
        cd->mbx.retry = MCD_RETRYS;
-       cd->mbx.bp = bp;
+       cd->mbx.bio = bio;
        cd->mbx.p_offset = p->p_offset;
 
        /* calling the read routine */
@@ -991,7 +1000,8 @@ mcd_doread(int state, struct mcd_mbx *mbxin)
        int     port = mbx->port;
        int     com_port = mbx->port + mcd_command;
        int     data_port = mbx->port + mcd_rdata;
-       struct  buf *bp = mbx->bp;
+       struct  bio *bio = mbx->bio;
+       struct  buf *bp = bio->bio_buf;
        struct  mcd_data *cd = mcd_data + unit;
 
        int     rm,i,k;
@@ -1089,7 +1099,7 @@ modedone:
                mbx->skip = 0;
 
 nextblock:
-               blknum  = (bp->b_blkno / (mbx->sz/DEV_BSIZE))
+               blknum  = (bio->bio_blkno / (mbx->sz/DEV_BSIZE))
                        + mbx->p_offset + mbx->skip/mbx->sz;
 
                MCD_TRACE("mcd_doread: read blknum=%d for bp=%p\n",
@@ -1153,7 +1163,7 @@ retry_read:
 
                                /* return buffer */
                                bp->b_resid = 0;
-                               biodone(bp);
+                               biodone(bio);
 
                                cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
                                mcd_start(mbx->unit);
@@ -1185,7 +1195,7 @@ harderr:
        /* invalidate the buffer */
        bp->b_flags |= B_ERROR;
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
+       biodone(bio);
 
        cd->flags &= ~(MCDMBXBSY|MCDREADRAW);
        mcd_start(mbx->unit);
index 737787d..64a938e 100644 (file)
@@ -7,7 +7,7 @@
  * ----------------------------------------------------------------------------
  *
  * $FreeBSD: src/sys/dev/md/md.c,v 1.8.2.2 2002/08/19 17:43:34 jdp Exp $
- * $DragonFly: src/sys/dev/disk/md/md.c,v 1.8 2005/06/06 22:51:54 corecode Exp $
+ * $DragonFly: src/sys/dev/disk/md/md.c,v 1.9 2006/02/17 19:18:00 dillon Exp $
  *
  */
 
@@ -88,7 +88,7 @@ static struct cdevsw md_cdevsw = {
 struct md_s {
        int unit;
        struct devstat stats;
-       struct buf_queue_head buf_queue;
+       struct bio_queue_head bio_queue;
        struct disk disk;
        dev_t dev;
        int busy;
@@ -143,44 +143,46 @@ mdioctl(dev_t dev, u_long cmd, caddr_t addr, int flags, struct thread *td)
 }
 
 static void
-mdstrategy(struct buf *bp)
+mdstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct md_s *sc;
 
-       if (md_debug > 1)
+       if (md_debug > 1) {
                printf("mdstrategy(%p) %s %lx, %d, %ld, %p)\n",
-                   bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, 
+                   bp, devtoname(dev), bp->b_flags, bio->bio_blkno, 
                    bp->b_bcount / DEV_BSIZE, bp->b_data);
-
-       sc = bp->b_dev->si_drv1;
+       }
+       bio->bio_driver_info = dev;
+       sc = dev->si_drv1;
        if (sc->type == MD_MALLOC) {
-               mdstrategy_malloc(bp);
+               mdstrategy_malloc(dev, bio);
        } else {
-               mdstrategy_preload(bp);
+               mdstrategy_preload(dev, bio);
        }
-       return;
 }
 
 
 static void
-mdstrategy_malloc(struct buf *bp)
+mdstrategy_malloc(dev_t dev, struct bio *bio)
 {
-       int i;
-       struct md_s *sc;
-       devstat_trans_flags dop;
-       u_char *secp, **secpp, *dst;
+       struct buf *bp = bio->bio_buf;
        unsigned secno, nsec, secval, uc;
+       u_char *secp, **secpp, *dst;
+       devstat_trans_flags dop;
+       struct md_s *sc;
+       int i;
 
        if (md_debug > 1)
                printf("mdstrategy_malloc(%p) %s %lx, %d, %ld, %p)\n",
-                   bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, 
+                   bp, devtoname(dev), bp->b_flags, bio->bio_blkno, 
                    bp->b_bcount / DEV_BSIZE, bp->b_data);
 
-       sc = bp->b_dev->si_drv1;
+       sc = dev->si_drv1;
 
        crit_enter();
 
-       bufqdisksort(&sc->buf_queue, bp);
+       bioqdisksort(&sc->bio_queue, bio);
 
        if (sc->busy) {
                crit_exit();
@@ -190,11 +192,11 @@ mdstrategy_malloc(struct buf *bp)
        sc->busy++;
        
        while (1) {
-               bp = bufq_first(&sc->buf_queue);
+               bio = bioq_first(&sc->bio_queue);
                if (bp)
-                       bufq_remove(&sc->buf_queue, bp);
+                       bioq_remove(&sc->bio_queue, bio);
                crit_exit();
-               if (!bp)
+               if (bio == NULL)
                        break;
 
                devstat_start_transaction(&sc->stats);
@@ -207,10 +209,9 @@ mdstrategy_malloc(struct buf *bp)
                        dop = DEVSTAT_WRITE;
 
                nsec = bp->b_bcount / DEV_BSIZE;
-               secno = bp->b_pblkno;
+               secno = bio->bio_blkno;
                dst = bp->b_data;
                while (nsec--) {
-
                        if (secno < sc->nsecp) {
                                secpp = &sc->secp[secno];
                                if ((u_int)*secpp > 255) {
@@ -281,30 +282,30 @@ mdstrategy_malloc(struct buf *bp)
                }
                bp->b_resid = 0;
                devstat_end_transaction_buf(&sc->stats, bp);
-               biodone(bp);
+               biodone(bio);
                crit_enter();
        }
        sc->busy = 0;
-       return;
 }
 
 
 static void
-mdstrategy_preload(struct buf *bp)
+mdstrategy_preload(dev_t dev, struct bio *bio)
 {
-       struct md_s *sc;
+       struct buf *bp = bio->bio_buf;
        devstat_trans_flags dop;
+       struct md_s *sc;
 
        if (md_debug > 1)
                printf("mdstrategy_preload(%p) %s %lx, %d, %ld, %p)\n",
-                   bp, devtoname(bp->b_dev), bp->b_flags, bp->b_blkno, 
+                   bp, devtoname(dev), bp->b_flags, bio->bio_blkno, 
                    bp->b_bcount / DEV_BSIZE, bp->b_data);
 
-       sc = bp->b_dev->si_drv1;
+       sc = dev->si_drv1;
 
        crit_enter();
 
-       bufqdisksort(&sc->buf_queue, bp);
+       bioqdisksort(&sc->bio_queue, bio);
 
        if (sc->busy) {
                crit_exit();
@@ -314,11 +315,11 @@ mdstrategy_preload(struct buf *bp)
        sc->busy++;
        
        while (1) {
-               bp = bufq_first(&sc->buf_queue);
-               if (bp)
-                       bufq_remove(&sc->buf_queue, bp);
+               bio = bioq_first(&sc->bio_queue);
+               if (bio)
+                       bioq_remove(&sc->bio_queue, bio);
                crit_exit();
-               if (!bp)
+               if (bio == NULL)
                        break;
 
                devstat_start_transaction(&sc->stats);
@@ -327,18 +328,17 @@ mdstrategy_preload(struct buf *bp)
                        dop = DEVSTAT_NO_DATA;
                } else if (bp->b_flags & B_READ) {
                        dop = DEVSTAT_READ;
-                       bcopy(sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_data, bp->b_bcount);
+                       bcopy(sc->pl_ptr + (bio->bio_blkno << DEV_BSHIFT), bp->b_data, bp->b_bcount);
                } else {
                        dop = DEVSTAT_WRITE;
-                       bcopy(bp->b_data, sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_bcount);
+                       bcopy(bp->b_data, sc->pl_ptr + (bio->bio_blkno << DEV_BSHIFT), bp->b_bcount);
                }
                bp->b_resid = 0;
                devstat_end_transaction_buf(&sc->stats, bp);
-               biodone(bp);
+               biodone(bio);
                crit_enter();
        }
        sc->busy = 0;
-       return;
 }
 
 static struct md_s *
@@ -349,7 +349,7 @@ mdcreate(void)
        MALLOC(sc, struct md_s *,sizeof(*sc), M_MD, M_WAITOK);
        bzero(sc, sizeof(*sc));
        sc->unit = mdunits++;
-       bufq_init(&sc->buf_queue);
+       bioq_init(&sc->bio_queue);
        devstat_add_entry(&sc->stats, "md", sc->unit, DEV_BSIZE,
                DEVSTAT_NO_ORDERED_TAGS, 
                DEVSTAT_TYPE_DIRECT | DEVSTAT_TYPE_IF_OTHER,
index 7e4cbbd..c2920df 100644 (file)
@@ -42,7 +42,7 @@
 
 
 /* $FreeBSD: src/sys/i386/isa/scd.c,v 1.54 2000/01/29 16:00:30 peter Exp $ */
-/* $DragonFly: src/sys/dev/disk/scd/Attic/scd.c,v 1.13 2005/06/06 21:48:16 eirikn Exp $ */
+/* $DragonFly: src/sys/dev/disk/scd/Attic/scd.c,v 1.14 2006/02/17 19:18:01 dillon Exp $ */
 
 /* Please send any comments to micke@dynas.se */
 
@@ -107,7 +107,7 @@ struct scd_mbx {
        short           nblk;
        int             sz;
        u_long          skip;
-       struct buf      *bp;
+       struct bio      *bio;
        int             p_offset;
        short           count;
 };
@@ -131,7 +131,7 @@ static struct scd_data {
        struct  ioc_play_msf last_play;
 
        short   audio_status;
-       struct buf_queue_head head;             /* head of buf queue */
+       struct bio_queue_head bio_queue;        /* head of bio queue */
        struct scd_mbx mbx;
        struct callout callout;
 } scd_data[NSCD];
@@ -217,7 +217,7 @@ scd_attach(struct isa_device *dev)
 
        cd->flags = SCDINIT;
        cd->audio_status = CD_AS_AUDIO_INVALID;
-       bufq_init(&cd->head);
+       bioq_init(&cd->bio_queue);
 
        cdevsw_add(&scd_cdevsw, dkunitmask(), dkmakeunit(unit));
        make_dev(&scd_cdevsw, dkmakeminor(unit, 0, 0),
@@ -315,19 +315,21 @@ scdclose(dev_t dev, int flags, int fmt, struct thread *td)
 }
 
 static void
-scdstrategy(struct buf *bp)
+scdstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
+       struct bio *nbio;
        struct scd_data *cd;
-       int unit = scd_unit(bp->b_dev);
+       int unit = scd_unit(dev);
 
        cd = scd_data + unit;
 
        XDEBUG(2, ("scd%d: DEBUG: strategy: block=%ld, bcount=%ld\n",
-               unit, (long)bp->b_blkno, bp->b_bcount));
+               unit, (long)bio->bio_blkno, bp->b_bcount));
 
-       if (unit >= NSCD || bp->b_blkno < 0 || (bp->b_bcount % SCDBLKSIZE)) {
+       if (unit >= NSCD || bio->bio_blkno < 0 || (bp->b_bcount % SCDBLKSIZE)) {
                printf("scd%d: strategy failure: blkno = %ld, bcount = %ld\n",
-                       unit, (long)bp->b_blkno, bp->b_bcount);
+                       unit, (long)bio->bio_blkno, bp->b_bcount);
                bp->b_error = EINVAL;
                bp->b_flags |= B_ERROR;
                goto bad;
@@ -355,15 +357,16 @@ scdstrategy(struct buf *bp)
                goto bad;
        }
        /* adjust transfer if necessary */
-       if (bounds_check_with_label(bp,&cd->dlabel,1) <= 0)
+       nbio = bounds_check_with_label(dev, bio, &cd->dlabel, 1);
+       if (nbio == NULL)
                goto done;
 
-       bp->b_pblkno = bp->b_blkno;
+       nbio->bio_driver_info = dev;
        bp->b_resid = 0;
 
        /* queue it */
        crit_enter();
-       bufqdisksort(&cd->head, bp);
+       bioqdisksort(&cd->bio_queue, nbio);
        crit_exit();
 
        /* now check whether we can perform processing */
@@ -374,16 +377,16 @@ bad:
        bp->b_flags |= B_ERROR;
 done:
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
-       return;
+       biodone(bio);
 }
 
 static void
 scd_start(int unit)
 {
        struct scd_data *cd = scd_data + unit;
-       struct buf *bp;
+       struct bio *bio;
        struct partition *p;
+       dev_t dev;
 
        crit_enter();
        if (cd->flags & SCDMBXBSY) {
@@ -391,23 +394,23 @@ scd_start(int unit)
                return;
        }
 
-       bp = bufq_first(&cd->head);
-       if (bp != 0) {
-               /* block found to process, dequeue */
-               bufq_remove(&cd->head, bp);
-               cd->flags |= SCDMBXBSY;
-       } else {
+       bio = bioq_first(&cd->bio_queue);
+       if (bio == NULL) {
                /* nothing to do */
                crit_exit();
                return;
        }
+       /* block found to process, dequeue */
+       bioq_remove(&cd->bio_queue, bio);
+       cd->flags |= SCDMBXBSY;
+       dev = bio->bio_driver_info;
 
-       p = cd->dlabel.d_partitions + scd_part(bp->b_dev);
+       p = cd->dlabel.d_partitions + scd_part(dev);
 
        cd->mbx.unit = unit;
        cd->mbx.port = cd->iobase;
        cd->mbx.retry = 3;
-       cd->mbx.bp = bp;
+       cd->mbx.bio = bio;
        cd->mbx.p_offset = p->p_offset;
        crit_exit();
 
@@ -792,7 +795,8 @@ scd_doread(int state, struct scd_mbx *mbxin)
        struct scd_mbx *mbx = (state!=SCD_S_BEGIN) ? mbxsave : mbxin;
        int     unit = mbx->unit;
        int     port = mbx->port;
-       struct  buf *bp = mbx->bp;
+       struct  bio *bio = mbx->bio;
+       struct  buf *bp = bio->bio_buf;
        struct  scd_data *cd = scd_data + unit;
        int     reg,i;
        int     blknum;
@@ -843,7 +847,7 @@ nextblock:
                if (!(cd->flags & SCDVALID))
                        goto changed;
 
-               blknum  = (bp->b_blkno / (mbx->sz/DEV_BSIZE))
+               blknum  = (bio->bio_blkno / (mbx->sz/DEV_BSIZE))
                        + mbx->p_offset + mbx->skip/mbx->sz;
 
                XDEBUG(2, ("scd%d: scd_doread: read blknum=%d\n", unit, blknum));
@@ -1026,7 +1030,7 @@ got_param:
 
                /* return buffer */
                bp->b_resid = 0;
-               biodone(bp);
+               biodone(bio);
 
                cd->flags &= ~SCDMBXBSY;
                scd_start(mbx->unit);
@@ -1044,7 +1048,7 @@ harderr:
        bp->b_error = EIO;
        bp->b_flags |= B_ERROR;
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
+       biodone(bio);
 
        cd->flags &= ~SCDMBXBSY;
        scd_start(mbx->unit);
index a9ba6f9..7a55443 100644 (file)
@@ -39,7 +39,7 @@
  *
  *     from: @(#)vn.c  8.6 (Berkeley) 4/1/94
  * $FreeBSD: src/sys/dev/vn/vn.c,v 1.105.2.4 2001/11/18 07:11:00 dillon Exp $
- * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.15 2005/12/11 01:54:08 swildner Exp $
+ * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.16 2006/02/17 19:18:02 dillon Exp $
  */
 
 /*
@@ -123,12 +123,6 @@ static struct cdevsw vn_cdevsw = {
        /* psize */     vnsize
 };
 
-#define        getvnbuf()      \
-       ((struct buf *)malloc(sizeof(struct buf), M_DEVBUF, M_WAITOK))
-
-#define putvnbuf(bp)   \
-       free((caddr_t)(bp), M_DEVBUF)
-
 struct vn_softc {
        int             sc_unit;
        int             sc_flags;       /* flags                        */
@@ -285,20 +279,24 @@ vnopen(dev_t dev, int flags, int mode, struct thread *td)
  *
  *     Currently B_ASYNC is only partially handled - for OBJT_SWAP I/O only.
  *
- *     NOTE: bp->b_blkno is DEV_BSIZE'd.  We must generate bp->b_pblkno for
- *     our uio or vn_pager_strategy() call that is vn->sc_secsize'd
+ *     NOTE: bio->bio_blkno is DEV_BSIZE'd.  We must generate a new bio
+ *     with a secsize'd blkno.
  */
 
 static void
-vnstrategy(struct buf *bp)
+vnstrategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp;
+       struct bio *nbio;
        int unit;
        struct vn_softc *vn;
        int error;
 
-       unit = dkunit(bp->b_dev);
-       if ((vn = bp->b_dev->si_drv1) == NULL)
-               vn = vnfindvn(bp->b_dev);
+       unit = dkunit(dev);
+       if ((vn = dev->si_drv1) == NULL)
+               vn = vnfindvn(dev);
+
+       bp = bio->bio_buf;
 
        IFOPT(vn, VN_DEBUG)
                printf("vnstrategy(%p): unit %d\n", bp, unit);
@@ -306,7 +304,7 @@ vnstrategy(struct buf *bp)
        if ((vn->sc_flags & VNF_INITED) == 0) {
                bp->b_error = ENXIO;
                bp->b_flags |= B_ERROR;
-               biodone(bp);
+               biodone(bio);
                return;
        }
 
@@ -320,9 +318,11 @@ vnstrategy(struct buf *bp)
                 * slices that exist ON the vnode device itself, and
                 * translate the "slice-relative" block number, again.
                 */
-               if (vn->sc_slices != NULL && dscheck(bp, vn->sc_slices) <= 0) {
+               if (vn->sc_slices == NULL) {
+                       nbio = bio;
+               } else if ((nbio = dscheck(dev, bio, vn->sc_slices)) == NULL) {
                        bp->b_flags |= B_INVAL;
-                       biodone(bp);
+                       biodone(bio);
                        return;
                }
        } else {
@@ -334,14 +334,14 @@ vnstrategy(struct buf *bp)
                 * multiple of the sector size.
                 */
                if (bp->b_bcount % vn->sc_secsize != 0 ||
-                   bp->b_blkno % (vn->sc_secsize / DEV_BSIZE) != 0) {
+                   bio->bio_blkno % (vn->sc_secsize / DEV_BSIZE) != 0) {
                        bp->b_error = EINVAL;
                        bp->b_flags |= B_ERROR | B_INVAL;
-                       biodone(bp);
+                       biodone(bio);
                        return;
                }
 
-               pbn = bp->b_blkno / (vn->sc_secsize / DEV_BSIZE);
+               pbn = bio->bio_blkno / (vn->sc_secsize / DEV_BSIZE);
                sz = howmany(bp->b_bcount, vn->sc_secsize);
 
                /*
@@ -353,7 +353,7 @@ vnstrategy(struct buf *bp)
                                bp->b_error = EINVAL;
                                bp->b_flags |= B_ERROR | B_INVAL;
                        }
-                       biodone(bp);
+                       biodone(bio);
                        return;
                }
 
@@ -364,14 +364,18 @@ vnstrategy(struct buf *bp)
                        bp->b_bcount = (vn->sc_size - pbn) * vn->sc_secsize;
                        bp->b_resid = bp->b_bcount;
                }
-               bp->b_pblkno = pbn;
+               nbio = push_bio(bio);
+               nbio->bio_blkno = pbn;
        }
 
+       /*
+        * Use the translated nbio from this point on
+        */
        if (vn->sc_vp && (bp->b_flags & B_FREEBUF)) {
                /*
                 * Not handled for vnode-backed element yet.
                 */
-               biodone(bp);
+               biodone(nbio);
        } else if (vn->sc_vp) {
                /*
                 * VNODE I/O
@@ -389,9 +393,9 @@ vnstrategy(struct buf *bp)
                aiov.iov_len = bp->b_bcount;
                auio.uio_iov = &aiov;
                auio.uio_iovcnt = 1;
-               auio.uio_offset = (vm_ooffset_t)bp->b_pblkno * vn->sc_secsize;
+               auio.uio_offset = (vm_ooffset_t)nbio->bio_blkno * vn->sc_secsize;
                auio.uio_segflg = UIO_SYSSPACE;
-               ifbp->b_flags & B_READ)
+               if (bp->b_flags & B_READ)
                        auio.uio_rw = UIO_READ;
                else
                        auio.uio_rw = UIO_WRITE;
@@ -409,7 +413,7 @@ vnstrategy(struct buf *bp)
                        bp->b_error = error;
                        bp->b_flags |= B_ERROR;
                }
-               biodone(bp);
+               biodone(nbio);
        } else if (vn->sc_object) {
                /*
                 * OBJT_SWAP I/O
@@ -422,14 +426,14 @@ vnstrategy(struct buf *bp)
                    ("vnstrategy: buffer %p too small for physio", bp));
 
                if ((bp->b_flags & B_FREEBUF) && TESTOPT(vn, VN_RESERVE)) {
-                       biodone(bp);
+                       biodone(nbio);
                } else {
-                       vm_pager_strategy(vn->sc_object, bp);
+                       vm_pager_strategy(vn->sc_object, nbio);
                }
        } else {
                bp->b_flags |= B_ERROR;
                bp->b_error = EINVAL;
-               biodone(bp);
+               biodone(nbio);
        }
 }
 
index a9f6f9d..ed433a4 100644 (file)
@@ -21,7 +21,7 @@
  *
  * Version 1.3, Thu Nov 11 12:09:13 MSK 1993
  * $FreeBSD: src/sys/i386/isa/wt.c,v 1.57.2.1 2000/08/08 19:49:53 peter Exp $
- * $DragonFly: src/sys/dev/disk/wt/wt.c,v 1.12 2005/10/13 08:50:33 sephe Exp $
+ * $DragonFly: src/sys/dev/disk/wt/wt.c,v 1.13 2006/02/17 19:18:05 dillon Exp $
  *
  */
 
@@ -507,9 +507,10 @@ wtioctl (dev_t dev, u_long cmd, caddr_t arg, int flags, struct thread *td)
  * Strategy routine.
  */
 static void
-wtstrategy (struct buf *bp)
+wtstrategy (dev_t dev, struct bio *bio)
 {
-       int u = minor (bp->b_dev) & T_UNIT;
+       struct buf *bp = bio->bio_buf;
+       int u = minor(dev) & T_UNIT;
        wtinfo_t *t = wttab + u;
 
        bp->b_resid = bp->b_bcount;
@@ -576,7 +577,7 @@ wtstrategy (struct buf *bp)
 errxit:                bp->b_error = EIO;
 err2xit:       bp->b_flags |= B_ERROR;
        }
-xit:    biodone (bp);
+xit:    biodone (bio);
        return;
 }
 
index 61492bd..1e93d69 100644 (file)
@@ -39,7 +39,7 @@
  * dufault@hda.com
  *
  * $FreeBSD: src/sys/i386/isa/labpc.c,v 1.35 1999/09/25 18:24:08 phk Exp $
- * $DragonFly: src/sys/dev/misc/labpc/labpc.c,v 1.14 2005/10/13 08:50:33 sephe Exp $
+ * $DragonFly: src/sys/dev/misc/labpc/labpc.c,v 1.15 2006/02/17 19:18:05 dillon Exp $
  *
  */
 
@@ -52,7 +52,7 @@
 #include <sys/kernel.h>
 #include <sys/malloc.h>
 #include <sys/buf.h>
-#define b_actf b_act.tqe_next
+#define bio_actf       bio_act.tqe_next
 #include <sys/dataacq.h>
 #include <sys/conf.h>
 #include <sys/thread2.h>
@@ -124,8 +124,9 @@ struct ctlr
 
        u_short sample_us;
 
-       struct buf start_queue; /* Start queue */
-       struct buf *last;       /* End of start queue */
+       struct bio start_queue; /* Start queue */
+       struct bio *last;       /* End of start queue */
+       int count;
        u_char *data;
        u_char *data_end;
        long tmo;                       /* Timeout in Hertz */
@@ -312,29 +313,28 @@ static void labpcintr(void *);
 static void start(struct ctlr *ctlr);
 
 static void
-bp_done(struct buf *bp, int err)
+bp_done(struct bio *bio, int err)
 {
-       bp->b_error = err;
+       struct buf *bp = bio->bio_buf;
 
        if (err || bp->b_resid)
-       {
                bp->b_flags |= B_ERROR;
-       }
-
-       biodone(bp);
+       biodone(bio);
 }
 
 static void tmo_stop(void *p);
 
 static void
-done_and_start_next(struct ctlr *ctlr, struct buf *bp, int err)
+done_and_start_next(struct ctlr *ctlr, struct bio *bio, int err)
 {
+       struct buf *bp = bio->bio_buf;
+
        bp->b_resid = ctlr->data_end - ctlr->data;
 
        ctlr->data = 0;
 
-       ctlr->start_queue.b_actf = bp->b_actf;
-       bp_done(bp, err);
+       ctlr->start_queue.bio_actf = bio->bio_actf;
+       bp_done(bio, err);
 
        callout_stop(&ctlr->ch);
 
@@ -592,7 +592,7 @@ static void
 tmo_stop(void *p)
 {
        struct ctlr *ctlr = (struct ctlr *)p;
-       struct buf *bp;
+       struct bio *bio;
 
        crit_enter();
 
@@ -607,9 +607,9 @@ tmo_stop(void *p)
 
        (*ctlr->stop)(ctlr);
 
-       bp = ctlr->start_queue.b_actf;
+       bio = ctlr->start_queue.bio_actf;
 
-       if (bp == 0) {
+       if (bio == NULL) {
                printf(", Null bp.\n");
                crit_exit();
                return;
@@ -617,7 +617,7 @@ tmo_stop(void *p)
 
        printf("\n");
 
-       done_and_start_next(ctlr, bp, ETIMEDOUT);
+       done_and_start_next(ctlr, bio, ETIMEDOUT);
 
        crit_exit();
 }
@@ -643,10 +643,10 @@ static void ad_intr(struct ctlr *ctlr)
        {
                if ((status & (OVERRUN|OVERFLOW)))
                {
-                       struct buf *bp = ctlr->start_queue.b_actf;
+                       struct bio *bio = ctlr->start_queue.bio_actf;
 
                        printf("ad_intr: error: bp %p, data %p, status %x",
-                           (void *)bp, (void *)ctlr->data, status);
+                           bio->bio_buf, ctlr->data, status);
 
                        if (status & OVERRUN)
                                printf(" Conversion overrun (multiple A-D trigger)");
@@ -656,13 +656,10 @@ static void ad_intr(struct ctlr *ctlr)
 
                        printf("\n");
 
-                       if (bp)
-                       {
-                               done_and_start_next(ctlr, bp, EIO);
+                       if (bio) {
+                               done_and_start_next(ctlr, bio, EIO);
                                return;
-                       }
-                       else
-                       {
+                       } else {
                                printf("ad_intr: (should not happen) error between records\n");
                                ctlr->err = status;     /* Set overrun condition */
                                return;
@@ -670,25 +667,22 @@ static void ad_intr(struct ctlr *ctlr)
                }
                else    /* FIFO interrupt */
                {
-                       struct buf *bp = ctlr->start_queue.b_actf;
+                       struct bio *bio = ctlr->start_queue.bio_actf;
 
-                       if (ctlr->data)
-                       {
+                       if (ctlr->data) {
                                *ctlr->data++ = inb(ADFIFO(ctlr));
-                               if (ctlr->data == ctlr->data_end)       /* Normal completion */
-                               {
-                                       done_and_start_next(ctlr, bp, 0);
+                               if (ctlr->data == ctlr->data_end) {
+                                       /* Normal completion */
+                                       done_and_start_next(ctlr, bio, 0);
                                        return;
                                }
-                       }
-                       else    /* Interrupt with no where to put the data.  */
-                       {
+                       } else {
+                               /* Interrupt with no where to put the data.  */
                                printf("ad_intr: (should not happen) dropped input.\n");
                                (void)inb(ADFIFO(ctlr));
 
                                printf("bp %p, status %x, cr3 %x\n",
-                                   (void *)bp, status, ctlr->cr_image[2]);
-
+                                   bio->bio_buf, status, ctlr->cr_image[2]);
                                ctlr->err = DROPPED_INPUT;
                                return;
                        }
@@ -770,19 +764,20 @@ labpcclose(dev_t dev, int flags, int fmt, struct thread *td)
 static void
 start(struct ctlr *ctlr)
 {
+       struct bio *bio;
        struct buf *bp;
 
-       if ((bp = ctlr->start_queue.b_actf) == 0)
-       {
+       if ((bio = ctlr->start_queue.bio_actf) == NULL) {
                /* We must turn off FIFO interrupts when there is no
                 * place to put the data.  We have to get back to
                 * reading before the FIFO overflows.
                 */
                CR_EXPR(ctlr, 3, &= ~(FIFOINTEN|ERRINTEN));
                ctlr->cleared_intr = 1;
-               ctlr->start_queue.b_bcount = 0;
+               ctlr->count = 0;
                return;
        }
+       bp = bio->bio_buf;
 
        ctlr->data = (u_char *)bp->b_data;
        ctlr->data_end = ctlr->data + bp->b_bcount;
@@ -790,18 +785,17 @@ start(struct ctlr *ctlr)
        if (ctlr->err)
        {
                printf("labpc start: (should not happen) error between records.\n");
-               done_and_start_next(ctlr, bp, EIO);
+               done_and_start_next(ctlr, bio, EIO);
                return;
        }
 
        if (ctlr->data == 0)
        {
                printf("labpc start: (should not happen) NULL data pointer.\n");
-               done_and_start_next(ctlr, bp, EIO);
+               done_and_start_next(ctlr, bio, EIO);
                return;
        }
 
-
        (*ctlr->starter)(ctlr, bp->b_bcount);
 
        if (!FIFOINTENABLED(ctlr))      /* We can store the data again */
@@ -817,21 +811,18 @@ start(struct ctlr *ctlr)
 }
 
 static void
-ad_strategy(struct buf *bp, struct ctlr *ctlr)
+ad_strategy(struct bio *bio, struct ctlr *ctlr)
 {
        crit_enter();
-       bp->b_actf = NULL;
-
-       if (ctlr->start_queue.b_bcount)
-       {
-               ctlr->last->b_actf = bp;
-               ctlr->last = bp;
-       }
-       else
-       {
-               ctlr->start_queue.b_bcount = 1;
-               ctlr->start_queue.b_actf = bp;
-               ctlr->last = bp;
+       bio->bio_actf = NULL;
+
+       if (ctlr->count) {
+               ctlr->last->bio_actf = bio;
+               ctlr->last = bio;
+       } else {
+               ctlr->count = 1;
+               ctlr->start_queue.bio_actf = bio;
+               ctlr->last = bio;
                start(ctlr);
        }
        crit_exit();
@@ -850,14 +841,16 @@ ad_strategy(struct buf *bp, struct ctlr *ctlr)
  * 2. No interrupt support yet.
  */
 static void
-da_strategy(struct buf *bp, struct ctlr *ctlr)
+da_strategy(struct bio *bio, struct ctlr *ctlr)
 {
+       struct buf *bp = bio->bio_buf;
+       dev_t dev = bio->bio_driver_info;
        int len;
        u_char *data;
        int port;
        int i;
 
-       switch(CHAN(bp->b_dev))
+       switch(CHAN(dev))
        {
                case 0:
                        port = DAC0L(ctlr);
@@ -886,18 +879,18 @@ da_strategy(struct buf *bp, struct ctlr *ctlr)
                        }
 
                        bp->b_resid = bp->b_bcount & 3;
-                       bp_done(bp, 0);
+                       bp_done(bio, 0);
                        return;
 
                default:
-                       bp_done(bp, ENXIO);
+                       bp_done(bio, ENXIO);
                        return;
        }
 
        /* Port 0 or 1 falls through to here.
         */
        if (bp->b_bcount & 1)   /* Odd transfers are illegal */
-               bp_done(bp, EIO);
+               bp_done(bio, EIO);
 
        len = bp->b_bcount;
        data = (u_char *)bp->b_data;
@@ -910,7 +903,7 @@ da_strategy(struct buf *bp, struct ctlr *ctlr)
 
        bp->b_resid = 0;
 
-       bp_done(bp, 0);
+       bp_done(bio, 0);
 }
 
 /* Input masks for MODE 0 of the ports treating PC as a single
@@ -931,13 +924,15 @@ static void flush_dcr(struct ctlr *ctlr)
 /* do: Digital output
  */
 static void
-digital_out_strategy(struct buf *bp, struct ctlr *ctlr)
+digital_out_strategy(struct bio *bio, struct ctlr *ctlr)
 {
+       struct buf *bp = bio->bio_buf;
+       dev_t dev = bio->bio_driver_info;
        int len;
        u_char *data;
        int port;
        int i;
-       int chan = CHAN(bp->b_dev);
+       int chan = CHAN(dev);
 
        ctlr->dcr_val &= ~set_input[chan];      /* Digital out: Clear bit */
        flush_dcr(ctlr);
@@ -954,19 +949,21 @@ digital_out_strategy(struct buf *bp, struct ctlr *ctlr)
 
        bp->b_resid = 0;
 
-       bp_done(bp, 0);
+       bp_done(bio, 0);
 }
 
 /* digital_in_strategy: Digital input
  */
 static void
-digital_in_strategy(struct buf *bp, struct ctlr *ctlr)
+digital_in_strategy(struct bio *bio, struct ctlr *ctlr)
 {
+       struct buf *bp = bio->bio_buf;
+       dev_t dev = bio->bio_driver_info;
        int len;
        u_char *data;
        int port;
        int i;
-       int chan = CHAN(bp->b_dev);
+       int chan = CHAN(dev);
 
        ctlr->dcr_val |= set_input[chan];       /* Digital in: Set bit */
        flush_dcr(ctlr);
@@ -982,28 +979,31 @@ digital_in_strategy(struct buf *bp, struct ctlr *ctlr)
 
        bp->b_resid = 0;
 
-       bp_done(bp, 0);
+       bp_done(bio, 0);
 }
 
 
 static void
-labpcstrategy(struct buf *bp)
+labpcstrategy(dev_t dev, struct bio *bio)
 {
-       struct ctlr *ctlr = labpcs[UNIT(bp->b_dev)];
+       struct buf *bp = bio->bio_buf;
+       struct ctlr *ctlr = labpcs[UNIT(dev)];
+
+       bio->bio_driver_info = dev;
 
-       if (DIGITAL(bp->b_dev)) {
+       if (DIGITAL(dev)) {
                if (bp->b_flags & B_READ) {
                        ctlr->starter = null_start;
                        ctlr->stop = all_stop;
                        ctlr->intr = null_intr;
-                       digital_in_strategy(bp, ctlr);
+                       digital_in_strategy(bio, ctlr);
                }
                else
                {
                        ctlr->starter = null_start;
                        ctlr->stop = all_stop;
                        ctlr->intr = null_intr;
-                       digital_out_strategy(bp, ctlr);
+                       digital_out_strategy(bio, ctlr);
                }
        }
        else {
@@ -1012,14 +1012,14 @@ labpcstrategy(struct buf *bp)
                        ctlr->starter = INTERVAL(ctlr->dev) ? ad_interval_start : ad_start;
                        ctlr->stop = all_stop;
                        ctlr->intr = ad_intr;
-                       ad_strategy(bp, ctlr);
+                       ad_strategy(bio, ctlr);
                }
                else
                {
                        ctlr->starter = null_start;
                        ctlr->stop = all_stop;
                        ctlr->intr = null_intr;
-                       da_strategy(bp, ctlr);
+                       da_strategy(bio, ctlr);
                }
        }
 }
index 938225d..9b23c01 100644 (file)
@@ -1,7 +1,7 @@
 /*     $NetBSD: if_de.c,v 1.86 1999/06/01 19:17:59 thorpej Exp $       */
 
 /* $FreeBSD: src/sys/pci/if_de.c,v 1.123.2.4 2000/08/04 23:25:09 peter Exp $ */
-/* $DragonFly: src/sys/dev/netif/de/if_de.c,v 1.41 2005/11/28 17:13:42 dillon Exp $ */
+/* $DragonFly: src/sys/dev/netif/de/if_de.c,v 1.42 2006/02/17 19:18:05 dillon Exp $ */
 
 /*-
  * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
@@ -129,11 +129,11 @@ tulip_timeout_callback(void *arg)
 {
     tulip_softc_t *sc = arg;
 
-    lwkt_serialize_enter(&sc->tulip_serializer);
+    lwkt_serialize_enter(sc->tulip_if.if_serializer);
     sc->tulip_flags &= ~TULIP_TIMEOUTPENDING;
     sc->tulip_probe_timeout -= 1000 / TULIP_HZ;
     (sc->tulip_boardsw->bd_media_poll)(sc, TULIP_MEDIAPOLL_TIMER);
-    lwkt_serialize_exit(&sc->tulip_serializer);
+    lwkt_serialize_exit(sc->tulip_if.if_serializer);
 }
 
 static void
@@ -3944,6 +3944,13 @@ tulip_attach(tulip_softc_t *sc)
     ifp->if_snd.ifq_maxlen = ifqmaxlen;
 }
 
+static void
+tulip_detach(tulip_softc_t *sc)
+{
+    ifmedia_removeall(&sc->tulip_ifmedia);
+    ether_ifdetach(&sc->tulip_if);
+}
+
 static void
 tulip_initcsrs(tulip_softc_t *sc, tulip_csrptr_t csr_base, size_t csr_size)
 {
@@ -4031,12 +4038,12 @@ tulip_shutdown(device_t dev)
 {
     tulip_softc_t *sc = device_get_softc(dev);
 
-    lwkt_serialize_enter(&sc->tulip_serializer);
+    lwkt_serialize_enter(sc->tulip_if.if_serializer);
     TULIP_CSR_WRITE(sc, csr_busmode, TULIP_BUSMODE_SWRESET);
     DELAY(10); /* Wait 10 microseconds (actually 50 PCI cycles but at 
                   33MHz that comes to two microseconds but wait a
                   bit longer anyways) */
-    lwkt_serialize_exit(&sc->tulip_serializer);
+    lwkt_serialize_exit(sc->tulip_if.if_serializer);
     return 0;
 }
 
@@ -4090,7 +4097,6 @@ tulip_pci_attach(device_t dev)
     }
 
     sc = device_get_softc(dev);
-    lwkt_serialize_init(&sc->tulip_serializer);
     sc->tulip_dev = dev;
     sc->tulip_pci_busno = pci_get_bus(dev);
     sc->tulip_pci_devno = pci_get_slot(dev);
@@ -4156,7 +4162,6 @@ tulip_pci_attach(device_t dev)
                   33MHz that comes to two microseconds but wait a
                   bit longer anyways) */
 
-    lwkt_serialize_enter(&sc->tulip_serializer);
     if ((retval = tulip_read_macaddr(sc)) < 0) {
        device_printf(dev, "can't read ENET ROM (why=%d) (", retval);
        for (idx = 0; idx < 32; idx++)
@@ -4172,6 +4177,7 @@ tulip_pci_attach(device_t dev)
        if (sc->tulip_features & TULIP_HAVE_SHAREDINTR)
            intr_rtn = tulip_intr_shared;
 
+       tulip_attach(sc);
        if ((sc->tulip_features & TULIP_HAVE_SLAVEDINTR) == 0) {
            void *ih;
 
@@ -4180,16 +4186,14 @@ tulip_pci_attach(device_t dev)
                                         RF_SHAREABLE | RF_ACTIVE);
            if (res == 0 || bus_setup_intr(dev, res, INTR_NETSAFE,
                                           intr_rtn, sc, &ih,
-                                          &sc->tulip_serializer)) {
-               lwkt_serialize_exit(&sc->tulip_serializer);
+                                          sc->tulip_if.if_serializer)) {
                device_printf(dev, "couldn't map interrupt\n");
+               tulip_detach(sc);
                free((caddr_t) sc->tulip_rxdescs, M_DEVBUF);
                free((caddr_t) sc->tulip_txdescs, M_DEVBUF);
                return ENXIO;
            }
        }
-       tulip_attach(sc);
-       lwkt_serialize_exit(&sc->tulip_serializer);
     }
     return 0;
 }
index b4b4dbc..d7af83d 100644 (file)
@@ -1,7 +1,7 @@
 /*     $NetBSD: if_devar.h,v 1.32 1999/04/01 14:55:25 tsubai Exp $     */
 
 /* $FreeBSD: src/sys/pci/if_devar.h,v 1.23.2.1 2000/08/04 23:25:10 peter Exp $ */
-/* $DragonFly: src/sys/dev/netif/de/if_devar.h,v 1.14 2005/11/28 17:13:42 dillon Exp $ */
+/* $DragonFly: src/sys/dev/netif/de/if_devar.h,v 1.15 2006/02/17 19:18:05 dillon Exp $ */
 
 /*-
  * Copyright (c) 1994-1997 Matt Thomas (matt@3am-software.com)
@@ -432,7 +432,6 @@ struct _tulip_softc_t {
     struct ifmedia tulip_ifmedia;
     struct callout tulip_timer;
     struct callout tulip_fast_timer;
-    struct lwkt_serialize tulip_serializer;
     bus_space_tag_t tulip_csrs_bst;
     bus_space_handle_t tulip_csrs_bsh;
     tulip_regfile_t tulip_csrs;
index 08af215..f1eb7d7 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/aac/aac.c,v 1.9.2.14 2003/04/08 13:22:08 scottl Exp $
- *     $DragonFly: src/sys/dev/raid/aac/aac.c,v 1.19 2005/08/08 01:25:31 hmp Exp $
+ *     $DragonFly: src/sys/dev/raid/aac/aac.c,v 1.20 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -877,18 +877,17 @@ aac_complete(void *context, int pending)
  * Handle a bio submitted from a disk device.
  */
 void
-aac_submit_bio(struct buf *bp)
+aac_submit_bio(struct aac_disk *ad, struct bio *bio)
 {
-       struct aac_disk *ad;
        struct aac_softc *sc;
 
        debug_called(2);
 
-       ad = (struct aac_disk *)bp->b_dev->si_drv1;
+       bio->bio_driver_info = ad;
        sc = ad->ad_controller;
 
        /* queue the BIO and try to get some work done */
-       aac_enqueue_bio(sc, bp);
+       aac_enqueue_bio(sc, bio);
        aac_startio(sc);
 }
 
@@ -903,22 +902,24 @@ aac_bio_command(struct aac_softc *sc, struct aac_command **cmp)
        struct aac_blockread *br;
        struct aac_blockwrite *bw;
        struct aac_disk *ad;
+       struct bio *bio;
        struct buf *bp;
 
        debug_called(2);
 
        /* get the resources we will need */
        cm = NULL;
-       if ((bp = aac_dequeue_bio(sc)) == NULL)
+       if ((bio = aac_dequeue_bio(sc)) == NULL)
                goto fail;
        if (aac_alloc_command(sc, &cm)) /* get a command */
                goto fail;
 
        /* fill out the command */
+       bp = bio->bio_buf;
        cm->cm_data = (void *)bp->b_data;
        cm->cm_datalen = bp->b_bcount;
        cm->cm_complete = aac_bio_complete;
-       cm->cm_private = bp;
+       cm->cm_private = bio;
        cm->cm_timestamp = time_second;
        cm->cm_queue = AAC_ADAP_NORM_CMD_QUEUE;
 
@@ -937,12 +938,12 @@ aac_bio_command(struct aac_softc *sc, struct aac_command **cmp)
        fib->Header.Size = sizeof(struct aac_fib_header);
 
        /* build the read/write request */
-       ad = (struct aac_disk *)bp->b_dev->si_drv1;
-       if (BIO_IS_READ(bp)) {
+       ad = (struct aac_disk *)bio->bio_driver_info;
+       if (bp->b_flags & B_READ) {
                br = (struct aac_blockread *)&fib->data[0];
                br->Command = VM_CtBlockRead;
                br->ContainerId = ad->ad_container->co_mntobj.ObjectId;
-               br->BlockNumber = bp->b_pblkno;
+               br->BlockNumber = bio->bio_blkno;
                br->ByteCount = bp->b_bcount;
                fib->Header.Size += sizeof(struct aac_blockread);
                cm->cm_sgtable = &br->SgMap;
@@ -951,7 +952,7 @@ aac_bio_command(struct aac_softc *sc, struct aac_command **cmp)
                bw = (struct aac_blockwrite *)&fib->data[0];
                bw->Command = VM_CtBlockWrite;
                bw->ContainerId = ad->ad_container->co_mntobj.ObjectId;
-               bw->BlockNumber = bp->b_pblkno;
+               bw->BlockNumber = bio->bio_blkno;
                bw->ByteCount = bp->b_bcount;
                bw->Stable = CUNSTABLE; /* XXX what's appropriate here? */
                fib->Header.Size += sizeof(struct aac_blockwrite);
@@ -963,8 +964,8 @@ aac_bio_command(struct aac_softc *sc, struct aac_command **cmp)
        return(0);
 
 fail:
-       if (bp != NULL)
-               aac_enqueue_bio(sc, bp);
+       if (bio != NULL)
+               aac_enqueue_bio(sc, bio);
        if (cm != NULL)
                aac_release_command(cm);
        return(ENOMEM);
@@ -978,12 +979,15 @@ aac_bio_complete(struct aac_command *cm)
 {
        struct aac_blockread_response *brr;
        struct aac_blockwrite_response *bwr;
+       struct bio *bio;
        struct buf *bp;
+       const char *code;
        AAC_FSAStatus status;
 
        /* fetch relevant status and then release the command */
-       bp = (struct buf *)cm->cm_private;
-       if (BIO_IS_READ(bp)) {
+       bio = (struct bio *)cm->cm_private;
+       bp = bio->bio_buf;
+       if (bp->b_flags & B_READ) {
                brr = (struct aac_blockread_response *)&cm->cm_fib->data[0];
                status = brr->Status;
        } else {
@@ -995,14 +999,14 @@ aac_bio_complete(struct aac_command *cm)
        /* fix up the bio based on status */
        if (status == ST_OK) {
                bp->b_resid = 0;
+               code = 0;
        } else {
                bp->b_error = EIO;
                bp->b_flags |= B_ERROR;
                /* pass an error string out to the disk layer */
-               bp->b_driver1 = aac_describe_code(aac_command_status_table,
-                                                   status);
+               code = aac_describe_code(aac_command_status_table, status);
        }
-       aac_biodone(bp);
+       aac_biodone(bio, code);
 }
 
 /*
index 948d8e5..41601b1 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/aac/aac_compat.h,v 1.2.2.2 2001/09/19 19:09:11 scottl Exp $
- * $DragonFly: src/sys/dev/raid/aac/Attic/aac_compat.h,v 1.6 2005/08/08 01:25:31 hmp Exp $
+ * $DragonFly: src/sys/dev/raid/aac/Attic/aac_compat.h,v 1.7 2006/02/17 19:18:05 dillon Exp $
  */
 /*
  * Backwards compatibility support.
 #include <sys/proc.h>
 #include <sys/buf.h>
 #include <sys/buf2.h>
-#define bioq_init(x)                           bufq_init(x)
-#define bioq_insert_tail(x, y)         bufq_insert_tail(x, y)
-#define bioq_remove(x, y)                      bufq_remove(x, y)
-#define bioq_first(x)                          bufq_first(x)
-#define bio_queue_head                         buf_queue_head
+
+#if 0
 #define        FREEBSD_4
 #define BIO_ERROR                              B_ERROR
 #define devstat_end_transaction_bio(x, y)      devstat_end_transaction_buf(x, y)
 #define BIO_IS_READ(x)                         ((x)->b_flags & B_READ)
 #endif
+#endif
index 93897be..b9548b7 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/aac/aac_disk.c,v 1.3.2.8 2003/01/11 18:39:39 scottl Exp $
- *     $DragonFly: src/sys/dev/raid/aac/aac_disk.c,v 1.10 2005/08/08 01:25:31 hmp Exp $
+ *     $DragonFly: src/sys/dev/raid/aac/aac_disk.c,v 1.11 2006/02/17 19:18:05 dillon Exp $
  */
 
 #include "opt_aac.h"
@@ -183,26 +183,27 @@ aac_disk_close(dev_t dev, int flags, int fmt, d_thread_t *td)
  * Handle an I/O request.
  */
 static void
-aac_disk_strategy(struct buf *bp)
+aac_disk_strategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct aac_disk *sc;
 
        debug_called(4);
 
-       sc = (struct aac_disk *)bp->b_dev->si_drv1;
+       sc = (struct aac_disk *)dev->si_drv1;
 
        /* bogus disk? */
        if (sc == NULL) {
                bp->b_flags |= B_ERROR;
                bp->b_error = EINVAL;
-               biodone(bp);
+               biodone(bio);
                return;
        }
 
        /* do-nothing operation? */
        if (bp->b_bcount == 0) {
                bp->b_resid = bp->b_bcount;
-               biodone(bp);
+               biodone(bio);
                return;
        }
 
@@ -210,8 +211,7 @@ aac_disk_strategy(struct buf *bp)
        devstat_start_transaction(&sc->ad_stats);
 
        /* pass the bio to the controller - it can work out who we are */
-       aac_submit_bio(bp);
-       return;
+       aac_submit_bio(sc, bio);
 }
 
 /*
@@ -294,27 +294,28 @@ retry:
  * Handle completion of an I/O request.
  */
 void
-aac_biodone(struct buf *bp)
+aac_biodone(struct bio *bio, const char *code)
 {
+       struct buf *bp = bio->bio_buf;
        struct aac_disk *sc;
        int blkno;
 
        debug_called(4);
 
-       sc = (struct aac_disk *)bp->b_dev->si_drv1;
+       sc = (struct aac_disk *)bio->bio_driver_info;
 
-       devstat_end_transaction_bio(&sc->ad_stats, bp);
-       if (bp->b_flags & BIO_ERROR) {
+       devstat_end_transaction_buf(&sc->ad_stats, bp);
+       if (bp->b_flags & B_ERROR) {
                blkno = (sc->ad_label.d_nsectors) ? 0 : -1;
 #if defined(__FreeBSD__) && __FreeBSD_version > 500005
-               diskerr(bp, bp->b_dev,
-                       (char *)bp->bio_driver1, blkno, &sc->ad_label);
+               diskerr(bio, sc->ad_dev_t,
+                       code, blkno, &sc->ad_label);
 #else
-               diskerr(bp, bp->b_dev,
-                       (char *)bp->b_driver1, 0, blkno, &sc->ad_label);
+               diskerr(bio, sc->ad_dev_t,
+                       code, 0, blkno, &sc->ad_label);
 #endif
        }
-       biodone(bp);
+       biodone(bio);
 }
 
 /*
index e873ab7..c98fdb0 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/aac/aacvar.h,v 1.4.2.7 2003/04/08 13:22:08 scottl Exp $
- *     $DragonFly: src/sys/dev/raid/aac/aacvar.h,v 1.10 2005/08/08 01:25:31 hmp Exp $
+ *     $DragonFly: src/sys/dev/raid/aac/aacvar.h,v 1.11 2006/02/17 19:18:05 dillon Exp $
  */
 
 #include <sys/thread2.h>
@@ -330,7 +330,7 @@ struct aac_softc
        TAILQ_HEAD(,aac_command) aac_busy;
        TAILQ_HEAD(,aac_command) aac_complete;  /* commands which have been
                                                 * returned by the controller */
-       struct buf_queue_head   aac_bioq;
+       struct bio_queue_head   aac_bioq;
        struct aac_queue_table  *aac_queues;
        struct aac_queue_entry  *aac_qentries[AAC_QUEUE_COUNT];
 
@@ -390,8 +390,8 @@ extern int          aac_suspend(device_t dev);
 extern int             aac_resume(device_t dev);
 extern void            aac_intr(void *arg);
 extern devclass_t      aac_devclass;
-extern void            aac_submit_bio(struct buf *bp);
-extern void            aac_biodone(struct buf *bp);
+extern void            aac_submit_bio(struct aac_disk *ad, struct bio *bio);
+extern void            aac_biodone(struct bio *bio, const char *code);
 extern int             aac_dump_enqueue(struct aac_disk *ad, u_int32_t lba,
                                         void *data, int nblks);
 extern void            aac_dump_complete(struct aac_softc *sc);
@@ -557,26 +557,26 @@ aac_initq_bio(struct aac_softc *sc)
 }
 
 static __inline void
-aac_enqueue_bio(struct aac_softc *sc, struct buf *bp)
+aac_enqueue_bio(struct aac_softc *sc, struct bio *bio)
 {
        crit_enter();
-       bioq_insert_tail(&sc->aac_bioq, bp);
+       bioq_insert_tail(&sc->aac_bioq, bio);
        AACQ_ADD(sc, AACQ_BIO);
        crit_exit();
 }
 
-static __inline struct buf *
+static __inline struct bio *
 aac_dequeue_bio(struct aac_softc *sc)
 {
-       struct buf *bp;
+       struct bio *bio;
 
        crit_enter();
-       if ((bp = bioq_first(&sc->aac_bioq)) != NULL) {
-               bioq_remove(&sc->aac_bioq, bp);
+       if ((bio = bioq_first(&sc->aac_bioq)) != NULL) {
+               bioq_remove(&sc->aac_bioq, bio);
                AACQ_REMOVE(sc, AACQ_BIO);
        }
        crit_exit();
-       return(bp);
+       return(bio);
 }
 
 static __inline void
index 1f2bf17..236918b 100644 (file)
@@ -53,7 +53,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/amr/amr.c,v 1.7.2.13 2003/01/15 13:41:18 emoore Exp $
- *     $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.15 2005/06/09 20:55:05 swildner Exp $
+ *     $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.16 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -838,8 +838,8 @@ amr_completeio(struct amr_command *ac)
     struct amr_softc   *sc = ac->ac_sc;
     
     if (ac->ac_status != AMR_STATUS_SUCCESS) { /* could be more verbose here? */
-       ac->ac_bio->bio_error = EIO;
-       ac->ac_bio->bio_flags |= BIO_ERROR;
+       ac->ac_bio->bio_buf->b_error = EIO;
+       ac->ac_bio->bio_buf->b_flags |= B_ERROR;
 
        device_printf(sc->amr_dev, "I/O error - 0x%x\n", ac->ac_status);
 /*     amr_printcommand(ac);*/
@@ -884,28 +884,28 @@ amr_bio_command(struct amr_softc *sc, struct amr_command **acp)
     /* connect the bio to the command */
     ac->ac_complete = amr_completeio;
     ac->ac_bio = bio;
-    ac->ac_data = bio->bio_data;
-    ac->ac_length = bio->bio_bcount;
-    if (BIO_IS_READ(bio)) {
+    ac->ac_data = bio->bio_buf->b_data;
+    ac->ac_length = bio->bio_buf->b_bcount;
+    if (bio->bio_buf->b_flags & B_READ) {
        ac->ac_flags |= AMR_CMD_DATAIN;
        cmd = AMR_CMD_LREAD;
     } else {
        ac->ac_flags |= AMR_CMD_DATAOUT;
        cmd = AMR_CMD_LWRITE;
     }
-    amrd = (struct amrd_softc *)bio->bio_dev->si_drv1;
+    amrd = (struct amrd_softc *)bio->bio_driver_info;
     driveno = amrd->amrd_drive - sc->amr_drive;
-    blkcount = (bio->bio_bcount + AMR_BLKSIZE - 1) / AMR_BLKSIZE;
+    blkcount = (bio->bio_buf->b_bcount + AMR_BLKSIZE - 1) / AMR_BLKSIZE;
 
     ac->ac_mailbox.mb_command = cmd;
     ac->ac_mailbox.mb_blkcount = blkcount;
-    ac->ac_mailbox.mb_lba = bio->bio_pblkno;
+    ac->ac_mailbox.mb_lba = bio->bio_blkno;
     ac->ac_mailbox.mb_drive = driveno;
     /* we fill in the s/g related data when the command is mapped */
 
-    if ((bio->bio_pblkno + blkcount) > sc->amr_drive[driveno].al_size)
+    if ((bio->bio_blkno + blkcount) > sc->amr_drive[driveno].al_size)
        device_printf(sc->amr_dev, "I/O beyond end of unit (%lld,%d > %lu)\n", 
-                     (long long)bio->bio_pblkno, blkcount,
+                     (long long)bio->bio_blkno, blkcount,
                      (u_long)sc->amr_drive[driveno].al_size);
 
 out:
index b048074..88e3f86 100644 (file)
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/amr/amr_compat.h,v 1.2.2.4 2002/11/11 13:19:10 emoore Exp $
- * $DragonFly: src/sys/dev/raid/amr/amr_compat.h,v 1.6 2004/07/17 01:45:37 hmp Exp $
+ * $DragonFly: src/sys/dev/raid/amr/amr_compat.h,v 1.7 2006/02/17 19:18:05 dillon Exp $
  */
-/*
- * Backwards compatibility support.
- */
-
-#if defined(__DragonFly__) || __FreeBSD_version < 500003               /* old buf style */
-# include <sys/proc.h>
-# include <sys/buf.h>
-# include <machine/clock.h>
-# include <sys/buf2.h>
-
-# define FREEBSD_4
-# define bio                                   buf
-# define bioq_init(x)                          bufq_init(x)
-# define bioq_insert_tail(x, y)                        bufq_insert_tail(x, y)
-# define bioq_remove(x, y)                     bufq_remove(x, y)
-# define bioq_first(x)                         bufq_first(x)
-# define bio_queue_head                                buf_queue_head
-# define bio_bcount                            b_bcount
-# define bio_blkno                             b_blkno
-# define bio_caller1                           b_caller1
-# define bio_data                              b_data
-# define bio_dev                               b_dev
-# define bio_driver1                           b_driver1
-# define bio_error                             b_error
-# define bio_flags                             b_flags
-# define bio_pblkno                            b_pblkno
-# define bio_resid                             b_resid
-# define BIO_ERROR                             B_ERROR
-# define devstat_end_transaction_bio(x, y)     devstat_end_transaction_buf(x, y)
-# define BIO_IS_READ(x)                                ((x)->b_flags & B_READ)
-# define AMR_BIO_FINISH(x)                      devstat_end_transaction_bio(&sc->amrd_stats, x);\
-                                                biodone(x)
-
-#else
-# include <sys/bio.h>
-# define BIO_IS_READ(x)                                ((x)->bio_cmd == BIO_READ)
-# define AMR_BIO_FINISH(x)                      biofinish(x, &sc->amrd_stats, 0)
-#endif
-
-/************************************************************************
- * Compatibility with older versions of FreeBSD
- */
-#if defined(__FreeBSD__) && __FreeBSD_version < 440001
-typedef struct proc     d_thread_t;
-#define M_ZERO          0x0008          /* bzero the allocation */
-#endif
 
+#include <sys/proc.h>
+#include <sys/buf.h>
+#include <machine/clock.h>
+#include <sys/buf2.h>
 
 #ifndef __packed
 #define __packed __attribute__ ((packed))
index d494656..1e99d7e 100644 (file)
@@ -54,7 +54,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/amr/amr_disk.c,v 1.5.2.5 2002/12/20 15:12:04 emoore Exp $
- * $DragonFly: src/sys/dev/raid/amr/amr_disk.c,v 1.9 2004/05/19 22:52:46 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/amr/amr_disk.c,v 1.10 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -252,47 +252,46 @@ amrd_dump(dev_t dev, u_int count, u_int blkno, u_int secsize)
  * be a multiple of a sector in length.
  */
 static void
-amrd_strategy(struct bio *bio)
+amrd_strategy(dev_t dev, struct bio *bio)
 {
-    struct amrd_softc  *sc = (struct amrd_softc *)bio->bio_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
+    struct amrd_softc *sc = (struct amrd_softc *)dev->si_drv1;
 
     /* bogus disk? */
     if (sc == NULL) {
-       bio->bio_error = EINVAL;
+       bp->b_error = EINVAL;
        goto bad;
     }
+    bio->bio_driver_info = sc;
 
     devstat_start_transaction(&sc->amrd_stats);
     amr_submit_bio(sc->amrd_controller, bio);
     return;
 
  bad:
-    bio->bio_flags |= BIO_ERROR;
+    bp->b_flags |= B_ERROR;
 
     /*
      * Correctly set the buf to indicate a completed transfer
      */
-    bio->bio_resid = bio->bio_bcount;
+    bp->b_resid = bp->b_bcount;
     biodone(bio);
-    return;
 }
 
 void
-amrd_intr(void *data)
+amrd_intr(struct bio *bio)
 {
-    struct bio *bio = (struct bio *)data;
-    struct amrd_softc *sc = (struct amrd_softc *)bio->bio_dev->si_drv1;
+    struct buf *bp = bio->bio_buf;
 
     debug_called(2);
 
-    if (bio->bio_flags & BIO_ERROR) {
-       bio->bio_error = EIO;
+    if (bp->b_flags & B_ERROR) {
+       bp->b_error = EIO;
        debug(1, "i/o error\n");
     } else {
-       bio->bio_resid = 0;
+       bp->b_resid = 0;
     }
-
-    AMR_BIO_FINISH(bio);
+    biodone(bio);
 }
 
 static int
index c49e116..f4db446 100644 (file)
@@ -53,7 +53,7 @@
  * SUCH DAMAGE.
  *
  *      $FreeBSD: src/sys/dev/amr/amrvar.h,v 1.2.2.5 2002/12/20 15:12:04 emoore Exp $
- *      $DragonFly: src/sys/dev/raid/amr/amrvar.h,v 1.6 2005/06/09 20:55:05 swildner Exp $
+ *      $DragonFly: src/sys/dev/raid/amr/amrvar.h,v 1.7 2006/02/17 19:18:05 dillon Exp $
  */
 
 #include <sys/thread2.h>
@@ -266,7 +266,7 @@ struct amrd_softc
  * Interface between driver core and disk driver (should be using a bus?)
  */
 extern int     amr_submit_bio(struct amr_softc *sc, struct bio *bio);
-extern void    amrd_intr(void *data);
+extern void    amrd_intr(struct bio *bio);
 extern int     amr_dump_blocks(struct amr_softc *sc, int unit, u_int32_t lba, void *data, int blks);
 
 /********************************************************************************
index 17695b8..ef7e646 100644 (file)
@@ -28,7 +28,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ida/ida.c,v 1.7.2.3 2001/03/01 01:57:32 ps Exp $
- * $DragonFly: src/sys/dev/raid/ida/ida.c,v 1.8 2005/06/10 15:46:31 swildner Exp $
+ * $DragonFly: src/sys/dev/raid/ida/ida.c,v 1.9 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -196,7 +196,7 @@ ida_init(struct ida_softc *ida)
 
        SLIST_INIT(&ida->free_qcbs);
        STAILQ_INIT(&ida->qcb_queue);
-        bufq_init(&ida->buf_queue);
+        bioq_init(&ida->bio_queue);
 
        ida->qcbs = malloc(IDA_QCB_MAX * sizeof(struct ida_qcb), 
                            M_DEVBUF, M_INTWAIT|M_ZERO);
@@ -372,9 +372,9 @@ ida_command(struct ida_softc *ida, int command, void *data, int datasize,
 }
 
 void
-ida_submit_buf(struct ida_softc *ida, struct buf *bp)
+ida_submit_buf(struct ida_softc *ida, struct bio *bio)
 {
-        bufq_insert_tail(&ida->buf_queue, bp);
+        bioq_insert_tail(&ida->bio_queue, bio);
         ida_construct_qcb(ida);
        ida_start(ida);
 }
@@ -386,22 +386,24 @@ ida_construct_qcb(struct ida_softc *ida)
        struct ida_qcb *qcb;
        bus_dmasync_op_t op;
        struct buf *bp;
+       struct bio *bio;
 
-       bp = bufq_first(&ida->buf_queue);
-       if (bp == NULL)
+       bio = bioq_first(&ida->bio_queue);
+       if (bio == NULL)
                return;                         /* no more buffers */
 
        qcb = ida_get_qcb(ida);
        if (qcb == NULL)
                return;                         /* out of resources */
 
-       bufq_remove(&ida->buf_queue, bp);
-       qcb->buf = bp;
+       bioq_remove(&ida->bio_queue, bio);
+       qcb->bio = bio;
        qcb->flags = 0;
 
        hwqcb = qcb->hwqcb;
        bzero(hwqcb, sizeof(struct ida_hdr) + sizeof(struct ida_req));
 
+       bp = bio->bio_buf;
        bus_dmamap_load(ida->buffer_dmat, qcb->dmamap,
            (void *)bp->b_data, bp->b_bcount, ida_setup_dmamap, hwqcb, 0);
        op = qcb->flags & DMA_DATA_IN ?
@@ -409,11 +411,13 @@ ida_construct_qcb(struct ida_softc *ida)
        bus_dmamap_sync(ida->buffer_dmat, qcb->dmamap, op);
 
        {
-               struct idad_softc *drv = (struct idad_softc *)bp->b_driver1;
+               struct idad_softc *drv;
+
+               drv = (struct idad_softc *)bio->bio_driver_info;
                hwqcb->hdr.drive = drv->drive;
        }
 
-       hwqcb->req.blkno = bp->b_pblkno;
+       hwqcb->req.blkno = bio->bio_blkno;
        hwqcb->req.bcount = howmany(bp->b_bcount, DEV_BSIZE);
        hwqcb->req.command = bp->b_flags & B_READ ? CMD_READ : CMD_WRITE;
 
@@ -532,8 +536,8 @@ ida_done(struct ida_softc *ida, struct ida_qcb *qcb)
                        wakeup(qcb);
        } else {
                if (error)
-                       qcb->buf->b_flags |= B_ERROR;
-               idad_intr(qcb->buf);
+                       qcb->bio->bio_buf->b_flags |= B_ERROR;
+               idad_intr(qcb->bio);
        }
 
        qcb->state = QCB_FREE;
index 17fa040..9224a8f 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ida/ida_disk.c,v 1.12.2.6 2001/11/27 20:21:02 ps Exp $
- * $DragonFly: src/sys/dev/raid/ida/ida_disk.c,v 1.9 2005/06/10 15:46:31 swildner Exp $
+ * $DragonFly: src/sys/dev/raid/ida/ida_disk.c,v 1.10 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -156,11 +156,12 @@ idad_close(dev_t dev, int flags, int fmt, d_thread_t *td)
  * be a multiple of a sector in length.
  */
 static void
-idad_strategy(struct buf *bp)
+idad_strategy(dev_t dev, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        struct idad_softc *drv;
 
-       drv = idad_getsoftc(bp->b_dev);
+       drv = idad_getsoftc(dev);
        if (drv == NULL) {
                bp->b_error = EINVAL;
                goto bad;
@@ -180,10 +181,10 @@ idad_strategy(struct buf *bp)
        if (bp->b_bcount == 0)
                goto done;
 
-       bp->b_driver1 = drv;
+       bio->bio_driver_info = drv;
        crit_enter();
        devstat_start_transaction(&drv->stats);
-       ida_submit_buf(drv->controller, bp);
+       ida_submit_buf(drv->controller, bio);
        crit_exit();
        return;
 
@@ -195,8 +196,7 @@ done:
         * Correctly set the buf to indicate a completed transfer
         */
        bp->b_resid = bp->b_bcount;
-       biodone(bp);
-       return;
+       biodone(bio);
 }
 
 static int
@@ -244,9 +244,10 @@ idad_dump(dev_t dev, u_int count, u_int blkno, u_int secsize)
 }
 
 void
-idad_intr(struct buf *bp)
+idad_intr(struct bio *bio)
 {
-       struct idad_softc *drv = (struct idad_softc *)bp->b_driver1;
+       struct idad_softc *drv = (struct idad_softc *)bio->bio_driver_info;
+       struct buf *bp = bio->bio_buf;
 
        if (bp->b_flags & B_ERROR)
                bp->b_error = EIO;
@@ -254,7 +255,7 @@ idad_intr(struct buf *bp)
                bp->b_resid = 0;
 
        devstat_end_transaction_buf(&drv->stats, bp);
-       biodone(bp);
+       biodone(bio);
 }
 
 static int
index 339ee53..86bca59 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ida/idavar.h,v 1.3.2.4 2001/07/30 20:29:58 jlemon Exp $
- * $DragonFly: src/sys/dev/raid/ida/idavar.h,v 1.2 2003/06/17 04:28:27 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/ida/idavar.h,v 1.3 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -104,7 +104,7 @@ struct ida_qcb {
        } link;
        bus_dmamap_t    dmamap;
        bus_addr_t      hwqcb_busaddr;
-       struct          buf *buf;               /* buf associated with qcb */
+       struct          bio *bio;               /* bio associated with qcb */
 };
 
 struct ida_softc;
@@ -157,7 +157,7 @@ struct ida_softc {
        struct          ida_qcb *qcbs;                  /* kernel QCB array */
        SLIST_HEAD(, ida_qcb)   free_qcbs;      
        STAILQ_HEAD(, ida_qcb)  qcb_queue;
-       struct          buf_queue_head buf_queue;
+       struct          bio_queue_head bio_queue;
 
        struct          ida_access cmd;
 };
@@ -197,9 +197,9 @@ extern int ida_init(struct ida_softc *ida);
 extern void ida_attach(struct ida_softc *ida); 
 extern int ida_command(struct ida_softc *ida, int command, void *data,
        int datasize, int drive, u_int32_t pblkno, int flags);
-extern void ida_submit_buf(struct ida_softc *ida, struct buf *bp);
+extern void ida_submit_buf(struct ida_softc *ida, struct bio *bio);
 extern void ida_intr(void *data);
 
-extern void idad_intr(struct buf *bp);
+extern void idad_intr(struct bio *bio);
 
 #endif /* _IDAVAR_H */
index 81e9740..9f96b22 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ips/ips.h,v 1.10 2004/05/30 20:08:34 phk Exp $
- * $DragonFly: src/sys/dev/raid/ips/ips.h,v 1.7 2005/08/09 16:23:13 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/ips/ips.h,v 1.8 2006/02/17 19:18:05 dillon Exp $
  */
 
 
@@ -198,6 +198,7 @@ MALLOC_DECLARE(M_IPSBUF);
  * for compatibility
  */
 /* struct buf to struct bio changes */
+#if 0
 #define BIO_ERROR      B_ERROR
 #define BIO_READ       B_READ
 #define bio            buf
@@ -211,8 +212,9 @@ MALLOC_DECLARE(M_IPSBUF);
 #define bio_resid      b_resid
 
 /* geom */
-#define bio_disk       bio_dev
 #define d_drv1         si_drv1
+#endif
+
 #define d_maxsize      si_iosize_max
 
 #define disk_open_t    d_open_t
@@ -237,7 +239,7 @@ MALLOC_DECLARE(M_IPSBUF);
 #define ips_write_2(sc,offset,value)   bus_space_write_2(sc->bustag, sc->bushandle, offset, value)
 #define ips_write_4(sc,offset,value)   bus_space_write_4(sc->bustag, sc->bushandle, offset, value)
 
-#define ips_read_request(iobuf)                ((iobuf)->b_flags & B_READ)
+#define ips_read_request(iobuf)                ((bio)->bio_buf->b_flags & B_READ)
 
 #define COMMAND_ERROR(status)          (((status)->fields.basic_status & 0x0f) >= IPS_MIN_ERROR)
 
@@ -469,7 +471,7 @@ typedef struct ips_softc {
        ips_copper_queue_t      *copper_queue;
 
        struct lwkt_rwlock      queue_lock;
-       struct buf_queue_head   queue;
+       struct bio_queue_head   bio_queue;
 } ips_softc_t;
 
 /* function defines from ips_ioctl.c */
index e0d6aef..7e392b5 100644 (file)
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ips/ips_commands.c,v 1.10 2004/05/30 04:01:29 scottl Exp $
- * $DragonFly: src/sys/dev/raid/ips/ips_commands.c,v 1.10 2006/01/01 16:53:15 y0netan1 Exp $
+ * $DragonFly: src/sys/dev/raid/ips/ips_commands.c,v 1.11 2006/02/17 19:18:05 dillon Exp $
  */
 
+#include <sys/devicestat.h>
 #include <dev/raid/ips/ips.h>
+#include <dev/raid/ips/ips_disk.h>
 
 int
 ips_timed_wait(ips_command_t *command, const char *id, int timo)
@@ -71,9 +73,9 @@ ips_wakeup_callback(ips_command_t *command)
 static void
 ips_io_request_finish(ips_command_t *command)
 {
-       struct bio *iobuf = command->arg;
+       struct bio *bio = command->arg;
 
-       if (ips_read_request(iobuf)) {
+       if (ips_read_request(bio)) {
                bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
                                BUS_DMASYNC_POSTREAD);
        } else {
@@ -82,11 +84,11 @@ ips_io_request_finish(ips_command_t *command)
        }
        bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
        if (COMMAND_ERROR(&command->status)) {
-               iobuf->bio_flags |=BIO_ERROR;
-               iobuf->bio_error = EIO;
+               bio->bio_buf->b_flags |=B_ERROR;
+               bio->bio_buf->b_error = EIO;
        }
        ips_insert_free_cmd(command->sc, command);
-       ipsd_finish(iobuf);
+       ipsd_finish(bio);
 }
 
 static void
@@ -97,7 +99,9 @@ ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
        ips_command_t *command = cmdptr;
        ips_sg_element_t *sg_list;
        ips_io_cmd *command_struct;
-       struct bio *iobuf = command->arg;
+       struct bio *bio = command->arg;
+       struct buf *bp = bio->bio_buf;
+       ipsdisk_softc_t *dsc;
        int i, length = 0;
        u_int8_t cmdtype;
 
@@ -105,17 +109,19 @@ ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
        if (error) {
                printf("ips: error = %d in ips_sg_request_callback\n", error);
                bus_dmamap_unload(command->data_dmatag, command->data_dmamap);
-               iobuf->bio_flags |= BIO_ERROR;
-               iobuf->bio_error = ENOMEM;
+               bp->b_flags |= B_ERROR;
+               bp->b_error = ENOMEM;
                ips_insert_free_cmd(sc, command);
-               ipsd_finish(iobuf);
+               ipsd_finish(bio);
                return;
        }
+       dsc = bio->bio_driver_info;
        command_struct = (ips_io_cmd *)command->command_buffer;
        command_struct->id = command->id;
-       command_struct->drivenum = (uintptr_t)iobuf->bio_driver1;
+       command_struct->drivenum = dsc->sc->drives[dsc->disk_number].drivenum;
+
        if (segnum != 1) {
-               if (ips_read_request(iobuf))
+               if (ips_read_request(bio))
                        cmdtype = IPS_SG_READ_CMD;
                else
                        cmdtype = IPS_SG_WRITE_CMD;
@@ -130,7 +136,7 @@ ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
                command_struct->buffaddr =
                    (u_int32_t)command->command_phys_addr + IPS_COMMAND_LEN;
        } else {
-               if (ips_read_request(iobuf))
+               if (ips_read_request(bio))
                        cmdtype = IPS_READ_CMD;
                else
                        cmdtype = IPS_WRITE_CMD;
@@ -138,12 +144,12 @@ ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
                length = segments[0].ds_len;
        }
        command_struct->command = cmdtype;
-       command_struct->lba = iobuf->bio_pblkno;
+       command_struct->lba = bio->bio_blkno;
        length = (length + IPS_BLKSIZE - 1)/IPS_BLKSIZE;
        command_struct->length = length;
        bus_dmamap_sync(sc->command_dmatag, command->command_dmamap,
                        BUS_DMASYNC_PREWRITE);
-       if (ips_read_request(iobuf)) {
+       if (ips_read_request(bio)) {
                bus_dmamap_sync(command->data_dmatag, command->data_dmamap,
                                BUS_DMASYNC_PREREAD);
        } else {
@@ -156,7 +162,7 @@ ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
         */
        PRINTF(10, "ips test: command id: %d segments: %d "
                "pblkno: %lld length: %d, ds_len: %d\n", command->id, segnum,
-               (long long)iobuf->bio_pblkno,
+               (long long)bio->bio_blkno,
                length, segments[0].ds_len);
 
        sc->ips_issue_cmd(command);
@@ -164,13 +170,15 @@ ips_io_request_callback(void *cmdptr, bus_dma_segment_t *segments, int segnum,
 }
 
 static int
-ips_send_io_request(ips_command_t *command, struct buf *iobuf)
+ips_send_io_request(ips_command_t *command, struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
+
        command->callback = ips_io_request_finish;
-       command->arg = iobuf;
-       PRINTF(10, "ips test: : bcount %ld\n", iobuf->bio_bcount);
+       command->arg = bio;
+       PRINTF(10, "ips test: : bcount %ld\n", bp->b_bcount);
        bus_dmamap_load(command->data_dmatag, command->data_dmamap,
-                       iobuf->bio_data, iobuf->bio_bcount,
+                       bp->b_data, bp->b_bcount,
                        ips_io_request_callback, command, 0);
        return 0;
 }
@@ -179,15 +187,15 @@ void
 ips_start_io_request(ips_softc_t *sc)
 {
        ips_command_t *command;
-       struct bio *iobuf;
+       struct bio *bio;
 
-       iobuf = bufq_first(&sc->queue);
-       if (iobuf == NULL)
+       bio = bioq_first(&sc->bio_queue);
+       if (bio == NULL)
                return;
        if (ips_get_free_cmd(sc, &command, 0) != 0)
                return;
-       bufq_remove(&sc->queue, iobuf);
-       ips_send_io_request(command, iobuf);
+       bioq_remove(&sc->bio_queue, bio);
+       ips_send_io_request(command, bio);
 }
 
 /*
index bff05af..cc4572b 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ips/ips_disk.c,v 1.4 2003/09/22 04:59:07 njl Exp $
- * $DragonFly: src/sys/dev/raid/ips/ips_disk.c,v 1.6 2005/08/09 16:23:13 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/ips/ips_disk.c,v 1.7 2006/02/17 19:18:05 dillon Exp $
  */
 
 #include <sys/devicestat.h>
@@ -112,32 +112,34 @@ ipsd_close(dev_t dev, int oflags, int devtype, d_thread_t *td)
 
 /* ipsd_finish is called to clean up and return a completed IO request */
 void
-ipsd_finish(struct bio *iobuf)
+ipsd_finish(struct bio *bio)
 {
+       struct buf *bp = bio->bio_buf;
        ipsdisk_softc_t *dsc;
 
-       dsc = iobuf->bio_disk->d_drv1;
-       if (iobuf->bio_flags & BIO_ERROR) {
-               device_printf(dsc->dev, "iobuf error %d\n", iobuf->bio_error);
-       } else
-               iobuf->bio_resid = 0;
-       devstat_end_transaction_buf(&dsc->stats, iobuf);
-       biodone(iobuf);
+       dsc = bio->bio_driver_info;
+       if (bp->b_flags & B_ERROR) {
+               device_printf(dsc->dev, "iobuf error %d\n", bp->b_error);
+       } else {
+               bp->b_resid = 0;
+       }
+       devstat_end_transaction_buf(&dsc->stats, bp);
+       biodone(bio);
        ips_start_io_request(dsc->sc);
 }
 
 
 static void
-ipsd_strategy(struct bio *iobuf)
+ipsd_strategy(dev_t dev, struct bio *bio)
 {
        ipsdisk_softc_t *dsc;
 
-       dsc = iobuf->bio_disk->d_drv1;
+       dsc = dev->si_drv1;
        DEVICE_PRINTF(8, dsc->dev, "in strategy\n");
-       iobuf->bio_driver1 = (void *)(uintptr_t)dsc->sc->drives[dsc->disk_number].drivenum;
+       bio->bio_driver_info = dsc;
        devstat_start_transaction(&dsc->stats);
        lwkt_exlock(&dsc->sc->queue_lock, __func__);
-       bufq_insert_tail(&dsc->sc->queue, iobuf);
+       bioq_insert_tail(&dsc->sc->bio_queue, bio);
        ips_start_io_request(dsc->sc);
        lwkt_exunlock(&dsc->sc->queue_lock);
 }
index 7308bf2..7ed2e84 100644 (file)
@@ -26,7 +26,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/ips/ips_pci.c,v 1.10 2004/03/19 17:36:47 scottl Exp $
- * $DragonFly: src/sys/dev/raid/ips/ips_pci.c,v 1.14 2005/10/12 17:35:54 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/ips/ips_pci.c,v 1.15 2006/02/17 19:18:05 dillon Exp $
  */
 
 #include <dev/raid/ips/ips.h>
@@ -155,7 +155,7 @@ ips_pci_attach(device_t dev)
        sc->ips_ich.ich_arg = sc;
        sc->ips_ich.ich_desc = "ips";
        lwkt_rwlock_init(&sc->queue_lock);
-       bufq_init(&sc->queue);
+       bioq_init(&sc->bio_queue);
        if (config_intrhook_establish(&sc->ips_ich) != 0) {
                printf("IPS can't establish configuration hook\n");
                goto error;
index 6ac48f4..9f9506e 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/mlx/mlx.c,v 1.14.2.5 2001/09/11 09:49:53 kris Exp $
- *     $DragonFly: src/sys/dev/raid/mlx/mlx.c,v 1.15 2006/01/25 19:56:29 dillon Exp $
+ *     $DragonFly: src/sys/dev/raid/mlx/mlx.c,v 1.16 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -300,7 +300,7 @@ mlx_attach(struct mlx_softc *sc)
      */
     TAILQ_INIT(&sc->mlx_work);
     TAILQ_INIT(&sc->mlx_freecmds);
-    MLX_BIO_QINIT(sc->mlx_bioq);
+    bioq_init(&sc->mlx_bioq);
 
     /* 
      * Select accessor methods based on controller interface type.
@@ -703,12 +703,12 @@ mlx_intr(void *arg)
  * disk resource, then poke the disk resource to start as much work as it can.
  */
 int
-mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp)
+mlx_submit_bio(struct mlx_softc *sc, struct bio *bio)
 {
     debug_called(1);
 
     crit_enter();
-    MLX_BIO_QINSERT(sc->mlx_bioq, bp);
+    bioq_insert_tail(&sc->mlx_bioq, bio);
     sc->mlx_waitbufs++;
     crit_exit();
     mlx_startio(sc);
@@ -1732,7 +1732,8 @@ mlx_startio(struct mlx_softc *sc)
 {
     struct mlx_command *mc;
     struct mlxd_softc  *mlxd;
-    mlx_bio            *bp;
+    struct bio         *bio;
+    struct buf         *bp;
     int                        blkcount;
     int                        driveno;
     int                        cmd;
@@ -1746,7 +1747,7 @@ mlx_startio(struct mlx_softc *sc)
     for (;;) {
 
        /* see if there's work to be done */
-       if ((bp = MLX_BIO_QFIRST(sc->mlx_bioq)) == NULL)
+       if ((bio = bioq_first(&sc->mlx_bioq)) == NULL)
            break;
        /* get a command */
        if ((mc = mlx_alloccmd(sc)) == NULL)
@@ -1757,16 +1758,17 @@ mlx_startio(struct mlx_softc *sc)
            break;
        }
        /* get the buf containing our work */
-       MLX_BIO_QREMOVE(sc->mlx_bioq, bp);
+       bioq_remove(&sc->mlx_bioq, bio);
+       bp = bio->bio_buf;
        sc->mlx_waitbufs--;
        crit_exit();
        
        /* connect the buf to the command */
        mc->mc_complete = mlx_completeio;
        mc->mc_private = bp;
-       mc->mc_data = MLX_BIO_DATA(bp);
-       mc->mc_length = MLX_BIO_LENGTH(bp);
-       if (MLX_BIO_IS_READ(bp)) {
+       mc->mc_data = bp->b_data;
+       mc->mc_length = bp->b_bcount;
+       if (bp->b_flags & B_READ) {
            mc->mc_flags |= MLX_CMD_DATAIN;
            cmd = MLX_CMD_READSG;
        } else {
@@ -1778,13 +1780,13 @@ mlx_startio(struct mlx_softc *sc)
        mlx_mapcmd(mc);
        
        /* build a suitable I/O command (assumes 512-byte rounded transfers) */
-       mlxd = (struct mlxd_softc *)MLX_BIO_SOFTC(bp);
+       mlxd = (struct mlxd_softc *)bio->bio_driver_info;
        driveno = mlxd->mlxd_drive - sc->mlx_sysdrive;
-       blkcount = (MLX_BIO_LENGTH(bp) + MLX_BLKSIZE - 1) / MLX_BLKSIZE;
+       blkcount = (bp->b_bcount + MLX_BLKSIZE - 1) / MLX_BLKSIZE;
 
-       if ((MLX_BIO_LBA(bp) + blkcount) > sc->mlx_sysdrive[driveno].ms_size)
+       if ((bio->bio_blkno + blkcount) > sc->mlx_sysdrive[driveno].ms_size)
            device_printf(sc->mlx_dev, "I/O beyond end of unit (%u,%d > %u)\n", 
-                         MLX_BIO_LBA(bp), blkcount, sc->mlx_sysdrive[driveno].ms_size);
+                         bio->bio_blkno, blkcount, sc->mlx_sysdrive[driveno].ms_size);
 
        /*
         * Build the I/O command.  Note that the SG list type bits are set to zero,
@@ -1793,7 +1795,7 @@ mlx_startio(struct mlx_softc *sc)
        if (sc->mlx_iftype == MLX_IFTYPE_2) {
            mlx_make_type1(mc, (cmd == MLX_CMD_WRITESG) ? MLX_CMD_WRITESG_OLD : MLX_CMD_READSG_OLD,
                           blkcount & 0xff,                             /* xfer length low byte */
-                          MLX_BIO_LBA(bp),                             /* physical block number */
+                          bio->bio_blkno,                              /* physical block number */
                           driveno,                                     /* target drive number */
                           mc->mc_sgphys,                               /* location of SG list */
                           mc->mc_nsgent & 0x3f);                       /* size of SG list (top 3 bits clear) */
@@ -1801,7 +1803,7 @@ mlx_startio(struct mlx_softc *sc)
            mlx_make_type5(mc, cmd, 
                           blkcount & 0xff,                             /* xfer length low byte */
                           (driveno << 3) | ((blkcount >> 8) & 0x07),   /* target and length high 3 bits */
-                          MLX_BIO_LBA(bp),                             /* physical block number */
+                          bio->bio_blkno,                              /* physical block number */
                           mc->mc_sgphys,                               /* location of SG list */
                           mc->mc_nsgent & 0x3f);                       /* size of SG list (top 3 bits clear) */
        }
@@ -1825,11 +1827,13 @@ static void
 mlx_completeio(struct mlx_command *mc)
 {
     struct mlx_softc   *sc = mc->mc_sc;
-    mlx_bio            *bp = (mlx_bio *)mc->mc_private;
-    struct mlxd_softc  *mlxd = (struct mlxd_softc *)MLX_BIO_SOFTC(bp);
+    struct bio         *bio = (mlx_bio *)mc->mc_private;
+    struct mlxd_softc  *mlxd = (struct mlxd_softc *)bio->bio_driver_info;
+    struct buf         *bp = bio->bio_buf;
     
     if (mc->mc_status != MLX_STATUS_OK) {      /* could be more verbose here? */
-       MLX_BIO_SET_ERROR(bp, EIO);
+       bp->b_error = EIO;
+       bp->b_flags |= B_ERROR;
 
        switch(mc->mc_status) {
        case MLX_STATUS_RDWROFFLINE:            /* system drive has gone offline */
@@ -1842,14 +1846,14 @@ mlx_completeio(struct mlx_command *mc)
            device_printf(sc->mlx_dev, "I/O error - %s\n", mlx_diagnose_command(mc));
 #if 0
            device_printf(sc->mlx_dev, "  b_bcount %ld  blkcount %ld  b_pblkno %d\n", 
-                         MLX_BIO_LENGTH(bp), MLX_BIO_LENGTH(bp) / MLX_BLKSIZE, MLX_BIO_LBA(bp));
+                         bp->b_bcount, bp->b_bcount / MLX_BLKSIZE, bio->bio_blkno);
            device_printf(sc->mlx_dev, "  %13D\n", mc->mc_mailbox, " ");
 #endif
            break;
        }
     }
     mlx_releasecmd(mc);
-    mlxd_intr(bp);
+    mlxd_intr(bio);
 }
 
 /********************************************************************************
index cbd5430..91d71b0 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/mlx/mlx_compat.h,v 1.1.2.1 2001/06/25 04:37:51 msmith Exp $
- * $DragonFly: src/sys/dev/raid/mlx/mlx_compat.h,v 1.5 2004/02/21 06:37:06 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/mlx/mlx_compat.h,v 1.6 2006/02/17 19:18:05 dillon Exp $
  */
 /*
  * Portability and compatibility interfaces.
 # include <sys/proc.h>                 /* old buf style */
 # include <sys/buf.h>                  /* old buf style */
 # include <sys/buf2.h>
-typedef struct buf                     mlx_bio;
-typedef struct buf_queue_head          mlx_bioq;
-# define MLX_BIO_QINIT(bq)             bufq_init(&bq);
-# define MLX_BIO_QINSERT(bq, bp)       bufq_insert_tail(&bq, bp)
-# define MLX_BIO_QFIRST(bq)            bufq_first(&bq)
-# define MLX_BIO_QREMOVE(bq, bp)       bufq_remove(&bq, bp)
+typedef struct bio                     mlx_bio;
+typedef struct bio_queue_head          mlx_bioq;
+#if 0
+# define MLX_BIO_QINIT(bq)             bioq_init(&bq);
+# define MLX_BIO_QINSERT(bq, bp)       bioq_insert_tail(&bq, bp)
+# define MLX_BIO_QFIRST(bq)            bioq_first(&bq)
+# define MLX_BIO_QREMOVE(bq, bp)       bioq_remove(&bq, bp)
 # define MLX_BIO_IS_READ(bp)           ((bp)->b_flags & B_READ)
 # define MLX_BIO_DATA(bp)              (bp)->b_data
 # define MLX_BIO_LENGTH(bp)            (bp)->b_bcount
@@ -55,6 +56,7 @@ typedef struct buf_queue_head         mlx_bioq;
 # define MLX_BIO_DONE(bp)              biodone(bp)
 # define MLX_BIO_STATS_START(bp)       devstat_start_transaction(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats)
 # define MLX_BIO_STATS_END(bp)         devstat_end_transaction_buf(&((struct mlxd_softc *)MLX_BIO_SOFTC(bp))->mlxd_stats, bp)
+#endif
 #else
 # include <sys/bio.h>
 typedef struct bio                     mlx_bio;
index 1e41975..d18acc7 100644 (file)
@@ -25,7 +25,7 @@
  * SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/mlx/mlx_disk.c,v 1.8.2.4 2001/06/25 04:37:51 msmith Exp $
- * $DragonFly: src/sys/dev/raid/mlx/mlx_disk.c,v 1.7 2004/05/13 23:49:19 dillon Exp $
+ * $DragonFly: src/sys/dev/raid/mlx/mlx_disk.c,v 1.8 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -164,51 +164,54 @@ mlxd_ioctl(dev_t dev, u_long cmd, caddr_t addr, int32_t flag, d_thread_t *td)
  * be a multiple of a sector in length.
  */
 static void
-mlxd_strategy(mlx_bio *bp)
+mlxd_strategy(dev_t dev, mlx_bio *bio)
 {
-    struct mlxd_softc  *sc = (struct mlxd_softc *)MLX_BIO_SOFTC(bp);
+    struct buf *bp = bio->bio_buf;
+    struct mlxd_softc  *sc = (struct mlxd_softc *)bio->bio_driver_info;
 
     debug_called(1);
 
     /* bogus disk? */
     if (sc == NULL) {
-       MLX_BIO_SET_ERROR(bp, EINVAL);
+       bp->b_error = EINVAL;
+       bp->b_flags |= B_ERROR;
        goto bad;
     }
 
     /* XXX may only be temporarily offline - sleep? */
     if (sc->mlxd_drive->ms_state == MLX_SYSD_OFFLINE) {
-       MLX_BIO_SET_ERROR(bp, ENXIO);
+       bp->b_error = ENXIO;
+       bp->b_flags |= B_ERROR;
        goto bad;
     }
 
-    MLX_BIO_STATS_START(bp);
-    mlx_submit_buf(sc->mlxd_controller, bp);
+    devstat_start_transaction(&sc->mlxd_stats);
+    mlx_submit_bio(sc->mlxd_controller, bio);
     return;
 
  bad:
     /*
      * Correctly set the bio to indicate a failed tranfer.
      */
-    MLX_BIO_RESID(bp) = MLX_BIO_LENGTH(bp);
-    MLX_BIO_DONE(bp);
+    bp->b_resid = bp->b_bcount;
+    biodone(bio);
     return;
 }
 
 void
-mlxd_intr(void *data)
+mlxd_intr(struct bio *bio)
 {
-    mlx_bio            *bp = (mlx_bio *)data;
+    struct buf *bp = bio->bio_buf;
+    struct mlxd_softc  *sc = (struct mlxd_softc *)bio->bio_driver_info;
 
     debug_called(1);
-       
-    if (MLX_BIO_HAS_ERROR(bp))
-       MLX_BIO_SET_ERROR(bp, EIO);
-    else
-       MLX_BIO_RESID(bp) = 0;
 
-    MLX_BIO_STATS_END(bp);
-    MLX_BIO_DONE(bp);
+    if (bp->b_flags & B_ERROR)
+       bp->b_error = EIO;
+    else
+       bp->b_resid = 0;
+    devstat_end_transaction_buf(&sc->mlxd_stats, bp);
+    biodone(bio);
 }
 
 static int
index b443f39..2f2d7f0 100644 (file)
@@ -24,7 +24,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/mlx/mlxvar.h,v 1.5.2.3 2001/06/25 04:37:51 msmith Exp $
- *     $DragonFly: src/sys/dev/raid/mlx/mlxvar.h,v 1.6 2005/02/17 13:59:36 joerg Exp $
+ *     $DragonFly: src/sys/dev/raid/mlx/mlxvar.h,v 1.7 2006/02/17 19:18:05 dillon Exp $
  */
 
 /*
@@ -239,9 +239,9 @@ struct mlxd_softc
 /*
  * Interface between driver core and disk driver (should be using a bus?)
  */
-extern int     mlx_submit_buf(struct mlx_softc *sc, mlx_bio *bp);
+extern int     mlx_submit_bio(struct mlx_softc *sc, struct bio *bio);
 extern int     mlx_submit_ioctl(struct mlx_softc *sc, struct mlx_sysdrive *drive, u_long cmd, 
                                 caddr_t addr, int32_t flag, d_thread_t *td);
-extern void    mlxd_intr(void *data);
+extern void    mlxd_intr(struct bio *bio);
 
 
index 8f2e758..2037054 100644 (file)
@@ -26,7 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  * $FreeBSD: src/sys/dev/pst/pst-raid.c,v 1.2.2.1 2002/08/18 12:32:36 sos Exp $
- * $DragonFly: src/sys/dev/raid/pst/pst-raid.c,v 1.12 2005/06/10 17:10:26 swildner Exp $
+ * $DragonFly: src/sys/dev/raid/pst/pst-raid.c,v 1.13 2006/02/17 19:18:06 dillon Exp $
  */
 
 #include <sys/param.h>
@@ -82,7 +82,7 @@ struct pst_softc {
     dev_t                      device;
     struct devstat             stats;
     struct disk                        disk;
-    struct buf_queue_head      queue;
+    struct bio_queue_head      bio_queue;
     int                                outstanding;
 };
 
@@ -90,7 +90,7 @@ struct pst_request {
     struct pst_softc           *psc;           /* pointer to softc */
     u_int32_t                  mfa;            /* frame addreess */
     struct callout             timeout;        /* handle for untimeout */
-    struct buf                 *bp;            /* associated bio ptr */
+    struct bio                 *bio;           /* associated bio ptr */
 };
 
 /* prototypes */
@@ -166,7 +166,7 @@ pst_attach(device_t dev)
     sprintf(name, "%s %s", ident->vendor, ident->product);
     contigfree(reply, PAGE_SIZE, M_PSTRAID);
 
-    bufq_init(&psc->queue);
+    bioq_init(&psc->bio_queue);
 
     psc->device = disk_create(lun, &psc->disk, 0, &pst_cdevsw);
     psc->device->si_drv1 = psc;
@@ -223,12 +223,12 @@ pst_shutdown(device_t dev)
 #endif
 
 static void
-pststrategy(struct buf *bp)
+pststrategy(dev_t dev, struct bio *bio)
 {
-    struct pst_softc *psc = bp->b_dev->si_drv1;
+    struct pst_softc *psc = dev->si_drv1;
 
     crit_enter();
-    bufqdisksort(&psc->queue, bp);
+    bioqdisksort(&psc->bio_queue, bio);
     pst_start(psc);
     crit_exit();
 }
@@ -238,27 +238,29 @@ pst_start(struct pst_softc *psc)
 {
     struct pst_request *request;
     struct buf *bp;
+    struct bio *bio;
     u_int32_t mfa;
 
     if (psc->outstanding < (I2O_IOP_OUTBOUND_FRAME_COUNT - 1) &&
-       (bp = bufq_first(&psc->queue))) {
+       (bio = bioq_first(&psc->bio_queue))) {
        if ((mfa = iop_get_mfa(psc->iop)) != 0xffffffff) {
            request = malloc(sizeof(struct pst_request),
                               M_PSTRAID, M_INTWAIT | M_ZERO);
            psc->outstanding++;
            request->psc = psc;
            request->mfa = mfa;
-           request->bp = bp;
+           request->bio = bio;
            callout_init(&request->timeout);
            if (!dumping)
                callout_reset(&request->timeout, 10 * hz, pst_timeout, request);
-           bufq_remove(&psc->queue, bp);
+           bioq_remove(&psc->bio_queue, bio);
+           bp = bio->bio_buf;
            devstat_start_transaction(&psc->stats);
            if (pst_rw(request)) {
-               devstat_end_transaction_buf(&psc->stats, request->bp);
-               request->bp->b_error = EIO;
-               request->bp->b_flags |= B_ERROR;
-               biodone(request->bp);
+               devstat_end_transaction_buf(&psc->stats, bp);
+               bp->b_error = EIO;
+               bp->b_flags |= B_ERROR;
+               biodone(bio);
                iop_free_mfa(request->psc->iop, request->mfa);
                psc->outstanding--;
                callout_stop(&request->timeout);
@@ -274,15 +276,16 @@ pst_done(struct iop_softc *sc, u_int32_t mfa, struct i2o_single_reply *reply)
     struct pst_request *request =
         (struct pst_request *)reply->transaction_context;
     struct pst_softc *psc = request->psc;
+    struct buf *bp = request->bio->bio_buf;
 
     callout_stop(&request->timeout);
-    request->bp->b_resid = request->bp->b_bcount - reply->donecount;
-    devstat_end_transaction_buf(&psc->stats, request->bp);
+    bp->b_resid = bp->b_bcount - reply->donecount;
+    devstat_end_transaction_buf(&psc->stats, bp);
     if (reply->status) {
-       request->bp->b_error = EIO;
-       request->bp->b_flags |= B_ERROR;
+       bp->b_error = EIO;
+       bp->b_flags |= B_ERROR;
     }
-    biodone(request->bp);
+    biodone(request->bio);
     free(request, M_PSTRAID);
     crit_enter();
     psc->iop->reg->oqueue = mfa;
@@ -295,17 +298,18 @@ static void
 pst_timeout(void *xrequest)
 {
     struct pst_request *request = xrequest;
+    struct buf *bp = request->bio->bio_buf;
 
     crit_enter();
     printf("pst: timeout mfa=0x%08x cmd=%s\n",
-          request->mfa, request->bp->b_flags & B_READ ? "READ" : "WRITE");
+          request->mfa, bp->b_flags & B_READ ? "READ" : "WRITE");
     iop_free_mfa(request->psc->iop, request->mfa);
     if ((request->mfa = iop_get_mfa(request->psc->iop)) == 0xffffffff) {
        printf("pst: timeout no mfa possible\n");
-       devstat_end_transaction_buf(&request->psc->stats, request->bp);
-       request->bp->b_error = EIO;
-       request->bp->b_flags |= B_ERROR;
-       biodone(request->bp);
+       devstat_end_transaction_buf(&request->psc->stats, bp);
+       bp->b_error = EIO;
+       bp->b_flags |= B_ERROR;
+       biodone(request->bio);
        request->psc->outstanding--;
        crit_exit();
        return;
@@ -314,10 +318,10 @@ pst_timeout(void *xrequest)
        callout_reset(&request->timeout, 10 * hz, pst_timeout, request);
     if (pst_rw(request)) {
        iop_free_mfa(request->psc->iop, request->mfa);
-       devstat_end_transaction_buf(&request->psc->stats, request->bp);
-       request->bp->b_error = EIO;
-       request->bp->b_flags |= B_ERROR;
-       biodone(request->bp);
+       devstat_end_transaction_buf(&request->psc->stats, bp);
+       bp->b_error = EIO;
+       bp->b_flags |= B_ERROR;
+       biodone(request->bio);
        request->psc->outstanding--;
     }
     crit_exit();
@@ -328,6 +332,7 @@ pst_rw(struct pst_request *request)
 {
     struct i2o_bsa_rw_block_message *msg;
     int sgl_flag;
+    struct buf *bp = request->bio->bio_buf;
 
     msg = (struct i2o_bsa_rw_block_message *)
          (request->psc->iop->ibase + request->mfa);
@@ -337,7 +342,7 @@ pst_rw(struct pst_request *request)
     msg->message_size = sizeof(struct i2o_bsa_rw_block_message) >> 2;
     msg->target_address = request->psc->lct->local_tid;
     msg->initiator_address = I2O_TID_HOST;
-    if (request->bp->b_flags & B_READ) {
+    if (bp->b_flags & B_READ) {
        msg->function = I2O_BSA_BLOCK_READ;
        msg->control_flags = 0x0; /* 0x0c = read cache + readahead */
        msg->fetch_ahead = 0x0; /* 8 Kb */
@@ -352,10 +357,10 @@ pst_rw(struct pst_request *request)
     msg->initiator_context = (u_int32_t)pst_done;
     msg->transaction_context = (u_int32_t)request;
     msg->time_multiplier = 1;
-    msg->bytecount = request->bp->b_bcount;
-    msg->lba = ((u_int64_t)request->bp->b_pblkno) * (DEV_BSIZE * 1LL);
-    if (!iop_create_sgl((struct i2o_basic_message *)msg, request->bp->b_data,
-                       request->bp->b_bcount, sgl_flag))
+    msg->bytecount = bp->b_bcount;
+    msg->lba = ((u_int64_t)request->bio->bio_blkno) * (DEV_BSIZE * 1LL);
+    if (!iop_create_sgl((struct i2o_basic_message *)msg, bp->b_data,
+                       bp->b_bcount, sgl_flag))
        return -1;
     request->psc->iop->reg->iqueue = request->mfa;
     return 0;
index fd01ede..6849851 100644 (file)
@@ -27,7 +27,7 @@
  * SUCH DAMAGE.
  *
  *     $FreeBSD: src/sys/dev/twe/twe.c,v 1.1.2.10 2004/06/11 18:57:31 vkashyap Exp $
- *     $DragonFly: src/sys/dev/raid/twe/twe.c,v 1.12 2005/08/22 21:16:20 hmp Exp $
+ *     $DragonFly: src/sys/dev/raid/twe/twe.c,v 1.13 2006/02/17 19:18:06 dillon Exp $
  */
 
 /*
@@ -378,7 +378,7 @@ twe_startio(struct twe_softc *sc)
 {
     struct twe_request *tr;
     TWE_Command                *cmd;
-    twe_bio            *bp;
+    struct bio         *bio;
     int                        error;
 
     debug_called(4);
@@ -400,18 +400,18 @@ twe_startio(struct twe_softc *sc)
                break;
 
            /* see if there's work to be done */
-           if ((bp = twe_dequeue_bio(sc)) == NULL) {
+           if ((bio = twe_dequeue_bio(sc)) == NULL) {
                twe_release_request(tr);
                break;
            }
 
            /* connect the bio to the command */
            tr->tr_complete = twe_completeio;
-           tr->tr_private = bp;
-           tr->tr_data = TWE_BIO_DATA(bp);
-           tr->tr_length = TWE_BIO_LENGTH(bp);
+           tr->tr_private = bio;
+           tr->tr_data = bio->bio_buf->b_data;
+           tr->tr_length = bio->bio_buf->b_bcount;
            cmd = &tr->tr_command;
-           if (TWE_BIO_IS_READ(bp)) {
+           if (bio->bio_buf->b_flags & B_READ) {
                tr->tr_flags |= TWE_CMD_DATAIN;
                cmd->io.opcode = TWE_OP_READ;
            } else {
@@ -421,9 +421,9 @@ twe_startio(struct twe_softc *sc)
        
            /* build a suitable I/O command (assumes 512-byte rounded transfers) */
            cmd->io.size = 3;
-           cmd->io.unit = TWE_BIO_UNIT(bp);
+           cmd->io.unit = ((struct twed_softc *)bio->bio_driver_info)->twed_drive->td_twe_unit;
            cmd->io.block_count = (tr->tr_length + TWE_BLOCK_SIZE - 1) / TWE_BLOCK_SIZE;
-           cmd->io.lba = TWE_BIO_LBA(bp);
+           cmd->io.lba = bio->bio_blkno;
        }
        
        /* did we find something to do? */
@@ -438,10 +438,11 @@ twe_startio(struct twe_softc *sc)
                break;
            tr->tr_status = TWE_CMD_ERROR;
            if (tr->tr_private != NULL) {
-               bp = (twe_bio *)(tr->tr_private);
-               TWE_BIO_SET_ERROR(bp, error);
+               bio&nb