Module Name: src
Committed By: pooka
Date: Thu May 27 23:40:12 UTC 2010
Modified Files:
src/sys/fs/sysvbfs: sysvbfs.h sysvbfs_vnops.c
Log Message:
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.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/fs/sysvbfs/sysvbfs.h
cvs rdiff -u -r1.29 -r1.30 src/sys/fs/sysvbfs/sysvbfs_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/sysvbfs/sysvbfs.h
diff -u src/sys/fs/sysvbfs/sysvbfs.h:1.8 src/sys/fs/sysvbfs/sysvbfs.h:1.9
--- src/sys/fs/sysvbfs/sysvbfs.h:1.8 Thu Sep 4 12:07:30 2008
+++ src/sys/fs/sysvbfs/sysvbfs.h Thu May 27 23:40:12 2010
@@ -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;
};
Index: src/sys/fs/sysvbfs/sysvbfs_vnops.c
diff -u src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.29 src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.30
--- src/sys/fs/sysvbfs/sysvbfs_vnops.c:1.29 Thu May 27 13:22:02 2010
+++ src/sys/fs/sysvbfs/sysvbfs_vnops.c Thu May 27 23:40:12 2010
@@ -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;