summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2007-04-23 19:17:01 +0000
committerdes <des@FreeBSD.org>2007-04-23 19:17:01 +0000
commitd5a4cf1cbe02539c3073cba6f89a65720280d265 (patch)
tree0bac482e662701ce2de5cf60d8dba7b32b0f27f0 /sys/fs
parent57f1ae0c23f3c2995016ebfa9744d5ecde4379fa (diff)
downloadFreeBSD-src-d5a4cf1cbe02539c3073cba6f89a65720280d265.zip
FreeBSD-src-d5a4cf1cbe02539c3073cba6f89a65720280d265.tar.gz
Fix old locking bugs which were revealed when pseudofs was made MPSAFE.
Submitted by: tegge
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/pseudofs/pseudofs_vncache.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/sys/fs/pseudofs/pseudofs_vncache.c b/sys/fs/pseudofs/pseudofs_vncache.c
index 1310013..57aa983 100644
--- a/sys/fs/pseudofs/pseudofs_vncache.c
+++ b/sys/fs/pseudofs/pseudofs_vncache.c
@@ -150,10 +150,15 @@ retry:
/* nope, get a new one */
MALLOC(pvd, struct pfs_vdata *, sizeof *pvd, M_PFSVNCACHE, M_WAITOK);
+ mtx_lock(&pfs_vncache_mutex);
if (++pfs_vncache_entries > pfs_vncache_maxentries)
pfs_vncache_maxentries = pfs_vncache_entries;
+ mtx_unlock(&pfs_vncache_mutex);
error = getnewvnode("pseudofs", mp, &pfs_vnodeops, vpp);
if (error) {
+ mtx_lock(&pfs_vncache_mutex);
+ --pfs_vncache_entries;
+ mtx_unlock(&pfs_vncache_mutex);
FREE(pvd, M_PFSVNCACHE);
return (error);
}
@@ -195,6 +200,9 @@ retry:
vn_lock(*vpp, LK_EXCLUSIVE | LK_RETRY, curthread);
error = insmntque(*vpp, mp);
if (error != 0) {
+ mtx_lock(&pfs_vncache_mutex);
+ --pfs_vncache_entries;
+ mtx_unlock(&pfs_vncache_mutex);
FREE(pvd, M_PFSVNCACHE);
*vpp = NULLVP;
return (error);
@@ -226,9 +234,9 @@ pfs_vncache_free(struct vnode *vp)
pvd->pvd_prev->pvd_next = pvd->pvd_next;
else
pfs_vncache = pvd->pvd_next;
+ --pfs_vncache_entries;
mtx_unlock(&pfs_vncache_mutex);
- --pfs_vncache_entries;
FREE(pvd, M_PFSVNCACHE);
vp->v_data = NULL;
return (0);
OpenPOWER on IntegriCloud