From 9b9a4abb706d28dc13c49605c3c1fdf500af0722 Mon Sep 17 00:00:00 2001 From: oga Date: Mon, 19 Jul 2010 20:58:21 +0000 Subject: [PATCH] Replace XXXLOCKING comments by me (replacing simple_locks that are the same thing) with mutexes. From Gabriel Kihlman (gk AT stacken DOT kth DOT se); thanks! ok art@ ages ago. --- sys/ufs/ufs/ufs_ihash.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/sys/ufs/ufs/ufs_ihash.c b/sys/ufs/ufs/ufs_ihash.c index d7c360afb67..737206c8635 100644 --- a/sys/ufs/ufs/ufs_ihash.c +++ b/sys/ufs/ufs/ufs_ihash.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_ihash.c,v 1.14 2010/04/23 19:57:43 oga Exp $ */ +/* $OpenBSD: ufs_ihash.c,v 1.15 2010/07/19 20:58:21 oga Exp $ */ /* $NetBSD: ufs_ihash.c,v 1.3 1996/02/09 22:36:04 christos Exp $ */ /* @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -48,6 +49,7 @@ LIST_HEAD(ihashhead, inode) *ihashtbl; u_long ihash; /* size of hash table - 1 */ #define INOHASH(device, inum) (&ihashtbl[((device) + (inum)) & ihash]) +struct mutex ihash_mtx = MUTEX_INITIALIZER(IPL_NONE); /* * Initialize inode hash table. @@ -67,11 +69,11 @@ ufs_ihashlookup(dev_t dev, ino_t inum) { struct inode *ip; - /* XXXLOCKING lock hash list */ + mtx_enter(&ihash_mtx); LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) if (inum == ip->i_number && dev == ip->i_dev) break; - /* XXXLOCKING unlock hash list? */ + mtx_leave(&ihash_mtx); if (ip) return (ITOV(ip)); @@ -90,17 +92,17 @@ ufs_ihashget(dev_t dev, ino_t inum) struct inode *ip; struct vnode *vp; loop: - /* XXXLOCKING lock hash list */ + mtx_enter(&ihash_mtx); LIST_FOREACH(ip, INOHASH(dev, inum), i_hash) { if (inum == ip->i_number && dev == ip->i_dev) { vp = ITOV(ip); - /* XXXLOCKING unlock hash list? */ + mtx_leave(&ihash_mtx); if (vget(vp, LK_EXCLUSIVE, p)) goto loop; return (vp); } } - /* XXXLOCKING unlock hash list? */ + mtx_leave(&ihash_mtx); return (NULL); } @@ -118,11 +120,11 @@ ufs_ihashins(struct inode *ip) /* lock the inode, then put it on the appropriate hash list */ lockmgr(&ip->i_lock, LK_EXCLUSIVE, NULL); - /* XXXLOCKING lock hash list */ + mtx_enter(&ihash_mtx); LIST_FOREACH(curip, INOHASH(dev, inum), i_hash) { if (inum == curip->i_number && dev == curip->i_dev) { - /* XXXLOCKING unlock hash list? */ + mtx_leave(&ihash_mtx); lockmgr(&ip->i_lock, LK_RELEASE, NULL); return (EEXIST); } @@ -130,7 +132,7 @@ ufs_ihashins(struct inode *ip) ipp = INOHASH(dev, inum); LIST_INSERT_HEAD(ipp, ip, i_hash); - /* XXXLOCKING unlock hash list? */ + mtx_leave(&ihash_mtx); return (0); } @@ -141,7 +143,7 @@ ufs_ihashins(struct inode *ip) void ufs_ihashrem(struct inode *ip) { - /* XXXLOCKING lock hash list */ + mtx_enter(&ihash_mtx); if (ip->i_hash.le_prev == NULL) return; @@ -151,5 +153,5 @@ ufs_ihashrem(struct inode *ip) ip->i_hash.le_next = NULL; ip->i_hash.le_prev = NULL; #endif - /* XXXLOCKING unlock hash list? */ + mtx_leave(&ihash_mtx); } -- 2.20.1