summaryrefslogtreecommitdiffstats
path: root/sys/fs
diff options
context:
space:
mode:
authoralfred <alfred@FreeBSD.org>2001-05-19 01:28:09 +0000
committeralfred <alfred@FreeBSD.org>2001-05-19 01:28:09 +0000
commita3f0842419d98da211706f921fc626e160cd960b (patch)
treee86922a5639c32e1242d4f3088fc487f3be5b236 /sys/fs
parent9eda9187f024233436e6a743f13bd938b1a0f19c (diff)
downloadFreeBSD-src-a3f0842419d98da211706f921fc626e160cd960b.zip
FreeBSD-src-a3f0842419d98da211706f921fc626e160cd960b.tar.gz
Introduce a global lock for the vm subsystem (vm_mtx).
vm_mtx does not recurse and is required for most low level vm operations. faults can not be taken without holding Giant. Memory subsystems can now call the base page allocators safely. Almost all atomic ops were removed as they are covered under the vm mutex. Alpha and ia64 now need to catch up to i386's trap handlers. FFS and NFS have been tested, other filesystems will need minor changes (grabbing the vm lock when twiddling page properties). Reviewed (partially) by: jake, jhb
Diffstat (limited to 'sys/fs')
-rw-r--r--sys/fs/coda/coda_namecache.c1
-rw-r--r--sys/fs/procfs/procfs_map.c1
-rw-r--r--sys/fs/procfs/procfs_mem.c12
-rw-r--r--sys/fs/specfs/spec_vnops.c4
-rw-r--r--sys/fs/unionfs/union_subr.c1
5 files changed, 18 insertions, 1 deletions
diff --git a/sys/fs/coda/coda_namecache.c b/sys/fs/coda/coda_namecache.c
index 3b73a67..9dfaf19 100644
--- a/sys/fs/coda/coda_namecache.c
+++ b/sys/fs/coda/coda_namecache.c
@@ -81,6 +81,7 @@
#include <sys/errno.h>
#include <sys/lock.h>
#include <sys/malloc.h>
+#include <sys/mutex.h>
#include <sys/ucred.h>
#include <vm/vm.h>
diff --git a/sys/fs/procfs/procfs_map.c b/sys/fs/procfs/procfs_map.c
index 5e4a30c..5c21993 100644
--- a/sys/fs/procfs/procfs_map.c
+++ b/sys/fs/procfs/procfs_map.c
@@ -42,6 +42,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/vnode.h>
diff --git a/sys/fs/procfs/procfs_mem.c b/sys/fs/procfs/procfs_mem.c
index 3a2f8d2..1e28870 100644
--- a/sys/fs/procfs/procfs_mem.c
+++ b/sys/fs/procfs/procfs_mem.c
@@ -48,6 +48,7 @@
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/ptrace.h>
#include <sys/user.h>
@@ -88,8 +89,14 @@ procfs_rwmem(curp, p, uio)
* usage in that process can be messed up.
*/
vm = p->p_vmspace;
- if ((p->p_flag & P_WEXIT) || (vm->vm_refcnt < 1))
+ if ((p->p_flag & P_WEXIT))
return EFAULT;
+
+ mtx_lock(&vm_mtx);
+ if (vm->vm_refcnt < 1) {
+ mtx_unlock(&vm_mtx);
+ return EFAULT;
+ }
++vm->vm_refcnt;
/*
* The map we want...
@@ -207,7 +214,9 @@ procfs_rwmem(curp, p, uio)
/*
* Now do the i/o move.
*/
+ mtx_unlock(&vm_mtx);
error = uiomove((caddr_t)(kva + page_offset), len, uio);
+ mtx_lock(&vm_mtx);
pmap_kremove(kva);
@@ -226,6 +235,7 @@ procfs_rwmem(curp, p, uio)
kmem_free(kernel_map, kva, PAGE_SIZE);
vmspace_free(vm);
+ mtx_unlock(&vm_mtx);
return (error);
}
diff --git a/sys/fs/specfs/spec_vnops.c b/sys/fs/specfs/spec_vnops.c
index 2940f40..ba81229 100644
--- a/sys/fs/specfs/spec_vnops.c
+++ b/sys/fs/specfs/spec_vnops.c
@@ -731,6 +731,8 @@ spec_getpages(ap)
cnt.v_vnodein++;
cnt.v_vnodepgsin += pcount;
+ mtx_unlock(&vm_mtx);
+ mtx_lock(&Giant);
/* Do the input. */
BUF_STRATEGY(bp);
@@ -741,6 +743,8 @@ spec_getpages(ap)
tsleep(bp, PVM, "spread", 0);
splx(s);
+ mtx_unlock(&Giant);
+ mtx_lock(&vm_mtx);
if ((bp->b_ioflags & BIO_ERROR) != 0) {
if (bp->b_error)
diff --git a/sys/fs/unionfs/union_subr.c b/sys/fs/unionfs/union_subr.c
index 869818f..3ac98bf 100644
--- a/sys/fs/unionfs/union_subr.c
+++ b/sys/fs/unionfs/union_subr.c
@@ -45,6 +45,7 @@
#include <sys/filedesc.h>
#include <sys/kernel.h>
#include <sys/lock.h>
+#include <sys/mutex.h>
#include <sys/malloc.h>
#include <sys/module.h>
#include <sys/mount.h>
OpenPOWER on IntegriCloud