Module Name: src Committed By: snj Date: Mon Feb 22 04:43:47 UTC 2010
Modified Files: src/sys/ufs/ext2fs [netbsd-5]: ext2fs_inode.c src/sys/ufs/ffs [netbsd-5]: ffs_inode.c src/sys/ufs/lfs [netbsd-5]: lfs_inode.c src/sys/ufs/ufs [netbsd-5]: ufs_inode.c Log Message: Pull up following revision(s) (requested by bouyer in ticket #1302): sys/ufs/ext2fs/ext2fs_inode.c: revision 1.71 sys/ufs/ffs/ffs_inode.c: revision 1.104 sys/ufs/lfs/lfs_inode.c: revision 1.121 sys/ufs/ufs/ufs_inode.c: revision 1.79 - ufs_balloc_range(): on error, only PG_RELEASED the pages that were allocated to extend the file to the new size. Releasing all pages may release pages that contains previously-written data not yet flushed to disk. Should fix PR kern/35704 - {ffs,lfs,ext2fs}_truncate(): Even if the inode's size is the same as the new length, call uvm_vnp_setsize(). *_truncate() may have been called by *_write() in the error path (e.g. block allocation failure because of quota of file system full), and at this point v_writesize has been set to the desired size of the file and not reverted to the old size. Not adjusting v_writesize to the real size cause genfs_do_io() to write to disk past the real end of the file. To generate a diff of this commit: cvs rdiff -u -r1.66 -r1.66.8.1 src/sys/ufs/ext2fs/ext2fs_inode.c cvs rdiff -u -r1.99 -r1.99.4.1 src/sys/ufs/ffs/ffs_inode.c cvs rdiff -u -r1.120 -r1.120.10.1 src/sys/ufs/lfs/lfs_inode.c cvs rdiff -u -r1.76.4.1 -r1.76.4.2 src/sys/ufs/ufs/ufs_inode.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/ufs/ext2fs/ext2fs_inode.c diff -u src/sys/ufs/ext2fs/ext2fs_inode.c:1.66 src/sys/ufs/ext2fs/ext2fs_inode.c:1.66.8.1 --- src/sys/ufs/ext2fs/ext2fs_inode.c:1.66 Fri May 16 09:22:00 2008 +++ src/sys/ufs/ext2fs/ext2fs_inode.c Mon Feb 22 04:43:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ext2fs_inode.c,v 1.66 2008/05/16 09:22:00 hannken Exp $ */ +/* $NetBSD: ext2fs_inode.c,v 1.66.8.1 2010/02/22 04:43:46 snj Exp $ */ /* * Copyright (c) 1982, 1986, 1989, 1993 @@ -65,7 +65,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.66 2008/05/16 09:22:00 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ext2fs_inode.c,v 1.66.8.1 2010/02/22 04:43:46 snj Exp $"); #include <sys/param.h> #include <sys/systm.h> @@ -277,6 +277,8 @@ return (ext2fs_update(ovp, NULL, NULL, 0)); } if (ext2fs_size(oip) == length) { + /* still do a uvm_vnp_setsize() as writesize may be larger */ + uvm_vnp_setsize(ovp, length); oip->i_flag |= IN_CHANGE | IN_UPDATE; return (ext2fs_update(ovp, NULL, NULL, 0)); } Index: src/sys/ufs/ffs/ffs_inode.c diff -u src/sys/ufs/ffs/ffs_inode.c:1.99 src/sys/ufs/ffs/ffs_inode.c:1.99.4.1 --- src/sys/ufs/ffs/ffs_inode.c:1.99 Sat Aug 30 08:25:53 2008 +++ src/sys/ufs/ffs/ffs_inode.c Mon Feb 22 04:43:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ffs_inode.c,v 1.99 2008/08/30 08:25:53 hannken Exp $ */ +/* $NetBSD: ffs_inode.c,v 1.99.4.1 2010/02/22 04:43:46 snj Exp $ */ /*- * Copyright (c) 2008 The NetBSD Foundation, Inc. @@ -61,7 +61,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.99 2008/08/30 08:25:53 hannken Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ffs_inode.c,v 1.99.4.1 2010/02/22 04:43:46 snj Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -242,6 +242,8 @@ return (ffs_update(ovp, NULL, NULL, 0)); } if (oip->i_size == length) { + /* still do a uvm_vnp_setsize() as writesize may be larger */ + uvm_vnp_setsize(ovp, length); oip->i_flag |= IN_CHANGE | IN_UPDATE; return (ffs_update(ovp, NULL, NULL, 0)); } Index: src/sys/ufs/lfs/lfs_inode.c diff -u src/sys/ufs/lfs/lfs_inode.c:1.120 src/sys/ufs/lfs/lfs_inode.c:1.120.10.1 --- src/sys/ufs/lfs/lfs_inode.c:1.120 Mon Apr 28 20:24:11 2008 +++ src/sys/ufs/lfs/lfs_inode.c Mon Feb 22 04:43:46 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: lfs_inode.c,v 1.120 2008/04/28 20:24:11 martin Exp $ */ +/* $NetBSD: lfs_inode.c,v 1.120.10.1 2010/02/22 04:43:46 snj Exp $ */ /*- * Copyright (c) 1999, 2000, 2001, 2002, 2003 The NetBSD Foundation, Inc. @@ -60,7 +60,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.120 2008/04/28 20:24:11 martin Exp $"); +__KERNEL_RCSID(0, "$NetBSD: lfs_inode.c,v 1.120.10.1 2010/02/22 04:43:46 snj Exp $"); #if defined(_KERNEL_OPT) #include "opt_quota.h" @@ -226,8 +226,11 @@ /* * Just return and not update modification times. */ - if (oip->i_size == length) + if (oip->i_size == length) { + /* still do a uvm_vnp_setsize() as writesize may be larger */ + uvm_vnp_setsize(ovp, length); return (0); + } if (ovp->v_type == VLNK && (oip->i_size < ump->um_maxsymlinklen || Index: src/sys/ufs/ufs/ufs_inode.c diff -u src/sys/ufs/ufs/ufs_inode.c:1.76.4.1 src/sys/ufs/ufs/ufs_inode.c:1.76.4.2 --- src/sys/ufs/ufs/ufs_inode.c:1.76.4.1 Sun Feb 8 19:08:23 2009 +++ src/sys/ufs/ufs/ufs_inode.c Mon Feb 22 04:43:47 2010 @@ -1,4 +1,4 @@ -/* $NetBSD: ufs_inode.c,v 1.76.4.1 2009/02/08 19:08:23 snj Exp $ */ +/* $NetBSD: ufs_inode.c,v 1.76.4.2 2010/02/22 04:43:47 snj Exp $ */ /* * Copyright (c) 1991, 1993 @@ -37,7 +37,7 @@ */ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.76.4.1 2009/02/08 19:08:23 snj Exp $"); +__KERNEL_RCSID(0, "$NetBSD: ufs_inode.c,v 1.76.4.2 2010/02/22 04:43:47 snj Exp $"); #if defined(_KERNEL_OPT) #include "opt_ffs.h" @@ -328,11 +328,11 @@ GOP_SIZE(vp, off + len, &eob, 0); mutex_enter(&uobj->vmobjlock); for (i = 0; i < npages; i++) { - if (error) { - pgs[i]->flags |= PG_RELEASED; - } else if (off <= pagestart + (i << PAGE_SHIFT) && + if (off <= pagestart + (i << PAGE_SHIFT) && pagestart + ((i + 1) << PAGE_SHIFT) <= eob) { pgs[i]->flags &= ~PG_RDONLY; + } else if (error) { + pgs[i]->flags |= PG_RELEASED; } } if (error) {