Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/ntfs convert ntfs_ntlookup() to use lockmgr()-style lock...
details: https://anonhg.NetBSD.org/src/rev/381e61d8b49e
branches: trunk
changeset: 476872:381e61d8b49e
user: jdolecek <jdolecek%NetBSD.org@localhost>
date: Thu Sep 30 16:56:40 1999 +0000
description:
convert ntfs_ntlookup() to use lockmgr()-style locking, instead of it's
home brewed variant
diffstat:
sys/ntfs/ntfs_ihash.c | 5 +++--
sys/ntfs/ntfs_ihash.h | 3 ++-
sys/ntfs/ntfs_subr.c | 32 +++++++++-----------------------
3 files changed, 14 insertions(+), 26 deletions(-)
diffs (104 lines):
diff -r 57ba68f6c249 -r 381e61d8b49e sys/ntfs/ntfs_ihash.c
--- a/sys/ntfs/ntfs_ihash.c Thu Sep 30 14:49:12 1999 +0000
+++ b/sys/ntfs/ntfs_ihash.c Thu Sep 30 16:56:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_ihash.c,v 1.4 1999/09/12 16:41:05 jdolecek Exp $ */
+/* $NetBSD: ntfs_ihash.c,v 1.5 1999/09/30 16:56:40 jdolecek Exp $ */
/*
* Copyright (c) 1982, 1986, 1989, 1991, 1993, 1995
@@ -60,6 +60,7 @@
#ifndef NULL_SIMPLELOCKS
static struct simplelock ntfs_nthash_slock;
#endif
+struct lock ntfs_hashlock;
/*
* Initialize inode hash table.
@@ -67,7 +68,7 @@
void
ntfs_nthashinit()
{
-
+ lockinit(&ntfs_hashlock, PINOD, "ntfs_nthashlock", 0, 0);
ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK,
&ntfs_nthash);
simple_lock_init(&ntfs_nthash_slock);
diff -r 57ba68f6c249 -r 381e61d8b49e sys/ntfs/ntfs_ihash.h
--- a/sys/ntfs/ntfs_ihash.h Thu Sep 30 14:49:12 1999 +0000
+++ b/sys/ntfs/ntfs_ihash.h Thu Sep 30 16:56:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_ihash.h,v 1.3 1999/07/26 14:02:31 jdolecek Exp $ */
+/* $NetBSD: ntfs_ihash.h,v 1.4 1999/09/30 16:56:40 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko
@@ -28,6 +28,7 @@
* Id: ntfs_ihash.h,v 1.3 1999/05/12 09:42:59 semenu Exp
*/
+extern struct lock ntfs_hashlock;
void ntfs_nthashinit __P((void));
struct ntnode *ntfs_nthashlookup __P((dev_t, ino_t));
struct ntnode *ntfs_nthashget __P((dev_t, ino_t));
diff -r 57ba68f6c249 -r 381e61d8b49e sys/ntfs/ntfs_subr.c
--- a/sys/ntfs/ntfs_subr.c Thu Sep 30 14:49:12 1999 +0000
+++ b/sys/ntfs/ntfs_subr.c Thu Sep 30 16:56:40 1999 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ntfs_subr.c,v 1.16 1999/09/29 15:58:28 jdolecek Exp $ */
+/* $NetBSD: ntfs_subr.c,v 1.17 1999/09/30 16:56:40 jdolecek Exp $ */
/*-
* Copyright (c) 1998, 1999 Semen Ustimenko (semenu%FreeBSD.org@localhost)
@@ -382,7 +382,6 @@
*
* ntnode returned locked
*/
-static int ntfs_ntnode_hash_lock;
int
ntfs_ntlookup(
struct ntfsmount * ntmp,
@@ -394,25 +393,14 @@
dprintf(("ntfs_ntlookup: for ntnode %d\n", ino));
*ipp = NULL;
-restart:
- ip = ntfs_nthashlookup(ntmp->ntm_dev, ino); /* XXX */
- if (ip) {
- ntfs_ntget(ip);
- *ipp = ip;
- dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n",
- ino, ip, ip->i_usecount));
-
- return (0);
- }
-
- if (ntfs_ntnode_hash_lock) {
- while(ntfs_ntnode_hash_lock) {
- ntfs_ntnode_hash_lock = -1;
- tsleep(&ntfs_ntnode_hash_lock, PVM, "ntfsntgt", 0);
+ do {
+ if ((*ipp = ntfs_nthashlookup(ntmp->ntm_dev, ino)) != NULL) {
+ ntfs_ntget(*ipp);
+ dprintf(("ntfs_ntlookup: ntnode %d: %p, usecount: %d\n",
+ ino, ip, ip->i_usecount));
+ return (0);
}
- goto restart;
- }
- ntfs_ntnode_hash_lock = 1;
+ } while (lockmgr(&ntfs_hashlock, LK_EXCLUSIVE|LK_SLEEPFAIL, 0));
MALLOC(ip, struct ntnode *, sizeof(struct ntnode),
M_NTFSNTNODE, M_WAITOK);
@@ -434,9 +422,7 @@
ntfs_nthashins(ip);
- if (ntfs_ntnode_hash_lock < 0)
- wakeup(&ntfs_ntnode_hash_lock);
- ntfs_ntnode_hash_lock = 0;
+ lockmgr(&ntfs_hashlock, LK_RELEASE, 0);
*ipp = ip;
Home |
Main Index |
Thread Index |
Old Index