Remove B_READ, B_WRITE and B_FREEBUF and replace them with a new

field in struct buf: b_iocmd.  The b_iocmd is enforced to have
exactly one bit set.

B_WRITE was bogusly defined as zero giving rise to obvious coding
mistakes.

Also eliminate the redundant struct buf flag B_CALL, it can just
as efficiently be done by comparing b_iodone to NULL.

Should you get a panic or drop into the debugger, complaining about
"b_iocmd", don't continue.  It is likely to write on your disk
where it should have been reading.

This change is a step in the direction towards a stackable BIO capability.

A lot of this patch were machine generated (Thanks to style(9) compliance!)

Vinum users:  Greg has not had time to test this yet, be careful.
This commit is contained in:
Poul-Henning Kamp 2000-03-20 10:44:49 +00:00
parent 44bdcfa638
commit 21144e3bf1
98 changed files with 392 additions and 350 deletions

View File

@ -1929,7 +1929,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if LABELSECTOR != 0 #if LABELSECTOR != 0
bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
#endif #endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) { (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }
@ -1937,7 +1937,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if defined(DOSBBSECTOR) && defined(notyet) #if defined(DOSBBSECTOR) && defined(notyet)
/* overwriting master boot record? */ /* overwriting master boot record? */
if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && 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; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -319,7 +319,7 @@ vmapbuf(bp)
* when reading stuff off device into memory. * when reading stuff off device into memory.
*/ */
vm_fault_quick(addr, 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)); pa = trunc_page(pmap_kextract((vm_offset_t) addr));
if (pa == 0) if (pa == 0)
panic("vmapbuf: page not present"); panic("vmapbuf: page not present");

View File

@ -153,7 +153,6 @@ ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
ASSYM(B_READ, B_READ);
ASSYM(ENOENT, ENOENT); ASSYM(ENOENT, ENOENT);
ASSYM(EFAULT, EFAULT); ASSYM(EFAULT, EFAULT);
ASSYM(ENAMETOOLONG, ENAMETOOLONG); ASSYM(ENAMETOOLONG, ENAMETOOLONG);

View File

@ -2360,7 +2360,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if LABELSECTOR != 0 #if LABELSECTOR != 0
bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
#endif #endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) { (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }
@ -2368,7 +2368,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if defined(DOSBBSECTOR) && defined(notyet) #if defined(DOSBBSECTOR) && defined(notyet)
/* overwriting master boot record? */ /* overwriting master boot record? */
if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && 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; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -357,7 +357,7 @@ vmapbuf(bp)
* when reading stuff off device into memory. * when reading stuff off device into memory.
*/ */
vm_fault_quick(addr, 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)); pa = trunc_page(pmap_kextract((vm_offset_t) addr));
if (pa == 0) if (pa == 0)
panic("vmapbuf: page not present"); panic("vmapbuf: page not present");

View File

@ -556,7 +556,7 @@ cam_periph_mapmem(union ccb *ccb, struct cam_periph_map_info *mapinfo)
} }
if (dirs[i] & CAM_DIR_OUT) { if (dirs[i] & CAM_DIR_OUT) {
flags[i] = B_WRITE; flags[i] = BIO_WRITE;
if (!useracc(*data_ptrs[i], lengths[i], if (!useracc(*data_ptrs[i], lengths[i],
VM_PROT_READ)) { VM_PROT_READ)) {
printf("cam_periph_mapmem: error, " 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) { if (dirs[i] & CAM_DIR_IN) {
flags[i] |= B_READ; flags[i] = BIO_READ;
if (!useracc(*data_ptrs[i], lengths[i], if (!useracc(*data_ptrs[i], lengths[i],
VM_PROT_WRITE)) { VM_PROT_WRITE)) {
printf("cam_periph_mapmem: error, " 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]; mapinfo->bp[i]->b_bufsize = lengths[i];
/* set the flags */ /* 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 */ /* map the buffer into kernel memory */
vmapbuf(mapinfo->bp[i]); vmapbuf(mapinfo->bp[i]);

View File

@ -1432,7 +1432,7 @@ cdstart(struct cam_periph *periph, union ccb *start_ccb)
(bp->b_flags & B_ORDERED) != 0 ? (bp->b_flags & B_ORDERED) != 0 ?
MSG_ORDERED_Q_TAG : MSG_ORDERED_Q_TAG :
MSG_SIMPLE_Q_TAG, MSG_SIMPLE_Q_TAG,
/* read */bp->b_flags & B_READ, /* read */bp->b_iocmd == BIO_READ,
/* byte2 */ 0, /* byte2 */ 0,
/* minimum_cmd_size */ 10, /* minimum_cmd_size */ 10,
/* lba */ bp->b_pblkno, /* lba */ bp->b_pblkno,

View File

@ -1056,7 +1056,7 @@ dastart(struct cam_periph *periph, union ccb *start_ccb)
/*retries*/4, /*retries*/4,
dadone, dadone,
tag_code, tag_code,
bp->b_flags & B_READ, bp->b_iocmd == BIO_READ,
/*byte2*/0, /*byte2*/0,
softc->minimum_cmd_size, softc->minimum_cmd_size,
bp->b_pblkno, bp->b_pblkno,

View File

@ -539,7 +539,7 @@ ptstart(struct cam_periph *periph, union ccb *start_ccb)
/*retries*/4, /*retries*/4,
ptdone, ptdone,
MSG_SIMPLE_Q_TAG, MSG_SIMPLE_Q_TAG,
bp->b_flags & B_READ, bp->b_iocmd == BIO_READ,
/*byte2*/0, /*byte2*/0,
bp->b_bcount, bp->b_bcount,
bp->b_data, bp->b_data,

View File

@ -710,7 +710,7 @@ sastrategy(struct buf *bp)
CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastrategy: enqueuing a %d " CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("sastrategy: enqueuing a %d "
"%s byte %s queue count now %d\n", (int) bp->b_bcount, "%s byte %s queue count now %d\n", (int) bp->b_bcount,
(softc->flags & SA_FLAG_FIXED)? "fixed" : "variable", (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); splx(s);
@ -1491,7 +1491,7 @@ sastart(struct cam_periph *periph, union ccb *start_ccb)
bp->b_resid = bp->b_bcount; bp->b_resid = bp->b_bcount;
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
if ((softc->flags & SA_FLAG_EOM_PENDING) != 0) { 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; bp->b_error = ENOSPC;
else else
bp->b_error = EIO; 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 * have to do deal with 512 byte or 1KB intermediate
* records. * records.
*/ */
softc->dsreg = (bp->b_flags & B_READ)? softc->dsreg = (bp->b_iocmd == BIO_READ)?
MTIO_DSREG_RD : MTIO_DSREG_WR; MTIO_DSREG_RD : MTIO_DSREG_WR;
scsi_sa_read_write(&start_ccb->csio, 0, sadone, 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, FALSE, (softc->flags & SA_FLAG_FIXED) != 0,
length, bp->b_data, bp->b_bcount, SSD_FULL_SIZE, length, bp->b_data, bp->b_bcount, SSD_FULL_SIZE,
120 * 60 * 1000); 120 * 60 * 1000);
@ -1661,7 +1661,7 @@ sadone(struct cam_periph *periph, union ccb *done_ccb)
if (csio->resid != 0) { if (csio->resid != 0) {
bp->b_flags |= B_ERROR; 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->flags |= SA_FLAG_TAPE_WRITTEN;
softc->filemarks = 0; softc->filemarks = 0;
} }

View File

@ -1165,7 +1165,7 @@ targstrategy(struct buf *bp)
* *
*/ */
bp->b_resid = bp->b_bcount; 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, CAM_DEBUG(periph->path, CAM_DEBUG_PERIPH,
("Queued a SEND buffer\n")); ("Queued a SEND buffer\n"));
bufq_insert_tail(&softc->snd_buf_queue, bp); bufq_insert_tail(&softc->snd_buf_queue, bp);

View File

@ -221,9 +221,9 @@ flastrategy(struct buf *bp)
bp->b_resid = bp->b_bcount; bp->b_resid = bp->b_bcount;
unit = dkunit(bp->b_dev); unit = dkunit(bp->b_dev);
if (bp->b_flags & B_FREEBUF) if (bp->b_iocmd == BIO_DELETE)
what = DOC2K_ERASE; what = DOC2K_ERASE;
else if (bp->b_flags & B_READ) else if (bp->b_iocmd == BIO_READ)
what = DOC2K_READ; what = DOC2K_READ;
else else
what = DOC2K_WRITE; what = DOC2K_WRITE;

View File

@ -2780,7 +2780,7 @@ softdep_disk_io_initiation(bp)
* We only care about write operations. There should never * We only care about write operations. There should never
* be dependencies for reads. * be dependencies for reads.
*/ */
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
panic("softdep_disk_io_initiation: read"); panic("softdep_disk_io_initiation: read");
/* /*
* Do any necessary pre-I/O processing. * Do any necessary pre-I/O processing.

View File

@ -853,7 +853,7 @@ amr_startio(struct amr_softc *sc)
ac->ac_private = bp; ac->ac_private = bp;
ac->ac_data = bp->b_data; ac->ac_data = bp->b_data;
ac->ac_length = bp->b_bcount; ac->ac_length = bp->b_bcount;
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
ac->ac_flags |= AMR_CMD_DATAIN; ac->ac_flags |= AMR_CMD_DATAIN;
cmd = AMR_CMD_LREAD; cmd = AMR_CMD_LREAD;
} else { } else {

View File

@ -337,7 +337,7 @@ ad_start(struct ad_softc *adp)
request->blockaddr = bp->b_pblkno; request->blockaddr = bp->b_pblkno;
request->bytecount = bp->b_bcount; request->bytecount = bp->b_bcount;
request->data = bp->b_data; 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 */ /* remove from drive queue */
bufq_remove(&adp->queue, bp); bufq_remove(&adp->queue, bp);

View File

@ -1107,7 +1107,6 @@ acd_start(struct atapi_softc *atp)
} }
acd_select_slot(cdp); acd_select_slot(cdp);
bzero(ccb, sizeof(ccb)); bzero(ccb, sizeof(ccb));
count = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size; count = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size;
if (bp->b_flags & B_PHYS) if (bp->b_flags & B_PHYS)
@ -1115,7 +1114,7 @@ acd_start(struct atapi_softc *atp)
else else
lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE); 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 transfer goes beyond EOM adjust it to be within limits */
if (lba + count > cdp->info.volsize) { if (lba + count > cdp->info.volsize) {
/* if we are entirely beyond EOM return EOF */ /* if we are entirely beyond EOM return EOF */
@ -1145,8 +1144,8 @@ acd_start(struct atapi_softc *atp)
devstat_start_transaction(cdp->stats); devstat_start_transaction(cdp->stats);
atapi_queue_cmd(cdp->atp, ccb, bp->b_data, count * cdp->block_size, atapi_queue_cmd(cdp->atp, ccb, bp->b_data, bp->b_bcount,
bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, acd_done, bp); (bp->b_iocmd == BIO_READ)?ATPR_F_READ : 0, 30, acd_done, bp);
} }
static int32_t static int32_t
@ -1161,7 +1160,7 @@ acd_done(struct atapi_request *request)
} }
else { else {
bp->b_resid = bp->b_bcount - request->donecount; bp->b_resid = bp->b_bcount - request->donecount;
if (!(bp->b_flags & B_READ)) if (bp->b_iocmd == BIO_WRITE)
cdp->flags |= F_WRITTEN; cdp->flags |= F_WRITTEN;
} }
devstat_end_transaction_buf(cdp->stats, bp); devstat_end_transaction_buf(cdp->stats, bp);

View File

@ -321,7 +321,7 @@ afd_start(struct atapi_softc *atp)
bzero(ccb, sizeof(ccb)); bzero(ccb, sizeof(ccb));
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
ccb[0] = ATAPI_READ_BIG; ccb[0] = ATAPI_READ_BIG;
else else
ccb[0] = ATAPI_WRITE_BIG; ccb[0] = ATAPI_WRITE_BIG;
@ -338,7 +338,7 @@ afd_start(struct atapi_softc *atp)
atapi_queue_cmd(fdp->atp, ccb, data_ptr, atapi_queue_cmd(fdp->atp, ccb, data_ptr,
fdp->transfersize * fdp->cap.sector_size, 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); afd_partial_done, bp);
count -= fdp->transfersize; count -= fdp->transfersize;
@ -354,7 +354,7 @@ afd_start(struct atapi_softc *atp)
ccb[8] = count; ccb[8] = count;
atapi_queue_cmd(fdp->atp, ccb, data_ptr, count * fdp->cap.sector_size, 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 static int32_t

View File

@ -421,7 +421,7 @@ aststrategy(struct buf *bp)
biodone(bp); biodone(bp);
return; 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_error = EPERM;
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
biodone(bp); biodone(bp);
@ -466,7 +466,7 @@ ast_start(struct atapi_softc *atp)
bzero(ccb, sizeof(ccb)); bzero(ccb, sizeof(ccb));
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
ccb[0] = ATAPI_READ; ccb[0] = ATAPI_READ;
else else
ccb[0] = ATAPI_WRITE; ccb[0] = ATAPI_WRITE;
@ -482,7 +482,7 @@ ast_start(struct atapi_softc *atp)
devstat_start_transaction(&stp->stats); devstat_start_transaction(&stp->stats);
atapi_queue_cmd(stp->atp, ccb, bp->b_data, blkcount * stp->blksize, 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 static int32_t
@ -496,7 +496,7 @@ ast_done(struct atapi_request *request)
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
} }
else { else {
if (!(bp->b_flags & B_READ)) if (!(bp->b_iocmd == BIO_READ))
stp->flags |= F_DATA_WRITTEN; stp->flags |= F_DATA_WRITTEN;
bp->b_resid = bp->b_bcount - request->donecount; bp->b_resid = bp->b_bcount - request->donecount;
ast_total += (bp->b_bcount - bp->b_resid); ast_total += (bp->b_bcount - bp->b_resid);

View File

@ -193,7 +193,7 @@ static void ccdattach __P((void));
static int ccd_modevent __P((module_t, int, void *)); static int ccd_modevent __P((module_t, int, void *));
/* called by biodone() at interrupt time */ /* 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 ccdstart __P((struct ccd_softc *, struct buf *));
static void ccdinterleave __P((struct ccd_softc *, int)); static void ccdinterleave __P((struct ccd_softc *, int));
@ -887,7 +887,7 @@ ccdstart(cs, bp)
* to writes when making this determination and we * to writes when making this determination and we
* also try to avoid hogging. * 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[0]->cb_buf.b_vp->v_numoutput++;
cbp[1]->cb_buf.b_vp->v_numoutput++; cbp[1]->cb_buf.b_vp->v_numoutput++;
VOP_STRATEGY(cbp[0]->cb_buf.b_vp, VOP_STRATEGY(cbp[0]->cb_buf.b_vp,
@ -911,7 +911,7 @@ ccdstart(cs, bp)
/* /*
* Not mirroring * 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++; cbp[0]->cb_buf.b_vp->v_numoutput++;
VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf); 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. * Fill in the component buf structure.
*/ */
cbp = getccdbuf(NULL); cbp = getccdbuf(NULL);
cbp->cb_buf.b_flags = bp->b_flags | B_CALL; cbp->cb_buf.b_flags = bp->b_flags;
cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone; 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_dev = ci->ci_dev; /* XXX */
cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET; cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET;
cbp->cb_buf.b_offset = dbtob(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. * take a ccd interrupt.
*/ */
static void static void
ccdiodone(cbp) ccdiodone(ibp)
struct ccdbuf *cbp; struct buf *ibp;
{ {
struct ccdbuf *cbp = (struct ccdbuf *)ibp;
struct buf *bp = cbp->cb_obp; struct buf *bp = cbp->cb_obp;
int unit = cbp->cb_unit; int unit = cbp->cb_unit;
int count, s; int count, s;
@ -1153,7 +1155,7 @@ ccdiodone(cbp)
const char *msg = ""; const char *msg = "";
if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) && 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) { (cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) {
/* /*
* We will try our read on the other disk down * 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 (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 * When writing, handshake with the second buffer
* to determine when both are done. If both are not * to determine when both are done. If both are not

View File

@ -1620,7 +1620,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
{ {
u_char *cptr = (u_char *)addr; u_char *cptr = (u_char *)addr;
if (flags & B_READ) { if (flags == BIO_READ) {
if (fdc->state != PIOREAD) { if (fdc->state != PIOREAD) {
fdc->state = PIOREAD; fdc->state = PIOREAD;
return(0); return(0);
@ -1679,7 +1679,7 @@ fdstate(fdc_p fdc)
fdblk = 128 << fd->ft->secsize; fdblk = 128 << fd->ft->secsize;
if (fdc->fd && (fd != fdc->fd)) if (fdc->fd && (fd != fdc->fd))
device_printf(fd->dev, "confused fd pointers\n"); 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; format = bp->b_flags & B_FORMAT;
if (format) { if (format) {
finfo = (struct fd_formb *)bp->b_data; finfo = (struct fd_formb *)bp->b_data;
@ -1885,7 +1885,7 @@ fdstate(fdc_p fdc)
*/ */
SET_BCDR(fdc, 1, bp->b_bcount, 0); 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_data+fd->skip,
bp->b_bcount); bp->b_bcount);
@ -1918,7 +1918,7 @@ fdstate(fdc_p fdc)
* the WRITE command is sent * the WRITE command is sent
*/ */
if (!read) if (!read)
(void)fdcpio(fdc,bp->b_flags, (void)fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip, bp->b_data+fd->skip,
fdblk); fdblk);
} }
@ -1948,7 +1948,7 @@ fdstate(fdc_p fdc)
* if this is a read, then simply await interrupt * if this is a read, then simply await interrupt
* before performing PIO * before performing PIO
*/ */
if (read && !fdcpio(fdc,bp->b_flags, if (read && !fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,fdblk)) { bp->b_data+fd->skip,fdblk)) {
fd->tohandle = timeout(fd_iotimeout, fdc, hz); fd->tohandle = timeout(fd_iotimeout, fdc, hz);
return(0); /* will return later */ return(0); /* will return later */
@ -1966,7 +1966,7 @@ fdstate(fdc_p fdc)
* actually perform the PIO read. The IOCOMPLETE case * actually perform the PIO read. The IOCOMPLETE case
* removes the timeout for us. * 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; fdc->state = IOCOMPLETE;
/* FALLTHROUGH */ /* FALLTHROUGH */
case IOCOMPLETE: /* IO DONE, post-analyze */ case IOCOMPLETE: /* IO DONE, post-analyze */

View File

@ -404,7 +404,7 @@ ida_construct_qcb(struct ida_softc *ida)
hwqcb->req.blkno = bp->b_pblkno; hwqcb->req.blkno = bp->b_pblkno;
hwqcb->req.bcount = howmany(bp->b_bcount, DEV_BSIZE); 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); STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe);
} }

