diff --git a/sys/fs/nullfs/null_subr.c b/sys/fs/nullfs/null_subr.c index fa6c4af12577..4d29addb0972 100644 --- a/sys/fs/nullfs/null_subr.c +++ b/sys/fs/nullfs/null_subr.c @@ -38,7 +38,7 @@ #include #include #include -#include +#include #include #include #include @@ -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