Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/tmpfs Protect tmpfs_getpages() against reclaiming vno...



details:   https://anonhg.NetBSD.org/src/rev/388cb982fbea
branches:  trunk
changeset: 822644:388cb982fbea
user:      hannken <hannken%NetBSD.org@localhost>
date:      Thu Mar 30 09:09:26 2017 +0000

description:
Protect tmpfs_getpages() against reclaiming vnodes.

diffstat:

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

diffs (41 lines):

diff -r 3a4126be630a -r 388cb982fbea sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c        Thu Mar 30 08:44:33 2017 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c        Thu Mar 30 09:09:26 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: tmpfs_vnops.c,v 1.129 2017/01/11 12:12:32 joerg Exp $  */
+/*     $NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken 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.129 2017/01/11 12:12:32 joerg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.130 2017/03/30 09:09:26 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/dirent.h>
@@ -1165,9 +1165,6 @@
        KASSERT(vp->v_type == VREG);
        KASSERT(mutex_owned(vp->v_interlock));
 
-       node = VP_TO_TMPFS_NODE(vp);
-       uobj = node->tn_spec.tn_reg.tn_aobj;
-
        /*
         * Currently, PGO_PASTEOF is not supported.
         */
@@ -1184,6 +1181,12 @@
        if ((flags & PGO_LOCKED) != 0)
                return EBUSY;
 
+       if (vdead_check(vp, VDEAD_NOWAIT) != 0)
+               return ENOENT;
+
+       node = VP_TO_TMPFS_NODE(vp);
+       uobj = node->tn_spec.tn_reg.tn_aobj;
+
        if ((flags & PGO_NOTIMESTAMP) == 0) {
                u_int tflags = 0;
 



Home | Main Index | Thread Index | Old Index