svn commit: r276425 - head/sys/fs/nullfs
Mateusz Guzik
mjg at FreeBSD.org
Tue Dec 30 21:42:39 UTC 2014
Author: mjg
Date: Tue Dec 30 21:41:35 2014
New Revision: 276425
URL: https://svnweb.freebsd.org/changeset/base/276425
Log:
Convert nullfs hash lock from a mutex to an rwlock.
Modified:
head/sys/fs/nullfs/null_subr.c
Modified: head/sys/fs/nullfs/null_subr.c
==============================================================================
--- head/sys/fs/nullfs/null_subr.c Tue Dec 30 21:40:45 2014 (r276424)
+++ head/sys/fs/nullfs/null_subr.c Tue Dec 30 21:41:35 2014 (r276425)
@@ -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
More information about the svn-src-all
mailing list