Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/ufs Be careful to always zero pages on truncation/fragme...



details:   https://anonhg.NetBSD.org/src/rev/979194824f7a
branches:  trunk
changeset: 543616:979194824f7a
user:      perseant <perseant%NetBSD.org@localhost>
date:      Sat Mar 01 05:07:51 2003 +0000

description:
Be careful to always zero pages on truncation/fragment extension,
in the case where the filesystem block size is larger than PAGE_SIZE.

diffstat:

 sys/ufs/lfs/lfs_inode.c  |   7 +++----
 sys/ufs/lfs/lfs_vfsops.c |   6 +++---
 sys/ufs/ufs/ufs_inode.c  |  17 +++++++++++++----
 3 files changed, 19 insertions(+), 11 deletions(-)

diffs (100 lines):

diff -r 5d36cbc6c3bd -r 979194824f7a sys/ufs/lfs/lfs_inode.c
--- a/sys/ufs/lfs/lfs_inode.c   Sat Mar 01 04:43:42 2003 +0000
+++ b/sys/ufs/lfs/lfs_inode.c   Sat Mar 01 05:07:51 2003 +0000
@@ -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 @@
                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 -r 5d36cbc6c3bd -r 979194824f7a sys/ufs/lfs/lfs_vfsops.c
--- a/sys/ufs/lfs/lfs_vfsops.c  Sat Mar 01 04:43:42 2003 +0000
+++ b/sys/ufs/lfs/lfs_vfsops.c  Sat Mar 01 05:07:51 2003 +0000
@@ -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 @@
                                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 -r 5d36cbc6c3bd -r 979194824f7a sys/ufs/ufs/ufs_inode.c
--- a/sys/ufs/ufs/ufs_inode.c   Sat Mar 01 04:43:42 2003 +0000
+++ b/sys/ufs/ufs/ufs_inode.c   Sat Mar 01 05:07:51 2003 +0000
@@ -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 @@
        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 @@
                    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);



Home | Main Index | Thread Index | Old Index