From 132086955992d54751ba7185f3fea0c7a33f5867 Mon Sep 17 00:00:00 2001 From: dg Date: Sun, 26 Mar 1995 23:29:13 +0000 Subject: [PATCH] Removed third arg (vmio) to allocbuf() that was added with the original merged cache changes, and figure it out based on the B_VMIO buffer flag. Fixes a problem where delayed write VMIO buffers would sometimes get recopied into kernel-alloced memory. Submitted by: John Dyson --- sys/kern/vfs_bio.c | 15 +++++++-------- sys/sys/bio.h | 4 ++-- sys/sys/buf.h | 4 ++-- sys/ufs/ffs/ffs_alloc.c | 6 +++--- sys/ufs/ffs/ffs_inode.c | 4 ++-- sys/ufs/lfs/lfs_inode.c | 4 ++-- 6 files changed, 18 insertions(+), 19 deletions(-) diff --git a/sys/kern/vfs_bio.c b/sys/kern/vfs_bio.c index 5b7bc76de246..8d2fa28b9713 100644 --- a/sys/kern/vfs_bio.c +++ b/sys/kern/vfs_bio.c @@ -18,7 +18,7 @@ * 5. Modifications may be freely made to this file if the above conditions * are met. * - * $Id: vfs_bio.c,v 1.35 1995/03/07 19:53:27 davidg Exp $ + * $Id: vfs_bio.c,v 1.36 1995/03/16 18:12:47 bde Exp $ */ /* @@ -439,12 +439,10 @@ brelse(struct buf * bp) vm_page_protect(m, VM_PROT_NONE); vm_page_free(m); } -#if 1 else if ((m->dirty & m->valid) == 0 && (m->flags & PG_REFERENCED) == 0 && !pmap_is_referenced(VM_PAGE_TO_PHYS(m))) vm_page_cache(m); -#endif else if ((m->flags & PG_ACTIVE) == 0) { vm_page_activate(m); m->act_count = 0; @@ -628,7 +626,7 @@ getnewbuf(int slpflag, int slptimeo, int doingvmio) LIST_INSERT_HEAD(&invalhash, bp, b_hash); splx(s); if (bp->b_bufsize) { - allocbuf(bp, 0, 0); + allocbuf(bp, 0); } bp->b_flags = B_BUSY; bp->b_dev = NODEV; @@ -809,7 +807,7 @@ getblk(struct vnode * vp, daddr_t blkno, int size, int slpflag, int slptimeo) } splx(s); - if (!allocbuf(bp, size, 1)) { + if (!allocbuf(bp, size)) { s = splbio(); goto loop; } @@ -826,7 +824,7 @@ geteblk(int size) struct buf *bp; while ((bp = getnewbuf(0, 0, 0)) == 0); - allocbuf(bp, size, 0); + allocbuf(bp, size); bp->b_flags |= B_INVAL; return (bp); } @@ -843,14 +841,15 @@ geteblk(int size) * destroying information (unless, of course the buffer is shrinking). */ int -allocbuf(struct buf * bp, int size, int vmio) +allocbuf(struct buf * bp, int size) { int s; int newbsize, mbsize; int i; + int vmio = (bp->b_flags & B_VMIO) != 0; - if ((bp->b_flags & B_VMIO) == 0) { + if (!vmio) { /* * Just get anonymous memory from the kernel */ diff --git a/sys/sys/bio.h b/sys/sys/bio.h index 92c0a4c83033..b0b3677c94fd 100644 --- a/sys/sys/bio.h +++ b/sys/sys/bio.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)buf.h 8.7 (Berkeley) 1/21/94 - * $Id: buf.h,v 1.13 1995/03/16 18:16:12 bde Exp $ + * $Id: buf.h,v 1.14 1995/03/25 08:55:02 davidg Exp $ */ #ifndef _SYS_BUF_H_ @@ -220,7 +220,7 @@ struct buf *incore __P((struct vnode *, daddr_t)); int inmem __P((struct vnode *, daddr_t)); struct buf *getblk __P((struct vnode *, daddr_t, int, int, int)); struct buf *geteblk __P((int)); -int allocbuf __P((struct buf *, int, int)); +int allocbuf __P((struct buf *, int)); int biowait __P((struct buf *)); void biodone __P((struct buf *)); diff --git a/sys/sys/buf.h b/sys/sys/buf.h index 92c0a4c83033..b0b3677c94fd 100644 --- a/sys/sys/buf.h +++ b/sys/sys/buf.h @@ -36,7 +36,7 @@ * SUCH DAMAGE. * * @(#)buf.h 8.7 (Berkeley) 1/21/94 - * $Id: buf.h,v 1.13 1995/03/16 18:16:12 bde Exp $ + * $Id: buf.h,v 1.14 1995/03/25 08:55:02 davidg Exp $ */ #ifndef _SYS_BUF_H_ @@ -220,7 +220,7 @@ struct buf *incore __P((struct vnode *, daddr_t)); int inmem __P((struct vnode *, daddr_t)); struct buf *getblk __P((struct vnode *, daddr_t, int, int, int)); struct buf *geteblk __P((int)); -int allocbuf __P((struct buf *, int, int)); +int allocbuf __P((struct buf *, int)); int biowait __P((struct buf *)); void biodone __P((struct buf *)); diff --git a/sys/ufs/ffs/ffs_alloc.c b/sys/ufs/ffs/ffs_alloc.c index 81d1fe48f7c0..6af2d938eba3 100644 --- a/sys/ufs/ffs/ffs_alloc.c +++ b/sys/ufs/ffs/ffs_alloc.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_alloc.c 8.8 (Berkeley) 2/21/94 - * $Id: ffs_alloc.c,v 1.10 1995/03/10 22:11:50 davidg Exp $ + * $Id: ffs_alloc.c,v 1.11 1995/03/19 14:29:11 davidg Exp $ */ #include @@ -222,7 +222,7 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) panic("bad blockno"); ip->i_blocks += btodb(nsize - osize); ip->i_flag |= IN_CHANGE | IN_UPDATE; - allocbuf(bp, nsize, 0); + allocbuf(bp, nsize); bp->b_flags |= B_DONE; bzero((char *)bp->b_data + osize, (u_int)nsize - osize); *bpp = bp; @@ -286,7 +286,7 @@ ffs_realloccg(ip, lbprev, bpref, osize, nsize, cred, bpp) (long)(request - nsize)); ip->i_blocks += btodb(nsize - osize); ip->i_flag |= IN_CHANGE | IN_UPDATE; - allocbuf(bp, nsize, 0); + allocbuf(bp, nsize); bp->b_flags |= B_DONE; bzero((char *)bp->b_data + osize, (u_int)nsize - osize); *bpp = bp; diff --git a/sys/ufs/ffs/ffs_inode.c b/sys/ufs/ffs/ffs_inode.c index 5f56b6806a5f..0bb88a96dff5 100644 --- a/sys/ufs/ffs/ffs_inode.c +++ b/sys/ufs/ffs/ffs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)ffs_inode.c 8.5 (Berkeley) 12/30/93 - * $Id: ffs_inode.c,v 1.11 1995/01/09 16:05:18 davidg Exp $ + * $Id: ffs_inode.c,v 1.12 1995/03/04 03:24:42 davidg Exp $ */ #include @@ -249,7 +249,7 @@ ffs_truncate(ap) oip->i_size = length; size = blksize(fs, oip, lbn); bzero((char *)bp->b_data + offset, (u_int)(size - offset)); - allocbuf(bp, size, 0); + allocbuf(bp, size); if (aflags & IO_SYNC) bwrite(bp); else diff --git a/sys/ufs/lfs/lfs_inode.c b/sys/ufs/lfs/lfs_inode.c index dd729ac899e7..cc298d9ba8d3 100644 --- a/sys/ufs/lfs/lfs_inode.c +++ b/sys/ufs/lfs/lfs_inode.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)lfs_inode.c 8.5 (Berkeley) 12/30/93 - * $Id: lfs_inode.c,v 1.6 1995/01/09 16:05:21 davidg Exp $ + * $Id: lfs_inode.c,v 1.7 1995/03/19 14:29:17 davidg Exp $ */ #include @@ -235,7 +235,7 @@ lfs_truncate(ap) ip->i_size = length; size = blksize(fs); bzero((char *)bp->b_data + offset, (u_int)(size - offset)); - allocbuf(bp, size, 0); + allocbuf(bp, size); if (e1 = VOP_BWRITE(bp)) return (e1); }