View File

@ -163,7 +163,7 @@ idstrategy(struct buf *bp)
/* /*
* software write protect check * 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; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -414,7 +414,7 @@ MCD_TRACE("strategy: drive not valid\n");
} }
/* read only */ /* read only */
if (!(bp->b_flags & B_READ)) { if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -191,9 +191,9 @@ mdstrategy_malloc(struct buf *bp)
devstat_start_transaction(&sc->stats); devstat_start_transaction(&sc->stats);
if (bp->b_flags & B_FREEBUF) if (bp->b_iocmd == BIO_DELETE)
dop = DEVSTAT_NO_DATA; dop = DEVSTAT_NO_DATA;
else if (bp->b_flags & B_READ) else if (bp->b_iocmd == BIO_READ)
dop = DEVSTAT_READ; dop = DEVSTAT_READ;
else else
dop = DEVSTAT_WRITE; dop = DEVSTAT_WRITE;
@ -220,13 +220,13 @@ mdstrategy_malloc(struct buf *bp)
if (md_debug > 2) if (md_debug > 2)
printf("%lx %p %p %d\n", bp->b_flags, secpp, secp, secval); 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 (secpp) {
if (secp) if (secp)
FREE(secp, M_MDSECT); FREE(secp, M_MDSECT);
*secpp = 0; *secpp = 0;
} }
} else if (bp->b_flags & B_READ) { } else if (bp->b_iocmd == BIO_READ) {
if (secp) { if (secp) {
bcopy(secp, dst, DEV_BSIZE); bcopy(secp, dst, DEV_BSIZE);
} else if (secval) { } else if (secval) {
@ -316,9 +316,9 @@ mdstrategy_preload(struct buf *bp)
devstat_start_transaction(&sc->stats); devstat_start_transaction(&sc->stats);
if (bp->b_flags & B_FREEBUF) { if (bp->b_iocmd == BIO_DELETE) {
dop = DEVSTAT_NO_DATA; dop = DEVSTAT_NO_DATA;
} else if (bp->b_flags & B_READ) { } else if (bp->b_iocmd == BIO_READ) {
dop = DEVSTAT_READ; dop = DEVSTAT_READ;
bcopy(sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_data, bp->b_bcount); bcopy(sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_data, bp->b_bcount);
} else { } else {

View File

@ -1658,7 +1658,7 @@ mlx_startio(struct mlx_softc *sc)
mc->mc_private = bp; mc->mc_private = bp;
mc->mc_data = bp->b_data; mc->mc_data = bp->b_data;
mc->mc_length = bp->b_bcount; mc->mc_length = bp->b_bcount;
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
mc->mc_flags |= MLX_CMD_DATAIN; mc->mc_flags |= MLX_CMD_DATAIN;
cmd = MLX_CMD_READSG; cmd = MLX_CMD_READSG;
} else { } else {

View File

@ -337,7 +337,7 @@ scdstrategy(struct buf *bp)
} }
/* read only */ /* read only */
if (!(bp->b_flags & B_READ)) { if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -106,7 +106,7 @@ vinum_daemon(void)
log(LOG_WARNING, log(LOG_WARNING,
"vinum: recovering I/O request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n", "vinum: recovering I/O request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq, rq,
rq->bp->b_flags & B_READ ? "Read" : "Write", rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev), major(rq->bp->b_dev),
minor(rq->bp->b_dev), minor(rq->bp->b_dev),
rq->bp->b_blkno, rq->bp->b_blkno,

View File

@ -46,8 +46,8 @@ extern int debug; /* debug flags */
#endif #endif
/* Physical read and write drive */ /* Physical read and write drive */
#define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ) #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, B_WRITE) #define write_drive(a, b, c, d) driveio (a, b, c, d, BIO_WRITE)
#define CHECKALLOC(ptr, msg) \ #define CHECKALLOC(ptr, msg) \
if (ptr == NULL) \ if (ptr == NULL) \

View File

@ -89,7 +89,7 @@ complete_rqe(struct buf *bp)
else if (rq->error == 0) /* no: do we have one already? */ else if (rq->error == 0) /* no: do we have one already? */
rq->error = EIO; /* no: catchall "I/O error" */ rq->error = EIO; /* no: catchall "I/O error" */
SD[rqe->sdno].lasterror = rq->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); 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 */ set_sd_state(rqe->sdno, sd_crashed, setstate_force); /* subdisk is crashed */
} else { /* write operation */ } else { /* write operation */
@ -105,7 +105,7 @@ complete_rqe(struct buf *bp)
} }
} }
/* Now update the statistics */ /* 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].reads++;
DRIVE[rqe->driveno].bytes_read += bp->b_bcount; DRIVE[rqe->driveno].bytes_read += bp->b_bcount;
SD[rqe->sdno].reads++; SD[rqe->sdno].reads++;
@ -226,7 +226,7 @@ sdio_done(struct buf *bp)
#endif #endif
sbp->bp->b_resid = sbp->b.b_resid; /* copy the resid field */ sbp->bp->b_resid = sbp->b.b_resid; /* copy the resid field */
/* Now update the statistics */ /* 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].reads++;
DRIVE[sbp->driveno].bytes_read += sbp->b.b_bcount; DRIVE[sbp->driveno].bytes_read += sbp->b.b_bcount;
SD[sbp->sdno].reads++; SD[sbp->sdno].reads++;
@ -340,11 +340,10 @@ complete_raid5_write(struct rqelement *rqe)
} else } else
panic("complete_raid5_write: malloc conflict"); 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->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_DONE; /* we're writing now */
rqe->b.b_flags |= B_CALL; /* call us when you're done */ rqe->b.b_iodone = complete_rqe; /* call us here when done */
rqe->b.b_iodone = complete_rqe; /* by calling us here */
rqe->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ 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_data = &bp->b_data[rqe->useroffset << DEV_BSHIFT]; /* point to the user data */
rqe->b.b_bcount = rqe->datalen << DEV_BSHIFT; /* length to write */ 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) if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG, log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", " %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), major(rqe->b.b_dev),
minor(rqe->b.b_dev), minor(rqe->b.b_dev),
rqe->sdno, rqe->sdno,
@ -382,9 +381,8 @@ complete_raid5_write(struct rqelement *rqe)
} }
/* Finally, write the parity block */ /* Finally, write the parity block */
rqe = &rqg->rqe[0]; rqe = &rqg->rqe[0];
rqe->b.b_flags &= ~(B_READ | B_DONE); /* we're writing now */ rqe->b.b_flags &= ~B_DONE; /* we're writing now */
rqe->b.b_flags |= B_CALL; /* call us when you're done */ rqe->b.b_iodone = complete_rqe; /* call us here when done */
rqe->b.b_iodone = complete_rqe; /* by calling us here */
rqg->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */ rqg->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */
rqe->b.b_bcount = rqe->buflen << DEV_BSHIFT; /* length to write */ 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 */ 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) if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG, log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", " %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), major(rqe->b.b_dev),
minor(rqe->b.b_dev), minor(rqe->b.b_dev),
rqe->sdno, rqe->sdno,

View File

@ -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 */ int len = min(length, MAXBSIZE); /* maximum block device transfer is MAXBSIZE */
bp = geteblk(len); /* get a buffer header */ 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_dev = drive->dev; /* device */
bp->b_blkno = offset / drive->partinfo.disklab->d_secsize; /* block number */ bp->b_blkno = offset / drive->partinfo.disklab->d_secsize; /* block number */
bp->b_saveaddr = bp->b_data; bp->b_saveaddr = bp->b_data;
@ -754,7 +755,7 @@ write_volume_label(int volno)
dlp = (struct disklabel *) bp->b_data; dlp = (struct disklabel *) bp->b_data;
*dlp = *lp; *dlp = *lp;
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_WRITE; bp->b_iocmd = BIO_WRITE;
/* /*
* This should read: * This should read:

View File

@ -360,7 +360,7 @@ bre5(struct request *rq,
} }
if (SD[plex->sdnos[m.psdno]].state < sd_reborn) /* is our parity subdisk down? */ if (SD[plex->sdnos[m.psdno]].state < sd_reborn) /* is our parity subdisk down? */
m.badsdno = m.psdno; /* note that it's 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++) { for (mysdno = m.firstsdno; rsectors > 0; mysdno++) {
if (mysdno == m.psdno) /* ignore parity on read */ if (mysdno == m.psdno) /* ignore parity on read */
mysdno++; mysdno++;
@ -493,7 +493,7 @@ bre5(struct request *rq,
rqe->driveno = sd->driveno; rqe->driveno = sd->driveno;
if (build_rq_buffer(rqe, plex)) /* build the buffer */ if (build_rq_buffer(rqe, plex)) /* build the buffer */
return REQUEST_ENOMEM; /* can't do it */ 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 */ m.sdcount++; /* adjust the subdisk count */
rqno++; /* and point to the next request */ rqno++; /* and point to the next request */
} }
@ -534,7 +534,7 @@ bre5(struct request *rq,
return REQUEST_ENOMEM; /* can't do it */ return REQUEST_ENOMEM; /* can't do it */
if ((m.flags & XFR_PARITYOP) /* parity operation, */ if ((m.flags & XFR_PARITYOP) /* parity operation, */
&&((m.flags & XFR_BAD_SUBDISK) == 0)) /* and not the bad subdisk, */ &&((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 */ /* Now update pointers for the next block */
*diskaddr += m.datalen; /* skip past what we've done */ *diskaddr += m.datalen; /* skip past what we've done */
@ -577,7 +577,7 @@ bre5(struct request *rq,
rqe->driveno = sd->driveno; rqe->driveno = sd->driveno;
if (build_rq_buffer(rqe, plex)) /* build the buffer */ if (build_rq_buffer(rqe, plex)) /* build the buffer */
return REQUEST_ENOMEM; /* can't do it */ 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 */
} }
} }
/* /*

View File

@ -224,7 +224,7 @@ vinumstart(struct buf *bp, int reviveok)
maxplex = 1; /* just the one plex */ maxplex = 1; /* just the one plex */
} }
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
/* /*
* This is a read request. Decide * This is a read request. Decide
* which plex to read from. * 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", "Revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq->sdno, rq->sdno,
rq, rq,
rq->bp->b_flags & B_READ ? "Read" : "Write", rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev), major(rq->bp->b_dev),
minor(rq->bp->b_dev), minor(rq->bp->b_dev),
rq->bp->b_blkno, rq->bp->b_blkno,
@ -351,7 +351,7 @@ launch_requests(struct request *rq, int reviveok)
log(LOG_DEBUG, log(LOG_DEBUG,
"Request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n", "Request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq, rq,
rq->bp->b_flags & B_READ ? "Read" : "Write", rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev), major(rq->bp->b_dev),
minor(rq->bp->b_dev), minor(rq->bp->b_dev),
rq->bp->b_blkno, rq->bp->b_blkno,
@ -406,7 +406,7 @@ launch_requests(struct request *rq, int reviveok)
if (debug & DEBUG_ADDRESSES) if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG, log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", " %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), major(rqe->b.b_dev),
minor(rqe->b.b_dev), minor(rqe->b.b_dev),
rqe->sdno, rqe->sdno,
@ -505,7 +505,7 @@ bre(struct request *rq,
s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */ s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */
if (s == REQUEST_DOWN) { /* down? */ if (s == REQUEST_DOWN) { /* down? */
rqe->flags = XFR_BAD_SUBDISK; /* yup */ 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 */ return REQUEST_DEGRADED; /* give up here */
/* /*
* If we're writing, don't give up * 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? */ s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */
if (s == REQUEST_DOWN) { /* down? */ if (s == REQUEST_DOWN) { /* down? */
rqe->flags = XFR_BAD_SUBDISK; /* yup */ 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 */ return REQUEST_DEGRADED; /* give up here */
/* /*
* If we're writing, don't give up * 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 */ /* Initialize the buf struct */
/* copy these flags from user bp */ /* copy these flags from user bp */
bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_READ | B_ASYNC); bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_ASYNC);
bp->b_flags |= B_CALL; /* inform us when it's done */ bp->b_iocmd = BIO_READ; /* inform us when it's done */
BUF_LOCKINIT(bp); /* get a lock for the buffer */ BUF_LOCKINIT(bp); /* get a lock for the buffer */
BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */ BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */
@ -891,9 +891,9 @@ sdio(struct buf *bp)
if (drive->state != drive_up) { if (drive->state != drive_up) {
if (sd->state >= sd_crashed) { 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); 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); set_sd_state(sd->sdno, sd_stale, setstate_force);
} }
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
@ -920,7 +920,7 @@ sdio(struct buf *bp)
return; return;
} }
bzero(sbp, sizeof(struct sdbuf)); /* start with nothing */ 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_bufsize = bp->b_bufsize; /* buffer size */
sbp->b.b_bcount = bp->b_bcount; /* number of bytes to transfer */ sbp->b.b_bcount = bp->b_bcount; /* number of bytes to transfer */
sbp->b.b_resid = bp->b_resid; /* and amount waiting */ sbp->b.b_resid = bp->b_resid; /* and amount waiting */
@ -947,7 +947,7 @@ sdio(struct buf *bp)
if (debug & DEBUG_ADDRESSES) if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG, log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n", " %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), major(sbp->b.b_dev),
minor(sbp->b.b_dev), minor(sbp->b.b_dev),
sbp->sdno, sbp->sdno,
@ -992,7 +992,7 @@ vinum_bounds_check(struct buf *bp, struct volume *vol)
&& bp->b_blkno + size > LABELSECTOR /* and finishes after */ && bp->b_blkno + size > LABELSECTOR /* and finishes after */
#endif #endif
&& (!(vol->flags & VF_RAW)) /* and it's not raw */ && (!(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 */ && (!vol->flags & (VF_WLABEL | VF_LABELLING))) { /* and we're not allowed to write the label */
bp->b_error = EROFS; /* read-only */ bp->b_error = EROFS; /* read-only */
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;

View File

@ -170,7 +170,8 @@ revive_block(int sdno)
else /* it's an unattached plex */ else /* it's an unattached plex */
bp->b_dev = VINUM_PLEX(sd->plexno); /* create the device number */ 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); vinumstart(bp, 1);
biowait(bp); biowait(bp);
} }
@ -181,7 +182,8 @@ revive_block(int sdno)
/* Now write to the subdisk */ /* Now write to the subdisk */
{ {
bp->b_dev = VINUM_SD(sdno); /* create the device number */ 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_LOCKINIT(bp); /* get a lock for the buffer */
BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */ BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */
bp->b_resid = bp->b_bcount; 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", "Relaunch revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq->sdno, rq->sdno,
rq, rq,
rq->bp->b_flags & B_READ ? "Read" : "Write", rq->bp->b_flags == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev), major(rq->bp->b_dev),
minor(rq->bp->b_dev), minor(rq->bp->b_dev),
rq->bp->b_blkno, rq->bp->b_blkno,
@ -310,8 +312,7 @@ parityops(struct vinum_ioctl_msg *data, enum parityop op)
} }
} }
} else { /* rebuildparity */ } else { /* rebuildparity */
pbp->b_flags &= ~B_READ; pbp->b_iocmd = BIO_WRITE;
pbp->b_flags |= B_WRITE;
pbp->b_resid = pbp->b_bcount; pbp->b_resid = pbp->b_bcount;
BUF_LOCKINIT(pbp); /* get a lock for the buffer */ BUF_LOCKINIT(pbp); /* get a lock for the buffer */
BUF_LOCK(pbp, LK_EXCLUSIVE); /* and lock it */ BUF_LOCK(pbp, LK_EXCLUSIVE); /* and lock it */
@ -404,7 +405,8 @@ parityrebuild(struct plex *plex,
bzero(parity_buf, mysize); bzero(parity_buf, mysize);
} }
bpp[sdno]->b_dev = VINUM_SD(plex->sdnos[sdno]); /* device number */ 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_bcount = bpp[sdno]->b_bufsize;
bpp[sdno]->b_resid = bpp[sdno]->b_bcount; bpp[sdno]->b_resid = bpp[sdno]->b_bcount;
bpp[sdno]->b_blkno = pstripe; /* read from here */ 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_resid = bp->b_bcount;
bp->b_blkno = sd->initialized; /* read from here */ bp->b_blkno = sd->initialized; /* read from here */
bp->b_dev = VINUM_SD(sdno); /* create the device number */ 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); splx(s);
BUF_LOCKINIT(bp); /* get a lock for the buffer */ BUF_LOCKINIT(bp); /* get a lock for the buffer */
BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */ BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */

