diff --git a/sys/ufs/lfs/lfs_inode.c b/sys/ufs/lfs/lfs_inode.c index 87939314786b..7328d350ab04 100644 --- a/sys/ufs/lfs/lfs_inode.c +++ b/sys/ufs/lfs/lfs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_inode.c,v 1.67 2003/02/28 07:37:56 perseant Exp $ */ +/* $NetBSD: lfs_inode.c,v 1.68 2003/03/01 05:07:51 perseant Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.67 2003/02/28 07:37:56 perseant Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.68 2003/03/01 05:07:51 perseant Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -428,8 +428,7 @@ lfs_truncate(void *v) if (error) { return error; } - size = blksize(fs, oip, lblkno(fs, length)); - eoz = MIN(lblktosize(fs, lblkno(fs, length)) + size, osize); + eoz = blkroundup(fs, length); uvm_vnp_zerorange(ovp, length, eoz - length); simple_lock(&ovp->v_interlock); error = VOP_PUTPAGES(ovp, trunc_page(length), round_page(eoz), diff --git a/sys/ufs/lfs/lfs_vfsops.c b/sys/ufs/lfs/lfs_vfsops.c index 1bc6b810a63b..0c285041ef35 100644 --- a/sys/ufs/lfs/lfs_vfsops.c +++ b/sys/ufs/lfs/lfs_vfsops.c @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_vfsops.c,v 1.99 2003/02/25 20:35:40 thorpej Exp $ */ +/* $NetBSD: lfs_vfsops.c,v 1.100 2003/03/01 05:07:52 perseant Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -71,7 +71,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.99 2003/02/25 20:35:40 thorpej Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_vfsops.c,v 1.100 2003/03/01 05:07:52 perseant Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -1806,7 +1806,7 @@ lfs_gop_write(struct vnode *vp, struct vm_page **pgs, int npages, int flags) uvmexp.paging--; if (pg->flags & PG_DELWRI) { uvm_pageunwire(pg); - uvm_pagedeactivate(pg); + uvm_pageactivate(pg); } pg->flags &= ~(PG_BUSY|PG_CLEAN|PG_WANTED|PG_DELWRI|PG_PAGEOUT|PG_RELEASED); UVM_PAGE_OWN(pg, NULL); diff --git a/sys/ufs/ufs/ufs_inode.c b/sys/ufs/ufs/ufs_inode.c index d2b00389b975..fe980e3647bb 100644 --- a/sys/ufs/ufs/ufs_inode.c +++ b/sys/ufs/ufs/ufs_inode.c @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.34 2003/02/17 23:48:23 perseant Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.35 2003/03/01 05:07:53 perseant Exp $ */ /* * Copyright (c) 1991, 1993 @@ -41,7 +41,7 @@ */ #include -__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.34 2003/02/17 23:48:23 perseant Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.35 2003/03/01 05:07:53 perseant Exp $"); #include "opt_quota.h" @@ -179,7 +179,7 @@ ufs_balloc_range(vp, off, len, cred, flags) struct ucred *cred; int flags; { - off_t oldeof, neweof, oldeob, neweob, pagestart; + off_t oldeof, neweof, oldeob, oldeop, neweob, pagestart; struct uvm_object *uobj; struct genfs_node *gp = VTOG(vp); int i, delta, error, npages; @@ -192,7 +192,16 @@ ufs_balloc_range(vp, off, len, cred, flags) vp, off, len, vp->v_size); oldeof = vp->v_size; - GOP_SIZE(vp, oldeof, &oldeob, GOP_SIZE_WRITE); + GOP_SIZE(vp, oldeof, &oldeop, GOP_SIZE_WRITE); + GOP_SIZE(vp, oldeof, &oldeob, GOP_SIZE_READ); + + /* + * If we need to map pages in the former last block, + * do so now. + */ + if (oldeob != oldeop) { + uvm_vnp_zerorange(vp, oldeop, oldeob - oldeop); + } neweof = MAX(vp->v_size, off + len); GOP_SIZE(vp, neweof, &neweob, GOP_SIZE_WRITE);