Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/tmpfs tmpfs_inactive(): do like other file systems an...



details:   https://anonhg.NetBSD.org/src/rev/824405e7755d
branches:  trunk
changeset: 1008189:824405e7755d
user:      ad <ad%NetBSD.org@localhost>
date:      Sat Mar 14 13:39:36 2020 +0000

description:
tmpfs_inactive(): do like other file systems and truncate the file if it
has been deleted.  Otherwise VFS will try to write cached data "back to
disc", which in the case of a UAO means needless page deactivations and
the resulting TLB shootdowns.

diffstat:

 sys/fs/tmpfs/tmpfs_vnops.c |  16 +++++++++++++---
 1 files changed, 13 insertions(+), 3 deletions(-)

diffs (49 lines):

diff -r 7e4c1e02cb26 -r 824405e7755d sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Sat Mar 14 13:37:49 2020 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Sat Mar 14 13:39:36 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vnops.c,v 1.134 2020/02/23 15:46:40 ad Exp $     */
+/*     $NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $     */
 
 /*
  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
@@ -35,7 +35,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.134 2020/02/23 15:46:40 ad Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.135 2020/03/14 13:39:36 ad Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -1040,6 +1040,7 @@
        } */ *ap = v;
        vnode_t *vp = ap->a_vp;
        tmpfs_node_t *node;
+       int error = 0;
 
        KASSERT(VOP_ISLOCKED(vp));
 
@@ -1049,12 +1050,21 @@
                 * Mark node as dead by setting its generation to zero.
                 */
                atomic_and_32(&node->tn_gen, ~TMPFS_NODE_GEN_MASK);
+
+               /*
+                * If the file has been deleted, truncate it, otherwise VFS
+                * will quite rightly try to write back dirty data, which in
+                * the case of tmpfs/UAO means needless page deactivations.
+                */
+               if (vp->v_type == VREG) {
+                       error = tmpfs_reg_resize(vp, 0);
+               }
                *ap->a_recycle = true;
        } else {
                *ap->a_recycle = false;
        }
 
-       return 0;
+       return error;
 }
 
 int



Home | Main Index | Thread Index | Old Index