summaryrefslogtreecommitdiff
path: root/sys/vm
diff options
context:
space:
mode:
authorConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-10-06 15:29:00 +0000
committerConstantine Sapuntzakis <csapuntz@cvs.openbsd.org>1997-10-06 15:29:00 +0000
commite676b3b5ac1041891584dd10c6bde24b82ebb2f2 (patch)
tree4a8713f46221eee3951af02dd885b8dd8a1bf869 /sys/vm
parent62c64950f8e658fa60106b4d32e70ae3b6156d0d (diff)
VFS Lite2 Changes
Diffstat (limited to 'sys/vm')
-rw-r--r--sys/vm/kern_lock.c538
-rw-r--r--sys/vm/lock.h175
-rw-r--r--sys/vm/vm.h14
-rw-r--r--sys/vm/vm_extern.h4
-rw-r--r--sys/vm/vm_fault.c4
-rw-r--r--sys/vm/vm_glue.c10
-rw-r--r--sys/vm/vm_kern.c4
-rw-r--r--sys/vm/vm_map.c40
-rw-r--r--sys/vm/vm_map.h42
-rw-r--r--sys/vm/vm_meter.c5
-rw-r--r--sys/vm/vm_object.c8
-rw-r--r--sys/vm/vm_object.h4
-rw-r--r--sys/vm/vm_pageout.c4
-rw-r--r--sys/vm/vm_pageout.h4
-rw-r--r--sys/vm/vm_pager.c4
-rw-r--r--sys/vm/vm_pager.h4
-rw-r--r--sys/vm/vm_param.h4
-rw-r--r--sys/vm/vm_unix.c4
-rw-r--r--sys/vm/vnode_pager.c36
19 files changed, 120 insertions, 788 deletions
diff --git a/sys/vm/kern_lock.c b/sys/vm/kern_lock.c
deleted file mode 100644
index 6e856bc9c7b..00000000000
--- a/sys/vm/kern_lock.c
+++ /dev/null
@@ -1,538 +0,0 @@
-/* $OpenBSD: kern_lock.c,v 1.6 1997/07/25 06:03:03 mickey Exp $ */
-/* $NetBSD: kern_lock.c,v 1.10 1994/10/30 19:11:09 cgd Exp $ */
-
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * The Mach Operating System project at Carnegie-Mellon University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)kern_lock.c 8.1 (Berkeley) 6/11/93
- *
- *
- * Copyright (c) 1987, 1990 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Authors: Avadis Tevanian, Jr., Michael Wayne Young
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-/*
- * Locking primitives implementation
- */
-
-#include <sys/param.h>
-#include <sys/systm.h>
-
-#include <vm/vm.h>
-#include <vm/vm_extern.h>
-
-/* XXX */
-#include <sys/proc.h>
-typedef void *thread_t;
-#define current_thread() ((thread_t)&curproc->p_thread)
-/* XXX */
-
-#if NCPUS > 1
-
-/*
- * Module: lock
- * Function:
- * Provide reader/writer sychronization.
- * Implementation:
- * Simple interlock on a bit. Readers first interlock
- * increment the reader count, then let go. Writers hold
- * the interlock (thus preventing further readers), and
- * wait for already-accepted readers to go away.
- */
-
-/*
- * The simple-lock routines are the primitives out of which
- * the lock package is built. The implementation is left
- * to the machine-dependent code.
- */
-
-#ifdef notdef
-/*
- * A sample implementation of simple locks.
- * assumes:
- * boolean_t test_and_set(boolean_t *)
- * indivisibly sets the boolean to TRUE
- * and returns its old value
- * and that setting a boolean to FALSE is indivisible.
- */
-/*
- * simple_lock_init initializes a simple lock. A simple lock
- * may only be used for exclusive locks.
- */
-
-void simple_lock_init(l)
- simple_lock_t l;
-{
- *(boolean_t *)l = FALSE;
-}
-
-void simple_lock(l)
- simple_lock_t l;
-{
- while (test_and_set((boolean_t *)l))
- continue;
-}
-
-void simple_unlock(l)
- simple_lock_t l;
-{
- *(boolean_t *)l = FALSE;
-}
-
-boolean_t simple_lock_try(l)
- simple_lock_t l;
-{
- return (!test_and_set((boolean_t *)l));
-}
-#endif /* notdef */
-#endif /* NCPUS > 1 */
-
-#if NCPUS > 1
-int lock_wait_time = 100;
-#else /* NCPUS > 1 */
-
- /*
- * It is silly to spin on a uni-processor as if we
- * thought something magical would happen to the
- * want_write bit while we are executing.
- */
-int lock_wait_time = 0;
-#endif /* NCPUS > 1 */
-
-
-/*
- * Routine: lock_init
- * Function:
- * Initialize a lock; required before use.
- * Note that clients declare the "struct lock"
- * variables and then initialize them, rather
- * than getting a new one from this module.
- */
-void lock_init(l, can_sleep)
- lock_t l;
- boolean_t can_sleep;
-{
- bzero(l, sizeof(lock_data_t));
- simple_lock_init(&l->interlock);
- l->want_write = FALSE;
- l->want_upgrade = FALSE;
- l->read_count = 0;
- l->can_sleep = can_sleep;
- l->thread = (char *)-1; /* XXX */
- l->recursion_depth = 0;
-}
-
-void lock_sleepable(l, can_sleep)
- lock_t l;
- boolean_t can_sleep;
-{
- simple_lock(&l->interlock);
- l->can_sleep = can_sleep;
- simple_unlock(&l->interlock);
-}
-
-
-/*
- * Sleep locks. These use the same data structure and algorithm
- * as the spin locks, but the process sleeps while it is waiting
- * for the lock. These work on uniprocessor systems.
- */
-
-void lock_write(l)
- register lock_t l;
-{
- register int i;
-
- simple_lock(&l->interlock);
-
- if (((thread_t)l->thread) == current_thread()) {
- /*
- * Recursive lock.
- */
- l->recursion_depth++;
- simple_unlock(&l->interlock);
- return;
- }
-
- /*
- * Try to acquire the want_write bit.
- */
- while (l->want_write) {
- if ((i = lock_wait_time) > 0) {
- simple_unlock(&l->interlock);
- while (--i > 0 && l->want_write)
- continue;
- simple_lock(&l->interlock);
- }
-
- if (l->can_sleep && l->want_write) {
- l->waiting = TRUE;
- thread_sleep(l, &l->interlock, FALSE);
- simple_lock(&l->interlock);
- }
- }
- l->want_write = TRUE;
-
- /* Wait for readers (and upgrades) to finish */
-
- while ((l->read_count != 0) || l->want_upgrade) {
- if ((i = lock_wait_time) > 0) {
- simple_unlock(&l->interlock);
- while (--i > 0 && (l->read_count != 0 ||
- l->want_upgrade))
- continue;
- simple_lock(&l->interlock);
- }
-
- if (l->can_sleep && (l->read_count != 0 || l->want_upgrade)) {
- l->waiting = TRUE;
- thread_sleep(l, &l->interlock, FALSE);
- simple_lock(&l->interlock);
- }
- }
- simple_unlock(&l->interlock);
-}
-
-void lock_done(l)
- register lock_t l;
-{
- simple_lock(&l->interlock);
-
- if (l->read_count != 0)
- l->read_count--;
- else
- if (l->recursion_depth != 0)
- l->recursion_depth--;
- else
- if (l->want_upgrade)
- l->want_upgrade = FALSE;
- else
- l->want_write = FALSE;
-
- if (l->waiting) {
- l->waiting = FALSE;
- thread_wakeup(l);
- }
- simple_unlock(&l->interlock);
-}
-
-void lock_read(l)
- register lock_t l;
-{
- register int i;
-
- simple_lock(&l->interlock);
-
- if (((thread_t)l->thread) == current_thread()) {
- /*
- * Recursive lock.
- */
- l->read_count++;
- simple_unlock(&l->interlock);
- return;
- }
-
- while (l->want_write || l->want_upgrade) {
- if ((i = lock_wait_time) > 0) {
- simple_unlock(&l->interlock);
- while (--i > 0 && (l->want_write || l->want_upgrade))
- continue;
- simple_lock(&l->interlock);
- }
-
- if (l->can_sleep && (l->want_write || l->want_upgrade)) {
- l->waiting = TRUE;
- thread_sleep(l, &l->interlock, FALSE);
- simple_lock(&l->interlock);
- }
- }
-
- l->read_count++;
- simple_unlock(&l->interlock);
-}
-
-/*
- * Routine: lock_read_to_write
- * Function:
- * Improves a read-only lock to one with
- * write permission. If another reader has
- * already requested an upgrade to a write lock,
- * no lock is held upon return.
- *
- * Returns TRUE if the upgrade *failed*.
- */
-boolean_t lock_read_to_write(l)
- register lock_t l;
-{
- register int i;
-
- simple_lock(&l->interlock);
-
- l->read_count--;
-
- if (((thread_t)l->thread) == current_thread()) {
- /*
- * Recursive lock.
- */
- l->recursion_depth++;
- simple_unlock(&l->interlock);
- return(FALSE);
- }
-
- if (l->want_upgrade) {
- /*
- * Someone else has requested upgrade.
- * Since we've released a read lock, wake
- * him up.
- */
- if (l->waiting) {
- l->waiting = FALSE;
- thread_wakeup(l);
- }
-
- simple_unlock(&l->interlock);
- return (TRUE);
- }
-
- l->want_upgrade = TRUE;
-
- while (l->read_count != 0) {
- if ((i = lock_wait_time) > 0) {
- simple_unlock(&l->interlock);
- while (--i > 0 && l->read_count != 0)
- continue;
- simple_lock(&l->interlock);
- }
-
- if (l->can_sleep && l->read_count != 0) {
- l->waiting = TRUE;
- thread_sleep(l, &l->interlock, FALSE);
- simple_lock(&l->interlock);
- }
- }
-
- simple_unlock(&l->interlock);
- return (FALSE);
-}
-
-void lock_write_to_read(l)
- register lock_t l;
-{
- simple_lock(&l->interlock);
-
- l->read_count++;
- if (l->recursion_depth != 0)
- l->recursion_depth--;
- else
- if (l->want_upgrade)
- l->want_upgrade = FALSE;
- else
- l->want_write = FALSE;
-
- if (l->waiting) {
- l->waiting = FALSE;
- thread_wakeup(l);
- }
-
- simple_unlock(&l->interlock);
-}
-
-
-/*
- * Routine: lock_try_write
- * Function:
- * Tries to get a write lock.
- *
- * Returns FALSE if the lock is not held on return.
- */
-
-boolean_t lock_try_write(l)
- register lock_t l;
-{
-
- simple_lock(&l->interlock);
-
- if (((thread_t)l->thread) == current_thread()) {
- /*
- * Recursive lock
- */
- l->recursion_depth++;
- simple_unlock(&l->interlock);
- return(TRUE);
- }
-
- if (l->want_write || l->want_upgrade || l->read_count) {
- /*
- * Can't get lock.
- */
- simple_unlock(&l->interlock);
- return(FALSE);
- }
-
- /*
- * Have lock.
- */
-
- l->want_write = TRUE;
- simple_unlock(&l->interlock);
- return(TRUE);
-}
-
-/*
- * Routine: lock_try_read
- * Function:
- * Tries to get a read lock.
- *
- * Returns FALSE if the lock is not held on return.
- */
-
-boolean_t lock_try_read(l)
- register lock_t l;
-{
- simple_lock(&l->interlock);
-
- if (((thread_t)l->thread) == current_thread()) {
- /*
- * Recursive lock
- */
- l->read_count++;
- simple_unlock(&l->interlock);
- return(TRUE);
- }
-
- if (l->want_write || l->want_upgrade) {
- simple_unlock(&l->interlock);
- return(FALSE);
- }
-
- l->read_count++;
- simple_unlock(&l->interlock);
- return(TRUE);
-}
-
-/*
- * Routine: lock_try_read_to_write
- * Function:
- * Improves a read-only lock to one with
- * write permission. If another reader has
- * already requested an upgrade to a write lock,
- * the read lock is still held upon return.
- *
- * Returns FALSE if the upgrade *failed*.
- */
-boolean_t lock_try_read_to_write(l)
- register lock_t l;
-{
-
- simple_lock(&l->interlock);
-
- if (((thread_t)l->thread) == current_thread()) {
- /*
- * Recursive lock
- */
- l->read_count--;
- l->recursion_depth++;
- simple_unlock(&l->interlock);
- return(TRUE);
- }
-
- if (l->want_upgrade) {
- simple_unlock(&l->interlock);
- return(FALSE);
- }
- l->want_upgrade = TRUE;
- l->read_count--;
-
- while (l->read_count != 0) {
- l->waiting = TRUE;
- thread_sleep(l, &l->interlock, FALSE);
- simple_lock(&l->interlock);
- }
-
- simple_unlock(&l->interlock);
- return(TRUE);
-}
-
-/*
- * Allow a process that has a lock for write to acquire it
- * recursively (for read, write, or update).
- */
-void lock_set_recursive(l)
- lock_t l;
-{
- simple_lock(&l->interlock);
- if (!l->want_write) {
- panic("lock_set_recursive: don't have write lock");
- }
- l->thread = (char *) current_thread();
- simple_unlock(&l->interlock);
-}
-
-/*
- * Prevent a lock from being re-acquired.
- */
-void lock_clear_recursive(l)
- lock_t l;
-{
- simple_lock(&l->interlock);
- if (((thread_t) l->thread) != current_thread()) {
- panic("lock_clear_recursive: wrong thread");
- }
- if (l->recursion_depth == 0)
- l->thread = (char *)-1; /* XXX */
- simple_unlock(&l->interlock);
-}
diff --git a/sys/vm/lock.h b/sys/vm/lock.h
deleted file mode 100644
index 4d64105395e..00000000000
--- a/sys/vm/lock.h
+++ /dev/null
@@ -1,175 +0,0 @@
-/* $OpenBSD: lock.h,v 1.4 1996/08/02 00:05:56 niklas Exp $ */
-/* $NetBSD: lock.h,v 1.8 1994/10/30 19:11:11 cgd Exp $ */
-
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * The Mach Operating System project at Carnegie-Mellon University.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)lock.h 8.1 (Berkeley) 6/11/93
- *
- *
- * Copyright (c) 1987, 1990 Carnegie-Mellon University.
- * All rights reserved.
- *
- * Authors: Avadis Tevanian, Jr., Michael Wayne Young
- *
- * Permission to use, copy, modify and distribute this software and
- * its documentation is hereby granted, provided that both the copyright
- * notice and this permission notice appear in all copies of the
- * software, derivative works or modified versions, and any portions
- * thereof, and that both notices appear in supporting documentation.
- *
- * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
- * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
- * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
- *
- * Carnegie Mellon requests users of this software to return to
- *
- * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
- * School of Computer Science
- * Carnegie Mellon University
- * Pittsburgh PA 15213-3890
- *
- * any improvements or extensions that they make and grant Carnegie the
- * rights to redistribute these changes.
- */
-
-/*
- * Locking primitives definitions
- */
-
-#ifndef _LOCK_H_
-#define _LOCK_H_
-
-#define NCPUS 1 /* XXX */
-
-/*
- * A simple spin lock.
- */
-
-struct slock {
- int lock_data; /* in general 1 bit is sufficient */
-};
-
-typedef struct slock simple_lock_data_t;
-typedef struct slock *simple_lock_t;
-
-/*
- * The general lock structure. Provides for multiple readers,
- * upgrading from read to write, and sleeping until the lock
- * can be gained.
- */
-
-struct lock {
-#ifdef vax
- /*
- * Efficient VAX implementation -- see field description below.
- */
- unsigned int read_count:16,
- want_upgrade:1,
- want_write:1,
- waiting:1,
- can_sleep:1,
- :0;
-
- simple_lock_data_t interlock;
-#else /* vax */
-#ifdef ns32000
- /*
- * Efficient ns32000 implementation --
- * see field description below.
- */
- simple_lock_data_t interlock;
- unsigned int read_count:16,
- want_upgrade:1,
- want_write:1,
- waiting:1,
- can_sleep:1,
- :0;
-
-#else /* ns32000 */
- /* Only the "interlock" field is used for hardware exclusion;
- * other fields are modified with normal instructions after
- * acquiring the interlock bit.
- */
- simple_lock_data_t
- interlock; /* Interlock for remaining fields */
- boolean_t want_write; /* Writer is waiting, or locked for write */
- boolean_t want_upgrade; /* Read-to-write upgrade waiting */
- boolean_t waiting; /* Someone is sleeping on lock */
- boolean_t can_sleep; /* Can attempts to lock go to sleep */
- int read_count; /* Number of accepted readers */
-#endif /* ns32000 */
-#endif /* vax */
- void *thread; /* Thread that has lock, if recursive locking allowed */
- /* (should be thread_t, but but we then have mutually
- recursive definitions) */
- int recursion_depth;/* Depth of recursion */
-};
-
-typedef struct lock lock_data_t;
-typedef struct lock *lock_t;
-
-#if NCPUS > 1
-__BEGIN_DECLS
-void simple_lock __P((simple_lock_t));
-void simple_lock_init __P((simple_lock_t));
-boolean_t simple_lock_try __P((simple_lock_t));
-void simple_unlock __P((simple_lock_t));
-__END_DECLS
-#else /* No multiprocessor locking is necessary. */
-#define simple_lock(l)
-#define simple_lock_init(l)
-#define simple_lock_try(l) (1) /* Always succeeds. */
-#define simple_unlock(l)
-#endif
-
-/* Sleep locks must work even if no multiprocessing. */
-
-#define lock_read_done(l) lock_done(l)
-#define lock_write_done(l) lock_done(l)
-
-void lock_clear_recursive __P((lock_t));
-void lock_done __P((lock_t));
-void lock_init __P((lock_t, boolean_t));
-void lock_read __P((lock_t));
-boolean_t lock_read_to_write __P((lock_t));
-void lock_set_recursive __P((lock_t));
-void lock_sleepable __P((lock_t, boolean_t));
-boolean_t lock_try_read __P((lock_t));
-boolean_t lock_try_read_to_write __P((lock_t));
-boolean_t lock_try_write __P((lock_t));
-void lock_write __P((lock_t));
-void lock_write_to_read __P((lock_t));
-#endif /* !_LOCK_H_ */
diff --git a/sys/vm/vm.h b/sys/vm/vm.h
index 688c7987e8c..5a1775f9ace 100644
--- a/sys/vm/vm.h
+++ b/sys/vm/vm.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm.h,v 1.2 1996/08/02 00:05:58 niklas Exp $ */
+/* $OpenBSD: vm.h,v 1.3 1997/10/06 15:28:51 csapuntz Exp $ */
/* $NetBSD: vm.h,v 1.13 1994/06/29 06:47:52 cgd Exp $ */
/*
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm.h 8.2 (Berkeley) 12/13/93
+ * @(#)vm.h 8.5 (Berkeley) 5/11/95
*/
#ifndef VM_H
@@ -59,10 +59,18 @@ typedef struct vm_page *vm_page_t;
struct pager_struct;
typedef struct pager_struct *vm_pager_t;
+/*
+ * MACH VM locking type mappings to kernel types
+ */
+typedef struct simplelock simple_lock_data_t;
+typedef struct simplelock *simple_lock_t;
+typedef struct lock lock_data_t;
+typedef struct lock *lock_t;
+
#include <sys/vmmeter.h>
#include <sys/queue.h>
#include <vm/vm_param.h>
-#include <vm/lock.h>
+#include <sys/lock.h>
#include <vm/vm_prot.h>
#include <vm/vm_inherit.h>
#include <vm/vm_map.h>
diff --git a/sys/vm/vm_extern.h b/sys/vm/vm_extern.h
index 8f09389aae1..449a3c4d7ee 100644
--- a/sys/vm/vm_extern.h
+++ b/sys/vm/vm_extern.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_extern.h,v 1.11 1997/07/25 06:03:05 mickey Exp $ */
+/* $OpenBSD: vm_extern.h,v 1.12 1997/10/06 15:28:51 csapuntz Exp $ */
/* $NetBSD: vm_extern.h,v 1.20 1996/04/23 12:25:23 christos Exp $ */
/*-
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_extern.h 8.2 (Berkeley) 1/12/94
+ * @(#)vm_extern.h 8.5 (Berkeley) 5/3/95
*/
struct buf;
diff --git a/sys/vm/vm_fault.c b/sys/vm/vm_fault.c
index f2529758cfc..036d768c9ec 100644
--- a/sys/vm/vm_fault.c
+++ b/sys/vm/vm_fault.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_fault.c,v 1.10 1997/07/30 23:32:24 niklas Exp $ */
+/* $OpenBSD: vm_fault.c,v 1.11 1997/10/06 15:28:52 csapuntz Exp $ */
/* $NetBSD: vm_fault.c,v 1.20 1997/02/18 13:39:33 mrg Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_fault.c 8.4 (Berkeley) 1/12/94
+ * @(#)vm_fault.c 8.5 (Berkeley) 1/9/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_glue.c b/sys/vm/vm_glue.c
index a3abdf369da..9d7ae19daeb 100644
--- a/sys/vm/vm_glue.c
+++ b/sys/vm/vm_glue.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_glue.c,v 1.24 1997/07/25 06:03:07 mickey Exp $ */
+/* $OpenBSD: vm_glue.c,v 1.25 1997/10/06 15:28:52 csapuntz Exp $ */
/* $NetBSD: vm_glue.c,v 1.55.4.1 1996/06/13 17:25:45 cgd Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_glue.c 8.6 (Berkeley) 1/5/94
+ * @(#)vm_glue.c 8.9 (Berkeley) 3/4/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
@@ -381,13 +381,16 @@ scheduler()
loop:
#ifdef DEBUG
- while (!enableswap)
+ while (!enableswap) {
+ panic ("swap disabled??");
tsleep((caddr_t)&proc0, PVM, "noswap", 0);
+ }
#endif
pp = NULL;
ppri = INT_MIN;
for (p = allproc.lh_first; p != 0; p = p->p_list.le_next) {
if (p->p_stat == SRUN && (p->p_flag & P_INMEM) == 0) {
+
pri = p->p_swtime + p->p_slptime - p->p_nice * 8;
if (pri > ppri) {
pp = p;
@@ -411,6 +414,7 @@ loop:
* We would like to bring someone in.
* This part is really bogus cuz we could deadlock on memory
* despite our feeble check.
+ * XXX should require at least vm_swrss / 2
*/
if (cnt.v_free_count > atop(USPACE)) {
#ifdef DEBUG
diff --git a/sys/vm/vm_kern.c b/sys/vm/vm_kern.c
index a0af430839c..134fb7fa8de 100644
--- a/sys/vm/vm_kern.c
+++ b/sys/vm/vm_kern.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_kern.c,v 1.5 1997/09/22 15:17:18 chuck Exp $ */
+/* $OpenBSD: vm_kern.c,v 1.6 1997/10/06 15:28:53 csapuntz Exp $ */
/* $NetBSD: vm_kern.c,v 1.17.6.1 1996/06/13 17:21:28 cgd Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_kern.c 8.3 (Berkeley) 1/12/94
+ * @(#)vm_kern.c 8.4 (Berkeley) 1/9/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_map.c b/sys/vm/vm_map.c
index b96f1570623..2cf2387896f 100644
--- a/sys/vm/vm_map.c
+++ b/sys/vm/vm_map.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_map.c,v 1.5 1997/07/25 06:03:07 mickey Exp $ */
+/* $OpenBSD: vm_map.c,v 1.6 1997/10/06 15:28:53 csapuntz Exp $ */
/* $NetBSD: vm_map.c,v 1.23 1996/02/10 00:08:08 christos Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_map.c 8.3 (Berkeley) 1/12/94
+ * @(#)vm_map.c 8.9 (Berkeley) 5/17/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
@@ -75,7 +75,6 @@
#include <vm/vm.h>
#include <vm/vm_page.h>
-#include <vm/vm_object.h>
/*
* Virtual memory maps provide for the mapping, protection,
@@ -267,7 +266,7 @@ vm_map_init(map, min, max, pageable)
map->first_free = &map->header;
map->hint = &map->header;
map->timestamp = 0;
- lock_init(&map->lock, TRUE);
+ lockinit(&map->lock, PVM, "thrd_sleep", 0, 0);
simple_lock_init(&map->ref_lock);
simple_lock_init(&map->hint_lock);
}
@@ -401,12 +400,14 @@ vm_map_deallocate(map)
* to it.
*/
- vm_map_lock(map);
+ vm_map_lock_drain_interlock(map);
(void) vm_map_delete(map, map->min_offset, map->max_offset);
pmap_destroy(map->pmap);
+ vm_map_unlock(map);
+
FREE(map, M_VMMAP);
}
@@ -1195,7 +1196,7 @@ vm_map_pageable(map, start, end, new_pageable)
* If a region becomes completely unwired,
* unwire its physical pages and mappings.
*/
- lock_set_recursive(&map->lock);
+ vm_map_set_recursive(&map->lock);
entry = start_entry;
while ((entry != &map->header) && (entry->start < end)) {
@@ -1207,7 +1208,7 @@ vm_map_pageable(map, start, end, new_pageable)
entry = entry->next;
}
- lock_clear_recursive(&map->lock);
+ vm_map_clear_recursive(&map->lock);
}
else {
@@ -1316,8 +1317,8 @@ vm_map_pageable(map, start, end, new_pageable)
vm_map_unlock(map); /* trust me ... */
}
else {
- lock_set_recursive(&map->lock);
- lock_write_to_read(&map->lock);
+ vm_map_set_recursive(&map->lock);
+ lockmgr(&map->lock, LK_DOWNGRADE, (void *)0, curproc);
}
rv = 0;
@@ -1348,7 +1349,7 @@ vm_map_pageable(map, start, end, new_pageable)
vm_map_lock(map);
}
else {
- lock_clear_recursive(&map->lock);
+ vm_map_clear_recursive(&map->lock);
}
if (rv) {
vm_map_unlock(map);
@@ -2002,7 +2003,7 @@ vm_map_copy(dst_map, src_map,
else {
new_src_map = src_map;
new_src_start = src_entry->start;
- lock_set_recursive(&src_map->lock);
+ vm_map_set_recursive(&src_map->lock);
}
if (dst_entry->is_a_map) {
@@ -2040,7 +2041,7 @@ vm_map_copy(dst_map, src_map,
else {
new_dst_map = dst_map;
new_dst_start = dst_entry->start;
- lock_set_recursive(&dst_map->lock);
+ vm_map_set_recursive(&dst_map->lock);
}
/*
@@ -2052,9 +2053,9 @@ vm_map_copy(dst_map, src_map,
FALSE, FALSE);
if (dst_map == new_dst_map)
- lock_clear_recursive(&dst_map->lock);
+ vm_map_clear_recursive(&dst_map->lock);
if (src_map == new_src_map)
- lock_clear_recursive(&src_map->lock);
+ vm_map_clear_recursive(&src_map->lock);
}
/*
@@ -2423,7 +2424,8 @@ vm_map_lookup(var_map, vaddr, fault_type, out_entry,
* share map to the new object.
*/
- if (lock_read_to_write(&share_map->lock)) {
+ if (lockmgr(&share_map->lock, LK_EXCLUPGRADE,
+ (void *)0, curproc)) {
if (share_map != map)
vm_map_unlock_read(map);
goto RetryLookup;
@@ -2436,7 +2438,8 @@ vm_map_lookup(var_map, vaddr, fault_type, out_entry,
entry->needs_copy = FALSE;
- lock_write_to_read(&share_map->lock);
+ lockmgr(&share_map->lock, LK_DOWNGRADE,
+ (void *)0, curproc);
}
else {
/*
@@ -2453,7 +2456,8 @@ vm_map_lookup(var_map, vaddr, fault_type, out_entry,
*/
if (entry->object.vm_object == NULL) {
- if (lock_read_to_write(&share_map->lock)) {
+ if (lockmgr(&share_map->lock, LK_EXCLUPGRADE,
+ (void *)0, curproc)) {
if (share_map != map)
vm_map_unlock_read(map);
goto RetryLookup;
@@ -2462,7 +2466,7 @@ vm_map_lookup(var_map, vaddr, fault_type, out_entry,
entry->object.vm_object = vm_object_allocate(
(vm_size_t)(entry->end - entry->start));
entry->offset = 0;
- lock_write_to_read(&share_map->lock);
+ lockmgr(&share_map->lock, LK_DOWNGRADE, (void *)0, curproc);
}
/*
diff --git a/sys/vm/vm_map.h b/sys/vm/vm_map.h
index d67ca25e845..8bcc10691a0 100644
--- a/sys/vm/vm_map.h
+++ b/sys/vm/vm_map.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_map.h,v 1.3 1996/08/02 00:06:01 niklas Exp $ */
+/* $OpenBSD: vm_map.h,v 1.4 1997/10/06 15:28:54 csapuntz Exp $ */
/* $NetBSD: vm_map.h,v 1.11 1995/03/26 20:39:10 jtc Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_map.h 8.3 (Berkeley) 3/15/94
+ * @(#)vm_map.h 8.9 (Berkeley) 5/17/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
@@ -162,14 +162,42 @@ typedef struct {
* Perform locking on the data portion of a map.
*/
+#include <sys/proc.h> /* XXX for curproc and p_pid */
+
+#define vm_map_lock_drain_interlock(map) { \
+ lockmgr(&(map)->lock, LK_DRAIN|LK_INTERLOCK, \
+ &(map)->ref_lock, curproc); \
+ (map)->timestamp++; \
+}
+#ifdef DIAGNOSTIC
#define vm_map_lock(map) { \
- lock_write(&(map)->lock); \
+ if (lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc) != 0) { \
+ panic("vm_map_lock: failed to get lock"); \
+ } \
(map)->timestamp++; \
}
-#define vm_map_unlock(map) lock_write_done(&(map)->lock)
-#define vm_map_lock_read(map) lock_read(&(map)->lock)
-#define vm_map_unlock_read(map) lock_read_done(&(map)->lock)
-
+#else
+#define vm_map_lock(map) { \
+ lockmgr(&(map)->lock, LK_EXCLUSIVE, (void *)0, curproc); \
+ (map)->timestamp++; \
+}
+#endif /* DIAGNOSTIC */
+#define vm_map_unlock(map) \
+ lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc)
+#define vm_map_lock_read(map) \
+ lockmgr(&(map)->lock, LK_SHARED, (void *)0, curproc)
+#define vm_map_unlock_read(map) \
+ lockmgr(&(map)->lock, LK_RELEASE, (void *)0, curproc)
+#define vm_map_set_recursive(map) { \
+ simple_lock(&(map)->lk_interlock); \
+ (map)->lk_flags |= LK_CANRECURSE; \
+ simple_unlock(&(map)->lk_interlock); \
+}
+#define vm_map_clear_recursive(map) { \
+ simple_lock(&(map)->lk_interlock); \
+ (map)->lk_flags &= ~LK_CANRECURSE; \
+ simple_unlock(&(map)->lk_interlock); \
+}
/*
* Functions implemented as macros
*/
diff --git a/sys/vm/vm_meter.c b/sys/vm/vm_meter.c
index 3d96b889c5a..f873a44fb81 100644
--- a/sys/vm/vm_meter.c
+++ b/sys/vm/vm_meter.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_meter.c,v 1.4 1997/04/17 01:25:20 niklas Exp $ */
+/* $OpenBSD: vm_meter.c,v 1.5 1997/10/06 15:28:54 csapuntz Exp $ */
/* $NetBSD: vm_meter.c,v 1.18 1996/02/05 01:53:59 christos Exp $ */
/*
@@ -33,7 +33,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_meter.c 8.4 (Berkeley) 1/4/94
+ * @(#)vm_meter.c 8.7 (Berkeley) 5/10/95
*/
#include <sys/param.h>
@@ -223,6 +223,7 @@ vmtotal(totalp)
}
if (object->ref_count > 1) {
/* shared object */
+ simple_unlock(&vm_object_list_lock);
totalp->t_vmshr += num_pages(object->size);
totalp->t_rmshr += object->resident_page_count;
if (object->flags & OBJ_ACTIVE) {
diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c
index b4c7ae54454..2191798d551 100644
--- a/sys/vm/vm_object.c
+++ b/sys/vm/vm_object.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_object.c,v 1.17 1997/07/25 06:03:09 mickey Exp $ */
+/* $OpenBSD: vm_object.c,v 1.18 1997/10/06 15:28:55 csapuntz Exp $ */
/* $NetBSD: vm_object.c,v 1.46 1997/03/30 20:56:12 mycroft Exp $ */
/*-
@@ -66,7 +66,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_object.c 8.5 (Berkeley) 3/22/94
+ * @(#)vm_object.c 8.7 (Berkeley) 5/11/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
@@ -416,10 +416,8 @@ vm_object_terminate(object)
*
* XXX need to do something in the event of a cleaning error.
*/
- if ((object->flags & OBJ_INTERNAL) == 0) {
+ if ((object->flags & OBJ_INTERNAL) == 0)
(void) vm_object_page_clean(object, 0, 0, TRUE, TRUE);
- vm_object_unlock(object);
- }
/*
* Now free the pages.
diff --git a/sys/vm/vm_object.h b/sys/vm/vm_object.h
index 370bab3920b..1ab4e4e717b 100644
--- a/sys/vm/vm_object.h
+++ b/sys/vm/vm_object.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_object.h,v 1.5 1997/04/17 01:25:21 niklas Exp $ */
+/* $OpenBSD: vm_object.h,v 1.6 1997/10/06 15:28:56 csapuntz Exp $ */
/* $NetBSD: vm_object.h,v 1.16 1995/03/29 22:10:28 briggs Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_object.h 8.3 (Berkeley) 1/12/94
+ * @(#)vm_object.h 8.4 (Berkeley) 1/9/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_pageout.c b/sys/vm/vm_pageout.c
index 23585120dd2..2e67ad62b54 100644
--- a/sys/vm/vm_pageout.c
+++ b/sys/vm/vm_pageout.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_pageout.c,v 1.5 1997/04/17 01:25:22 niklas Exp $ */
+/* $OpenBSD: vm_pageout.c,v 1.6 1997/10/06 15:28:56 csapuntz Exp $ */
/* $NetBSD: vm_pageout.c,v 1.23 1996/02/05 01:54:07 christos Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_pageout.c 8.5 (Berkeley) 2/14/94
+ * @(#)vm_pageout.c 8.7 (Berkeley) 6/19/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_pageout.h b/sys/vm/vm_pageout.h
index f07c6fbcf85..8dc02c28b13 100644
--- a/sys/vm/vm_pageout.h
+++ b/sys/vm/vm_pageout.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_pageout.h,v 1.2 1996/08/02 00:06:04 niklas Exp $ */
+/* $OpenBSD: vm_pageout.h,v 1.3 1997/10/06 15:28:57 csapuntz Exp $ */
/* $NetBSD: vm_pageout.h,v 1.11 1995/03/26 20:39:14 jtc Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_pageout.h 8.2 (Berkeley) 1/12/94
+ * @(#)vm_pageout.h 8.3 (Berkeley) 1/9/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_pager.c b/sys/vm/vm_pager.c
index 8adc53ed4b4..6e22f638a73 100644
--- a/sys/vm/vm_pager.c
+++ b/sys/vm/vm_pager.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_pager.c,v 1.5 1996/09/20 06:44:49 deraadt Exp $ */
+/* $OpenBSD: vm_pager.c,v 1.6 1997/10/06 15:28:57 csapuntz Exp $ */
/* $NetBSD: vm_pager.c,v 1.21 1996/03/16 23:15:25 christos Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_pager.c 8.6 (Berkeley) 1/12/94
+ * @(#)vm_pager.c 8.7 (Berkeley) 7/7/94
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_pager.h b/sys/vm/vm_pager.h
index 81e7a361ca2..53faf42aaab 100644
--- a/sys/vm/vm_pager.h
+++ b/sys/vm/vm_pager.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_pager.h,v 1.2 1996/08/02 00:06:05 niklas Exp $ */
+/* $OpenBSD: vm_pager.h,v 1.3 1997/10/06 15:28:57 csapuntz Exp $ */
/* $NetBSD: vm_pager.h,v 1.10 1995/03/26 20:39:15 jtc Exp $ */
/*
@@ -38,7 +38,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_pager.h 8.4 (Berkeley) 1/12/94
+ * @(#)vm_pager.h 8.5 (Berkeley) 7/7/94
*/
/*
diff --git a/sys/vm/vm_param.h b/sys/vm/vm_param.h
index 1348b9021d5..3a18feac870 100644
--- a/sys/vm/vm_param.h
+++ b/sys/vm/vm_param.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_param.h,v 1.8 1997/04/10 13:48:50 deraadt Exp $ */
+/* $OpenBSD: vm_param.h,v 1.9 1997/10/06 15:28:58 csapuntz Exp $ */
/* $NetBSD: vm_param.h,v 1.12 1995/03/26 20:39:16 jtc Exp $ */
/*
@@ -36,7 +36,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vm_param.h 8.1 (Berkeley) 6/11/93
+ * @(#)vm_param.h 8.2 (Berkeley) 1/9/95
*
*
* Copyright (c) 1987, 1990 Carnegie-Mellon University.
diff --git a/sys/vm/vm_unix.c b/sys/vm/vm_unix.c
index 135815a9afe..c5e46bf65f4 100644
--- a/sys/vm/vm_unix.c
+++ b/sys/vm/vm_unix.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vm_unix.c,v 1.5 1997/09/17 17:26:15 weingart Exp $ */
+/* $OpenBSD: vm_unix.c,v 1.6 1997/10/06 15:28:58 csapuntz Exp $ */
/* $NetBSD: vm_unix.c,v 1.19 1996/02/10 00:08:14 christos Exp $ */
/*
@@ -40,7 +40,7 @@
*
* from: Utah $Hdr: vm_unix.c 1.1 89/11/07$
*
- * @(#)vm_unix.c 8.1 (Berkeley) 6/11/93
+ * @(#)vm_unix.c 8.2 (Berkeley) 1/9/95
*/
/*
diff --git a/sys/vm/vnode_pager.c b/sys/vm/vnode_pager.c
index 58eb3712a30..16788808a0a 100644
--- a/sys/vm/vnode_pager.c
+++ b/sys/vm/vnode_pager.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: vnode_pager.c,v 1.3 1996/04/21 22:33:18 deraadt Exp $ */
+/* $OpenBSD: vnode_pager.c,v 1.4 1997/10/06 15:28:59 csapuntz Exp $ */
/* $NetBSD: vnode_pager.c,v 1.19 1996/03/16 23:15:27 christos Exp $ */
/*
@@ -38,7 +38,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * @(#)vnode_pager.c 8.8 (Berkeley) 2/13/94
+ * @(#)vnode_pager.c 8.10 (Berkeley) 5/14/95
*/
/*
@@ -280,7 +280,8 @@ vnode_pager_haspage(pager, offset)
vm_pager_t pager;
vm_offset_t offset;
{
- register vn_pager_t vnp = (vn_pager_t)pager->pg_data;
+ struct proc *p = curproc; /* XXX */
+ vn_pager_t vnp = (vn_pager_t)pager->pg_data;
daddr_t bn;
int err;
@@ -294,9 +295,9 @@ vnode_pager_haspage(pager, offset)
* Lock the vnode first to make sure we have the most recent
* version of the size.
*/
- VOP_LOCK(vnp->vnp_vp);
+ vn_lock(vnp->vnp_vp, LK_EXCLUSIVE | LK_RETRY, p);
if (offset >= vnp->vnp_size) {
- VOP_UNLOCK(vnp->vnp_vp);
+ VOP_UNLOCK(vnp->vnp_vp, 0, p);
#ifdef DEBUG
if (vpagerdebug & (VDB_FAIL|VDB_SIZE))
printf("vnode_pager_haspage: pg %p, off %lx, size %lx\n",
@@ -315,7 +316,7 @@ vnode_pager_haspage(pager, offset)
err = VOP_BMAP(vnp->vnp_vp,
offset / vnp->vnp_vp->v_mount->mnt_stat.f_iosize,
(struct vnode **)0, &bn, NULL);
- VOP_UNLOCK(vnp->vnp_vp);
+ VOP_UNLOCK(vnp->vnp_vp, 0, p);
if (err) {
#ifdef DEBUG
if (vpagerdebug & VDB_FAIL)
@@ -425,7 +426,8 @@ void
vnode_pager_umount(mp)
register struct mount *mp;
{
- register vm_pager_t pager, npager;
+ struct proc *p = curproc; /* XXX */
+ vm_pager_t pager, npager;
struct vnode *vp;
for (pager = vnode_pager_list.tqh_first; pager != NULL; pager = npager){
@@ -436,9 +438,9 @@ vnode_pager_umount(mp)
npager = pager->pg_list.tqe_next;
vp = ((vn_pager_t)pager->pg_data)->vnp_vp;
if (mp == (struct mount *)0 || vp->v_mount == mp) {
- VOP_LOCK(vp);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
(void) vnode_pager_uncache(vp);
- VOP_UNLOCK(vp);
+ VOP_UNLOCK(vp, 0, p);
}
}
}
@@ -455,15 +457,15 @@ boolean_t
vnode_pager_uncache(vp)
register struct vnode *vp;
{
- register vm_object_t object;
+ struct proc *p = curproc; /* XXX */
+ vm_object_t object;
boolean_t uncached;
vm_pager_t pager;
/*
* Not a mapped vnode
*/
- pager = (vm_pager_t)vp->v_vmdata;
- if (pager == NULL)
+ if (vp->v_type != VREG || (pager = (vm_pager_t)vp->v_vmdata) == NULL)
return (TRUE);
#ifdef DEBUG
if (!VOP_ISLOCKED(vp)) {
@@ -492,9 +494,9 @@ vnode_pager_uncache(vp)
object = vm_object_lookup(pager);
if (object) {
uncached = (object->ref_count <= 1);
- VOP_UNLOCK(vp);
+ VOP_UNLOCK(vp, 0, p);
pager_cache(object, FALSE);
- VOP_LOCK(vp);
+ vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
} else
uncached = TRUE;
return(uncached);
@@ -540,9 +542,9 @@ vnode_pager_io(vnp, mlist, npages, sync, rw)
* read beyond EOF (returns error)
* short read
*/
- VOP_LOCK(vnp->vnp_vp);
+ vn_lock(vnp->vnp_vp, LK_EXCLUSIVE | LK_RETRY, p);
if (foff >= vnp->vnp_size) {
- VOP_UNLOCK(vnp->vnp_vp);
+ VOP_UNLOCK(vnp->vnp_vp, 0, p);
vm_pager_unmap_pages(kva, npages);
#ifdef DEBUG
if (vpagerdebug & VDB_SIZE)
@@ -573,7 +575,7 @@ vnode_pager_io(vnp, mlist, npages, sync, rw)
error = VOP_READ(vnp->vnp_vp, &auio, 0, p->p_ucred);
else
error = VOP_WRITE(vnp->vnp_vp, &auio, 0, p->p_ucred);
- VOP_UNLOCK(vnp->vnp_vp);
+ VOP_UNLOCK(vnp->vnp_vp, 0, p);
#ifdef DEBUG
if (vpagerdebug & VDB_IO) {
if (error || auio.uio_resid)