summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>2000-03-20 10:44:49 +0000
committerphk <phk@FreeBSD.org>2000-03-20 10:44:49 +0000
commita246e10f55686681d4b6bd4dba5ca661b4e34bb0 (patch)
tree13a3ded179bf1de0aff7c33b0eba0534aa2dcf09 /sys/dev
parentf274a82c1448c090620cb35f8516831602a12658 (diff)
downloadFreeBSD-src-a246e10f55686681d4b6bd4dba5ca661b4e34bb0.zip
FreeBSD-src-a246e10f55686681d4b6bd4dba5ca661b4e34bb0.tar.gz
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.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/amr/amr.c2
-rw-r--r--sys/dev/ata/ata-disk.c2
-rw-r--r--sys/dev/ata/atapi-cd.c9
-rw-r--r--sys/dev/ata/atapi-fd.c6
-rw-r--r--sys/dev/ata/atapi-tape.c8
-rw-r--r--sys/dev/ccd/ccd.c20
-rw-r--r--sys/dev/fdc/fdc.c12
-rw-r--r--sys/dev/ida/ida.c2
-rw-r--r--sys/dev/ida/ida_disk.c2
-rw-r--r--sys/dev/mcd/mcd.c2
-rw-r--r--sys/dev/md/md.c12
-rw-r--r--sys/dev/mlx/mlx.c2
-rw-r--r--sys/dev/scd/scd.c2
-rw-r--r--sys/dev/vinum/vinumdaemon.c2
-rw-r--r--sys/dev/vinum/vinumext.h4
-rw-r--r--sys/dev/vinum/vinuminterrupt.c22
-rw-r--r--sys/dev/vinum/vinumio.c5
-rw-r--r--sys/dev/vinum/vinumraid5.c8
-rw-r--r--sys/dev/vinum/vinumrequest.c26
-rw-r--r--sys/dev/vinum/vinumrevive.c16
-rw-r--r--sys/dev/vinum/vinumstate.c2
-rw-r--r--sys/dev/vn/vn.c14
22 files changed, 91 insertions, 89 deletions
diff --git a/sys/dev/amr/amr.c b/sys/dev/amr/amr.c
index 14dfec4..6d7524d 100644
--- a/sys/dev/amr/amr.c
+++ b/sys/dev/amr/amr.c
@@ -853,7 +853,7 @@ amr_startio(struct amr_softc *sc)
ac->ac_private = bp;
ac->ac_data = bp->b_data;
ac->ac_length = bp->b_bcount;
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
ac->ac_flags |= AMR_CMD_DATAIN;
cmd = AMR_CMD_LREAD;
} else {
diff --git a/sys/dev/ata/ata-disk.c b/sys/dev/ata/ata-disk.c
index 802a783..cba36c9 100644
--- a/sys/dev/ata/ata-disk.c
+++ b/sys/dev/ata/ata-disk.c
@@ -337,7 +337,7 @@ ad_start(struct ad_softc *adp)
request->blockaddr = bp->b_pblkno;
request->bytecount = bp->b_bcount;
request->data = bp->b_data;
- request->flags = (bp->b_flags & B_READ) ? ADR_F_READ : 0;
+ request->flags = (bp->b_iocmd == BIO_READ) ? ADR_F_READ : 0;
/* remove from drive queue */
bufq_remove(&adp->queue, bp);
diff --git a/sys/dev/ata/atapi-cd.c b/sys/dev/ata/atapi-cd.c
index 4c9da0d..a20cb4c 100644
--- a/sys/dev/ata/atapi-cd.c
+++ b/sys/dev/ata/atapi-cd.c
@@ -1107,7 +1107,6 @@ acd_start(struct atapi_softc *atp)
}
acd_select_slot(cdp);
-
bzero(ccb, sizeof(ccb));
count = (bp->b_bcount + (cdp->block_size - 1)) / cdp->block_size;
if (bp->b_flags & B_PHYS)
@@ -1115,7 +1114,7 @@ acd_start(struct atapi_softc *atp)
else
lba = bp->b_blkno / (cdp->block_size / DEV_BSIZE);
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
/* if transfer goes beyond EOM adjust it to be within limits */
if (lba + count > cdp->info.volsize) {
/* if we are entirely beyond EOM return EOF */
@@ -1145,8 +1144,8 @@ acd_start(struct atapi_softc *atp)
devstat_start_transaction(cdp->stats);
- atapi_queue_cmd(cdp->atp, ccb, bp->b_data, count * cdp->block_size,
- bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, acd_done, bp);
+ atapi_queue_cmd(cdp->atp, ccb, bp->b_data, bp->b_bcount,
+ (bp->b_iocmd == BIO_READ)?ATPR_F_READ : 0, 30, acd_done, bp);
}
static int32_t
@@ -1161,7 +1160,7 @@ acd_done(struct atapi_request *request)
}
else {
bp->b_resid = bp->b_bcount - request->donecount;
- if (!(bp->b_flags & B_READ))
+ if (bp->b_iocmd == BIO_WRITE)
cdp->flags |= F_WRITTEN;
}
devstat_end_transaction_buf(cdp->stats, bp);
diff --git a/sys/dev/ata/atapi-fd.c b/sys/dev/ata/atapi-fd.c
index a27147b..6588684 100644
--- a/sys/dev/ata/atapi-fd.c
+++ b/sys/dev/ata/atapi-fd.c
@@ -321,7 +321,7 @@ afd_start(struct atapi_softc *atp)
bzero(ccb, sizeof(ccb));
- if (bp->b_flags & B_READ)
+ if (bp->b_iocmd == BIO_READ)
ccb[0] = ATAPI_READ_BIG;
else
ccb[0] = ATAPI_WRITE_BIG;
@@ -338,7 +338,7 @@ afd_start(struct atapi_softc *atp)
atapi_queue_cmd(fdp->atp, ccb, data_ptr,
fdp->transfersize * fdp->cap.sector_size,
- (bp->b_flags & B_READ) ? ATPR_F_READ : 0, 30,
+ (bp->b_iocmd == BIO_READ) ? ATPR_F_READ : 0, 30,
afd_partial_done, bp);
count -= fdp->transfersize;
@@ -354,7 +354,7 @@ afd_start(struct atapi_softc *atp)
ccb[8] = count;
atapi_queue_cmd(fdp->atp, ccb, data_ptr, count * fdp->cap.sector_size,
- bp->b_flags&B_READ ? ATPR_F_READ : 0, 30, afd_done, bp);
+ (bp->b_iocmd == BIO_READ) ? ATPR_F_READ : 0, 30, afd_done, bp);
}
static int32_t
diff --git a/sys/dev/ata/atapi-tape.c b/sys/dev/ata/atapi-tape.c
index 2f737c4..3d08eba 100644
--- a/sys/dev/ata/atapi-tape.c
+++ b/sys/dev/ata/atapi-tape.c
@@ -421,7 +421,7 @@ aststrategy(struct buf *bp)
biodone(bp);
return;
}
- if (!(bp->b_flags & B_READ) && stp->flags & F_WRITEPROTECT) {
+ if (!(bp->b_iocmd == BIO_READ) && stp->flags & F_WRITEPROTECT) {
bp->b_error = EPERM;
bp->b_flags |= B_ERROR;
biodone(bp);
@@ -466,7 +466,7 @@ ast_start(struct atapi_softc *atp)
bzero(ccb, sizeof(ccb));
- if (bp->b_flags & B_READ)
+ if (bp->b_iocmd == BIO_READ)
ccb[0] = ATAPI_READ;
else
ccb[0] = ATAPI_WRITE;
@@ -482,7 +482,7 @@ ast_start(struct atapi_softc *atp)
devstat_start_transaction(&stp->stats);
atapi_queue_cmd(stp->atp, ccb, bp->b_data, blkcount * stp->blksize,
- bp->b_flags & B_READ ? ATPR_F_READ : 0, 60, ast_done, bp);
+ (bp->b_iocmd == BIO_READ) ? ATPR_F_READ : 0, 60, ast_done, bp);
}
static int32_t
@@ -496,7 +496,7 @@ ast_done(struct atapi_request *request)
bp->b_flags |= B_ERROR;
}
else {
- if (!(bp->b_flags & B_READ))
+ if (!(bp->b_iocmd == BIO_READ))
stp->flags |= F_DATA_WRITTEN;
bp->b_resid = bp->b_bcount - request->donecount;
ast_total += (bp->b_bcount - bp->b_resid);
diff --git a/sys/dev/ccd/ccd.c b/sys/dev/ccd/ccd.c
index 672ffe2..fe45b6e 100644
--- a/sys/dev/ccd/ccd.c
+++ b/sys/dev/ccd/ccd.c
@@ -193,7 +193,7 @@ static void ccdattach __P((void));
static int ccd_modevent __P((module_t, int, void *));
/* called by biodone() at interrupt time */
-static void ccdiodone __P((struct ccdbuf *cbp));
+static void ccdiodone __P((struct buf *bp));
static void ccdstart __P((struct ccd_softc *, struct buf *));
static void ccdinterleave __P((struct ccd_softc *, int));
@@ -887,7 +887,7 @@ ccdstart(cs, bp)
* to writes when making this determination and we
* also try to avoid hogging.
*/
- if ((cbp[0]->cb_buf.b_flags & B_READ) == 0) {
+ if (cbp[0]->cb_buf.b_iocmd == BIO_WRITE) {
cbp[0]->cb_buf.b_vp->v_numoutput++;
cbp[1]->cb_buf.b_vp->v_numoutput++;
VOP_STRATEGY(cbp[0]->cb_buf.b_vp,
@@ -911,7 +911,7 @@ ccdstart(cs, bp)
/*
* Not mirroring
*/
- if ((cbp[0]->cb_buf.b_flags & B_READ) == 0)
+ if (cbp[0]->cb_buf.b_iocmd == BIO_WRITE)
cbp[0]->cb_buf.b_vp->v_numoutput++;
VOP_STRATEGY(cbp[0]->cb_buf.b_vp, &cbp[0]->cb_buf);
}
@@ -1050,8 +1050,9 @@ ccdbuffer(cb, cs, bp, bn, addr, bcount)
* Fill in the component buf structure.
*/
cbp = getccdbuf(NULL);
- cbp->cb_buf.b_flags = bp->b_flags | B_CALL;
- cbp->cb_buf.b_iodone = (void (*)(struct buf *))ccdiodone;
+ cbp->cb_buf.b_flags = bp->b_flags;
+ cbp->cb_buf.b_iocmd = bp->b_iocmd;
+ cbp->cb_buf.b_iodone = ccdiodone;
cbp->cb_buf.b_dev = ci->ci_dev; /* XXX */
cbp->cb_buf.b_blkno = cbn + cboff + CCD_OFFSET;
cbp->cb_buf.b_offset = dbtob(cbn + cboff + CCD_OFFSET);
@@ -1122,9 +1123,10 @@ ccdintr(cs, bp)
* take a ccd interrupt.
*/
static void
-ccdiodone(cbp)
- struct ccdbuf *cbp;
+ccdiodone(ibp)
+ struct buf *ibp;
{
+ struct ccdbuf *cbp = (struct ccdbuf *)ibp;
struct buf *bp = cbp->cb_obp;
int unit = cbp->cb_unit;
int count, s;
@@ -1153,7 +1155,7 @@ ccdiodone(cbp)
const char *msg = "";
if ((ccd_softc[unit].sc_cflags & CCDF_MIRROR) &&
- (cbp->cb_buf.b_flags & B_READ) &&
+ (cbp->cb_buf.b_iocmd == BIO_READ) &&
(cbp->cb_pflags & CCDPF_MIRROR_DONE) == 0) {
/*
* We will try our read on the other disk down
@@ -1186,7 +1188,7 @@ ccdiodone(cbp)
*/
if (ccd_softc[unit].sc_cflags & CCDF_MIRROR) {
- if ((cbp->cb_buf.b_flags & B_READ) == 0) {
+ if (cbp->cb_buf.b_iocmd == BIO_WRITE) {
/*
* When writing, handshake with the second buffer
* to determine when both are done. If both are not
diff --git a/sys/dev/fdc/fdc.c b/sys/dev/fdc/fdc.c
index 7c96092..4048c7f 100644
--- a/sys/dev/fdc/fdc.c
+++ b/sys/dev/fdc/fdc.c
@@ -1620,7 +1620,7 @@ static int fdcpio(fdc_p fdc, long flags, caddr_t addr, u_int count)
{
u_char *cptr = (u_char *)addr;
- if (flags & B_READ) {
+ if (flags == BIO_READ) {
if (fdc->state != PIOREAD) {
fdc->state = PIOREAD;
return(0);
@@ -1679,7 +1679,7 @@ fdstate(fdc_p fdc)
fdblk = 128 << fd->ft->secsize;
if (fdc->fd && (fd != fdc->fd))
device_printf(fd->dev, "confused fd pointers\n");
- read = bp->b_flags & B_READ;
+ read = bp->b_iocmd == BIO_READ;
format = bp->b_flags & B_FORMAT;
if (format) {
finfo = (struct fd_formb *)bp->b_data;
@@ -1885,7 +1885,7 @@ fdstate(fdc_p fdc)
*/
SET_BCDR(fdc, 1, bp->b_bcount, 0);
- (void)fdcpio(fdc,bp->b_flags,
+ (void)fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,
bp->b_bcount);
@@ -1918,7 +1918,7 @@ fdstate(fdc_p fdc)
* the WRITE command is sent
*/
if (!read)
- (void)fdcpio(fdc,bp->b_flags,
+ (void)fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,
fdblk);
}
@@ -1948,7 +1948,7 @@ fdstate(fdc_p fdc)
* if this is a read, then simply await interrupt
* before performing PIO
*/
- if (read && !fdcpio(fdc,bp->b_flags,
+ if (read && !fdcpio(fdc,bp->b_iocmd,
bp->b_data+fd->skip,fdblk)) {
fd->tohandle = timeout(fd_iotimeout, fdc, hz);
return(0); /* will return later */
@@ -1966,7 +1966,7 @@ fdstate(fdc_p fdc)
* actually perform the PIO read. The IOCOMPLETE case
* removes the timeout for us.
*/
- (void)fdcpio(fdc,bp->b_flags,bp->b_data+fd->skip,fdblk);
+ (void)fdcpio(fdc,bp->b_iocmd,bp->b_data+fd->skip,fdblk);
fdc->state = IOCOMPLETE;
/* FALLTHROUGH */
case IOCOMPLETE: /* IO DONE, post-analyze */
diff --git a/sys/dev/ida/ida.c b/sys/dev/ida/ida.c
index c53f2c9..c9e924e 100644
--- a/sys/dev/ida/ida.c
+++ b/sys/dev/ida/ida.c
@@ -404,7 +404,7 @@ ida_construct_qcb(struct ida_softc *ida)
hwqcb->req.blkno = bp->b_pblkno;
hwqcb->req.bcount = howmany(bp->b_bcount, DEV_BSIZE);
- hwqcb->req.command = bp->b_flags & B_READ ? CMD_READ : CMD_WRITE;
+ hwqcb->req.command = bp->b_iocmd == BIO_READ ? CMD_READ : CMD_WRITE;
STAILQ_INSERT_TAIL(&ida->qcb_queue, qcb, link.stqe);
}
diff --git a/sys/dev/ida/ida_disk.c b/sys/dev/ida/ida_disk.c
index c0bf915..ee1c157 100644
--- a/sys/dev/ida/ida_disk.c
+++ b/sys/dev/ida/ida_disk.c
@@ -163,7 +163,7 @@ idstrategy(struct buf *bp)
/*
* software write protect check
*/
- if (drv->flags & DRV_WRITEPROT && (bp->b_flags & B_READ) == 0) {
+ if (drv->flags & DRV_WRITEPROT && (bp->b_iocmd == BIO_WRITE)) {
bp->b_error = EROFS;
goto bad;
}
diff --git a/sys/dev/mcd/mcd.c b/sys/dev/mcd/mcd.c
index 923ec0f..8b41449 100644
--- a/sys/dev/mcd/mcd.c
+++ b/sys/dev/mcd/mcd.c
@@ -414,7 +414,7 @@ MCD_TRACE("strategy: drive not valid\n");
}
/* read only */
- if (!(bp->b_flags & B_READ)) {
+ if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS;
goto bad;
}
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 66ede3b..8b5ca80 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -191,9 +191,9 @@ mdstrategy_malloc(struct buf *bp)
devstat_start_transaction(&sc->stats);
- if (bp->b_flags & B_FREEBUF)
+ if (bp->b_iocmd == BIO_DELETE)
dop = DEVSTAT_NO_DATA;
- else if (bp->b_flags & B_READ)
+ else if (bp->b_iocmd == BIO_READ)
dop = DEVSTAT_READ;
else
dop = DEVSTAT_WRITE;
@@ -220,13 +220,13 @@ mdstrategy_malloc(struct buf *bp)
if (md_debug > 2)
printf("%lx %p %p %d\n", bp->b_flags, secpp, secp, secval);
- if (bp->b_flags & B_FREEBUF) {
+ if (bp->b_iocmd == BIO_DELETE) {
if (secpp) {
if (secp)
FREE(secp, M_MDSECT);
*secpp = 0;
}
- } else if (bp->b_flags & B_READ) {
+ } else if (bp->b_iocmd == BIO_READ) {
if (secp) {
bcopy(secp, dst, DEV_BSIZE);
} else if (secval) {
@@ -316,9 +316,9 @@ mdstrategy_preload(struct buf *bp)
devstat_start_transaction(&sc->stats);
- if (bp->b_flags & B_FREEBUF) {
+ if (bp->b_iocmd == BIO_DELETE) {
dop = DEVSTAT_NO_DATA;
- } else if (bp->b_flags & B_READ) {
+ } else if (bp->b_iocmd == BIO_READ) {
dop = DEVSTAT_READ;
bcopy(sc->pl_ptr + (bp->b_pblkno << DEV_BSHIFT), bp->b_data, bp->b_bcount);
} else {
diff --git a/sys/dev/mlx/mlx.c b/sys/dev/mlx/mlx.c
index 3e33bfa..94e2863 100644
--- a/sys/dev/mlx/mlx.c
+++ b/sys/dev/mlx/mlx.c
@@ -1658,7 +1658,7 @@ mlx_startio(struct mlx_softc *sc)
mc->mc_private = bp;
mc->mc_data = bp->b_data;
mc->mc_length = bp->b_bcount;
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
mc->mc_flags |= MLX_CMD_DATAIN;
cmd = MLX_CMD_READSG;
} else {
diff --git a/sys/dev/scd/scd.c b/sys/dev/scd/scd.c
index b6e9460..836dbc9 100644
--- a/sys/dev/scd/scd.c
+++ b/sys/dev/scd/scd.c
@@ -337,7 +337,7 @@ scdstrategy(struct buf *bp)
}
/* read only */
- if (!(bp->b_flags & B_READ)) {
+ if (!(bp->b_iocmd == BIO_READ)) {
bp->b_error = EROFS;
goto bad;
}
diff --git a/sys/dev/vinum/vinumdaemon.c b/sys/dev/vinum/vinumdaemon.c
index 835fec8..3ac54d2 100644
--- a/sys/dev/vinum/vinumdaemon.c
+++ b/sys/dev/vinum/vinumdaemon.c
@@ -106,7 +106,7 @@ vinum_daemon(void)
log(LOG_WARNING,
"vinum: recovering I/O request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq,
- rq->bp->b_flags & B_READ ? "Read" : "Write",
+ rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
diff --git a/sys/dev/vinum/vinumext.h b/sys/dev/vinum/vinumext.h
index 5d87ad4..6518b90 100644
--- a/sys/dev/vinum/vinumext.h
+++ b/sys/dev/vinum/vinumext.h
@@ -46,8 +46,8 @@ extern int debug; /* debug flags */
#endif
/* Physical read and write drive */
-#define read_drive(a, b, c, d) driveio (a, b, c, d, B_READ)
-#define write_drive(a, b, c, d) driveio (a, b, c, d, B_WRITE)
+#define read_drive(a, b, c, d) driveio (a, b, c, d, BIO_READ)
+#define write_drive(a, b, c, d) driveio (a, b, c, d, BIO_WRITE)
#define CHECKALLOC(ptr, msg) \
if (ptr == NULL) \
diff --git a/sys/dev/vinum/vinuminterrupt.c b/sys/dev/vinum/vinuminterrupt.c
index 935317a..8a23462 100644
--- a/sys/dev/vinum/vinuminterrupt.c
+++ b/sys/dev/vinum/vinuminterrupt.c
@@ -89,7 +89,7 @@ complete_rqe(struct buf *bp)
else if (rq->error == 0) /* no: do we have one already? */
rq->error = EIO; /* no: catchall "I/O error" */
SD[rqe->sdno].lasterror = rq->error;
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
log(LOG_ERR, "%s: fatal read I/O error\n", SD[rqe->sdno].name);
set_sd_state(rqe->sdno, sd_crashed, setstate_force); /* subdisk is crashed */
} else { /* write operation */
@@ -105,7 +105,7 @@ complete_rqe(struct buf *bp)
}
}
/* Now update the statistics */
- if (bp->b_flags & B_READ) { /* read operation */
+ if (bp->b_iocmd == BIO_READ) { /* read operation */
DRIVE[rqe->driveno].reads++;
DRIVE[rqe->driveno].bytes_read += bp->b_bcount;
SD[rqe->sdno].reads++;
@@ -226,7 +226,7 @@ sdio_done(struct buf *bp)
#endif
sbp->bp->b_resid = sbp->b.b_resid; /* copy the resid field */
/* Now update the statistics */
- if (bp->b_flags & B_READ) { /* read operation */
+ if (bp->b_iocmd == BIO_READ) { /* read operation */
DRIVE[sbp->driveno].reads++;
DRIVE[sbp->driveno].bytes_read += sbp->b.b_bcount;
SD[sbp->sdno].reads++;
@@ -340,11 +340,10 @@ complete_raid5_write(struct rqelement *rqe)
} else
panic("complete_raid5_write: malloc conflict");
- if ((rqe->b.b_flags & B_READ) /* this was a read */
+ if ((rqe->b.b_iocmd == BIO_READ) /* this was a read */
&&((rqe->flags & XFR_BAD_SUBDISK) == 0)) { /* and we can write this block */
- rqe->b.b_flags &= ~(B_READ | B_DONE); /* we're writing now */
- rqe->b.b_flags |= B_CALL; /* call us when you're done */
- rqe->b.b_iodone = complete_rqe; /* by calling us here */
+ rqe->b.b_flags &= ~B_DONE; /* we're writing now */
+ rqe->b.b_iodone = complete_rqe; /* call us here when done */
rqe->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */
rqe->b.b_data = &bp->b_data[rqe->useroffset << DEV_BSHIFT]; /* point to the user data */
rqe->b.b_bcount = rqe->datalen << DEV_BSHIFT; /* length to write */
@@ -365,7 +364,7 @@ complete_raid5_write(struct rqelement *rqe)
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
- rqe->b.b_flags & B_READ ? "Read" : "Write",
+ rqe->b.b_iocmd == BIO_READ ? "Read" : "Write",
major(rqe->b.b_dev),
minor(rqe->b.b_dev),
rqe->sdno,
@@ -382,9 +381,8 @@ complete_raid5_write(struct rqelement *rqe)
}
/* Finally, write the parity block */
rqe = &rqg->rqe[0];
- rqe->b.b_flags &= ~(B_READ | B_DONE); /* we're writing now */
- rqe->b.b_flags |= B_CALL; /* call us when you're done */
- rqe->b.b_iodone = complete_rqe; /* by calling us here */
+ rqe->b.b_flags &= ~B_DONE; /* we're writing now */
+ rqe->b.b_iodone = complete_rqe; /* call us here when done */
rqg->flags &= ~XFR_PARITYOP; /* reset flags that brought us here */
rqe->b.b_bcount = rqe->buflen << DEV_BSHIFT; /* length to write */
rqe->b.b_bufsize = rqe->b.b_bcount; /* don't claim we have more */
@@ -404,7 +402,7 @@ complete_raid5_write(struct rqelement *rqe)
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
- rqe->b.b_flags & B_READ ? "Read" : "Write",
+ rqe->b.b_iocmd == BIO_READ ? "Read" : "Write",
major(rqe->b.b_dev),
minor(rqe->b.b_dev),
rqe->sdno,
diff --git a/sys/dev/vinum/vinumio.c b/sys/dev/vinum/vinumio.c
index 17fc5fe..8913d66 100644
--- a/sys/dev/vinum/vinumio.c
+++ b/sys/dev/vinum/vinumio.c
@@ -297,7 +297,8 @@ driveio(struct drive *drive, char *buf, size_t length, off_t offset, int flag)
int len = min(length, MAXBSIZE); /* maximum block device transfer is MAXBSIZE */
bp = geteblk(len); /* get a buffer header */
- bp->b_flags = flag;
+ bp->b_flags = 0;
+ bp->b_iocmd = flag;
bp->b_dev = drive->dev; /* device */
bp->b_blkno = offset / drive->partinfo.disklab->d_secsize; /* block number */
bp->b_saveaddr = bp->b_data;
@@ -754,7 +755,7 @@ write_volume_label(int volno)
dlp = (struct disklabel *) bp->b_data;
*dlp = *lp;
bp->b_flags &= ~B_INVAL;
- bp->b_flags |= B_WRITE;
+ bp->b_iocmd = BIO_WRITE;
/*
* This should read:
diff --git a/sys/dev/vinum/vinumraid5.c b/sys/dev/vinum/vinumraid5.c
index 2c44d71..5596814 100644
--- a/sys/dev/vinum/vinumraid5.c
+++ b/sys/dev/vinum/vinumraid5.c
@@ -360,7 +360,7 @@ bre5(struct request *rq,
}
if (SD[plex->sdnos[m.psdno]].state < sd_reborn) /* is our parity subdisk down? */
m.badsdno = m.psdno; /* note that it's down */
- if (bp->b_flags & B_READ) { /* read operation */
+ if (bp->b_iocmd == BIO_READ) { /* read operation */
for (mysdno = m.firstsdno; rsectors > 0; mysdno++) {
if (mysdno == m.psdno) /* ignore parity on read */
mysdno++;
@@ -493,7 +493,7 @@ bre5(struct request *rq,
rqe->driveno = sd->driveno;
if (build_rq_buffer(rqe, plex)) /* build the buffer */
return REQUEST_ENOMEM; /* can't do it */
- rqe->b.b_flags |= B_READ; /* we must read first */
+ rqe->b.b_iocmd == BIO_READ; /* we must read first */
m.sdcount++; /* adjust the subdisk count */
rqno++; /* and point to the next request */
}
@@ -534,7 +534,7 @@ bre5(struct request *rq,
return REQUEST_ENOMEM; /* can't do it */
if ((m.flags & XFR_PARITYOP) /* parity operation, */
&&((m.flags & XFR_BAD_SUBDISK) == 0)) /* and not the bad subdisk, */
- rqe->b.b_flags |= B_READ; /* we must read first */
+ rqe->b.b_iocmd = BIO_READ; /* we must read first */
/* Now update pointers for the next block */
*diskaddr += m.datalen; /* skip past what we've done */
@@ -577,7 +577,7 @@ bre5(struct request *rq,
rqe->driveno = sd->driveno;
if (build_rq_buffer(rqe, plex)) /* build the buffer */
return REQUEST_ENOMEM; /* can't do it */
- rqe->b.b_flags |= B_READ; /* we must read first */
+ rqe->b.b_iocmd = BIO_READ; /* we must read first */
}
}
/*
diff --git a/sys/dev/vinum/vinumrequest.c b/sys/dev/vinum/vinumrequest.c
index da7bff4..98c7892 100644
--- a/sys/dev/vinum/vinumrequest.c
+++ b/sys/dev/vinum/vinumrequest.c
@@ -224,7 +224,7 @@ vinumstart(struct buf *bp, int reviveok)
maxplex = 1; /* just the one plex */
}
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
/*
* This is a read request. Decide
* which plex to read from.
@@ -337,7 +337,7 @@ launch_requests(struct request *rq, int reviveok)
"Revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq->sdno,
rq,
- rq->bp->b_flags & B_READ ? "Read" : "Write",
+ rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
@@ -351,7 +351,7 @@ launch_requests(struct request *rq, int reviveok)
log(LOG_DEBUG,
"Request: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq,
- rq->bp->b_flags & B_READ ? "Read" : "Write",
+ rq->bp->b_iocmd == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
@@ -406,7 +406,7 @@ launch_requests(struct request *rq, int reviveok)
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
- rqe->b.b_flags & B_READ ? "Read" : "Write",
+ rqe->b.b_iocmd == BIO_READ ? "Read" : "Write",
major(rqe->b.b_dev),
minor(rqe->b.b_dev),
rqe->sdno,
@@ -505,7 +505,7 @@ bre(struct request *rq,
s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */
if (s == REQUEST_DOWN) { /* down? */
rqe->flags = XFR_BAD_SUBDISK; /* yup */
- if (rq->bp->b_flags & B_READ) /* read request, */
+ if (rq->bp->b_iocmd == BIO_READ) /* read request, */
return REQUEST_DEGRADED; /* give up here */
/*
* If we're writing, don't give up
@@ -589,7 +589,7 @@ bre(struct request *rq,
s = checksdstate(sd, rq, *diskaddr, diskend); /* do we need to change state? */
if (s == REQUEST_DOWN) { /* down? */
rqe->flags = XFR_BAD_SUBDISK; /* yup */
- if (rq->bp->b_flags & B_READ) /* read request, */
+ if (rq->bp->b_iocmd == BIO_READ) /* read request, */
return REQUEST_DEGRADED; /* give up here */
/*
* If we're writing, don't give up
@@ -791,8 +791,8 @@ build_rq_buffer(struct rqelement *rqe, struct plex *plex)
/* Initialize the buf struct */
/* copy these flags from user bp */
- bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_READ | B_ASYNC);
- bp->b_flags |= B_CALL; /* inform us when it's done */
+ bp->b_flags = ubp->b_flags & (B_ORDERED | B_NOCACHE | B_ASYNC);
+ bp->b_iocmd = BIO_READ; /* inform us when it's done */
BUF_LOCKINIT(bp); /* get a lock for the buffer */
BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */
@@ -891,9 +891,9 @@ sdio(struct buf *bp)
if (drive->state != drive_up) {
if (sd->state >= sd_crashed) {
- if (bp->b_flags & B_READ) /* reading, */
+ if (bp->b_iocmd == BIO_READ) /* reading, */
set_sd_state(sd->sdno, sd_crashed, setstate_force);
- else
+ else if (bp->b_iocmd == BIO_WRITE) /* writing, */
set_sd_state(sd->sdno, sd_stale, setstate_force);
}
bp->b_flags |= B_ERROR;
@@ -920,7 +920,7 @@ sdio(struct buf *bp)
return;
}
bzero(sbp, sizeof(struct sdbuf)); /* start with nothing */
- sbp->b.b_flags = bp->b_flags | B_CALL; /* inform us when it's done */
+ sbp->b.b_flags = bp->b_flags;
sbp->b.b_bufsize = bp->b_bufsize; /* buffer size */
sbp->b.b_bcount = bp->b_bcount; /* number of bytes to transfer */
sbp->b.b_resid = bp->b_resid; /* and amount waiting */
@@ -947,7 +947,7 @@ sdio(struct buf *bp)
if (debug & DEBUG_ADDRESSES)
log(LOG_DEBUG,
" %s dev %d.%d, sd %d, offset 0x%x, devoffset 0x%x, length %ld\n",
- sbp->b.b_flags & B_READ ? "Read" : "Write",
+ sbp->b.b_iocmd == BIO_READ ? "Read" : "Write",
major(sbp->b.b_dev),
minor(sbp->b.b_dev),
sbp->sdno,
@@ -992,7 +992,7 @@ vinum_bounds_check(struct buf *bp, struct volume *vol)
&& bp->b_blkno + size > LABELSECTOR /* and finishes after */
#endif
&& (!(vol->flags & VF_RAW)) /* and it's not raw */
- &&(bp->b_flags & B_READ) == 0 /* and it's a write */
+ && (bp->b_iocmd == BIO_WRITE) /* and it's a write */
&& (!vol->flags & (VF_WLABEL | VF_LABELLING))) { /* and we're not allowed to write the label */
bp->b_error = EROFS; /* read-only */
bp->b_flags |= B_ERROR;
diff --git a/sys/dev/vinum/vinumrevive.c b/sys/dev/vinum/vinumrevive.c
index bfa1c9a..3204512 100644
--- a/sys/dev/vinum/vinumrevive.c
+++ b/sys/dev/vinum/vinumrevive.c
@@ -170,7 +170,8 @@ revive_block(int sdno)
else /* it's an unattached plex */
bp->b_dev = VINUM_PLEX(sd->plexno); /* create the device number */
- bp->b_flags = B_READ; /* either way, read it */
+ bp->b_flags = 0; /* either way, read it */
+ bp->b_iocmd = BIO_READ; /* either way, read it */
vinumstart(bp, 1);
biowait(bp);
}
@@ -181,7 +182,8 @@ revive_block(int sdno)
/* Now write to the subdisk */
{
bp->b_dev = VINUM_SD(sdno); /* create the device number */
- bp->b_flags = B_ORDERED | B_WRITE; /* and make this an ordered write */
+ bp->b_flags = B_ORDERED; /* and make this an ordered write */
+ bp->b_iocmd = BIO_WRITE; /* and make this an ordered write */
BUF_LOCKINIT(bp); /* get a lock for the buffer */
BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */
bp->b_resid = bp->b_bcount;
@@ -211,7 +213,7 @@ revive_block(int sdno)
"Relaunch revive conflict sd %d: %p\n%s dev %d.%d, offset 0x%x, length %ld\n",
rq->sdno,
rq,
- rq->bp->b_flags & B_READ ? "Read" : "Write",
+ rq->bp->b_flags == BIO_READ ? "Read" : "Write",
major(rq->bp->b_dev),
minor(rq->bp->b_dev),
rq->bp->b_blkno,
@@ -310,8 +312,7 @@ parityops(struct vinum_ioctl_msg *data, enum parityop op)
}
}
} else { /* rebuildparity */
- pbp->b_flags &= ~B_READ;
- pbp->b_flags |= B_WRITE;
+ pbp->b_iocmd = BIO_WRITE;
pbp->b_resid = pbp->b_bcount;
BUF_LOCKINIT(pbp); /* get a lock for the buffer */
BUF_LOCK(pbp, LK_EXCLUSIVE); /* and lock it */
@@ -404,7 +405,8 @@ parityrebuild(struct plex *plex,
bzero(parity_buf, mysize);
}
bpp[sdno]->b_dev = VINUM_SD(plex->sdnos[sdno]); /* device number */
- bpp[sdno]->b_flags = B_READ; /* either way, read it */
+ bpp[sdno]->b_flags = 0; /* either way, read it */
+ bpp[sdno]->b_iocmd = BIO_READ; /* either way, read it */
bpp[sdno]->b_bcount = bpp[sdno]->b_bufsize;
bpp[sdno]->b_resid = bpp[sdno]->b_bcount;
bpp[sdno]->b_blkno = pstripe; /* read from here */
@@ -557,7 +559,7 @@ initsd(int sdno, int verify)
bp->b_resid = bp->b_bcount;
bp->b_blkno = sd->initialized; /* read from here */
bp->b_dev = VINUM_SD(sdno); /* create the device number */
- bp->b_flags |= B_READ; /* read it back */
+ bp->b_iocmd = BIO_READ; /* read it back */
splx(s);
BUF_LOCKINIT(bp); /* get a lock for the buffer */
BUF_LOCK(bp, LK_EXCLUSIVE); /* and lock it */
diff --git a/sys/dev/vinum/vinumstate.c b/sys/dev/vinum/vinumstate.c
index 3ed347f..318e040 100644
--- a/sys/dev/vinum/vinumstate.c
+++ b/sys/dev/vinum/vinumstate.c
@@ -617,7 +617,7 @@ enum requeststatus
checksdstate(struct sd *sd, struct request *rq, daddr_t diskaddr, daddr_t diskend)
{
struct plex *plex = &PLEX[sd->plexno];
- int writeop = (rq->bp->b_flags & B_READ) == 0; /* note if we're writing */
+ int writeop = (rq->bp->b_iocmd == BIO_WRITE); /* note if we're writing */
switch (sd->state) {
/* We shouldn't get called if the subdisk is up */
diff --git a/sys/dev/vn/vn.c b/sys/dev/vn/vn.c
index 49fa104..ba0caad 100644
--- a/sys/dev/vn/vn.c
+++ b/sys/dev/vn/vn.c
@@ -101,7 +101,7 @@ static d_strategy_t vnstrategy;
/*
* cdevsw
* D_DISK we want to look like a disk
- * D_CANFREE We support B_FREEBUF
+ * D_CANFREE We support BIO_DELETE
*/
static struct cdevsw vn_cdevsw = {
@@ -286,7 +286,7 @@ vnstrategy(struct buf *bp)
unit = dkunit(bp->b_dev);
vn = bp->b_dev->si_drv1;
- if (!vn)
+ if (vn == NULL)
vn = vnfindvn(bp->b_dev);
IFOPT(vn, VN_DEBUG)
@@ -349,7 +349,7 @@ vnstrategy(struct buf *bp)
bp->b_pblkno = pbn;
}
- if (vn->sc_vp && (bp->b_flags & B_FREEBUF)) {
+ if (vn->sc_vp && (bp->b_iocmd == BIO_DELETE)) {
/*
* Not handled for vnode-backed element yet.
*/
@@ -368,7 +368,7 @@ vnstrategy(struct buf *bp)
auio.uio_iovcnt = 1;
auio.uio_offset = (vm_ooffset_t)bp->b_pblkno * vn->sc_secsize;
auio.uio_segflg = UIO_SYSSPACE;
- if( bp->b_flags & B_READ)
+ if(bp->b_iocmd == BIO_READ)
auio.uio_rw = UIO_READ;
else
auio.uio_rw = UIO_WRITE;
@@ -378,7 +378,7 @@ vnstrategy(struct buf *bp)
isvplocked = 1;
vn_lock(vn->sc_vp, LK_EXCLUSIVE | LK_RETRY, curproc);
}
- if( bp->b_flags & B_READ)
+ if(bp->b_iocmd == BIO_READ)
error = VOP_READ(vn->sc_vp, &auio, 0, vn->sc_cred);
else
error = VOP_WRITE(vn->sc_vp, &auio, 0, vn->sc_cred);
@@ -399,12 +399,12 @@ vnstrategy(struct buf *bp)
*
* ( handles read, write, freebuf )
*
- * Note: if we pre-reserved swap, B_FREEBUF is disabled
+ * Note: if we pre-reserved swap, BIO_DELETE is disabled
*/
KASSERT((bp->b_bufsize & (vn->sc_secsize - 1)) == 0,
("vnstrategy: buffer %p too small for physio", bp));
- if ((bp->b_flags & B_FREEBUF) && TESTOPT(vn, VN_RESERVE)) {
+ if ((bp->b_iocmd == BIO_DELETE) && TESTOPT(vn, VN_RESERVE)) {
biodone(bp);
} else {
vm_pager_strategy(vn->sc_object, bp);
OpenPOWER on IntegriCloud