Module Name:    src
Committed By:   ad
Date:           Sat Mar 14 13:39:36 UTC 2020

Modified Files:
        src/sys/fs/tmpfs: tmpfs_vnops.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.134 -r1.135 src/sys/fs/tmpfs/tmpfs_vnops.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/fs/tmpfs/tmpfs_vnops.c
diff -u src/sys/fs/tmpfs/tmpfs_vnops.c:1.134 src/sys/fs/tmpfs/tmpfs_vnops.c:1.135
--- src/sys/fs/tmpfs/tmpfs_vnops.c:1.134	Sun Feb 23 15:46:40 2020
+++ src/sys/fs/tmpfs/tmpfs_vnops.c	Sat Mar 14 13:39:36 2020
@@ -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 @@ tmpfs_inactive(void *v)
 	} */ *ap = v;
 	vnode_t *vp = ap->a_vp;
 	tmpfs_node_t *node;
+	int error = 0;
 
 	KASSERT(VOP_ISLOCKED(vp));
 
@@ -1049,12 +1050,21 @@ tmpfs_inactive(void *v)
 		 * 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

Reply via email to