Convert nullfs hash lock from a mutex to an rwlock.

This commit is contained in:
Mateusz Guzik 2014-12-30 21:41:35 +00:00
parent af77c1a620
commit cd29b292b8
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=276425

View file

@ -38,7 +38,7 @@
#include <sys/systm.h>
#include <sys/kernel.h>
#include <sys/lock.h>
#include <sys/mutex.h>
#include <sys/rwlock.h>
#include <sys/malloc.h>
#include <sys/mount.h>
#include <sys/proc.h>
@ -57,7 +57,7 @@
#define NULL_NHASH(vp) (&null_node_hashtbl[vfs_hash_index(vp) & null_hash_mask])
static LIST_HEAD(null_node_hashhead, null_node) *null_node_hashtbl;
static struct mtx null_hashmtx;
static struct rwlock null_hash_lock;
static u_long null_hash_mask;
static MALLOC_DEFINE(M_NULLFSHASH, "nullfs_hash", "NULLFS hash table");
@ -75,7 +75,7 @@ nullfs_init(vfsp)
null_node_hashtbl = hashinit(desiredvnodes, M_NULLFSHASH,
&null_hash_mask);
mtx_init(&null_hashmtx, "nullhs", NULL, MTX_DEF);
rw_init(&null_hash_lock, "nullhs");
return (0);
}
@ -84,7 +84,7 @@ nullfs_uninit(vfsp)
struct vfsconf *vfsp;
{
mtx_destroy(&null_hashmtx);
rw_destroy(&null_hash_lock);
hashdestroy(null_node_hashtbl, M_NULLFSHASH, null_hash_mask);
return (0);
}
@ -111,7 +111,7 @@ null_hashget(mp, lowervp)
* reference count (but NOT the lower vnode's VREF counter).
*/
hd = NULL_NHASH(lowervp);
mtx_lock(&null_hashmtx);
rw_rlock(&null_hash_lock);
LIST_FOREACH(a, hd, null_hash) {
if (a->null_lowervp == lowervp && NULLTOV(a)->v_mount == mp) {
/*
@ -122,11 +122,11 @@ null_hashget(mp, lowervp)
*/
vp = NULLTOV(a);
vref(vp);
mtx_unlock(&null_hashmtx);
rw_runlock(&null_hash_lock);
return (vp);
}
}
mtx_unlock(&null_hashmtx);
rw_runlock(&null_hash_lock);
return (NULLVP);
}
@ -144,7 +144,7 @@ null_hashins(mp, xp)
struct vnode *ovp;
hd = NULL_NHASH(xp->null_lowervp);
mtx_lock(&null_hashmtx);
rw_wlock(&null_hash_lock);
LIST_FOREACH(oxp, hd, null_hash) {
if (oxp->null_lowervp == xp->null_lowervp &&
NULLTOV(oxp)->v_mount == mp) {
@ -154,12 +154,12 @@ null_hashins(mp, xp)
*/
ovp = NULLTOV(oxp);
vref(ovp);
mtx_unlock(&null_hashmtx);
rw_wunlock(&null_hash_lock);
return (ovp);
}
}
LIST_INSERT_HEAD(hd, xp, null_hash);
mtx_unlock(&null_hashmtx);
rw_wunlock(&null_hash_lock);
return (NULLVP);
}
@ -277,9 +277,9 @@ null_hashrem(xp)
struct null_node *xp;
{
mtx_lock(&null_hashmtx);
rw_wlock(&null_hash_lock);
LIST_REMOVE(xp, null_hash);
mtx_unlock(&null_hashmtx);
rw_wunlock(&null_hash_lock);
}
#ifdef DIAGNOSTIC