Index: amd64/amd64/genassym.c =================================================================== RCS file: /cvs/src/sys/amd64/amd64/genassym.c,v retrieving revision 1.9 diff -u -r1.9 genassym.c --- amd64/amd64/genassym.c 1 Dec 2005 18:30:11 -0000 1.9 +++ amd64/amd64/genassym.c 28 Apr 2006 16:43:28 -0000 @@ -171,7 +171,6 @@ 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); Index: bus/cam/cam_periph.c =================================================================== RCS file: /cvs/src/sys/bus/cam/cam_periph.c,v retrieving revision 1.13 diff -u -r1.13 cam_periph.c --- bus/cam/cam_periph.c 28 Apr 2006 16:33:57 -0000 1.13 +++ bus/cam/cam_periph.c 28 Apr 2006 16:49:56 -0000 @@ -481,7 +481,7 @@ 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 @@ * 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 @@ } 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 @@ } } - /* - * 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 @@ 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) { Index: bus/cam/scsi/scsi_cd.c =================================================================== RCS file: /cvs/src/sys/bus/cam/scsi/scsi_cd.c,v retrieving revision 1.21 diff -u -r1.21 scsi_cd.c --- bus/cam/scsi/scsi_cd.c 24 Mar 2006 18:35:26 -0000 1.21 +++ bus/cam/scsi/scsi_cd.c 28 Apr 2006 16:51:28 -0000 @@ -1552,7 +1552,7 @@ (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 */ Index: bus/cam/scsi/scsi_da.c =================================================================== RCS file: /cvs/src/sys/bus/cam/scsi/scsi_da.c,v retrieving revision 1.28 diff -u -r1.28 scsi_da.c --- bus/cam/scsi/scsi_da.c 24 Mar 2006 18:35:27 -0000 1.28 +++ bus/cam/scsi/scsi_da.c 28 Apr 2006 16:52:02 -0000 @@ -1399,7 +1399,7 @@ /*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, Index: bus/cam/scsi/scsi_pt.c =================================================================== RCS file: /cvs/src/sys/bus/cam/scsi/scsi_pt.c,v retrieving revision 1.13 diff -u -r1.13 scsi_pt.c --- bus/cam/scsi/scsi_pt.c 17 Feb 2006 19:17:42 -0000 1.13 +++ bus/cam/scsi/scsi_pt.c 28 Apr 2006 16:52:14 -0000 @@ -533,7 +533,7 @@ /*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, Index: bus/cam/scsi/scsi_sa.c =================================================================== RCS file: /cvs/src/sys/bus/cam/scsi/scsi_sa.c,v retrieving revision 1.16 diff -u -r1.16 scsi_sa.c --- bus/cam/scsi/scsi_sa.c 25 Mar 2006 21:30:41 -0000 1.16 +++ bus/cam/scsi/scsi_sa.c 28 Apr 2006 16:53:35 -0000 @@ -751,7 +751,7 @@ 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 @@ * 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 @@ 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; } Index: bus/firewire/fwmem.c =================================================================== RCS file: /cvs/src/sys/bus/firewire/fwmem.c,v retrieving revision 1.8 diff -u -r1.8 fwmem.c --- bus/firewire/fwmem.c 17 Feb 2006 19:17:44 -0000 1.8 +++ bus/firewire/fwmem.c 28 Apr 2006 16:54:20 -0000 @@ -371,7 +371,7 @@ } 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, Index: bus/isa/isavar.h =================================================================== RCS file: /cvs/src/sys/bus/isa/isavar.h,v retrieving revision 1.8 diff -u -r1.8 isavar.h --- bus/isa/isavar.h 12 Jun 2005 20:55:14 -0000 1.8 +++ bus/isa/isavar.h 28 Apr 2006 21:20:44 -0000 @@ -30,8 +30,10 @@ #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 @@ #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 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); Index: bus/isa/i386/isa_device.h =================================================================== RCS file: /cvs/src/sys/bus/isa/i386/isa_device.h,v retrieving revision 1.7 diff -u -r1.7 isa_device.h --- bus/isa/i386/isa_device.h 13 Oct 2005 00:02:28 -0000 1.7 +++ bus/isa/i386/isa_device.h 28 Apr 2006 21:18:36 -0000 @@ -38,11 +38,6 @@ #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 Index: bus/isa/i386/isa_dma.c =================================================================== RCS file: /cvs/src/sys/bus/isa/i386/isa_dma.c,v retrieving revision 1.7 diff -u -r1.7 isa_dma.c --- bus/isa/i386/isa_dma.c 22 Jan 2006 14:03:51 -0000 1.7 +++ bus/isa/i386/isa_dma.c 28 Apr 2006 21:23:23 -0000 @@ -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 @@ 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 @@ } 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); +} + Index: bus/isa/i386/isa_dma.h =================================================================== RCS file: bus/isa/i386/isa_dma.h diff -N bus/isa/i386/isa_dma.h --- bus/isa/i386/isa_dma.h 27 Aug 2003 11:42:34 -0000 1.3 +++ /dev/null 1 Jan 1970 00:00:00 -0000 @@ -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/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_ */ Index: contrib/dev/fla/fla.c =================================================================== RCS file: /cvs/src/sys/contrib/dev/fla/fla.c,v retrieving revision 1.11 diff -u -r1.11 fla.c --- contrib/dev/fla/fla.c 24 Mar 2006 18:35:29 -0000 1.11 +++ contrib/dev/fla/fla.c 28 Apr 2006 17:13:59 -0000 @@ -227,12 +227,19 @@ 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(); Index: dev/disk/ata/ata-disk.c =================================================================== RCS file: /cvs/src/sys/dev/disk/ata/ata-disk.c,v retrieving revision 1.27 diff -u -r1.27 ata-disk.c --- dev/disk/ata/ata-disk.c 24 Mar 2006 18:35:30 -0000 1.27 +++ dev/disk/ata/ata-disk.c 28 Apr 2006 16:56:58 -0000 @@ -432,7 +432,7 @@ 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) { Index: dev/disk/ata/ata-raid.c =================================================================== RCS file: /cvs/src/sys/dev/disk/ata/ata-raid.c,v retrieving revision 1.18 diff -u -r1.18 ata-raid.c --- dev/disk/ata/ata-raid.c 28 Apr 2006 16:33:58 -0000 1.18 +++ dev/disk/ata/ata-raid.c 28 Apr 2006 19:52:32 -0000 @@ -559,6 +559,7 @@ 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 @@ 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 @@ 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 @@ 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 @@ } } 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 @@ 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; Index: dev/disk/ata/atapi-cd.c =================================================================== RCS file: /cvs/src/sys/dev/disk/ata/atapi-cd.c,v retrieving revision 1.21 diff -u -r1.21 atapi-cd.c --- dev/disk/ata/atapi-cd.c 24 Mar 2006 18:35:30 -0000 1.21 +++ dev/disk/ata/atapi-cd.c 28 Apr 2006 17:03:19 -0000 @@ -1181,7 +1181,7 @@ } 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 @@ 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); } Index: dev/disk/ata/atapi-fd.c =================================================================== RCS file: /cvs/src/sys/dev/disk/ata/atapi-fd.c,v retrieving revision 1.14 diff -u -r1.14 atapi-fd.c --- dev/disk/ata/atapi-fd.c 24 Mar 2006 18:35:30 -0000 1.14 +++ dev/disk/ata/atapi-fd.c 28 Apr 2006 17:04:00 -0000 @@ -353,7 +353,7 @@ 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 @@ 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 Index: dev/disk/ata/atapi-tape.c =================================================================== RCS file: /cvs/src/sys/dev/disk/ata/atapi-tape.c,v retrieving revision 1.14 diff -u -r1.14 atapi-tape.c --- dev/disk/ata/atapi-tape.c 24 Mar 2006 18:35:30 -0000 1.14 +++ dev/disk/ata/atapi-tape.c 28 Apr 2006 17:05:06 -0000 @@ -437,7 +437,7 @@ 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 @@ 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 @@ 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 @@ 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); Index: dev/disk/ccd/ccd.c =================================================================== RCS file: /cvs/src/sys/dev/disk/ccd/ccd.c,v retrieving revision 1.26 diff -u -r1.26 ccd.c --- dev/disk/ccd/ccd.c 28 Apr 2006 16:33:59 -0000 1.26 +++ dev/disk/ccd/ccd.c 28 Apr 2006 17:06:45 -0000 @@ -875,7 +875,7 @@ * 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 @@ 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 @@ */ 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 Index: dev/disk/fd/fd.c =================================================================== RCS file: /cvs/src/sys/dev/disk/fd/fd.c,v retrieving revision 1.28 diff -u -r1.28 fd.c --- dev/disk/fd/fd.c 28 Apr 2006 16:34:00 -0000 1.28 +++ dev/disk/fd/fd.c 28 Apr 2006 20:42:34 -0000 @@ -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 @@ }; 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 @@ /* * 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 @@ 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 @@ } 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 @@ { /* 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 @@ */ 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 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ /* 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 @@ 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 @@ /* ...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; Index: dev/disk/mcd/mcd.c =================================================================== RCS file: /cvs/src/sys/dev/disk/mcd/mcd.c,v retrieving revision 1.17 diff -u -r1.17 mcd.c --- dev/disk/mcd/mcd.c 26 Mar 2006 07:56:54 -0000 1.17 +++ dev/disk/mcd/mcd.c 28 Apr 2006 17:11:58 -0000 @@ -419,7 +419,7 @@ } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (bp->b_cmd != BUF_CMD_READ) { bp->b_error = EROFS; goto bad; } Index: dev/disk/md/md.c =================================================================== RCS file: /cvs/src/sys/dev/disk/md/md.c,v retrieving revision 1.10 diff -u -r1.10 md.c --- dev/disk/md/md.c 24 Mar 2006 18:35:32 -0000 1.10 +++ dev/disk/md/md.c 28 Apr 2006 19:10:11 -0000 @@ -201,12 +201,19 @@ 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 @@ 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 @@ } 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 @@ *secpp = secp; } } + break; + default: + panic("md: bad b_cmd %d", bp->b_cmd); + } secno++; dst += DEV_BSIZE; @@ -324,16 +338,22 @@ 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); Index: dev/disk/scd/scd.c =================================================================== RCS file: /cvs/src/sys/dev/disk/scd/scd.c,v retrieving revision 1.16 diff -u -r1.16 scd.c --- dev/disk/scd/scd.c 26 Mar 2006 07:56:54 -0000 1.16 +++ dev/disk/scd/scd.c 28 Apr 2006 17:14:28 -0000 @@ -343,7 +343,7 @@ } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (bp->b_cmd != BUF_CMD_READ) { bp->b_error = EROFS; goto bad; } Index: dev/disk/vn/vn.c =================================================================== RCS file: /cvs/src/sys/dev/disk/vn/vn.c,v retrieving revision 1.18 diff -u -r1.18 vn.c --- dev/disk/vn/vn.c 27 Mar 2006 01:54:14 -0000 1.18 +++ dev/disk/vn/vn.c 28 Apr 2006 17:19:56 -0000 @@ -96,7 +96,7 @@ /* * 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 @@ /* * 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 @@ 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 @@ * * ( 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); Index: dev/disk/wt/wt.c =================================================================== RCS file: /cvs/src/sys/dev/disk/wt/wt.c,v retrieving revision 1.13 diff -u -r1.13 wt.c --- dev/disk/wt/wt.c 17 Feb 2006 19:18:05 -0000 1.13 +++ dev/disk/wt/wt.c 28 Apr 2006 20:46:31 -0000 @@ -163,7 +163,7 @@ 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 @@ 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 @@ 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 @@ } 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 @@ } t->flags |= TPWO | TPWANY; } + flags = ISADMA_WRITE; } if (! bp->b_bcount) @@ -567,8 +570,8 @@ 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(); Index: dev/misc/labpc/labpc.c =================================================================== RCS file: /cvs/src/sys/dev/misc/labpc/labpc.c,v retrieving revision 1.15 diff -u -r1.15 labpc.c --- dev/misc/labpc/labpc.c 17 Feb 2006 19:18:05 -0000 1.15 +++ dev/misc/labpc/labpc.c 28 Apr 2006 17:21:22 -0000 @@ -992,7 +992,7 @@ 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 @@ } } 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; Index: dev/misc/ppc/ppc.c =================================================================== RCS file: /cvs/src/sys/dev/misc/ppc/ppc.c,v retrieving revision 1.11 diff -u -r1.11 ppc.c --- dev/misc/ppc/ppc.c 11 Dec 2005 01:54:08 -0000 1.11 +++ dev/misc/ppc/ppc.c 28 Apr 2006 20:43:11 -0000 @@ -1671,7 +1671,7 @@ 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 @@ #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); Index: dev/raid/aac/aac.c =================================================================== RCS file: /cvs/src/sys/dev/raid/aac/aac.c,v retrieving revision 1.22 diff -u -r1.22 aac.c --- dev/raid/aac/aac.c 17 Apr 2006 15:59:54 -0000 1.22 +++ dev/raid/aac/aac.c 28 Apr 2006 17:21:45 -0000 @@ -943,7 +943,7 @@ /* 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 @@ /* 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 { Index: dev/raid/aac/aac_compat.h =================================================================== RCS file: /cvs/src/sys/dev/raid/aac/aac_compat.h,v retrieving revision 1.7 diff -u -r1.7 aac_compat.h --- dev/raid/aac/aac_compat.h 17 Feb 2006 19:18:05 -0000 1.7 +++ dev/raid/aac/aac_compat.h 28 Apr 2006 17:23:00 -0000 @@ -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 Index: dev/raid/amr/amr.c =================================================================== RCS file: /cvs/src/sys/dev/raid/amr/amr.c,v retrieving revision 1.17 diff -u -r1.17 amr.c --- dev/raid/amr/amr.c 24 Mar 2006 18:35:32 -0000 1.17 +++ dev/raid/amr/amr.c 28 Apr 2006 17:23:19 -0000 @@ -887,7 +887,7 @@ 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 { Index: dev/raid/ida/ida.c =================================================================== RCS file: /cvs/src/sys/dev/raid/ida/ida.c,v retrieving revision 1.10 diff -u -r1.10 ida.c --- dev/raid/ida/ida.c 24 Mar 2006 18:35:32 -0000 1.10 +++ dev/raid/ida/ida.c 28 Apr 2006 17:23:35 -0000 @@ -419,7 +419,7 @@ 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); } Index: dev/raid/ida/ida_disk.c =================================================================== RCS file: /cvs/src/sys/dev/raid/ida/ida_disk.c,v retrieving revision 1.10 diff -u -r1.10 ida_disk.c --- dev/raid/ida/ida_disk.c 17 Feb 2006 19:18:05 -0000 1.10 +++ dev/raid/ida/ida_disk.c 28 Apr 2006 17:23:55 -0000 @@ -170,7 +170,7 @@ /* * 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; } Index: dev/raid/ips/ips.h =================================================================== RCS file: /cvs/src/sys/dev/raid/ips/ips.h,v retrieving revision 1.8 diff -u -r1.8 ips.h --- dev/raid/ips/ips.h 17 Feb 2006 19:18:05 -0000 1.8 +++ dev/raid/ips/ips.h 28 Apr 2006 17:24:17 -0000 @@ -198,22 +198,6 @@ * 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 @@ #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) Index: dev/raid/mlx/mlx.c =================================================================== RCS file: /cvs/src/sys/dev/raid/mlx/mlx.c,v retrieving revision 1.17 diff -u -r1.17 mlx.c --- dev/raid/mlx/mlx.c 24 Mar 2006 18:35:32 -0000 1.17 +++ dev/raid/mlx/mlx.c 28 Apr 2006 17:24:38 -0000 @@ -1769,7 +1769,7 @@ 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 { Index: dev/raid/mlx/mlx_compat.h =================================================================== RCS file: /cvs/src/sys/dev/raid/mlx/mlx_compat.h,v retrieving revision 1.6 diff -u -r1.6 mlx_compat.h --- dev/raid/mlx/mlx_compat.h 17 Feb 2006 19:18:05 -0000 1.6 +++ dev/raid/mlx/mlx_compat.h 28 Apr 2006 17:24:49 -0000 @@ -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; Index: dev/raid/pst/pst-raid.c =================================================================== RCS file: /cvs/src/sys/dev/raid/pst/pst-raid.c,v retrieving revision 1.14 diff -u -r1.14 pst-raid.c --- dev/raid/pst/pst-raid.c 24 Mar 2006 18:35:32 -0000 1.14 +++ dev/raid/pst/pst-raid.c 28 Apr 2006 17:25:16 -0000 @@ -302,7 +302,7 @@ 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 @@ 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 */ Index: dev/raid/twe/twe.c =================================================================== RCS file: /cvs/src/sys/dev/raid/twe/twe.c,v retrieving revision 1.14 diff -u -r1.14 twe.c --- dev/raid/twe/twe.c 24 Mar 2006 18:35:32 -0000 1.14 +++ dev/raid/twe/twe.c 28 Apr 2006 17:25:27 -0000 @@ -411,7 +411,7 @@ 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 { Index: dev/raid/twe/twe_compat.h =================================================================== RCS file: /cvs/src/sys/dev/raid/twe/twe_compat.h,v retrieving revision 1.13 diff -u -r1.13 twe_compat.h --- dev/raid/twe/twe_compat.h 17 Feb 2006 19:18:06 -0000 1.13 +++ dev/raid/twe/twe_compat.h 28 Apr 2006 17:25:34 -0000 @@ -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; Index: dev/raid/vinum/vinumdaemon.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumdaemon.c,v retrieving revision 1.9 diff -u -r1.9 vinumdaemon.c --- dev/raid/vinum/vinumdaemon.c 24 Mar 2006 18:35:32 -0000 1.9 +++ dev/raid/vinum/vinumdaemon.c 28 Apr 2006 17:25:51 -0000 @@ -106,7 +106,7 @@ 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, Index: dev/raid/vinum/vinumext.h =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumext.h,v retrieving revision 1.6 diff -u -r1.6 vinumext.h --- dev/raid/vinum/vinumext.h 17 Feb 2006 19:18:06 -0000 1.6 +++ dev/raid/vinum/vinumext.h 28 Apr 2006 17:27:05 -0000 @@ -47,8 +47,8 @@ #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 @@ 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 */ Index: dev/raid/vinum/vinuminterrupt.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinuminterrupt.c,v retrieving revision 1.8 diff -u -r1.8 vinuminterrupt.c --- dev/raid/vinum/vinuminterrupt.c 26 Mar 2006 07:56:54 -0000 1.8 +++ dev/raid/vinum/vinuminterrupt.c 28 Apr 2006 17:29:35 -0000 @@ -96,7 +96,7 @@ 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 @@ } } /* 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 @@ #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 @@ } 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 @@ 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 @@ } /* 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 @@ 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, Index: dev/raid/vinum/vinumio.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumio.c,v retrieving revision 1.12 diff -u -r1.12 vinumio.c --- dev/raid/vinum/vinumio.c 28 Apr 2006 16:34:00 -0000 1.12 +++ dev/raid/vinum/vinumio.c 28 Apr 2006 19:55:20 -0000 @@ -304,8 +304,8 @@ /* * 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 @@ * 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 @@ 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 @@ 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: Index: dev/raid/vinum/vinumparser.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumparser.c,v retrieving revision 1.5 diff -u -r1.5 vinumparser.c --- dev/raid/vinum/vinumparser.c 25 Jan 2005 22:58:42 -0000 1.5 +++ dev/raid/vinum/vinumparser.c 28 Apr 2006 21:25:47 -0000 @@ -65,6 +65,7 @@ #include /* All this mess for a single struct definition */ #include +#include #include #include #include Index: dev/raid/vinum/vinumraid5.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumraid5.c,v retrieving revision 1.4 diff -u -r1.4 vinumraid5.c --- dev/raid/vinum/vinumraid5.c 17 Feb 2006 19:18:06 -0000 1.4 +++ dev/raid/vinum/vinumraid5.c 28 Apr 2006 17:30:30 -0000 @@ -363,7 +363,7 @@ } 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 @@ 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 @@ 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 @@ 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 */ } } /* Index: dev/raid/vinum/vinumrequest.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumrequest.c,v retrieving revision 1.10 diff -u -r1.10 vinumrequest.c --- dev/raid/vinum/vinumrequest.c 28 Apr 2006 16:34:00 -0000 1.10 +++ dev/raid/vinum/vinumrequest.c 28 Apr 2006 17:33:37 -0000 @@ -237,7 +237,7 @@ 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 @@ "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 @@ 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 @@ 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 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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 @@ && 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; Index: dev/raid/vinum/vinumrevive.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumrevive.c,v retrieving revision 1.9 diff -u -r1.9 vinumrevive.c --- dev/raid/vinum/vinumrevive.c 28 Apr 2006 16:34:01 -0000 1.9 +++ dev/raid/vinum/vinumrevive.c 28 Apr 2006 19:17:59 -0000 @@ -164,7 +164,8 @@ 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 @@ /* 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 @@ "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 @@ 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 @@ 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 @@ 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 @@ 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); Index: dev/raid/vinum/vinumstate.c =================================================================== RCS file: /cvs/src/sys/dev/raid/vinum/vinumstate.c,v retrieving revision 1.5 diff -u -r1.5 vinumstate.c --- dev/raid/vinum/vinumstate.c 17 Feb 2006 19:18:06 -0000 1.5 +++ dev/raid/vinum/vinumstate.c 28 Apr 2006 17:36:15 -0000 @@ -618,7 +618,7 @@ 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 */ Index: dev/sound/pcm/buffer.c =================================================================== RCS file: /cvs/src/sys/dev/sound/pcm/buffer.c,v retrieving revision 1.3 diff -u -r1.3 buffer.c --- dev/sound/pcm/buffer.c 30 Jul 2003 00:20:39 -0000 1.3 +++ dev/sound/pcm/buffer.c 28 Apr 2006 21:28:24 -0000 @@ -43,13 +43,14 @@ 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 @@ 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 @@ 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; } Index: dev/sound/pcm/sound.h =================================================================== RCS file: /cvs/src/sys/dev/sound/pcm/sound.h,v retrieving revision 1.7 diff -u -r1.7 sound.h --- dev/sound/pcm/sound.h 12 Oct 2005 17:35:55 -0000 1.7 +++ dev/sound/pcm/sound.h 28 Apr 2006 17:52:27 -0000 @@ -97,11 +97,6 @@ #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 Index: dev/video/gsc/gsc.c =================================================================== RCS file: /cvs/src/sys/dev/video/gsc/gsc.c,v retrieving revision 1.10 diff -u -r1.10 gsc.c --- dev/video/gsc/gsc.c 10 Jun 2005 23:25:08 -0000 1.10 +++ dev/video/gsc/gsc.c 28 Apr 2006 17:49:36 -0000 @@ -327,7 +327,7 @@ 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 @@ 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) Index: i386/i386/genassym.c =================================================================== RCS file: /cvs/src/sys/i386/i386/genassym.c,v retrieving revision 1.48 diff -u -r1.48 genassym.c --- i386/i386/genassym.c 1 Dec 2005 18:30:13 -0000 1.48 +++ i386/i386/genassym.c 28 Apr 2006 17:54:13 -0000 @@ -165,7 +165,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)); -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); Index: i386/i386/machdep.c =================================================================== RCS file: /cvs/src/sys/i386/i386/machdep.c,v retrieving revision 1.89 diff -u -r1.89 machdep.c --- i386/i386/machdep.c 2 Apr 2006 20:50:33 -0000 1.89 +++ i386/i386/machdep.c 28 Apr 2006 17:54:44 -0000 @@ -2543,7 +2543,7 @@ #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 @@ #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; } Index: i386/isa/asc.c =================================================================== RCS file: /cvs/src/sys/i386/isa/asc.c,v retrieving revision 1.11 diff -u -r1.11 asc.c --- i386/isa/asc.c 13 Oct 2005 08:50:33 -0000 1.11 +++ i386/isa/asc.c 28 Apr 2006 17:49:43 -0000 @@ -302,7 +302,7 @@ 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 @@ 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 @@ 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; Index: kern/kern_device.c =================================================================== RCS file: /cvs/src/sys/kern/kern_device.c,v retrieving revision 1.16 diff -u -r1.16 kern_device.c --- kern/kern_device.c 17 Feb 2006 19:18:06 -0000 1.16 +++ kern/kern_device.c 28 Apr 2006 19:47:47 -0000 @@ -211,7 +211,8 @@ 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; Index: kern/kern_physio.c =================================================================== RCS file: /cvs/src/sys/kern/kern_physio.c,v retrieving revision 1.17 diff -u -r1.17 kern_physio.c --- kern/kern_physio.c 28 Apr 2006 16:34:01 -0000 1.17 +++ kern/kern_physio.c 28 Apr 2006 21:12:51 -0000 @@ -35,6 +35,7 @@ static void physwakeup(struct bio *bio) { + bio->bio_buf->b_cmd = BUF_CMD_DONE; wakeup(bio); } @@ -70,9 +71,10 @@ 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 @@ } 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(); Index: kern/subr_devstat.c =================================================================== RCS file: /cvs/src/sys/kern/subr_devstat.c,v retrieving revision 1.2 diff -u -r1.2 subr_devstat.c --- kern/subr_devstat.c 17 Jun 2003 04:28:41 -0000 1.2 +++ kern/subr_devstat.c 28 Apr 2006 19:11:13 -0000 @@ -234,13 +234,17 @@ { 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); Index: kern/subr_disk.c =================================================================== RCS file: /cvs/src/sys/kern/subr_disk.c,v retrieving revision 1.22 diff -u -r1.22 subr_disk.c --- kern/subr_disk.c 24 Mar 2006 18:35:33 -0000 1.22 +++ kern/subr_disk.c 28 Apr 2006 19:18:14 -0000 @@ -660,7 +660,7 @@ 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 @@ * (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 @@ 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 @@ 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 @@ 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); Index: kern/subr_diskmbr.c =================================================================== RCS file: /cvs/src/sys/kern/subr_diskmbr.c,v retrieving revision 1.12 diff -u -r1.12 subr_diskmbr.c --- kern/subr_diskmbr.c 24 Mar 2006 18:35:33 -0000 1.12 +++ kern/subr_diskmbr.c 28 Apr 2006 17:57:16 -0000 @@ -179,7 +179,7 @@ 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 @@ 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, Index: kern/subr_diskslice.c =================================================================== RCS file: /cvs/src/sys/kern/subr_diskslice.c,v retrieving revision 1.16 diff -u -r1.16 subr_diskslice.c --- kern/subr_diskslice.c 28 Apr 2006 16:34:01 -0000 1.16 +++ kern/subr_diskslice.c 28 Apr 2006 19:20:41 -0000 @@ -204,14 +204,14 @@ #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 @@ 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 @@ } } +/* + * 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 *) Index: kern/vfs_aio.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_aio.c,v retrieving revision 1.23 diff -u -r1.23 vfs_aio.c --- kern/vfs_aio.c 28 Apr 2006 16:34:01 -0000 1.23 +++ kern/vfs_aio.c 28 Apr 2006 20:31:31 -0000 @@ -961,7 +961,8 @@ 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 @@ 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 @@ process_signal, aiocbe); } } + bp->b_cmd = BUF_CMD_DONE; wakeup(bp); } #endif /* VFS_AIO */ Index: kern/vfs_bio.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_bio.c,v retrieving revision 1.66 diff -u -r1.66 vfs_bio.c --- kern/vfs_bio.c 28 Apr 2006 16:34:01 -0000 1.66 +++ kern/vfs_bio.c 28 Apr 2006 20:24:57 -0000 @@ -354,6 +354,7 @@ 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 @@ /* 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 @@ /* 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 @@ 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 @@ /* 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 @@ /* * 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 ). - * - * 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. + * Turn buffer into delayed write request by marking it B_DELWRI. + * B_RELBUF and B_NOCACHE must be cleared. * - * Since the buffer is not on a queue, we do not update the numfreebuffers - * count. + * 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. * * Must be called from a critical section. * The buffer must be on BQUEUE_NONE. @@ -829,10 +827,10 @@ 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 @@ 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 @@ */ 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 @@ --numdirtybuffers; numdirtywakeup(lodirtybuffers); } - bp->b_flags &= ~(B_DELWRI | B_CACHE | B_FREEBUF); + bp->b_flags &= ~(B_DELWRI | B_CACHE); } /* @@ -1008,6 +1007,7 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ 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 @@ */ 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 @@ * 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 @@ { 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 @@ 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 @@ * 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 @@ 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 @@ * 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 @@ * 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 @@ * 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 @@ } /* - * 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 @@ * 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 @@ 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 @@ */ 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_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", Index: kern/vfs_cluster.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_cluster.c,v retrieving revision 1.21 diff -u -r1.21 vfs_cluster.c --- kern/vfs_cluster.c 28 Apr 2006 16:34:01 -0000 1.21 +++ kern/vfs_cluster.c 28 Apr 2006 20:19:00 -0000 @@ -69,7 +69,8 @@ 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 @@ 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 @@ * 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 @@ 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 @@ 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 @@ /* * 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 @@ 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 @@ } /* - * 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 @@ 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 @@ */ 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 @@ } 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 @@ */ 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 @@ 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 @@ 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 @@ } } /* - * 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 @@ continue; } bremfree(tbp); - tbp->b_flags &= ~B_DONE; + KKASSERT(tbp->b_cmd == BUF_CMD_DONE); crit_exit(); /* @@ -800,8 +804,8 @@ */ 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 @@ * 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 @@ 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 @@ 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 */ Index: kern/vfs_default.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_default.c,v retrieving revision 1.34 diff -u -r1.34 vfs_default.c --- kern/vfs_default.c 28 Apr 2006 16:34:01 -0000 1.34 +++ kern/vfs_default.c 28 Apr 2006 18:47:36 -0000 @@ -1134,10 +1134,10 @@ * 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 Index: kern/vfs_vopops.c =================================================================== RCS file: /cvs/src/sys/kern/vfs_vopops.c,v retrieving revision 1.21 diff -u -r1.21 vfs_vopops.c --- kern/vfs_vopops.c 25 Apr 2006 22:11:28 -0000 1.21 +++ kern/vfs_vopops.c 28 Apr 2006 18:48:17 -0000 @@ -871,7 +871,7 @@ 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); } Index: sys/buf.h =================================================================== RCS file: /cvs/src/sys/sys/buf.h,v retrieving revision 1.30 diff -u -r1.30 buf.h --- sys/buf.h 28 Apr 2006 16:34:01 -0000 1.30 +++ sys/buf.h 28 Apr 2006 20:19:10 -0000 @@ -99,6 +99,14 @@ 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 @@ 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 @@ * 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 @@ #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 @@ #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 @@ #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 *); Index: vfs/gnu/ext2fs/ext2_bmap.c =================================================================== RCS file: /cvs/src/sys/vfs/gnu/ext2fs/ext2_bmap.c,v retrieving revision 1.2 diff -u -r1.2 ext2_bmap.c --- vfs/gnu/ext2fs/ext2_bmap.c 28 Apr 2006 16:34:01 -0000 1.2 +++ vfs/gnu/ext2fs/ext2_bmap.c 28 Apr 2006 20:19:14 -0000 @@ -215,9 +215,9 @@ 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) { Index: vfs/gnu/ext2fs/ext2_inode.c =================================================================== RCS file: /cvs/src/sys/vfs/gnu/ext2fs/ext2_inode.c,v retrieving revision 1.16 diff -u -r1.16 ext2_inode.c --- vfs/gnu/ext2fs/ext2_inode.c 28 Apr 2006 16:34:01 -0000 1.16 +++ vfs/gnu/ext2fs/ext2_inode.c 28 Apr 2006 20:19:18 -0000 @@ -400,15 +400,13 @@ */ 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); } Index: vfs/mfs/mfs_vnops.c =================================================================== RCS file: /cvs/src/sys/vfs/mfs/mfs_vnops.c,v retrieving revision 1.24 diff -u -r1.24 mfs_vnops.c --- vfs/mfs/mfs_vnops.c 2 Apr 2006 01:35:34 -0000 1.24 +++ vfs/mfs/mfs_vnops.c 28 Apr 2006 21:13:31 -0000 @@ -133,7 +133,7 @@ /* * 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 @@ 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 @@ 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 @@ * * 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 @@ { 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 @@ } } 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; Index: vfs/nfs/nfs_bio.c =================================================================== RCS file: /cvs/src/sys/vfs/nfs/nfs_bio.c,v retrieving revision 1.33 diff -u -r1.33 nfs_bio.c --- vfs/nfs/nfs_bio.c 28 Apr 2006 16:34:01 -0000 1.33 +++ vfs/nfs/nfs_bio.c 28 Apr 2006 20:19:37 -0000 @@ -434,8 +434,9 @@ 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 @@ */ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ } 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 @@ * 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 @@ */ 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 @@ /* * 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 @@ || (!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(); Index: vfs/nfs/nfs_vnops.c =================================================================== RCS file: /cvs/src/sys/vfs/nfs/nfs_vnops.c,v retrieving revision 1.57 diff -u -r1.57 nfs_vnops.c --- vfs/nfs/nfs_vnops.c 28 Apr 2006 16:34:01 -0000 1.57 +++ vfs/nfs/nfs_vnops.c 28 Apr 2006 20:19:53 -0000 @@ -2834,8 +2834,8 @@ 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 @@ 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 @@ * Error, leave B_DELWRI intact */ vfs_unbusy_pages(bp); + bp->b_cmd = BUF_CMD_DONE; brelse(bp); } else { /* @@ -3173,7 +3177,7 @@ 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 @@ /* * 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 @@ */ 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) { Index: vfs/ntfs/ntfs_vnops.c =================================================================== RCS file: /cvs/src/sys/vfs/ntfs/ntfs_vnops.c,v retrieving revision 1.30 diff -u -r1.30 ntfs_vnops.c --- vfs/ntfs/ntfs_vnops.c 9 Apr 2006 17:51:28 -0000 1.30 +++ vfs/ntfs/ntfs_vnops.c 28 Apr 2006 18:56:46 -0000 @@ -330,6 +330,9 @@ 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 @@ 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 @@ 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 @@ bp->b_flags |= B_ERROR; } } + break; + default: + panic("ntfs: bad b_cmd %d\n", bp->b_cmd); } biodone(bio); return (error); Index: vfs/nwfs/nwfs_io.c =================================================================== RCS file: /cvs/src/sys/vfs/nwfs/nwfs_io.c,v retrieving revision 1.19 diff -u -r1.19 nwfs_io.c --- vfs/nwfs/nwfs_io.c 24 Mar 2006 18:35:34 -0000 1.19 +++ vfs/nwfs/nwfs_io.c 28 Apr 2006 19:44:08 -0000 @@ -276,7 +276,8 @@ 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 @@ 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 @@ 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(); Index: vfs/smbfs/smbfs_io.c =================================================================== RCS file: /cvs/src/sys/vfs/smbfs/smbfs_io.c,v retrieving revision 1.22 diff -u -r1.22 smbfs_io.c --- vfs/smbfs/smbfs_io.c 24 Mar 2006 18:35:34 -0000 1.22 +++ vfs/smbfs/smbfs_io.c 28 Apr 2006 19:44:11 -0000 @@ -316,7 +316,7 @@ 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 @@ 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 @@ 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(); Index: vfs/specfs/spec_vnops.c =================================================================== RCS file: /cvs/src/sys/vfs/specfs/spec_vnops.c,v retrieving revision 1.38 diff -u -r1.38 spec_vnops.c --- vfs/specfs/spec_vnops.c 28 Apr 2006 16:34:01 -0000 1.38 +++ vfs/specfs/spec_vnops.c 28 Apr 2006 19:35:06 -0000 @@ -451,9 +451,10 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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 @@ 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(); Index: vfs/ufs/ffs_alloc.c =================================================================== RCS file: /cvs/src/sys/vfs/ufs/ffs_alloc.c,v retrieving revision 1.20 diff -u -r1.20 ffs_alloc.c --- vfs/ufs/ffs_alloc.c 28 Apr 2006 06:13:56 -0000 1.20 +++ vfs/ufs/ffs_alloc.c 28 Apr 2006 19:36:10 -0000 @@ -231,7 +231,6 @@ 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 @@ 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); Index: vfs/ufs/ffs_inode.c =================================================================== RCS file: /cvs/src/sys/vfs/ufs/ffs_inode.c,v retrieving revision 1.20 diff -u -r1.20 ffs_inode.c --- vfs/ufs/ffs_inode.c 28 Apr 2006 16:34:01 -0000 1.20 +++ vfs/ufs/ffs_inode.c 28 Apr 2006 20:19:59 -0000 @@ -457,12 +457,12 @@ 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 Index: vfs/ufs/ffs_rawread.c =================================================================== RCS file: /cvs/src/sys/vfs/ufs/ffs_rawread.c,v retrieving revision 1.20 diff -u -r1.20 ffs_rawread.c --- vfs/ufs/ffs_rawread.c 28 Apr 2006 16:34:01 -0000 1.20 +++ vfs/ufs/ffs_rawread.c 28 Apr 2006 19:37:14 -0000 @@ -171,8 +171,7 @@ 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 @@ /* Mark operation completed (similar to bufdone()) */ bp->b_resid = 0; - bp->b_flags |= B_DONE; return 0; } @@ -227,6 +225,7 @@ * 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 @@ } 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 @@ 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 @@ static void ffs_rawreadwakeup(struct bio *bio) { + bio->bio_buf->b_cmd = BUF_CMD_DONE; wakeup(bio); } Index: vfs/ufs/ffs_softdep.c =================================================================== RCS file: /cvs/src/sys/vfs/ufs/ffs_softdep.c,v retrieving revision 1.38 diff -u -r1.38 ffs_softdep.c --- vfs/ufs/ffs_softdep.c 28 Apr 2006 06:13:56 -0000 1.38 +++ vfs/ufs/ffs_softdep.c 28 Apr 2006 19:44:46 -0000 @@ -3037,7 +3037,7 @@ * 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 */ Index: vfs/ufs/ufs_bmap.c =================================================================== RCS file: /cvs/src/sys/vfs/ufs/ufs_bmap.c,v retrieving revision 1.11 diff -u -r1.11 ufs_bmap.c --- vfs/ufs/ufs_bmap.c 28 Apr 2006 16:34:01 -0000 1.11 +++ vfs/ufs/ufs_bmap.c 28 Apr 2006 20:20:04 -0000 @@ -208,9 +208,9 @@ 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) { Index: vfs/union/union_vnops.c =================================================================== RCS file: /cvs/src/sys/vfs/union/union_vnops.c,v retrieving revision 1.25 diff -u -r1.25 union_vnops.c --- vfs/union/union_vnops.c 29 Mar 2006 18:45:06 -0000 1.25 +++ vfs/union/union_vnops.c 28 Apr 2006 19:04:01 -0000 @@ -1830,7 +1830,7 @@ #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)); Index: vm/swap_pager.c =================================================================== RCS file: /cvs/src/sys/vm/swap_pager.c,v retrieving revision 1.21 diff -u -r1.21 swap_pager.c --- vm/swap_pager.c 28 Apr 2006 16:34:02 -0000 1.21 +++ vm/swap_pager.c 28 Apr 2006 21:37:57 -0000 @@ -861,7 +861,7 @@ /* * 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 @@ 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 @@ */ 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 @@ ) ) { 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 @@ */ 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 @@ 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 @@ 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 @@ } 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 @@ } biodone(nbio->bio_prev); } - bufx->b_flags |= B_DONE; bufx->b_flags &= ~B_ASYNC; relpbuf(bufx, NULL); } @@ -1245,7 +1244,6 @@ 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 @@ * 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 @@ * 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 @@ 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 @@ */ 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 @@ { 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 @@ 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 @@ * 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 @@ 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 @@ /* * 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(); } Index: vm/vm_pager.c =================================================================== RCS file: /cvs/src/sys/vm/vm_pager.c,v retrieving revision 1.18 diff -u -r1.18 vm_pager.c --- vm/vm_pager.c 28 Apr 2006 16:34:02 -0000 1.18 +++ vm/vm_pager.c 28 Apr 2006 20:22:39 -0000 @@ -320,6 +320,7 @@ 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); Index: vm/vm_swap.c =================================================================== RCS file: /cvs/src/sys/vm/vm_swap.c,v retrieving revision 1.22 diff -u -r1.22 vm_swap.c --- vm/vm_swap.c 24 Mar 2006 18:35:34 -0000 1.22 +++ vm/vm_swap.c 28 Apr 2006 19:40:29 -0000 @@ -79,7 +79,7 @@ * 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) */ Index: vm/vnode_pager.c =================================================================== RCS file: /cvs/src/sys/vm/vnode_pager.c,v retrieving revision 1.24 diff -u -r1.24 vnode_pager.c --- vm/vnode_pager.c 28 Apr 2006 16:34:02 -0000 1.24 +++ vm/vnode_pager.c 28 Apr 2006 19:40:59 -0000 @@ -404,7 +404,7 @@ { struct buf *bp = bio->bio_buf; - bp->b_flags |= B_DONE; + bp->b_cmd = BUF_CMD_DONE; wakeup(bp); } @@ -451,7 +451,6 @@ 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 @@ 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 @@ /* 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 @@ 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 @@ 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;