Be careful to always zero pages on truncation/fragment extension,

in the case where the filesystem block size is larger than PAGE_SIZE.
This commit is contained in:
perseant 2003-03-01 05:07:51 +00:00
parent 3cdf0a27ee
commit cfc73a5fa9
3 changed files with 19 additions and 11 deletions

View File

@ -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 <sys/cdefs.h>
__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),

View File

@ -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 <sys/cdefs.h>
__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);

View File

@ -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 <sys/cdefs.h>
__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);