Source-Changes-HG archive

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

[src/trunk]: src/sys/miscfs Since VOP_UPCALL() has been a long time in coming...



details:   https://anonhg.NetBSD.org/src/rev/86d1b560c4df
branches:  trunk
changeset: 567030:86d1b560c4df
user:      wrstuden <wrstuden%NetBSD.org@localhost>
date:      Fri May 28 18:55:20 2004 +0000

description:
Since VOP_UPCALL() has been a long time in coming, add this partial
fix for layered-file-removal. It will work for the case of accessing
and deleting a file through the layered file system. Accessing via
the layer and deleting on the underlying still won't work, nor will
accessing via complicated structures (like two umap layers over a
given file systems).

We still need VOP_UPCALL(), but this is better than things were before.

This patch has been discussed off & on for a while. This incarnation
was tested by hannken at netbsd dot org.

diffstat:

 sys/miscfs/genfs/layer.h           |   3 ++-
 sys/miscfs/genfs/layer_extern.h    |   3 ++-
 sys/miscfs/genfs/layer_vnops.c     |  36 +++++++++++++++++++++++++++++++-----
 sys/miscfs/nullfs/null_vnops.c     |   5 +++--
 sys/miscfs/overlay/overlay_vnops.c |   7 ++++---
 sys/miscfs/umapfs/umap_vnops.c     |   5 +++--
 6 files changed, 45 insertions(+), 14 deletions(-)

diffs (189 lines):

diff -r 82535db43d9b -r 86d1b560c4df sys/miscfs/genfs/layer.h
--- a/sys/miscfs/genfs/layer.h  Fri May 28 17:52:06 2004 +0000
+++ b/sys/miscfs/genfs/layer.h  Fri May 28 18:55:20 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer.h,v 1.5 2003/08/07 16:32:35 agc Exp $    */
+/*     $NetBSD: layer.h,v 1.6 2004/05/28 18:55:20 wrstuden Exp $       */
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -116,6 +116,7 @@
 };
 
 #define        LAYERFS_RESFLAGS        0x00000fff      /* flags reserved for layerfs */
+#define        LAYERFS_REMOVED         0x00000001      /* Did a remove on this node */
 
 /*
  * The following macros handle upperfs-specific locking. They are needed
diff -r 82535db43d9b -r 86d1b560c4df sys/miscfs/genfs/layer_extern.h
--- a/sys/miscfs/genfs/layer_extern.h   Fri May 28 17:52:06 2004 +0000
+++ b/sys/miscfs/genfs/layer_extern.h   Fri May 28 18:55:20 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer_extern.h,v 1.13 2004/04/27 17:37:31 jrf Exp $    */
+/*     $NetBSD: layer_extern.h,v 1.14 2004/05/28 18:55:20 wrstuden Exp $       */
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -110,5 +110,6 @@
 int    layer_setattr __P((void *));
 int    layer_access __P((void *));
 int    layer_open __P((void *));
+int    layer_remove __P((void *));
 int    layer_getpages __P((void *));
 int    layer_putpages __P((void *));
diff -r 82535db43d9b -r 86d1b560c4df sys/miscfs/genfs/layer_vnops.c
--- a/sys/miscfs/genfs/layer_vnops.c    Fri May 28 17:52:06 2004 +0000
+++ b/sys/miscfs/genfs/layer_vnops.c    Fri May 28 18:55:20 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: layer_vnops.c,v 1.15 2004/04/21 01:05:41 christos Exp $        */
+/*     $NetBSD: layer_vnops.c,v 1.16 2004/05/28 18:55:20 wrstuden Exp $        */
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -67,7 +67,7 @@
  *
  * Ancestors:
  *     @(#)lofs_vnops.c        1.2 (Berkeley) 6/18/92
- *     $Id: layer_vnops.c,v 1.15 2004/04/21 01:05:41 christos Exp $
+ *     $Id: layer_vnops.c,v 1.16 2004/05/28 18:55:20 wrstuden Exp $
  *     ...and...
  *     @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
  */
@@ -232,7 +232,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.15 2004/04/21 01:05:41 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: layer_vnops.c,v 1.16 2004/05/28 18:55:20 wrstuden Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -750,13 +750,39 @@
         */
        VOP_UNLOCK(vp, 0);
 
-       /* ..., but don't cache the device node. */
-       if (vp->v_type == VBLK || vp->v_type == VCHR)
+       /*
+        * ..., but don't cache the device node. Also, if we did a
+        * remove, don't cache the node.
+        */
+       if (vp->v_type == VBLK || vp->v_type == VCHR
+           || (VTOLAYER(vp)->layer_flags & LAYERFS_REMOVED))
                vgone(vp);
        return (0);
 }
 
 int
