summaryrefslogtreecommitdiffstats
path: root/sys/vm
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/vm
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/vm')
-rw-r--r--sys/vm/swap_pager.c25
-rw-r--r--sys/vm/vm_pager.c5
-rw-r--r--sys/vm/vm_swap.c2
-rw-r--r--sys/vm/vnode_pager.c4
4 files changed, 18 insertions, 18 deletions
diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c
index f7793cd..7653506 100644
--- a/sys/vm/swap_pager.c
+++ b/sys/vm/swap_pager.c
@@ -844,10 +844,10 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
s = splvm();
/*
- * Deal with B_FREEBUF
+ * Deal with BIO_DELETE
*/
- if (bp->b_flags & B_FREEBUF) {
+ if (bp->b_iocmd & BIO_DELETE) {
/*
* FREE PAGE(s) - destroy underlying swap that is no longer
* needed.
@@ -872,7 +872,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
*/
blk = swp_pager_meta_ctl(object, start, 0);
- if ((blk == SWAPBLK_NONE) && (bp->b_flags & B_READ) == 0) {
+ if ((blk == SWAPBLK_NONE) && (bp->b_iocmd == BIO_WRITE)) {
blk = swp_pager_getswapspace(1);
if (blk == SWAPBLK_NONE) {
bp->b_error = ENOMEM;
@@ -897,7 +897,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
)
) {
splx(s);
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
++cnt.v_swapin;
cnt.v_swappgsin += btoc(nbp->b_bcount);
} else {
@@ -925,7 +925,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
bp->b_resid -= PAGE_SIZE;
} else {
if (nbp == NULL) {
- nbp = getchainbuf(bp, swapdev_vp, (bp->b_flags & B_READ) | B_ASYNC);
+ nbp = getchainbuf(bp, swapdev_vp, (bp->b_iocmd == BIO_READ) | B_ASYNC);
nbp->b_blkno = blk;
nbp->b_bcount = 0;
nbp->b_data = data;
@@ -946,7 +946,7 @@ swap_pager_strategy(vm_object_t object, struct buf *bp)
if (nbp) {
if ((bp->b_flags & B_ASYNC) == 0)
nbp->b_flags &= ~B_ASYNC;
- if (nbp->b_flags & B_READ) {
+ if (nbp->b_iocmd == BIO_READ) {
++cnt.v_swapin;
cnt.v_swappgsin += btoc(nbp->b_bcount);
} else {
@@ -1086,7 +1086,7 @@ swap_pager_getpages(object, m, count, reqpage)
pmap_qenter(kva, m + i, j - i);
- bp->b_flags = B_READ | B_CALL;
+ bp->b_iocmd = BIO_READ;
bp->b_iodone = swp_pager_async_iodone;
bp->b_rcred = bp->b_wcred = proc0.p_ucred;
bp->b_data = (caddr_t) kva;
@@ -1329,10 +1329,9 @@ swap_pager_putpages(object, m, count, sync, rtvals)
if (sync == TRUE) {
bp = getpbuf(&nsw_wcount_sync);
- bp->b_flags = B_CALL;
} else {
bp = getpbuf(&nsw_wcount_async);
- bp->b_flags = B_CALL | B_ASYNC;
+ bp->b_flags = B_ASYNC;
}
bp->b_spc = NULL; /* not used, but NULL-out anyway */
@@ -1481,7 +1480,7 @@ swp_pager_async_iodone(bp)
printf(
"swap_pager: I/O error - %s failed; blkno %ld,"
"size %ld, error %d\n",
- ((bp->b_flags & B_READ) ? "pagein" : "pageout"),
+ ((bp->b_iocmd == BIO_READ) ? "pagein" : "pageout"),
(long)bp->b_blkno,
(long)bp->b_bcount,
bp->b_error
@@ -1524,7 +1523,7 @@ swp_pager_async_iodone(bp)
* interrupt.
*/
- if (bp->b_flags & B_READ) {
+ if (bp->b_iocmd == BIO_READ) {
/*
* When reading, reqpage needs to stay
* locked for the parent, but all other
@@ -1566,7 +1565,7 @@ swp_pager_async_iodone(bp)
vm_page_activate(m);
vm_page_io_finish(m);
}
- } else if (bp->b_flags & B_READ) {
+ } else if (bp->b_iocmd == BIO_READ) {
/*
* For read success, clear dirty bits. Nobody should
* have this page mapped but don't take any chances,
@@ -1637,7 +1636,7 @@ swp_pager_async_iodone(bp)
relpbuf(
bp,
- ((bp->b_flags & B_READ) ? &nsw_rcount :
+ ((bp->b_iocmd == BIO_READ) ? &nsw_rcount :
((bp->b_flags & B_ASYNC) ?
&nsw_wcount_async :
&nsw_wcount_sync
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index 1bef6df..e3817c5 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -348,6 +348,7 @@ initpbuf(struct buf *bp)
bp->b_kvasize = MAXPHYS;
bp->b_xflags = 0;
bp->b_flags = 0;
+ bp->b_iodone = NULL;
bp->b_error = 0;
BUF_LOCK(bp, LK_EXCLUSIVE);
}
@@ -546,7 +547,7 @@ getchainbuf(struct buf *bp, struct vnode *vp, int flags)
if (bp->b_chain.count > 4)
waitchainbuf(bp, 4, 0);
- nbp->b_flags = B_CALL | (bp->b_flags & B_ORDERED) | flags;
+ nbp->b_flags = (bp->b_flags & B_ORDERED) | flags;
nbp->b_rcred = nbp->b_wcred = proc0.p_ucred;
nbp->b_iodone = vm_pager_chain_iodone;
@@ -563,7 +564,7 @@ flushchainbuf(struct buf *nbp)
{
if (nbp->b_bcount) {
nbp->b_bufsize = nbp->b_bcount;
- if ((nbp->b_flags & B_READ) == 0)
+ if (nbp->b_iocmd == BIO_WRITE)
nbp->b_dirtyend = nbp->b_bcount;
BUF_KERNPROC(nbp);
VOP_STRATEGY(nbp->b_vp, nbp);
diff --git a/sys/vm/vm_swap.c b/sys/vm/vm_swap.c
index 0a38aa3..11ca203 100644
--- a/sys/vm/vm_swap.c
+++ b/sys/vm/vm_swap.c
@@ -137,7 +137,7 @@ swapdev_strategy(ap)
vhold(sp->sw_vp);
s = splvm();
- if ((bp->b_flags & B_READ) == 0) {
+ if (bp->b_iocmd == BIO_WRITE) {
vp = bp->b_vp;
if (vp) {
vp->v_numoutput--;
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 1ccc692..279f47c 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -411,7 +411,7 @@ vnode_pager_input_smlfs(object, m)
bp = getpbuf(&vnode_pbuf_freecnt);
/* build a minimal buffer header */
- bp->b_flags = B_READ | B_CALL;
+ bp->b_iocmd = BIO_READ;
bp->b_iodone = vnode_pager_iodone;
bp->b_rcred = bp->b_wcred = curproc->p_ucred;
if (bp->b_rcred != NOCRED)
@@ -729,7 +729,7 @@ vnode_pager_generic_getpages(vp, m, bytecount, reqpage)
pmap_qenter(kva, m, count);
/* build a minimal buffer header */
- bp->b_flags = B_READ | B_CALL;
+ bp->b_iocmd = BIO_READ;
bp->b_iodone = vnode_pager_iodone;
/* B_PHYS is not set, but it is nice to fill this in */
bp->b_rcred = bp->b_wcred = curproc->p_ucred;
OpenPOWER on IntegriCloud