View File

@ -617,7 +617,7 @@ enum requeststatus
checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend) checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend)
{ {
struct plex *plex = &PLEX[sd->plexno]; 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) { switch (sd->state) {
/* We shouldn't get called if the subdisk is up */ /* We shouldn't get called if the subdisk is up */

View File

@ -101,7 +101,7 @@ static d_strategy_t vnstrategy;
/* /*
* cdevsw * cdevsw
* D_DISK we want to look like a disk * 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 = { static struct cdevsw vn_cdevsw = {
@ -286,7 +286,7 @@ vnstrategy(struct buf *bp)
unit = dkunit(bp->b_dev); unit = dkunit(bp->b_dev);
vn = bp->b_dev->si_drv1; vn = bp->b_dev->si_drv1;
if (!vn) if (vn == NULL)
vn = vnfindvn(bp->b_dev); vn = vnfindvn(bp->b_dev);
IFOPT(vn, VN_DEBUG) IFOPT(vn, VN_DEBUG)
@ -349,7 +349,7 @@ vnstrategy(struct buf *bp)
bp->b_pblkno = pbn; 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. * Not handled for vnode-backed element yet.
*/ */
@ -368,7 +368,7 @@ vnstrategy(struct buf *bp)
auio.uio_iovcnt = 1; auio.uio_iovcnt = 1;
auio.uio_offset = (vm_ooffset_t)bp->b_pblkno * vn->sc_secsize; auio.uio_offset = (vm_ooffset_t)bp->b_pblkno * vn->sc_secsize;
auio.uio_segflg = UIO_SYSSPACE; auio.uio_segflg = UIO_SYSSPACE;
if( bp->b_flags & B_READ) if(bp->b_iocmd == BIO_READ)
auio.uio_rw = UIO_READ; auio.uio_rw = UIO_READ;
else else
auio.uio_rw = UIO_WRITE; auio.uio_rw = UIO_WRITE;
@ -378,7 +378,7 @@ vnstrategy(struct buf *bp)
isvplocked = 1; isvplocked = 1;
vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc); 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); error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred);
else else
error = VOP_WRITE(vn->sc_vp, &auio, 0, vn->sc_cred); error = VOP_WRITE(vn->sc_vp, &auio, 0, vn->sc_cred);
@ -399,12 +399,12 @@ vnstrategy(struct buf *bp)
* *
* ( handles read, write, freebuf ) * ( 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, KASSERT((bp->b_bufsize & (vn->sc_secsize - 1)) == 0,
("vnstrategy: buffer %p too small for physio", bp)); ("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); biodone(bp);
} else { } else {
vm_pager_strategy(vn->sc_object, bp); vm_pager_strategy(vn->sc_object, bp);

View File

@ -345,7 +345,7 @@ ntfs_strategy(ap)
dprintf(("strategy: bcount: %d flags: 0x%lx\n", dprintf(("strategy: bcount: %d flags: 0x%lx\n",
(u_int32_t)bp->b_bcount,bp->b_flags)); (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; u_int32_t toread;
if (ntfs_cntob(bp->b_blkno) >= fp->f_size) { if (ntfs_cntob(bp->b_blkno) >= fp->f_size) {

View File

@ -275,7 +275,7 @@ nwfs_doio(bp, cr, p)
uiop->uio_iovcnt = 1; uiop->uio_iovcnt = 1;
uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_segflg = UIO_SYSSPACE;
uiop->uio_procp = p; 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_len = uiop->uio_resid = bp->b_bcount;
io.iov_base = bp->b_data; io.iov_base = bp->b_data;
uiop->uio_rw = UIO_READ; uiop->uio_rw = UIO_READ;

View File

@ -812,7 +812,7 @@ static int nwfs_strategy (ap)
p = (struct proc *)0; p = (struct proc *)0;
else else
p = curproc; /* XXX */ p = curproc; /* XXX */
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
cr = bp->b_rcred; cr = bp->b_rcred;
else else
cr = bp->b_wcred; cr = bp->b_wcred;

View File

@ -407,7 +407,7 @@ spec_strategy(ap)
struct mount *mp; struct mount *mp;
bp = ap->a_bp; 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) (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
(*bioops.io_start)(bp); (*bioops.io_start)(bp);
@ -417,7 +417,7 @@ spec_strategy(ap)
*/ */
vp = ap->a_vp; vp = ap->a_vp;
if (vn_isdisk(vp, NULL) && (mp = vp->v_specmountpoint) != NULL) { 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) if (bp->b_lock.lk_lockholder == LK_KERNPROC)
mp->mnt_stat.f_asyncwrites++; mp->mnt_stat.f_asyncwrites++;
else else
@ -458,7 +458,7 @@ spec_freeblks(ap)
if ((bsw->d_flags & D_CANFREE) == 0) if ((bsw->d_flags & D_CANFREE) == 0)
return (0); return (0);
bp = geteblk(ap->a_length); 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_dev = ap->a_vp->v_rdev;
bp->b_blkno = ap->a_addr; bp->b_blkno = ap->a_addr;
bp->b_offset = dbtob(ap->a_addr); bp->b_offset = dbtob(ap->a_addr);
@ -657,7 +657,7 @@ spec_getpages(ap)
pmap_qenter(kva, ap->a_m, pcount); pmap_qenter(kva, ap->a_m, pcount);
/* Build a minimal buffer header. */ /* Build a minimal buffer header. */
bp->b_flags = B_READ | B_CALL; bp->b_iocmd = BIO_READ;
bp->b_iodone = spec_getpages_iodone; bp->b_iodone = spec_getpages_iodone;
/* B_PHYS is not set, but it is nice to fill this in. */ /* B_PHYS is not set, but it is nice to fill this in. */

View File

@ -1923,7 +1923,7 @@ union_strategy(ap)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (othervp == NULLVP) if (othervp == NULLVP)
panic("union_strategy: nil vp"); panic("union_strategy: nil vp");
if (((bp->b_flags & B_READ) == 0) && if ((bp->b_iocmd == BIO_WRITE) &&
(othervp == LOWERVP(bp->b_vp))) (othervp == LOWERVP(bp->b_vp)))
panic("union_strategy: writing to lowervp"); panic("union_strategy: writing to lowervp");
#endif #endif

View File

@ -193,7 +193,7 @@ static void ccdattach __P((void));
static int ccd_modevent __P((module_t, int, void *)); static int ccd_modevent __P((module_t, int, void *));
/* called by biodone() at interrupt time */ /* 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 ccdstart __P((struct ccd_softc *, struct buf *));
static void ccdinterleave __P((struct ccd_softc *, int)); static void ccdinterleave __P((struct ccd_softc *, int));
@ -887,7 +887,7 @@ ccdstart(cs, bp)
* to writes when making this determination and we * to writes when making this determination and we
* also try to avoid hogging. * 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[0]->cb_buf.b_vp->v_numoutput++;
cbp[1]->cb_buf.b_vp->v_numoutput++; cbp[1]->cb_buf.b_vp->v_numoutput++;
VOP_STRATEGY(cbp[0]->cb_buf.b_vp, VOP_STRATEGY(cbp[0]->cb_buf.b_vp,
@ -911,7 +911,7 @@ ccdstart(cs, bp)
/* /*
* Not mirroring * 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++; cbp[0]->cb_buf.b_vp->v_numoutput++;
VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf); 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. * Fill in the component buf structure.
*/ */
cbp = getccdbuf(NULL); cbp = getccdbuf(NULL);
cbp->cb_buf.b_flags = bp->b_flags | B_CALL; cbp->cb_buf.b_flags = bp->b_flags;
cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone; 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_dev = ci->ci_dev; /* XXX */
cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET; cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET;
cbp->cb_buf.b_offset = dbtob(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. * take a ccd interrupt.
*/ */
static void static void
ccdiodone(cbp) ccdiodone(ibp)
struct ccdbuf *cbp; struct buf *ibp;
{ {
struct ccdbuf *cbp = (struct ccdbuf *)ibp;
struct buf *bp = cbp->cb_obp; struct buf *bp = cbp->cb_obp;
int unit = cbp->cb_unit; int unit = cbp->cb_unit;
int count, s; int count, s;
@ -1153,7 +1155,7 @@ ccdiodone(cbp)
const char *msg = ""; const char *msg = "";
if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) && 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) { (cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) {
/* /*
* We will try our read on the other disk down * 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 (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 * When writing, handshake with the second buffer
* to determine when both are done. If both are not * to determine when both are done. If both are not

View File

@ -192,7 +192,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
panic("ufs_bmaparray: indirect block not in cache"); panic("ufs_bmaparray: indirect block not in cache");
#endif #endif
bp->b_blkno = blkptrtodb(ump, daddr); bp->b_blkno = blkptrtodb(ump, daddr);
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
bp->b_flags &= ~(B_INVAL|B_ERROR); bp->b_flags &= ~(B_INVAL|B_ERROR);
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
VOP_STRATEGY(bp->b_vp, bp); VOP_STRATEGY(bp->b_vp, bp);

View File

@ -37,6 +37,8 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93 * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93
*
* $FreeBSD$
*/ */
#include "opt_quota.h" #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); bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0);
if (bp->b_flags & (B_DONE | B_DELWRI)) { if (bp->b_flags & (B_DONE | B_DELWRI)) {
} else { } else {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
if (bp->b_bcount > bp->b_bufsize) if (bp->b_bcount > bp->b_bufsize)
panic("ext2_indirtrunc: bad buffer size"); panic("ext2_indirtrunc: bad buffer size");
bp->b_blkno = dbn; bp->b_blkno = dbn;

View File

@ -192,7 +192,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
panic("ufs_bmaparray: indirect block not in cache"); panic("ufs_bmaparray: indirect block not in cache");
#endif #endif
bp->b_blkno = blkptrtodb(ump, daddr); bp->b_blkno = blkptrtodb(ump, daddr);
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
bp->b_flags &= ~(B_INVAL|B_ERROR); bp->b_flags &= ~(B_INVAL|B_ERROR);
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
VOP_STRATEGY(bp->b_vp, bp); VOP_STRATEGY(bp->b_vp, bp);

View File

@ -37,6 +37,8 @@
* SUCH DAMAGE. * SUCH DAMAGE.
* *
* @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93 * @(#)ext2_inode.c 8.5 (Berkeley) 12/30/93
*
* $FreeBSD$
*/ */
#include "opt_quota.h" #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); bp = getblk(vp, lbn, (int)fs->s_blocksize, 0, 0);
if (bp->b_flags & (B_DONE | B_DELWRI)) { if (bp->b_flags & (B_DONE | B_DELWRI)) {
} else { } else {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
if (bp->b_bcount > bp->b_bufsize) if (bp->b_bcount > bp->b_bufsize)
panic("ext2_indirtrunc: bad buffer size"); panic("ext2_indirtrunc: bad buffer size");
bp->b_blkno = dbn; bp->b_blkno = dbn;

View File

@ -153,7 +153,6 @@ ASSYM(SC_GS, offsetof(struct osigcontext, sc_gs));
ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno)); ASSYM(SC_TRAPNO, offsetof(struct osigcontext, sc_trapno));
ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags)); ASSYM(UC_EFLAGS, offsetof(ucontext_t, uc_mcontext.mc_eflags));
ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs)); ASSYM(UC_GS, offsetof(ucontext_t, uc_mcontext.mc_gs));
ASSYM(B_READ, B_READ);
ASSYM(ENOENT, ENOENT); ASSYM(ENOENT, ENOENT);
ASSYM(EFAULT, EFAULT); ASSYM(EFAULT, EFAULT);
ASSYM(ENAMETOOLONG, ENAMETOOLONG); ASSYM(ENAMETOOLONG, ENAMETOOLONG);

View File

@ -2360,7 +2360,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if LABELSECTOR != 0 #if LABELSECTOR != 0
bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
#endif #endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) { (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }
@ -2368,7 +2368,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if defined(DOSBBSECTOR) && defined(notyet) #if defined(DOSBBSECTOR) && defined(notyet)
/* overwriting master boot record? */ /* overwriting master boot record? */
if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && 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; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -357,7 +357,7 @@ vmapbuf(bp)
* when reading stuff off device into memory. * when reading stuff off device into memory.
*/ */
vm_fault_quick(addr, 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)); pa = trunc_page(pmap_kextract((vm_offset_t) addr));
if (pa == 0) if (pa == 0)
panic("vmapbuf: page not present"); panic("vmapbuf: page not present");

View File

@ -992,7 +992,7 @@ labpcstrategy(struct buf *bp)
struct ctlr *ctlr = labpcs[UNIT(bp->b_dev)]; struct ctlr *ctlr = labpcs[UNIT(bp->b_dev)];
if (DIGITAL(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->starter = null_start;
ctlr->stop = all_stop; ctlr->stop = all_stop;
ctlr->intr = null_intr; ctlr->intr = null_intr;
@ -1007,7 +1007,7 @@ labpcstrategy(struct buf *bp)
} }
} }
else { else {
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
ctlr->starter = INTERVAL(ctlr->dev) ? ad_interval_start : ad_start; ctlr->starter = INTERVAL(ctlr->dev) ? ad_interval_start : ad_start;
ctlr->stop = all_stop; ctlr->stop = all_stop;

View File

@ -876,7 +876,7 @@ void matcdstrategy(struct buf *bp)
goto bad; goto bad;
} }
if (!(bp->b_flags & B_READ)) { if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -414,7 +414,7 @@ MCD_TRACE("strategy: drive not valid\n");
} }
/* read only */ /* read only */
if (!(bp->b_flags & B_READ)) { if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -337,7 +337,7 @@ scdstrategy(struct buf *bp)
} }
/* read only */ /* read only */
if (!(bp->b_flags & B_READ)) { if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -700,7 +700,7 @@ wdstart(int ctrlr)
#ifdef WDDEBUG #ifdef WDDEBUG
if (du->dk_skip == 0) if (du->dk_skip == 0)
printf("wd%d: wdstart: %s %d@%d; map ", lunit, 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); bp->b_bcount, blknum);
else else
printf(" %d)%x", du->dk_skip, inb(du->dk_altport)); 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 * XXX this looks like an attempt to skip bad sectors
* on write. * 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; du->dk_bc += DEV_BSIZE;
count1 = howmany( du->dk_bc, DEV_BSIZE); count1 = howmany( du->dk_bc, DEV_BSIZE);
@ -742,7 +742,7 @@ wdstart(int ctrlr)
du->dk_flags &= ~DKFL_MULTI; du->dk_flags &= ~DKFL_MULTI;
if (du->dk_flags & DKFL_SINGLE) { if (du->dk_flags & DKFL_SINGLE) {
command = (bp->b_flags & B_READ) command = (bp->b_iocmd == BIO_READ)
? WDCC_READ : WDCC_WRITE; ? WDCC_READ : WDCC_WRITE;
count1 = 1; count1 = 1;
du->dk_currentiosize = 1; du->dk_currentiosize = 1;
@ -752,16 +752,16 @@ wdstart(int ctrlr)
(void *)((int)bp->b_data + (void *)((int)bp->b_data +
du->dk_skip * DEV_BSIZE), du->dk_skip * DEV_BSIZE),
du->dk_bc, du->dk_bc,
bp->b_flags & B_READ)) { bp->b_iocmd == BIO_READ)) {
du->dk_flags |= DKFL_DMA; du->dk_flags |= DKFL_DMA;
if( bp->b_flags & B_READ) if(bp->b_iocmd == BIO_READ)
command = WDCC_READ_DMA; command = WDCC_READ_DMA;
else else
command = WDCC_WRITE_DMA; command = WDCC_WRITE_DMA;
du->dk_currentiosize = count1; du->dk_currentiosize = count1;
} else if( (count1 > 1) && (du->dk_multi > 1)) { } else if( (count1 > 1) && (du->dk_multi > 1)) {
du->dk_flags |= DKFL_MULTI; du->dk_flags |= DKFL_MULTI;
if( bp->b_flags & B_READ) { if(bp->b_iocmd == BIO_READ) {
command = WDCC_READ_MULTI; command = WDCC_READ_MULTI;
} else { } else {
command = WDCC_WRITE_MULTI; command = WDCC_WRITE_MULTI;
@ -770,7 +770,7 @@ wdstart(int ctrlr)
if( du->dk_currentiosize > count1) if( du->dk_currentiosize > count1)
du->dk_currentiosize = count1; du->dk_currentiosize = count1;
} else { } else {
if( bp->b_flags & B_READ) { if(bp->b_iocmd == BIO_READ) {
command = WDCC_READ; command = WDCC_READ;
} else { } else {
command = WDCC_WRITE; command = WDCC_WRITE;
@ -797,7 +797,7 @@ wdstart(int ctrlr)
(void *)((int)bp->b_data + (void *)((int)bp->b_data +
du->dk_skip * DEV_BSIZE), du->dk_skip * DEV_BSIZE),
du->dk_bc, du->dk_bc,
bp->b_flags & B_READ); bp->b_iocmd == BIO_READ);
} }
while (wdcommand(du, cylin, head, sector, count1, command) while (wdcommand(du, cylin, head, sector, count1, command)
!= 0) { != 0) {
@ -842,7 +842,7 @@ wdstart(int ctrlr)
} }
/* If this is a read operation, just go away until it's done. */ /* 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; return;
/* Ready to send data? */ /* Ready to send data? */
@ -1010,7 +1010,7 @@ oops:
/* /*
* If this was a successful read operation, fetch the data. * 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) && !((du->dk_flags & (DKFL_DMA|DKFL_SINGLE)) == DKFL_DMA)
&& wdtab[unit].b_active) { && wdtab[unit].b_active) {
u_int chk, dummy, multisize; u_int chk, dummy, multisize;
@ -1074,7 +1074,7 @@ outt:
/* see if more to transfer */ /* see if more to transfer */
if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) { if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) {
if( (du->dk_flags & DKFL_SINGLE) || if( (du->dk_flags & DKFL_SINGLE) ||
((bp->b_flags & B_READ) == 0)) { (bp->b_iocmd == BIO_WRITE)) {
wdtab[unit].b_active = 0; wdtab[unit].b_active = 0;
wdstart(unit); wdstart(unit);
} else { } else {

View File

@ -527,7 +527,7 @@ wtstrategy (struct buf *bp)
goto err2xit; goto err2xit;
} }
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
/* Check read access and no previous write to this tape. */ /* Check read access and no previous write to this tape. */
if (! (t->flags & TPREAD) || (t->flags & TPWANY)) if (! (t->flags & TPREAD) || (t->flags & TPWANY))
goto errxit; goto errxit;
@ -566,8 +566,9 @@ wtstrategy (struct buf *bp)
t->flags &= ~TPEXCEP; t->flags &= ~TPEXCEP;
s = splbio (); s = splbio ();
if (wtstart (t, bp->b_flags & B_READ ? ISADMA_READ : ISADMA_WRITE, bp->b_data, bp->b_bcount)) { if (wtstart (t, bp->b_iocmd == BIO_READ ? ISADMA_READ : ISADMA_WRITE,
wtwait (t, 0, (bp->b_flags & B_READ) ? "wtread" : "wtwrite"); bp->b_data, bp->b_bcount)) {
wtwait (t, 0, (bp->b_iocmd == BIO_READ) ? "wtread" : "wtwrite");
bp->b_resid -= t->dmacount; bp->b_resid -= t->dmacount;
} }
splx (s); splx (s);

View File

@ -1620,7 +1620,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
{ {
u_char *cptr = (u_char *)addr; u_char *cptr = (u_char *)addr;
if (flags & B_READ) { if (flags == BIO_READ) {
if (fdc->state != PIOREAD) { if (fdc->state != PIOREAD) {
fdc->state = PIOREAD; fdc->state = PIOREAD;
return(0); return(0);
@ -1679,7 +1679,7 @@ fdstate(fdc_p fdc)
fdblk = 128 << fd->ft->secsize; fdblk = 128 << fd->ft->secsize;
if (fdc->fd && (fd != fdc->fd)) if (fdc->fd && (fd != fdc->fd))
device_printf(fd->dev, "confused fd pointers\n"); 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; format = bp->b_flags & B_FORMAT;
if (format) { if (format) {
finfo = (struct fd_formb *)bp->b_data; finfo = (struct fd_formb *)bp->b_data;
@ -1885,7 +1885,7 @@ fdstate(fdc_p fdc)
*/ */
SET_BCDR(fdc, 1, bp->b_bcount, 0); 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_data+fd->skip,
bp->b_bcount); bp->b_bcount);
@ -1918,7 +1918,7 @@ fdstate(fdc_p fdc)
* the WRITE command is sent * the WRITE command is sent
*/ */
if (!read) if (!read)
(void)fdcpio(fdc,bp->b_flags, (void)fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip, bp->b_data+fd->skip,
fdblk); fdblk);
} }
@ -1948,7 +1948,7 @@ fdstate(fdc_p fdc)
* if this is a read, then simply await interrupt * if this is a read, then simply await interrupt
* before performing PIO * before performing PIO
*/ */
if (read && !fdcpio(fdc,bp->b_flags, if (read && !fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,fdblk)) { bp->b_data+fd->skip,fdblk)) {
fd->tohandle = timeout(fd_iotimeout, fdc, hz); fd->tohandle = timeout(fd_iotimeout, fdc, hz);
return(0); /* will return later */ return(0); /* will return later */
@ -1966,7 +1966,7 @@ fdstate(fdc_p fdc)
* actually perform the PIO read. The IOCOMPLETE case * actually perform the PIO read. The IOCOMPLETE case
* removes the timeout for us. * 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; fdc->state = IOCOMPLETE;
/* FALLTHROUGH */ /* FALLTHROUGH */
case IOCOMPLETE: /* IO DONE, post-analyze */ case IOCOMPLETE: /* IO DONE, post-analyze */

View File

@ -33,7 +33,6 @@ static void
physwakeup(struct buf *bp) physwakeup(struct buf *bp)
{ {
wakeup((caddr_t) bp); wakeup((caddr_t) bp);
bp->b_flags &= ~B_CALL;
} }
int int
@ -63,10 +62,11 @@ physio(dev_t dev, struct uio *uio, int ioflag)
for (i = 0; i < uio->uio_iovcnt; i++) { for (i = 0; i < uio->uio_iovcnt; i++) {
while (uio->uio_iov[i].iov_len) { while (uio->uio_iov[i].iov_len) {
bp->b_flags = B_PHYS;
if (uio->uio_rw == UIO_READ) if (uio->uio_rw == UIO_READ)
bp->b_flags = B_PHYS | B_CALL | B_READ; bp->b_iocmd = BIO_READ;
else else
bp->b_flags = B_PHYS | B_CALL | B_WRITE; bp->b_iocmd = BIO_WRITE;
bp->b_dev = dev; bp->b_dev = dev;
bp->b_iodone = physwakeup; bp->b_iodone = physwakeup;
bp->b_data = uio->uio_iov[i].iov_base; 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 (uio->uio_segflg == UIO_USERSPACE) {
if (!useracc(bp->b_data, bp->b_bufsize, if (!useracc(bp->b_data, bp->b_bufsize,
bp->b_flags & B_READ ? bp->b_iocmd == BIO_READ ?
VM_PROT_WRITE : VM_PROT_READ)) { VM_PROT_WRITE : VM_PROT_READ)) {
error = EFAULT; error = EFAULT;
goto doerror; goto doerror;

View File

@ -233,9 +233,9 @@ devstat_end_transaction_buf(struct devstat *ds, struct buf *bp)
{ {
devstat_trans_flags flg; devstat_trans_flags flg;
if (bp->b_flags & B_FREEBUF) if (bp->b_iocmd == BIO_DELETE)
flg = DEVSTAT_FREE; flg = DEVSTAT_FREE;
else if (bp->b_flags & B_READ) else if (bp->b_iocmd == BIO_READ)
flg = DEVSTAT_READ; flg = DEVSTAT_READ;
else else
flg = DEVSTAT_WRITE; flg = DEVSTAT_WRITE;

View File

@ -181,7 +181,7 @@ readdisklabel(dev, lp)
bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE);
bp->b_bcount = lp->d_secsize; bp->b_bcount = lp->d_secsize;
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
if (biowait(bp)) if (biowait(bp))
msg = "I/O error"; msg = "I/O error";
@ -284,7 +284,7 @@ writedisklabel(dev, lp)
* (also stupid.. how do you write the first one? by raw writes?) * (also stupid.. how do you write the first one? by raw writes?)
*/ */
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
error = biowait(bp); error = biowait(bp);
if (error) if (error)
@ -296,8 +296,8 @@ writedisklabel(dev, lp)
if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
dkcksum(dlp) == 0) { dkcksum(dlp) == 0) {
*dlp = *lp; *dlp = *lp;
bp->b_flags &= ~(B_DONE | B_READ); bp->b_flags &= ~B_DONE;
bp->b_flags |= B_WRITE; bp->b_iocmd = BIO_WRITE;
#ifdef __alpha__ #ifdef __alpha__
alpha_fix_srm_checksum(bp); alpha_fix_srm_checksum(bp);
#endif #endif
@ -313,7 +313,7 @@ done:
dlp = (struct disklabel *)bp->b_data; dlp = (struct disklabel *)bp->b_data;
*dlp = *lp; *dlp = *lp;
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_WRITE; bp->b_iocmd = BIO_WRITE;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
error = biowait(bp); error = biowait(bp);
#endif #endif
@ -375,7 +375,7 @@ diskerr(bp, what, pri, blkdone, lp)
pr = printf; pr = printf;
sname = dsname(bp->b_dev, unit, slice, part, partname); sname = dsname(bp->b_dev, unit, slice, part, partname);
(*pr)("%s%s: %s %sing fsbn ", sname, partname, what, (*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; sn = bp->b_blkno;
if (bp->b_bcount <= DEV_BSIZE) if (bp->b_bcount <= DEV_BSIZE)
(*pr)("%ld", (long)sn); (*pr)("%ld", (long)sn);

View File

@ -187,7 +187,7 @@ reread_mbr:
bp->b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART); bp->b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
bp->b_blkno = mbr_offset; bp->b_blkno = mbr_offset;
bp->b_bcount = lp->d_secsize; bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
if (biowait(bp) != 0) { if (biowait(bp) != 0) {
diskerr(bp, "reading primary partition table: error", 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_dev = dev;
bp->b_blkno = ext_offset; bp->b_blkno = ext_offset;
bp->b_bcount = lp->d_secsize; bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
if (biowait(bp) != 0) { if (biowait(bp) != 0) {
diskerr(bp, "reading extended partition table: error", diskerr(bp, "reading extended partition table: error",

View File

@ -208,14 +208,14 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()");
#if LABELSECTOR != 0 #if LABELSECTOR != 0
slicerel_secno + nsec > LABELSECTOR + labelsect && slicerel_secno + nsec > LABELSECTOR + labelsect &&
#endif #endif
(bp->b_flags & B_READ) == 0 && sp->ds_wlabel == 0) { (bp->b_iocmd == BIO_WRITE) && sp->ds_wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }
#if defined(DOSBBSECTOR) && defined(notyet) #if defined(DOSBBSECTOR) && defined(notyet)
/* overwriting master boot record? */ /* 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) { sp->ds_wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
@ -259,10 +259,9 @@ if (labelsect != 0) Debugger("labelsect != 0 in dscheck()");
ic->ic_args[0].ia_long = (LABELSECTOR + labelsect - ic->ic_args[0].ia_long = (LABELSECTOR + labelsect -
slicerel_secno) * ssp->dss_secsize; slicerel_secno) * ssp->dss_secsize;
ic->ic_args[1].ia_ptr = sp; ic->ic_args[1].ia_ptr = sp;
bp->b_flags |= B_CALL;
bp->b_iodone = dsiodone; bp->b_iodone = dsiodone;
bp->b_iodone_chain = ic; 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 * XXX even disklabel(8) writes directly so we need
* to adjust writes. Perhaps we should drop support * to adjust writes. Perhaps we should drop support
@ -537,11 +536,10 @@ dsiodone(bp)
char *msg; char *msg;
ic = bp->b_iodone_chain; ic = bp->b_iodone_chain;
bp->b_flags = (ic->ic_prev_flags & B_CALL) bp->b_flags = bp->b_flags & ~B_DONE;
| (bp->b_flags & ~(B_CALL | B_DONE));
bp->b_iodone = ic->ic_prev_iodone; bp->b_iodone = ic->ic_prev_iodone;
bp->b_iodone_chain = ic->ic_prev_iodone_chain; 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)) { || (!(bp->b_flags & B_ERROR) && bp->b_error == 0)) {
msg = fixlabel((char *)NULL, ic->ic_args[1].ia_ptr, msg = fixlabel((char *)NULL, ic->ic_args[1].ia_ptr,
(struct disklabel *) (struct disklabel *)

View File

@ -996,20 +996,20 @@ aio_qphysio(struct proc *p, struct aiocblist *aiocbe)
bp->b_bcount = cb->aio_nbytes; bp->b_bcount = cb->aio_nbytes;
bp->b_bufsize = 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_iodone = aio_physwakeup;
bp->b_saveaddr = bp->b_data; bp->b_saveaddr = bp->b_data;
bp->b_data = (void *)cb->aio_buf; bp->b_data = (void *)cb->aio_buf;
bp->b_blkno = btodb(cb->aio_offset); bp->b_blkno = btodb(cb->aio_offset);
if (cb->aio_lio_opcode == LIO_WRITE) { 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)) { if (!useracc(bp->b_data, bp->b_bufsize, VM_PROT_READ)) {
error = EFAULT; error = EFAULT;
goto doerror; goto doerror;
} }
} else { } else {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
if (!useracc(bp->b_data, bp->b_bufsize, VM_PROT_WRITE)) { if (!useracc(bp->b_data, bp->b_bufsize, VM_PROT_WRITE)) {
error = EFAULT; error = EFAULT;
goto doerror; goto doerror;
@ -2132,7 +2132,6 @@ aio_physwakeup(struct buf *bp)
s = splbio(); s = splbio();
wakeup((caddr_t)bp); wakeup((caddr_t)bp);
bp->b_flags &= ~B_CALL;
bp->b_flags |= B_DONE; bp->b_flags |= B_DONE;
aiocbe = (struct aiocblist *)bp->b_spc; aiocbe = (struct aiocblist *)bp->b_spc;

View File

@ -501,7 +501,7 @@ bread(struct vnode * vp, daddr_t blkno, int size, struct ucred * cred,
if (curproc != NULL) if (curproc != NULL)
curproc->p_stats->p_ru.ru_inblock++; curproc->p_stats->p_ru.ru_inblock++;
KASSERT(!(bp->b_flags & B_ASYNC), ("bread: illegal async bp %p", bp)); 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); bp->b_flags &= ~(B_ERROR | B_INVAL);
if (bp->b_rcred == NOCRED) { if (bp->b_rcred == NOCRED) {
if (cred != 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 ((bp->b_flags & B_CACHE) == 0) {
if (curproc != NULL) if (curproc != NULL)
curproc->p_stats->p_ru.ru_inblock++; curproc->p_stats->p_ru.ru_inblock++;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
bp->b_flags &= ~(B_ERROR | B_INVAL); bp->b_flags &= ~(B_ERROR | B_INVAL);
if (bp->b_rcred == NOCRED) { if (bp->b_rcred == NOCRED) {
if (cred != 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 ((rabp->b_flags & B_CACHE) == 0) {
if (curproc != NULL) if (curproc != NULL)
curproc->p_stats->p_ru.ru_inblock++; 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_flags &= ~(B_ERROR | B_INVAL);
rabp->b_iocmd = BIO_READ;
if (rabp->b_rcred == NOCRED) { if (rabp->b_rcred == NOCRED) {
if (cred != NOCRED) if (cred != NOCRED)
crhold(cred); crhold(cred);
@ -630,8 +631,10 @@ bwrite(struct buf * bp)
* copy so as to leave this buffer ready for further use. * 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_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"); panic("bwrite: need chained iodone");
}
/* get a new block */ /* get a new block */
newbp = geteblk(bp->b_bufsize); newbp = geteblk(bp->b_bufsize);
@ -643,7 +646,7 @@ bwrite(struct buf * bp)
newbp->b_blkno = bp->b_blkno; newbp->b_blkno = bp->b_blkno;
newbp->b_offset = bp->b_offset; newbp->b_offset = bp->b_offset;
newbp->b_iodone = vfs_backgroundwritedone; newbp->b_iodone = vfs_backgroundwritedone;
newbp->b_flags |= B_ASYNC | B_CALL; newbp->b_flags |= B_ASYNC;
newbp->b_flags &= ~B_INVAL; newbp->b_flags &= ~B_INVAL;
/* move over the dependencies */ /* move over the dependencies */
@ -664,8 +667,9 @@ bwrite(struct buf * bp)
bp = newbp; 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_flags |= B_WRITEINPROG | B_CACHE;
bp->b_iocmd = BIO_WRITE;
bp->b_vp->v_numoutput++; bp->b_vp->v_numoutput++;
vfs_busy_pages(bp, 1); vfs_busy_pages(bp, 1);
@ -726,11 +730,12 @@ vfs_backgroundwritedone(bp)
} }
/* /*
* This buffer is marked B_NOCACHE, so when it is released * 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. * to avoid biodone doing a second vwakeup.
*/ */
bp->b_flags |= B_NOCACHE | B_READ; bp->b_flags |= B_NOCACHE;
bp->b_flags &= ~(B_CACHE | B_CALL | B_DONE); bp->b_iocmd = BIO_READ;
bp->b_flags &= ~(B_CACHE | B_DONE);
bp->b_iodone = 0; bp->b_iodone = 0;
biodone(bp); biodone(bp);
} }
@ -806,7 +811,7 @@ bdwrite(struct buf * bp)
/* /*
* bdirty: * 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 * 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 * itself to properly update it in the dirty/clean lists. We mark it
* B_DONE to ensure that any asynchronization of the buffer properly * B_DONE to ensure that any asynchronization of the buffer properly
@ -827,7 +832,8 @@ bdirty(bp)
struct buf *bp; struct buf *bp;
{ {
KASSERT(bp->b_qindex == QUEUE_NONE, ("bdirty: buffer %p still on queue %d", bp, bp->b_qindex)); 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) { if ((bp->b_flags & B_DELWRI) == 0) {
bp->b_flags |= B_DONE | B_DELWRI; bp->b_flags |= B_DONE | B_DELWRI;
@ -946,7 +952,8 @@ brelse(struct buf * bp)
if (bp->b_flags & B_LOCKED) if (bp->b_flags & B_LOCKED)
bp->b_flags &= ~B_ERROR; 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 * Failed write, redirty. Must clear B_ERROR to prevent
* pages from being scrapped. If B_INVAL is set then * pages from being scrapped. If B_INVAL is set then
@ -956,8 +963,8 @@ brelse(struct buf * bp)
*/ */
bp->b_flags &= ~B_ERROR; bp->b_flags &= ~B_ERROR;
bdirty(bp); bdirty(bp);
} else if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR | B_FREEBUF)) || } else if ((bp->b_flags & (B_NOCACHE | B_INVAL | B_ERROR)) ||
(bp->b_bufsize <= 0)) { bp->b_iocmd == BIO_DELETE || (bp->b_bufsize <= 0)) {
/* /*
* Either a failed I/O or we were asked to free or not * Either a failed I/O or we were asked to free or not
* cache the buffer. * cache the buffer.
@ -969,7 +976,7 @@ brelse(struct buf * bp)
--numdirtybuffers; --numdirtybuffers;
numdirtywakeup(); 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_flags & B_VMIO) == 0) {
if (bp->b_bufsize) if (bp->b_bufsize)
allocbuf(bp, 0); allocbuf(bp, 0);
@ -2632,7 +2639,7 @@ biowait(register struct buf * bp)
#if defined(NO_SCHEDULE_MODS) #if defined(NO_SCHEDULE_MODS)
tsleep(bp, PRIBIO, "biowait", 0); tsleep(bp, PRIBIO, "biowait", 0);
#else #else
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
tsleep(bp, PRIBIO, "biord", 0); tsleep(bp, PRIBIO, "biord", 0);
else else
tsleep(bp, PRIBIO, "biowr", 0); tsleep(bp, PRIBIO, "biowr", 0);
@ -2673,6 +2680,7 @@ void
biodone(register struct buf * bp) biodone(register struct buf * bp)
{ {
int s; int s;
void (*b_iodone) __P((struct buf *));
s = splbio(); s = splbio();
@ -2681,20 +2689,21 @@ biodone(register struct buf * bp)
bp->b_flags |= B_DONE; bp->b_flags |= B_DONE;
if (bp->b_flags & B_FREEBUF) { if (bp->b_iocmd == BIO_DELETE) {
brelse(bp); brelse(bp);
splx(s); splx(s);
return; return;
} }
if ((bp->b_flags & B_READ) == 0) { if (bp->b_iocmd == BIO_WRITE) {
vwakeup(bp); vwakeup(bp);
} }
/* call optional completion function if requested */ /* call optional completion function if requested */
if (bp->b_flags & B_CALL) { if (bp->b_iodone != NULL) {
bp->b_flags &= ~B_CALL; b_iodone = bp->b_iodone;
(*bp->b_iodone) (bp); bp->b_iodone = NULL;
(*b_iodone) (bp);
splx(s); splx(s);
return; return;
} }
@ -2745,7 +2754,8 @@ biodone(register struct buf * bp)
* routines. * routines.
*/ */
iosize = bp->b_bcount - bp->b_resid; 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; bp->b_flags |= B_CACHE;
} }
@ -2782,7 +2792,7 @@ biodone(register struct buf * bp)
* already changed correctly ( see bdwrite() ), so we * already changed correctly ( see bdwrite() ), so we
* only need to do this here in the read case. * 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); vfs_page_set_valid(bp, foff, i, m);
} }
vm_page_flag_clear(m, PG_ZERO); vm_page_flag_clear(m, PG_ZERO);

View File

@ -200,7 +200,8 @@ single_block_read:
* if it isn't in the cache, then get a chunk from * if it isn't in the cache, then get a chunk from
* disk if sequential, otherwise just get the block. * 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; lblkno += 1;
} }
} }
@ -228,7 +229,8 @@ single_block_read:
blkno, size, ntoread, NULL); blkno, size, ntoread, NULL);
} else { } else {
rbp = getblk(vp, lblkno, size, 0, 0); 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; rbp->b_blkno = blkno;
} }
} }
@ -246,7 +248,7 @@ single_block_read:
if ((bp->b_flags & B_CLUSTER) == 0) if ((bp->b_flags & B_CLUSTER) == 0)
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
bp->b_flags &= ~(B_ERROR|B_INVAL); 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); BUF_KERNPROC(bp);
error = VOP_STRATEGY(vp, bp); error = VOP_STRATEGY(vp, bp);
curproc->p_stats->p_ru.ru_inblock++; curproc->p_stats->p_ru.ru_inblock++;
@ -257,10 +259,10 @@ single_block_read:
*/ */
if (rbp) { if (rbp) {
if (error) { if (error) {
rbp->b_flags &= ~(B_ASYNC | B_READ); rbp->b_flags &= ~B_ASYNC;
brelse(rbp); brelse(rbp);
} else if (rbp->b_flags & B_CACHE) { } else if (rbp->b_flags & B_CACHE) {
rbp->b_flags &= ~(B_ASYNC | B_READ); rbp->b_flags &= ~B_ASYNC;
bqrelse(rbp); bqrelse(rbp);
} else { } else {
#if defined(CLUSTERDEBUG) #if defined(CLUSTERDEBUG)
@ -281,7 +283,7 @@ single_block_read:
if ((rbp->b_flags & B_CLUSTER) == 0) if ((rbp->b_flags & B_CLUSTER) == 0)
vfs_busy_pages(rbp, 0); vfs_busy_pages(rbp, 0);
rbp->b_flags &= ~(B_ERROR|B_INVAL); 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); BUF_KERNPROC(rbp);
(void) VOP_STRATEGY(vp, rbp); (void) VOP_STRATEGY(vp, rbp);
curproc->p_stats->p_ru.ru_inblock++; curproc->p_stats->p_ru.ru_inblock++;
@ -325,12 +327,13 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
if (fbp) { if (fbp) {
tbp = fbp; tbp = fbp;
tbp->b_flags |= B_READ; tbp->b_iocmd = BIO_READ;
} else { } else {
tbp = getblk(vp, lbn, size, 0, 0); tbp = getblk(vp, lbn, size, 0, 0);
if (tbp->b_flags & B_CACHE) if (tbp->b_flags & B_CACHE)
return tbp; 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; 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 | bp->b_data = (char *)((vm_offset_t)bp->b_data |
((vm_offset_t)tbp->b_data & PAGE_MASK)); ((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_iodone = cluster_callback;
bp->b_blkno = blkno; bp->b_blkno = blkno;
bp->b_lblkno = lbn; bp->b_lblkno = lbn;
@ -400,7 +404,8 @@ cluster_rbuild(vp, filesize, lbn, blkno, size, run, fbp)
if ((fbp && (i == 1)) || (i == (run - 1))) if ((fbp && (i == 1)) || (i == (run - 1)))
tbp->b_flags |= B_RAM; 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) { if (tbp->b_blkno == tbp->b_lblkno) {
tbp->b_blkno = bn; tbp->b_blkno = bn;
} else if (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_offset = tbp->b_offset;
bp->b_data = (char *)((vm_offset_t)bp->b_data | bp->b_data = (char *)((vm_offset_t)bp->b_data |
((vm_offset_t)tbp->b_data & PAGE_MASK)); ((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)); (tbp->b_flags & (B_VMIO | B_NEEDCOMMIT));
bp->b_iodone = cluster_callback; bp->b_iodone = cluster_callback;
pbgetvp(vp, bp); pbgetvp(vp, bp);
@ -811,8 +816,9 @@ cluster_wbuild(vp, size, start_lbn, len)
s = splbio(); s = splbio();
bundirty(tbp); 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_flags |= B_ASYNC;
tbp->b_iocmd = BIO_WRITE;
reassignbuf(tbp, tbp->b_vp); /* put on clean list */ reassignbuf(tbp, tbp->b_vp); /* put on clean list */
++tbp->b_vp->v_numoutput; ++tbp->b_vp->v_numoutput;
splx(s); splx(s);

View File

@ -153,10 +153,10 @@ vop_panic(struct vop_generic_args *ap)
* Strategy routine for VFS devices that have none. * Strategy routine for VFS devices that have none.
* *
* B_ERROR and B_INVAL must be cleared prior to calling any strategy * 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 * routine. Typically this is done for a BIO_READ strategy call.
* B_INVAL is assumed to already be clear prior to a write and should not * Typically B_INVAL is assumed to already be clear prior to a write
* be cleared manually unless you just made the buffer invalid. B_ERROR * and should not be cleared manually unless you just made the buffer
* should be cleared either way. * invalid. B_ERROR should be cleared either way.
*/ */
static int static int

View File

@ -1569,7 +1569,7 @@ devfs_strategy(struct vop_strategy_args *ap)
return error; return error;
if (((bp->b_flags & B_READ) == 0) && if ((bp->b_iocmd == BIO_WRITE) &&
(LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start) (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
(*bioops.io_start)(bp); (*bioops.io_start)(bp);
switch (vp->v_type) { switch (vp->v_type) {
@ -1606,7 +1606,7 @@ devfs_freeblks(struct vop_freeblks_args *ap)
if ((bsw->d_flags & D_CANFREE) == 0) if ((bsw->d_flags & D_CANFREE) == 0)
return (0); return (0);
bp = geteblk(ap->a_length); bp = geteblk(ap->a_length);
bp->b_flags |= B_FREEBUF; bp->b_iocmd = BIO_DELETE;
bp->b_dev = vp->v_rdev; bp->b_dev = vp->v_rdev;
bp->b_blkno = ap->a_addr; bp->b_blkno = ap->a_addr;
bp->b_offset = dbtob(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); pmap_qenter(kva, ap->a_m, pcount);
/* Build a minimal buffer header. */ /* Build a minimal buffer header. */
bp->b_flags = B_READ | B_CALL; bp->b_iocmd = BIO_READ;
bp->b_iodone = devfs_getpages_iodone; bp->b_iodone = devfs_getpages_iodone;
/* B_PHYS is not set, but it is nice to fill this in. */ /* B_PHYS is not set, but it is nice to fill this in. */

View File

@ -407,7 +407,7 @@ spec_strategy(ap)
struct mount *mp; struct mount *mp;
bp = ap->a_bp; 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) (LIST_FIRST(&bp->b_dep)) != NULL && bioops.io_start)
(*bioops.io_start)(bp); (*bioops.io_start)(bp);
@ -417,7 +417,7 @@ spec_strategy(ap)
*/ */
vp = ap->a_vp; vp = ap->a_vp;
if (vn_isdisk(vp, NULL) && (mp = vp->v_specmountpoint) != NULL) { 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) if (bp->b_lock.lk_lockholder == LK_KERNPROC)
mp->mnt_stat.f_asyncwrites++; mp->mnt_stat.f_asyncwrites++;
else else
@ -458,7 +458,7 @@ spec_freeblks(ap)
if ((bsw->d_flags & D_CANFREE) == 0) if ((bsw->d_flags & D_CANFREE) == 0)
return (0); return (0);
bp = geteblk(ap->a_length); 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_dev = ap->a_vp->v_rdev;
bp->b_blkno = ap->a_addr; bp->b_blkno = ap->a_addr;
bp->b_offset = dbtob(ap->a_addr); bp->b_offset = dbtob(ap->a_addr);
@ -657,7 +657,7 @@ spec_getpages(ap)
pmap_qenter(kva, ap->a_m, pcount); pmap_qenter(kva, ap->a_m, pcount);
/* Build a minimal buffer header. */ /* Build a minimal buffer header. */
bp->b_flags = B_READ | B_CALL; bp->b_iocmd = BIO_READ;
bp->b_iodone = spec_getpages_iodone; bp->b_iodone = spec_getpages_iodone;
/* B_PHYS is not set, but it is nice to fill this in. */ /* B_PHYS is not set, but it is nice to fill this in. */

View File

@ -1923,7 +1923,7 @@ union_strategy(ap)
#ifdef DIAGNOSTIC #ifdef DIAGNOSTIC
if (othervp == NULLVP) if (othervp == NULLVP)
panic("union_strategy: nil vp"); panic("union_strategy: nil vp");
if (((bp->b_flags & B_READ) == 0) && if ((bp->b_iocmd == BIO_WRITE) &&
(othervp == LOWERVP(bp->b_vp))) (othervp == LOWERVP(bp->b_vp)))
panic("union_strategy: writing to lowervp"); panic("union_strategy: writing to lowervp");
#endif #endif

View File

@ -465,7 +465,8 @@ nfs_bioread(vp, uio, ioflag, cred)
if (!rabp) if (!rabp)
return (EINTR); return (EINTR);
if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { 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); vfs_busy_pages(rabp, 0);
if (nfs_asyncio(rabp, cred, p)) { if (nfs_asyncio(rabp, cred, p)) {
rabp->b_flags |= B_INVAL|B_ERROR; rabp->b_flags |= B_INVAL|B_ERROR;
@ -526,7 +527,7 @@ again:
*/ */
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -553,7 +554,7 @@ again:
if (!bp) if (!bp)
return (EINTR); return (EINTR);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -577,7 +578,7 @@ again:
if (!bp) if (!bp)
return (EINTR); return (EINTR);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -605,7 +606,7 @@ again:
if (!bp) if (!bp)
return (EINTR); return (EINTR);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
/* /*
@ -648,7 +649,8 @@ again:
rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p);
if (rabp) { if (rabp) {
if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { 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); vfs_busy_pages(rabp, 0);
if (nfs_asyncio(rabp, cred, p)) { if (nfs_asyncio(rabp, cred, p)) {
rabp->b_flags |= B_INVAL|B_ERROR; rabp->b_flags |= B_INVAL|B_ERROR;
@ -936,7 +938,7 @@ again:
} }
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -1232,7 +1234,7 @@ nfs_asyncio(bp, cred, procp)
* leave the async daemons for more important rpc's (such as reads * leave the async daemons for more important rpc's (such as reads
* and writes). * 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)) { (nmp->nm_bufqiods > nfs_numasync / 2)) {
return(EIO); 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) { if (bp->b_rcred == NOCRED && cred != NOCRED) {
crhold(cred); crhold(cred);
bp->b_rcred = cred; bp->b_rcred = cred;
@ -1383,7 +1385,7 @@ nfs_doio(bp, cr, p)
/* mapping was done by vmapbuf() */ /* mapping was done by vmapbuf() */
io.iov_base = bp->b_data; io.iov_base = bp->b_data;
uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE; 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; uiop->uio_rw = UIO_READ;
nfsstats.read_physios++; nfsstats.read_physios++;
error = nfs_readrpc(vp, uiop, cr); error = nfs_readrpc(vp, uiop, cr);
@ -1399,7 +1401,7 @@ nfs_doio(bp, cr, p)
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
bp->b_error = 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_len = uiop->uio_resid = bp->b_bcount;
io.iov_base = bp->b_data; io.iov_base = bp->b_data;
uiop->uio_rw = UIO_READ; uiop->uio_rw = UIO_READ;

View File

@ -961,7 +961,7 @@ nfssvc_iod(p)
nmp->nm_bufqwant = FALSE; nmp->nm_bufqwant = FALSE;
wakeup(&nmp->nm_bufq); 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); (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
else else
(void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);

View File

@ -2705,7 +2705,7 @@ nfs_strategy(ap)
else else
p = curproc; /* XXX */ p = curproc; /* XXX */
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
cr = bp->b_rcred; cr = bp->b_rcred;
else else
cr = bp->b_wcred; cr = bp->b_wcred;
@ -2939,7 +2939,7 @@ again:
vp->v_numoutput++; vp->v_numoutput++;
bp->b_flags |= B_ASYNC; bp->b_flags |= B_ASYNC;
bundirty(bp); 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; bp->b_dirtyoff = bp->b_dirtyend = 0;
splx(s); splx(s);
biodone(bp); biodone(bp);
@ -3116,7 +3116,8 @@ nfs_writebp(bp, force, procp)
s = splbio(); s = splbio();
bundirty(bp); 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++; bp->b_vp->v_numoutput++;
curproc->p_stats->p_ru.ru_oublock++; curproc->p_stats->p_ru.ru_oublock++;

View File

@ -465,7 +465,8 @@ nfs_bioread(vp, uio, ioflag, cred)
if (!rabp) if (!rabp)
return (EINTR); return (EINTR);
if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { 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); vfs_busy_pages(rabp, 0);
if (nfs_asyncio(rabp, cred, p)) { if (nfs_asyncio(rabp, cred, p)) {
rabp->b_flags |= B_INVAL|B_ERROR; rabp->b_flags |= B_INVAL|B_ERROR;
@ -526,7 +527,7 @@ again:
*/ */
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -553,7 +554,7 @@ again:
if (!bp) if (!bp)
return (EINTR); return (EINTR);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -577,7 +578,7 @@ again:
if (!bp) if (!bp)
return (EINTR); return (EINTR);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -605,7 +606,7 @@ again:
if (!bp) if (!bp)
return (EINTR); return (EINTR);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
/* /*
@ -648,7 +649,8 @@ again:
rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p); rabp = nfs_getcacheblk(vp, lbn + 1, NFS_DIRBLKSIZ, p);
if (rabp) { if (rabp) {
if ((rabp->b_flags & (B_CACHE|B_DELWRI)) == 0) { 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); vfs_busy_pages(rabp, 0);
if (nfs_asyncio(rabp, cred, p)) { if (nfs_asyncio(rabp, cred, p)) {
rabp->b_flags |= B_INVAL|B_ERROR; rabp->b_flags |= B_INVAL|B_ERROR;
@ -936,7 +938,7 @@ again:
} }
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
error = nfs_doio(bp, cred, p); error = nfs_doio(bp, cred, p);
if (error) { if (error) {
@ -1232,7 +1234,7 @@ nfs_asyncio(bp, cred, procp)
* leave the async daemons for more important rpc's (such as reads * leave the async daemons for more important rpc's (such as reads
* and writes). * 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)) { (nmp->nm_bufqiods > nfs_numasync / 2)) {
return(EIO); 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) { if (bp->b_rcred == NOCRED && cred != NOCRED) {
crhold(cred); crhold(cred);
bp->b_rcred = cred; bp->b_rcred = cred;
@ -1383,7 +1385,7 @@ nfs_doio(bp, cr, p)
/* mapping was done by vmapbuf() */ /* mapping was done by vmapbuf() */
io.iov_base = bp->b_data; io.iov_base = bp->b_data;
uiop->uio_offset = ((off_t)bp->b_blkno) * DEV_BSIZE; 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; uiop->uio_rw = UIO_READ;
nfsstats.read_physios++; nfsstats.read_physios++;
error = nfs_readrpc(vp, uiop, cr); error = nfs_readrpc(vp, uiop, cr);
@ -1399,7 +1401,7 @@ nfs_doio(bp, cr, p)
bp->b_flags |= B_ERROR; bp->b_flags |= B_ERROR;
bp->b_error = 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_len = uiop->uio_resid = bp->b_bcount;
io.iov_base = bp->b_data; io.iov_base = bp->b_data;
uiop->uio_rw = UIO_READ; uiop->uio_rw = UIO_READ;

View File

@ -961,7 +961,7 @@ nfssvc_iod(p)
nmp->nm_bufqwant = FALSE; nmp->nm_bufqwant = FALSE;
wakeup(&nmp->nm_bufq); 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); (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
else else
(void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);

View File

@ -2705,7 +2705,7 @@ nfs_strategy(ap)
else else
p = curproc; /* XXX */ p = curproc; /* XXX */
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
cr = bp->b_rcred; cr = bp->b_rcred;
else else
cr = bp->b_wcred; cr = bp->b_wcred;
@ -2939,7 +2939,7 @@ again:
vp->v_numoutput++; vp->v_numoutput++;
bp->b_flags |= B_ASYNC; bp->b_flags |= B_ASYNC;
bundirty(bp); 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; bp->b_dirtyoff = bp->b_dirtyend = 0;
splx(s); splx(s);
biodone(bp); biodone(bp);
@ -3116,7 +3116,8 @@ nfs_writebp(bp, force, procp)
s = splbio(); s = splbio();
bundirty(bp); 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++; bp->b_vp->v_numoutput++;
curproc->p_stats->p_ru.ru_oublock++; curproc->p_stats->p_ru.ru_oublock++;

View File

@ -961,7 +961,7 @@ nfssvc_iod(p)
nmp->nm_bufqwant = FALSE; nmp->nm_bufqwant = FALSE;
wakeup(&nmp->nm_bufq); 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); (void) nfs_doio(bp, bp->b_rcred, (struct proc *)0);
else else
(void) nfs_doio(bp, bp->b_wcred, (struct proc *)0); (void) nfs_doio(bp, bp->b_wcred, (struct proc *)0);

View File

@ -345,7 +345,7 @@ ntfs_strategy(ap)
dprintf(("strategy: bcount: %d flags: 0x%lx\n", dprintf(("strategy: bcount: %d flags: 0x%lx\n",
(u_int32_t)bp->b_bcount,bp->b_flags)); (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; u_int32_t toread;
if (ntfs_cntob(bp->b_blkno) >= fp->f_size) { if (ntfs_cntob(bp->b_blkno) >= fp->f_size) {

View File

@ -275,7 +275,7 @@ nwfs_doio(bp, cr, p)
uiop->uio_iovcnt = 1; uiop->uio_iovcnt = 1;
uiop->uio_segflg = UIO_SYSSPACE; uiop->uio_segflg = UIO_SYSSPACE;
uiop->uio_procp = p; 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_len = uiop->uio_resid = bp->b_bcount;
io.iov_base = bp->b_data; io.iov_base = bp->b_data;
uiop->uio_rw = UIO_READ; uiop->uio_rw = UIO_READ;

View File

@ -812,7 +812,7 @@ static int nwfs_strategy (ap)
p = (struct proc *)0; p = (struct proc *)0;
else else
p = curproc; /* XXX */ p = curproc; /* XXX */
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
cr = bp->b_rcred; cr = bp->b_rcred;
else else
cr = bp->b_wcred; cr = bp->b_wcred;

View File

@ -1944,7 +1944,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
{ {
u_char *cptr = (u_char *)addr; u_char *cptr = (u_char *)addr;
if (flags & B_READ) { if (flags == BIO_READ) {
if (fdc->state != PIOREAD) { if (fdc->state != PIOREAD) {
fdc->state = PIOREAD; fdc->state = PIOREAD;
return(0); return(0);
@ -2003,7 +2003,7 @@ fdstate(fdc_p fdc)
fdblk = 128 << fd->ft->secsize; fdblk = 128 << fd->ft->secsize;
if (fdc->fd && (fd != fdc->fd)) if (fdc->fd && (fd != fdc->fd))
device_printf(fd->dev, "confused fd pointers\n"); 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; format = bp->b_flags & B_FORMAT;
if (format) { if (format) {
finfo = (struct fd_formb *)bp->b_data; finfo = (struct fd_formb *)bp->b_data;
@ -2257,7 +2257,7 @@ fdstate(fdc_p fdc)
*/ */
SET_BCDR(fdc, 1, bp->b_bcount, 0); 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_data+fd->skip,
bp->b_bcount); bp->b_bcount);
@ -2290,7 +2290,7 @@ fdstate(fdc_p fdc)
* the WRITE command is sent * the WRITE command is sent
*/ */
if (!read) if (!read)
(void)fdcpio(fdc,bp->b_flags, (void)fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip, bp->b_data+fd->skip,
fdblk); fdblk);
} }
@ -2320,7 +2320,7 @@ fdstate(fdc_p fdc)
* if this is a read, then simply await interrupt * if this is a read, then simply await interrupt
* before performing PIO * before performing PIO
*/ */
if (read && !fdcpio(fdc,bp->b_flags, if (read && !fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,fdblk)) { bp->b_data+fd->skip,fdblk)) {
fd->tohandle = timeout(fd_iotimeout, fdc, hz); fd->tohandle = timeout(fd_iotimeout, fdc, hz);
return(0); /* will return later */ return(0); /* will return later */
@ -2368,7 +2368,7 @@ fdstate(fdc_p fdc)
* actually perform the PIO read. The IOCOMPLETE case * actually perform the PIO read. The IOCOMPLETE case
* removes the timeout for us. * 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; fdc->state = IOCOMPLETE;
/* FALLTHROUGH */ /* FALLTHROUGH */
case IOCOMPLETE: /* IO DONE, post-analyze */ case IOCOMPLETE: /* IO DONE, post-analyze */

View File

@ -2656,7 +2656,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if LABELSECTOR != 0 #if LABELSECTOR != 0
bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
#endif #endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) { (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }
@ -2664,7 +2664,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if defined(DOSBBSECTOR) && defined(notyet) #if defined(DOSBBSECTOR) && defined(notyet)
/* overwriting master boot record? */ /* overwriting master boot record? */
if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && 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; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -243,7 +243,7 @@ reread_mbr:
bp->b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART); bp->b_dev = dkmodpart(dkmodslice(dev, WHOLE_DISK_SLICE), RAW_PART);
bp->b_blkno = mbr_offset; bp->b_blkno = mbr_offset;
bp->b_bcount = lp->d_secsize; bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
#ifdef PC98 #ifdef PC98
if (bp->b_bcount < 1024) if (bp->b_bcount < 1024)
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_dev = dev;
bp->b_blkno = ext_offset; bp->b_blkno = ext_offset;
bp->b_bcount = lp->d_secsize; bp->b_bcount = lp->d_secsize;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
if (biowait(bp) != 0) { if (biowait(bp) != 0) {
diskerr(bp, "reading extended partition table: error", diskerr(bp, "reading extended partition table: error",

View File

@ -1944,7 +1944,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
{ {
u_char *cptr = (u_char *)addr; u_char *cptr = (u_char *)addr;
if (flags & B_READ) { if (flags == BIO_READ) {
if (fdc->state != PIOREAD) { if (fdc->state != PIOREAD) {
fdc->state = PIOREAD; fdc->state = PIOREAD;
return(0); return(0);
@ -2003,7 +2003,7 @@ fdstate(fdc_p fdc)
fdblk = 128 << fd->ft->secsize; fdblk = 128 << fd->ft->secsize;
if (fdc->fd && (fd != fdc->fd)) if (fdc->fd && (fd != fdc->fd))
device_printf(fd->dev, "confused fd pointers\n"); 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; format = bp->b_flags & B_FORMAT;
if (format) { if (format) {
finfo = (struct fd_formb *)bp->b_data; finfo = (struct fd_formb *)bp->b_data;
@ -2257,7 +2257,7 @@ fdstate(fdc_p fdc)
*/ */
SET_BCDR(fdc, 1, bp->b_bcount, 0); 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_data+fd->skip,
bp->b_bcount); bp->b_bcount);
@ -2290,7 +2290,7 @@ fdstate(fdc_p fdc)
* the WRITE command is sent * the WRITE command is sent
*/ */
if (!read) if (!read)
(void)fdcpio(fdc,bp->b_flags, (void)fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip, bp->b_data+fd->skip,
fdblk); fdblk);
} }
@ -2320,7 +2320,7 @@ fdstate(fdc_p fdc)
* if this is a read, then simply await interrupt * if this is a read, then simply await interrupt
* before performing PIO * before performing PIO
*/ */
if (read && !fdcpio(fdc,bp->b_flags, if (read && !fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,fdblk)) { bp->b_data+fd->skip,fdblk)) {
fd->tohandle = timeout(fd_iotimeout, fdc, hz); fd->tohandle = timeout(fd_iotimeout, fdc, hz);
return(0); /* will return later */ return(0); /* will return later */
@ -2368,7 +2368,7 @@ fdstate(fdc_p fdc)
* actually perform the PIO read. The IOCOMPLETE case * actually perform the PIO read. The IOCOMPLETE case
* removes the timeout for us. * 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; fdc->state = IOCOMPLETE;
/* FALLTHROUGH */ /* FALLTHROUGH */
case IOCOMPLETE: /* IO DONE, post-analyze */ case IOCOMPLETE: /* IO DONE, post-analyze */

View File

@ -2656,7 +2656,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if LABELSECTOR != 0 #if LABELSECTOR != 0
bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect && bp->b_blkno + p->p_offset + sz > LABELSECTOR + labelsect &&
#endif #endif
(bp->b_flags & B_READ) == 0 && wlabel == 0) { (bp->b_iocmd == BIO_WRITE) && wlabel == 0) {
bp->b_error = EROFS; bp->b_error = EROFS;
goto bad; goto bad;
} }
@ -2664,7 +2664,7 @@ bounds_check_with_label(struct buf *bp, struct disklabel *lp, int wlabel)
#if defined(DOSBBSECTOR) && defined(notyet) #if defined(DOSBBSECTOR) && defined(notyet)
/* overwriting master boot record? */ /* overwriting master boot record? */
if (bp->b_blkno + p->p_offset <= DOSBBSECTOR && 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; bp->b_error = EROFS;
goto bad; goto bad;
} }

View File

@ -805,7 +805,7 @@ wdstart(int ctrlr)
#ifdef WDDEBUG #ifdef WDDEBUG
if (du->dk_skip == 0) if (du->dk_skip == 0)
printf("wd%d: wdstart: %s %d@%d; map ", lunit, 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); bp->b_bcount, blknum);
else { else {
if (old_epson_note) if (old_epson_note)
@ -843,7 +843,7 @@ wdstart(int ctrlr)
* XXX this looks like an attempt to skip bad sectors * XXX this looks like an attempt to skip bad sectors
* on write. * 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; du->dk_bc += DEV_BSIZE;
count1 = howmany( du->dk_bc, DEV_BSIZE); count1 = howmany( du->dk_bc, DEV_BSIZE);
@ -851,7 +851,7 @@ wdstart(int ctrlr)
du->dk_flags &= ~DKFL_MULTI; du->dk_flags &= ~DKFL_MULTI;
if (du->dk_flags & DKFL_SINGLE) { if (du->dk_flags & DKFL_SINGLE) {
command = (bp->b_flags & B_READ) command = (bp->b_iocmd == BIO_READ)
? WDCC_READ : WDCC_WRITE; ? WDCC_READ : WDCC_WRITE;
count1 = 1; count1 = 1;
du->dk_currentiosize = 1; du->dk_currentiosize = 1;
@ -861,16 +861,16 @@ wdstart(int ctrlr)
(void *)((int)bp->b_data + (void *)((int)bp->b_data +
du->dk_skip * DEV_BSIZE), du->dk_skip * DEV_BSIZE),
du->dk_bc, du->dk_bc,
bp->b_flags & B_READ)) { bp->b_iocmd == BIO_READ)) {
du->dk_flags |= DKFL_DMA; du->dk_flags |= DKFL_DMA;
if( bp->b_flags & B_READ) if(bp->b_iocmd == BIO_READ)
command = WDCC_READ_DMA; command = WDCC_READ_DMA;
else else
command = WDCC_WRITE_DMA; command = WDCC_WRITE_DMA;
du->dk_currentiosize = count1; du->dk_currentiosize = count1;
} else if( (count1 > 1) && (du->dk_multi > 1)) { } else if( (count1 > 1) && (du->dk_multi > 1)) {
du->dk_flags |= DKFL_MULTI; du->dk_flags |= DKFL_MULTI;
if( bp->b_flags & B_READ) { if(bp->b_iocmd == BIO_READ) {
command = WDCC_READ_MULTI; command = WDCC_READ_MULTI;
} else { } else {
command = WDCC_WRITE_MULTI; command = WDCC_WRITE_MULTI;
@ -879,7 +879,7 @@ wdstart(int ctrlr)
if( du->dk_currentiosize > count1) if( du->dk_currentiosize > count1)
du->dk_currentiosize = count1; du->dk_currentiosize = count1;
} else { } else {
if( bp->b_flags & B_READ) { if(bp->b_iocmd == BIO_READ) {
command = WDCC_READ; command = WDCC_READ;
} else { } else {
command = WDCC_WRITE; command = WDCC_WRITE;
@ -906,7 +906,7 @@ wdstart(int ctrlr)
(void *)((int)bp->b_data + (void *)((int)bp->b_data +
du->dk_skip * DEV_BSIZE), du->dk_skip * DEV_BSIZE),
du->dk_bc, du->dk_bc,
bp->b_flags & B_READ); bp->b_iocmd == BIO_READ);
} }
while (wdcommand(du, cylin, head, sector, count1, command) while (wdcommand(du, cylin, head, sector, count1, command)
!= 0) { != 0) {
@ -954,7 +954,7 @@ wdstart(int ctrlr)
} }
/* If this is a read operation, just go away until it's done. */ /* 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; return;
/* Ready to send data? */ /* Ready to send data? */
@ -1133,7 +1133,7 @@ oops:
/* /*
* If this was a successful read operation, fetch the data. * 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) && !((du->dk_flags & (DKFL_DMA|DKFL_SINGLE)) == DKFL_DMA)
&& wdtab[unit].b_active) { && wdtab[unit].b_active) {
u_int chk, dummy, multisize; u_int chk, dummy, multisize;
@ -1197,7 +1197,7 @@ outt:
/* see if more to transfer */ /* see if more to transfer */
if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) { if (du->dk_bc > 0 && (du->dk_flags & DKFL_ERROR) == 0) {
if( (du->dk_flags & DKFL_SINGLE) || if( (du->dk_flags & DKFL_SINGLE) ||
((bp->b_flags & B_READ) == 0)) { (bp->b_iocmd == BIO_WRITE)) {
wdtab[unit].b_active = 0; wdtab[unit].b_active = 0;
wdstart(unit); wdstart(unit);
} else { } else {

View File

@ -319,7 +319,7 @@ vmapbuf(bp)
* when reading stuff off device into memory. * when reading stuff off device into memory.
*/ */
vm_fault_quick(addr, 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)); pa = trunc_page(pmap_kextract((vm_offset_t) addr));
if (pa == 0) if (pa == 0)
panic("vmapbuf: page not present"); panic("vmapbuf: page not present");

View File

@ -319,7 +319,7 @@ vmapbuf(bp)
* when reading stuff off device into memory. * when reading stuff off device into memory.
*/ */
vm_fault_quick(addr, 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)); pa = trunc_page(pmap_kextract((vm_offset_t) addr));
if (pa == 0) if (pa == 0)
panic("vmapbuf: page not present"); panic("vmapbuf: page not present");

View File

@ -100,6 +100,7 @@ struct buf {
TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */ TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */ TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */ 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. */ long b_flags; /* B_* flags. */
unsigned short b_qindex; /* buffer queue index */ unsigned short b_qindex; /* buffer queue index */
unsigned char b_xflags; /* extra flags */ unsigned char b_xflags; /* extra flags */
@ -170,7 +171,7 @@ struct buf {
* B_DELWRI can also be cleared. See the comments for * B_DELWRI can also be cleared. See the comments for
* getblk() in kern/vfs_bio.c. If B_CACHE is clear, * getblk() in kern/vfs_bio.c. If B_CACHE is clear,
* the caller is expected to clear B_ERROR|B_INVAL, * 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 * The 'entire buffer' is defined to be the range from
* 0 through b_bcount. * 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_AGE 0x00000001 /* Move to age queue when I/O done. */
#define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */ #define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */
#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */ #define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
#define B_UNUSED0 0x00000008 /* Old B_BAD */ #define B_UNUSED0 0x00000008 /* Old B_BAD */
#define B_DEFERRED 0x00000010 /* Skipped over for cleaning */ #define B_DEFERRED 0x00000010 /* Skipped over for cleaning */
#define B_CACHE 0x00000020 /* Bread found us in the cache. */ #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_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_DONE 0x00000200 /* I/O completed. */
#define B_EINTR 0x00000400 /* I/O was interrupted */ #define B_EINTR 0x00000400 /* I/O was interrupted */
#define B_ERROR 0x00000800 /* I/O error occurred. */ #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_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */
#define B_PHYS 0x00040000 /* I/O to user memory. */ #define B_PHYS 0x00040000 /* I/O to user memory. */
#define B_RAW 0x00080000 /* Set by physio for raw transfers. */ #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_DIRTY 0x00200000 /* Needs writing later. */
#define B_RELBUF 0x00400000 /* Release VMIO buffer. */ #define B_RELBUF 0x00400000 /* Release VMIO buffer. */
#define B_WANT 0x00800000 /* Used by vm_pager.c */ #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_WRITEINPROG 0x01000000 /* Write in progress. */
#define B_XXX 0x02000000 /* Debugging flag. */ #define B_XXX 0x02000000 /* Debugging flag. */
#define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */ #define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */

View File

@ -100,6 +100,7 @@ struct buf {
TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */ TAILQ_ENTRY(buf) b_vnbufs; /* Buffer's associated vnode. */
TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */ TAILQ_ENTRY(buf) b_freelist; /* Free list position if not active. */
TAILQ_ENTRY(buf) b_act; /* Device driver queue when active. *new* */ 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. */ long b_flags; /* B_* flags. */
unsigned short b_qindex; /* buffer queue index */ unsigned short b_qindex; /* buffer queue index */
unsigned char b_xflags; /* extra flags */ unsigned char b_xflags; /* extra flags */
@ -170,7 +171,7 @@ struct buf {
* B_DELWRI can also be cleared. See the comments for * B_DELWRI can also be cleared. See the comments for
* getblk() in kern/vfs_bio.c. If B_CACHE is clear, * getblk() in kern/vfs_bio.c. If B_CACHE is clear,
* the caller is expected to clear B_ERROR|B_INVAL, * 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 * The 'entire buffer' is defined to be the range from
* 0 through b_bcount. * 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_AGE 0x00000001 /* Move to age queue when I/O done. */
#define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */ #define B_NEEDCOMMIT 0x00000002 /* Append-write in progress. */
#define B_ASYNC 0x00000004 /* Start I/O, do not wait. */ #define B_ASYNC 0x00000004 /* Start I/O, do not wait. */
#define B_UNUSED0 0x00000008 /* Old B_BAD */ #define B_UNUSED0 0x00000008 /* Old B_BAD */
#define B_DEFERRED 0x00000010 /* Skipped over for cleaning */ #define B_DEFERRED 0x00000010 /* Skipped over for cleaning */
#define B_CACHE 0x00000020 /* Bread found us in the cache. */ #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_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_DONE 0x00000200 /* I/O completed. */
#define B_EINTR 0x00000400 /* I/O was interrupted */ #define B_EINTR 0x00000400 /* I/O was interrupted */
#define B_ERROR 0x00000800 /* I/O error occurred. */ #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_CLUSTEROK 0x00020000 /* Pagein op, so swap() can count it. */
#define B_PHYS 0x00040000 /* I/O to user memory. */ #define B_PHYS 0x00040000 /* I/O to user memory. */
#define B_RAW 0x00080000 /* Set by physio for raw transfers. */ #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_DIRTY 0x00200000 /* Needs writing later. */
#define B_RELBUF 0x00400000 /* Release VMIO buffer. */ #define B_RELBUF 0x00400000 /* Release VMIO buffer. */
#define B_WANT 0x00800000 /* Used by vm_pager.c */ #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_WRITEINPROG 0x01000000 /* Write in progress. */
#define B_XXX 0x02000000 /* Debugging flag. */ #define B_XXX 0x02000000 /* Debugging flag. */
#define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */ #define B_PAGING 0x04000000 /* volatile paging I/O -- bypass VMIO */

View File

@ -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 * of surgery, reset the flag and restart all the stuff on the stall
* queue. * 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. * Types for d_flags.
*/ */

View File

@ -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 * of surgery, reset the flag and restart all the stuff on the stall
* queue. * 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. * Types for d_flags.
*/ */

View File

@ -447,7 +447,7 @@ ffs_indirtrunc(ip, lbn, dbn, lastbn, level, countp)
bp = getblk(vp, lbn, (int)fs->fs_bsize, 0, 0); bp = getblk(vp, lbn, (int)fs->fs_bsize, 0, 0);
if ((bp->b_flags & B_CACHE) == 0) { if ((bp->b_flags & B_CACHE) == 0) {
curproc->p_stats->p_ru.ru_inblock++; /* pay for read */ 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); bp->b_flags &= ~(B_ERROR|B_INVAL);
if (bp->b_bcount > bp->b_bufsize) if (bp->b_bcount > bp->b_bufsize)
panic("ffs_indirtrunc: bad buffer size"); panic("ffs_indirtrunc: bad buffer size");

View File

@ -2780,7 +2780,7 @@ softdep_disk_io_initiation(bp)
* We only care about write operations. There should never * We only care about write operations. There should never
* be dependencies for reads. * be dependencies for reads.
*/ */
if (bp->b_flags & B_READ) if (bp->b_iocmd == BIO_READ)
panic("softdep_disk_io_initiation: read"); panic("softdep_disk_io_initiation: read");
/* /*
* Do any necessary pre-I/O processing. * Do any necessary pre-I/O processing.

View File

@ -123,7 +123,7 @@ mfs_fsync(ap)
/* /*
* mfs_freeblks() - hook to allow us to free physical memory. * 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 * here because we have to do it in the correct order vs other bio
* requests, so we queue it. * requests, so we queue it.
* *
@ -146,7 +146,8 @@ mfs_freeblks(ap)
panic("mfs_freeblks: bad dev"); panic("mfs_freeblks: bad dev");
bp = geteblk(ap->a_length); 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_dev = ap->a_vp->v_rdev;
bp->b_blkno = ap->a_addr; bp->b_blkno = ap->a_addr;
bp->b_offset = dbtob(ap->a_addr); bp->b_offset = dbtob(ap->a_addr);
@ -185,15 +186,15 @@ mfs_strategy(ap)
if (mfsp->mfs_pid == 0) { 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. * I'm not sure what kind of dataspace b_data is in.
*/ */
caddr_t base; caddr_t base;
base = mfsp->mfs_baseoff + (bp->b_blkno << DEV_BSHIFT); 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); bcopy(base, bp->b_data, bp->b_bcount);
else else
bcopy(bp->b_data, base, bp->b_bcount); 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. * 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 * completely -- for example, on fragments or inode metadata, but we can
* implement it for page-aligned requests. * 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); 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 block device when blocks are no longer needed (like when
* a file is deleted). We use the hook to MADV_FREE the VM. * a file is deleted). We use the hook to MADV_FREE the VM.
* This makes an MFS filesystem work as well or better then * This makes an MFS filesystem work as well or better then
@ -263,7 +264,7 @@ mfs_doio(bp, mfsp)
} }
} }
bp->b_error = 0; bp->b_error = 0;
} else if (bp->b_flags & B_READ) { } else if (bp->b_iocmd == BIO_READ) {
/* /*
* Read data from our 'memory' disk * Read data from our 'memory' disk
*/ */

View File

@ -192,7 +192,7 @@ ufs_bmaparray(vp, bn, bnp, ap, nump, runp, runb)
panic("ufs_bmaparray: indirect block not in cache"); panic("ufs_bmaparray: indirect block not in cache");
#endif #endif
bp->b_blkno = blkptrtodb(ump, daddr); bp->b_blkno = blkptrtodb(ump, daddr);
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
bp->b_flags &= ~(B_INVAL|B_ERROR); bp->b_flags &= ~(B_INVAL|B_ERROR);
vfs_busy_pages(bp, 0); vfs_busy_pages(bp, 0);
VOP_STRATEGY(bp->b_vp, bp); VOP_STRATEGY(bp->b_vp, bp);

View File

@ -181,7 +181,7 @@ readdisklabel(dev, lp)
bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE); bp->b_blkno = LABELSECTOR * ((int)lp->d_secsize/DEV_BSIZE);
bp->b_bcount = lp->d_secsize; bp->b_bcount = lp->d_secsize;
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
if (biowait(bp)) if (biowait(bp))
msg = "I/O error"; msg = "I/O error";
@ -284,7 +284,7 @@ writedisklabel(dev, lp)
* (also stupid.. how do you write the first one? by raw writes?) * (also stupid.. how do you write the first one? by raw writes?)
*/ */
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_READ; bp->b_iocmd = BIO_READ;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
error = biowait(bp); error = biowait(bp);
if (error) if (error)
@ -296,8 +296,8 @@ writedisklabel(dev, lp)
if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC && if (dlp->d_magic == DISKMAGIC && dlp->d_magic2 == DISKMAGIC &&
dkcksum(dlp) == 0) { dkcksum(dlp) == 0) {
*dlp = *lp; *dlp = *lp;
bp->b_flags &= ~(B_DONE | B_READ); bp->b_flags &= ~B_DONE;
bp->b_flags |= B_WRITE; bp->b_iocmd = BIO_WRITE;
#ifdef __alpha__ #ifdef __alpha__
alpha_fix_srm_checksum(bp); alpha_fix_srm_checksum(bp);
#endif #endif
@ -313,7 +313,7 @@ done:
dlp = (struct disklabel *)bp->b_data; dlp = (struct disklabel *)bp->b_data;
*dlp = *lp; *dlp = *lp;
bp->b_flags &= ~B_INVAL; bp->b_flags &= ~B_INVAL;
bp->b_flags |= B_WRITE; bp->b_iocmd = BIO_WRITE;
BUF_STRATEGY(bp, 1); BUF_STRATEGY(bp, 1);
error = biowait(bp); error = biowait(bp);
#endif #endif
@ -375,7 +375,7 @@ diskerr(bp, what, pri, blkdone, lp)
pr = printf; pr = printf;
sname = dsname(bp->b_dev, unit, slice, part, partname); sname = dsname(bp->b_dev, unit, slice, part, partname);
(*pr)("%s%s: %s %sing fsbn ", sname, partname, what, (*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; sn = bp->b_blkno;
if (bp->b_bcount <= DEV_BSIZE) if (bp->b_bcount <= DEV_BSIZE)
(*pr)("%ld", (long)sn); (*pr)("%ld", (long)sn);

View File

@ -844,10 +844,10 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
s = splvm(); 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 * FREE PAGE(s) - destroy underlying swap that is no longer
* needed. * needed.
@ -872,7 +872,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
*/ */
blk = swp_pager_meta_ctl(object, start, 0); 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); blk = swp_pager_getswapspace(1);
if (blk == SWAPBLK_NONE) { if (blk == SWAPBLK_NONE) {
bp->b_error = ENOMEM; bp->b_error = ENOMEM;
@ -897,7 +897,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
) )
) { ) {
splx(s); splx(s);
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
++cnt.v_swapin; ++cnt.v_swapin;
cnt.v_swappgsin += btoc(nbp->b_bcount); cnt.v_swappgsin += btoc(nbp->b_bcount);
} else { } else {
@ -925,7 +925,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
bp->b_resid -= PAGE_SIZE; bp->b_resid -= PAGE_SIZE;
} else { } else {
if (nbp == NULL) { 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_blkno = blk;
nbp->b_bcount = 0; nbp->b_bcount = 0;
nbp->b_data = data; nbp->b_data = data;
@ -946,7 +946,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
if (nbp) { if (nbp) {
if ((bp->b_flags & B_ASYNC) == 0) if ((bp->b_flags & B_ASYNC) == 0)
nbp->b_flags &= ~B_ASYNC; nbp->b_flags &= ~B_ASYNC;
if (nbp->b_flags & B_READ) { if (nbp->b_iocmd == BIO_READ) {
++cnt.v_swapin; ++cnt.v_swapin;
cnt.v_swappgsin += btoc(nbp->b_bcount); cnt.v_swappgsin += btoc(nbp->b_bcount);
} else { } else {
@ -1086,7 +1086,7 @@ swap_pager_getpages(object, m, count, reqpage)
pmap_qenter(kva, m + i, j - i); 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_iodone = swp_pager_async_iodone;
bp->b_rcred = bp->b_wcred = proc0.p_ucred; bp->b_rcred = bp->b_wcred = proc0.p_ucred;
bp->b_data = (caddr_t) kva; bp->b_data = (caddr_t) kva;
@ -1329,10 +1329,9 @@ swap_pager_putpages(object, m, count, sync, rtvals)
if (sync == TRUE) { if (sync == TRUE) {
bp = getpbuf(&nsw_wcount_sync); bp = getpbuf(&nsw_wcount_sync);
bp->b_flags = B_CALL;
} else { } else {
bp = getpbuf(&nsw_wcount_async); 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 */ bp->b_spc = NULL; /* not used, but NULL-out anyway */
@ -1481,7 +1480,7 @@ swp_pager_async_iodone(bp)
printf( printf(
"swap_pager: I/O error - %s failed; blkno %ld," "swap_pager: I/O error - %s failed; blkno %ld,"
"size %ld, error %d\n", "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_blkno,
(long)bp->b_bcount, (long)bp->b_bcount,
bp->b_error bp->b_error
@ -1524,7 +1523,7 @@ swp_pager_async_iodone(bp)
* interrupt. * interrupt.
*/ */
if (bp->b_flags & B_READ) { if (bp->b_iocmd == BIO_READ) {
/* /*
* When reading, reqpage needs to stay * When reading, reqpage needs to stay
* locked for the parent, but all other * locked for the parent, but all other
@ -1566,7 +1565,7 @@ swp_pager_async_iodone(bp)
vm_page_activate(m); vm_page_activate(m);
vm_page_io_finish(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 * For read success, clear dirty bits. Nobody should
* have this page mapped but don't take any chances, * have this page mapped but don't take any chances,
@ -1637,7 +1636,7 @@ swp_pager_async_iodone(bp)
relpbuf( relpbuf(
bp, bp,
((bp->b_flags & B_READ) ? &nsw_rcount : ((bp->b_iocmd == BIO_READ) ? &nsw_rcount :
((bp->b_flags & B_ASYNC) ? ((bp->b_flags & B_ASYNC) ?
&nsw_wcount_async : &nsw_wcount_async :
&nsw_wcount_sync &nsw_wcount_sync

View File

@ -348,6 +348,7 @@ initpbuf(struct buf *bp)
bp->b_kvasize = MAXPHYS; bp->b_kvasize = MAXPHYS;
bp->b_xflags = 0; bp->b_xflags = 0;
bp->b_flags = 0; bp->b_flags = 0;
bp->b_iodone = NULL;
bp->b_error = 0; bp->b_error = 0;
BUF_LOCK(bp, LK_EXCLUSIVE); BUF_LOCK(bp, LK_EXCLUSIVE);
} }
@ -546,7 +547,7 @@ getchainbuf(struct buf *bp, struct vnode *vp, int flags)
if (bp->b_chain.count > 4) if (bp->b_chain.count > 4)
waitchainbuf(bp, 4, 0); 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_rcred = nbp->b_wcred = proc0.p_ucred;
nbp->b_iodone = vm_pager_chain_iodone; nbp->b_iodone = vm_pager_chain_iodone;
@ -563,7 +564,7 @@ flushchainbuf(struct buf *nbp)
{ {
if (nbp->b_bcount) { if (nbp->b_bcount) {
nbp->b_bufsize = 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; nbp->b_dirtyend = nbp->b_bcount;
BUF_KERNPROC(nbp); BUF_KERNPROC(nbp);
VOP_STRATEGY(nbp->b_vp, nbp); VOP_STRATEGY(nbp->b_vp, nbp);

View File

@ -137,7 +137,7 @@ swapdev_strategy(ap)
vhold(sp->sw_vp); vhold(sp->sw_vp);
s = splvm(); s = splvm();
if ((bp->b_flags & B_READ) == 0) { if (bp->b_iocmd == BIO_WRITE) {
vp = bp->b_vp; vp = bp->b_vp;
if (vp) { if (vp) {
vp->v_numoutput--; vp->v_numoutput--;

View File

@ -411,7 +411,7 @@ vnode_pager_input_smlfs(object, m)
bp = getpbuf(&vnode_pbuf_freecnt); bp = getpbuf(&vnode_pbuf_freecnt);
/* build a minimal buffer header */ /* 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_iodone = vnode_pager_iodone;
bp->b_rcred = bp->b_wcred = curproc->p_ucred; bp->b_rcred = bp->b_wcred = curproc->p_ucred;
if (bp->b_rcred != NOCRED) if (bp->b_rcred != NOCRED)
@ -729,7 +729,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
pmap_qenter(kva, m, count); pmap_qenter(kva, m, count);
/* build a minimal buffer header */ /* 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_iodone = vnode_pager_iodone;
/* B_PHYS is not set, but it is nice to fill this in */ /* B_PHYS is not set, but it is nice to fill this in */
bp->b_rcred = bp->b_wcred = curproc->p_ucred; bp->b_rcred = bp->b_wcred = curproc->p_ucred;