Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs/genfs Protect layer_getpages against vnodes disap...



details:   https://anonhg.NetBSD.org/src/rev/6b26411396bb
branches:  trunk
changeset: 824116:6b26411396bb
user:      hannken <hannken%NetBSD.org@localhost>
date:      Wed May 24 09:54:40 2017 +0000

description:
Protect layer_getpages against vnodes disappearing during a
forced unmount.

diffstat:

 sys/miscfs/genfs/layer_vnops.c |  21 ++++++++++++++++++---
 1 files changed, 18 insertions(+), 3 deletions(-)

diffs (56 lines):

diff -r 482e357b3006 -r 6b26411396bb sys/miscfs/genfs/layer_vnops.c
--- a/sys/miscfs/genfs/layer_vnops.c    Wed May 24 09:54:35 2017 +0000
+++ b/sys/miscfs/genfs/layer_vnops.c    Wed May 24 09:54:40 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $ */
+/*     $NetBSD: layer_vnops.c,v 1.65 2017/05/24 09:54:40 hannken Exp $ */
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -170,7 +170,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.64 2017/05/07 08:21:57 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.65 2017/05/24 09:54:40 hannken Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -183,6 +183,7 @@
 #include <sys/buf.h>
 #include <sys/kauth.h>
 #include <sys/fcntl.h>
+#include <sys/fstrans.h>
 
 #include <miscfs/genfs/layer.h>
 #include <miscfs/genfs/layer_extern.h>
@@ -790,6 +791,8 @@
                int a_flags;
        } */ *ap = v;
        struct vnode *vp = ap->a_vp;
+       struct mount *mp = vp->v_mount;
+       int error;
 
        KASSERT(mutex_owned(vp->v_interlock));
 
@@ -800,7 +803,19 @@
        KASSERT(vp->v_interlock == ap->a_vp->v_interlock);
 
        /* Just pass the request on to the underlying layer. */
-       return VCALL(ap->a_vp, VOFFSET(vop_getpages), ap);
+       mutex_exit(vp->v_interlock);
+       fstrans_start(mp, FSTRANS_SHARED);
+       mutex_enter(vp->v_interlock);
+       if (mp == vp->v_mount) {
+               /* Will release the interlock. */
+               error = VCALL(ap->a_vp, VOFFSET(vop_getpages), ap);
+       } else {
+               mutex_exit(vp->v_interlock);
+               error = ENOENT;
+       }
+       fstrans_done(mp);
+
+       return error;
 }
 
 int



Home | Main Index | Thread Index | Old Index