From 40c3518aefd420580d257271e0b1dd4f1bcf779f Mon Sep 17 00:00:00 2001 From: Owain Ainsworth Date: Fri, 23 Apr 2010 19:32:58 +0000 Subject: It is about time that we stopped pretending simple_locks are locks. replace ntfs_nthash_slock usage with comments prefixed XXXLOCKING (for grepability). This lock looks to be correct, but it could well be the bad way to do it (having a rwlock for inserts to avoid races inserting the same inode but then simple locking on list accesses). approach discussed with deraadt@ --- sys/ntfs/ntfs_ihash.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'sys') diff --git a/sys/ntfs/ntfs_ihash.c b/sys/ntfs/ntfs_ihash.c index 190f73fa843..de2f7575875 100644 --- a/sys/ntfs/ntfs_ihash.c +++ b/sys/ntfs/ntfs_ihash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ntfs_ihash.c,v 1.6 2009/08/13 16:00:53 jasper Exp $ */ +/* $OpenBSD: ntfs_ihash.c,v 1.7 2010/04/23 19:32:57 oga Exp $ */ /* $NetBSD: ntfs_ihash.c,v 1.1 2002/12/23 17:38:32 jdolecek Exp $ */ /* @@ -36,7 +36,6 @@ #include #include #include -#include #include #include #include @@ -57,9 +56,6 @@ MALLOC_DEFINE(M_NTFSNTHASH, "NTFS nthash", "NTFS ntnode hash tables"); static LIST_HEAD(nthashhead, ntnode) *ntfs_nthashtbl; static u_long ntfs_nthash; /* size of hash table - 1 */ #define NTNOHASH(device, inum) ((minor(device) + (inum)) & ntfs_nthash) -#ifndef NULL_SIMPLELOCKS -static struct simplelock ntfs_nthash_slock; -#endif struct rwlock ntfs_hashlock = RWLOCK_INITIALIZER("ntfs_nthashlock"); /* @@ -70,7 +66,6 @@ ntfs_nthashinit() { ntfs_nthashtbl = HASHINIT(desiredvnodes, M_NTFSNTHASH, M_WAITOK, &ntfs_nthash); - simple_lock_init(&ntfs_nthash_slock); } /* @@ -85,13 +80,13 @@ ntfs_nthashlookup(dev, inum) struct ntnode *ip; struct nthashhead *ipp; - simple_lock(&ntfs_nthash_slock); + /* XXXLOCKING lock hash list? */ ipp = &ntfs_nthashtbl[NTNOHASH(dev, inum)]; LIST_FOREACH(ip, ipp, i_hash) { if (inum == ip->i_number && dev == ip->i_dev) break; } - simple_unlock(&ntfs_nthash_slock); + /* XXXLOCKING unlock hash list? */ return (ip); } @@ -105,11 +100,11 @@ ntfs_nthashins(ip) { struct nthashhead *ipp; - simple_lock(&ntfs_nthash_slock); + /* XXXLOCKING lock hash list? */ ipp = &ntfs_nthashtbl[NTNOHASH(ip->i_dev, ip->i_number)]; LIST_INSERT_HEAD(ipp, ip, i_hash); ip->i_flag |= IN_HASHED; - simple_unlock(&ntfs_nthash_slock); + /* XXXLOCKING unlock hash list? */ } /* @@ -119,10 +114,10 @@ void ntfs_nthashrem(ip) struct ntnode *ip; { - simple_lock(&ntfs_nthash_slock); + /* XXXLOCKING lock hash list? */ if (ip->i_flag & IN_HASHED) { ip->i_flag &= ~IN_HASHED; LIST_REMOVE(ip, i_hash); } - simple_unlock(&ntfs_nthash_slock); + /* XXXLOCKING unlock hash list? */ } -- cgit v1.2.3