Source-Changes-HG archive

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

[src/trunk]: src/sys/fs/sysvbfs Mark files removed in the in-memory structure...



details:   https://anonhg.NetBSD.org/src/rev/bf5bcfa8a9f7
branches:  trunk
changeset: 755204:bf5bcfa8a9f7
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu May 27 23:40:12 2010 +0000

description:
Mark files removed in the in-memory structure.  This allows us
to do two things:

 1) properly set "recycle?" in inactive
 2) easily check if we are renaming a removed vnode.  without the
    check, it was possible to enter a dirent in the file system for
    a removed (and hence scheduled to be vcleaned) vnode.  this would
    lead to the succesful vget() of a clean vnode.  the use of the
    cleaned vnode was, however, less succesful, except for purposes
    of crashing.

diffstat:

 sys/fs/sysvbfs/sysvbfs.h       |   3 ++-
 sys/fs/sysvbfs/sysvbfs_vnops.c |  31 +++++++++++++++++++++++++++----
 2 files changed, 29 insertions(+), 5 deletions(-)

diffs (89 lines):

diff -r 5aa3fadd1b8f -r bf5bcfa8a9f7 sys/fs/sysvbfs/sysvbfs.h
--- a/sys/fs/sysvbfs/sysvbfs.h  Thu May 27 23:13:10 2010 +0000
+++ b/sys/fs/sysvbfs/sysvbfs.h  Thu May 27 23:40:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysvbfs.h,v 1.8 2008/09/04 12:07:30 pooka Exp $        */
+/*     $NetBSD: sysvbfs.h,v 1.9 2010/05/27 23:40:12 pooka Exp $        */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -52,6 +52,7 @@
        int update_ctime;
        int update_atime;
        int update_mtime;
+       int removed;
 
        LIST_ENTRY(sysvbfs_node) link;
 };
diff -r 5aa3fadd1b8f -r bf5bcfa8a9f7 sys/fs/sysvbfs/sysvbfs_vnops.c
--- a/sys/fs/sysvbfs/sysvbfs_vnops.c    Thu May 27 23:13:10 2010 +0000
+++ b/sys/fs/sysvbfs/sysvbfs_vnops.c    Thu May 27 23:40:12 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: sysvbfs_vnops.c,v 1.29 2010/05/27 13:22:02 pooka Exp $ */
+/*     $NetBSD: sysvbfs_vnops.c,v 1.30 2010/05/27 23:40:12 pooka Exp $ */
 
 /*-
  * Copyright (c) 2004 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.29 2010/05/27 13:22:02 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: sysvbfs_vnops.c,v 1.30 2010/05/27 23:40:12 pooka Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -481,6 +481,10 @@
                vput(vp);
        vput(dvp);
 
+       if (err == 0) {
+               bnode->removed = 1;
+       }
+
        if (err || (ap->a_cnp->cn_flags & SAVESTART) == 0)
                PNBUF_PUT(ap->a_cnp->cn_pnbuf);
 
@@ -518,11 +522,26 @@
 
        KDASSERT(fvp->v_type == VREG);
        KDASSERT(tvp == NULL ? true : tvp->v_type == VREG);
+       KASSERT(tdvp == fdvp);
+
+       /*
+        * Make sure the source hasn't been removed between lookup
+        * and target directory lock.
+        */
+       if (bnode->removed) {
+               error = ENOENT;
+               goto out;
+       }
 
        error = bfs_file_rename(bfs, from_name, to_name);
  out:
-       if (tvp)
+       if (tvp) {
+               if (error == 0) {
+                       struct sysvbfs_node *tbnode = tvp->v_data;
+                       tbnode->removed = 1;
+               }
                vput(tvp);
+       }
 
        /* tdvp == tvp probably can't happen with this fs, but safety first */
        if (tdvp == tvp)
@@ -604,9 +623,13 @@
                bool *a_recycle;
        } */ *a = arg;
        struct vnode *v = a->a_vp;
+       struct sysvbfs_node *bnode = v->v_data;
 
        DPRINTF("%s:\n", __func__);
-       *a->a_recycle = true;
+       if (bnode->removed)
+               *a->a_recycle = true;
+       else
+               *a->a_recycle = false;
        VOP_UNLOCK(v, 0);
 
        return 0;



Home | Main Index | Thread Index | Old Index