Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ufs/ffs In ffs_vget, do not hold ufs_haslock across the ...
details: https://anonhg.NetBSD.org/src/rev/9525b9e2203d
branches: trunk
changeset: 493959:9525b9e2203d
user: fvdl <fvdl%NetBSD.org@localhost>
date: Tue Jun 27 23:39:17 2000 +0000
description:
In ffs_vget, do not hold ufs_haslock across the call to getnewvnode.
We may sleep in it, or even recurse, with softdeps. Instead, grab
the lock later, but check if noone else has beaten us to the VFS_VGET
operation, and if so, roll back getnewvnode using vinsheadfree, and
just return.
diffstat:
sys/ufs/ffs/ffs_vfsops.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diffs (42 lines):
diff -r a9739dc09ae2 -r 9525b9e2203d sys/ufs/ffs/ffs_vfsops.c
--- a/sys/ufs/ffs/ffs_vfsops.c Tue Jun 27 23:36:06 2000 +0000
+++ b/sys/ufs/ffs/ffs_vfsops.c Tue Jun 27 23:39:17 2000 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ffs_vfsops.c,v 1.67 2000/06/16 05:45:14 perseant Exp $ */
+/* $NetBSD: ffs_vfsops.c,v 1.68 2000/06/27 23:39:17 fvdl Exp $ */
/*
* Copyright (c) 1989, 1991, 1993, 1994
@@ -1008,17 +1008,27 @@
ump = VFSTOUFS(mp);
dev = ump->um_dev;
- do {
- if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL)
- return (0);
- } while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
+
+ if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL)
+ return (0);
/* Allocate a new vnode/inode. */
if ((error = getnewvnode(VT_UFS, mp, ffs_vnodeop_p, &vp)) != 0) {
*vpp = NULL;
- lockmgr(&ufs_hashlock, LK_RELEASE, 0);
return (error);
}
+
+ /*
+ * If someone beat us to it while sleeping in getnewvnode(),
+ * push back the freshly allocated vnode we don't need, and return.
+ */
+ do {
+ if ((*vpp = ufs_ihashget(dev, ino, LK_EXCLUSIVE)) != NULL) {
+ vinsheadfree(vp);
+ return (0);
+ }
+ } while (lockmgr(&ufs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
+
/*
* XXX MFS ends up here, too, to allocate an inode. Should we
* XXX create another pool for MFS inodes?
Home |
Main Index |
Thread Index |
Old Index