From 5a025167e7ccc8ee68b10b0a68ffc94e4b271700 Mon Sep 17 00:00:00 2001
From: Dima Dorfman
Date: Sun, 27 May 2001 00:42:46 +0000
Subject: [PATCH] Acquire vm_mtx before calling vm_pager_deallocate.
Reviewed by: phk
---
sys/dev/md/md.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/sys/dev/md/md.c b/sys/dev/md/md.c
index 0aafaeca95a..b541b66a154 100644
--- a/sys/dev/md/md.c
+++ b/sys/dev/md/md.c
@@ -711,8 +711,11 @@ mddestroy(struct md_s *sc, struct md_ioctl *mdio, struct proc *p)
(void)vn_close(sc->vnode, sc->flags & MD_READONLY ? FREAD : (FREAD|FWRITE), sc->cred, p);
if (sc->cred != NULL)
crfree(sc->cred);
- if (sc->object != NULL)
+ if (sc->object != NULL) {
+ mtx_lock(&vm_mtx);
vm_pager_deallocate(sc->object);
+ mtx_unlock(&vm_mtx);
+ }
if (sc->secp != NULL) {
for (u = 0; u < sc->nsect; u++)
if ((uintptr_t)sc->secp[u] > 255)
@@ -763,17 +766,20 @@ mdcreate_swap(struct md_ioctl *mdio, struct proc *p)
* Note the truncation.
*/
+ mtx_lock(&vm_mtx);
sc->secsize = PAGE_SIZE;
sc->nsect = mdio->md_size / (PAGE_SIZE / DEV_BSIZE);
sc->object = vm_pager_allocate(OBJT_SWAP, NULL, sc->secsize * (vm_offset_t)sc->nsect, VM_PROT_DEFAULT, 0);
if (mdio->md_options & MD_RESERVE) {
if (swap_pager_reserve(sc->object, 0, sc->nsect) < 0) {
vm_pager_deallocate(sc->object);
+ mtx_unlock(&vm_mtx);
sc->object = NULL;
mddestroy(sc, mdio, p);
return(EDOM);
}
}
+ mtx_unlock(&vm_mtx);
error = mdsetcred(sc, p->p_ucred);
if (error)
mddestroy(sc, mdio, p);