diff options
98 files changed, 392 insertions, 350 deletions
diff --git a/sys/alpha/alpha/machdep.c b/sys/alpha/alpha/machdep.c index 4a8fb48..89da22f 100644 --- a/sys/alpha/alpha/machdep.c +++ b/sys/alpha/alpha/machdep.c @@ -1929,7 +1929,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if LABELSECTOR != 0 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -1937,7 +1937,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c index bb2bbfd..982f127 100644 --- a/sys/alpha/alpha/vm_machdep.c +++ b/sys/alpha/alpha/vm_machdep.c @@ -319,7 +319,7 @@ vmapbuf(bp) * when reading stuff off device into memory. */ vm_fault_quick(addr, - (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); pa = trunc_page(pmap_kextract((vm_offset_t) addr)); if (pa == 0) panic("vmapbuf: page not present"); diff --git a/sys/amd64/amd64/genassym.c b/sys/amd64/amd64/genassym.c index 3e843db..2303982 100644 --- a/sys/amd64/amd64/genassym.c +++ b/sys/amd64/amd64/genassym.c @@ -153,7 +153,6 @@ ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/amd64/amd64/machdep.c b/sys/amd64/amd64/machdep.c index c204fbe..bc6dc89 100644 --- a/sys/amd64/amd64/machdep.c +++ b/sys/amd64/amd64/machdep.c @@ -2360,7 +2360,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if LABELSECTOR != 0 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -2368,7 +2368,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/amd64/amd64/vm_machdep.c b/sys/amd64/amd64/vm_machdep.c index cdcc278..9f5d6c0 100644 --- a/sys/amd64/amd64/vm_machdep.c +++ b/sys/amd64/amd64/vm_machdep.c @@ -357,7 +357,7 @@ vmapbuf(bp) * when reading stuff off device into memory. */ vm_fault_quick(addr, - (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); pa = trunc_page(pmap_kextract((vm_offset_t) addr)); if (pa == 0) panic("vmapbuf: page not present"); diff --git a/sys/cam/cam_periph.c b/sys/cam/cam_periph.c index 2b6445f..080912b 100644 --- a/sys/cam/cam_periph.c +++ b/sys/cam/cam_periph.c @@ -556,7 +556,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) } if (dirs[i] & CAM_DIR_OUT) { - flags[i] = B_WRITE; + flags[i] = BIO_WRITE; if (!useracc(*data_ptrs[i], lengths[i], VM_PROT_READ)) { printf("cam_periph_mapmem: error, " @@ -568,12 +568,8 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) } } - /* - * XXX this check is really bogus, since B_WRITE currently - * is all 0's, and so it is "set" all the time. - */ if (dirs[i] & CAM_DIR_IN) { - flags[i] |= B_READ; + flags[i] = BIO_READ; if (!useracc(*data_ptrs[i], lengths[i], VM_PROT_WRITE)) { printf("cam_periph_mapmem: error, " @@ -610,7 +606,10 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo) mapinfo->bp[i]->b_bufsize = lengths[i]; /* set the flags */ - mapinfo->bp[i]->b_flags = flags[i] | B_PHYS; + mapinfo->bp[i]->b_flags = B_PHYS; + + /* set the direction */ + mapinfo->bp[i]->b_iocmd = flags[i]; /* map the buffer into kernel memory */ vmapbuf(mapinfo->bp[i]); diff --git a/sys/cam/scsi/scsi_cd.c b/sys/cam/scsi/scsi_cd.c index c2e2e25..11df7be 100644 --- a/sys/cam/scsi/scsi_cd.c +++ b/sys/cam/scsi/scsi_cd.c @@ -1432,7 +1432,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb) (bp->b_flags & B_ORDERED) != 0 ? MSG_ORDERED_Q_TAG : MSG_SIMPLE_Q_TAG, - /* read */bp->b_flags & B_READ, + /* read */bp->b_iocmd == BIO_READ, /* byte2 */ 0, /* minimum_cmd_size */ 10, /* lba */ bp->b_pblkno, diff --git a/sys/cam/scsi/scsi_da.c b/sys/cam/scsi/scsi_da.c index a9e1e21..ef35924 100644 --- a/sys/cam/scsi/scsi_da.c +++ b/sys/cam/scsi/scsi_da.c @@ -1056,7 +1056,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb) /*retries*/4, dadone, tag_code, - bp->b_flags & B_READ, + bp->b_iocmd == BIO_READ, /*byte2*/0, softc->minimum_cmd_size, bp->b_pblkno, diff --git a/sys/cam/scsi/scsi_pt.c b/sys/cam/scsi/scsi_pt.c index 4f7b8e0..911f46a 100644 --- a/sys/cam/scsi/scsi_pt.c +++ b/sys/cam/scsi/scsi_pt.c @@ -539,7 +539,7 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb) /*retries*/4, ptdone, MSG_SIMPLE_Q_TAG, - bp->b_flags & B_READ, + bp->b_iocmd == BIO_READ, /*byte2*/0, bp->b_bcount, bp->b_data, diff --git a/sys/cam/scsi/scsi_sa.c b/sys/cam/scsi/scsi_sa.c index 5bcb802..77b0445 100644 --- a/sys/cam/scsi/scsi_sa.c +++ b/sys/cam/scsi/scsi_sa.c @@ -710,7 +710,7 @@ sastrategy(struct buf *bp) 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_iocmd == BIO_READ)? "read" : "write", softc->queue_count)); splx(s); @@ -1491,7 +1491,7 @@ sastart(struct cam_periph *periph, union ccb *start_ccb) bp->b_resid = bp->b_bcount; bp->b_flags |= B_ERROR; if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) { - if ((bp->b_flags & B_READ) == 0) + if (bp->b_iocmd == BIO_WRITE) bp->b_error = ENOSPC; else bp->b_error = EIO; @@ -1568,10 +1568,10 @@ sastart(struct cam_periph *periph, union ccb *start_ccb) * have to do deal with 512 byte or 1KB intermediate * records. */ - softc->dsreg = (bp->b_flags & B_READ)? + softc->dsreg = (bp->b_iocmd == BIO_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_iocmd == BIO_READ), FALSE, (softc->flags & SA_FLAG_FIXED) != 0, length, bp->b_data, bp->b_bcount, SSD_FULL_SIZE, 120 * 60 * 1000); @@ -1661,7 +1661,7 @@ sadone(struct cam_periph *periph, union ccb *done_ccb) if (csio->resid != 0) { bp->b_flags |= B_ERROR; } - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_iocmd == BIO_WRITE) { softc->flags |= SA_FLAG_TAPE_WRITTEN; softc->filemarks = 0; } diff --git a/sys/cam/scsi/scsi_target.c b/sys/cam/scsi/scsi_target.c index 0b81045..541dbd6 100644 --- a/sys/cam/scsi/scsi_target.c +++ b/sys/cam/scsi/scsi_target.c @@ -1165,7 +1165,7 @@ targstrategy(struct buf *bp) * */ bp->b_resid = bp->b_bcount; - if ((bp->b_flags & B_READ) != 0) { + if (bp->b_iocmd == BIO_READ) { CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH, ("Queued a SEND buffer\n")); bufq_insert_tail(&softc->snd_buf_queue, bp); diff --git a/sys/contrib/dev/fla/fla.c b/sys/contrib/dev/fla/fla.c index 0f91842..cfc3b93 100644 --- a/sys/contrib/dev/fla/fla.c +++ b/sys/contrib/dev/fla/fla.c @@ -221,9 +221,9 @@ flastrategy(struct buf *bp) bp->b_resid = bp->b_bcount; unit = dkunit(bp->b_dev); - if (bp->b_flags & B_FREEBUF) + if (bp->b_iocmd == BIO_DELETE) what = DOC2K_ERASE; - else if (bp->b_flags & B_READ) + else if (bp->b_iocmd == BIO_READ) what = DOC2K_READ; else what = DOC2K_WRITE; diff --git a/sys/contrib/softupdates/ffs_softdep.c b/sys/contrib/softupdates/ffs_softdep.c index a137ce7..456667d 100644 --- a/sys/contrib/softupdates/ffs_softdep.c +++ b/sys/contrib/softupdates/ffs_softdep.c @@ -2780,7 +2780,7 @@ softdep_disk_io_initiation(bp) * We only care about write operations. There should never * be dependencies for reads. */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) panic("softdep_disk_io_initiation: read"); /* * Do any necessary pre-I/O processing. diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c index 14dfec4..6d7524d 100644 --- a/sys/dev/amr/amr.c +++ b/sys/dev/amr/amr.c @@ -853,7 +853,7 @@ amr_startio(struct amr_softc *sc) ac->ac_private = bp; ac->ac_data = bp->b_data; ac->ac_length = bp->b_bcount; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { ac->ac_flags |= AMR_CMD_DATAIN; cmd = AMR_CMD_LREAD; } else { diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c index 802a783..cba36c9 100644 --- a/sys/dev/ata/ata-disk.c +++ b/sys/dev/ata/ata-disk.c @@ -337,7 +337,7 @@ ad_start(struct ad_softc *adp) request->blockaddr = bp->b_pblkno; request->bytecount = bp->b_bcount; request->data = bp->b_data; - request->flags = (bp->b_flags & B_READ) ? ADR_F_READ : 0; + request->flags = (bp->b_iocmd == BIO_READ) ? ADR_F_READ : 0; /* remove from drive queue */ bufq_remove(&adp->queue, bp); diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c index 4c9da0d..a20cb4c 100644 --- a/sys/dev/ata/atapi-cd.c +++ b/sys/dev/ata/atapi-cd.c @@ -1107,7 +1107,6 @@ acd_start(struct atapi_softc *atp) } acd_select_slot(cdp); - bzero(ccb, sizeof(ccb)); count = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size; if (bp->b_flags & B_PHYS) @@ -1115,7 +1114,7 @@ acd_start(struct atapi_softc *atp) else lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { /* if transfer goes beyond EOM adjust it to be within limits */ if (lba + count > cdp->info.volsize) { /* if we are entirely beyond EOM return EOF */ @@ -1145,8 +1144,8 @@ acd_start(struct atapi_softc *atp) devstat_start_transaction(cdp->stats); - atapi_queue_cmd(cdp->atp, ccb, bp->b_data, count * cdp->block_size, - bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, acd_done, bp); + atapi_queue_cmd(cdp->atp, ccb, bp->b_data, bp->b_bcount, + (bp->b_iocmd == BIO_READ)?ATPR_F_READ : 0, 30, acd_done, bp); } static int32_t @@ -1161,7 +1160,7 @@ acd_done(struct atapi_request *request) } else { bp->b_resid = bp->b_bcount - request->donecount; - if (!(bp->b_flags & B_READ)) + if (bp->b_iocmd == BIO_WRITE) cdp->flags |= F_WRITTEN; } devstat_end_transaction_buf(cdp->stats, bp); diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c index a27147b..6588684 100644 --- a/sys/dev/ata/atapi-fd.c +++ b/sys/dev/ata/atapi-fd.c @@ -321,7 +321,7 @@ afd_start(struct atapi_softc *atp) bzero(ccb, sizeof(ccb)); - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) ccb[0] = ATAPI_READ_BIG; else ccb[0] = ATAPI_WRITE_BIG; @@ -338,7 +338,7 @@ afd_start(struct atapi_softc *atp) atapi_queue_cmd(fdp->atp, ccb, data_ptr, fdp->transfersize * fdp->cap.sector_size, - (bp->b_flags & B_READ) ? ATPR_F_READ : 0, 30, + (bp->b_iocmd == BIO_READ) ? ATPR_F_READ : 0, 30, afd_partial_done, bp); count -= fdp->transfersize; @@ -354,7 +354,7 @@ afd_start(struct atapi_softc *atp) ccb[8] = count; atapi_queue_cmd(fdp->atp, ccb, data_ptr, count * fdp->cap.sector_size, - bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, afd_done, bp); + (bp->b_iocmd == BIO_READ) ? ATPR_F_READ : 0, 30, afd_done, bp); } static int32_t diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c index 2f737c4..3d08eba 100644 --- a/sys/dev/ata/atapi-tape.c +++ b/sys/dev/ata/atapi-tape.c @@ -421,7 +421,7 @@ aststrategy(struct buf *bp) biodone(bp); return; } - if (!(bp->b_flags & B_READ) && stp->flags & F_WRITEPROTECT) { + if (!(bp->b_iocmd == BIO_READ) && stp->flags & F_WRITEPROTECT) { bp->b_error = EPERM; bp->b_flags |= B_ERROR; biodone(bp); @@ -466,7 +466,7 @@ ast_start(struct atapi_softc *atp) bzero(ccb, sizeof(ccb)); - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) ccb[0] = ATAPI_READ; else ccb[0] = ATAPI_WRITE; @@ -482,7 +482,7 @@ ast_start(struct atapi_softc *atp) devstat_start_transaction(&stp->stats); atapi_queue_cmd(stp->atp, ccb, bp->b_data, blkcount * stp->blksize, - bp->b_flags & B_READ ? ATPR_F_READ : 0, 60, ast_done, bp); + (bp->b_iocmd == BIO_READ) ? ATPR_F_READ : 0, 60, ast_done, bp); } static int32_t @@ -496,7 +496,7 @@ ast_done(struct atapi_request *request) bp->b_flags |= B_ERROR; } else { - if (!(bp->b_flags & B_READ)) + if (!(bp->b_iocmd == BIO_READ)) stp->flags |= F_DATA_WRITTEN; bp->b_resid = bp->b_bcount - request->donecount; ast_total += (bp->b_bcount - bp->b_resid); diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c index 672ffe2..fe45b6e 100644 --- a/sys/dev/ccd/ccd.c +++ b/sys/dev/ccd/ccd.c @@ -193,7 +193,7 @@ static void ccdattach __P((void)); static int ccd_modevent __P((module_t, int, void *)); /* called by biodone() at interrupt time */ -static void ccdiodone __P((struct ccdbuf *cbp)); +static void ccdiodone __P((struct buf *bp)); static void ccdstart __P((struct ccd_softc *, struct buf *)); static void ccdinterleave __P((struct ccd_softc *, int)); @@ -887,7 +887,7 @@ ccdstart(cs, bp) * 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_iocmd == BIO_WRITE) { cbp[0]->cb_buf.b_vp->v_numoutput++; cbp[1]->cb_buf.b_vp->v_numoutput++; VOP_STRATEGY(cbp[0]->cb_buf.b_vp, @@ -911,7 +911,7 @@ ccdstart(cs, bp) /* * Not mirroring */ - if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) + if (cbp[0]->cb_buf.b_iocmd == BIO_WRITE) cbp[0]->cb_buf.b_vp->v_numoutput++; VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf); } @@ -1050,8 +1050,9 @@ ccdbuffer(cb, cs, bp, bn, addr, bcount) * Fill in the component buf structure. */ cbp = getccdbuf(NULL); - cbp->cb_buf.b_flags = bp->b_flags | B_CALL; - cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone; + cbp->cb_buf.b_flags = bp->b_flags; + cbp->cb_buf.b_iocmd = bp->b_iocmd; + cbp->cb_buf.b_iodone = ccdiodone; cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */ cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET; cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET); @@ -1122,9 +1123,10 @@ ccdintr(cs, bp) * take a ccd interrupt. */ static void -ccdiodone(cbp) - struct ccdbuf *cbp; +ccdiodone(ibp) + struct buf *ibp; { + struct ccdbuf *cbp = (struct ccdbuf *)ibp; struct buf *bp = cbp->cb_obp; int unit = cbp->cb_unit; int count, s; @@ -1153,7 +1155,7 @@ ccdiodone(cbp) const char *msg = ""; if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) && - (cbp->cb_buf.b_flags & B_READ) && + (cbp->cb_buf.b_iocmd == BIO_READ) && (cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) { /* * We will try our read on the other disk down @@ -1186,7 +1188,7 @@ ccdiodone(cbp) */ if (ccd_softc[unit].sc_cflags & CCDF_MIRROR) { - if ((cbp->cb_buf.b_flags & B_READ) == 0) { + if (cbp->cb_buf.b_iocmd == BIO_WRITE) { /* * When writing, handshake with the second buffer * to determine when both are done. If both are not diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c index 7c96092..4048c7f 100644 --- a/sys/dev/fdc/fdc.c +++ b/sys/dev/fdc/fdc.c @@ -1620,7 +1620,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count) { u_char *cptr = (u_char *)addr; - if (flags & B_READ) { + if (flags == BIO_READ) { if (fdc->state != PIOREAD) { fdc->state = PIOREAD; return(0); @@ -1679,7 +1679,7 @@ fdstate(fdc_p fdc) fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); - read = bp->b_flags & B_READ; + read = bp->b_iocmd == BIO_READ; format = bp->b_flags & B_FORMAT; if (format) { finfo = (struct fd_formb *)bp->b_data; @@ -1885,7 +1885,7 @@ fdstate(fdc_p fdc) */ SET_BCDR(fdc, 1, bp->b_bcount, 0); - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, bp->b_bcount); @@ -1918,7 +1918,7 @@ fdstate(fdc_p fdc) * the WRITE command is sent */ if (!read) - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, fdblk); } @@ -1948,7 +1948,7 @@ fdstate(fdc_p fdc) * if this is a read, then simply await interrupt * before performing PIO */ - if (read && !fdcpio(fdc,bp->b_flags, + if (read && !fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip,fdblk)) { fd->tohandle = timeout(fd_iotimeout, fdc, hz); return(0); /* will return later */ @@ -1966,7 +1966,7 @@ fdstate(fdc_p fdc) * actually perform the PIO read. The IOCOMPLETE case * removes the timeout for us. */ - (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk); + (void)fdcpio(fdc,bp->b_iocmd,bp->b_data+fd->skip,fdblk); fdc->state = IOCOMPLETE; /* FALLTHROUGH */ case IOCOMPLETE: /* IO DONE, post-analyze */ diff --git a/sys/dev/ida/ida.c b/sys/dev/ida/ida.c index c53f2c9..c9e924e 100644 --- a/sys/dev/ida/ida.c +++ b/sys/dev/ida/ida.c @@ -404,7 +404,7 @@ ida_construct_qcb(struct ida_softc *ida) hwqcb->req.blkno = bp->b_pblkno; 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_iocmd == BIO_READ ? CMD_READ : CMD_WRITE; STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe); } diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c index c0bf915..ee1c157 100644 --- a/sys/dev/ida/ida_disk.c +++ b/sys/dev/ida/ida_disk.c @@ -163,7 +163,7 @@ idstrategy(struct buf *bp) /* * software write protect check */ - if (drv->flags & DRV_WRITEPROT && (bp->b_flags & B_READ) == 0) { + if (drv->flags & DRV_WRITEPROT && (bp->b_iocmd == BIO_WRITE)) { bp->b_error = EROFS; goto bad; } diff --git a/sys/dev/mcd/mcd.c b/sys/dev/mcd/mcd.c index 923ec0f..8b41449 100644 --- a/sys/dev/mcd/mcd.c +++ b/sys/dev/mcd/mcd.c @@ -414,7 +414,7 @@ MCD_TRACE("strategy: drive not valid\n"); } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (!(bp->b_iocmd == BIO_READ)) { bp->b_error = EROFS; goto bad; } diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c index 66ede3b..8b5ca80 100644 --- a/sys/dev/md/md.c +++ b/sys/dev/md/md.c @@ -191,9 +191,9 @@ mdstrategy_malloc(struct buf *bp) devstat_start_transaction(&sc->stats); - if (bp->b_flags & B_FREEBUF) + if (bp->b_iocmd == BIO_DELETE) dop = DEVSTAT_NO_DATA; - else if (bp->b_flags & B_READ) + else if (bp->b_iocmd == BIO_READ) dop = DEVSTAT_READ; else dop = DEVSTAT_WRITE; @@ -220,13 +220,13 @@ mdstrategy_malloc(struct buf *bp) if (md_debug > 2) printf("%lx %p %p %d\n", bp->b_flags, secpp, secp, secval); - if (bp->b_flags & B_FREEBUF) { + if (bp->b_iocmd == BIO_DELETE) { if (secpp) { if (secp) FREE(secp, M_MDSECT); *secpp = 0; } - } else if (bp->b_flags & B_READ) { + } else if (bp->b_iocmd == BIO_READ) { if (secp) { bcopy(secp, dst, DEV_BSIZE); } else if (secval) { @@ -316,9 +316,9 @@ mdstrategy_preload(struct buf *bp) devstat_start_transaction(&sc->stats); - if (bp->b_flags & B_FREEBUF) { + if (bp->b_iocmd == BIO_DELETE) { dop = DEVSTAT_NO_DATA; - } else if (bp->b_flags & B_READ) { + } else if (bp->b_iocmd == BIO_READ) { dop = DEVSTAT_READ; bcopy(sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_data, bp->b_bcount); } else { diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c index 3e33bfa..94e2863 100644 --- a/sys/dev/mlx/mlx.c +++ b/sys/dev/mlx/mlx.c @@ -1658,7 +1658,7 @@ mlx_startio(struct mlx_softc *sc) mc->mc_private = bp; mc->mc_data = bp->b_data; mc->mc_length = bp->b_bcount; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { mc->mc_flags |= MLX_CMD_DATAIN; cmd = MLX_CMD_READSG; } else { diff --git a/sys/dev/scd/scd.c b/sys/dev/scd/scd.c index b6e9460..836dbc9 100644 --- a/sys/dev/scd/scd.c +++ b/sys/dev/scd/scd.c @@ -337,7 +337,7 @@ scdstrategy(struct buf *bp) } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (!(bp->b_iocmd == BIO_READ)) { bp->b_error = EROFS; goto bad; } diff --git a/sys/dev/vinum/vinumdaemon.c b/sys/dev/vinum/vinumdaemon.c index 835fec8..3ac54d2 100644 --- a/sys/dev/vinum/vinumdaemon.c +++ b/sys/dev/vinum/vinumdaemon.c @@ -106,7 +106,7 @@ vinum_daemon(void) log(LOG_WARNING, "vinum: recovering I/O request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n", rq, - rq->bp->b_flags & B_READ ? "Read" : "Write", + rq->bp->b_iocmd == BIO_READ ? "Read" : "Write", major(rq->bp->b_dev), minor(rq->bp->b_dev), rq->bp->b_blkno, diff --git a/sys/dev/vinum/vinumext.h b/sys/dev/vinum/vinumext.h index 5d87ad4..6518b90 100644 --- a/sys/dev/vinum/vinumext.h +++ b/sys/dev/vinum/vinumext.h @@ -46,8 +46,8 @@ extern int debug; /* debug flags */ #endif /* Physical read and write drive */ -#define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ) -#define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE) +#define read_drive(a, b, c, d) driveio (a, b, c, d, BIO_READ) +#define write_drive(a, b, c, d) driveio (a, b, c, d, BIO_WRITE) #define CHECKALLOC(ptr, msg) \ if (ptr == NULL) \ diff --git a/sys/dev/vinum/vinuminterrupt.c b/sys/dev/vinum/vinuminterrupt.c index 935317a..8a23462 100644 --- a/sys/dev/vinum/vinuminterrupt.c +++ b/sys/dev/vinum/vinuminterrupt.c @@ -89,7 +89,7 @@ complete_rqe(struct buf *bp) else if (rq->error == 0) /* no: do we have one already? */ rq->error = EIO; /* no: catchall "I/O error" */ SD[rqe->sdno].lasterror = rq->error; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { log(LOG_ERR, "%s: fatal read I/O error\n", SD[rqe->sdno].name); set_sd_state(rqe->sdno, sd_crashed, setstate_force); /* subdisk is crashed */ } else { /* write operation */ @@ -105,7 +105,7 @@ complete_rqe(struct buf *bp) } } /* Now update the statistics */ - if (bp->b_flags & B_READ) { /* read operation */ + if (bp->b_iocmd == BIO_READ) { /* read operation */ DRIVE[rqe->driveno].reads++; DRIVE[rqe->driveno].bytes_read += bp->b_bcount; SD[rqe->sdno].reads++; @@ -226,7 +226,7 @@ sdio_done(struct buf *bp) #endif sbp->bp->b_resid = sbp->b.b_resid; /* copy the resid field */ /* Now update the statistics */ - if (bp->b_flags & B_READ) { /* read operation */ + if (bp->b_iocmd == BIO_READ) { /* read operation */ DRIVE[sbp->driveno].reads++; DRIVE[sbp->driveno].bytes_read += sbp->b.b_bcount; SD[sbp->sdno].reads++; @@ -340,11 +340,10 @@ complete_raid5_write(struct rqelement *rqe) } else panic("complete_raid5_write: malloc conflict"); - if ((rqe->b.b_flags & B_READ) /* this was a read */ + if ((rqe->b.b_iocmd == BIO_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_flags |= B_CALL; /* call us when you're done */ - rqe->b.b_iodone = complete_rqe; /* by calling us here */ + rqe->b.b_flags &= ~B_DONE; /* we're writing now */ + rqe->b.b_iodone = complete_rqe; /* call us here when done */ rqe->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqe->b.b_data = &bp->b_data[rqe->useroffset << DEV_BSHIFT]; /* point to the user data */ rqe->b.b_bcount = rqe->datalen << DEV_BSHIFT; /* length to write */ @@ -365,7 +364,7 @@ complete_raid5_write(struct rqelement *rqe) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", - rqe->b.b_flags & B_READ ? "Read" : "Write", + rqe->b.b_iocmd == BIO_READ ? "Read" : "Write", major(rqe->b.b_dev), minor(rqe->b.b_dev), rqe->sdno, @@ -382,9 +381,8 @@ complete_raid5_write(struct rqelement *rqe) } /* Finally, write the parity block */ rqe = &rqg->rqe[0]; - rqe->b.b_flags &= ~(B_READ | B_DONE); /* we're writing now */ - rqe->b.b_flags |= B_CALL; /* call us when you're done */ - rqe->b.b_iodone = complete_rqe; /* by calling us here */ + rqe->b.b_flags &= ~B_DONE; /* we're writing now */ + rqe->b.b_iodone = complete_rqe; /* call us here when done */ rqg->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqe->b.b_bcount = rqe->buflen << DEV_BSHIFT; /* length to write */ rqe->b.b_bufsize = rqe->b.b_bcount; /* don't claim we have more */ @@ -404,7 +402,7 @@ complete_raid5_write(struct rqelement *rqe) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", - rqe->b.b_flags & B_READ ? "Read" : "Write", + rqe->b.b_iocmd == BIO_READ ? "Read" : "Write", major(rqe->b.b_dev), minor(rqe->b.b_dev), rqe->sdno, diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c index 17fc5fe..8913d66 100644 --- a/sys/dev/vinum/vinumio.c +++ b/sys/dev/vinum/vinumio.c @@ -297,7 +297,8 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag) int len = min(length, MAXBSIZE); /* maximum block device transfer is MAXBSIZE */ bp = geteblk(len); /* get a buffer header */ - bp->b_flags = flag; + bp->b_flags = 0; + bp->b_iocmd = flag; bp->b_dev = drive->dev; /* device */ bp->b_blkno = offset / drive->partinfo.disklab->d_secsize; /* block number */ bp->b_saveaddr = bp->b_data; @@ -754,7 +755,7 @@ write_volume_label(int volno) dlp = (struct disklabel *) bp->b_data; *dlp = *lp; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_WRITE; + bp->b_iocmd = BIO_WRITE; /* * This should read: diff --git a/sys/dev/vinum/vinumraid5.c b/sys/dev/vinum/vinumraid5.c index 2c44d71..5596814 100644 --- a/sys/dev/vinum/vinumraid5.c +++ b/sys/dev/vinum/vinumraid5.c @@ -360,7 +360,7 @@ bre5(struct request *rq, } if (SD[plex->sdnos[m.psdno]].state < sd_reborn) /* is our parity subdisk down? */ m.badsdno = m.psdno; /* note that it's down */ - if (bp->b_flags & B_READ) { /* read operation */ + if (bp->b_iocmd == BIO_READ) { /* read operation */ for (mysdno = m.firstsdno; rsectors > 0; mysdno++) { if (mysdno == m.psdno) /* ignore parity on read */ mysdno++; @@ -493,7 +493,7 @@ bre5(struct request *rq, rqe->driveno = sd->driveno; if (build_rq_buffer(rqe, plex)) /* build the buffer */ return REQUEST_ENOMEM; /* can't do it */ - rqe->b.b_flags |= B_READ; /* we must read first */ + rqe->b.b_iocmd == BIO_READ; /* we must read first */ m.sdcount++; /* adjust the subdisk count */ rqno++; /* and point to the next request */ } @@ -534,7 +534,7 @@ bre5(struct request *rq, return REQUEST_ENOMEM; /* can't do it */ if ((m.flags & XFR_PARITYOP) /* parity operation, */ &&((m.flags & XFR_BAD_SUBDISK) == 0)) /* and not the bad subdisk, */ - rqe->b.b_flags |= B_READ; /* we must read first */ + rqe->b.b_iocmd = BIO_READ; /* we must read first */ /* Now update pointers for the next block */ *diskaddr += m.datalen; /* skip past what we've done */ @@ -577,7 +577,7 @@ bre5(struct request *rq, rqe->driveno = sd->driveno; if (build_rq_buffer(rqe, plex)) /* build the buffer */ return REQUEST_ENOMEM; /* can't do it */ - rqe->b.b_flags |= B_READ; /* we must read first */ + rqe->b.b_iocmd = BIO_READ; /* we must read first */ } } /* diff --git a/sys/dev/vinum/vinumrequest.c b/sys/dev/vinum/vinumrequest.c index da7bff4..98c7892 100644 --- a/sys/dev/vinum/vinumrequest.c +++ b/sys/dev/vinum/vinumrequest.c @@ -224,7 +224,7 @@ vinumstart(struct buf *bp, int reviveok) maxplex = 1; /* just the one plex */ } - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { /* * This is a read request. Decide * which plex to read from. @@ -337,7 +337,7 @@ launch_requests(struct request *rq, int reviveok) "Revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%x, length %ld\n", rq->sdno, rq, - rq->bp->b_flags & B_READ ? "Read" : "Write", + rq->bp->b_iocmd == BIO_READ ? "Read" : "Write", major(rq->bp->b_dev), minor(rq->bp->b_dev), rq->bp->b_blkno, @@ -351,7 +351,7 @@ launch_requests(struct request *rq, int reviveok) log(LOG_DEBUG, "Request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n", rq, - rq->bp->b_flags & B_READ ? "Read" : "Write", + rq->bp->b_iocmd == BIO_READ ? "Read" : "Write", major(rq->bp->b_dev), minor(rq->bp->b_dev), rq->bp->b_blkno, @@ -406,7 +406,7 @@ launch_requests(struct request *rq, int reviveok) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", - rqe->b.b_flags & B_READ ? "Read" : "Write", + rqe->b.b_iocmd == BIO_READ ? "Read" : "Write", major(rqe->b.b_dev), minor(rqe->b.b_dev), rqe->sdno, @@ -505,7 +505,7 @@ bre(struct request *rq, s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */ if (s == REQUEST_DOWN) { /* down? */ rqe->flags = XFR_BAD_SUBDISK; /* yup */ - if (rq->bp->b_flags & B_READ) /* read request, */ + if (rq->bp->b_iocmd == BIO_READ) /* read request, */ return REQUEST_DEGRADED; /* give up here */ /* * If we're writing, don't give up @@ -589,7 +589,7 @@ bre(struct request *rq, s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */ if (s == REQUEST_DOWN) { /* down? */ rqe->flags = XFR_BAD_SUBDISK; /* yup */ - if (rq->bp->b_flags & B_READ) /* read request, */ + if (rq->bp->b_iocmd == BIO_READ) /* read request, */ return REQUEST_DEGRADED; /* give up here */ /* * If we're writing, don't give up @@ -791,8 +791,8 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex) /* Initialize the buf struct */ /* copy these flags from user bp */ - bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_READ | B_ASYNC); - bp->b_flags |= B_CALL; /* inform us when it's done */ + bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_ASYNC); + bp->b_iocmd = BIO_READ; /* inform us when it's done */ BUF_LOCKINIT(bp); /* get a lock for the buffer */ BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */ @@ -891,9 +891,9 @@ sdio(struct buf *bp) if (drive->state != drive_up) { if (sd->state >= sd_crashed) { - if (bp->b_flags & B_READ) /* reading, */ + if (bp->b_iocmd == BIO_READ) /* reading, */ set_sd_state(sd->sdno, sd_crashed, setstate_force); - else + else if (bp->b_iocmd == BIO_WRITE) /* writing, */ set_sd_state(sd->sdno, sd_stale, setstate_force); } bp->b_flags |= B_ERROR; @@ -920,7 +920,7 @@ sdio(struct buf *bp) return; } bzero(sbp, sizeof(struct sdbuf)); /* start with nothing */ - sbp->b.b_flags = bp->b_flags | B_CALL; /* inform us when it's done */ + sbp->b.b_flags = bp->b_flags; sbp->b.b_bufsize = bp->b_bufsize; /* buffer size */ sbp->b.b_bcount = bp->b_bcount; /* number of bytes to transfer */ sbp->b.b_resid = bp->b_resid; /* and amount waiting */ @@ -947,7 +947,7 @@ sdio(struct buf *bp) if (debug & DEBUG_ADDRESSES) log(LOG_DEBUG, " %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", - sbp->b.b_flags & B_READ ? "Read" : "Write", + sbp->b.b_iocmd == BIO_READ ? "Read" : "Write", major(sbp->b.b_dev), minor(sbp->b.b_dev), sbp->sdno, @@ -992,7 +992,7 @@ vinum_bounds_check(struct buf *bp, struct volume *vol) && bp->b_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_iocmd == BIO_WRITE) /* and it's a write */ && (!vol->flags & (VF_WLABEL | VF_LABELLING))) { /* and we're not allowed to write the label */ bp->b_error = EROFS; /* read-only */ bp->b_flags |= B_ERROR; diff --git a/sys/dev/vinum/vinumrevive.c b/sys/dev/vinum/vinumrevive.c index bfa1c9a..3204512 100644 --- a/sys/dev/vinum/vinumrevive.c +++ b/sys/dev/vinum/vinumrevive.c @@ -170,7 +170,8 @@ revive_block(int sdno) else /* it's an unattached plex */ bp->b_dev = VINUM_PLEX(sd->plexno); /* create the device number */ - bp->b_flags = B_READ; /* either way, read it */ + bp->b_flags = 0; /* either way, read it */ + bp->b_iocmd = BIO_READ; /* either way, read it */ vinumstart(bp, 1); biowait(bp); } @@ -181,7 +182,8 @@ revive_block(int sdno) /* Now write to the subdisk */ { bp->b_dev = VINUM_SD(sdno); /* create the device number */ - bp->b_flags = B_ORDERED | B_WRITE; /* and make this an ordered write */ + bp->b_flags = B_ORDERED; /* and make this an ordered write */ + bp->b_iocmd = BIO_WRITE; /* and make this an ordered write */ BUF_LOCKINIT(bp); /* get a lock for the buffer */ BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */ bp->b_resid = bp->b_bcount; @@ -211,7 +213,7 @@ revive_block(int sdno) "Relaunch revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%x, length %ld\n", rq->sdno, rq, - rq->bp->b_flags & B_READ ? "Read" : "Write", + rq->bp->b_flags == BIO_READ ? "Read" : "Write", major(rq->bp->b_dev), minor(rq->bp->b_dev), rq->bp->b_blkno, @@ -310,8 +312,7 @@ parityops(struct vinum_ioctl_msg *data, enum parityop op) } } } else { /* rebuildparity */ - pbp->b_flags &= ~B_READ; - pbp->b_flags |= B_WRITE; + pbp->b_iocmd = BIO_WRITE; pbp->b_resid = pbp->b_bcount; BUF_LOCKINIT(pbp); /* get a lock for the buffer */ BUF_LOCK(pbp, LK_EXCLUSIVE); /* and lock it */ @@ -404,7 +405,8 @@ parityrebuild(struct plex *plex, bzero(parity_buf, mysize); } bpp[sdno]->b_dev = VINUM_SD(plex->sdnos[sdno]); /* device number */ - bpp[sdno]->b_flags = B_READ; /* either way, read it */ + bpp[sdno]->b_flags = 0; /* either way, read it */ + bpp[sdno]->b_iocmd = BIO_READ; /* either way, read it */ bpp[sdno]->b_bcount = bpp[sdno]->b_bufsize; bpp[sdno]->b_resid = bpp[sdno]->b_bcount; bpp[sdno]->b_blkno = pstripe; /* read from here */ @@ -557,7 +559,7 @@ initsd(int sdno, int verify) bp->b_resid = bp->b_bcount; bp->b_blkno = sd->initialized; /* read from here */ bp->b_dev = VINUM_SD(sdno); /* create the device number */ - bp->b_flags |= B_READ; /* read it back */ + bp->b_iocmd = BIO_READ; /* read it back */ splx(s); BUF_LOCKINIT(bp); /* get a lock for the buffer */ BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */ diff --git a/sys/dev/vinum/vinumstate.c b/sys/dev/vinum/vinumstate.c index 3ed347f..318e040 100644 --- a/sys/dev/vinum/vinumstate.c +++ b/sys/dev/vinum/vinumstate.c @@ -617,7 +617,7 @@ enum requeststatus checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend) { struct plex *plex = &PLEX[sd->plexno]; - int writeop = (rq->bp->b_flags & B_READ) == 0; /* note if we're writing */ + int writeop = (rq->bp->b_iocmd == BIO_WRITE); /* note if we're writing */ switch (sd->state) { /* We shouldn't get called if the subdisk is up */ diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c index 49fa104..ba0caad 100644 --- a/sys/dev/vn/vn.c +++ b/sys/dev/vn/vn.c @@ -101,7 +101,7 @@ static d_strategy_t vnstrategy; /* * cdevsw * D_DISK we want to look like a disk - * D_CANFREE We support B_FREEBUF + * D_CANFREE We support BIO_DELETE */ static struct cdevsw vn_cdevsw = { @@ -286,7 +286,7 @@ vnstrategy(struct buf *bp) unit = dkunit(bp->b_dev); vn = bp->b_dev->si_drv1; - if (!vn) + if (vn == NULL) vn = vnfindvn(bp->b_dev); IFOPT(vn, VN_DEBUG) @@ -349,7 +349,7 @@ vnstrategy(struct buf *bp) bp->b_pblkno = pbn; } - if (vn->sc_vp && (bp->b_flags & B_FREEBUF)) { + if (vn->sc_vp && (bp->b_iocmd == BIO_DELETE)) { /* * Not handled for vnode-backed element yet. */ @@ -368,7 +368,7 @@ vnstrategy(struct buf *bp) auio.uio_iovcnt = 1; auio.uio_offset = (vm_ooffset_t)bp->b_pblkno * vn->sc_secsize; auio.uio_segflg = UIO_SYSSPACE; - if( bp->b_flags & B_READ) + if(bp->b_iocmd == BIO_READ) auio.uio_rw = UIO_READ; else auio.uio_rw = UIO_WRITE; @@ -378,7 +378,7 @@ vnstrategy(struct buf *bp) isvplocked = 1; vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc); } - if( bp->b_flags & B_READ) + if(bp->b_iocmd == BIO_READ) error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred); else error = VOP_WRITE(vn->sc_vp, &auio, 0, vn->sc_cred); @@ -399,12 +399,12 @@ vnstrategy(struct buf *bp) * * ( handles read, write, freebuf ) * - * Note: if we pre-reserved swap, B_FREEBUF is disabled + * Note: if we pre-reserved swap, BIO_DELETE is disabled */ 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_iocmd == BIO_DELETE) && TESTOPT(vn, VN_RESERVE)) { biodone(bp); } else { vm_pager_strategy(vn->sc_object, bp); diff --git a/sys/fs/ntfs/ntfs_vnops.c b/sys/fs/ntfs/ntfs_vnops.c index 381cb8f..a47cf56f 100644 --- a/sys/fs/ntfs/ntfs_vnops.c +++ b/sys/fs/ntfs/ntfs_vnops.c @@ -345,7 +345,7 @@ ntfs_strategy(ap) dprintf(("strategy: bcount: %d flags: 0x%lx\n", (u_int32_t)bp->b_bcount,bp->b_flags)); - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { u_int32_t toread; if (ntfs_cntob(bp->b_blkno) >= fp->f_size) { diff --git a/sys/fs/nwfs/nwfs_io.c b/sys/fs/nwfs/nwfs_io.c index d634cbc..6f7a6c8 100644 --- a/sys/fs/nwfs/nwfs_io.c +++ b/sys/fs/nwfs/nwfs_io.c @@ -275,7 +275,7 @@ nwfs_doio(bp, cr, p) uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = p; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; diff --git a/sys/fs/nwfs/nwfs_vnops.c b/sys/fs/nwfs/nwfs_vnops.c index 22df1b3..c8e8b67 100644 --- a/sys/fs/nwfs/nwfs_vnops.c +++ b/sys/fs/nwfs/nwfs_vnops.c @@ -812,7 +812,7 @@ static int nwfs_strategy (ap) p = (struct proc *)0; else p = curproc; /* XXX */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; else cr = bp->b_wcred; diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c index a9a711e..f48c0c1 100644 --- a/sys/fs/specfs/spec_vnops.c +++ b/sys/fs/specfs/spec_vnops.c @@ -407,7 +407,7 @@ spec_strategy(ap) struct mount *mp; bp = ap->a_bp; - if (((bp->b_flags & B_READ) == 0) && + if ((bp->b_iocmd == BIO_WRITE) && (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) (*bioops.io_start)(bp); @@ -417,7 +417,7 @@ spec_strategy(ap) */ vp = ap->a_vp; if (vn_isdisk(vp, NULL) && (mp = vp->v_specmountpoint) != NULL) { - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_iocmd == BIO_WRITE) { if (bp->b_lock.lk_lockholder == LK_KERNPROC) mp->mnt_stat.f_asyncwrites++; else @@ -458,7 +458,7 @@ spec_freeblks(ap) if ((bsw->d_flags & D_CANFREE) == 0) return (0); bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF; + bp->b_iocmd = BIO_DELETE; bp->b_dev = ap->a_vp->v_rdev; bp->b_blkno = ap->a_addr; bp->b_offset = dbtob(ap->a_addr); @@ -657,7 +657,7 @@ spec_getpages(ap) pmap_qenter(kva, ap->a_m, pcount); /* Build a minimal buffer header. */ - bp->b_flags = B_READ | B_CALL; + bp->b_iocmd = BIO_READ; bp->b_iodone = spec_getpages_iodone; /* B_PHYS is not set, but it is nice to fill this in. */ diff --git a/sys/fs/unionfs/union_vnops.c b/sys/fs/unionfs/union_vnops.c index 03d41a0..38c190b 100644 --- a/sys/fs/unionfs/union_vnops.c +++ b/sys/fs/unionfs/union_vnops.c @@ -1923,7 +1923,7 @@ union_strategy(ap) #ifdef DIAGNOSTIC if (othervp == NULLVP) panic("union_strategy: nil vp"); - if (((bp->b_flags & B_READ) == 0) && + if ((bp->b_iocmd == BIO_WRITE) && (othervp == LOWERVP(bp->b_vp))) panic("union_strategy: writing to lowervp"); #endif diff --git a/sys/geom/geom_ccd.c b/sys/geom/geom_ccd.c index 672ffe2..fe45b6e 100644 --- a/sys/geom/geom_ccd.c +++ b/sys/geom/geom_ccd.c @@ -193,7 +193,7 @@ static void ccdattach __P((void)); static int ccd_modevent __P((module_t, int, void *)); /* called by biodone() at interrupt time */ -static void ccdiodone __P((struct ccdbuf *cbp)); +static void ccdiodone __P((struct buf *bp)); static void ccdstart __P((struct ccd_softc *, struct buf *)); static void ccdinterleave __P((struct ccd_softc *, int)); @@ -887,7 +887,7 @@ ccdstart(cs, bp) * 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_iocmd == BIO_WRITE) { cbp[0]->cb_buf.b_vp->v_numoutput++; cbp[1]->cb_buf.b_vp->v_numoutput++; VOP_STRATEGY(cbp[0]->cb_buf.b_vp, @@ -911,7 +911,7 @@ ccdstart(cs, bp) /* * Not mirroring */ - if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) + if (cbp[0]->cb_buf.b_iocmd == BIO_WRITE) cbp[0]->cb_buf.b_vp->v_numoutput++; VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf); } @@ -1050,8 +1050,9 @@ ccdbuffer(cb, cs, bp, bn, addr, bcount) * Fill in the component buf structure. */ cbp = getccdbuf(NULL); - cbp->cb_buf.b_flags = bp->b_flags | B_CALL; - cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone; + cbp->cb_buf.b_flags = bp->b_flags; + cbp->cb_buf.b_iocmd = bp->b_iocmd; + cbp->cb_buf.b_iodone = ccdiodone; cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */ cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET; cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET); @@ -1122,9 +1123,10 @@ ccdintr(cs, bp) * take a ccd interrupt. */ static void -ccdiodone(cbp) - struct ccdbuf *cbp; +ccdiodone(ibp) + struct buf *ibp; { + struct ccdbuf *cbp = (struct ccdbuf *)ibp; struct buf *bp = cbp->cb_obp; int unit = cbp->cb_unit; int count, s; @@ -1153,7 +1155,7 @@ ccdiodone(cbp) const char *msg = ""; if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) && - (cbp->cb_buf.b_flags & B_READ) && + (cbp->cb_buf.b_iocmd == BIO_READ) && (cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) { /* * We will try our read on the other disk down @@ -1186,7 +1188,7 @@ ccdiodone(cbp) */ if (ccd_softc[unit].sc_cflags & CCDF_MIRROR) { - if ((cbp->cb_buf.b_flags & B_READ) == 0) { + if (cbp->cb_buf.b_iocmd == BIO_WRITE) { /* * When writing, handshake with the second buffer * to determine when both are done. If both are not diff --git a/sys/gnu/ext2fs/ext2_bmap.c b/sys/gnu/ext2fs/ext2_bmap.c index 57cef46..ab5ebb5 100644 --- a/sys/gnu/ext2fs/ext2_bmap.c +++ b/sys/gnu/ext2fs/ext2_bmap.c @@ -192,7 +192,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) panic("ufs_bmaparray: indirect block not in cache"); #endif bp->b_blkno = blkptrtodb(ump, daddr); - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); vfs_busy_pages(bp, 0); VOP_STRATEGY(bp->b_vp, bp); diff --git a/sys/gnu/ext2fs/ext2_inode.c b/sys/gnu/ext2fs/ext2_inode.c index 657f699..22847f5 100644 --- a/sys/gnu/ext2fs/ext2_inode.c +++ b/sys/gnu/ext2fs/ext2_inode.c @@ -37,6 +37,8 @@ * SUCH DAMAGE. * * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93 + * + * $FreeBSD$ */ #include "opt_quota.h" @@ -416,7 +418,7 @@ ext2_indirtrunc(ip, lbn, dbn, lastbn, level, countp) bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0); if (bp->b_flags & (B_DONE | B_DELWRI)) { } else { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; if (bp->b_bcount > bp->b_bufsize) panic("ext2_indirtrunc: bad buffer size"); bp->b_blkno = dbn; diff --git a/sys/gnu/fs/ext2fs/ext2_bmap.c b/sys/gnu/fs/ext2fs/ext2_bmap.c index 57cef46..ab5ebb5 100644 --- a/sys/gnu/fs/ext2fs/ext2_bmap.c +++ b/sys/gnu/fs/ext2fs/ext2_bmap.c @@ -192,7 +192,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) panic("ufs_bmaparray: indirect block not in cache"); #endif bp->b_blkno = blkptrtodb(ump, daddr); - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); vfs_busy_pages(bp, 0); VOP_STRATEGY(bp->b_vp, bp); diff --git a/sys/gnu/fs/ext2fs/ext2_inode.c b/sys/gnu/fs/ext2fs/ext2_inode.c index 657f699..22847f5 100644 --- a/sys/gnu/fs/ext2fs/ext2_inode.c +++ b/sys/gnu/fs/ext2fs/ext2_inode.c @@ -37,6 +37,8 @@ * SUCH DAMAGE. * * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93 + * + * $FreeBSD$ */ #include "opt_quota.h" @@ -416,7 +418,7 @@ ext2_indirtrunc(ip, lbn, dbn, lastbn, level, countp) bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0); if (bp->b_flags & (B_DONE | B_DELWRI)) { } else { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; if (bp->b_bcount > bp->b_bufsize) panic("ext2_indirtrunc: bad buffer size"); bp->b_blkno = dbn; diff --git a/sys/i386/i386/genassym.c b/sys/i386/i386/genassym.c index 3e843db..2303982 100644 --- a/sys/i386/i386/genassym.c +++ b/sys/i386/i386/genassym.c @@ -153,7 +153,6 @@ ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs)); ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); -ASSYM(B_READ, B_READ); ASSYM(ENOENT, ENOENT); ASSYM(EFAULT, EFAULT); ASSYM(ENAMETOOLONG, ENAMETOOLONG); diff --git a/sys/i386/i386/machdep.c b/sys/i386/i386/machdep.c index c204fbe..bc6dc89 100644 --- a/sys/i386/i386/machdep.c +++ b/sys/i386/i386/machdep.c @@ -2360,7 +2360,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if LABELSECTOR != 0 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -2368,7 +2368,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/i386/i386/vm_machdep.c b/sys/i386/i386/vm_machdep.c index cdcc278..9f5d6c0 100644 --- a/sys/i386/i386/vm_machdep.c +++ b/sys/i386/i386/vm_machdep.c @@ -357,7 +357,7 @@ vmapbuf(bp) * when reading stuff off device into memory. */ vm_fault_quick(addr, - (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); pa = trunc_page(pmap_kextract((vm_offset_t) addr)); if (pa == 0) panic("vmapbuf: page not present"); diff --git a/sys/i386/isa/labpc.c b/sys/i386/isa/labpc.c index 54d7dca..27c0555 100644 --- a/sys/i386/isa/labpc.c +++ b/sys/i386/isa/labpc.c @@ -992,7 +992,7 @@ labpcstrategy(struct buf *bp) struct ctlr *ctlr = labpcs[UNIT(bp->b_dev)]; if (DIGITAL(bp->b_dev)) { - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { ctlr->starter = null_start; ctlr->stop = all_stop; ctlr->intr = null_intr; @@ -1007,7 +1007,7 @@ labpcstrategy(struct buf *bp) } } else { - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { ctlr->starter = INTERVAL(ctlr->dev) ? ad_interval_start : ad_start; ctlr->stop = all_stop; diff --git a/sys/i386/isa/matcd/matcd.c b/sys/i386/isa/matcd/matcd.c index f0ec9e7..0d14e1e 100644 --- a/sys/i386/isa/matcd/matcd.c +++ b/sys/i386/isa/matcd/matcd.c @@ -876,7 +876,7 @@ void matcdstrategy(struct buf *bp) goto bad; } - if (!(bp->b_flags & B_READ)) { + if (!(bp->b_iocmd == BIO_READ)) { bp->b_error = EROFS; goto bad; } diff --git a/sys/i386/isa/mcd.c b/sys/i386/isa/mcd.c index 923ec0f..8b41449 100644 --- a/sys/i386/isa/mcd.c +++ b/sys/i386/isa/mcd.c @@ -414,7 +414,7 @@ MCD_TRACE("strategy: drive not valid\n"); } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (!(bp->b_iocmd == BIO_READ)) { bp->b_error = EROFS; goto bad; } diff --git a/sys/i386/isa/scd.c b/sys/i386/isa/scd.c index b6e9460..836dbc9 100644 --- a/sys/i386/isa/scd.c +++ b/sys/i386/isa/scd.c @@ -337,7 +337,7 @@ scdstrategy(struct buf *bp) } /* read only */ - if (!(bp->b_flags & B_READ)) { + if (!(bp->b_iocmd == BIO_READ)) { bp->b_error = EROFS; goto bad; } diff --git a/sys/i386/isa/wd.c b/sys/i386/isa/wd.c index 160bd2a..1281f7b 100644 --- a/sys/i386/isa/wd.c +++ b/sys/i386/isa/wd.c @@ -700,7 +700,7 @@ wdstart(int ctrlr) #ifdef WDDEBUG if (du->dk_skip == 0) printf("wd%d: wdstart: %s %d@%d; map ", lunit, - (bp->b_flags & B_READ) ? "read" : "write", + (bp->b_iocmd == BIO_READ) ? "read" : "write", bp->b_bcount, blknum); else printf(" %d)%x", du->dk_skip, inb(du->dk_altport)); @@ -734,7 +734,7 @@ wdstart(int ctrlr) * XXX this looks like an attempt to skip bad sectors * on write. */ - if (wdtab[ctrlr].b_errcnt && (bp->b_flags & B_READ) == 0) + if (wdtab[ctrlr].b_errcnt && (bp->b_iocmd == BIO_WRITE)) du->dk_bc += DEV_BSIZE; count1 = howmany( du->dk_bc, DEV_BSIZE); @@ -742,7 +742,7 @@ wdstart(int ctrlr) du->dk_flags &= ~DKFL_MULTI; if (du->dk_flags & DKFL_SINGLE) { - command = (bp->b_flags & B_READ) + command = (bp->b_iocmd == BIO_READ) ? WDCC_READ : WDCC_WRITE; count1 = 1; du->dk_currentiosize = 1; @@ -752,16 +752,16 @@ wdstart(int ctrlr) (void *)((int)bp->b_data + du->dk_skip * DEV_BSIZE), du->dk_bc, - bp->b_flags & B_READ)) { + bp->b_iocmd == BIO_READ)) { du->dk_flags |= DKFL_DMA; - if( bp->b_flags & B_READ) + if(bp->b_iocmd == BIO_READ) command = WDCC_READ_DMA; else command = WDCC_WRITE_DMA; du->dk_currentiosize = count1; } else if( (count1 > 1) && (du->dk_multi > 1)) { du->dk_flags |= DKFL_MULTI; - if( bp->b_flags & B_READ) { + if(bp->b_iocmd == BIO_READ) { command = WDCC_READ_MULTI; } else { command = WDCC_WRITE_MULTI; @@ -770,7 +770,7 @@ wdstart(int ctrlr) if( du->dk_currentiosize > count1) du->dk_currentiosize = count1; } else { - if( bp->b_flags & B_READ) { + if(bp->b_iocmd == BIO_READ) { command = WDCC_READ; } else { command = WDCC_WRITE; @@ -797,7 +797,7 @@ wdstart(int ctrlr) (void *)((int)bp->b_data + du->dk_skip * DEV_BSIZE), du->dk_bc, - bp->b_flags & B_READ); + bp->b_iocmd == BIO_READ); } while (wdcommand(du, cylin, head, sector, count1, command) != 0) { @@ -842,7 +842,7 @@ wdstart(int ctrlr) } /* If this is a read operation, just go away until it's done. */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) return; /* Ready to send data? */ @@ -1010,7 +1010,7 @@ oops: /* * If this was a successful read operation, fetch the data. */ - if (((bp->b_flags & (B_READ | B_ERROR)) == B_READ) + if ((bp->b_iocmd == BIO_READ && !(bp->b_flags & B_ERROR)) && !((du->dk_flags & (DKFL_DMA|DKFL_SINGLE)) == DKFL_DMA) && wdtab[unit].b_active) { u_int chk, dummy, multisize; @@ -1074,7 +1074,7 @@ outt: /* see if more to transfer */ if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) { if( (du->dk_flags & DKFL_SINGLE) || - ((bp->b_flags & B_READ) == 0)) { + (bp->b_iocmd == BIO_WRITE)) { wdtab[unit].b_active = 0; wdstart(unit); } else { diff --git a/sys/i386/isa/wt.c b/sys/i386/isa/wt.c index 1a1c691..b601b5b 100644 --- a/sys/i386/isa/wt.c +++ b/sys/i386/isa/wt.c @@ -527,7 +527,7 @@ wtstrategy (struct buf *bp) goto err2xit; } - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { /* Check read access and no previous write to this tape. */ if (! (t->flags & TPREAD) || (t->flags & TPWANY)) goto errxit; @@ -566,8 +566,9 @@ wtstrategy (struct buf *bp) t->flags &= ~TPEXCEP; s = splbio (); - 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, bp->b_iocmd == BIO_READ ? ISADMA_READ : ISADMA_WRITE, + bp->b_data, bp->b_bcount)) { + wtwait (t, 0, (bp->b_iocmd == BIO_READ) ? "wtread" : "wtwrite"); bp->b_resid -= t->dmacount; } splx (s); diff --git a/sys/isa/fd.c b/sys/isa/fd.c index 7c96092..4048c7f 100644 --- a/sys/isa/fd.c +++ b/sys/isa/fd.c @@ -1620,7 +1620,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count) { u_char *cptr = (u_char *)addr; - if (flags & B_READ) { + if (flags == BIO_READ) { if (fdc->state != PIOREAD) { fdc->state = PIOREAD; return(0); @@ -1679,7 +1679,7 @@ fdstate(fdc_p fdc) fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); - read = bp->b_flags & B_READ; + read = bp->b_iocmd == BIO_READ; format = bp->b_flags & B_FORMAT; if (format) { finfo = (struct fd_formb *)bp->b_data; @@ -1885,7 +1885,7 @@ fdstate(fdc_p fdc) */ SET_BCDR(fdc, 1, bp->b_bcount, 0); - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, bp->b_bcount); @@ -1918,7 +1918,7 @@ fdstate(fdc_p fdc) * the WRITE command is sent */ if (!read) - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, fdblk); } @@ -1948,7 +1948,7 @@ fdstate(fdc_p fdc) * if this is a read, then simply await interrupt * before performing PIO */ - if (read && !fdcpio(fdc,bp->b_flags, + if (read && !fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip,fdblk)) { fd->tohandle = timeout(fd_iotimeout, fdc, hz); return(0); /* will return later */ @@ -1966,7 +1966,7 @@ fdstate(fdc_p fdc) * actually perform the PIO read. The IOCOMPLETE case * removes the timeout for us. */ - (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk); + (void)fdcpio(fdc,bp->b_iocmd,bp->b_data+fd->skip,fdblk); fdc->state = IOCOMPLETE; /* FALLTHROUGH */ case IOCOMPLETE: /* IO DONE, post-analyze */ diff --git a/sys/kern/kern_physio.c b/sys/kern/kern_physio.c index 128283f..1510bf1 100644 --- a/sys/kern/kern_physio.c +++ b/sys/kern/kern_physio.c @@ -33,7 +33,6 @@ static void physwakeup(struct buf *bp) { wakeup((caddr_t) bp); - bp->b_flags &= ~B_CALL; } int @@ -63,10 +62,11 @@ physio(dev_t dev, struct uio *uio, int ioflag) for (i = 0; i < uio->uio_iovcnt; i++) { while (uio->uio_iov[i].iov_len) { + bp->b_flags = B_PHYS; if (uio->uio_rw == UIO_READ) - bp->b_flags = B_PHYS | B_CALL | B_READ; + bp->b_iocmd = BIO_READ; else - bp->b_flags = B_PHYS | B_CALL | B_WRITE; + bp->b_iocmd = BIO_WRITE; bp->b_dev = dev; bp->b_iodone = physwakeup; bp->b_data = uio->uio_iov[i].iov_base; @@ -101,7 +101,7 @@ physio(dev_t dev, struct uio *uio, int ioflag) if (uio->uio_segflg == UIO_USERSPACE) { if (!useracc(bp->b_data, bp->b_bufsize, - bp->b_flags & B_READ ? + bp->b_iocmd == BIO_READ ? VM_PROT_WRITE : VM_PROT_READ)) { error = EFAULT; goto doerror; diff --git a/sys/kern/subr_devstat.c b/sys/kern/subr_devstat.c index b04662b..7ebc257 100644 --- a/sys/kern/subr_devstat.c +++ b/sys/kern/subr_devstat.c @@ -233,9 +233,9 @@ devstat_end_transaction_buf(struct devstat *ds, struct buf *bp) { devstat_trans_flags flg; - if (bp->b_flags & B_FREEBUF) + if (bp->b_iocmd == BIO_DELETE) flg = DEVSTAT_FREE; - else if (bp->b_flags & B_READ) + else if (bp->b_iocmd == BIO_READ) flg = DEVSTAT_READ; else flg = DEVSTAT_WRITE; diff --git a/sys/kern/subr_disklabel.c b/sys/kern/subr_disklabel.c index 9184f2f..ff72629 100644 --- a/sys/kern/subr_disklabel.c +++ b/sys/kern/subr_disklabel.c @@ -181,7 +181,7 @@ readdisklabel(dev, lp) bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_bcount = lp->d_secsize; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); if (biowait(bp)) msg = "I/O error"; @@ -284,7 +284,7 @@ writedisklabel(dev, lp) * (also stupid.. how do you write the first one? by raw writes?) */ bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); error = biowait(bp); if (error) @@ -296,8 +296,8 @@ writedisklabel(dev, lp) if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && dkcksum(dlp) == 0) { *dlp = *lp; - bp->b_flags &= ~(B_DONE | B_READ); - bp->b_flags |= B_WRITE; + bp->b_flags &= ~B_DONE; + bp->b_iocmd = BIO_WRITE; #ifdef __alpha__ alpha_fix_srm_checksum(bp); #endif @@ -313,7 +313,7 @@ done: dlp = (struct disklabel *)bp->b_data; *dlp = *lp; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_WRITE; + bp->b_iocmd = BIO_WRITE; BUF_STRATEGY(bp, 1); error = biowait(bp); #endif @@ -375,7 +375,7 @@ diskerr(bp, what, pri, blkdone, lp) pr = printf; sname = dsname(bp->b_dev, unit, slice, part, partname); (*pr)("%s%s: %s %sing fsbn ", sname, partname, what, - bp->b_flags & B_READ ? "read" : "writ"); + bp->b_iocmd == BIO_READ ? "read" : "writ"); sn = bp->b_blkno; if (bp->b_bcount <= DEV_BSIZE) (*pr)("%ld", (long)sn); diff --git a/sys/kern/subr_diskmbr.c b/sys/kern/subr_diskmbr.c index c16f5d7..9802d9f 100644 --- a/sys/kern/subr_diskmbr.c +++ b/sys/kern/subr_diskmbr.c @@ -187,7 +187,7 @@ reread_mbr: bp->b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART); bp->b_blkno = mbr_offset; bp->b_bcount = lp->d_secsize; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); if (biowait(bp) != 0) { diskerr(bp, "reading primary partition table: error", @@ -403,7 +403,7 @@ mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors, bp->b_dev = dev; bp->b_blkno = ext_offset; bp->b_bcount = lp->d_secsize; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); if (biowait(bp) != 0) { diskerr(bp, "reading extended partition table: error", diff --git a/sys/kern/subr_diskslice.c b/sys/kern/subr_diskslice.c index e42488e..73f735e 100644 --- a/sys/kern/subr_diskslice.c +++ b/sys/kern/subr_diskslice.c @@ -208,14 +208,14 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); #if LABELSECTOR != 0 slicerel_secno + nsec > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && sp->ds_wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && 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_iocmd == BIO_WRITE) && sp->ds_wlabel == 0) { bp->b_error = EROFS; goto bad; @@ -259,10 +259,9 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()"); ic->ic_args[0].ia_long = (LABELSECTOR + labelsect - slicerel_secno) * ssp->dss_secsize; ic->ic_args[1].ia_ptr = sp; - bp->b_flags |= B_CALL; bp->b_iodone = dsiodone; bp->b_iodone_chain = ic; - if (!(bp->b_flags & B_READ)) { + if (!(bp->b_iocmd == BIO_READ)) { /* * XXX even disklabel(8) writes directly so we need * to adjust writes. Perhaps we should drop support @@ -537,11 +536,10 @@ dsiodone(bp) char *msg; ic = bp->b_iodone_chain; - bp->b_flags = (ic->ic_prev_flags & B_CALL) - | (bp->b_flags & ~(B_CALL | B_DONE)); + bp->b_flags = bp->b_flags & ~B_DONE; bp->b_iodone = ic->ic_prev_iodone; bp->b_iodone_chain = ic->ic_prev_iodone_chain; - if (!(bp->b_flags & B_READ) + if (!(bp->b_iocmd == BIO_READ) || (!(bp->b_flags & B_ERROR) && bp->b_error == 0)) { msg = fixlabel((char *)NULL, ic->ic_args[1].ia_ptr, (struct disklabel *) diff --git a/sys/kern/vfs_aio.c b/sys/kern/vfs_aio.c index 9ef54a7..10b1eab 100644 --- a/sys/kern/vfs_aio.c +++ b/sys/kern/vfs_aio.c @@ -996,20 +996,20 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe) bp->b_bcount = cb->aio_nbytes; bp->b_bufsize = cb->aio_nbytes; - bp->b_flags = B_PHYS | B_CALL; + bp->b_flags = B_PHYS; bp->b_iodone = aio_physwakeup; bp->b_saveaddr = bp->b_data; bp->b_data = (void *)cb->aio_buf; bp->b_blkno = btodb(cb->aio_offset); if (cb->aio_lio_opcode == LIO_WRITE) { - bp->b_flags |= B_WRITE; + bp->b_iocmd = BIO_WRITE; if (!useracc(bp->b_data, bp->b_bufsize, VM_PROT_READ)) { error = EFAULT; goto doerror; } } else { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; if (!useracc(bp->b_data, bp->b_bufsize, VM_PROT_WRITE)) { error = EFAULT; goto doerror; @@ -2132,7 +2132,6 @@ aio_physwakeup(struct buf *bp) s = splbio(); wakeup((caddr_t)bp); - bp->b_flags &= ~B_CALL; bp->b_flags |= B_DONE; aiocbe = (struct aiocblist *)bp->b_spc; diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index a2e8d26..da67cf2 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -501,7 +501,7 @@ bread(struct vnode * vp, daddr_t blkno, int size, struct ucred * cred, if (curproc != NULL) curproc->p_stats->p_ru.ru_inblock++; KASSERT(!(bp->b_flags & B_ASYNC), ("bread: illegal async bp %p", bp)); - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_ERROR | B_INVAL); if (bp->b_rcred == NOCRED) { if (cred != NOCRED) @@ -536,7 +536,7 @@ breadn(struct vnode * vp, daddr_t blkno, int size, if ((bp->b_flags & B_CACHE) == 0) { if (curproc != NULL) curproc->p_stats->p_ru.ru_inblock++; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_ERROR | B_INVAL); if (bp->b_rcred == NOCRED) { if (cred != NOCRED) @@ -556,8 +556,9 @@ breadn(struct vnode * vp, daddr_t blkno, int size, if ((rabp->b_flags & B_CACHE) == 0) { if (curproc != NULL) curproc->p_stats->p_ru.ru_inblock++; - rabp->b_flags |= B_READ | B_ASYNC; + rabp->b_flags |= B_ASYNC; rabp->b_flags &= ~(B_ERROR | B_INVAL); + rabp->b_iocmd = BIO_READ; if (rabp->b_rcred == NOCRED) { if (cred != NOCRED) crhold(cred); @@ -630,8 +631,10 @@ bwrite(struct buf * bp) * copy so as to leave this buffer ready for further use. */ if ((bp->b_xflags & BX_BKGRDWRITE) && (bp->b_flags & B_ASYNC)) { - if (bp->b_flags & B_CALL) + if (bp->b_iodone != NULL) { + printf("bp->b_iodone = %p\n", bp->b_iodone); panic("bwrite: need chained iodone"); + } /* get a new block */ newbp = geteblk(bp->b_bufsize); @@ -643,7 +646,7 @@ bwrite(struct buf * bp) newbp->b_blkno = bp->b_blkno; newbp->b_offset = bp->b_offset; newbp->b_iodone = vfs_backgroundwritedone; - newbp->b_flags |= B_ASYNC | B_CALL; + newbp->b_flags |= B_ASYNC; newbp->b_flags &= ~B_INVAL; /* move over the dependencies */ @@ -664,8 +667,9 @@ bwrite(struct buf * bp) bp = newbp; } - bp->b_flags &= ~(B_READ | B_DONE | B_ERROR); + bp->b_flags &= ~(B_DONE | B_ERROR); bp->b_flags |= B_WRITEINPROG | B_CACHE; + bp->b_iocmd = BIO_WRITE; bp->b_vp->v_numoutput++; vfs_busy_pages(bp, 1); @@ -726,11 +730,12 @@ vfs_backgroundwritedone(bp) } /* * This buffer is marked B_NOCACHE, so when it is released - * by biodone, it will be tossed. We mark it with B_READ + * by biodone, it will be tossed. We mark it with BIO_READ * to avoid biodone doing a second vwakeup. */ - bp->b_flags |= B_NOCACHE | B_READ; - bp->b_flags &= ~(B_CACHE | B_CALL | B_DONE); + bp->b_flags |= B_NOCACHE; + bp->b_iocmd = BIO_READ; + bp->b_flags &= ~(B_CACHE | B_DONE); bp->b_iodone = 0; biodone(bp); } @@ -806,7 +811,7 @@ bdwrite(struct buf * bp) /* * bdirty: * - * Turn buffer into delayed write request. We must clear B_READ and + * Turn buffer into delayed write request. We must clear BIO_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 @@ -827,7 +832,8 @@ bdirty(bp) struct buf *bp; { KASSERT(bp->b_qindex == QUEUE_NONE, ("bdirty: buffer %p still on queue %d", bp, bp->b_qindex)); - bp->b_flags &= ~(B_READ|B_RELBUF); + bp->b_flags &= ~(B_RELBUF); + bp->b_iocmd = BIO_WRITE; if ((bp->b_flags & B_DELWRI) == 0) { bp->b_flags |= B_DONE | B_DELWRI; @@ -946,7 +952,8 @@ brelse(struct buf * bp) if (bp->b_flags & B_LOCKED) bp->b_flags &= ~B_ERROR; - if ((bp->b_flags & (B_READ | B_ERROR | B_INVAL)) == B_ERROR) { + if (bp->b_iocmd == BIO_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 @@ -956,8 +963,8 @@ brelse(struct buf * bp) */ bp->b_flags &= ~B_ERROR; bdirty(bp); - } else if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_FREEBUF)) || - (bp->b_bufsize <= 0)) { + } else if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR)) || + bp->b_iocmd == BIO_DELETE || (bp->b_bufsize <= 0)) { /* * Either a failed I/O or we were asked to free or not * cache the buffer. @@ -969,7 +976,7 @@ brelse(struct buf * bp) --numdirtybuffers; numdirtywakeup(); } - bp->b_flags &= ~(B_DELWRI | B_CACHE | B_FREEBUF); + bp->b_flags &= ~(B_DELWRI | B_CACHE); if ((bp->b_flags & B_VMIO) == 0) { if (bp->b_bufsize) allocbuf(bp, 0); @@ -2632,7 +2639,7 @@ biowait(register struct buf * bp) #if defined(NO_SCHEDULE_MODS) tsleep(bp, PRIBIO, "biowait", 0); #else - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) tsleep(bp, PRIBIO, "biord", 0); else tsleep(bp, PRIBIO, "biowr", 0); @@ -2673,6 +2680,7 @@ void biodone(register struct buf * bp) { int s; + void (*b_iodone) __P((struct buf *)); s = splbio(); @@ -2681,20 +2689,21 @@ biodone(register struct buf * bp) bp->b_flags |= B_DONE; - if (bp->b_flags & B_FREEBUF) { + if (bp->b_iocmd == BIO_DELETE) { brelse(bp); splx(s); return; } - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_iocmd == BIO_WRITE) { vwakeup(bp); } /* call optional completion function if requested */ - if (bp->b_flags & B_CALL) { - bp->b_flags &= ~B_CALL; - (*bp->b_iodone) (bp); + if (bp->b_iodone != NULL) { + b_iodone = bp->b_iodone; + bp->b_iodone = NULL; + (*b_iodone) (bp); splx(s); return; } @@ -2745,7 +2754,8 @@ biodone(register struct buf * bp) * 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 (bp->b_iocmd == BIO_READ && + !(bp->b_flags & (B_INVAL|B_NOCACHE|B_ERROR))) { bp->b_flags |= B_CACHE; } @@ -2782,7 +2792,7 @@ biodone(register struct buf * bp) * 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 ((bp->b_iocmd == BIO_READ) && !bogusflag && resid > 0) { vfs_page_set_valid(bp, foff, i, m); } vm_page_flag_clear(m, PG_ZERO); diff --git a/sys/kern/vfs_cluster.c b/sys/kern/vfs_cluster.c index 7a8ce7c..ac14bc4 100644 --- a/sys/kern/vfs_cluster.c +++ b/sys/kern/vfs_cluster.c @@ -200,7 +200,8 @@ single_block_read: * if it isn't in the cache, then get a chunk from * disk if sequential, otherwise just get the block. */ - bp->b_flags |= B_READ | B_RAM; + bp->b_flags |= B_RAM; + bp->b_iocmd = BIO_READ; lblkno += 1; } } @@ -228,7 +229,8 @@ single_block_read: blkno, size, ntoread, NULL); } else { rbp = getblk(vp, lblkno, size, 0, 0); - rbp->b_flags |= B_READ | B_ASYNC | B_RAM; + rbp->b_flags |= B_ASYNC | B_RAM; + rbp->b_iocmd = BIO_READ; rbp->b_blkno = blkno; } } @@ -246,7 +248,7 @@ single_block_read: if ((bp->b_flags & B_CLUSTER) == 0) vfs_busy_pages(bp, 0); bp->b_flags &= ~(B_ERROR|B_INVAL); - if (bp->b_flags & (B_ASYNC|B_CALL)) + if ((bp->b_flags & B_ASYNC) || bp->b_iodone != NULL) BUF_KERNPROC(bp); error = VOP_STRATEGY(vp, bp); curproc->p_stats->p_ru.ru_inblock++; @@ -257,10 +259,10 @@ single_block_read: */ if (rbp) { if (error) { - rbp->b_flags &= ~(B_ASYNC | B_READ); + rbp->b_flags &= ~B_ASYNC; brelse(rbp); } else if (rbp->b_flags & B_CACHE) { - rbp->b_flags &= ~(B_ASYNC | B_READ); + rbp->b_flags &= ~B_ASYNC; bqrelse(rbp); } else { #if defined(CLUSTERDEBUG) @@ -281,7 +283,7 @@ single_block_read: if ((rbp->b_flags & B_CLUSTER) == 0) vfs_busy_pages(rbp, 0); rbp->b_flags &= ~(B_ERROR|B_INVAL); - if (rbp->b_flags & (B_ASYNC|B_CALL)) + if ((rbp->b_flags & B_ASYNC) || rbp->b_iodone != NULL) BUF_KERNPROC(rbp); (void) VOP_STRATEGY(vp, rbp); curproc->p_stats->p_ru.ru_inblock++; @@ -325,12 +327,13 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp) if (fbp) { tbp = fbp; - tbp->b_flags |= B_READ; + tbp->b_iocmd = BIO_READ; } else { tbp = getblk(vp, lbn, size, 0, 0); if (tbp->b_flags & B_CACHE) return tbp; - tbp->b_flags |= B_ASYNC | B_READ | B_RAM; + tbp->b_flags |= B_ASYNC | B_RAM; + tbp->b_iocmd = BIO_READ; } tbp->b_blkno = blkno; @@ -344,7 +347,8 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp) 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_CALL | B_CLUSTER | B_VMIO; + bp->b_flags = B_ASYNC | B_CLUSTER | B_VMIO; + bp->b_iocmd = BIO_READ; bp->b_iodone = cluster_callback; bp->b_blkno = blkno; bp->b_lblkno = lbn; @@ -400,7 +404,8 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp) if ((fbp && (i == 1)) || (i == (run - 1))) tbp->b_flags |= B_RAM; - tbp->b_flags |= B_READ | B_ASYNC; + tbp->b_flags |= B_ASYNC; + tbp->b_iocmd = BIO_READ; if (tbp->b_blkno == tbp->b_lblkno) { tbp->b_blkno = bn; } else if (tbp->b_blkno != bn) { @@ -716,7 +721,7 @@ cluster_wbuild(vp, size, start_lbn, len) bp->b_offset = tbp->b_offset; bp->b_data = (char *)((vm_offset_t)bp->b_data | ((vm_offset_t)tbp->b_data & PAGE_MASK)); - bp->b_flags |= B_CALL | B_CLUSTER | + bp->b_flags |= B_CLUSTER | (tbp->b_flags & (B_VMIO | B_NEEDCOMMIT)); bp->b_iodone = cluster_callback; pbgetvp(vp, bp); @@ -811,8 +816,9 @@ cluster_wbuild(vp, size, start_lbn, len) s = splbio(); bundirty(tbp); - tbp->b_flags &= ~(B_READ | B_DONE | B_ERROR); + tbp->b_flags &= ~(B_DONE | B_ERROR); tbp->b_flags |= B_ASYNC; + tbp->b_iocmd = BIO_WRITE; reassignbuf(tbp, tbp->b_vp); /* put on clean list */ ++tbp->b_vp->v_numoutput; splx(s); diff --git a/sys/kern/vfs_default.c b/sys/kern/vfs_default.c index bd7e9ca..35a3d09 100644 --- a/sys/kern/vfs_default.c +++ b/sys/kern/vfs_default.c @@ -153,10 +153,10 @@ vop_panic(struct vop_generic_args *ap) * Strategy routine for VFS devices that have none. * * B_ERROR and B_INVAL must be cleared prior to calling any strategy - * routine. Typically this is done for a B_READ strategy call. Typically - * B_INVAL is assumed to already be clear prior to a write and should not - * be cleared manually unless you just made the buffer invalid. B_ERROR - * should be cleared either way. + * routine. Typically this is done for a BIO_READ strategy call. + * Typically B_INVAL is assumed to already be clear prior to a write + * and should not be cleared manually unless you just made the buffer + * invalid. B_ERROR should be cleared either way. */ static int diff --git a/sys/miscfs/devfs/devfs_vnops.c b/sys/miscfs/devfs/devfs_vnops.c index 85351ba..9be35c6 100644 --- a/sys/miscfs/devfs/devfs_vnops.c +++ b/sys/miscfs/devfs/devfs_vnops.c @@ -1569,7 +1569,7 @@ devfs_strategy(struct vop_strategy_args *ap) return error; - if (((bp->b_flags & B_READ) == 0) && + if ((bp->b_iocmd == BIO_WRITE) && (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) (*bioops.io_start)(bp); switch (vp->v_type) { @@ -1606,7 +1606,7 @@ devfs_freeblks(struct vop_freeblks_args *ap) if ((bsw->d_flags & D_CANFREE) == 0) return (0); bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF; + bp->b_iocmd = BIO_DELETE; bp->b_dev = vp->v_rdev; bp->b_blkno = ap->a_addr; bp->b_offset = dbtob(ap->a_addr); @@ -1834,7 +1834,7 @@ devfs_getpages(struct vop_getpages_args *ap) pmap_qenter(kva, ap->a_m, pcount); /* Build a minimal buffer header. */ - bp->b_flags = B_READ | B_CALL; + bp->b_iocmd = BIO_READ; bp->b_iodone = devfs_getpages_iodone; /* B_PHYS is not set, but it is nice to fill this in. */ diff --git a/sys/miscfs/specfs/spec_vnops.c b/sys/miscfs/specfs/spec_vnops.c index a9a711e..f48c0c1 100644 --- a/sys/miscfs/specfs/spec_vnops.c +++ b/sys/miscfs/specfs/spec_vnops.c @@ -407,7 +407,7 @@ spec_strategy(ap) struct mount *mp; bp = ap->a_bp; - if (((bp->b_flags & B_READ) == 0) && + if ((bp->b_iocmd == BIO_WRITE) && (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) (*bioops.io_start)(bp); @@ -417,7 +417,7 @@ spec_strategy(ap) */ vp = ap->a_vp; if (vn_isdisk(vp, NULL) && (mp = vp->v_specmountpoint) != NULL) { - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_iocmd == BIO_WRITE) { if (bp->b_lock.lk_lockholder == LK_KERNPROC) mp->mnt_stat.f_asyncwrites++; else @@ -458,7 +458,7 @@ spec_freeblks(ap) if ((bsw->d_flags & D_CANFREE) == 0) return (0); bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF; + bp->b_iocmd = BIO_DELETE; bp->b_dev = ap->a_vp->v_rdev; bp->b_blkno = ap->a_addr; bp->b_offset = dbtob(ap->a_addr); @@ -657,7 +657,7 @@ spec_getpages(ap) pmap_qenter(kva, ap->a_m, pcount); /* Build a minimal buffer header. */ - bp->b_flags = B_READ | B_CALL; + bp->b_iocmd = BIO_READ; bp->b_iodone = spec_getpages_iodone; /* B_PHYS is not set, but it is nice to fill this in. */ diff --git a/sys/miscfs/union/union_vnops.c b/sys/miscfs/union/union_vnops.c index 03d41a0..38c190b 100644 --- a/sys/miscfs/union/union_vnops.c +++ b/sys/miscfs/union/union_vnops.c @@ -1923,7 +1923,7 @@ union_strategy(ap) #ifdef DIAGNOSTIC if (othervp == NULLVP) panic("union_strategy: nil vp"); - if (((bp->b_flags & B_READ) == 0) && + if ((bp->b_iocmd == BIO_WRITE) && (othervp == LOWERVP(bp->b_vp))) panic("union_strategy: writing to lowervp"); #endif diff --git a/sys/nfs/nfs_bio.c b/sys/nfs/nfs_bio.c index 4b9dcec..b137fe8 100644 --- a/sys/nfs/nfs_bio.c +++ b/sys/nfs/nfs_bio.c @@ -465,7 +465,8 @@ nfs_bioread(vp, uio, ioflag, cred) if (!rabp) return (EINTR); if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= (B_READ | B_ASYNC); + rabp->b_flags |= B_ASYNC; + rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); if (nfs_asyncio(rabp, cred, p)) { rabp->b_flags |= B_INVAL|B_ERROR; @@ -526,7 +527,7 @@ again: */ if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -553,7 +554,7 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -577,7 +578,7 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -605,7 +606,7 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); /* @@ -648,7 +649,8 @@ again: rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); if (rabp) { if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= (B_READ | B_ASYNC); + rabp->b_flags |= B_ASYNC; + rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); if (nfs_asyncio(rabp, cred, p)) { rabp->b_flags |= B_INVAL|B_ERROR; @@ -936,7 +938,7 @@ again: } if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -1232,7 +1234,7 @@ nfs_asyncio(bp, cred, procp) * 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_iocmd == BIO_WRITE && (bp->b_flags & B_NEEDCOMMIT) && (nmp->nm_bufqiods > nfs_numasync / 2)) { return(EIO); } @@ -1309,7 +1311,7 @@ again: } } - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { if (bp->b_rcred == NOCRED && cred != NOCRED) { crhold(cred); bp->b_rcred = cred; @@ -1383,7 +1385,7 @@ nfs_doio(bp, cr, p) /* mapping was done by vmapbuf() */ io.iov_base = bp->b_data; uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { uiop->uio_rw = UIO_READ; nfsstats.read_physios++; error = nfs_readrpc(vp, uiop, cr); @@ -1399,7 +1401,7 @@ nfs_doio(bp, cr, p) bp->b_flags |= B_ERROR; bp->b_error = error; } - } else if (bp->b_flags & B_READ) { + } else if (bp->b_iocmd == BIO_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; diff --git a/sys/nfs/nfs_syscalls.c b/sys/nfs/nfs_syscalls.c index 14ff8d1..8d82a43 100644 --- a/sys/nfs/nfs_syscalls.c +++ b/sys/nfs/nfs_syscalls.c @@ -961,7 +961,7 @@ nfssvc_iod(p) nmp->nm_bufqwant = FALSE; wakeup(&nmp->nm_bufq); } - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); else (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); diff --git a/sys/nfs/nfs_vnops.c b/sys/nfs/nfs_vnops.c index 0a6de2f..0dbbe09 100644 --- a/sys/nfs/nfs_vnops.c +++ b/sys/nfs/nfs_vnops.c @@ -2705,7 +2705,7 @@ nfs_strategy(ap) else p = curproc; /* XXX */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; else cr = bp->b_wcred; @@ -2939,7 +2939,7 @@ again: vp->v_numoutput++; bp->b_flags |= B_ASYNC; bundirty(bp); - bp->b_flags &= ~(B_READ|B_DONE|B_ERROR); + bp->b_flags &= ~(B_DONE|B_ERROR); bp->b_dirtyoff = bp->b_dirtyend = 0; splx(s); biodone(bp); @@ -3116,7 +3116,8 @@ nfs_writebp(bp, force, procp) s = splbio(); bundirty(bp); - bp->b_flags &= ~(B_READ|B_DONE|B_ERROR); + bp->b_flags &= ~(B_DONE|B_ERROR); + bp->b_iocmd = BIO_WRITE; bp->b_vp->v_numoutput++; curproc->p_stats->p_ru.ru_oublock++; diff --git a/sys/nfsclient/nfs_bio.c b/sys/nfsclient/nfs_bio.c index 4b9dcec..b137fe8 100644 --- a/sys/nfsclient/nfs_bio.c +++ b/sys/nfsclient/nfs_bio.c @@ -465,7 +465,8 @@ nfs_bioread(vp, uio, ioflag, cred) if (!rabp) return (EINTR); if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= (B_READ | B_ASYNC); + rabp->b_flags |= B_ASYNC; + rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); if (nfs_asyncio(rabp, cred, p)) { rabp->b_flags |= B_INVAL|B_ERROR; @@ -526,7 +527,7 @@ again: */ if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -553,7 +554,7 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -577,7 +578,7 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -605,7 +606,7 @@ again: if (!bp) return (EINTR); if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); /* @@ -648,7 +649,8 @@ again: rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); if (rabp) { if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { - rabp->b_flags |= (B_READ | B_ASYNC); + rabp->b_flags |= B_ASYNC; + rabp->b_iocmd = BIO_READ; vfs_busy_pages(rabp, 0); if (nfs_asyncio(rabp, cred, p)) { rabp->b_flags |= B_INVAL|B_ERROR; @@ -936,7 +938,7 @@ again: } if ((bp->b_flags & B_CACHE) == 0) { - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; vfs_busy_pages(bp, 0); error = nfs_doio(bp, cred, p); if (error) { @@ -1232,7 +1234,7 @@ nfs_asyncio(bp, cred, procp) * 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_iocmd == BIO_WRITE && (bp->b_flags & B_NEEDCOMMIT) && (nmp->nm_bufqiods > nfs_numasync / 2)) { return(EIO); } @@ -1309,7 +1311,7 @@ again: } } - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { if (bp->b_rcred == NOCRED && cred != NOCRED) { crhold(cred); bp->b_rcred = cred; @@ -1383,7 +1385,7 @@ nfs_doio(bp, cr, p) /* mapping was done by vmapbuf() */ io.iov_base = bp->b_data; uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { uiop->uio_rw = UIO_READ; nfsstats.read_physios++; error = nfs_readrpc(vp, uiop, cr); @@ -1399,7 +1401,7 @@ nfs_doio(bp, cr, p) bp->b_flags |= B_ERROR; bp->b_error = error; } - } else if (bp->b_flags & B_READ) { + } else if (bp->b_iocmd == BIO_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; diff --git a/sys/nfsclient/nfs_nfsiod.c b/sys/nfsclient/nfs_nfsiod.c index 14ff8d1..8d82a43 100644 --- a/sys/nfsclient/nfs_nfsiod.c +++ b/sys/nfsclient/nfs_nfsiod.c @@ -961,7 +961,7 @@ nfssvc_iod(p) nmp->nm_bufqwant = FALSE; wakeup(&nmp->nm_bufq); } - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); else (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); diff --git a/sys/nfsclient/nfs_vnops.c b/sys/nfsclient/nfs_vnops.c index 0a6de2f..0dbbe09 100644 --- a/sys/nfsclient/nfs_vnops.c +++ b/sys/nfsclient/nfs_vnops.c @@ -2705,7 +2705,7 @@ nfs_strategy(ap) else p = curproc; /* XXX */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; else cr = bp->b_wcred; @@ -2939,7 +2939,7 @@ again: vp->v_numoutput++; bp->b_flags |= B_ASYNC; bundirty(bp); - bp->b_flags &= ~(B_READ|B_DONE|B_ERROR); + bp->b_flags &= ~(B_DONE|B_ERROR); bp->b_dirtyoff = bp->b_dirtyend = 0; splx(s); biodone(bp); @@ -3116,7 +3116,8 @@ nfs_writebp(bp, force, procp) s = splbio(); bundirty(bp); - bp->b_flags &= ~(B_READ|B_DONE|B_ERROR); + bp->b_flags &= ~(B_DONE|B_ERROR); + bp->b_iocmd = BIO_WRITE; bp->b_vp->v_numoutput++; curproc->p_stats->p_ru.ru_oublock++; diff --git a/sys/nfsserver/nfs_syscalls.c b/sys/nfsserver/nfs_syscalls.c index 14ff8d1..8d82a43 100644 --- a/sys/nfsserver/nfs_syscalls.c +++ b/sys/nfsserver/nfs_syscalls.c @@ -961,7 +961,7 @@ nfssvc_iod(p) nmp->nm_bufqwant = FALSE; wakeup(&nmp->nm_bufq); } - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0); else (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); diff --git a/sys/ntfs/ntfs_vnops.c b/sys/ntfs/ntfs_vnops.c index 381cb8f..a47cf56f 100644 --- a/sys/ntfs/ntfs_vnops.c +++ b/sys/ntfs/ntfs_vnops.c @@ -345,7 +345,7 @@ ntfs_strategy(ap) dprintf(("strategy: bcount: %d flags: 0x%lx\n", (u_int32_t)bp->b_bcount,bp->b_flags)); - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { u_int32_t toread; if (ntfs_cntob(bp->b_blkno) >= fp->f_size) { diff --git a/sys/nwfs/nwfs_io.c b/sys/nwfs/nwfs_io.c index d634cbc..6f7a6c8 100644 --- a/sys/nwfs/nwfs_io.c +++ b/sys/nwfs/nwfs_io.c @@ -275,7 +275,7 @@ nwfs_doio(bp, cr, p) uiop->uio_iovcnt = 1; uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_procp = p; - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { io.iov_len = uiop->uio_resid = bp->b_bcount; io.iov_base = bp->b_data; uiop->uio_rw = UIO_READ; diff --git a/sys/nwfs/nwfs_vnops.c b/sys/nwfs/nwfs_vnops.c index 22df1b3..c8e8b67 100644 --- a/sys/nwfs/nwfs_vnops.c +++ b/sys/nwfs/nwfs_vnops.c @@ -812,7 +812,7 @@ static int nwfs_strategy (ap) p = (struct proc *)0; else p = curproc; /* XXX */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) cr = bp->b_rcred; else cr = bp->b_wcred; diff --git a/sys/pc98/cbus/fdc.c b/sys/pc98/cbus/fdc.c index 9a34ad4..5d76cf4 100644 --- a/sys/pc98/cbus/fdc.c +++ b/sys/pc98/cbus/fdc.c @@ -1944,7 +1944,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count) { u_char *cptr = (u_char *)addr; - if (flags & B_READ) { + if (flags == BIO_READ) { if (fdc->state != PIOREAD) { fdc->state = PIOREAD; return(0); @@ -2003,7 +2003,7 @@ fdstate(fdc_p fdc) fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); - read = bp->b_flags & B_READ; + read = bp->b_iocmd == BIO_READ; format = bp->b_flags & B_FORMAT; if (format) { finfo = (struct fd_formb *)bp->b_data; @@ -2257,7 +2257,7 @@ fdstate(fdc_p fdc) */ SET_BCDR(fdc, 1, bp->b_bcount, 0); - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, bp->b_bcount); @@ -2290,7 +2290,7 @@ fdstate(fdc_p fdc) * the WRITE command is sent */ if (!read) - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, fdblk); } @@ -2320,7 +2320,7 @@ fdstate(fdc_p fdc) * if this is a read, then simply await interrupt * before performing PIO */ - if (read && !fdcpio(fdc,bp->b_flags, + if (read && !fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip,fdblk)) { fd->tohandle = timeout(fd_iotimeout, fdc, hz); return(0); /* will return later */ @@ -2368,7 +2368,7 @@ fdstate(fdc_p fdc) * actually perform the PIO read. The IOCOMPLETE case * removes the timeout for us. */ - (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk); + (void)fdcpio(fdc,bp->b_iocmd,bp->b_data+fd->skip,fdblk); fdc->state = IOCOMPLETE; /* FALLTHROUGH */ case IOCOMPLETE: /* IO DONE, post-analyze */ diff --git a/sys/pc98/i386/machdep.c b/sys/pc98/i386/machdep.c index 88b5696..3851e8f 100644 --- a/sys/pc98/i386/machdep.c +++ b/sys/pc98/i386/machdep.c @@ -2656,7 +2656,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if LABELSECTOR != 0 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -2664,7 +2664,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/pc98/pc98/diskslice_machdep.c b/sys/pc98/pc98/diskslice_machdep.c index b932845..6026e92 100644 --- a/sys/pc98/pc98/diskslice_machdep.c +++ b/sys/pc98/pc98/diskslice_machdep.c @@ -243,7 +243,7 @@ reread_mbr: bp->b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART); bp->b_blkno = mbr_offset; bp->b_bcount = lp->d_secsize; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; #ifdef PC98 if (bp->b_bcount < 1024) bp->b_bcount = 1024; @@ -548,7 +548,7 @@ mbr_extended(dev, lp, ssp, ext_offset, ext_size, base_ext_offset, nsectors, bp->b_dev = dev; bp->b_blkno = ext_offset; bp->b_bcount = lp->d_secsize; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); if (biowait(bp) != 0) { diskerr(bp, "reading extended partition table: error", diff --git a/sys/pc98/pc98/fd.c b/sys/pc98/pc98/fd.c index 9a34ad4..5d76cf4 100644 --- a/sys/pc98/pc98/fd.c +++ b/sys/pc98/pc98/fd.c @@ -1944,7 +1944,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count) { u_char *cptr = (u_char *)addr; - if (flags & B_READ) { + if (flags == BIO_READ) { if (fdc->state != PIOREAD) { fdc->state = PIOREAD; return(0); @@ -2003,7 +2003,7 @@ fdstate(fdc_p fdc) fdblk = 128 << fd->ft->secsize; if (fdc->fd && (fd != fdc->fd)) device_printf(fd->dev, "confused fd pointers\n"); - read = bp->b_flags & B_READ; + read = bp->b_iocmd == BIO_READ; format = bp->b_flags & B_FORMAT; if (format) { finfo = (struct fd_formb *)bp->b_data; @@ -2257,7 +2257,7 @@ fdstate(fdc_p fdc) */ SET_BCDR(fdc, 1, bp->b_bcount, 0); - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, bp->b_bcount); @@ -2290,7 +2290,7 @@ fdstate(fdc_p fdc) * the WRITE command is sent */ if (!read) - (void)fdcpio(fdc,bp->b_flags, + (void)fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip, fdblk); } @@ -2320,7 +2320,7 @@ fdstate(fdc_p fdc) * if this is a read, then simply await interrupt * before performing PIO */ - if (read && !fdcpio(fdc,bp->b_flags, + if (read && !fdcpio(fdc,bp->b_iocmd, bp->b_data+fd->skip,fdblk)) { fd->tohandle = timeout(fd_iotimeout, fdc, hz); return(0); /* will return later */ @@ -2368,7 +2368,7 @@ fdstate(fdc_p fdc) * actually perform the PIO read. The IOCOMPLETE case * removes the timeout for us. */ - (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk); + (void)fdcpio(fdc,bp->b_iocmd,bp->b_data+fd->skip,fdblk); fdc->state = IOCOMPLETE; /* FALLTHROUGH */ case IOCOMPLETE: /* IO DONE, post-analyze */ diff --git a/sys/pc98/pc98/machdep.c b/sys/pc98/pc98/machdep.c index 88b5696..3851e8f 100644 --- a/sys/pc98/pc98/machdep.c +++ b/sys/pc98/pc98/machdep.c @@ -2656,7 +2656,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if LABELSECTOR != 0 bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && #endif - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } @@ -2664,7 +2664,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel) #if defined(DOSBBSECTOR) && defined(notyet) /* overwriting master boot record? */ if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && - (bp->b_flags & B_READ) == 0 && wlabel == 0) { + (bp->b_iocmd == BIO_WRITE) && wlabel == 0) { bp->b_error = EROFS; goto bad; } diff --git a/sys/pc98/pc98/wd.c b/sys/pc98/pc98/wd.c index aea2592..e8b78e1 100644 --- a/sys/pc98/pc98/wd.c +++ b/sys/pc98/pc98/wd.c @@ -805,7 +805,7 @@ wdstart(int ctrlr) #ifdef WDDEBUG if (du->dk_skip == 0) printf("wd%d: wdstart: %s %d@%d; map ", lunit, - (bp->b_flags & B_READ) ? "read" : "write", + (bp->b_iocmd == BIO_READ) ? "read" : "write", bp->b_bcount, blknum); else { if (old_epson_note) @@ -843,7 +843,7 @@ wdstart(int ctrlr) * XXX this looks like an attempt to skip bad sectors * on write. */ - if (wdtab[ctrlr].b_errcnt && (bp->b_flags & B_READ) == 0) + if (wdtab[ctrlr].b_errcnt && (bp->b_iocmd == BIO_WRITE)) du->dk_bc += DEV_BSIZE; count1 = howmany( du->dk_bc, DEV_BSIZE); @@ -851,7 +851,7 @@ wdstart(int ctrlr) du->dk_flags &= ~DKFL_MULTI; if (du->dk_flags & DKFL_SINGLE) { - command = (bp->b_flags & B_READ) + command = (bp->b_iocmd == BIO_READ) ? WDCC_READ : WDCC_WRITE; count1 = 1; du->dk_currentiosize = 1; @@ -861,16 +861,16 @@ wdstart(int ctrlr) (void *)((int)bp->b_data + du->dk_skip * DEV_BSIZE), du->dk_bc, - bp->b_flags & B_READ)) { + bp->b_iocmd == BIO_READ)) { du->dk_flags |= DKFL_DMA; - if( bp->b_flags & B_READ) + if(bp->b_iocmd == BIO_READ) command = WDCC_READ_DMA; else command = WDCC_WRITE_DMA; du->dk_currentiosize = count1; } else if( (count1 > 1) && (du->dk_multi > 1)) { du->dk_flags |= DKFL_MULTI; - if( bp->b_flags & B_READ) { + if(bp->b_iocmd == BIO_READ) { command = WDCC_READ_MULTI; } else { command = WDCC_WRITE_MULTI; @@ -879,7 +879,7 @@ wdstart(int ctrlr) if( du->dk_currentiosize > count1) du->dk_currentiosize = count1; } else { - if( bp->b_flags & B_READ) { + if(bp->b_iocmd == BIO_READ) { command = WDCC_READ; } else { command = WDCC_WRITE; @@ -906,7 +906,7 @@ wdstart(int ctrlr) (void *)((int)bp->b_data + du->dk_skip * DEV_BSIZE), du->dk_bc, - bp->b_flags & B_READ); + bp->b_iocmd == BIO_READ); } while (wdcommand(du, cylin, head, sector, count1, command) != 0) { @@ -954,7 +954,7 @@ wdstart(int ctrlr) } /* If this is a read operation, just go away until it's done. */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) return; /* Ready to send data? */ @@ -1133,7 +1133,7 @@ oops: /* * If this was a successful read operation, fetch the data. */ - if (((bp->b_flags & (B_READ | B_ERROR)) == B_READ) + if (bp->b_iocmd == BIO_READ && !(bp->b_flags & B_ERROR) && !((du->dk_flags & (DKFL_DMA|DKFL_SINGLE)) == DKFL_DMA) && wdtab[unit].b_active) { u_int chk, dummy, multisize; @@ -1197,7 +1197,7 @@ outt: /* see if more to transfer */ if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) { if( (du->dk_flags & DKFL_SINGLE) || - ((bp->b_flags & B_READ) == 0)) { + (bp->b_iocmd == BIO_WRITE)) { wdtab[unit].b_active = 0; wdstart(unit); } else { diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c index bb2bbfd..982f127 100644 --- a/sys/powerpc/aim/vm_machdep.c +++ b/sys/powerpc/aim/vm_machdep.c @@ -319,7 +319,7 @@ vmapbuf(bp) * when reading stuff off device into memory. */ vm_fault_quick(addr, - (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); pa = trunc_page(pmap_kextract((vm_offset_t) addr)); if (pa == 0) panic("vmapbuf: page not present"); diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c index bb2bbfd..982f127 100644 --- a/sys/powerpc/powerpc/vm_machdep.c +++ b/sys/powerpc/powerpc/vm_machdep.c @@ -319,7 +319,7 @@ vmapbuf(bp) * when reading stuff off device into memory. */ vm_fault_quick(addr, - (bp->b_flags&B_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); + (bp->b_iocmd == BIO_READ)?(VM_PROT_READ|VM_PROT_WRITE):VM_PROT_READ); pa = trunc_page(pmap_kextract((vm_offset_t) addr)); if (pa == 0) panic("vmapbuf: page not present"); diff --git a/sys/sys/bio.h b/sys/sys/bio.h index f38bf45..8339978 100644 --- a/sys/sys/bio.h +++ b/sys/sys/bio.h @@ -100,6 +100,7 @@ struct buf { TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */ TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */ TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */ + u_int b_iocmd; /* BIO_READ, BIO_WRITE, BIO_DELETE */ long b_flags; /* B_* flags. */ unsigned short b_qindex; /* buffer queue index */ unsigned char b_xflags; /* extra flags */ @@ -170,7 +171,7 @@ struct buf { * B_DELWRI can also be cleared. See the comments for * getblk() in kern/vfs_bio.c. If B_CACHE is clear, * the caller is expected to clear B_ERROR|B_INVAL, - * set B_READ, and initiate an I/O. + * set BIO_READ, and initiate an I/O. * * The 'entire buffer' is defined to be the range from * 0 through b_bcount. @@ -192,15 +193,18 @@ struct buf { * */ +#define BIO_READ 1 +#define BIO_WRITE 2 +#define BIO_DELETE 4 + #define B_AGE 0x00000001 /* Move to age queue when I/O done. */ #define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */ #define B_ASYNC 0x00000004 /* Start I/O, do not wait. */ #define B_UNUSED0 0x00000008 /* Old B_BAD */ #define B_DEFERRED 0x00000010 /* Skipped over for cleaning */ #define B_CACHE 0x00000020 /* Bread found us in the cache. */ -#define B_CALL 0x00000040 /* Call b_iodone from biodone. */ +#define B_UNUSED40 0x00000040 /* Old B_CALL */ #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_EINTR 0x00000400 /* I/O was interrupted */ #define B_ERROR 0x00000800 /* I/O error occurred. */ @@ -212,11 +216,9 @@ struct buf { #define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */ #define B_PHYS 0x00040000 /* I/O to user memory. */ #define B_RAW 0x00080000 /* Set by physio for raw transfers. */ -#define B_READ 0x00100000 /* Read buffer. */ #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_WRITEINPROG 0x01000000 /* Write in progress. */ #define B_XXX 0x02000000 /* Debugging flag. */ #define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */ diff --git a/sys/sys/buf.h b/sys/sys/buf.h index f38bf45..8339978 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -100,6 +100,7 @@ struct buf { TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */ TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */ TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */ + u_int b_iocmd; /* BIO_READ, BIO_WRITE, BIO_DELETE */ long b_flags; /* B_* flags. */ unsigned short b_qindex; /* buffer queue index */ unsigned char b_xflags; /* extra flags */ @@ -170,7 +171,7 @@ struct buf { * B_DELWRI can also be cleared. See the comments for * getblk() in kern/vfs_bio.c. If B_CACHE is clear, * the caller is expected to clear B_ERROR|B_INVAL, - * set B_READ, and initiate an I/O. + * set BIO_READ, and initiate an I/O. * * The 'entire buffer' is defined to be the range from * 0 through b_bcount. @@ -192,15 +193,18 @@ struct buf { * */ +#define BIO_READ 1 +#define BIO_WRITE 2 +#define BIO_DELETE 4 + #define B_AGE 0x00000001 /* Move to age queue when I/O done. */ #define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */ #define B_ASYNC 0x00000004 /* Start I/O, do not wait. */ #define B_UNUSED0 0x00000008 /* Old B_BAD */ #define B_DEFERRED 0x00000010 /* Skipped over for cleaning */ #define B_CACHE 0x00000020 /* Bread found us in the cache. */ -#define B_CALL 0x00000040 /* Call b_iodone from biodone. */ +#define B_UNUSED40 0x00000040 /* Old B_CALL */ #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_EINTR 0x00000400 /* I/O was interrupted */ #define B_ERROR 0x00000800 /* I/O error occurred. */ @@ -212,11 +216,9 @@ struct buf { #define B_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */ #define B_PHYS 0x00040000 /* I/O to user memory. */ #define B_RAW 0x00080000 /* Set by physio for raw transfers. */ -#define B_READ 0x00100000 /* Read buffer. */ #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_WRITEINPROG 0x01000000 /* Write in progress. */ #define B_XXX 0x02000000 /* Debugging flag. */ #define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */ diff --git a/sys/sys/conf.h b/sys/sys/conf.h index 263613c..1528a46 100644 --- a/sys/sys/conf.h +++ b/sys/sys/conf.h @@ -137,7 +137,13 @@ typedef void devfs_remove_t __P((dev_t dev)); * of surgery, reset the flag and restart all the stuff on the stall * queue. */ -#define BUF_STRATEGY(bp, dummy) (*devsw((bp)->b_dev)->d_strategy)(bp) +#define BUF_STRATEGY(bp, dummy) \ + do { \ + if ((!(bp)->b_iocmd) || ((bp)->b_iocmd & ((bp)->b_iocmd - 1))) \ + Debugger("d_iocmd botch"); \ + (*devsw((bp)->b_dev)->d_strategy)(bp); \ + } while (0) + /* * Types for d_flags. */ diff --git a/sys/sys/linedisc.h b/sys/sys/linedisc.h index 263613c..1528a46 100644 --- a/sys/sys/linedisc.h +++ b/sys/sys/linedisc.h @@ -137,7 +137,13 @@ typedef void devfs_remove_t __P((dev_t dev)); * of surgery, reset the flag and restart all the stuff on the stall * queue. */ -#define BUF_STRATEGY(bp, dummy) (*devsw((bp)->b_dev)->d_strategy)(bp) +#define BUF_STRATEGY(bp, dummy) \ + do { \ + if ((!(bp)->b_iocmd) || ((bp)->b_iocmd & ((bp)->b_iocmd - 1))) \ + Debugger("d_iocmd botch"); \ + (*devsw((bp)->b_dev)->d_strategy)(bp); \ + } while (0) + /* * Types for d_flags. */ diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index aad4285..f25b19f 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -447,7 +447,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp) bp = getblk(vp, lbn, (int)fs->fs_bsize, 0, 0); if ((bp->b_flags & B_CACHE) == 0) { curproc->p_stats->p_ru.ru_inblock++; /* pay for read */ - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_ERROR|B_INVAL); if (bp->b_bcount > bp->b_bufsize) panic("ffs_indirtrunc: bad buffer size"); diff --git a/sys/ufs/ffs/ffs_softdep.c b/sys/ufs/ffs/ffs_softdep.c index a137ce7..456667d 100644 --- a/sys/ufs/ffs/ffs_softdep.c +++ b/sys/ufs/ffs/ffs_softdep.c @@ -2780,7 +2780,7 @@ softdep_disk_io_initiation(bp) * We only care about write operations. There should never * be dependencies for reads. */ - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) panic("softdep_disk_io_initiation: read"); /* * Do any necessary pre-I/O processing. diff --git a/sys/ufs/mfs/mfs_vnops.c b/sys/ufs/mfs/mfs_vnops.c index ad691df..8f00850 100644 --- a/sys/ufs/mfs/mfs_vnops.c +++ b/sys/ufs/mfs/mfs_vnops.c @@ -123,7 +123,7 @@ mfs_fsync(ap) /* * mfs_freeblks() - hook to allow us to free physical memory. * - * We implement the B_FREEBUF strategy. We can't just madvise() + * We implement the BIO_DELETE 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. * @@ -146,7 +146,8 @@ mfs_freeblks(ap) panic("mfs_freeblks: bad dev"); bp = geteblk(ap->a_length); - bp->b_flags |= B_FREEBUF | B_ASYNC; + bp->b_flags |= B_ASYNC; + bp->b_iocmd = BIO_DELETE; bp->b_dev = ap->a_vp->v_rdev; bp->b_blkno = ap->a_addr; bp->b_offset = dbtob(ap->a_addr); @@ -185,15 +186,15 @@ mfs_strategy(ap) if (mfsp->mfs_pid == 0) { /* - * mini-root. Note: B_FREEBUF not supported at the moment, + * mini-root. Note: BIO_DELETE not supported at the moment, * I'm not sure what kind of dataspace b_data is in. */ caddr_t base; base = mfsp->mfs_baseoff + (bp->b_blkno << DEV_BSHIFT); - if (bp->b_flags & B_FREEBUF) + if (bp->b_iocmd == BIO_DELETE) ; - if (bp->b_flags & B_READ) + if (bp->b_iocmd == BIO_READ) bcopy(base, bp->b_data, bp->b_bcount); else bcopy(bp->b_data, base, bp->b_bcount); @@ -224,7 +225,7 @@ mfs_strategy(ap) * * Read and Write are handled with a simple copyin and copyout. * - * We also partially support VOP_FREEBLKS() via B_FREEBUF. We can't implement + * We also partially support VOP_FREEBLKS() via BIO_DELETE. We can't implement * completely -- for example, on fragments or inode metadata, but we can * implement it for page-aligned requests. */ @@ -235,9 +236,9 @@ mfs_doio(bp, mfsp) { caddr_t base = mfsp->mfs_baseoff + (bp->b_blkno << DEV_BSHIFT); - if (bp->b_flags & B_FREEBUF) { + if (bp->b_iocmd == BIO_DELETE) { /* - * Implement B_FREEBUF, which allows the filesystem to tell + * Implement BIO_DELETE, 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 @@ -263,7 +264,7 @@ mfs_doio(bp, mfsp) } } bp->b_error = 0; - } else if (bp->b_flags & B_READ) { + } else if (bp->b_iocmd == BIO_READ) { /* * Read data from our 'memory' disk */ diff --git a/sys/ufs/ufs/ufs_bmap.c b/sys/ufs/ufs/ufs_bmap.c index 57cef46..ab5ebb5 100644 --- a/sys/ufs/ufs/ufs_bmap.c +++ b/sys/ufs/ufs/ufs_bmap.c @@ -192,7 +192,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb) panic("ufs_bmaparray: indirect block not in cache"); #endif bp->b_blkno = blkptrtodb(ump, daddr); - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; bp->b_flags &= ~(B_INVAL|B_ERROR); vfs_busy_pages(bp, 0); VOP_STRATEGY(bp->b_vp, bp); diff --git a/sys/ufs/ufs/ufs_disksubr.c b/sys/ufs/ufs/ufs_disksubr.c index 9184f2f..ff72629 100644 --- a/sys/ufs/ufs/ufs_disksubr.c +++ b/sys/ufs/ufs/ufs_disksubr.c @@ -181,7 +181,7 @@ readdisklabel(dev, lp) bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_bcount = lp->d_secsize; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); if (biowait(bp)) msg = "I/O error"; @@ -284,7 +284,7 @@ writedisklabel(dev, lp) * (also stupid.. how do you write the first one? by raw writes?) */ bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_READ; + bp->b_iocmd = BIO_READ; BUF_STRATEGY(bp, 1); error = biowait(bp); if (error) @@ -296,8 +296,8 @@ writedisklabel(dev, lp) if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && dkcksum(dlp) == 0) { *dlp = *lp; - bp->b_flags &= ~(B_DONE | B_READ); - bp->b_flags |= B_WRITE; + bp->b_flags &= ~B_DONE; + bp->b_iocmd = BIO_WRITE; #ifdef __alpha__ alpha_fix_srm_checksum(bp); #endif @@ -313,7 +313,7 @@ done: dlp = (struct disklabel *)bp->b_data; *dlp = *lp; bp->b_flags &= ~B_INVAL; - bp->b_flags |= B_WRITE; + bp->b_iocmd = BIO_WRITE; BUF_STRATEGY(bp, 1); error = biowait(bp); #endif @@ -375,7 +375,7 @@ diskerr(bp, what, pri, blkdone, lp) pr = printf; sname = dsname(bp->b_dev, unit, slice, part, partname); (*pr)("%s%s: %s %sing fsbn ", sname, partname, what, - bp->b_flags & B_READ ? "read" : "writ"); + bp->b_iocmd == BIO_READ ? "read" : "writ"); sn = bp->b_blkno; if (bp->b_bcount <= DEV_BSIZE) (*pr)("%ld", (long)sn); diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c index f7793cd..7653506 100644 --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -844,10 +844,10 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) s = splvm(); /* - * Deal with B_FREEBUF + * Deal with BIO_DELETE */ - if (bp->b_flags & B_FREEBUF) { + if (bp->b_iocmd & BIO_DELETE) { /* * FREE PAGE(s) - destroy underlying swap that is no longer * needed. @@ -872,7 +872,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) */ blk = swp_pager_meta_ctl(object, start, 0); - if ((blk == SWAPBLK_NONE) && (bp->b_flags & B_READ) == 0) { + if ((blk == SWAPBLK_NONE) && (bp->b_iocmd == BIO_WRITE)) { blk = swp_pager_getswapspace(1); if (blk == SWAPBLK_NONE) { bp->b_error = ENOMEM; @@ -897,7 +897,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) ) ) { splx(s); - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { ++cnt.v_swapin; cnt.v_swappgsin += btoc(nbp->b_bcount); } else { @@ -925,7 +925,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) bp->b_resid -= PAGE_SIZE; } else { if (nbp == NULL) { - nbp = getchainbuf(bp, swapdev_vp, (bp->b_flags & B_READ) | B_ASYNC); + nbp = getchainbuf(bp, swapdev_vp, (bp->b_iocmd == BIO_READ) | B_ASYNC); nbp->b_blkno = blk; nbp->b_bcount = 0; nbp->b_data = data; @@ -946,7 +946,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp) if (nbp) { if ((bp->b_flags & B_ASYNC) == 0) nbp->b_flags &= ~B_ASYNC; - if (nbp->b_flags & B_READ) { + if (nbp->b_iocmd == BIO_READ) { ++cnt.v_swapin; cnt.v_swappgsin += btoc(nbp->b_bcount); } else { @@ -1086,7 +1086,7 @@ swap_pager_getpages(object, m, count, reqpage) pmap_qenter(kva, m + i, j - i); - bp->b_flags = B_READ | B_CALL; + bp->b_iocmd = BIO_READ; bp->b_iodone = swp_pager_async_iodone; bp->b_rcred = bp->b_wcred = proc0.p_ucred; bp->b_data = (caddr_t) kva; @@ -1329,10 +1329,9 @@ swap_pager_putpages(object, m, count, sync, rtvals) if (sync == TRUE) { bp = getpbuf(&nsw_wcount_sync); - bp->b_flags = B_CALL; } else { bp = getpbuf(&nsw_wcount_async); - bp->b_flags = B_CALL | B_ASYNC; + bp->b_flags = B_ASYNC; } bp->b_spc = NULL; /* not used, but NULL-out anyway */ @@ -1481,7 +1480,7 @@ swp_pager_async_iodone(bp) printf( "swap_pager: I/O error - %s failed; blkno %ld," "size %ld, error %d\n", - ((bp->b_flags & B_READ) ? "pagein" : "pageout"), + ((bp->b_iocmd == BIO_READ) ? "pagein" : "pageout"), (long)bp->b_blkno, (long)bp->b_bcount, bp->b_error @@ -1524,7 +1523,7 @@ swp_pager_async_iodone(bp) * interrupt. */ - if (bp->b_flags & B_READ) { + if (bp->b_iocmd == BIO_READ) { /* * When reading, reqpage needs to stay * locked for the parent, but all other @@ -1566,7 +1565,7 @@ swp_pager_async_iodone(bp) vm_page_activate(m); vm_page_io_finish(m); } - } else if (bp->b_flags & B_READ) { + } else if (bp->b_iocmd == BIO_READ) { /* * For read success, clear dirty bits. Nobody should * have this page mapped but don't take any chances, @@ -1637,7 +1636,7 @@ swp_pager_async_iodone(bp) relpbuf( bp, - ((bp->b_flags & B_READ) ? &nsw_rcount : + ((bp->b_iocmd == BIO_READ) ? &nsw_rcount : ((bp->b_flags & B_ASYNC) ? &nsw_wcount_async : &nsw_wcount_sync diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c index 1bef6df..e3817c5 100644 --- a/sys/vm/vm_pager.c +++ b/sys/vm/vm_pager.c @@ -348,6 +348,7 @@ initpbuf(struct buf *bp) bp->b_kvasize = MAXPHYS; bp->b_xflags = 0; bp->b_flags = 0; + bp->b_iodone = NULL; bp->b_error = 0; BUF_LOCK(bp, LK_EXCLUSIVE); } @@ -546,7 +547,7 @@ getchainbuf(struct buf *bp, struct vnode *vp, int flags) if (bp->b_chain.count > 4) waitchainbuf(bp, 4, 0); - nbp->b_flags = B_CALL | (bp->b_flags & B_ORDERED) | flags; + nbp->b_flags = (bp->b_flags & B_ORDERED) | flags; nbp->b_rcred = nbp->b_wcred = proc0.p_ucred; nbp->b_iodone = vm_pager_chain_iodone; @@ -563,7 +564,7 @@ flushchainbuf(struct buf *nbp) { if (nbp->b_bcount) { nbp->b_bufsize = nbp->b_bcount; - if ((nbp->b_flags & B_READ) == 0) + if (nbp->b_iocmd == BIO_WRITE) nbp->b_dirtyend = nbp->b_bcount; BUF_KERNPROC(nbp); VOP_STRATEGY(nbp->b_vp, nbp); diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c index 0a38aa3..11ca203 100644 --- a/sys/vm/vm_swap.c +++ b/sys/vm/vm_swap.c @@ -137,7 +137,7 @@ swapdev_strategy(ap) vhold(sp->sw_vp); s = splvm(); - if ((bp->b_flags & B_READ) == 0) { + if (bp->b_iocmd == BIO_WRITE) { vp = bp->b_vp; if (vp) { vp->v_numoutput--; diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c index 1ccc692..279f47c 100644 --- a/sys/vm/vnode_pager.c +++ b/sys/vm/vnode_pager.c @@ -411,7 +411,7 @@ vnode_pager_input_smlfs(object, m) bp = getpbuf(&vnode_pbuf_freecnt); /* build a minimal buffer header */ - bp->b_flags = B_READ | B_CALL; + bp->b_iocmd = BIO_READ; bp->b_iodone = vnode_pager_iodone; bp->b_rcred = bp->b_wcred = curproc->p_ucred; if (bp->b_rcred != NOCRED) @@ -729,7 +729,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage) pmap_qenter(kva, m, count); /* build a minimal buffer header */ - bp->b_flags = B_READ | B_CALL; + bp->b_iocmd = BIO_READ; bp->b_iodone = vnode_pager_iodone; /* B_PHYS is not set, but it is nice to fill this in */ bp->b_rcred = bp->b_wcred = curproc->p_ucred; |