+layer_remove(v)
+       void *v;
+{
+       struct vop_remove_args /* {
+               struct vonde            *a_dvp;
+               struct vnode            *a_vp;
+               struct componentname    *a_cnp;
+       } */ *ap = v;
+
+       int             error;
+       struct vnode    *vp = ap->a_vp;
+
+       vref(vp);
+       if ((error = LAYERFS_DO_BYPASS(vp, ap)) == 0)
+               VTOLAYER(vp)->layer_flags |= LAYERFS_REMOVED;
+
+       vrele(vp);
+
+       return (error);
+}
+
+int
 layer_reclaim(v)
        void *v;
 {
diff -r 82535db43d9b -r 86d1b560c4df sys/miscfs/nullfs/null_vnops.c
--- a/sys/miscfs/nullfs/null_vnops.c    Fri May 28 17:52:06 2004 +0000
+++ b/sys/miscfs/nullfs/null_vnops.c    Fri May 28 18:55:20 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: null_vnops.c,v 1.28 2004/01/25 18:06:49 hannken Exp $  */
+/*     $NetBSD: null_vnops.c,v 1.29 2004/05/28 18:55:20 wrstuden Exp $ */
 
 /*
  * Copyright (c) 1999 National Aeronautics & Space Administration
@@ -203,7 +203,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: null_vnops.c,v 1.28 2004/01/25 18:06:49 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: null_vnops.c,v 1.29 2004/05/28 18:55:20 wrstuden Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -236,6 +236,7 @@
        { &vop_inactive_desc, layer_inactive },
        { &vop_reclaim_desc,  layer_reclaim },
        { &vop_print_desc,    layer_print },
+       { &vop_remove_desc,   layer_remove },
 
        { &vop_open_desc,     layer_open },     /* mount option handling */
 
diff -r 82535db43d9b -r 86d1b560c4df sys/miscfs/overlay/overlay_vnops.c
--- a/sys/miscfs/overlay/overlay_vnops.c        Fri May 28 17:52:06 2004 +0000
+++ b/sys/miscfs/overlay/overlay_vnops.c        Fri May 28 18:55:20 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: overlay_vnops.c,v 1.11 2004/01/25 18:06:49 hannken Exp $       */
+/*     $NetBSD: overlay_vnops.c,v 1.12 2004/05/28 18:55:20 wrstuden Exp $      */
 
 /*
  * Copyright (c) 1999, 2000 National Aeronautics & Space Administration
@@ -67,7 +67,7 @@
  *
  * Ancestors:
  *     @(#)lofs_vnops.c        1.2 (Berkeley) 6/18/92
- *     $Id: overlay_vnops.c,v 1.11 2004/01/25 18:06:49 hannken Exp $
+ *     $Id: overlay_vnops.c,v 1.12 2004/05/28 18:55:20 wrstuden Exp $
  *     ...and...
  *     @(#)null_vnodeops.c 1.20 92/07/07 UCLA Ficus project
  */
@@ -126,7 +126,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: overlay_vnops.c,v 1.11 2004/01/25 18:06:49 hannken Exp $");
+__KERNEL_RCSID(0, "$NetBSD: overlay_vnops.c,v 1.12 2004/05/28 18:55:20 wrstuden Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -159,6 +159,7 @@
        { &vop_inactive_desc, layer_inactive },
        { &vop_reclaim_desc,  layer_reclaim },
        { &vop_print_desc,    layer_print },
+       { &vop_remove_desc,   layer_remove },
 
        { &vop_open_desc,     layer_open },     /* mount option handling */
 
diff -r 82535db43d9b -r 86d1b560c4df sys/miscfs/umapfs/umap_vnops.c
--- a/sys/miscfs/umapfs/umap_vnops.c    Fri May 28 17:52:06 2004 +0000
+++ b/sys/miscfs/umapfs/umap_vnops.c    Fri May 28 18:55:20 2004 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: umap_vnops.c,v 1.25 2004/04/21 01:05:42 christos Exp $ */
+/*     $NetBSD: umap_vnops.c,v 1.26 2004/05/28 18:55:20 wrstuden Exp $ */
 
 /*
  * Copyright (c) 1992, 1993
@@ -39,7 +39,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: umap_vnops.c,v 1.25 2004/04/21 01:05:42 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: umap_vnops.c,v 1.26 2004/05/28 18:55:20 wrstuden Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -84,6 +84,7 @@
        { &vop_open_desc,       layer_open },
        { &vop_setattr_desc,    layer_setattr },
        { &vop_access_desc,     layer_access },
+       { &vop_remove_desc,     layer_remove },
 
        { &vop_bwrite_desc,     layer_bwrite },
        { &vop_bmap_desc,       layer_bmap },



Home | Main Index | Thread Index | Old Index