Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/fs/tmpfs Lock the source directory during the rename ope...
details: https://anonhg.NetBSD.org/src/rev/75c09904a0d8
branches: trunk
changeset: 584540:75c09904a0d8
user: jmmv <jmmv%NetBSD.org@localhost>
date: Fri Sep 23 14:27:55 2005 +0000
description:
Lock the source directory during the rename operation so that we are safe
to modify it (I hope this is the correct way to go). Avoids triggering an
assertion in the tmpfs_dir_detach function, shown by the t_rename
regression test.
diffstat:
sys/fs/tmpfs/tmpfs_vnops.c | 16 ++++++++++++++--
1 files changed, 14 insertions(+), 2 deletions(-)
diffs (44 lines):
diff -r 1eca531ed39b -r 75c09904a0d8 sys/fs/tmpfs/tmpfs_vnops.c
--- a/sys/fs/tmpfs/tmpfs_vnops.c Fri Sep 23 14:22:27 2005 +0000
+++ b/sys/fs/tmpfs/tmpfs_vnops.c Fri Sep 23 14:27:55 2005 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: tmpfs_vnops.c,v 1.10 2005/09/15 12:34:35 yamt Exp $ */
+/* $NetBSD: tmpfs_vnops.c,v 1.11 2005/09/23 14:27:55 jmmv Exp $ */
/*
* Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -41,7 +41,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.10 2005/09/15 12:34:35 yamt Exp $");
+__KERNEL_RCSID(0, "$NetBSD: tmpfs_vnops.c,v 1.11 2005/09/23 14:27:55 jmmv Exp $");
#include <sys/param.h>
#include <sys/dirent.h>
@@ -845,6 +845,14 @@
}
KASSERT(de->td_node == fnode);
+ /* If we need to move the directory between entries, lock the
+ * source so that we can safely operate on it. */
+ if (fdnode != tdnode) {
+ error = vn_lock(fdvp, LK_EXCLUSIVE | LK_RETRY);
+ if (error != 0)
+ goto out_locked;
+ }
+
/* Ensure that we have enough memory to hold the new name, if it
* has to be changed. */
if (fcnp->cn_namelen != tcnp->cn_namelen ||
@@ -941,6 +949,10 @@
error = 0;
+out_locked:
+ if (fdnode != tdnode)
+ VOP_UNLOCK(fdvp, 0);
+
out:
/* Release target nodes. */
/* XXX: I don't understand when tdvp can be the same as tvp, but
Home |
Main Index |
Thread Index |
Old Index