From 10f3fee58821ab59bbaf8753b17cfb8c679b31bf Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Sun, 30 Apr 2006 17:22:18 +0000 Subject: [PATCH] Replace the the buffer cache's B_READ, B_WRITE, B_FORMAT, and B_FREEBUF b_flags with a separate b_cmd field. Use b_cmd to test for I/O completion as well (getting rid of B_DONE in the process). This further simplifies the setup required to issue a buffer cache I/O. Remove a redundant header file, bus/isa/i386/isa_dma.h and merge any discrepancies into bus/isa/isavar.h. Give ISADMA_READ/WRITE/RAW their own independant flag definitions instead of trying to overload them on top of B_READ, B_WRITE, and B_RAW. Add a routine isa_dmabp() which takes a struct buf pointer and returns the ISA dma flags associated with the operation. Remove the 'clear_modify' argument to vfs_busy_pages(). Instead, vfs_busy_pages() asserts that the buffer's b_cmd is valid and then uses it to determine the action it must take. --- sys/amd64/amd64/genassym.c | 3 +- sys/bus/cam/cam_periph.c | 21 ++-- sys/bus/cam/scsi/scsi_cd.c | 4 +- sys/bus/cam/scsi/scsi_da.c | 4 +- sys/bus/cam/scsi/scsi_pt.c | 4 +- sys/bus/cam/scsi/scsi_sa.c | 10 +- sys/bus/firewire/fwmem.c | 4 +- sys/bus/isa/i386/isa_device.h | 7 +- sys/bus/isa/i386/isa_dma.c | 27 ++++- sys/bus/isa/i386/isa_dma.h | 57 ----------- sys/bus/isa/isavar.h | 12 ++- sys/contrib/dev/fla/fla.c | 15 ++- sys/dev/disk/ata/ata-disk.c | 4 +- sys/dev/disk/ata/ata-raid.c | 18 ++-- sys/dev/disk/ata/atapi-cd.c | 6 +- sys/dev/disk/ata/atapi-fd.c | 8 +- sys/dev/disk/ata/atapi-tape.c | 10 +- sys/dev/disk/ccd/ccd.c | 8 +- sys/dev/disk/fd/fd.c | 52 +++++----- sys/dev/disk/mcd/mcd.c | 4 +- sys/dev/disk/md/md.c | 40 ++++++-- sys/dev/disk/scd/scd.c | 4 +- sys/dev/disk/vn/vn.c | 16 +-- sys/dev/disk/wt/wt.c | 13 ++- sys/dev/misc/labpc/labpc.c | 6 +- sys/dev/misc/ppc/ppc.c | 9 +- sys/dev/raid/aac/aac.c | 6 +- sys/dev/raid/aac/aac_compat.h | 9 +- sys/dev/raid/amr/amr.c | 4 +- sys/dev/raid/ida/ida.c | 4 +- sys/dev/raid/ida/ida_disk.c | 4 +- sys/dev/raid/ips/ips.h | 20 +--- sys/dev/raid/mlx/mlx.c | 4 +- sys/dev/raid/mlx/mlx_compat.h | 20 +--- sys/dev/raid/pst/pst-raid.c | 6 +- sys/dev/raid/twe/twe.c | 4 +- sys/dev/raid/twe/twe_compat.h | 20 +--- sys/dev/raid/vinum/vinumdaemon.c | 4 +- sys/dev/raid/vinum/vinumext.h | 8 +- sys/dev/raid/vinum/vinuminterrupt.c | 18 ++-- sys/dev/raid/vinum/vinumio.c | 12 +-- sys/dev/raid/vinum/vinumparser.c | 3 +- sys/dev/raid/vinum/vinumraid5.c | 10 +- sys/dev/raid/vinum/vinumrequest.c | 23 +++-- sys/dev/raid/vinum/vinumrevive.c | 19 ++-- sys/dev/raid/vinum/vinumstate.c | 4 +- sys/dev/sound/pcm/buffer.c | 13 +-- sys/dev/sound/pcm/sound.h | 7 +- sys/dev/video/gsc/gsc.c | 6 +- sys/i386/i386/genassym.c | 3 +- sys/i386/i386/machdep.c | 6 +- sys/i386/isa/asc.c | 8 +- sys/kern/kern_device.c | 5 +- sys/kern/kern_physio.c | 10 +- sys/kern/subr_devstat.c | 14 ++- sys/kern/subr_disk.c | 13 ++- sys/kern/subr_diskmbr.c | 6 +- sys/kern/subr_diskslice.c | 14 +-- sys/kern/vfs_aio.c | 13 ++- sys/kern/vfs_bio.c | 148 +++++++++++++++------------ sys/kern/vfs_cluster.c | 78 +++++++------- sys/kern/vfs_default.c | 10 +- sys/kern/vfs_vopops.c | 4 +- sys/platform/pc32/i386/genassym.c | 3 +- sys/platform/pc32/i386/machdep.c | 6 +- sys/platform/pc32/isa/asc.c | 8 +- sys/platform/vkernel/i386/genassym.c | 3 +- sys/sys/buf.h | 24 +++-- sys/vfs/gnu/ext2fs/ext2_bmap.c | 6 +- sys/vfs/gnu/ext2fs/ext2_inode.c | 10 +- sys/vfs/mfs/mfs_vnops.c | 45 +++++--- sys/vfs/nfs/nfs_bio.c | 45 ++++---- sys/vfs/nfs/nfs_vnops.c | 29 +++--- sys/vfs/ntfs/ntfs_vnops.c | 19 ++-- sys/vfs/nwfs/nwfs_io.c | 10 +- sys/vfs/smbfs/smbfs_io.c | 9 +- sys/vfs/specfs/spec_vnops.c | 27 +++-- sys/vfs/ufs/ffs_alloc.c | 4 +- sys/vfs/ufs/ffs_inode.c | 6 +- sys/vfs/ufs/ffs_rawread.c | 14 ++- sys/vfs/ufs/ffs_softdep.c | 4 +- sys/vfs/ufs/ufs_bmap.c | 6 +- sys/vfs/union/union_vnops.c | 4 +- sys/vm/swap_pager.c | 73 ++++++------- sys/vm/vm_pager.c | 3 +- sys/vm/vm_swap.c | 4 +- sys/vm/vnode_pager.c | 14 ++- 87 files changed, 643 insertions(+), 659 deletions(-) delete mode 100644 sys/bus/isa/i386/isa_dma.h diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index fbe986966a..866dfdefe8 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/amd64/amd64/Attic/genassym.c,v 1.9 2005/12/01 18:30:11 dillon Exp $ + * $DragonFly: src/sys/amd64/amd64/Attic/genassym.c,v 1.10 2006/04/30 17:22:13 dillon Exp $ */ #include @@ -171,7 +171,6 @@ ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); #endif -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/bus/cam/cam_periph.c b/sys/bus/cam/cam_periph.c index 78cf0f7cb9..7e4c7c3465 100644 --- a/sys/bus/cam/cam_periph.c +++ b/sys/bus/cam/cam_periph.c @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/cam/cam_periph.c,v 1.24.2.3 2003/01/25 19:04:40 dillon Exp $ - * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.13 2006/04/28 16:33:57 dillon Exp $ + * $DragonFly: src/sys/bus/cam/cam_periph.c,v 1.14 2006/04/30 17:22:14 dillon Exp $ */ #include @@ -481,7 +481,7 @@ int cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) { int numbufs, i, j; - int flags[CAM_PERIPH_MAXMAPS]; + buf_cmd_t cmd[CAM_PERIPH_MAXMAPS]; u_int8_t **data_ptrs[CAM_PERIPH_MAXMAPS]; u_int32_t lengths[CAM_PERIPH_MAXMAPS]; u_int32_t dirs[CAM_PERIPH_MAXMAPS]; @@ -528,8 +528,12 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) * have to unmap any previously mapped buffers. */ for (i = 0; i < numbufs; i++) { - - flags[i] = 0; + /* + * Its kinda bogus, we need a R+W command. For now the + * buffer needs some sort of command. Use BUF_CMD_WRITE + * to indicate a write and BUF_CMD_READ to indicate R+W. + */ + cmd[i] = BUF_CMD_WRITE; /* * The userland data pointer passed in may not be page @@ -550,7 +554,6 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) } if (dirs[i] & CAM_DIR_OUT) { - flags[i] = B_WRITE; if (!useracc(*data_ptrs[i], lengths[i], VM_PROT_READ)) { printf("cam_periph_mapmem: error, " @@ -562,12 +565,8 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) } } - /* - * XXX this check is really bogus, since B_WRITE currently - * is all 0's, and so it is "set" all the time. - */ if (dirs[i] & CAM_DIR_IN) { - flags[i] |= B_READ; + cmd[i] = BUF_CMD_READ; if (!useracc(*data_ptrs[i], lengths[i], VM_PROT_WRITE)) { printf("cam_periph_mapmem: error, " @@ -598,7 +597,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) mapinfo->bp[i]->b_bufsize = lengths[i]; /* set the flags */ - mapinfo->bp[i]->b_flags |= flags[i]; + mapinfo->bp[i]->b_cmd = cmd[i]; /* map the buffer into kernel memory */ if (vmapbuf(mapinfo->bp[i]) < 0) { diff --git a/sys/bus/cam/scsi/scsi_cd.c b/sys/bus/cam/scsi/scsi_cd.c index 418081d8a4..0bb3f19c55 100644 --- a/sys/bus/cam/scsi/scsi_cd.c +++ b/sys/bus/cam/scsi/scsi_cd.c @@ -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.21 2006/03/24 18:35:26 dillon Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_cd.c,v 1.22 2006/04/30 17:22:15 dillon Exp $ */ /* * Portions of this driver taken from the original FreeBSD cd driver. @@ -1552,7 +1552,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb) (bp->b_flags & B_ORDERED) != 0 ? MSG_ORDERED_Q_TAG : MSG_SIMPLE_Q_TAG, - /* read */bp->b_flags & B_READ, + /* read */(bp->b_cmd == BUF_CMD_READ), /* byte2 */ 0, /* minimum_cmd_size */ 10, /* lba */ diff --git a/sys/bus/cam/scsi/scsi_da.c b/sys/bus/cam/scsi/scsi_da.c index d215a54bee..cef1523cc2 100644 --- a/sys/bus/cam/scsi/scsi_da.c +++ b/sys/bus/cam/scsi/scsi_da.c @@ -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.28 2006/03/24 18:35:27 dillon Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_da.c,v 1.29 2006/04/30 17:22:15 dillon Exp $ */ #ifdef _KERNEL @@ -1399,7 +1399,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb) /*retries*/da_retry_count, dadone, tag_code, - bp->b_flags & B_READ, + (bp->b_cmd == BUF_CMD_READ), /*byte2*/0, softc->minimum_cmd_size, bio->bio_offset / softc->params.secsize, diff --git a/sys/bus/cam/scsi/scsi_pt.c b/sys/bus/cam/scsi/scsi_pt.c index 0c8c472883..9a9512691a 100644 --- a/sys/bus/cam/scsi/scsi_pt.c +++ b/sys/bus/cam/scsi/scsi_pt.c @@ -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.13 2006/02/17 19:17:42 dillon Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_pt.c,v 1.14 2006/04/30 17:22:15 dillon Exp $ */ #include @@ -533,7 +533,7 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb) /*retries*/4, ptdone, MSG_SIMPLE_Q_TAG, - bp->b_flags & B_READ, + (bp->b_cmd == BUF_CMD_READ), /*byte2*/0, bp->b_bcount, bp->b_data, diff --git a/sys/bus/cam/scsi/scsi_sa.c b/sys/bus/cam/scsi/scsi_sa.c index d57928e511..bc20769c6c 100644 --- a/sys/bus/cam/scsi/scsi_sa.c +++ b/sys/bus/cam/scsi/scsi_sa.c @@ -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.16 2006/03/25 21:30:41 swildner Exp $ + * $DragonFly: src/sys/bus/cam/scsi/scsi_sa.c,v 1.17 2006/04/30 17:22:15 dillon Exp $ * * Implementation of SCSI Sequential Access Peripheral driver for CAM. * @@ -751,7 +751,7 @@ sastrategy(dev_t dev, struct bio *bio) CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastrategy: enqueuing a %d " "%s byte %s queue count now %d\n", (int) bp->b_bcount, (softc->flags & SA_FLAG_FIXED)? "fixed" : "variable", - (bp->b_flags & B_READ)? "read" : "write", softc->queue_count)); + (bp->b_cmd == BUF_CMD_READ)? "read" : "write", softc->queue_count)); crit_exit(); @@ -1652,10 +1652,10 @@ again: * have to do deal with 512 byte or 1KB intermediate * records. */ - softc->dsreg = (bp->b_flags & B_READ)? + softc->dsreg = (bp->b_cmd == BUF_CMD_READ) ? MTIO_DSREG_RD : MTIO_DSREG_WR; scsi_sa_read_write(&start_ccb->csio, 0, sadone, - MSG_SIMPLE_Q_TAG, (bp->b_flags & B_READ) != 0, + MSG_SIMPLE_Q_TAG, (bp->b_cmd == BUF_CMD_READ) != 0, FALSE, (softc->flags & SA_FLAG_FIXED) != 0, length, bp->b_data, bp->b_bcount, SSD_FULL_SIZE, IO_TIMEOUT); @@ -1749,7 +1749,7 @@ sadone(struct cam_periph *periph, union ccb *done_ccb) if (csio->resid != 0) { bp->b_flags |= B_ERROR; } - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_cmd != BUF_CMD_READ) { softc->flags |= SA_FLAG_TAPE_WRITTEN; softc->filemarks = 0; } diff --git a/sys/bus/firewire/fwmem.c b/sys/bus/firewire/fwmem.c index 3d632d0ccc..694cd7b553 100644 --- a/sys/bus/firewire/fwmem.c +++ b/sys/bus/firewire/fwmem.c @@ -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.8 2006/02/17 19:17:44 dillon Exp $ + * $DragonFly: src/sys/bus/firewire/fwmem.c,v 1.9 2006/04/30 17:22:15 dillon Exp $ */ #ifndef __DragonFly__ @@ -371,7 +371,7 @@ fwmem_strategy(dev_t dev, struct bio *bio) } iolen = MIN(bp->b_bcount, MAXLEN); - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { if (iolen == 4 && (bio->bio_offset & 3) == 0) xfer = fwmem_read_quad(fwdev, (void *) bio, fwmem_speed, diff --git a/sys/bus/isa/i386/isa_device.h b/sys/bus/isa/i386/isa_device.h index f731738293..588360c3cf 100644 --- a/sys/bus/isa/i386/isa_device.h +++ b/sys/bus/isa/i386/isa_device.h @@ -32,17 +32,12 @@ * * from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91 * $FreeBSD: src/sys/i386/isa/isa_device.h,v 1.68 2000/01/29 18:01:10 peter Exp $ - * $DragonFly: src/sys/bus/isa/i386/isa_device.h,v 1.7 2005/10/13 00:02:28 dillon Exp $ + * $DragonFly: src/sys/bus/isa/i386/isa_device.h,v 1.8 2006/04/30 17:22:15 dillon Exp $ */ #ifndef _I386_ISA_ISA_DEVICE_H_ #define _I386_ISA_ISA_DEVICE_H_ -#ifdef _KERNEL -#ifndef _ISA_ISAVAR_H_ -#include "isa_dma.h" -#endif -#endif #ifndef _SYS_INTERRUPT_H_ #include #endif diff --git a/sys/bus/isa/i386/isa_dma.c b/sys/bus/isa/i386/isa_dma.c index d70fbe740e..4ddc48acef 100644 --- a/sys/bus/isa/i386/isa_dma.c +++ b/sys/bus/isa/i386/isa_dma.c @@ -35,7 +35,7 @@ * * from: @(#)isa.c 7.2 (Berkeley) 5/13/91 * $FreeBSD: src/sys/i386/isa/isa_dma.c,v 1.4.2.1 2000/08/08 19:49:53 peter Exp $ - * $DragonFly: src/sys/bus/isa/i386/isa_dma.c,v 1.7 2006/01/22 14:03:51 swildner Exp $ + * $DragonFly: src/sys/bus/isa/i386/isa_dma.c,v 1.8 2006/04/30 17:22:15 dillon Exp $ */ /* @@ -50,13 +50,16 @@ #include #include +#include +#include #include +#include #include #include #include #include "isa.h" -#include "isa_dma.h" #include +#include /* ** Register definitions for DMA controller 1 (channels 0..3): @@ -239,7 +242,7 @@ isa_dmastart(int flags, caddr_t addr, u_int nbytes, int chan) newaddr = dma_bouncebuf[chan]; /* copy bounce buffer on write */ - if (!(flags & ISADMA_READ)) + if (flags & ISADMA_WRITE) bcopy(addr, newaddr, nbytes); addr = newaddr; } @@ -491,3 +494,21 @@ isa_dmastop(int chan) } return(isa_dmastatus(chan)); } + +unsigned +isa_dmabp(struct buf *bp) +{ + unsigned flags = 0; + + KKASSERT(bp->b_cmd != BUF_CMD_DONE); + if (bp->b_flags & B_RAW) + flags |= ISADMA_RAW; + if (bp->b_cmd == BUF_CMD_READ) { + flags |= ISADMA_READ; + } else { + /* BUF_CMD_WRITE, BUF_CMD_FORMAT */ + flags |= ISADMA_WRITE; + } + return(flags); +} + diff --git a/sys/bus/isa/i386/isa_dma.h b/sys/bus/isa/i386/isa_dma.h deleted file mode 100644 index e44253d752..0000000000 --- a/sys/bus/isa/i386/isa_dma.h +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)isa_device.h 7.1 (Berkeley) 5/9/91 - * $FreeBSD: src/sys/i386/isa/isa_dma.h,v 1.3.2.1 2000/08/08 19:49:53 peter Exp $ - * $DragonFly: src/sys/bus/isa/i386/Attic/isa_dma.h,v 1.3 2003/08/27 11:42:34 rob Exp $ - */ - -#ifndef _I386_ISA_ISA_DMA_H_ -#define _I386_ISA_ISA_DMA_H_ - -#ifdef _KERNEL - -#define ISADMA_READ 0x00100000 -#define ISADMA_WRITE 0 -#define ISADMA_RAW 0x00080000 - -void isa_dmacascade (int chan); -void isa_dmadone (int flags, caddr_t addr, int nbytes, int chan); -void isa_dmainit (int chan, u_int bouncebufsize); -void isa_dmastart (int flags, caddr_t addr, u_int nbytes, int chan); -int isa_dma_acquire (int chan); -void isa_dma_release (int chan); -int isa_dmastatus (int chan); -int isa_dmastop (int chan); -#endif - -#endif /* !_I386_ISA_ISA_DMA_H_ */ diff --git a/sys/bus/isa/isavar.h b/sys/bus/isa/isavar.h index edc048b18b..57f888e060 100644 --- a/sys/bus/isa/isavar.h +++ b/sys/bus/isa/isavar.h @@ -24,14 +24,16 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/isa/isavar.h,v 1.16.2.2 2000/10/29 13:07:56 nyan Exp $ - * $DragonFly: src/sys/bus/isa/isavar.h,v 1.8 2005/06/12 20:55:14 swildner Exp $ + * $DragonFly: src/sys/bus/isa/isavar.h,v 1.9 2006/04/30 17:22:15 dillon Exp $ */ #ifndef _ISA_ISAVAR_H_ #define _ISA_ISAVAR_H_ +struct buf; struct isa_config; struct isa_pnp_id; + typedef void isa_config_cb(void *arg, struct isa_config *config, int enable); #include "isa_if.h" @@ -55,9 +57,10 @@ typedef void isa_config_cb(void *arg, struct isa_config *config, int enable); #define ISA_NIRQ 2 #define ISA_NDRQ 2 -#define ISADMA_READ 0x00100000 -#define ISADMA_WRITE 0 -#define ISADMA_RAW 0x00080000 +#define ISADMA_READ 0x00000001 +#define ISADMA_WRITE 0x00000002 +#define ISADMA_RAW 0x00000004 + /* * Plug and play cards can support a range of resource * configurations. This structure is used by the isapnp parser to @@ -172,6 +175,7 @@ extern int isa_dma_acquire (int chan); extern void isa_dma_release (int chan); extern int isa_dmastatus (int chan); extern int isa_dmastop (int chan); +unsigned isa_dmabp (struct buf *); int isab_attach(device_t dev); diff --git a/sys/contrib/dev/fla/fla.c b/sys/contrib/dev/fla/fla.c index 460e657280..43ee3aa5d7 100644 --- a/sys/contrib/dev/fla/fla.c +++ b/sys/contrib/dev/fla/fla.c @@ -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.11 2006/03/24 18:35:29 dillon Exp $ + * $DragonFly: src/sys/contrib/dev/fla/Attic/fla.c,v 1.12 2006/04/30 17:22:15 dillon Exp $ * */ @@ -227,12 +227,19 @@ flastrategy(dev_t dev, struct bio *bio) bp->b_resid = bp->b_bcount; unit = dkunit(dev); - if (bp->b_flags & B_FREEBUF) + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: what = DOC2K_ERASE; - else if (bp->b_flags & B_READ) + break; + case BUF_CMD_READ: what = DOC2K_READ; - else + break; + case BUF_CMD_WRITE: what = DOC2K_WRITE; + break; + default: + panic("fla: bad b_cmd %d", bp->b_cmd); + } LEAVE(); diff --git a/sys/dev/disk/ata/ata-disk.c b/sys/dev/disk/ata/ata-disk.c index 3cbbf0171e..8ff4023bae 100644 --- a/sys/dev/disk/ata/ata-disk.c +++ b/sys/dev/disk/ata/ata-disk.c @@ -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.27 2006/03/24 18:35:30 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-disk.c,v 1.28 2006/04/30 17:22:16 dillon Exp $ */ #include "opt_ata.h" @@ -432,7 +432,7 @@ ad_start(struct ata_device *atadev) request->data = bp->b_data; request->tag = tag; callout_init(&request->callout); - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) request->flags |= ADR_F_READ; if (adp->device->mode >= ATA_DMA) { if (ata_dmaalloc(atadev, M_NOWAIT) != 0) { diff --git a/sys/dev/disk/ata/ata-raid.c b/sys/dev/disk/ata/ata-raid.c index 3621c8f2ee..e8d3ab00f5 100644 --- a/sys/dev/disk/ata/ata-raid.c +++ b/sys/dev/disk/ata/ata-raid.c @@ -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.18 2006/04/28 16:33:58 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/ata-raid.c,v 1.19 2006/04/30 17:22:16 dillon Exp $ */ #include "opt_ata.h" @@ -559,6 +559,7 @@ arstrategy(dev_t dev, struct bio *bio) buf1->bp.b_bcount = chunk * DEV_BSIZE; buf1->bp.b_data = data; buf1->bp.b_flags = bp->b_flags | B_PAGING; + buf1->bp.b_cmd = bp->b_cmd; buf1->bp.b_bio1.bio_done = ar_done; buf1->org = bio; buf1_blkno = (int)(buf1->bp.b_bio1.bio_offset >> DEV_BSHIFT); @@ -583,7 +584,7 @@ arstrategy(dev_t dev, struct bio *bio) case AR_F_RAID1: case AR_F_RAID0 | AR_F_RAID1: - if ((rdp->flags & AR_F_REBUILDING) && !(bp->b_flags & B_READ)) { + if ((rdp->flags & AR_F_REBUILDING) && bp->b_cmd != BUF_CMD_READ) { if ((orig_blkno >= rdp->lock_start && orig_blkno < rdp->lock_end) || ((orig_blkno + chunk) > rdp->lock_start && @@ -613,7 +614,7 @@ arstrategy(dev_t dev, struct bio *bio) biodone(bio); return; } - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { if ((buf1_blkno < (rdp->disks[buf1->drive].last_lba - AR_PROXIMITY) || buf1_blkno > @@ -687,7 +688,7 @@ ar_done(struct bio *bio) rdp->disks[buf->drive].flags &= ~AR_DF_ONLINE; ar_config_changed(rdp, 1); if (rdp->flags & AR_F_READY) { - if (buf->bp.b_flags & B_READ) { + if (buf->bp.b_cmd == BUF_CMD_READ) { if (buf->drive < rdp->width) buf->drive = buf->drive + rdp->width; else @@ -715,7 +716,7 @@ ar_done(struct bio *bio) } } else { - if (!(buf->bp.b_flags & B_READ)) { + if (buf->bp.b_cmd != BUF_CMD_READ) { if (buf->mirror && !(buf->flags & AB_F_DONE)){ buf->mirror->flags |= AB_F_DONE; break; @@ -1402,14 +1403,15 @@ ar_rw(struct ad_softc *adp, u_int32_t lba, int count, caddr_t data, int flags) else bp->b_bio1.bio_done = ar_rw_done; if (flags & AR_READ) - bp->b_flags |= B_READ; + bp->b_cmd = BUF_CMD_READ; if (flags & AR_WRITE) - bp->b_flags |= B_WRITE; + bp->b_cmd = BUF_CMD_WRITE; + KKASSERT(bp->b_cmd != BUF_CMD_DONE); dev_dstrategy(adp->dev, &bp->b_bio1); if (flags & AR_WAIT) { - while ((retry++ < (15*hz/10)) && (error = !(bp->b_flags & B_DONE))) + while ((retry++ < (15*hz/10)) && (error = !(bp->b_cmd == BUF_CMD_DONE))) error = tsleep(&bp->b_bio1, 0, "arrw", 10); if (!error && (bp->b_flags & B_ERROR)) error = bp->b_error; diff --git a/sys/dev/disk/ata/atapi-cd.c b/sys/dev/disk/ata/atapi-cd.c index 5f030f2922..696ca18670 100644 --- a/sys/dev/disk/ata/atapi-cd.c +++ b/sys/dev/disk/ata/atapi-cd.c @@ -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.21 2006/03/24 18:35:30 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-cd.c,v 1.22 2006/04/30 17:22:16 dillon Exp $ */ #include "opt_ata.h" @@ -1181,7 +1181,7 @@ acd_start(struct ata_device *atadev) } count = bp->b_bcount / blocksize; - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { /* if transfer goes beyond range adjust it to be within limits */ if (lba + count > lastlba) { /* if we are entirely beyond EOM return EOF */ @@ -1222,7 +1222,7 @@ acd_start(struct ata_device *atadev) devstat_start_transaction(cdp->stats); 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, + ((bp->b_cmd == BUF_CMD_READ) ? ATPR_F_READ : 0), (ccb[0] == ATAPI_WRITE_BIG) ? 60 : 30, acd_done, bio); } diff --git a/sys/dev/disk/ata/atapi-fd.c b/sys/dev/disk/ata/atapi-fd.c index 6b48f40eeb..69632e32b3 100644 --- a/sys/dev/disk/ata/atapi-fd.c +++ b/sys/dev/disk/ata/atapi-fd.c @@ -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.14 2006/03/24 18:35:30 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-fd.c,v 1.15 2006/04/30 17:22:16 dillon Exp $ */ #include @@ -353,7 +353,7 @@ afd_start(struct ata_device *atadev) bzero(ccb, sizeof(ccb)); - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) ccb[0] = ATAPI_READ_BIG; else ccb[0] = ATAPI_WRITE_BIG; @@ -368,8 +368,8 @@ afd_start(struct ata_device *atadev) devstat_start_transaction(&fdp->stats); 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, bio); + ((bp->b_cmd == BUF_CMD_READ) ? ATPR_F_READ : 0), + 30, afd_done, bio); } static int diff --git a/sys/dev/disk/ata/atapi-tape.c b/sys/dev/disk/ata/atapi-tape.c index cece6f602f..2ac4bcbec4 100644 --- a/sys/dev/disk/ata/atapi-tape.c +++ b/sys/dev/disk/ata/atapi-tape.c @@ -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.14 2006/03/24 18:35:30 dillon Exp $ + * $DragonFly: src/sys/dev/disk/ata/atapi-tape.c,v 1.15 2006/04/30 17:22:16 dillon Exp $ */ #include "opt_ata.h" @@ -437,7 +437,7 @@ aststrategy(dev_t dev, struct bio *bio) biodone(bio); return; } - if (!(bp->b_flags & B_READ) && stp->flags & F_WRITEPROTECT) { + if (bp->b_cmd != BUF_CMD_READ && (stp->flags & F_WRITEPROTECT)) { bp->b_flags |= B_ERROR; bp->b_error = EPERM; biodone(bio); @@ -483,7 +483,7 @@ ast_start(struct ata_device *atadev) bzero(ccb, sizeof(ccb)); bp = bio->bio_buf; - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) ccb[0] = ATAPI_READ; else ccb[0] = ATAPI_WRITE; @@ -499,7 +499,7 @@ ast_start(struct ata_device *atadev) devstat_start_transaction(&stp->stats); atapi_queue_cmd(stp->device, ccb, bp->b_data, blkcount * stp->blksize, - (bp->b_flags & B_READ) ? ATPR_F_READ : 0, + ((bp->b_cmd == BUF_CMD_READ) ? ATPR_F_READ : 0), 120, ast_done, bio); } @@ -514,7 +514,7 @@ ast_done(struct atapi_request *request) bp->b_error = request->error; bp->b_flags |= B_ERROR; } else { - if (!(bp->b_flags & B_READ)) + if (bp->b_cmd != BUF_CMD_READ) stp->flags |= F_DATA_WRITTEN; bp->b_resid = bp->b_bcount - request->donecount; ast_total += (bp->b_bcount - bp->b_resid); diff --git a/sys/dev/disk/ccd/ccd.c b/sys/dev/disk/ccd/ccd.c index 1d4fee6f83..eefeba9600 100644 --- a/sys/dev/disk/ccd/ccd.c +++ b/sys/dev/disk/ccd/ccd.c @@ -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.26 2006/04/28 16:33:59 dillon Exp $ */ +/* $DragonFly: src/sys/dev/disk/ccd/ccd.c,v 1.27 2006/04/30 17:22:16 dillon Exp $ */ /* $NetBSD: ccd.c,v 1.22 1995/12/08 19:13:26 thorpej Exp $ */ @@ -875,7 +875,7 @@ ccdstart(struct ccd_softc *cs, struct bio *bio) * to writes when making this determination and we * also try to avoid hogging. */ - if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) { + if (cbp[0]->cb_buf.b_cmd != BUF_CMD_READ) { vn_strategy(cbp[0]->cb_vp, &cbp[0]->cb_buf.b_bio1); vn_strategy(cbp[1]->cb_vp, @@ -1159,7 +1159,7 @@ ccdiodone(struct bio *bio) const char *msg = ""; if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) && - (cbp->cb_buf.b_flags & B_READ) && + (cbp->cb_buf.b_cmd == BUF_CMD_READ) && (cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) { /* * We will try our read on the other disk down @@ -1193,7 +1193,7 @@ ccdiodone(struct bio *bio) */ if (ccd_softc[unit].sc_cflags & CCDF_MIRROR) { - if ((cbp->cb_buf.b_flags & B_READ) == 0) { + if (cbp->cb_buf.b_cmd != BUF_CMD_READ) { /* * When writing, handshake with the second buffer * to determine when both are done. If both are not diff --git a/sys/dev/disk/fd/fd.c b/sys/dev/disk/fd/fd.c index 5c31ca86e5..5ecb76317e 100644 --- a/sys/dev/disk/fd/fd.c +++ b/sys/dev/disk/fd/fd.c @@ -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.28 2006/04/28 16:34:00 dillon Exp $ + * $DragonFly: src/sys/dev/disk/fd/fd.c,v 1.29 2006/04/30 17:22:16 dillon Exp $ * */ @@ -92,9 +92,6 @@ #include "fdc.h" #include -/* misuse a flag to identify format operation */ -#define B_FORMAT B_XXX - /* configuration flags */ #define FDC_PRETEND_D0 (1 << 0) /* pretend drive 0 to be there */ #define FDC_NO_FIFO (1 << 2) /* do not enable FIFO */ @@ -1403,7 +1400,7 @@ fdstrategy(dev_t dev, struct bio *bio) }; fdblk = 128 << (fd->ft->secsize); - if (!(bp->b_flags & B_FORMAT)) { + if (bp->b_cmd != BUF_CMD_FORMAT) { if (bio->bio_offset < 0) { printf( "fd%d: fdstrat: bad request offset = %lld, bcount = %d\n", @@ -1545,11 +1542,11 @@ fdc_intr(void *xfdc) /* * fdcpio(): perform programmed IO read/write for YE PCMCIA floppy */ -static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count) +static int fdcpio(fdc_p fdc, buf_cmd_t cmd, caddr_t addr, u_int count) { u_char *cptr = (u_char *)addr; - if (flags & B_READ) { + if (cmd == BUF_CMD_READ) { if (fdc->state != PIOREAD) { fdc->state = PIOREAD; return(0); @@ -1613,8 +1610,8 @@ fdstate(fdc_p fdc) fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); - read = bp->b_flags & B_READ; - format = bp->b_flags & B_FORMAT; + read = (bp->b_cmd == BUF_CMD_READ); + format = (bp->b_cmd == BUF_CMD_FORMAT); if (format) { finfo = (struct fd_formb *)bp->b_data; fd->skip = (char *)&(finfo->fd_formb_cylno(0)) @@ -1759,9 +1756,11 @@ fdstate(fdc_p fdc) } fd->track = b_cylinder; - if (!(fdc->flags & FDC_NODMA)) - isa_dmastart(bp->b_flags, bp->b_data+fd->skip, + if (!(fdc->flags & FDC_NODMA)) { + isa_dmastart(isa_dmabp(bp), + bp->b_data+fd->skip, format ? bp->b_bcount : fdblk, fdc->dmachan); + } sectrac = fd->ft->sectrac; sec = blknum % (sectrac * fd->ft->heads); head = sec / sectrac; @@ -1775,7 +1774,7 @@ fdstate(fdc_p fdc) { /* stuck controller? */ if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(bp->b_flags, + isa_dmadone(isa_dmabp(bp), bp->b_data + fd->skip, format ? bp->b_bcount : fdblk, fdc->dmachan); @@ -1819,7 +1818,7 @@ fdstate(fdc_p fdc) */ SET_BCDR(fdc, 1, bp->b_bcount, 0); - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_cmd, bp->b_data+fd->skip, bp->b_bcount); @@ -1832,7 +1831,7 @@ fdstate(fdc_p fdc) finfo->fd_formb_fillbyte, 0)) { /* controller fell over */ if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(bp->b_flags, + isa_dmadone(isa_dmabp(bp), bp->b_data + fd->skip, format ? bp->b_bcount : fdblk, fdc->dmachan); @@ -1852,7 +1851,7 @@ fdstate(fdc_p fdc) * the WRITE command is sent */ if (!read) - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_cmd, bp->b_data+fd->skip, fdblk); } @@ -1869,7 +1868,7 @@ fdstate(fdc_p fdc) 0)) { /* the beast is sleeping again */ if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(bp->b_flags, + isa_dmadone(isa_dmabp(bp), bp->b_data + fd->skip, format ? bp->b_bcount : fdblk, fdc->dmachan); @@ -1882,7 +1881,7 @@ fdstate(fdc_p fdc) * if this is a read, then simply await interrupt * before performing PIO */ - if (read && !fdcpio(fdc,bp->b_flags, + if (read && !fdcpio(fdc,bp->b_cmd, bp->b_data+fd->skip,fdblk)) { callout_reset(&fd->tohandle, hz, fd_iotimeout, fdc); @@ -1901,17 +1900,19 @@ fdstate(fdc_p fdc) * actually perform the PIO read. The IOCOMPLETE case * removes the timeout for us. */ - (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk); + (void)fdcpio(fdc,bp->b_cmd,bp->b_data+fd->skip,fdblk); fdc->state = IOCOMPLETE; /* FALLTHROUGH */ case IOCOMPLETE: /* IO DONE, post-analyze */ callout_stop(&fd->tohandle); if (fd_read_status(fdc, fd->fdsu)) { - if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(bp->b_flags, bp->b_data + fd->skip, + if (!(fdc->flags & FDC_NODMA)) { + isa_dmadone(isa_dmabp(bp), + bp->b_data + fd->skip, format ? bp->b_bcount : fdblk, fdc->dmachan); + } if (fdc->retry < 6) fdc->retry = 6; /* force a reset */ return (retrier(fdc)); @@ -1922,9 +1923,11 @@ fdstate(fdc_p fdc) /* FALLTHROUGH */ case IOTIMEDOUT: - if (!(fdc->flags & FDC_NODMA)) - isa_dmadone(bp->b_flags, bp->b_data + fd->skip, + if (!(fdc->flags & FDC_NODMA)) { + isa_dmadone(isa_dmabp(bp), + bp->b_data + fd->skip, format ? bp->b_bcount : fdblk, fdc->dmachan); + } if (fdc->status[0] & NE7_ST0_IC) { if ((fdc->status[0] & NE7_ST0_IC) == NE7_ST0_IC_AT && fdc->status[1] & NE7_ST1_OR) { @@ -2174,7 +2177,8 @@ fdformat(dev_t dev, struct fd_formb *finfo, struct thread *td) BUF_LOCKINIT(bp); BUF_LOCK(bp, LK_EXCLUSIVE); initbufbio(bp); - bp->b_flags = B_FORMAT | B_PAGING; + bp->b_flags = B_PAGING; + bp->b_cmd = BUF_CMD_FORMAT; /* * calculate a fake blkno, so fdstrategy() would initiate a @@ -2193,7 +2197,7 @@ fdformat(dev_t dev, struct fd_formb *finfo, struct thread *td) /* ...and wait for it to complete */ crit_enter(); - while(!(bp->b_flags & B_DONE)) { + while (bp->b_cmd != BUF_CMD_DONE) { rv = tsleep((caddr_t)bp, 0, "fdform", 20 * hz); if (rv == EWOULDBLOCK) break; diff --git a/sys/dev/disk/mcd/mcd.c b/sys/dev/disk/mcd/mcd.c index f66ce48b8e..c7e57df258 100644 --- a/sys/dev/disk/mcd/mcd.c +++ b/sys/dev/disk/mcd/mcd.c @@ -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.17 2006/03/26 07:56:54 swildner Exp $ + * $DragonFly: src/sys/dev/disk/mcd/Attic/mcd.c,v 1.18 2006/04/30 17:22:16 dillon Exp $ */ static const char COPYRIGHT[] = "mcd-driver (C)1993 by H.Veit & B.Moore"; @@ -419,7 +419,7 @@ MCD_TRACE("strategy: drive not valid\n"); } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (bp->b_cmd != BUF_CMD_READ) { bp->b_error = EROFS; goto bad; } diff --git a/sys/dev/disk/md/md.c b/sys/dev/disk/md/md.c index b7d35a6ebb..1c5a5172e7 100644 --- a/sys/dev/disk/md/md.c +++ b/sys/dev/disk/md/md.c @@ -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.10 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/disk/md/md.c,v 1.11 2006/04/30 17:22:16 dillon Exp $ * */ @@ -201,12 +201,19 @@ mdstrategy_malloc(dev_t dev, struct bio *bio) devstat_start_transaction(&sc->stats); - if (bp->b_flags & B_FREEBUF) + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: dop = DEVSTAT_NO_DATA; - else if (bp->b_flags & B_READ) + break; + case BUF_CMD_READ: dop = DEVSTAT_READ; - else + break; + case BUF_CMD_WRITE: dop = DEVSTAT_WRITE; + break; + default: + panic("md: bad b_cmd %d", bp->b_cmd); + } nsec = bp->b_bcount >> DEV_BSHIFT; secno = (unsigned)(bio->bio_offset >> DEV_BSHIFT); @@ -229,13 +236,15 @@ mdstrategy_malloc(dev_t dev, struct bio *bio) if (md_debug > 2) printf("%08x %p %p %d\n", bp->b_flags, secpp, secp, secval); - if (bp->b_flags & B_FREEBUF) { + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: if (secpp) { if (secp) FREE(secp, M_MDSECT); *secpp = 0; } - } else if (bp->b_flags & B_READ) { + break; + case BUF_CMD_READ: if (secp) { bcopy(secp, dst, DEV_BSIZE); } else if (secval) { @@ -244,7 +253,8 @@ mdstrategy_malloc(dev_t dev, struct bio *bio) } else { bzero(dst, DEV_BSIZE); } - } else { + break; + case BUF_CMD_WRITE: uc = dst[0]; for (i = 1; i < DEV_BSIZE; i++) if (dst[i] != uc) @@ -276,6 +286,10 @@ mdstrategy_malloc(dev_t dev, struct bio *bio) *secpp = secp; } } + break; + default: + panic("md: bad b_cmd %d", bp->b_cmd); + } secno++; dst += DEV_BSIZE; @@ -324,16 +338,22 @@ mdstrategy_preload(dev_t dev, struct bio *bio) devstat_start_transaction(&sc->stats); - if (bp->b_flags & B_FREEBUF) { + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: dop = DEVSTAT_NO_DATA; - } else if (bp->b_flags & B_READ) { + break; + case BUF_CMD_READ: dop = DEVSTAT_READ; bcopy(sc->pl_ptr + bio->bio_offset, bp->b_data, bp->b_bcount); - } else { + break; + case BUF_CMD_WRITE: dop = DEVSTAT_WRITE; bcopy(bp->b_data, sc->pl_ptr + bio->bio_offset, bp->b_bcount); + break; + default: + panic("md: bad cmd %d\n", bp->b_cmd); } bp->b_resid = 0; devstat_end_transaction_buf(&sc->stats, bp); diff --git a/sys/dev/disk/scd/scd.c b/sys/dev/disk/scd/scd.c index b4ccb82d6c..b9c635f2f6 100644 --- a/sys/dev/disk/scd/scd.c +++ b/sys/dev/disk/scd/scd.c @@ -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.16 2006/03/26 07:56:54 swildner Exp $ */ +/* $DragonFly: src/sys/dev/disk/scd/Attic/scd.c,v 1.17 2006/04/30 17:22:16 dillon Exp $ */ /* Please send any comments to micke@dynas.se */ @@ -343,7 +343,7 @@ scdstrategy(dev_t dev, struct bio *bio) } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (bp->b_cmd != BUF_CMD_READ) { bp->b_error = EROFS; goto bad; } diff --git a/sys/dev/disk/vn/vn.c b/sys/dev/disk/vn/vn.c index 5f75df40e1..46ceaf6ae6 100644 --- a/sys/dev/disk/vn/vn.c +++ b/sys/dev/disk/vn/vn.c @@ -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.18 2006/03/27 01:54:14 dillon Exp $ + * $DragonFly: src/sys/dev/disk/vn/vn.c,v 1.19 2006/04/30 17:22:16 dillon Exp $ */ /* @@ -96,7 +96,7 @@ static d_strategy_t vnstrategy; /* * cdevsw * D_DISK we want to look like a disk - * D_CANFREE We support B_FREEBUF + * D_CANFREE We support BUF_CMD_FREEBLKS */ static struct cdevsw vn_cdevsw = { @@ -363,9 +363,9 @@ vnstrategy(dev_t dev, struct bio *bio) /* * Use the translated nbio from this point on */ - if (vn->sc_vp && (bp->b_flags & B_FREEBUF)) { + if (vn->sc_vp && bp->b_cmd == BUF_CMD_FREEBLKS) { /* - * Not handled for vnode-backed element yet. + * Freeblks is not handled for vnode-backed elements yet. */ biodone(nbio); } else if (vn->sc_vp) { @@ -387,14 +387,14 @@ vnstrategy(dev_t dev, struct bio *bio) auio.uio_iovcnt = 1; auio.uio_offset = nbio->bio_offset; auio.uio_segflg = UIO_SYSSPACE; - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) auio.uio_rw = UIO_READ; else auio.uio_rw = UIO_WRITE; auio.uio_resid = bp->b_bcount; auio.uio_td = curthread; vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curthread); - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) error = VOP_READ(vn->sc_vp, &auio, IO_DIRECT, vn->sc_cred); else error = VOP_WRITE(vn->sc_vp, &auio, IO_NOWDRAIN, vn->sc_cred); @@ -412,12 +412,12 @@ vnstrategy(dev_t dev, struct bio *bio) * * ( handles read, write, freebuf ) * - * Note: if we pre-reserved swap, B_FREEBUF is disabled + * Note: freeblks is not supported with pre-reserved swap. */ KASSERT((bp->b_bufsize & (vn->sc_secsize - 1)) == 0, ("vnstrategy: buffer %p too small for physio", bp)); - if ((bp->b_flags & B_FREEBUF) && TESTOPT(vn, VN_RESERVE)) { + if (bp->b_cmd == BUF_CMD_FREEBLKS && TESTOPT(vn, VN_RESERVE)) { biodone(nbio); } else { vm_pager_strategy(vn->sc_object, nbio); diff --git a/sys/dev/disk/wt/wt.c b/sys/dev/disk/wt/wt.c index ed433a4fbd..8906e1ffb4 100644 --- a/sys/dev/disk/wt/wt.c +++ b/sys/dev/disk/wt/wt.c @@ -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.13 2006/02/17 19:18:05 dillon Exp $ + * $DragonFly: src/sys/dev/disk/wt/wt.c,v 1.14 2006/04/30 17:22:16 dillon Exp $ * */ @@ -163,7 +163,7 @@ static wtinfo_t wttab[NWT]; /* tape info by unit number */ static int wtwait (wtinfo_t *t, int catch, char *msg); static int wtcmd (wtinfo_t *t, int cmd); -static int wtstart (wtinfo_t *t, unsigned mode, void *vaddr, unsigned len); +static int wtstart (wtinfo_t *t, unsigned flags, void *vaddr, unsigned len); static void wtdma (wtinfo_t *t); static timeout_t wtimer; static void wtclock (wtinfo_t *t); @@ -512,6 +512,7 @@ wtstrategy (dev_t dev, struct bio *bio) struct buf *bp = bio->bio_buf; int u = minor(dev) & T_UNIT; wtinfo_t *t = wttab + u; + unsigned flags; bp->b_resid = bp->b_bcount; if (u >= NWT || t->type == UNKNOWN) { @@ -528,7 +529,7 @@ wtstrategy (dev_t dev, struct bio *bio) goto err2xit; } - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { /* Check read access and no previous write to this tape. */ if (! (t->flags & TPREAD) || (t->flags & TPWANY)) goto errxit; @@ -544,6 +545,7 @@ wtstrategy (dev_t dev, struct bio *bio) } t->flags |= TPRO | TPRANY; } + flags = ISADMA_READ; } else { /* Check write access and write protection. */ /* No previous read from this tape allowed. */ @@ -560,6 +562,7 @@ wtstrategy (dev_t dev, struct bio *bio) } t->flags |= TPWO | TPWANY; } + flags = ISADMA_WRITE; } if (! bp->b_bcount) @@ -567,8 +570,8 @@ wtstrategy (dev_t dev, struct bio *bio) t->flags &= ~TPEXCEP; crit_enter(); - if (wtstart (t, bp->b_flags & B_READ ? ISADMA_READ : ISADMA_WRITE, bp->b_data, bp->b_bcount)) { - wtwait (t, 0, (bp->b_flags & B_READ) ? "wtread" : "wtwrite"); + if (wtstart (t, flags, bp->b_data, bp->b_bcount)) { + wtwait (t, 0, (flags & ISADMA_READ) ? "wtread" : "wtwrite"); bp->b_resid -= t->dmacount; } crit_exit(); diff --git a/sys/dev/misc/labpc/labpc.c b/sys/dev/misc/labpc/labpc.c index 1e93d69ddd..1eebf5e3f1 100644 --- a/sys/dev/misc/labpc/labpc.c +++ b/sys/dev/misc/labpc/labpc.c @@ -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.15 2006/02/17 19:18:05 dillon Exp $ + * $DragonFly: src/sys/dev/misc/labpc/labpc.c,v 1.16 2006/04/30 17:22:16 dillon Exp $ * */ @@ -992,7 +992,7 @@ labpcstrategy(dev_t dev, struct bio *bio) bio->bio_driver_info = dev; if (DIGITAL(dev)) { - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { ctlr->starter = null_start; ctlr->stop = all_stop; ctlr->intr = null_intr; @@ -1007,7 +1007,7 @@ labpcstrategy(dev_t dev, struct bio *bio) } } else { - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { ctlr->starter = INTERVAL(ctlr->dev) ? ad_interval_start : ad_start; ctlr->stop = all_stop; diff --git a/sys/dev/misc/ppc/ppc.c b/sys/dev/misc/ppc/ppc.c index ec49ab5bd8..29e2c8fdd3 100644 --- a/sys/dev/misc/ppc/ppc.c +++ b/sys/dev/misc/ppc/ppc.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/isa/ppc.c,v 1.26.2.5 2001/10/02 05:21:45 nsouch Exp $ - * $DragonFly: src/sys/dev/misc/ppc/ppc.c,v 1.11 2005/12/11 01:54:08 swildner Exp $ + * $DragonFly: src/sys/dev/misc/ppc/ppc.c,v 1.12 2006/04/30 17:22:16 dillon Exp $ * */ @@ -1671,7 +1671,7 @@ ppc_write(device_t dev, char *buf, int len, int how) ctr &= ~IRQENABLE; w_ctr(ppc, ctr); - ppc->ppc_dmaflags = 0; + ppc->ppc_dmaflags = ISADMA_WRITE; ppc->ppc_dmaddr = (caddr_t)buf; ppc->ppc_dmacnt = (u_int)len; @@ -1732,8 +1732,9 @@ ppc_write(device_t dev, char *buf, int len, int how) #endif /* stop DMA */ isa_dmadone( - ppc->ppc_dmaflags, ppc->ppc_dmaddr, - ppc->ppc_dmacnt, ppc->ppc_dmachan); + ppc->ppc_dmaflags, + ppc->ppc_dmaddr, ppc->ppc_dmacnt, + ppc->ppc_dmachan); /* no dma, no interrupt, flush the fifo */ w_ecr(ppc, PPC_ECR_RESET); diff --git a/sys/dev/raid/aac/aac.c b/sys/dev/raid/aac/aac.c index 41c2487549..60686826ab 100644 --- a/sys/dev/raid/aac/aac.c +++ b/sys/dev/raid/aac/aac.c @@ -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.22 2006/04/17 15:59:54 dillon Exp $ + * $DragonFly: src/sys/dev/raid/aac/aac.c,v 1.23 2006/04/30 17:22:16 dillon Exp $ */ /* @@ -943,7 +943,7 @@ aac_bio_command(struct aac_softc *sc, struct aac_command **cmp) /* build the read/write request */ ad = (struct aac_disk *)bio->bio_driver_info; - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { br = (struct aac_blockread *)&fib->data[0]; br->Command = VM_CtBlockRead; br->ContainerId = ad->ad_container->co_mntobj.ObjectId; @@ -991,7 +991,7 @@ aac_bio_complete(struct aac_command *cm) /* fetch relevant status and then release the command */ bio = (struct bio *)cm->cm_private; bp = bio->bio_buf; - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { brr = (struct aac_blockread_response *)&cm->cm_fib->data[0]; status = brr->Status; } else { diff --git a/sys/dev/raid/aac/aac_compat.h b/sys/dev/raid/aac/aac_compat.h index 41601b11b2..34701b3328 100644 --- a/sys/dev/raid/aac/aac_compat.h +++ b/sys/dev/raid/aac/aac_compat.h @@ -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.7 2006/02/17 19:18:05 dillon Exp $ + * $DragonFly: src/sys/dev/raid/aac/Attic/aac_compat.h,v 1.8 2006/04/30 17:22:16 dillon Exp $ */ /* * Backwards compatibility support. @@ -39,11 +39,4 @@ #include #include #include - -#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 diff --git a/sys/dev/raid/amr/amr.c b/sys/dev/raid/amr/amr.c index 5e2f156ec8..41f6841097 100644 --- a/sys/dev/raid/amr/amr.c +++ b/sys/dev/raid/amr/amr.c @@ -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.17 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/amr/amr.c,v 1.18 2006/04/30 17:22:16 dillon Exp $ */ /* @@ -887,7 +887,7 @@ amr_bio_command(struct amr_softc *sc, struct amr_command **acp) ac->ac_bio = 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) { + if (bio->bio_buf->b_cmd == BUF_CMD_READ) { ac->ac_flags |= AMR_CMD_DATAIN; cmd = AMR_CMD_LREAD; } else { diff --git a/sys/dev/raid/ida/ida.c b/sys/dev/raid/ida/ida.c index f5e71ac39a..98b1b5ce6e 100644 --- a/sys/dev/raid/ida/ida.c +++ b/sys/dev/raid/ida/ida.c @@ -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.10 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/ida/ida.c,v 1.11 2006/04/30 17:22:16 dillon Exp $ */ /* @@ -419,7 +419,7 @@ ida_construct_qcb(struct ida_softc *ida) hwqcb->req.blkno = bio->bio_offset >> DEV_BSHIFT; hwqcb->req.bcount = howmany(bp->b_bcount, DEV_BSIZE); - hwqcb->req.command = bp->b_flags & B_READ ? CMD_READ : CMD_WRITE; + hwqcb->req.command = (bp->b_cmd == BUF_CMD_READ) ? CMD_READ : CMD_WRITE; STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe); } diff --git a/sys/dev/raid/ida/ida_disk.c b/sys/dev/raid/ida/ida_disk.c index 9224a8f8c0..54c2c39008 100644 --- a/sys/dev/raid/ida/ida_disk.c +++ b/sys/dev/raid/ida/ida_disk.c @@ -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.10 2006/02/17 19:18:05 dillon Exp $ + * $DragonFly: src/sys/dev/raid/ida/ida_disk.c,v 1.11 2006/04/30 17:22:16 dillon Exp $ */ /* @@ -170,7 +170,7 @@ idad_strategy(dev_t dev, struct bio *bio) /* * software write protect check */ - if (drv->flags & DRV_WRITEPROT && (bp->b_flags & B_READ) == 0) { + if ((drv->flags & DRV_WRITEPROT) && bp->b_cmd != BUF_CMD_READ) { bp->b_error = EROFS; goto bad; } diff --git a/sys/dev/raid/ips/ips.h b/sys/dev/raid/ips/ips.h index 9f96b221ab..9e6d0d8ce9 100644 --- a/sys/dev/raid/ips/ips.h +++ b/sys/dev/raid/ips/ips.h @@ -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.8 2006/02/17 19:18:05 dillon Exp $ + * $DragonFly: src/sys/dev/raid/ips/ips.h,v 1.9 2006/04/30 17:22:16 dillon Exp $ */ @@ -198,22 +198,6 @@ 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 -#define bio_error b_error -#define bio_flags b_flags -#define bio_driver1 b_driver1 -#define bio_pblkno b_pblkno -#define bio_data b_data -#define bio_bcount b_bcount -#define bio_dev b_dev -#define bio_resid b_resid - -/* geom */ -#define d_drv1 si_drv1 -#endif #define d_maxsize si_iosize_max @@ -239,7 +223,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) ((bio)->bio_buf->b_flags & B_READ) +#define ips_read_request(iobuf) ((bio)->bio_buf->b_cmd == BUF_CMD_READ) #define COMMAND_ERROR(status) (((status)->fields.basic_status & 0x0f) >= IPS_MIN_ERROR) diff --git a/sys/dev/raid/mlx/mlx.c b/sys/dev/raid/mlx/mlx.c index f60b4c9042..671bde37cb 100644 --- a/sys/dev/raid/mlx/mlx.c +++ b/sys/dev/raid/mlx/mlx.c @@ -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.17 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/mlx/mlx.c,v 1.18 2006/04/30 17:22:16 dillon Exp $ */ /* @@ -1769,7 +1769,7 @@ mlx_startio(struct mlx_softc *sc) mc->mc_private = bp; mc->mc_data = bp->b_data; mc->mc_length = bp->b_bcount; - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { mc->mc_flags |= MLX_CMD_DATAIN; cmd = MLX_CMD_READSG; } else { diff --git a/sys/dev/raid/mlx/mlx_compat.h b/sys/dev/raid/mlx/mlx_compat.h index 91d71b098e..feeb2a1a64 100644 --- a/sys/dev/raid/mlx/mlx_compat.h +++ b/sys/dev/raid/mlx/mlx_compat.h @@ -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.6 2006/02/17 19:18:05 dillon Exp $ + * $DragonFly: src/sys/dev/raid/mlx/mlx_compat.h,v 1.7 2006/04/30 17:22:16 dillon Exp $ */ /* * Portability and compatibility interfaces. @@ -39,24 +39,6 @@ # include 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 -# define MLX_BIO_LBA(bp) (bp)->b_pblkno -# define MLX_BIO_SOFTC(bp) (bp)->b_dev->si_drv1 -# define MLX_BIO_UNIT(bp) *(int *)((bp)->b_dev->si_drv2) -# define MLX_BIO_SET_ERROR(bp, err) do { (bp)->b_error = err; (bp)->b_flags |= B_ERROR;} while(0) -# define MLX_BIO_HAS_ERROR(bp) ((bp)->b_flags & B_ERROR) -# define MLX_BIO_RESID(bp) (bp)->b_resid -# 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 typedef struct bio mlx_bio; diff --git a/sys/dev/raid/pst/pst-raid.c b/sys/dev/raid/pst/pst-raid.c index e1af78bf96..959746f023 100644 --- a/sys/dev/raid/pst/pst-raid.c +++ b/sys/dev/raid/pst/pst-raid.c @@ -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.14 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/pst/pst-raid.c,v 1.15 2006/04/30 17:22:16 dillon Exp $ */ #include @@ -302,7 +302,7 @@ pst_timeout(void *xrequest) crit_enter(); printf("pst: timeout mfa=0x%08x cmd=%s\n", - request->mfa, bp->b_flags & B_READ ? "READ" : "WRITE"); + request->mfa, (bp->b_cmd == BUF_CMD_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"); @@ -342,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 (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { msg->function = I2O_BSA_BLOCK_READ; msg->control_flags = 0x0; /* 0x0c = read cache + readahead */ msg->fetch_ahead = 0x0; /* 8 Kb */ diff --git a/sys/dev/raid/twe/twe.c b/sys/dev/raid/twe/twe.c index 06542e5bb9..c3123d4dc4 100644 --- a/sys/dev/raid/twe/twe.c +++ b/sys/dev/raid/twe/twe.c @@ -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.14 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/twe/twe.c,v 1.15 2006/04/30 17:22:17 dillon Exp $ */ /* @@ -411,7 +411,7 @@ twe_startio(struct twe_softc *sc) tr->tr_data = bio->bio_buf->b_data; tr->tr_length = bio->bio_buf->b_bcount; cmd = &tr->tr_command; - if (bio->bio_buf->b_flags & B_READ) { + if (bio->bio_buf->b_cmd == BUF_CMD_READ) { tr->tr_flags |= TWE_CMD_DATAIN; cmd->io.opcode = TWE_OP_READ; } else { diff --git a/sys/dev/raid/twe/twe_compat.h b/sys/dev/raid/twe/twe_compat.h index c8d266eb56..76ce391c64 100644 --- a/sys/dev/raid/twe/twe_compat.h +++ b/sys/dev/raid/twe/twe_compat.h @@ -27,7 +27,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/twe/twe_compat.h,v 1.1.2.5 2004/04/07 22:18:00 vkashyap Exp $ - * $DragonFly: src/sys/dev/raid/twe/twe_compat.h,v 1.13 2006/02/17 19:18:06 dillon Exp $ + * $DragonFly: src/sys/dev/raid/twe/twe_compat.h,v 1.14 2006/04/30 17:22:17 dillon Exp $ */ /* * Portability and compatibility interfaces. @@ -164,24 +164,6 @@ #define FREEBSD_4 typedef struct bio twe_bio; typedef struct bio_queue_head twe_bioq; -#if 0 -# define TWE_BIO_QINIT(bq) bioq_init(&bq); -# define TWE_BIO_QINSERT(bq, bp) bioq_insert_tail(&bq, bp) -# define TWE_BIO_QFIRST(bq) bioq_first(&bq) -# define TWE_BIO_QREMOVE(bq, bp) bioq_remove(&bq, bp) -# define TWE_BIO_IS_READ(bp) ((bp)->b_flags & B_READ) -# define TWE_BIO_DATA(bp) (bp)->b_data -# define TWE_BIO_LENGTH(bp) (bp)->b_bcount -# define TWE_BIO_LBA(bp) (bp)->b_pblkno -# define TWE_BIO_SOFTC(bp) (bp)->b_dev->si_drv1 -# define TWE_BIO_UNIT(bp) ((struct twed_softc *)(TWE_BIO_SOFTC(bp)))->twed_drive->td_twe_unit -# define TWE_BIO_SET_ERROR(bp, err) do { (bp)->b_error = err; (bp)->b_flags |= B_ERROR;} while(0) -# define TWE_BIO_HAS_ERROR(bp) ((bp)->b_flags & B_ERROR) -# define TWE_BIO_RESID(bp) (bp)->b_resid -# define TWE_BIO_DONE(bp) biodone(bp) -# define TWE_BIO_STATS_START(bp) devstat_start_transaction(&((struct twed_softc *)TWE_BIO_SOFTC(bp))->twed_stats) -# define TWE_BIO_STATS_END(bp) devstat_end_transaction_buf(&((struct twed_softc *)TWE_BIO_SOFTC(bp))->twed_stats, bp) -#endif #else # include typedef struct bio twe_bio; diff --git a/sys/dev/raid/vinum/vinumdaemon.c b/sys/dev/raid/vinum/vinumdaemon.c index 0f65c69f89..0015e1c7cf 100644 --- a/sys/dev/raid/vinum/vinumdaemon.c +++ b/sys/dev/raid/vinum/vinumdaemon.c @@ -36,7 +36,7 @@ * * $Id: vinumdaemon.c,v 1.8 2000/01/03 05:22:03 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumdaemon.c,v 1.16 2000/01/05 06:03:56 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumdaemon.c,v 1.9 2006/03/24 18:35:32 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumdaemon.c,v 1.10 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" @@ -106,7 +106,7 @@ vinum_daemon(void) log(LOG_WARNING, "vinum: recovering I/O request: %p\n%s dev %d.%d, offset 0x%012llx, length %d\n", rq, - rq->bio->bio_buf->b_flags & B_READ ? "Read" : "Write", + (rq->bio->bio_buf->b_cmd == BUF_CMD_READ) ? "Read" : "Write", major((dev_t)rq->bio->bio_driver_info), minor((dev_t)rq->bio->bio_driver_info), rq->bio->bio_offset, diff --git a/sys/dev/raid/vinum/vinumext.h b/sys/dev/raid/vinum/vinumext.h index bc9c883620..3d365ce80e 100644 --- a/sys/dev/raid/vinum/vinumext.h +++ b/sys/dev/raid/vinum/vinumext.h @@ -35,7 +35,7 @@ * * $Id: vinumext.h,v 1.26 2000/05/16 07:38:08 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumext.h,v 1.25.2.3 2001/05/11 02:11:06 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumext.h,v 1.6 2006/02/17 19:18:06 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumext.h,v 1.7 2006/04/30 17:22:17 dillon Exp $ */ /* vinumext.h: external definitions */ @@ -47,8 +47,8 @@ extern int debug; /* debug flags */ #endif /* Physical read and write drive */ -#define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ) -#define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) +#define read_drive(a, b, c, d) driveio (a, b, c, d, BUF_CMD_READ) +#define write_drive(a, b, c, d) driveio (a, b, c, d, BUF_CMD_WRITE) #define CHECKALLOC(ptr, msg) \ if (ptr == NULL) \ @@ -116,7 +116,7 @@ void checkdiskconfig(char *); int open_drive(struct drive *, struct proc *, int); void close_drive(struct drive *drive); void close_locked_drive(struct drive *drive); -int driveio(struct drive *, char *, size_t, off_t, int); +int driveio(struct drive *, char *, size_t, off_t, buf_cmd_t); int set_drive_parms(struct drive *drive); int init_drive(struct drive *, int); /* void throw_rude_remark (int, struct _ioctl_reply *, char *, ...); XXX */ diff --git a/sys/dev/raid/vinum/vinuminterrupt.c b/sys/dev/raid/vinum/vinuminterrupt.c index 8690051bf3..a07ea3ef4a 100644 --- a/sys/dev/raid/vinum/vinuminterrupt.c +++ b/sys/dev/raid/vinum/vinuminterrupt.c @@ -41,7 +41,7 @@ * * $Id: vinuminterrupt.c,v 1.12 2000/11/24 03:41:42 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinuminterrupt.c,v 1.25.2.3 2001/05/28 05:56:27 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinuminterrupt.c,v 1.8 2006/03/26 07:56:54 swildner Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinuminterrupt.c,v 1.9 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" @@ -96,7 +96,7 @@ complete_rqe(struct bio *bio) else if (rq->error == 0) /* no: do we have one already? */ rq->error = EIO; /* no: catchall "I/O error" */ sd->lasterror = rq->error; - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { if ((rq->error == ENXIO) || (sd->flags & VF_RETRYERRORS) == 0) { gravity = " fatal"; set_sd_state(rqe->sdno, sd_crashed, setstate_force); /* subdisk is crashed */ @@ -137,7 +137,7 @@ complete_rqe(struct bio *bio) } } /* Now update the statistics */ - if (bp->b_flags & B_READ) { /* read operation */ + if (bp->b_cmd == BUF_CMD_READ) { /* read operation */ DRIVE[rqe->driveno].reads++; DRIVE[rqe->driveno].bytes_read += bp->b_bcount; SD[rqe->sdno].reads++; @@ -273,7 +273,7 @@ sdio_done(struct bio *bio) #endif sbp->bio->bio_buf->b_resid = sbp->b.b_resid; /* copy the resid field */ /* Now update the statistics */ - if (sbp->b.b_flags & B_READ) { /* read operation */ + if (sbp->b.b_cmd == BUF_CMD_READ) { /* read operation */ DRIVE[sbp->driveno].reads++; DRIVE[sbp->driveno].bytes_read += sbp->b.b_bcount; SD[sbp->sdno].reads++; @@ -384,9 +384,9 @@ complete_raid5_write(struct rqelement *rqe) } else panic("complete_raid5_write: malloc conflict"); - if ((rqe->b.b_flags & B_READ) /* this was a read */ + if ((rqe->b.b_cmd == BUF_CMD_READ) /* this was a read */ &&((rqe->flags & XFR_BAD_SUBDISK) == 0)) { /* and we can write this block */ - rqe->b.b_flags &= ~(B_READ | B_DONE); /* we're writing now */ + rqe->b.b_cmd = BUF_CMD_WRITE; /* we're writing now */ rqe->b.b_bio1.bio_done = complete_rqe; /* by calling us here */ rqe->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqe->b.b_data = &ubio->bio_buf->b_data[rqe->useroffset << DEV_BSHIFT]; /* point to the user data */ @@ -410,7 +410,7 @@ complete_raid5_write(struct rqelement *rqe) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%llx, devoffset 0x%llx, length %d\n", - rqe->b.b_flags & B_READ ? "Read" : "Write", + (rqe->b.b_cmd == BUF_CMD_READ) ? "Read" : "Write", major(dev), minor(dev), rqe->sdno, @@ -427,7 +427,7 @@ complete_raid5_write(struct rqelement *rqe) } /* Finally, write the parity block */ rqe = &rqg->rqe[0]; - rqe->b.b_flags &= ~(B_READ | B_DONE); /* we're writing now */ + rqe->b.b_cmd = BUF_CMD_WRITE; /* we're writing now */ rqe->b.b_bio1.bio_done = complete_rqe; /* by calling us here */ rqg->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqe->b.b_bcount = rqe->buflen << DEV_BSHIFT; /* length to write */ @@ -450,7 +450,7 @@ complete_raid5_write(struct rqelement *rqe) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%llx, devoffset 0x%llx, length %d\n", - rqe->b.b_flags & B_READ ? "Read" : "Write", + (rqe->b.b_cmd == BUF_CMD_READ) ? "Read" : "Write", major(dev), minor(dev), rqe->sdno, diff --git a/sys/dev/raid/vinum/vinumio.c b/sys/dev/raid/vinum/vinumio.c index dee0944354..c179e4b328 100644 --- a/sys/dev/raid/vinum/vinumio.c +++ b/sys/dev/raid/vinum/vinumio.c @@ -35,7 +35,7 @@ * * $Id: vinumio.c,v 1.30 2000/05/10 23:23:30 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumio.c,v 1.52.2.6 2002/05/02 08:43:44 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumio.c,v 1.12 2006/04/28 16:34:00 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumio.c,v 1.13 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" @@ -304,8 +304,8 @@ remove_drive(int driveno) /* * Transfer drive data. Usually called from one of these defines; - * #define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ) - * #define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) + * #define read_drive(a, b, c, d) driveio (a, b, c, d, BUF_CMD_READ) + * #define write_drive(a, b, c, d) driveio (a, b, c, d, BUF_CMD_WRITE) * * length and offset are in bytes, but must be multiples of sector * size. The function *does not check* for this condition, and @@ -313,7 +313,7 @@ remove_drive(int driveno) * Return error number */ int -driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag) +driveio(struct drive *drive, char *buf, size_t length, off_t offset, buf_cmd_t cmd) { int error; struct buf *bp; @@ -323,7 +323,7 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag) int len = min(length, MAXBSIZE); /* maximum block device transfer is MAXBSIZE */ bp = geteblk(len); /* get a buffer header */ - bp->b_flags |= flag; + bp->b_cmd = cmd; bp->b_bio1.bio_offset = offset; /* disk offset */ bp->b_saveaddr = bp->b_data; bp->b_data = buf; @@ -799,7 +799,7 @@ write_volume_label(int volno) dlp = (struct disklabel *) bp->b_data; *dlp = *lp; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_WRITE; + bp->b_cmd = BUF_CMD_WRITE; /* * This should read: diff --git a/sys/dev/raid/vinum/vinumparser.c b/sys/dev/raid/vinum/vinumparser.c index f9628cf2da..c255a2116f 100644 --- a/sys/dev/raid/vinum/vinumparser.c +++ b/sys/dev/raid/vinum/vinumparser.c @@ -35,7 +35,7 @@ * * $Id: vinumparser.c,v 1.21 2000/12/20 03:44:13 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumparser.c,v 1.20.2.5 2001/05/28 05:56:27 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumparser.c,v 1.5 2005/01/25 22:58:42 joerg Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumparser.c,v 1.6 2006/04/30 17:22:17 dillon Exp $ */ /* @@ -65,6 +65,7 @@ #include /* All this mess for a single struct definition */ #include +#include #include #include #include diff --git a/sys/dev/raid/vinum/vinumraid5.c b/sys/dev/raid/vinum/vinumraid5.c index 02e3ab5bda..17385da392 100644 --- a/sys/dev/raid/vinum/vinumraid5.c +++ b/sys/dev/raid/vinum/vinumraid5.c @@ -40,7 +40,7 @@ * * $Id: vinumraid5.c,v 1.21 2001/01/09 04:21:27 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumraid5.c,v 1.6.2.2 2001/03/13 02:59:43 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumraid5.c,v 1.4 2006/02/17 19:18:06 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumraid5.c,v 1.5 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" #include "request.h" @@ -363,7 +363,7 @@ bre5(struct request *rq, } if (SD[plex->sdnos[m.psdno]].state < sd_reborn) /* is our parity subdisk down? */ m.badsdno = m.psdno; /* note that it's down */ - if (bp->b_flags & B_READ) { /* read operation */ + if (bp->b_cmd == BUF_CMD_READ) { /* read operation */ for (mysdno = m.firstsdno; rsectors > 0; mysdno++) { if (mysdno == m.psdno) /* ignore parity on read */ mysdno++; @@ -495,7 +495,7 @@ bre5(struct request *rq, rqe->driveno = sd->driveno; if (build_rq_buffer(rqe, plex)) /* build the buffer */ return REQUEST_ENOMEM; /* can't do it */ - rqe->b.b_flags |= B_READ; /* we must read first */ + rqe->b.b_cmd = BUF_CMD_READ; /* we must read first */ m.sdcount++; /* adjust the subdisk count */ rqno++; /* and point to the next request */ } @@ -536,7 +536,7 @@ bre5(struct request *rq, return REQUEST_ENOMEM; /* can't do it */ if ((m.flags & XFR_PARITYOP) /* parity operation, */ &&((m.flags & XFR_BAD_SUBDISK) == 0)) /* and not the bad subdisk, */ - rqe->b.b_flags |= B_READ; /* we must read first */ + rqe->b.b_cmd = BUF_CMD_READ; /* we must read first */ /* Now update pointers for the next block */ *diskaddr += m.datalen; /* skip past what we've done */ @@ -579,7 +579,7 @@ bre5(struct request *rq, rqe->driveno = sd->driveno; if (build_rq_buffer(rqe, plex)) /* build the buffer */ return REQUEST_ENOMEM; /* can't do it */ - rqe->b.b_flags |= B_READ; /* we must read first */ + rqe->b.b_cmd = BUF_CMD_READ; /* we must read first */ } } /* diff --git a/sys/dev/raid/vinum/vinumrequest.c b/sys/dev/raid/vinum/vinumrequest.c index 39a361b70d..fee74091da 100644 --- a/sys/dev/raid/vinum/vinumrequest.c +++ b/sys/dev/raid/vinum/vinumrequest.c @@ -39,7 +39,7 @@ * * $Id: vinumrequest.c,v 1.30 2001/01/09 04:20:55 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumrequest.c,v 1.44.2.5 2002/08/28 04:30:56 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.10 2006/04/28 16:34:00 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumrequest.c,v 1.11 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" @@ -237,7 +237,7 @@ vinumstart(dev_t dev, struct bio *bio, int reviveok) maxplex = 1; /* just the one plex */ } - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { /* * This is a read request. Decide * which plex to read from. @@ -346,7 +346,7 @@ launch_requests(struct request *rq, int reviveok) "Revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%llx, length %d\n", rq->sdno, rq, - rq->bio->bio_buf->b_flags & B_READ ? "Read" : "Write", + (rq->bio->bio_buf->b_cmd & BUF_CMD_READ) ? "Read" : "Write", major(((dev_t)rq->bio->bio_driver_info)), minor(((dev_t)rq->bio->bio_driver_info)), rq->bio->bio_offset, @@ -361,7 +361,7 @@ launch_requests(struct request *rq, int reviveok) log(LOG_DEBUG, "Request: %p\n%s dev %d.%d, offset 0x%llx, length %d\n", rq, - rq->bio->bio_buf->b_flags & B_READ ? "Read" : "Write", + (rq->bio->bio_buf->b_cmd == BUF_CMD_READ) ? "Read" : "Write", major(((dev_t)rq->bio->bio_driver_info)), minor(((dev_t)rq->bio->bio_driver_info)), rq->bio->bio_offset, @@ -423,7 +423,7 @@ launch_requests(struct request *rq, int reviveok) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%llx, devoffset 0x%llx, length %d\n", - rqe->b.b_flags & B_READ ? "Read" : "Write", + (rqe->b.b_cmd == BUF_CMD_READ) ? "Read" : "Write", major(dev), minor(dev), rqe->sdno, @@ -521,7 +521,7 @@ bre(struct request *rq, s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */ if (s == REQUEST_DOWN) { /* down? */ rqe->flags = XFR_BAD_SUBDISK; /* yup */ - if (rq->bio->bio_buf->b_flags & B_READ) /* read request, */ + if (rq->bio->bio_buf->b_cmd == BUF_CMD_READ) /* read request, */ return REQUEST_DEGRADED; /* give up here */ /* * If we're writing, don't give up @@ -603,7 +603,7 @@ bre(struct request *rq, s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */ if (s == REQUEST_DOWN) { /* down? */ rqe->flags = XFR_BAD_SUBDISK; /* yup */ - if (rq->bio->bio_buf->b_flags & B_READ) /* read request, */ + if (rq->bio->bio_buf->b_cmd == BUF_CMD_READ) /* read request, */ return REQUEST_DEGRADED; /* give up here */ /* * If we're writing, don't give up @@ -810,7 +810,8 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex) /* Initialize the buf struct */ /* copy these flags from user bp */ - bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_READ | B_ASYNC); + bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_ASYNC); + bp->b_cmd = ubp->b_cmd; bp->b_flags |= B_PAGING; #ifdef VINUMDEBUG if (rqe->flags & XFR_BUFLOCKED) /* paranoia */ @@ -915,7 +916,7 @@ sdio(struct bio *bio) if (drive->state != drive_up) { if (sd->state >= sd_crashed) { - if ((bp->b_flags & B_READ) == 0) /* writing, */ + if (bp->b_cmd != BUF_CMD_READ) /* writing, */ set_sd_state(sd->sdno, sd_stale, setstate_force); else set_sd_state(sd->sdno, sd_crashed, setstate_force); @@ -975,7 +976,7 @@ sdio(struct bio *bio) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%llx, devoffset 0x%llx, length %d\n", - sbp->b.b_flags & B_READ ? "Read" : "Write", + (sbp->b.b_cmd == BUF_CMD_READ) ? "Read" : "Write", major(sddev), minor(sddev), sbp->sdno, @@ -1023,7 +1024,7 @@ vinum_bounds_check(struct bio *bio, struct volume *vol) && blkno + size > LABELSECTOR /* and finishes after */ #endif && (!(vol->flags & VF_RAW)) /* and it's not raw */ - &&((bp->b_flags & B_READ) == 0) /* and it's a write */ + && (bp->b_cmd != BUF_CMD_READ) /* and it's a write */ &&(!vol->flags & (VF_WLABEL | VF_LABELLING))) { /* and we're not allowed to write the label */ bp->b_error = EROFS; /* read-only */ bp->b_flags |= B_ERROR; diff --git a/sys/dev/raid/vinum/vinumrevive.c b/sys/dev/raid/vinum/vinumrevive.c index d91947376f..88f5902eb7 100644 --- a/sys/dev/raid/vinum/vinumrevive.c +++ b/sys/dev/raid/vinum/vinumrevive.c @@ -39,7 +39,7 @@ * * $Id: vinumrevive.c,v 1.14 2000/12/21 01:55:11 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumrevive.c,v 1.22.2.5 2001/03/13 02:59:43 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumrevive.c,v 1.9 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumrevive.c,v 1.10 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" @@ -164,7 +164,8 @@ revive_block(int sdno) else /* it's an unattached plex */ dev = VINUM_PLEX(sd->plexno); /* create the device number */ - bp->b_flags = B_READ | B_PAGING; /* either way, read it */ + bp->b_flags = B_PAGING; /* either way, read it */ + bp->b_cmd = BUF_CMD_READ; vinumstart(dev, &bp->b_bio1, 1); biowait(bp); } @@ -175,7 +176,8 @@ revive_block(int sdno) /* Now write to the subdisk */ { dev = VINUM_SD(sdno); /* create the device number */ - bp->b_flags = B_ORDERED | B_WRITE | B_PAGING; /* and make this an ordered write */ + bp->b_flags = B_ORDERED | B_PAGING; /* and make this an ordered write */ + bp->b_cmd = BUF_CMD_WRITE; bp->b_resid = bp->b_bcount; bp->b_bio1.bio_offset = (off_t)sd->revived << DEV_BSHIFT; /* write it to here */ bp->b_bio1.bio_driver_info = dev; @@ -206,7 +208,7 @@ revive_block(int sdno) "Relaunch revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%llx, length %d\n", rq->sdno, rq, - rq->bio->bio_buf->b_flags & B_READ ? "Read" : "Write", + (rq->bio->bio_buf->b_cmd == BUF_CMD_READ) ? "Read" : "Write", major(dev), minor(dev), rq->bio->bio_offset, @@ -295,7 +297,7 @@ parityops(struct vinum_ioctl_msg *data) if ((pbp->b_flags & B_ERROR) == 0) { /* no error */ if ((op == rebuildparity) || (op == rebuildandcheckparity)) { - pbp->b_flags &= ~B_READ; + pbp->b_cmd = BUF_CMD_WRITE; pbp->b_resid = pbp->b_bcount; sdio(&pbp->b_bio1); /* write the parity block */ biowait(pbp); @@ -413,7 +415,8 @@ parityrebuild(struct plex *plex, bpp[sdno]->b_bio1.bio_driver_info = VINUM_SD(plex->sdnos[psd]); /* write back to the parity SD */ else bpp[sdno]->b_bio1.bio_driver_info = VINUM_SD(plex->sdnos[sdno]); /* device number */ - bpp[sdno]->b_flags = B_READ | B_PAGING; /* either way, read it */ + bpp[sdno]->b_cmd = BUF_CMD_READ; /* either way, read it */ + bpp[sdno]->b_flags = B_PAGING; bpp[sdno]->b_bcount = mysize; bpp[sdno]->b_resid = bpp[sdno]->b_bcount; bpp[sdno]->b_bio1.bio_offset = (off_t)pstripe << DEV_BSHIFT; /* transfer from here */ @@ -553,7 +556,7 @@ initsd(int sdno, int verify) bp->b_bio1.bio_offset = (off_t)sd->initialized << DEV_BSHIFT; /* write it to here */ bp->b_bio1.bio_driver_info = VINUM_SD(sdno); bzero(bp->b_data, bp->b_bcount); - bp->b_flags &= ~B_READ; + bp->b_cmd = BUF_CMD_WRITE; sdio(&bp->b_bio1); /* perform the I/O */ biowait(bp); if (bp->b_flags & B_ERROR) @@ -574,7 +577,7 @@ initsd(int sdno, int verify) bp->b_resid = bp->b_bcount; bp->b_bio1.bio_offset = (off_t)sd->initialized << DEV_BSHIFT; /* read from here */ bp->b_bio1.bio_driver_info = VINUM_SD(sdno); - bp->b_flags |= B_READ; /* read it back */ + bp->b_cmd = BUF_CMD_READ; /* read it back */ crit_exit(); sdio(&bp->b_bio1); biowait(bp); diff --git a/sys/dev/raid/vinum/vinumstate.c b/sys/dev/raid/vinum/vinumstate.c index b3542fd5e3..8dfe462c50 100644 --- a/sys/dev/raid/vinum/vinumstate.c +++ b/sys/dev/raid/vinum/vinumstate.c @@ -39,7 +39,7 @@ * * $Id: vinumstate.c,v 2.18 2000/05/10 07:30:50 grog Exp grog $ * $FreeBSD: src/sys/dev/vinum/vinumstate.c,v 1.28.2.2 2000/06/08 02:00:23 grog Exp $ - * $DragonFly: src/sys/dev/raid/vinum/vinumstate.c,v 1.5 2006/02/17 19:18:06 dillon Exp $ + * $DragonFly: src/sys/dev/raid/vinum/vinumstate.c,v 1.6 2006/04/30 17:22:17 dillon Exp $ */ #include "vinumhdr.h" @@ -618,7 +618,7 @@ enum requeststatus checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend) { struct plex *plex = &PLEX[sd->plexno]; - int writeop = (rq->bio->bio_buf->b_flags & B_READ) == 0; /* note if we're writing */ + int writeop = (rq->bio->bio_buf->b_cmd != BUF_CMD_READ); /* note if we're writing */ switch (sd->state) { /* We shouldn't get called if the subdisk is up */ diff --git a/sys/dev/sound/pcm/buffer.c b/sys/dev/sound/pcm/buffer.c index a0d25abcc2..d259f07ada 100644 --- a/sys/dev/sound/pcm/buffer.c +++ b/sys/dev/sound/pcm/buffer.c @@ -24,14 +24,14 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/buffer.c,v 1.1.2.4 2002/04/22 15:49:35 cg Exp $ - * $DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.3 2003/07/30 00:20:39 dillon Exp $ + * $DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.4 2006/04/30 17:22:17 dillon Exp $ */ #include #include "feeder_if.h" -SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.3 2003/07/30 00:20:39 dillon Exp $"); +SND_DECLARE_FILE("$DragonFly: src/sys/dev/sound/pcm/buffer.c,v 1.4 2006/04/30 17:22:17 dillon Exp $"); #define SNDBUF_NAMELEN 48 struct snd_dbuf { @@ -43,13 +43,14 @@ struct snd_dbuf { volatile int rl; /* length of ready area */ volatile int hp; volatile u_int32_t total, prev_total; - int isadmachan, dir; /* dma channel */ + int isadmachan; /* dma channel */ u_int32_t fmt, spd, bps; unsigned int blksz, blkcnt; int xrun; u_int32_t flags; bus_dmamap_t dmamap; bus_dma_tag_t dmatag; + unsigned dmaflags; struct selinfo sel; char name[SNDBUF_NAMELEN]; }; @@ -599,7 +600,7 @@ sndbuf_isadmasetdir(struct snd_dbuf *b, int dir) KASSERT(b, ("sndbuf_isadmasetdir called with b == NULL")); KASSERT(sndbuf_getflags(b) & SNDBUF_F_ISADMA, ("sndbuf_isadmasetdir called on non-ISA buffer")); - b->dir = (dir == PCMDIR_PLAY)? ISADMA_WRITE : ISADMA_READ; + b->dmaflags = (dir == PCMDIR_PLAY)? ISADMA_WRITE : ISADMA_READ; return 0; } @@ -612,13 +613,13 @@ sndbuf_isadma(struct snd_dbuf *b, int go) switch (go) { case PCMTRIG_START: /* isa_dmainit(b->chan, size); */ - isa_dmastart(b->dir | ISADMA_RAW, b->buf, b->bufsize, b->isadmachan); + isa_dmastart(b->dmaflags | ISADMA_RAW, b->buf, b->bufsize, b->isadmachan); break; case PCMTRIG_STOP: case PCMTRIG_ABORT: isa_dmastop(b->isadmachan); - isa_dmadone(b->dir | ISADMA_RAW, b->buf, b->bufsize, b->isadmachan); + isa_dmadone(b->dmaflags | ISADMA_RAW, b->buf, b->bufsize, b->isadmachan); break; } diff --git a/sys/dev/sound/pcm/sound.h b/sys/dev/sound/pcm/sound.h index 2918ea9202..7ee74b081e 100644 --- a/sys/dev/sound/pcm/sound.h +++ b/sys/dev/sound/pcm/sound.h @@ -25,7 +25,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/dev/sound/pcm/sound.h,v 1.10.2.11 2002/04/22 15:49:36 cg Exp $ - * $DragonFly: src/sys/dev/sound/pcm/sound.h,v 1.7 2005/10/12 17:35:55 dillon Exp $ + * $DragonFly: src/sys/dev/sound/pcm/sound.h,v 1.8 2006/04/30 17:22:17 dillon Exp $ */ /* @@ -97,11 +97,6 @@ struct snd_mixer; #define SND_STATUSLEN 64 /* descriptor of audio device */ -#ifndef ISADMA_WRITE -#define ISADMA_WRITE B_WRITE -#define ISADMA_READ B_READ -#define ISADMA_RAW B_RAW -#endif #define PCM_MODVER 1 diff --git a/sys/dev/video/gsc/gsc.c b/sys/dev/video/gsc/gsc.c index 9505887305..3402402cde 100644 --- a/sys/dev/video/gsc/gsc.c +++ b/sys/dev/video/gsc/gsc.c @@ -32,7 +32,7 @@ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * * $FreeBSD: src/sys/i386/isa/gsc.c,v 1.35.2.1 2000/08/08 19:49:53 peter Exp $ - * $DragonFly: src/sys/dev/video/gsc/gsc.c,v 1.10 2005/06/10 23:25:08 dillon Exp $ + * $DragonFly: src/sys/dev/video/gsc/gsc.c,v 1.11 2006/04/30 17:22:17 dillon Exp $ * */ @@ -327,7 +327,7 @@ buffer_read(struct gsc_unit *scu) outb( scu->clrp, 0 ); stb = inb( scu->stat ); - isa_dmastart(ISADMA_READ, scu->sbuf.base, scu->sbuf.size, scu->channel); + isa_dmastart(BUF_CMD_READ, 0, scu->sbuf.base, scu->sbuf.size, scu->channel); chan_bit = 0x01 << scu->channel; @@ -347,7 +347,7 @@ buffer_read(struct gsc_unit *scu) break; } crit_exit(); - isa_dmadone(ISADMA_READ, scu->sbuf.base, scu->sbuf.size, scu->channel); + isa_dmadone(BUF_CMD_READ, 0, scu->sbuf.base, scu->sbuf.size, scu->channel); outb( scu->clrp, 0 ); if(res != SUCCESS) diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index c30373db91..316ebe09b1 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.48 2005/12/01 18:30:13 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/genassym.c,v 1.49 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -165,7 +165,6 @@ ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index 2c3445d2d7..619d394554 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.89 2006/04/02 20:50:33 dillon Exp $ + * $DragonFly: src/sys/i386/i386/Attic/machdep.c,v 1.90 2006/04/30 17:22:17 dillon Exp $ */ #include "use_apm.h" @@ -2543,7 +2543,7 @@ bounds_check_with_label(dev_t dev, struct bio *bio, #if LABELSECTOR != 0 blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + bp->b_cmd != BUF_CMD_READ && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -2551,7 +2551,7 @@ bounds_check_with_label(dev_t dev, struct bio *bio, #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + bp->b_cmd != BUF_CMD_READ && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/i386/isa/asc.c b/sys/i386/isa/asc.c index 6a0f53caff..6118d8f387 100644 --- a/sys/i386/isa/asc.c +++ b/sys/i386/isa/asc.c @@ -35,7 +35,7 @@ */ /* * $FreeBSD: src/sys/i386/isa/asc.c,v 1.42.2.2 2001/03/01 03:22:39 jlemon Exp $ - * $DragonFly: src/sys/i386/isa/Attic/asc.c,v 1.11 2005/10/13 08:50:33 sephe Exp $ + * $DragonFly: src/sys/i386/isa/Attic/asc.c,v 1.12 2006/04/30 17:22:17 dillon Exp $ */ #include "use_asc.h" @@ -302,7 +302,7 @@ dma_restart(struct asc_unit *scu) unsigned char al=scu->cmd_byte; if (geomtab[scu->geometry].g_res==0) {/* color */ - isa_dmastart(ISADMA_READ, scu->sbuf.base+scu->sbuf.wptr, + isa_dmastart(BUF_CMD_READ, 0, scu->sbuf.base+scu->sbuf.wptr, scu->linesize + 90 /* XXX */ , scu->dma_num); /* * looks like we have to set and then clear this @@ -315,7 +315,7 @@ dma_restart(struct asc_unit *scu) outb( ASC_CMD, al &= 0xfb ); scu->cmd_byte = al; } else { /* normal */ - isa_dmastart(ISADMA_READ, scu->sbuf.base+scu->sbuf.wptr, + isa_dmastart(BUF_CMD_READ, 0, scu->sbuf.base+scu->sbuf.wptr, scu->linesize, scu->dma_num); /*** this is done in sub_20, after dmastart ? ***/ #if 0 @@ -514,7 +514,7 @@ ascintr(void *arg) outb( ASC_CMD, ASC_STANDBY); scu->flags &= ~DMA_ACTIVE; /* bounce buffers... */ - isa_dmadone(ISADMA_READ, scu->sbuf.base+scu->sbuf.wptr, + isa_dmadone(BUF_CMD_READ, 0, scu->sbuf.base+scu->sbuf.wptr, scu->linesize, scu->dma_num); scu->sbuf.wptr += scu->linesize; if (scu->sbuf.wptr >= scu->sbuf.size) scu->sbuf.wptr=0; diff --git a/sys/kern/kern_device.c b/sys/kern/kern_device.c index ca774a18c2..ceee328f99 100644 --- a/sys/kern/kern_device.c +++ b/sys/kern/kern_device.c @@ -25,7 +25,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/kern_device.c,v 1.16 2006/02/17 19:18:06 dillon Exp $ + * $DragonFly: src/sys/kern/kern_device.c,v 1.17 2006/04/30 17:22:17 dillon Exp $ */ #include #include @@ -211,7 +211,8 @@ dev_dstrategy(dev_t dev, struct bio *bio) lwkt_port_t port; KKASSERT(bio->bio_track == NULL); - if (bio->bio_buf->b_flags & B_READ) + KKASSERT(bio->bio_buf->b_cmd != BUF_CMD_DONE); + if (bio->bio_buf->b_cmd == BUF_CMD_READ) track = &dev->si_track_read; else track = &dev->si_track_write; diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index bfc39d7361..ce342c9def 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -17,7 +17,7 @@ * are met. * * $FreeBSD: src/sys/kern/kern_physio.c,v 1.46.2.4 2003/11/14 09:51:47 simokawa Exp $ - * $DragonFly: src/sys/kern/kern_physio.c,v 1.17 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/kern/kern_physio.c,v 1.18 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -35,6 +35,7 @@ static void physwakeup(struct bio *bio) { + bio->bio_buf->b_cmd = BUF_CMD_DONE; wakeup(bio); } @@ -70,9 +71,10 @@ physio(dev_t dev, struct uio *uio, int ioflag) for (i = 0; i < uio->uio_iovcnt; i++) { while (uio->uio_iov[i].iov_len) { if (uio->uio_rw == UIO_READ) - bp->b_flags = saflags | B_READ; + bp->b_cmd = BUF_CMD_READ; else - bp->b_flags = saflags | B_WRITE; + bp->b_cmd = BUF_CMD_WRITE; + bp->b_flags = saflags; bp->b_data = uio->uio_iov[i].iov_base; bp->b_bcount = uio->uio_iov[i].iov_len; bp->b_saveaddr = sa; @@ -107,7 +109,7 @@ physio(dev_t dev, struct uio *uio, int ioflag) } dev_dstrategy(dev, &bp->b_bio1); crit_enter(); - while ((bp->b_flags & B_DONE) == 0) + while (bp->b_cmd != BUF_CMD_DONE) tsleep(&bp->b_bio1, 0, "physstr", 0); crit_exit(); diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index 14673be759..040899b9df 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -26,7 +26,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/kern/subr_devstat.c,v 1.17.2.2 2000/08/03 00:09:32 ps Exp $ - * $DragonFly: src/sys/kern/subr_devstat.c,v 1.2 2003/06/17 04:28:41 dillon Exp $ + * $DragonFly: src/sys/kern/subr_devstat.c,v 1.3 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -234,13 +234,17 @@ devstat_end_transaction_buf(struct devstat *ds, struct buf *bp) { devstat_trans_flags flg; - if (bp->b_flags & B_FREEBUF) + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: flg = DEVSTAT_FREE; - else if (bp->b_flags & B_READ) + break; + case BUF_CMD_READ: flg = DEVSTAT_READ; - else + break; + default: flg = DEVSTAT_WRITE; - + break; + } devstat_end_transaction(ds, bp->b_bcount - bp->b_resid, (bp->b_flags & B_ORDERED) ? DEVSTAT_TAG_ORDERED : DEVSTAT_TAG_SIMPLE, flg); diff --git a/sys/kern/subr_disk.c b/sys/kern/subr_disk.c index 16ed7af57b..1ba1939478 100644 --- a/sys/kern/subr_disk.c +++ b/sys/kern/subr_disk.c @@ -77,7 +77,7 @@ * @(#)ufs_disksubr.c 8.5 (Berkeley) 1/21/94 * $FreeBSD: src/sys/kern/subr_disk.c,v 1.20.2.6 2001/10/05 07:14:57 peter Exp $ * $FreeBSD: src/sys/ufs/ufs/ufs_disksubr.c,v 1.44.2.3 2001/03/05 05:42:19 obrien Exp $ - * $DragonFly: src/sys/kern/subr_disk.c,v 1.22 2006/03/24 18:35:33 dillon Exp $ + * $DragonFly: src/sys/kern/subr_disk.c,v 1.23 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -660,7 +660,7 @@ readdisklabel(dev_t dev, struct disklabel *lp) bp->b_bio1.bio_offset = (off_t)LABELSECTOR * lp->d_secsize; bp->b_bcount = lp->d_secsize; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_READ; + bp->b_cmd = BUF_CMD_READ; dev_dstrategy(dev, &bp->b_bio1); if (biowait(bp)) msg = "I/O error"; @@ -758,7 +758,7 @@ writedisklabel(dev_t dev, struct disklabel *lp) * (also stupid.. how do you write the first one? by raw writes?) */ bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_READ; + bp->b_cmd = BUF_CMD_READ; dev_dstrategy(dkmodpart(dev, RAW_PART), &bp->b_bio1); error = biowait(bp); if (error) @@ -770,8 +770,7 @@ writedisklabel(dev_t dev, struct disklabel *lp) if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && dkcksum(dlp) == 0) { *dlp = *lp; - bp->b_flags &= ~(B_DONE | B_READ); - bp->b_flags |= B_WRITE; + bp->b_cmd = BUF_CMD_WRITE; dev_dstrategy(dkmodpart(dev, RAW_PART), &bp->b_bio1); error = biowait(bp); goto done; @@ -784,7 +783,7 @@ done: dlp = (struct disklabel *)bp->b_data; *dlp = *lp; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_WRITE; + bp->b_cmd = BUF_CMD_WRITE; BUF_STRATEGY(bp, 1); error = biowait(bp); #endif @@ -820,7 +819,7 @@ diskerr(struct bio *bio, dev_t dev, const char *what, int pri, sname = dsname(dev, unit, slice, part, partname); printf("%s%s: %s %sing ", sname, partname, what, - bp->b_flags & B_READ ? "read" : "writ"); + (bp->b_cmd == BUF_CMD_READ) ? "read" : "writ"); printf("offset %012llx for %d", bio->bio_offset, bp->b_bcount); if (donecnt) printf(" (%d bytes completed)", donecnt); diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index 1a2476912c..8c144f6f96 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -36,7 +36,7 @@ * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $ * $FreeBSD: src/sys/kern/subr_diskmbr.c,v 1.45 2000/01/28 10:22:07 bde Exp $ - * $DragonFly: src/sys/kern/subr_diskmbr.c,v 1.12 2006/03/24 18:35:33 dillon Exp $ + * $DragonFly: src/sys/kern/subr_diskmbr.c,v 1.13 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -179,7 +179,7 @@ reread_mbr: bp = geteblk((int)lp->d_secsize); bp->b_bio1.bio_offset = (off_t)mbr_offset * lp->d_secsize; bp->b_bcount = lp->d_secsize; - bp->b_flags |= B_READ; + bp->b_cmd = BUF_CMD_READ; dev_dstrategy(wdev, &bp->b_bio1); if (biowait(bp) != 0) { diskerr(&bp->b_bio1, wdev, @@ -388,7 +388,7 @@ mbr_extended(dev_t dev, struct disklabel *lp, struct diskslices *ssp, bp = geteblk((int)lp->d_secsize); bp->b_bio1.bio_offset = (off_t)ext_offset * lp->d_secsize; bp->b_bcount = lp->d_secsize; - bp->b_flags |= B_READ; + bp->b_cmd = BUF_CMD_READ; dev_dstrategy(dev, &bp->b_bio1); if (biowait(bp) != 0) { diskerr(&bp->b_bio1, dev, diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index 7bd5cf161a..bc79df6bec 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -44,7 +44,7 @@ * from: @(#)ufs_disksubr.c 7.16 (Berkeley) 5/4/91 * from: ufs_disksubr.c,v 1.8 1994/06/07 01:21:39 phk Exp $ * $FreeBSD: src/sys/kern/subr_diskslice.c,v 1.82.2.6 2001/07/24 09:49:41 dd Exp $ - * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.16 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/kern/subr_diskslice.c,v 1.17 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -204,14 +204,14 @@ doshift: #if LABELSECTOR != 0 slicerel_secno + nsec > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && sp->ds_wlabel == 0) { + bp->b_cmd != BUF_CMD_READ && sp->ds_wlabel == 0) { bp->b_error = EROFS; goto bad; } #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ - if (slicerel_secno <= DOSBBSECTOR && (bp->b_flags & B_READ) == 0 && + if (slicerel_secno <= DOSBBSECTOR && bp->b_cmd != BUF_CMD_READ && sp->ds_wlabel == 0) { bp->b_error = EROFS; goto bad; @@ -251,7 +251,7 @@ doshift: nbio->bio_caller_info1.ptr = sp; nbio->bio_caller_info2.offset = (off_t)(LABELSECTOR + labelsect - slicerel_secno) * ssp->dss_secsize; - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_cmd != BUF_CMD_READ) { /* * XXX even disklabel(8) writes directly so we need * to adjust writes. Perhaps we should drop support @@ -531,14 +531,16 @@ dsioctl(dev_t dev, u_long cmd, caddr_t data, } } +/* + * Chain the bio_done. b_cmd remains valid through such chaining. + */ static void dsiodone(struct bio *bio) { struct buf *bp = bio->bio_buf; char *msg; - bp->b_flags &= ~B_DONE; - if (!(bp->b_flags & B_READ) + if (bp->b_cmd != BUF_CMD_READ || (!(bp->b_flags & B_ERROR) && bp->b_error == 0)) { msg = fixlabel(NULL, bio->bio_caller_info1.ptr, (struct disklabel *) diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 2551ca96c5..bc8b2d5216 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -14,7 +14,7 @@ * of the author. This software is distributed AS-IS. * * $FreeBSD: src/sys/kern/vfs_aio.c,v 1.70.2.28 2003/05/29 06:15:35 alc Exp $ - * $DragonFly: src/sys/kern/vfs_aio.c,v 1.23 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_aio.c,v 1.24 2006/04/30 17:22:17 dillon Exp $ */ /* @@ -961,7 +961,8 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe) bp->b_bcount = cb->aio_nbytes; bp->b_bufsize = cb->aio_nbytes; - bp->b_flags |= (cb->aio_lio_opcode == LIO_WRITE ? B_WRITE : B_READ); + bp->b_cmd = (cb->aio_lio_opcode == LIO_WRITE) ? + BUF_CMD_WRITE : BUF_CMD_READ; bp->b_bio1.bio_done = aio_physwakeup; bp->b_saveaddr = bp->b_data; bp->b_data = (void *)(uintptr_t)cb->aio_buf; @@ -1044,13 +1045,14 @@ aio_fphysio(struct aiocblist *iocb) bp = iocb->bp; crit_enter(); - while ((bp->b_flags & B_DONE) == 0) { + while (bp->b_cmd != BUF_CMD_DONE) { if (tsleep(bp, 0, "physstr", aiod_timeout)) { - if ((bp->b_flags & B_DONE) == 0) { + if (bp->b_cmd != BUF_CMD_DONE) { crit_exit(); return EINPROGRESS; - } else + } else { break; + } } } crit_exit(); @@ -2063,6 +2065,7 @@ aio_physwakeup(struct bio *bio) process_signal, aiocbe); } } + bp->b_cmd = BUF_CMD_DONE; wakeup(bp); } #endif /* VFS_AIO */ diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index c61bb8ee29..d001419aad 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -12,7 +12,7 @@ * John S. Dyson. * * $FreeBSD: src/sys/kern/vfs_bio.c,v 1.242.2.20 2003/05/28 18:38:10 alc Exp $ - * $DragonFly: src/sys/kern/vfs_bio.c,v 1.66 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_bio.c,v 1.67 2006/04/30 17:22:17 dillon Exp $ */ /* @@ -354,6 +354,7 @@ bufinit(void) bp = &buf[i]; bzero(bp, sizeof *bp); bp->b_flags = B_INVAL; /* we're just an empty header */ + bp->b_cmd = BUF_CMD_DONE; bp->b_qindex = BQUEUE_EMPTY; initbufbio(bp); xio_init(&bp->b_xio); @@ -602,9 +603,9 @@ bread(struct vnode * vp, off_t loffset, int size, struct buf ** bpp) /* if not found in cache, do some I/O */ if ((bp->b_flags & B_CACHE) == 0) { KASSERT(!(bp->b_flags & B_ASYNC), ("bread: illegal async bp %p", bp)); - bp->b_flags |= B_READ; bp->b_flags &= ~(B_ERROR | B_INVAL); - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); vn_strategy(vp, &bp->b_bio1); return (biowait(bp)); } @@ -631,9 +632,9 @@ breadn(struct vnode *vp, off_t loffset, int size, off_t *raoffset, /* if not found in cache, do some I/O */ if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; bp->b_flags &= ~(B_ERROR | B_INVAL); - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); vn_strategy(vp, &bp->b_bio1); ++readwait; } @@ -644,9 +645,10 @@ breadn(struct vnode *vp, off_t loffset, int size, off_t *raoffset, rabp = getblk(vp, *raoffset, *rabsize, 0, 0); if ((rabp->b_flags & B_CACHE) == 0) { - rabp->b_flags |= B_READ | B_ASYNC; + rabp->b_flags |= B_ASYNC; rabp->b_flags &= ~(B_ERROR | B_INVAL); - vfs_busy_pages(vp, rabp, 0); + rabp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, rabp); BUF_KERNPROC(rabp); vn_strategy(vp, &rabp->b_bio1); } else { @@ -692,10 +694,10 @@ bwrite(struct buf * bp) /* Mark the buffer clean */ bundirty(bp); - bp->b_flags &= ~(B_READ | B_DONE | B_ERROR); + bp->b_flags &= ~B_ERROR; bp->b_flags |= B_CACHE; - - vfs_busy_pages(bp->b_vp, bp, 1); + bp->b_cmd = BUF_CMD_WRITE; + vfs_busy_pages(bp->b_vp, bp); /* * Normal bwrites pipeline writes @@ -802,18 +804,14 @@ bdwrite(struct buf *bp) /* * bdirty: * - * Turn buffer into delayed write request. We must clear B_READ and - * B_RELBUF, and we must set B_DELWRI. We reassign the buffer to - * itself to properly update it in the dirty/clean lists. We mark it - * B_DONE to ensure that any asynchronization of the buffer properly - * clears B_DONE ( else a panic will occur later ). + * Turn buffer into delayed write request by marking it B_DELWRI. + * B_RELBUF and B_NOCACHE must be cleared. * - * bdirty() is kinda like bdwrite() - we have to clear B_INVAL which - * might have been set pre-getblk(). Unlike bwrite/bdwrite, bdirty() - * should only be called if the buffer is known-good. + * We reassign the buffer to itself to properly update it in the + * dirty/clean lists. * - * Since the buffer is not on a queue, we do not update the numfreebuffers - * count. + * Since the buffer is not on a queue, we do not update the + * numfreebuffers count. * * Must be called from a critical section. * The buffer must be on BQUEUE_NONE. @@ -829,10 +827,10 @@ bdirty(struct buf *bp) if (bp->b_flags & B_INVAL) { printf("bdirty: warning, dirtying invalid buffer %p\n", bp); } - bp->b_flags &= ~(B_READ|B_RELBUF); + bp->b_flags &= ~B_RELBUF; if ((bp->b_flags & B_DELWRI) == 0) { - bp->b_flags |= B_DONE | B_DELWRI; + bp->b_flags |= B_DELWRI; reassignbuf(bp); ++numdirtybuffers; bd_wakeup((lodirtybuffers + hidirtybuffers) / 2); @@ -961,7 +959,8 @@ brelse(struct buf * bp) if (bp->b_flags & B_LOCKED) bp->b_flags &= ~B_ERROR; - if ((bp->b_flags & (B_READ | B_ERROR | B_INVAL)) == B_ERROR) { + if (bp->b_cmd == BUF_CMD_WRITE && + (bp->b_flags & (B_ERROR | B_INVAL)) == B_ERROR) { /* * Failed write, redirty. Must clear B_ERROR to prevent * pages from being scrapped. If B_INVAL is set then @@ -971,8 +970,8 @@ brelse(struct buf * bp) */ bp->b_flags &= ~B_ERROR; bdirty(bp); - } else if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_FREEBUF)) || - (bp->b_bufsize <= 0)) { + } else if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR)) || + (bp->b_bufsize <= 0) || bp->b_cmd == BUF_CMD_FREEBLKS) { /* * Either a failed I/O or we were asked to free or not * cache the buffer. @@ -984,7 +983,7 @@ brelse(struct buf * bp) --numdirtybuffers; numdirtywakeup(lodirtybuffers); } - bp->b_flags &= ~(B_DELWRI | B_CACHE | B_FREEBUF); + bp->b_flags &= ~(B_DELWRI | B_CACHE); } /* @@ -1008,6 +1007,7 @@ brelse(struct buf * bp) * At this point destroying the buffer is governed by the B_INVAL * or B_RELBUF flags. */ + bp->b_cmd = BUF_CMD_DONE; /* * VMIO buffer rundown. It is not very necessary to keep a VMIO buffer @@ -1686,6 +1686,7 @@ restart: allocbuf(bp, 0); bp->b_flags = 0; + bp->b_cmd = BUF_CMD_DONE; bp->b_xflags = 0; bp->b_vp = NULL; bp->b_error = 0; @@ -2096,10 +2097,8 @@ findblk(struct vnode *vp, off_t loffset) * getblk: * * Get a block given a specified block and offset into a file/device. - * The buffers B_DONE bit will be cleared on return, making it almost - * ready for an I/O initiation. B_INVAL may or may not be set on - * return. The caller should clear B_INVAL prior to initiating a - * READ. + * B_INVAL may or may not be set on return. The caller should clear + * B_INVAL prior to initiating a READ. * * IT IS IMPORTANT TO UNDERSTAND THAT IF YOU CALL GETBLK() AND B_CACHE * IS NOT SET, YOU MUST INITIALIZE THE RETURNED BUFFER, ISSUE A READ, @@ -2200,6 +2199,7 @@ loop: * All vnode-based buffers must be backed by a VM object. */ KKASSERT(bp->b_flags & B_VMIO); + KKASSERT(bp->b_cmd == BUF_CMD_DONE); /* * Make sure that B_INVAL buffers do not have a cached @@ -2273,9 +2273,7 @@ loop: VOP_BWRITE(bp->b_vp, bp); goto loop; } - crit_exit(); - bp->b_flags &= ~B_DONE; } else { /* * Buffer is not in-core, create new buffer. The buffer @@ -2350,11 +2348,11 @@ loop: */ KKASSERT(vp->v_object != NULL); bp->b_flags |= B_VMIO; + KKASSERT(bp->b_cmd == BUF_CMD_DONE); allocbuf(bp, size); crit_exit(); - bp->b_flags &= ~B_DONE; } return (bp); } @@ -2693,15 +2691,18 @@ allocbuf(struct buf *bp, int size) * biowait: * * Wait for buffer I/O completion, returning error status. The buffer - * is left locked and B_DONE on return. B_EINTR is converted into an - * EINTR error and cleared. + * is left locked on return. B_EINTR is converted into an EINTR error + * and cleared. + * + * NOTE! The original b_cmd is lost on return, since b_cmd will be + * set to BUF_CMD_DONE. */ int biowait(struct buf * bp) { crit_enter(); - while ((bp->b_flags & B_DONE) == 0) { - if (bp->b_flags & B_READ) + while (bp->b_cmd != BUF_CMD_DONE) { + if (bp->b_cmd == BUF_CMD_READ) tsleep(bp, 0, "biord", 0); else tsleep(bp, 0, "biowr", 0); @@ -2741,7 +2742,8 @@ vn_strategy(struct vnode *vp, struct bio *bio) { struct bio_track *track; - if (bio->bio_buf->b_flags & B_READ) + KKASSERT(bio->bio_buf->b_cmd != BUF_CMD_DONE); + if (bio->bio_buf->b_cmd == BUF_CMD_READ) track = &vp->v_track_read; else track = &vp->v_track_write; @@ -2774,19 +2776,19 @@ void biodone(struct bio *bio) { struct buf *bp = bio->bio_buf; + buf_cmd_t cmd; crit_enter(); KASSERT(BUF_REFCNTNB(bp) > 0, ("biodone: bp %p not busy %d", bp, BUF_REFCNTNB(bp))); - KASSERT(!(bp->b_flags & B_DONE), - ("biodone: bp %p already done", bp)); + KASSERT(bp->b_cmd != BUF_CMD_DONE, + ("biodone: bp %p already done!", bp)); - bp->b_flags |= B_DONE; runningbufwakeup(bp); /* - * Run up the chain of BIO's. + * Run up the chain of BIO's. Leave b_cmd intact for the duration. */ while (bio) { biodone_t *done_func; @@ -2812,6 +2814,8 @@ biodone(struct bio *bio) * A bio_done function terminates the loop. The function * will be responsible for any further chaining and/or * buffer management. + * + * WARNING! The done function can deallocate the buffer! */ if ((done_func = bio->bio_done) != NULL) { bio->bio_done = NULL; @@ -2822,10 +2826,13 @@ biodone(struct bio *bio) bio = bio->bio_prev; } + cmd = bp->b_cmd; + bp->b_cmd = BUF_CMD_DONE; + /* - * Special case (XXX) - not a read or write. + * Only reads and writes are processed past this point. */ - if (bp->b_flags & B_FREEBUF) { + if (cmd != BUF_CMD_READ && cmd != BUF_CMD_WRITE) { brelse(bp); crit_exit(); return; @@ -2871,7 +2878,7 @@ biodone(struct bio *bio) * routines. */ iosize = bp->b_bcount - bp->b_resid; - if ((bp->b_flags & (B_READ|B_FREEBUF|B_INVAL|B_NOCACHE|B_ERROR)) == B_READ) { + if (cmd == BUF_CMD_READ && (bp->b_flags & (B_INVAL|B_NOCACHE|B_ERROR)) == 0) { bp->b_flags |= B_CACHE; } @@ -2912,7 +2919,7 @@ biodone(struct bio *bio) * already changed correctly ( see bdwrite() ), so we * only need to do this here in the read case. */ - if ((bp->b_flags & B_READ) && !bogusflag && resid > 0) { + if (cmd == BUF_CMD_READ && !bogusflag && resid > 0) { vfs_page_set_valid(bp, foff, i, m); } vm_page_flag_clear(m, PG_ZERO); @@ -3064,16 +3071,18 @@ vfs_page_set_valid(struct buf *bp, vm_ooffset_t off, int pageno, vm_page_t m) * and should be ignored. */ void -vfs_busy_pages(struct vnode *vp, struct buf *bp, int clear_modify) +vfs_busy_pages(struct vnode *vp, struct buf *bp) { int i, bogus; struct proc *p = curthread->td_proc; /* - * clear_modify is 0 when setting up for a read. B_CACHE - * had better not be set. + * The buffer's I/O command must already be set. If reading, + * B_CACHE must be 0 (double check against callers only doing + * I/O when B_CACHE is 0). */ - KKASSERT(clear_modify || (bp->b_flags & B_CACHE) == 0); + KKASSERT(bp->b_cmd != BUF_CMD_DONE); + KKASSERT(bp->b_cmd == BUF_CMD_WRITE || (bp->b_flags & B_CACHE) == 0); if (bp->b_flags & B_VMIO) { vm_object_t obj; @@ -3103,23 +3112,22 @@ retry: } /* - * When readying a buffer for a read ( i.e - * clear_modify == 0 ), it is important to do - * bogus_page replacement for valid pages in - * partially instantiated buffers. Partially - * instantiated buffers can, in turn, occur when - * reconstituting a buffer from its VM backing store - * base. We only have to do this if B_CACHE is - * clear ( which causes the I/O to occur in the - * first place ). The replacement prevents the read - * I/O from overwriting potentially dirty VM-backed - * pages. XXX bogus page replacement is, uh, bogus. - * It may not work properly with small-block devices. - * We need to find a better way. + * When readying a vnode-backed buffer for a write + * we must zero-fill any invalid portions of the + * backing VM pages. + * + * When readying a vnode-backed buffer for a read + * we must replace any dirty pages with a bogus + * page so we do not destroy dirty data when + * filling in gaps. Dirty pages might not + * necessarily be marked dirty yet, so use m->valid + * as a reasonable test. + * + * Bogus page replacement is, uh, bogus. We need + * to find a better way. */ - vm_page_protect(m, VM_PROT_NONE); - if (clear_modify) { + if (bp->b_cmd == BUF_CMD_WRITE) { vfs_page_set_valid(bp, foff, i, m); } else if (m->valid == VM_PAGE_BITS_ALL) { bp->b_xio.xio_pages[i] = bogus_page; @@ -3137,7 +3145,7 @@ retry: * for now. */ if (p != NULL) { - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) p->p_stats->p_ru.ru_inblock++; else p->p_stats->p_ru.ru_oublock++; @@ -3382,6 +3390,11 @@ vmapbuf(struct buf *bp) int i; struct vm_page *m; + /* + * bp had better have a command + */ + KKASSERT(bp->b_cmd != BUF_CMD_DONE); + if (bp->b_bufsize < 0) return (-1); for (v = bp->b_saveaddr, @@ -3395,7 +3408,7 @@ vmapbuf(struct buf *bp) */ retry: i = vm_fault_quick((addr >= bp->b_data) ? addr : bp->b_data, - (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); + (bp->b_cmd == BUF_CMD_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); if (i < 0) { for (i = 0; i < pidx; ++i) { vm_page_unhold(bp->b_xio.xio_pages[i]); @@ -3523,6 +3536,7 @@ DB_SHOW_COMMAND(buffer, db_show_buffer) } db_printf("b_flags = 0x%b\n", (u_int)bp->b_flags, PRINT_BUF_FLAGS); + db_printf("b_cmd = %d\n", bp->b_cmd); db_printf("b_error = %d, b_bufsize = %d, b_bcount = %d, " "b_resid = %d\n, b_data = %p, " "bio_offset(disk) = %lld, bio_offset(phys) = %lld\n", diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 56ac738047..1a32a8080b 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -34,7 +34,7 @@ * * @(#)vfs_cluster.c 8.7 (Berkeley) 2/13/94 * $FreeBSD: src/sys/kern/vfs_cluster.c,v 1.92.2.9 2001/11/18 07:10:59 dillon Exp $ - * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.21 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_cluster.c,v 1.22 2006/04/30 17:22:17 dillon Exp $ */ #include "opt_debug_cluster.h" @@ -69,7 +69,8 @@ static struct cluster_save * int lblocksize); static struct buf * cluster_rbuild (struct vnode *vp, off_t filesize, off_t loffset, - off_t doffset, int size, int run, struct buf *fbp); + off_t doffset, int size, int run, + struct buf *fbp, int doasync); static void cluster_callback (struct bio *); @@ -185,7 +186,7 @@ cluster_read(struct vnode *vp, off_t filesize, off_t loffset, nblks = burstbytes / size; bp = cluster_rbuild(vp, filesize, loffset, - doffset, size, nblks, bp); + doffset, size, nblks, bp, 0); loffset += bp->b_bufsize; } else { single_block_read: @@ -193,7 +194,7 @@ single_block_read: * if it isn't in the cache, then get a chunk from * disk if sequential, otherwise just get the block. */ - bp->b_flags |= B_READ | B_RAM; + bp->b_flags |= B_RAM; loffset += size; } } @@ -215,7 +216,6 @@ single_block_read: error = VOP_BMAP(vp, loffset, NULL, &doffset, &burstbytes, NULL); if (error || doffset == NOOFFSET) { - rbp->b_flags &= ~(B_ASYNC | B_READ); brelse(rbp); rbp = NULL; goto no_read_ahead; @@ -227,11 +227,11 @@ single_block_read: if (seqcount < ntoread) ntoread = seqcount; - rbp->b_flags |= B_READ | B_ASYNC | B_RAM; + rbp->b_flags |= B_RAM; if (burstbytes) { rbp = cluster_rbuild(vp, filesize, loffset, doffset, size, - ntoread, rbp); + ntoread, rbp, 1); } else { rbp->b_bio2.bio_offset = doffset; } @@ -241,7 +241,9 @@ no_read_ahead: /* * Handle the synchronous read. This only occurs if B_CACHE was - * not set. + * not set. bp (and rbp) could be either a cluster bp or a normal + * bp depending on the what cluster_rbuild() decided to do. If + * it is a cluster bp, vfs_busy_pages() has already been called. */ if (bp) { #if defined(CLUSTERDEBUG) @@ -249,9 +251,9 @@ no_read_ahead: printf("S(%lld,%d,%d) ", bp->b_loffset, bp->b_bcount, seqcount); #endif - if ((bp->b_flags & B_CLUSTER) == 0) { - vfs_busy_pages(vp, bp, 0); - } + bp->b_cmd = BUF_CMD_READ; + if ((bp->b_flags & B_CLUSTER) == 0) + vfs_busy_pages(vp, bp); bp->b_flags &= ~(B_ERROR|B_INVAL); if ((bp->b_flags & B_ASYNC) || bp->b_bio1.bio_done != NULL) BUF_KERNPROC(bp); @@ -260,14 +262,12 @@ no_read_ahead: } /* - * And if we have read-aheads, do them too + * And if we have read-aheads, do them too. */ if (rbp) { if (error) { - rbp->b_flags &= ~(B_ASYNC | B_READ); brelse(rbp); } else if (rbp->b_flags & B_CACHE) { - rbp->b_flags &= ~(B_ASYNC | B_READ); bqrelse(rbp); } else { #if defined(CLUSTERDEBUG) @@ -284,11 +284,12 @@ no_read_ahead: seqcount); } #endif - - if ((rbp->b_flags & B_CLUSTER) == 0) { - vfs_busy_pages(vp, rbp, 0); - } rbp->b_flags &= ~(B_ERROR|B_INVAL); + rbp->b_flags |= B_ASYNC; + rbp->b_cmd = BUF_CMD_READ; + + if ((rbp->b_flags & B_CLUSTER) == 0) + vfs_busy_pages(vp, rbp); if ((rbp->b_flags & B_ASYNC) || rbp->b_bio1.bio_done != NULL) BUF_KERNPROC(rbp); vn_strategy(vp, &rbp->b_bio1); @@ -307,7 +308,7 @@ no_read_ahead: */ static struct buf * cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, - off_t doffset, int size, int run, struct buf *fbp) + off_t doffset, int size, int run, struct buf *fbp, int doasync) { struct buf *bp, *tbp; off_t boffset; @@ -325,11 +326,11 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, } tbp = fbp; - tbp->b_flags |= B_READ; tbp->b_bio2.bio_offset = doffset; - if( (tbp->b_flags & B_MALLOC) || - ((tbp->b_flags & B_VMIO) == 0) || (run <= 1) ) + if((tbp->b_flags & B_MALLOC) || + ((tbp->b_flags & B_VMIO) == 0) || (run <= 1)) { return tbp; + } bp = trypbuf(&cluster_pbuf_freecnt); if (bp == NULL) @@ -343,7 +344,8 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, */ bp->b_data = (char *)((vm_offset_t)bp->b_data | ((vm_offset_t)tbp->b_data & PAGE_MASK)); - bp->b_flags |= B_ASYNC | B_READ | B_CLUSTER | B_VMIO; + bp->b_flags |= B_ASYNC | B_CLUSTER | B_VMIO; + bp->b_cmd = BUF_CMD_READ; bp->b_bio1.bio_done = cluster_callback; bp->b_bio1.bio_caller_info1.cluster_head = NULL; bp->b_bio1.bio_caller_info2.cluster_tail = NULL; @@ -357,7 +359,7 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, bp->b_xio.xio_npages = 0; for (boffset = doffset, i = 0; i < run; ++i, boffset += size) { - if (i != 0) { + if (i) { if ((bp->b_xio.xio_npages * PAGE_SIZE) + round_page(size) > vp->v_mount->mnt_iosize_max) { break; @@ -421,13 +423,10 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, tbp->b_flags |= B_RAM; /* - * Set the buffer up for an async read (XXX should - * we do this only if we do not wind up brelse()ing?). * Set the block number if it isn't set, otherwise * if it is make sure it matches the block number we * expect. */ - tbp->b_flags |= B_READ | B_ASYNC; if (tbp->b_bio2.bio_offset == NOOFFSET) { tbp->b_bio2.bio_offset = boffset; } else if (tbp->b_bio2.bio_offset != boffset) { @@ -436,9 +435,14 @@ cluster_rbuild(struct vnode *vp, off_t filesize, off_t loffset, } } /* - * XXX fbp from caller may not be B_ASYNC, but we are going - * to biodone() it in cluster_callback() anyway + * The first buffer is setup async if doasync is specified. + * All other buffers in the cluster are setup async. This + * way the caller can decide how to deal with the requested + * buffer. */ + if (i || doasync) + tbp->b_flags |= B_ASYNC; + tbp->b_cmd = BUF_CMD_READ; BUF_KERNPROC(tbp); cluster_append(&bp->b_bio1, tbp); for (j = 0; j < tbp->b_xio.xio_npages; ++j) { @@ -759,7 +763,7 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) continue; } bremfree(tbp); - tbp->b_flags &= ~B_DONE; + KKASSERT(tbp->b_cmd == BUF_CMD_DONE); crit_exit(); /* @@ -800,8 +804,8 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) */ bp->b_data = (char *)((vm_offset_t)bp->b_data | ((vm_offset_t)tbp->b_data & PAGE_MASK)); - bp->b_flags &= ~(B_READ | B_DONE | B_ERROR); - bp->b_flags |= B_CLUSTER | B_ASYNC | + bp->b_flags &= ~B_ERROR; + bp->b_flags |= B_CLUSTER | (tbp->b_flags & (B_VMIO | B_NEEDCOMMIT | B_NOWDRAIN)); bp->b_bio1.bio_done = cluster_callback; bp->b_bio1.bio_caller_info1.cluster_head = NULL; @@ -860,7 +864,7 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) * and mark it busy. We will use it. */ bremfree(tbp); - tbp->b_flags &= ~B_DONE; + KKASSERT(tbp->b_cmd == BUF_CMD_DONE); crit_exit(); } /* end of code for non-first buffers only */ @@ -901,8 +905,9 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) crit_enter(); bundirty(tbp); - tbp->b_flags &= ~(B_READ | B_DONE | B_ERROR); + tbp->b_flags &= ~B_ERROR; tbp->b_flags |= B_ASYNC; + tbp->b_cmd = BUF_CMD_WRITE; crit_exit(); BUF_KERNPROC(tbp); cluster_append(&bp->b_bio1, tbp); @@ -925,8 +930,9 @@ cluster_wbuild(struct vnode *vp, int size, off_t start_loffset, int bytes) totalwritten += bp->b_bufsize; bp->b_dirtyoff = 0; bp->b_dirtyend = bp->b_bufsize; - - vfs_busy_pages(vp, bp, 1); + bp->b_flags |= B_ASYNC; + bp->b_cmd = BUF_CMD_WRITE; + vfs_busy_pages(vp, bp); bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; BUF_KERNPROC(bp); /* B_ASYNC */ diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index d41e47624d..e1f31a37b8 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -37,7 +37,7 @@ * * * $FreeBSD: src/sys/kern/vfs_default.c,v 1.28.2.7 2003/01/10 18:23:26 bde Exp $ - * $DragonFly: src/sys/kern/vfs_default.c,v 1.34 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_default.c,v 1.35 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -1134,10 +1134,10 @@ vop_nolookup(ap) * Strategy routine for VFS devices that have none. * * B_ERROR and B_INVAL must be cleared prior to calling any strategy - * routine. Typically this is done for a B_READ strategy call. Typically - * B_INVAL is assumed to already be clear prior to a write and should not - * be cleared manually unless you just made the buffer invalid. B_ERROR - * should be cleared either way. + * routine. Typically this is done for a BUF_CMD_READ strategy call. + * Typically B_INVAL is assumed to already be clear prior to a write + * and should not be cleared manually unless you just made the buffer + * invalid. B_ERROR should be cleared either way. */ static int diff --git a/sys/kern/vfs_vopops.c b/sys/kern/vfs_vopops.c index 70cef2130b..cc76d59c94 100644 --- a/sys/kern/vfs_vopops.c +++ b/sys/kern/vfs_vopops.c @@ -32,7 +32,7 @@ * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $DragonFly: src/sys/kern/vfs_vopops.c,v 1.21 2006/04/25 22:11:28 dillon Exp $ + * $DragonFly: src/sys/kern/vfs_vopops.c,v 1.22 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -871,7 +871,7 @@ vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio) ap.a_bio = bio; DO_OPS(ops, error, &ap, vop_strategy); - if (error == 0 && (bio->bio_buf->b_flags & B_READ) == 0) + if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ) cache_update_fsmid_vp(vp); return(error); } diff --git a/sys/platform/pc32/i386/genassym.c b/sys/platform/pc32/i386/genassym.c index 17a9fd0471..61ac66f6c3 100644 --- a/sys/platform/pc32/i386/genassym.c +++ b/sys/platform/pc32/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.48 2005/12/01 18:30:13 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/genassym.c,v 1.49 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -165,7 +165,6 @@ ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/platform/pc32/i386/machdep.c b/sys/platform/pc32/i386/machdep.c index 8160fe6603..6143181f91 100644 --- a/sys/platform/pc32/i386/machdep.c +++ b/sys/platform/pc32/i386/machdep.c @@ -36,7 +36,7 @@ * * from: @(#)machdep.c 7.4 (Berkeley) 6/3/91 * $FreeBSD: src/sys/i386/i386/machdep.c,v 1.385.2.30 2003/05/31 08:48:05 alc Exp $ - * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.89 2006/04/02 20:50:33 dillon Exp $ + * $DragonFly: src/sys/platform/pc32/i386/machdep.c,v 1.90 2006/04/30 17:22:17 dillon Exp $ */ #include "use_apm.h" @@ -2543,7 +2543,7 @@ bounds_check_with_label(dev_t dev, struct bio *bio, #if LABELSECTOR != 0 blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + bp->b_cmd != BUF_CMD_READ && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -2551,7 +2551,7 @@ bounds_check_with_label(dev_t dev, struct bio *bio, #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + bp->b_cmd != BUF_CMD_READ && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/platform/pc32/isa/asc.c b/sys/platform/pc32/isa/asc.c index ed5ca98d22..71c1cf8d35 100644 --- a/sys/platform/pc32/isa/asc.c +++ b/sys/platform/pc32/isa/asc.c @@ -35,7 +35,7 @@ */ /* * $FreeBSD: src/sys/i386/isa/asc.c,v 1.42.2.2 2001/03/01 03:22:39 jlemon Exp $ - * $DragonFly: src/sys/platform/pc32/isa/asc.c,v 1.11 2005/10/13 08:50:33 sephe Exp $ + * $DragonFly: src/sys/platform/pc32/isa/asc.c,v 1.12 2006/04/30 17:22:17 dillon Exp $ */ #include "use_asc.h" @@ -302,7 +302,7 @@ dma_restart(struct asc_unit *scu) unsigned char al=scu->cmd_byte; if (geomtab[scu->geometry].g_res==0) {/* color */ - isa_dmastart(ISADMA_READ, scu->sbuf.base+scu->sbuf.wptr, + isa_dmastart(BUF_CMD_READ, 0, scu->sbuf.base+scu->sbuf.wptr, scu->linesize + 90 /* XXX */ , scu->dma_num); /* * looks like we have to set and then clear this @@ -315,7 +315,7 @@ dma_restart(struct asc_unit *scu) outb( ASC_CMD, al &= 0xfb ); scu->cmd_byte = al; } else { /* normal */ - isa_dmastart(ISADMA_READ, scu->sbuf.base+scu->sbuf.wptr, + isa_dmastart(BUF_CMD_READ, 0, scu->sbuf.base+scu->sbuf.wptr, scu->linesize, scu->dma_num); /*** this is done in sub_20, after dmastart ? ***/ #if 0 @@ -514,7 +514,7 @@ ascintr(void *arg) outb( ASC_CMD, ASC_STANDBY); scu->flags &= ~DMA_ACTIVE; /* bounce buffers... */ - isa_dmadone(ISADMA_READ, scu->sbuf.base+scu->sbuf.wptr, + isa_dmadone(BUF_CMD_READ, 0, scu->sbuf.base+scu->sbuf.wptr, scu->linesize, scu->dma_num); scu->sbuf.wptr += scu->linesize; if (scu->sbuf.wptr >= scu->sbuf.size) scu->sbuf.wptr=0; diff --git a/sys/platform/vkernel/i386/genassym.c b/sys/platform/vkernel/i386/genassym.c index 8cb8beba9c..3fe3569a17 100644 --- a/sys/platform/vkernel/i386/genassym.c +++ b/sys/platform/vkernel/i386/genassym.c @@ -35,7 +35,7 @@ * * from: @(#)genassym.c 5.11 (Berkeley) 5/10/91 * $FreeBSD: src/sys/i386/i386/genassym.c,v 1.86.2.3 2002/03/03 05:42:49 nyan Exp $ - * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.48 2005/12/01 18:30:13 dillon Exp $ + * $DragonFly: src/sys/platform/vkernel/i386/genassym.c,v 1.49 2006/04/30 17:22:17 dillon Exp $ */ #include @@ -165,7 +165,6 @@ ASSYM(SIGF_HANDLER, offsetof(struct sigframe, sf_ahu.sf_handler)); ASSYM(SIGF_UC, offsetof(struct sigframe, sf_uc)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 0c7e7e827a..ef3fabf2c6 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -37,7 +37,7 @@ * * @(#)buf.h 8.9 (Berkeley) 3/30/95 * $FreeBSD: src/sys/sys/buf.h,v 1.88.2.10 2003/01/25 19:02:23 dillon Exp $ - * $DragonFly: src/sys/sys/buf.h,v 1.30 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/sys/buf.h,v 1.31 2006/04/30 17:22:17 dillon Exp $ */ #ifndef _SYS_BUF_H_ @@ -99,6 +99,14 @@ extern struct bio_ops { int (*io_countdeps) (struct buf *, int); } bioops; +typedef enum buf_cmd { + BUF_CMD_DONE = 0, + BUF_CMD_READ, + BUF_CMD_WRITE, + BUF_CMD_FREEBLKS, + BUF_CMD_FORMAT +} buf_cmd_t; + /* * The buffer header describes an I/O operation in the kernel. * @@ -151,6 +159,7 @@ struct buf { unsigned char b_xflags; /* extra flags */ unsigned char b_unused01; struct lock b_lock; /* Buffer lock */ + buf_cmd_t b_cmd; /* I/O command */ int b_bufsize; /* Allocated buffer size. */ int b_runningbufspace; /* when I/O is running, pipelining */ int b_bcount; /* Valid bytes in buffer. */ @@ -194,7 +203,7 @@ struct buf { * B_DELWRI can also be cleared. See the comments for * getblk() in kern/vfs_bio.c. If B_CACHE is clear, * the caller is expected to clear B_ERROR|B_INVAL, - * set B_READ, and initiate an I/O. + * set BUF_CMD_READ, and initiate an I/O. * * The 'entire buffer' is defined to be the range from * 0 through b_bcount. @@ -233,8 +242,8 @@ struct buf { #define B_CACHE 0x00000020 /* Bread found us in the cache. */ #define B_HASHED 0x00000040 /* Indexed via v_rbhash_tree */ #define B_DELWRI 0x00000080 /* Delay I/O until buffer reused. */ -#define B_FREEBUF 0x00000100 /* Instruct driver: free blocks */ -#define B_DONE 0x00000200 /* I/O completed. */ +#define B_UNUSED0100 0x00000100 +#define B_UNUSED0200 0x00000200 #define B_EINTR 0x00000400 /* I/O was interrupted */ #define B_ERROR 0x00000800 /* I/O error occurred. */ #define B_UNUSED1000 0x00001000 /* Unused */ @@ -245,13 +254,12 @@ struct buf { #define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */ #define B_UNUSED40000 0x00040000 #define B_RAW 0x00080000 /* Set by physio for raw transfers. */ -#define B_READ 0x00100000 /* Read buffer. */ +#define B_UNUSED100000 0x00100000 #define B_DIRTY 0x00200000 /* Needs writing later. */ #define B_RELBUF 0x00400000 /* Release VMIO buffer. */ #define B_WANT 0x00800000 /* Used by vm_pager.c */ -#define B_WRITE 0x00000000 /* Write buffer (pseudo flag). */ #define B_UNUSED1000000 0x01000000 /* Unused */ -#define B_XXX 0x02000000 /* Debugging flag. */ +#define B_UNUSED2000000 0x02000000 #define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */ #define B_ORDERED 0x08000000 /* Must guarantee I/O ordering */ #define B_RAM 0x10000000 /* Read ahead mark (flag) */ @@ -374,7 +382,7 @@ int physio (dev_t dev, struct uio *uio, int ioflag); #define physwrite physio void vfs_bio_set_validclean (struct buf *, int base, int size); void vfs_bio_clrbuf (struct buf *); -void vfs_busy_pages (struct vnode *, struct buf *, int clear_modify); +void vfs_busy_pages (struct vnode *, struct buf *); void vfs_unbusy_pages (struct buf *); int vmapbuf (struct buf *); void vunmapbuf (struct buf *); diff --git a/sys/vfs/gnu/ext2fs/ext2_bmap.c b/sys/vfs/gnu/ext2fs/ext2_bmap.c index 1b81c1930a..91d86ea733 100644 --- a/sys/vfs/gnu/ext2fs/ext2_bmap.c +++ b/sys/vfs/gnu/ext2fs/ext2_bmap.c @@ -37,7 +37,7 @@ * * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 * $FreeBSD: src/sys/ufs/ufs/ufs_bmap.c,v 1.34.2.1 2000/03/17 10:12:14 ps Exp $ - * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_bmap.c,v 1.2 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_bmap.c,v 1.3 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -215,9 +215,9 @@ ext2_bmaparray(struct vnode *vp, ext2_daddr_t bn, ext2_daddr_t *bnp, panic("ext2_bmaparray: indirect block not in cache"); #endif bp->b_bio2.bio_offset = fsbtodoff(fs, daddr); - bp->b_flags |= B_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); - vfs_busy_pages(bp->b_vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(bp->b_vp, bp); vn_strategy(bp->b_vp, &bp->b_bio1); error = biowait(bp); if (error) { diff --git a/sys/vfs/gnu/ext2fs/ext2_inode.c b/sys/vfs/gnu/ext2fs/ext2_inode.c index 7c746553d7..638e0bbef6 100644 --- a/sys/vfs/gnu/ext2fs/ext2_inode.c +++ b/sys/vfs/gnu/ext2fs/ext2_inode.c @@ -38,7 +38,7 @@ * * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93 * $FreeBSD: src/sys/gnu/ext2fs/ext2_inode.c,v 1.24.2.1 2000/08/03 00:52:57 peter Exp $ - * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_inode.c,v 1.16 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/gnu/ext2fs/ext2_inode.c,v 1.17 2006/04/30 17:22:18 dillon Exp $ */ #include "opt_quota.h" @@ -400,15 +400,13 @@ ext2_indirtrunc(struct inode *ip, daddr_t lbn, off_t doffset, daddr_t lastbn, */ vp = ITOV(ip); bp = getblk(vp, lblktodoff(fs, lbn), (int)fs->s_blocksize, 0, 0); - if (bp->b_flags & (B_DONE | B_DELWRI)) { - /* nop */ - } else if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + if ((bp->b_flags & B_CACHE) == 0) { bp->b_flags &= ~(B_ERROR | B_INVAL); + bp->b_cmd = BUF_CMD_READ; if (bp->b_bcount > bp->b_bufsize) panic("ext2_indirtrunc: bad buffer size"); bp->b_bio2.bio_offset = doffset; - vfs_busy_pages(bp->b_vp, bp, 0); + vfs_busy_pages(bp->b_vp, bp); vn_strategy(vp, &bp->b_bio1); error = biowait(bp); } diff --git a/sys/vfs/mfs/mfs_vnops.c b/sys/vfs/mfs/mfs_vnops.c index fd3f385fdc..a6a67b1d11 100644 --- a/sys/vfs/mfs/mfs_vnops.c +++ b/sys/vfs/mfs/mfs_vnops.c @@ -32,7 +32,7 @@ * * @(#)mfs_vnops.c 8.11 (Berkeley) 5/22/95 * $FreeBSD: src/sys/ufs/mfs/mfs_vnops.c,v 1.47.2.1 2001/05/22 02:06:43 bp Exp $ - * $DragonFly: src/sys/vfs/mfs/mfs_vnops.c,v 1.24 2006/04/02 01:35:34 dillon Exp $ + * $DragonFly: src/sys/vfs/mfs/mfs_vnops.c,v 1.25 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -133,7 +133,7 @@ mfs_fsync(struct vop_fsync_args *ap) /* * mfs_freeblks() - hook to allow us to free physical memory. * - * We implement the B_FREEBUF strategy. We can't just madvise() + * We implement the BUF_CMD_FREEBLKS strategy. We can't just madvise() * here because we have to do it in the correct order vs other bio * requests, so we queue it. * @@ -149,7 +149,8 @@ mfs_freeblks(struct vop_freeblks_args *ap) struct vnode *vp = ap->a_vp; bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF | B_ASYNC; + bp->b_flags |= B_ASYNC; + bp->b_cmd = BUF_CMD_FREEBLKS; bp->b_bio1.bio_offset = ap->a_offset; bp->b_bcount = ap->a_length; BUF_KERNPROC(bp); @@ -187,18 +188,25 @@ mfs_strategy(struct vop_strategy_args *ap) if (mfsp->mfs_td == NULL) { /* - * mini-root. Note: B_FREEBUF not supported at the moment, - * I'm not sure what kind of dataspace b_data is in. + * mini-root. Note: BUF_CMD_FREEBLKS not supported at the + * moment, since we do not know what kind of dataspace + * b_data is in. */ caddr_t base; base = mfsp->mfs_baseoff + bio->bio_offset; - if (bp->b_flags & B_FREEBUF) - ; - else if (bp->b_flags & B_READ) + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: + break; + case BUF_CMD_READ: bcopy(base, bp->b_data, bp->b_bcount); - else + break; + case BUF_CMD_WRITE: bcopy(bp->b_data, base, bp->b_bcount); + break; + default: + panic("mfs: bad b_cmd %d\n", bp->b_cmd); + } biodone(bio); } else if (mfsp->mfs_td == td) { /* @@ -226,7 +234,7 @@ mfs_strategy(struct vop_strategy_args *ap) * * Read and Write are handled with a simple copyin and copyout. * - * We also partially support VOP_FREEBLKS() via B_FREEBUF. We can't implement + * We also partially support VOP_FREEBLKS(). We can't implement * completely -- for example, on fragments or inode metadata, but we can * implement it for page-aligned requests. */ @@ -235,16 +243,18 @@ mfs_doio(struct bio *bio, struct mfsnode *mfsp) { struct buf *bp = bio->bio_buf; caddr_t base = mfsp->mfs_baseoff + bio->bio_offset; + int bytes; - if (bp->b_flags & B_FREEBUF) { + switch(bp->b_cmd) { + case BUF_CMD_FREEBLKS: /* - * Implement B_FREEBUF, which allows the filesystem to tell + * Implement FREEBLKS, which allows the filesystem to tell * a block device when blocks are no longer needed (like when * a file is deleted). We use the hook to MADV_FREE the VM. * This makes an MFS filesystem work as well or better then * a sun-style swap-mounted filesystem. */ - int bytes = bp->b_bcount; + bytes = bp->b_bcount; if ((vm_offset_t)base & PAGE_MASK) { int n = PAGE_SIZE - ((vm_offset_t)base & PAGE_MASK); @@ -264,16 +274,21 @@ mfs_doio(struct bio *bio, struct mfsnode *mfsp) } } bp->b_error = 0; - } else if (bp->b_flags & B_READ) { + break; + case BUF_CMD_READ: /* * Read data from our 'memory' disk */ bp->b_error = copyin(base, bp->b_data, bp->b_bcount); - } else { + break; + case BUF_CMD_WRITE: /* * Write data to our 'memory' disk */ bp->b_error = copyout(bp->b_data, base, bp->b_bcount); + break; + default: + panic("mfs: bad b_cmd %d\n", bp->b_cmd); } if (bp->b_error) bp->b_flags |= B_ERROR; diff --git a/sys/vfs/nfs/nfs_bio.c b/sys/vfs/nfs/nfs_bio.c index a35a9952e5..093b6cbe10 100644 --- a/sys/vfs/nfs/nfs_bio.c +++ b/sys/vfs/nfs/nfs_bio.c @@ -35,7 +35,7 @@ * * @(#)nfs_bio.c 8.9 (Berkeley) 3/30/95 * $FreeBSD: /repoman/r/ncvs/src/sys/nfsclient/nfs_bio.c,v 1.130 2004/04/14 23:23:55 peadar Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_bio.c,v 1.33 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_bio.c,v 1.34 2006/04/30 17:22:18 dillon Exp $ */ @@ -434,8 +434,9 @@ nfs_bioread(struct vnode *vp, struct uio *uio, int ioflag) if (!rabp) return (EINTR); if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= B_READ | B_ASYNC; - vfs_busy_pages(vp, rabp, 0); + rabp->b_flags |= B_ASYNC; + rabp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, rabp); if (nfs_asyncio(vp, &rabp->b_bio2, td)) { rabp->b_flags |= B_INVAL|B_ERROR; vfs_unbusy_pages(rabp); @@ -495,8 +496,8 @@ again: */ if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { brelse(bp); @@ -523,8 +524,8 @@ again: if (bp == NULL) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { bp->b_flags |= B_ERROR; @@ -549,8 +550,8 @@ again: return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { brelse(bp); @@ -578,8 +579,8 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); error = nfs_doio(vp, &bp->b_bio2, td); /* * no error + B_INVAL == directory EOF, @@ -622,8 +623,9 @@ again: NFS_DIRBLKSIZ, td); if (rabp) { if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= (B_READ | B_ASYNC); - vfs_busy_pages(vp, rabp, 0); + rabp->b_flags |= B_ASYNC; + rabp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, rabp); if (nfs_asyncio(vp, &rabp->b_bio2, td)) { rabp->b_flags |= B_INVAL|B_ERROR; vfs_unbusy_pages(rabp); @@ -944,8 +946,8 @@ again: } if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; - vfs_busy_pages(vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(vp, bp); error = nfs_doio(vp, &bp->b_bio2, td); if (error) { brelse(bp); @@ -1207,7 +1209,7 @@ nfs_asyncio(struct vnode *vp, struct bio *bio, struct thread *td) * leave the async daemons for more important rpc's (such as reads * and writes). */ - if ((bp->b_flags & (B_READ|B_NEEDCOMMIT)) == B_NEEDCOMMIT && + if (bp->b_cmd == BUF_CMD_WRITE && (bp->b_flags & B_NEEDCOMMIT) && (nmp->nm_bioqiods > nfs_numasync / 2)) { return(EIO); } @@ -1337,9 +1339,11 @@ nfs_doio(struct vnode *vp, struct bio *bio, struct thread *td) */ bp->b_flags &= ~(B_ERROR | B_INVAL); - KASSERT(!(bp->b_flags & B_DONE), ("nfs_doio: bp %p already marked done", bp)); - if (bp->b_flags & B_READ) { + KASSERT(bp->b_cmd != BUF_CMD_DONE, + ("nfs_doio: bp %p already marked done!", bp)); + + if (bp->b_cmd == BUF_CMD_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; @@ -1408,6 +1412,7 @@ nfs_doio(struct vnode *vp, struct bio *bio, struct thread *td) /* * If we only need to commit, try to commit */ + KKASSERT(bp->b_cmd == BUF_CMD_WRITE); if (bp->b_flags & B_NEEDCOMMIT) { int retv; off_t off; @@ -1493,10 +1498,8 @@ nfs_doio(struct vnode *vp, struct bio *bio, struct thread *td) || (!error && (bp->b_flags & B_NEEDCOMMIT))) { crit_enter(); bp->b_flags &= ~(B_INVAL|B_NOCACHE); - if ((bp->b_flags & B_PAGING) == 0) { + if ((bp->b_flags & B_PAGING) == 0) bdirty(bp); - bp->b_flags &= ~B_DONE; - } if (error && (bp->b_flags & B_ASYNC) == 0) bp->b_flags |= B_EINTR; crit_exit(); diff --git a/sys/vfs/nfs/nfs_vnops.c b/sys/vfs/nfs/nfs_vnops.c index 9416f3cc39..d465abdb0c 100644 --- a/sys/vfs/nfs/nfs_vnops.c +++ b/sys/vfs/nfs/nfs_vnops.c @@ -35,7 +35,7 @@ * * @(#)nfs_vnops.c 8.16 (Berkeley) 5/27/95 * $FreeBSD: src/sys/nfs/nfs_vnops.c,v 1.150.2.5 2001/12/20 19:56:28 dillon Exp $ - * $DragonFly: src/sys/vfs/nfs/nfs_vnops.c,v 1.57 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/nfs/nfs_vnops.c,v 1.58 2006/04/30 17:22:18 dillon Exp $ */ @@ -2834,8 +2834,8 @@ nfs_strategy(struct vop_strategy_args *ap) struct thread *td; int error = 0; - KASSERT(!(bp->b_flags & B_DONE), - ("nfs_strategy: buffer %p unexpectedly marked B_DONE", bp)); + KASSERT(bp->b_cmd != BUF_CMD_DONE, + ("nfs_strategy: buffer %p unexpectedly marked done", bp)); KASSERT(BUF_REFCNT(bp) > 0, ("nfs_strategy: buffer %p not locked", bp)); @@ -3088,15 +3088,18 @@ nfs_flush_bp(struct buf *bp, void *data) bremfree(bp); /* - * NOTE: we are not clearing B_DONE here, so we have - * to do it later on in this routine if we intend to - * initiate I/O on the bp. + * NOTE: storing the bp in the bvary[] basically sets + * it up for a commit operation. + * + * We must call vfs_busy_pages() now so the commit operation + * is interlocked with user modifications to memory mapped + * pages. * * Note: to avoid loopback deadlocks, we do not * assign b_runningbufspace. */ - vfs_busy_pages(bp->b_vp, bp, 1); - + bp->b_cmd = BUF_CMD_WRITE; + vfs_busy_pages(bp->b_vp, bp); info->bvary[info->bvsize] = bp; toff = bp->b_bio2.bio_offset + bp->b_dirtyoff; if (info->bvsize == 0 || toff < info->beg_off) @@ -3157,6 +3160,7 @@ nfs_flush_docommit(struct nfs_flush_info *info, int error) * Error, leave B_DELWRI intact */ vfs_unbusy_pages(bp); + bp->b_cmd = BUF_CMD_DONE; brelse(bp); } else { /* @@ -3173,7 +3177,7 @@ nfs_flush_docommit(struct nfs_flush_info *info, int error) crit_enter(); bp->b_flags |= B_ASYNC; bundirty(bp); - bp->b_flags &= ~(B_READ|B_DONE|B_ERROR); + bp->b_flags &= ~B_ERROR; bp->b_dirtyoff = bp->b_dirtyend = 0; crit_exit(); biodone(&bp->b_bio1); @@ -3226,8 +3230,6 @@ nfs_print(struct vop_print_args *ap) /* * Just call nfs_writebp() with the force argument set to 1. * - * NOTE: B_DONE may or may not be set in a_bp on call. - * * nfs_bwrite(struct vnode *a_bp) */ static int @@ -3260,14 +3262,15 @@ nfs_writebp(struct buf *bp, int force, struct thread *td) */ crit_enter(); bundirty(bp); - bp->b_flags &= ~(B_READ|B_DONE|B_ERROR); + bp->b_flags &= ~B_ERROR; + bp->b_cmd = BUF_CMD_WRITE; crit_exit(); /* * Note: to avoid loopback deadlocks, we do not * assign b_runningbufspace. */ - vfs_busy_pages(bp->b_vp, bp, 1); + vfs_busy_pages(bp->b_vp, bp); BUF_KERNPROC(bp); if (bp->b_flags & B_ASYNC) { diff --git a/sys/vfs/ntfs/ntfs_vnops.c b/sys/vfs/ntfs/ntfs_vnops.c index c5794286b9..cd276674ed 100644 --- a/sys/vfs/ntfs/ntfs_vnops.c +++ b/sys/vfs/ntfs/ntfs_vnops.c @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ntfs/ntfs_vnops.c,v 1.9.2.4 2002/08/06 19:35:18 semenu Exp $ - * $DragonFly: src/sys/vfs/ntfs/ntfs_vnops.c,v 1.30 2006/04/09 17:51:28 dillon Exp $ + * $DragonFly: src/sys/vfs/ntfs/ntfs_vnops.c,v 1.31 2006/04/30 17:22:18 dillon Exp $ * */ @@ -330,6 +330,9 @@ ntfs_strategy(struct vop_strategy_args *ap) struct fnode *fp = VTOF(vp); struct ntnode *ip = FTONT(fp); struct ntfsmount *ntmp = ip->i_mp; + u_int32_t toread; + u_int32_t towrite; + size_t tmp; int error; dprintf(("ntfs_strategy: loffset: %lld, doffset: %lld\n", @@ -338,9 +341,10 @@ ntfs_strategy(struct vop_strategy_args *ap) dprintf(("strategy: bcount: %d flags: 0x%lx\n", (u_int32_t)bp->b_bcount,bp->b_flags)); - if (bp->b_flags & B_READ) { - u_int32_t toread; + bp->b_error = 0; + switch(bp->b_cmd) { + case BUF_CMD_READ: if (bio->bio_offset >= fp->f_size) { clrbuf(bp); error = 0; @@ -362,10 +366,8 @@ ntfs_strategy(struct vop_strategy_args *ap) bzero(bp->b_data + toread, bp->b_bcount - toread); } - } else { - size_t tmp; - u_int32_t towrite; - + break; + case BUF_CMD_WRITE: if (bio->bio_offset + bp->b_bcount >= fp->f_size) { printf("ntfs_strategy: CAN'T EXTEND FILE\n"); bp->b_error = error = EFBIG; @@ -386,6 +388,9 @@ ntfs_strategy(struct vop_strategy_args *ap) bp->b_flags |= B_ERROR; } } + break; + default: + panic("ntfs: bad b_cmd %d\n", bp->b_cmd); } biodone(bio); return (error); diff --git a/sys/vfs/nwfs/nwfs_io.c b/sys/vfs/nwfs/nwfs_io.c index cb84c70418..02c3d5c950 100644 --- a/sys/vfs/nwfs/nwfs_io.c +++ b/sys/vfs/nwfs/nwfs_io.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/nwfs/nwfs_io.c,v 1.6.2.1 2000/10/25 02:11:10 bp Exp $ - * $DragonFly: src/sys/vfs/nwfs/nwfs_io.c,v 1.19 2006/03/24 18:35:34 dillon Exp $ + * $DragonFly: src/sys/vfs/nwfs/nwfs_io.c,v 1.20 2006/04/30 17:22:18 dillon Exp $ * */ #include @@ -276,7 +276,8 @@ nwfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *td uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_td = td; - if (bp->b_flags & B_READ) { + + if (bp->b_cmd == BUF_CMD_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; @@ -316,6 +317,7 @@ nwfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *td bp->b_error = error; } } else { /* write */ + KKASSERT(bp->b_cmd == BUF_CMD_WRITE); if (bio->bio_offset + bp->b_dirtyend > np->n_size) bp->b_dirtyend = np->n_size - bio->bio_offset; @@ -346,10 +348,8 @@ nwfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *td bp->b_flags &= ~(B_INVAL|B_NOCACHE); if ((bp->b_flags & B_ASYNC) == 0) bp->b_flags |= B_EINTR; - if ((bp->b_flags & B_PAGING) == 0) { + if ((bp->b_flags & B_PAGING) == 0) bdirty(bp); - bp->b_flags &= ~B_DONE; - } if ((bp->b_flags & B_ASYNC) == 0) bp->b_flags |= B_EINTR; crit_exit(); diff --git a/sys/vfs/smbfs/smbfs_io.c b/sys/vfs/smbfs/smbfs_io.c index 5af0976d2f..fa2473956a 100644 --- a/sys/vfs/smbfs/smbfs_io.c +++ b/sys/vfs/smbfs/smbfs_io.c @@ -30,7 +30,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/fs/smbfs/smbfs_io.c,v 1.3.2.3 2003/01/17 08:20:26 tjr Exp $ - * $DragonFly: src/sys/vfs/smbfs/smbfs_io.c,v 1.22 2006/03/24 18:35:34 dillon Exp $ + * $DragonFly: src/sys/vfs/smbfs/smbfs_io.c,v 1.23 2006/04/30 17:22:18 dillon Exp $ * */ #include @@ -316,7 +316,7 @@ smbfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *t smb_makescred(&scred, td, cr); - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; @@ -342,6 +342,7 @@ smbfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *t bp->b_flags |= B_ERROR; } } else { /* write */ + KKASSERT(bp->b_cmd == BUF_CMD_WRITE); if (bio->bio_offset + bp->b_dirtyend > np->n_size) bp->b_dirtyend = np->n_size - bio->bio_offset; @@ -372,10 +373,8 @@ smbfs_doio(struct vnode *vp, struct bio *bio, struct ucred *cr, struct thread *t bp->b_flags &= ~(B_INVAL|B_NOCACHE); if ((bp->b_flags & B_ASYNC) == 0) bp->b_flags |= B_EINTR; - if ((bp->b_flags & B_PAGING) == 0) { + if ((bp->b_flags & B_PAGING) == 0) bdirty(bp); - bp->b_flags &= ~B_DONE; - } if ((bp->b_flags & B_ASYNC) == 0) bp->b_flags |= B_EINTR; crit_exit(); diff --git a/sys/vfs/specfs/spec_vnops.c b/sys/vfs/specfs/spec_vnops.c index a0ee82ad31..e558c2e6ca 100644 --- a/sys/vfs/specfs/spec_vnops.c +++ b/sys/vfs/specfs/spec_vnops.c @@ -32,7 +32,7 @@ * * @(#)spec_vnops.c 8.14 (Berkeley) 5/21/95 * $FreeBSD: src/sys/miscfs/specfs/spec_vnops.c,v 1.131.2.4 2001/02/26 04:23:20 jlemon Exp $ - * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.38 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/specfs/spec_vnops.c,v 1.39 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -451,9 +451,10 @@ spec_strategy(struct vop_strategy_args *ap) struct vnode *vp; struct mount *mp; - if (((bp->b_flags & B_READ) == 0) && - (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) + if (bp->b_cmd != BUF_CMD_READ && + (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) { (*bioops.io_start)(bp); + } /* * Collect statistics on synchronous and asynchronous read @@ -462,16 +463,16 @@ spec_strategy(struct vop_strategy_args *ap) vp = ap->a_vp; KKASSERT(vp->v_rdev != NULL); /* XXX */ if (vn_isdisk(vp, NULL) && (mp = vp->v_rdev->si_mountpoint) != NULL) { - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_cmd == BUF_CMD_READ) { if (bp->b_lock.lk_lockholder == LK_KERNTHREAD) - mp->mnt_stat.f_asyncwrites++; + mp->mnt_stat.f_asyncreads++; else - mp->mnt_stat.f_syncwrites++; + mp->mnt_stat.f_syncreads++; } else { if (bp->b_lock.lk_lockholder == LK_KERNTHREAD) - mp->mnt_stat.f_asyncreads++; + mp->mnt_stat.f_asyncwrites++; else - mp->mnt_stat.f_syncreads++; + mp->mnt_stat.f_syncwrites++; } } dev_dstrategy_chain(vp->v_rdev, bio); @@ -494,7 +495,7 @@ spec_freeblks(struct vop_freeblks_args *ap) if ((dev_dflags(ap->a_vp->v_rdev) & D_CANFREE) == 0) return (0); bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF; + bp->b_cmd = BUF_CMD_FREEBLKS; bp->b_bio1.bio_offset = ap->a_offset; bp->b_bcount = ap->a_length; dev_dstrategy(ap->a_vp->v_rdev, &bp->b_bio1); @@ -639,7 +640,7 @@ spec_advlock(struct vop_advlock_args *ap) static void spec_getpages_iodone(struct bio *bio) { - bio->bio_buf->b_flags |= B_DONE; + bio->bio_buf->b_cmd = BUF_CMD_DONE; wakeup(bio->bio_buf); } @@ -691,8 +692,7 @@ spec_getpages(struct vop_getpages_args *ap) pmap_qenter(kva, ap->a_m, pcount); /* Build a minimal buffer header. */ - bp->b_flags |= B_READ; - + bp->b_cmd = BUF_CMD_READ; bp->b_bcount = size; bp->b_bufsize = size; bp->b_resid = 0; @@ -711,9 +711,8 @@ spec_getpages(struct vop_getpages_args *ap) crit_enter(); /* We definitely need to be at splbio here. */ - while ((bp->b_flags & B_DONE) == 0) { + while (bp->b_cmd != BUF_CMD_DONE) tsleep(bp, 0, "spread", 0); - } crit_exit(); diff --git a/sys/vfs/ufs/ffs_alloc.c b/sys/vfs/ufs/ffs_alloc.c index ba2c7fa68e..827b6776cc 100644 --- a/sys/vfs/ufs/ffs_alloc.c +++ b/sys/vfs/ufs/ffs_alloc.c @@ -32,7 +32,7 @@ * * @(#)ffs_alloc.c 8.18 (Berkeley) 5/26/95 * $FreeBSD: src/sys/ufs/ffs/ffs_alloc.c,v 1.64.2.2 2001/09/21 19:15:21 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_alloc.c,v 1.20 2006/04/28 06:13:56 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_alloc.c,v 1.21 2006/04/30 17:22:18 dillon Exp $ */ #include "opt_quota.h" @@ -231,7 +231,6 @@ ffs_realloccg(struct inode *ip, ufs_daddr_t lbprev, ufs_daddr_t bpref, ip->i_blocks += btodb(nsize - osize); ip->i_flag |= IN_CHANGE | IN_UPDATE; allocbuf(bp, nsize); - bp->b_flags |= B_DONE; bzero((char *)bp->b_data + osize, (uint)nsize - osize); *bpp = bp; return (0); @@ -296,7 +295,6 @@ ffs_realloccg(struct inode *ip, ufs_daddr_t lbprev, ufs_daddr_t bpref, ip->i_blocks += btodb(nsize - osize); ip->i_flag |= IN_CHANGE | IN_UPDATE; allocbuf(bp, nsize); - bp->b_flags |= B_DONE; bzero((char *)bp->b_data + osize, (uint)nsize - osize); *bpp = bp; return (0); diff --git a/sys/vfs/ufs/ffs_inode.c b/sys/vfs/ufs/ffs_inode.c index eb1f375e96..bfc306aff5 100644 --- a/sys/vfs/ufs/ffs_inode.c +++ b/sys/vfs/ufs/ffs_inode.c @@ -32,7 +32,7 @@ * * @(#)ffs_inode.c 8.13 (Berkeley) 4/21/95 * $FreeBSD: src/sys/ufs/ffs/ffs_inode.c,v 1.56.2.5 2002/02/05 18:35:03 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.20 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_inode.c,v 1.21 2006/04/30 17:22:18 dillon Exp $ */ #include "opt_quota.h" @@ -457,12 +457,12 @@ ffs_indirtrunc(struct inode *ip, ufs_daddr_t lbn, ufs_daddr_t dbn, vp = ITOV(ip); bp = getblk(vp, lblktodoff(fs, lbn), (int)fs->fs_bsize, 0, 0); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; bp->b_flags &= ~(B_ERROR|B_INVAL); + bp->b_cmd = BUF_CMD_READ; if (bp->b_bcount > bp->b_bufsize) panic("ffs_indirtrunc: bad buffer size"); bp->b_bio2.bio_offset = dbtodoff(fs, dbn); - vfs_busy_pages(vp, bp, 0); + vfs_busy_pages(vp, bp); /* * Access the block device layer using the device vnode * and the translated block number (bio2) instead of the diff --git a/sys/vfs/ufs/ffs_rawread.c b/sys/vfs/ufs/ffs_rawread.c index b7a1a708ec..ecc785f00b 100644 --- a/sys/vfs/ufs/ffs_rawread.c +++ b/sys/vfs/ufs/ffs_rawread.c @@ -24,7 +24,7 @@ * SUCH DAMAGE. * * $FreeBSD: src/sys/ufs/ffs/ffs_rawread.c,v 1.3.2.2 2003/05/29 06:15:35 alc Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_rawread.c,v 1.20 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_rawread.c,v 1.21 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -171,8 +171,7 @@ ffs_rawread_readahead(struct vnode *vp, caddr_t udata, off_t loffset, if (iolen != 0) bp->b_bcount -= PAGE_SIZE; } - bp->b_flags &= ~(/*B_READ|*/B_DONE|B_ERROR); - bp->b_flags |= B_READ; + bp->b_flags &= ~B_ERROR; bp->b_data = udata; bp->b_saveaddr = sa; bp->b_loffset = loffset; @@ -206,7 +205,6 @@ ffs_rawread_readahead(struct vnode *vp, caddr_t udata, off_t loffset, /* Mark operation completed (similar to bufdone()) */ bp->b_resid = 0; - bp->b_flags |= B_DONE; return 0; } @@ -227,6 +225,7 @@ ffs_rawread_readahead(struct vnode *vp, caddr_t udata, off_t loffset, * want the vnode state to indicate that an I/O on its behalf * is in progress. */ + bp->b_cmd = BUF_CMD_READ; bio_start_transaction(&bp->b_bio1, &vp->v_track_read); vn_strategy(dp, &bp->b_bio2); return 0; @@ -295,9 +294,8 @@ ffs_rawread_main(struct vnode *vp, struct uio *uio) } crit_enter(); - while ((bp->b_flags & B_DONE) == 0) { + while (bp->b_cmd != BUF_CMD_DONE) tsleep((caddr_t)&bp->b_bio2, 0, "rawrd", 0); - } crit_exit(); vunmapbuf(bp); @@ -365,9 +363,8 @@ ffs_rawread_main(struct vnode *vp, struct uio *uio) relpbuf(bp, &ffsrawbufcnt); if (nbp != NULL) { /* Run down readahead buffer */ crit_enter(); - while ((nbp->b_flags & B_DONE) == 0) { + while (nbp->b_cmd != BUF_CMD_DONE) tsleep(&nbp->b_bio2, 0, "rawrd", 0); - } crit_exit(); vunmapbuf(nbp); relpbuf(nbp, &ffsrawbufcnt); @@ -449,5 +446,6 @@ ffs_rawread(struct vnode *vp, static void ffs_rawreadwakeup(struct bio *bio) { + bio->bio_buf->b_cmd = BUF_CMD_DONE; wakeup(bio); } diff --git a/sys/vfs/ufs/ffs_softdep.c b/sys/vfs/ufs/ffs_softdep.c index a1803097c0..252bdce157 100644 --- a/sys/vfs/ufs/ffs_softdep.c +++ b/sys/vfs/ufs/ffs_softdep.c @@ -37,7 +37,7 @@ * * from: @(#)ffs_softdep.c 9.59 (McKusick) 6/21/00 * $FreeBSD: src/sys/ufs/ffs/ffs_softdep.c,v 1.57.2.11 2002/02/05 18:46:53 dillon Exp $ - * $DragonFly: src/sys/vfs/ufs/ffs_softdep.c,v 1.38 2006/04/28 06:13:56 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ffs_softdep.c,v 1.39 2006/04/30 17:22:18 dillon Exp $ */ /* @@ -3037,7 +3037,7 @@ softdep_disk_io_initiation(bp) * We only care about write operations. There should never * be dependencies for reads. */ - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) panic("softdep_disk_io_initiation: read"); marker.wk_type = D_LAST + 1; /* Not a normal workitem */ diff --git a/sys/vfs/ufs/ufs_bmap.c b/sys/vfs/ufs/ufs_bmap.c index d466e4af0e..176a91f60f 100644 --- a/sys/vfs/ufs/ufs_bmap.c +++ b/sys/vfs/ufs/ufs_bmap.c @@ -37,7 +37,7 @@ * * @(#)ufs_bmap.c 8.7 (Berkeley) 3/21/95 * $FreeBSD: src/sys/ufs/ufs/ufs_bmap.c,v 1.34.2.1 2000/03/17 10:12:14 ps Exp $ - * $DragonFly: src/sys/vfs/ufs/ufs_bmap.c,v 1.11 2006/04/28 16:34:01 dillon Exp $ + * $DragonFly: src/sys/vfs/ufs/ufs_bmap.c,v 1.12 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -208,9 +208,9 @@ ufs_bmaparray(struct vnode *vp, ufs_daddr_t bn, ufs_daddr_t *bnp, panic("ufs_bmaparray: indirect block not in cache"); #endif bp->b_bio2.bio_offset = fsbtodoff(fs, daddr); - bp->b_flags |= B_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); - vfs_busy_pages(bp->b_vp, bp, 0); + bp->b_cmd = BUF_CMD_READ; + vfs_busy_pages(bp->b_vp, bp); vn_strategy(bp->b_vp, &bp->b_bio1); error = biowait(bp); if (error) { diff --git a/sys/vfs/union/union_vnops.c b/sys/vfs/union/union_vnops.c index 6344a5385d..91134728e6 100644 --- a/sys/vfs/union/union_vnops.c +++ b/sys/vfs/union/union_vnops.c @@ -36,7 +36,7 @@ * * @(#)union_vnops.c 8.32 (Berkeley) 6/23/95 * $FreeBSD: src/sys/miscfs/union/union_vnops.c,v 1.72 1999/12/15 23:02:14 eivind Exp $ - * $DragonFly: src/sys/vfs/union/union_vnops.c,v 1.25 2006/03/29 18:45:06 dillon Exp $ + * $DragonFly: src/sys/vfs/union/union_vnops.c,v 1.26 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -1830,7 +1830,7 @@ union_strategy(struct vop_strategy_args *ap) #ifdef DIAGNOSTIC if (othervp == NULLVP) panic("union_strategy: nil vp"); - if (((bp->b_flags & B_READ) == 0) && (othervp == LOWERVP(ap->a_vp))) + if (bp->b_cmd != BUF_CMD_READ && (othervp == LOWERVP(ap->a_vp))) panic("union_strategy: writing to lowervp"); #endif return (vn_strategy(othervp, bio)); diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index 6cab8fbfdb..b9c47fc7ea 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -96,7 +96,7 @@ * @(#)swap_pager.c 8.9 (Berkeley) 3/21/94 * * $FreeBSD: src/sys/vm/swap_pager.c,v 1.130.2.12 2002/08/31 21:15:55 dillon Exp $ - * $DragonFly: src/sys/vm/swap_pager.c,v 1.21 2006/04/28 16:34:02 dillon Exp $ + * $DragonFly: src/sys/vm/swap_pager.c,v 1.22 2006/04/30 17:22:18 dillon Exp $ */ #include @@ -861,7 +861,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) /* * tracking for swapdev vnode I/Os */ - if (bp->b_flags & B_READ) + if (bp->b_cmd == BUF_CMD_READ) track = &swapdev_vp->v_track_read; else track = &swapdev_vp->v_track_write; @@ -888,9 +888,9 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) crit_enter(); /* - * Deal with B_FREEBUF + * Deal with BUF_CMD_FREEBLKS */ - if (bp->b_flags & B_FREEBUF) { + if (bp->b_cmd == BUF_CMD_FREEBLKS) { /* * FREE PAGE(s) - destroy underlying swap that is no longer * needed. @@ -928,7 +928,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) */ blk = swp_pager_meta_ctl(object, start, 0); - if ((blk == SWAPBLK_NONE) && (bp->b_flags & B_READ) == 0) { + if ((blk == SWAPBLK_NONE) && bp->b_cmd != BUF_CMD_READ) { blk = swp_pager_getswapspace(1); if (blk == SWAPBLK_NONE) { bp->b_error = ENOMEM; @@ -953,7 +953,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) ) ) { crit_exit(); - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { ++mycpu->gd_cnt.v_swapin; mycpu->gd_cnt.v_swappgsin += btoc(bufx->b_bcount); } else { @@ -967,7 +967,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) */ if (bufx->b_bcount) { bufx->b_bufsize = bufx->b_bcount; - if ((bufx->b_flags & B_READ) == 0) + if (bufx->b_cmd != BUF_CMD_READ) bufx->b_dirtyend = bufx->b_bcount; BUF_KERNPROC(bufx); vn_strategy(swapdev_vp, biox); @@ -999,8 +999,8 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) biox = &bufx->b_bio1; cluster_append(nbio, bufx); bufx->b_flags |= (bufx->b_flags & B_ORDERED) | - (bp->b_flags & B_READ) | B_ASYNC; + bufx->b_cmd = bp->b_cmd; biox->bio_done = swap_chain_iodone; biox->bio_offset = (off_t)blk << PAGE_SHIFT; biox->bio_caller_info1.cluster_parent = nbio; @@ -1023,7 +1023,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) if (biox) { if ((bp->b_flags & B_ASYNC) == 0) bufx->b_flags &= ~B_ASYNC; - if (bufx->b_flags & B_READ) { + if (bufx->b_cmd == BUF_CMD_READ) { ++mycpu->gd_cnt.v_swapin; mycpu->gd_cnt.v_swappgsin += btoc(bufx->b_bcount); } else { @@ -1033,7 +1033,7 @@ swap_pager_strategy(vm_object_t object, struct bio *bio) } if (bufx->b_bcount) { bufx->b_bufsize = bufx->b_bcount; - if ((bufx->b_flags & B_READ) == 0) + if (bufx->b_cmd != BUF_CMD_READ) bufx->b_dirtyend = bufx->b_bcount; BUF_KERNPROC(bufx); vn_strategy(swapdev_vp, biox); @@ -1127,7 +1127,6 @@ swap_chain_iodone(struct bio *biox) } biodone(nbio->bio_prev); } - bufx->b_flags |= B_DONE; bufx->b_flags &= ~B_ASYNC; relpbuf(bufx, NULL); } @@ -1245,7 +1244,6 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) pmap_qenter(kva, m + i, j - i); - bp->b_flags |= B_READ; bp->b_data = (caddr_t) kva; bp->b_bcount = PAGE_SIZE * (j - i); bp->b_bufsize = PAGE_SIZE * (j - i); @@ -1284,6 +1282,7 @@ swap_pager_getpages(vm_object_t object, vm_page_t *m, int count, int reqpage) * so we cannot assume they are valid anymore either. */ + bp->b_cmd = BUF_CMD_READ; BUF_KERNPROC(bp); vn_strategy(swapdev_vp, bio); @@ -1471,12 +1470,10 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync, * request and assign the swap space. */ - if (sync == TRUE) { + if (sync == TRUE) bp = getpbuf(&nsw_wcount_sync); - } else { + else bp = getpbuf(&nsw_wcount_async); - bp->b_flags |= B_ASYNC; - } bio = &bp->b_bio1; pmap_qenter((vm_offset_t)bp->b_data, &m[i], n); @@ -1500,22 +1497,21 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync, bp->b_xio.xio_pages[j] = mreq; } bp->b_xio.xio_npages = n; - /* - * Must set dirty range for NFS to work. - */ - bp->b_dirtyoff = 0; - bp->b_dirtyend = bp->b_bcount; mycpu->gd_cnt.v_swapout++; mycpu->gd_cnt.v_swappgsout += bp->b_xio.xio_npages; crit_exit(); + bp->b_dirtyoff = 0; /* req'd for NFS */ + bp->b_dirtyend = bp->b_bcount; /* req'd for NFS */ + bp->b_cmd = BUF_CMD_WRITE; + /* * asynchronous */ - if (sync == FALSE) { + bp->b_flags |= B_ASYNC; bio->bio_done = swp_pager_async_iodone; BUF_KERNPROC(bp); vn_strategy(swapdev_vp, bio); @@ -1540,9 +1536,8 @@ swap_pager_putpages(vm_object_t object, vm_page_t *m, int count, boolean_t sync, */ crit_enter(); - while ((bp->b_flags & B_DONE) == 0) { + while (bp->b_cmd != BUF_CMD_DONE) tsleep(bp, 0, "swwrt", 0); - } for (j = 0; j < n; ++j) rtvals[i+j] = VM_PAGER_PEND; @@ -1572,8 +1567,8 @@ swp_pager_sync_iodone(struct bio *bio) { struct buf *bp = bio->bio_buf; - bp->b_flags |= B_DONE; bp->b_flags &= ~B_ASYNC; + bp->b_cmd = BUF_CMD_DONE; wakeup(bp); } @@ -1598,18 +1593,16 @@ swp_pager_async_iodone(struct bio *bio) struct buf *bp = bio->bio_buf; vm_object_t object = NULL; int i; - - bp->b_flags |= B_DONE; + int *nswptr; /* * report error */ - if (bp->b_flags & B_ERROR) { printf( "swap_pager: I/O error - %s failed; offset %lld," "size %ld, error %d\n", - ((bp->b_flags & B_READ) ? "pagein" : "pageout"), + ((bp->b_cmd == BUF_CMD_READ) ? "pagein" : "pageout"), bio->bio_offset, (long)bp->b_bcount, bp->b_error @@ -1652,7 +1645,7 @@ swp_pager_async_iodone(struct bio *bio) * interrupt. */ - if (bp->b_flags & B_READ) { + if (bp->b_cmd == BUF_CMD_READ) { /* * When reading, reqpage needs to stay * locked for the parent, but all other @@ -1700,7 +1693,7 @@ swp_pager_async_iodone(struct bio *bio) vm_page_activate(m); vm_page_io_finish(m); } - } else if (bp->b_flags & B_READ) { + } else if (bp->b_cmd == BUF_CMD_READ) { /* * For read success, clear dirty bits. Nobody should * have this page mapped but don't take any chances, @@ -1771,16 +1764,14 @@ swp_pager_async_iodone(struct bio *bio) /* * release the physical I/O buffer */ - - relpbuf( - bp, - ((bp->b_flags & B_READ) ? &nsw_rcount : - ((bp->b_flags & B_ASYNC) ? - &nsw_wcount_async : - &nsw_wcount_sync - ) - ) - ); + if (bp->b_cmd == BUF_CMD_READ) + nswptr = &nsw_rcount; + else if (bp->b_flags & B_ASYNC) + nswptr = &nsw_wcount_async; + else + nswptr = &nsw_wcount_sync; + bp->b_cmd = BUF_CMD_DONE; + relpbuf(bp, nswptr); crit_exit(); } diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 22cd9e65ff..b9e134fa25 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -62,7 +62,7 @@ * rights to redistribute these changes. * * $FreeBSD: src/sys/vm/vm_pager.c,v 1.54.2.2 2001/11/18 07:11:00 dillon Exp $ - * $DragonFly: src/sys/vm/vm_pager.c,v 1.18 2006/04/28 16:34:02 dillon Exp $ + * $DragonFly: src/sys/vm/vm_pager.c,v 1.19 2006/04/30 17:22:18 dillon Exp $ */ /* @@ -320,6 +320,7 @@ initpbuf(struct buf *bp) bp->b_kvasize = MAXPHYS; bp->b_xflags = 0; bp->b_flags = B_PAGING; + bp->b_cmd = BUF_CMD_DONE; bp->b_error = 0; initbufbio(bp); xio_init(&bp->b_xio); diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 30725672a2..3d267ee45e 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -32,7 +32,7 @@ * * @(#)vm_swap.c 8.5 (Berkeley) 2/17/94 * $FreeBSD: src/sys/vm/vm_swap.c,v 1.96.2.2 2001/10/14 18:46:47 iedowse Exp $ - * $DragonFly: src/sys/vm/vm_swap.c,v 1.22 2006/03/24 18:35:34 dillon Exp $ + * $DragonFly: src/sys/vm/vm_swap.c,v 1.23 2006/04/30 17:22:18 dillon Exp $ */ #include "opt_swap.h" @@ -79,7 +79,7 @@ struct vnode *swapdev_vp; * vn_strategy() for swapdev_vp. * Perform swap strategy interleave device selection. * - * The bp is expected to be locked and *not* B_DONE on call. + * The bp is expected to be locked and on call. * * (struct vnode *a_vp, struct bio *b_bio) */ diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index a950b23009..1895d95c29 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -39,7 +39,7 @@ * * from: @(#)vnode_pager.c 7.5 (Berkeley) 4/20/91 * $FreeBSD: src/sys/vm/vnode_pager.c,v 1.116.2.7 2002/12/31 09:34:51 dillon Exp $ - * $DragonFly: src/sys/vm/vnode_pager.c,v 1.24 2006/04/28 16:34:02 dillon Exp $ + * $DragonFly: src/sys/vm/vnode_pager.c,v 1.25 2006/04/30 17:22:18 dillon Exp $ */ /* @@ -404,7 +404,7 @@ vnode_pager_iodone(struct bio *bio) { struct buf *bp = bio->bio_buf; - bp->b_flags |= B_DONE; + bp->b_cmd = BUF_CMD_DONE; wakeup(bp); } @@ -451,7 +451,6 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m) bp = getpbuf(&vnode_pbuf_freecnt); /* build a minimal buffer header */ - bp->b_flags |= B_READ; bp->b_data = (caddr_t) kva + i * bsize; bp->b_bio1.bio_done = vnode_pager_iodone; bp->b_bio1.bio_offset = doffset; @@ -459,6 +458,7 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m) bp->b_bufsize = bsize; bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; + bp->b_cmd = BUF_CMD_READ; /* do the input */ vn_strategy(dp, &bp->b_bio1); @@ -466,9 +466,8 @@ vnode_pager_input_smlfs(vm_object_t object, vm_page_t m) /* we definitely need to be at splvm here */ crit_enter(); - while ((bp->b_flags & B_DONE) == 0) { + while (bp->b_cmd != BUF_CMD_DONE) tsleep(bp, 0, "vnsrd", 0); - } crit_exit(); if ((bp->b_flags & B_ERROR) != 0) error = EIO; @@ -762,13 +761,13 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, pmap_qenter(kva, m, count); /* build a minimal buffer header */ - bp->b_flags |= B_READ; bp->b_bio1.bio_done = vnode_pager_iodone; bp->b_bio1.bio_offset = firstaddr; bp->b_bcount = size; bp->b_bufsize = size; bp->b_runningbufspace = bp->b_bufsize; runningbufspace += bp->b_runningbufspace; + bp->b_cmd = BUF_CMD_READ; mycpu->gd_cnt.v_vnodein++; mycpu->gd_cnt.v_vnodepgsin += count; @@ -779,9 +778,8 @@ vnode_pager_generic_getpages(struct vnode *vp, vm_page_t *m, int bytecount, crit_enter(); /* we definitely need to be at splvm here */ - while ((bp->b_flags & B_DONE) == 0) { + while (bp->b_cmd != BUF_CMD_DONE) tsleep(bp, 0, "vnread", 0); - } crit_exit(); if ((bp->b_flags & B_ERROR) != 0) error = EIO; -- 2.41.0