Source-Changes-HG archive

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

[src/trunk]: src/sys/nfs invalidate cache if filesize is changed besides our ...



details:   https://anonhg.NetBSD.org/src/rev/af5bf05b4fd0
branches:  trunk
changeset: 572605:af5bf05b4fd0
user:      yamt <yamt%NetBSD.org@localhost>
date:      Sun Jan 09 01:32:32 2005 +0000

description:
invalidate cache if filesize is changed besides our activity
because it means that we're out of sync with the server.

diffstat:

 sys/nfs/nfs_subs.c |  25 +++++++++++++++----------
 sys/nfs/nfsnode.h  |   5 +++--
 2 files changed, 18 insertions(+), 12 deletions(-)

diffs (73 lines):

diff -r c7f4283e9fd2 -r af5bf05b4fd0 sys/nfs/nfs_subs.c
--- a/sys/nfs/nfs_subs.c        Sun Jan 09 01:27:47 2005 +0000
+++ b/sys/nfs/nfs_subs.c        Sun Jan 09 01:32:32 2005 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: nfs_subs.c,v 1.139 2005/01/06 11:52:44 yamt Exp $      */
+/*     $NetBSD: nfs_subs.c,v 1.140 2005/01/09 01:32:32 yamt Exp $      */
 
 /*
  * Copyright (c) 1989, 1993
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.139 2005/01/06 11:52:44 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nfs_subs.c,v 1.140 2005/01/09 01:32:32 yamt Exp $");
 
 #include "fs_nfs.h"
 #include "opt_nfs.h"
@@ -1816,15 +1816,17 @@
                } else {
                        np->n_size = vap->va_size;
                        if (vap->va_type == VREG) {
-                               if ((flags & NAC_NOTRUNC)
-                                   && np->n_size < vp->v_size) {
-                                       /*
-                                        * we can't free pages now because
-                                        * the pages can be owned by ourselves.
-                                        */
+                               /*
+                                * we can't free pages if NAC_NOTRUNC because
+                                * the pages can be owned by ourselves.
+                                */
+                               if (flags & NAC_NOTRUNC) {
                                        np->n_flag |= NTRUNCDELAYED;
-                               }
-                               else {
+                               } else {
+                                       simple_lock(&vp->v_interlock);
+                                       (void)VOP_PUTPAGES(vp, 0,
+                                           0, PGO_SYNCIO | PGO_CLEANIT |
+                                           PGO_FREE | PGO_ALLPAGES);
                                        uvm_vnp_setsize(vp, np->n_size);
                                }
                        }
@@ -1894,6 +1896,9 @@
 
        if (np->n_flag & NTRUNCDELAYED) {
                np->n_flag &= ~NTRUNCDELAYED;
+               simple_lock(&vp->v_interlock);
+               (void)VOP_PUTPAGES(vp, 0,
+                   0, PGO_SYNCIO | PGO_CLEANIT | PGO_FREE | PGO_ALLPAGES);
                uvm_vnp_setsize(vp, np->n_size);
        }
 }
diff -r c7f4283e9fd2 -r af5bf05b4fd0 sys/nfs/nfsnode.h
--- a/sys/nfs/nfsnode.h Sun Jan 09 01:27:47 2005 +0000
+++ b/sys/nfs/nfsnode.h Sun Jan 09 01:32:32 2005 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: nfsnode.h,v 1.52 2005/01/08 03:12:31 yamt Exp $       */
+/*      $NetBSD: nfsnode.h,v 1.53 2005/01/09 01:32:32 yamt Exp $       */
 
 /*
  * Copyright (c) 1989, 1993
@@ -206,7 +206,8 @@
 #define        NACC            0x0100  /* Special file accessed */
 #define        NUPD            0x0200  /* Special file updated */
 #define        NCHG            0x0400  /* Special file times changed */
-#define        NTRUNCDELAYED   0x1000  /* Should be truncated later */
+#define        NTRUNCDELAYED   0x1000  /* Should be truncated later;
+                                  implies stale cache */
 #define        NREMOVED        0x2000  /* Has been removed */
 #define        NUSEOPENCRED    0x4000  /* Try open cred first rather than owner's */
 



Home | Main Index | Thread Index | Old Index