Backout the last commit. _S is also true for a few control codes for which
[dragonfly.git] / sys / vm / vm_rangelock.c
blob679794477924d4f161cd26c31a0d485ebe5c231e
1 /*
2 * Copyright (c) 2003,2004 The DragonFly Project. All rights reserved.
3 *
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
34 * VM range locking module. Range locks within VM objects are used to protect
35 * I/O operations and will eventually also be used in an extended form
36 * for cache coherency control.
38 * $DragonFly: src/sys/vm/vm_rangelock.c,v 1.2 2004/07/16 05:52:14 dillon Exp $
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/proc.h> /* for curproc, pageproc */
43 #include <sys/vnode.h>
44 #include <sys/vmmeter.h>
45 #include <sys/mman.h>
46 #include <sys/mount.h>
47 #include <sys/kernel.h>
48 #include <sys/sysctl.h>
50 #include <vm/vm.h>
51 #include <vm/vm_param.h>
52 #include <vm/pmap.h>
53 #include <vm/vm_map.h>
54 #include <vm/vm_object.h>
55 #include <vm/vm_page.h>
56 #include <vm/vm_pageout.h>
57 #include <vm/vm_pager.h>
58 #include <vm/swap_pager.h>
59 #include <vm/vm_kern.h>
60 #include <vm/vm_extern.h>
61 #include <vm/vm_zone.h>
64 * Note: these routines are currently greatly simplified and unoptimized.
66 * Locks are sorted by base address.
68 void
69 shlock_range(vm_object_lock_t lock, vm_object_t object, off_t base, off_t bytes)
71 struct vm_object_lock **plock;
72 vm_object_lock_t scan;
75 * Locate the insertion point and check for conflicts
77 again:
78 for (plock = &object->range_locks;
79 (scan = *plock) != NULL;
80 plock = &scan->next
81 ) {
82 if (base < scan->base + scan->bytes && base + bytes > scan->base) {
83 if (scan->type != VMOBJ_LOCK_SHARED) {
84 tsleep(scan
90 void
91 exlock_range(vm_object_lock_t lock, vm_object_t object, off_t base, off_t bytes)
95 void
96 unlock_range(vm_object_lock_t lock)