Deleted Added
full compact
default_pager.c (40286) default_pager.c (42957)
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
1/*
2 * Copyright (c) 1995, David Greenman
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 14 unchanged lines hidden (view full) ---

23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 * SUCH DAMAGE.
30 *
31 * $Id: default_pager.c,v 1.15 1998/02/06 12:14:20 eivind Exp $
31 * The default pager is responsible for supplying backing store to unbacked
32 * storage. The backing store is usually swap so we just fall through to
33 * the swap routines. However, since swap metadata has not been assigned,
34 * the swap routines assign and manage the swap backing store through the
35 * vm_page->swapblk field. The object is only converted when the page is
36 * physically freed after having been cleaned and even then vm_page->swapblk
37 * is maintained whenever a resident page also has swap backing store.
38 *
39 * $Id: default_pager.c,v 1.16 1998/10/13 08:24:42 dg Exp $
32 */
33
34#include <sys/param.h>
35#include <sys/systm.h>
36#include <sys/malloc.h>
37#include <sys/vmmeter.h>
38
39#include <vm/vm.h>

--- 33 unchanged lines hidden (view full) ---

73 vm_ooffset_t offset)
74{
75 if (handle != NULL)
76 panic("default_pager_alloc: handle specified");
77
78 return vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(round_page(offset + size)));
79}
80
40 */
41
42#include <sys/param.h>
43#include <sys/systm.h>
44#include <sys/malloc.h>
45#include <sys/vmmeter.h>
46
47#include <vm/vm.h>

--- 33 unchanged lines hidden (view full) ---

81 vm_ooffset_t offset)
82{
83 if (handle != NULL)
84 panic("default_pager_alloc: handle specified");
85
86 return vm_object_allocate(OBJT_DEFAULT, OFF_TO_IDX(round_page(offset + size)));
87}
88
89/*
90 * deallocate resources associated with default objects. The default objects
91 * have no special resources allocated to them, but the vm_page's being used
92 * in this object might. Still, we do not have to do anything - we will free
93 * the swapblk in the underlying vm_page's when we free the vm_page or
94 * garbage collect the vm_page cache list.
95 */
96
81static void
82default_pager_dealloc(object)
83 vm_object_t object;
84{
85 /*
86 * OBJT_DEFAULT objects have no special resources allocated to them.
87 */
88}
89
90/*
97static void
98default_pager_dealloc(object)
99 vm_object_t object;
100{
101 /*
102 * OBJT_DEFAULT objects have no special resources allocated to them.
103 */
104}
105
106/*
91 * The default pager has no backing store, so we always return
92 * failure.
107 * Load pages from backing store. Since OBJT_DEFAULT is converted to
108 * OBJT_SWAP at the time a swap-backed vm_page_t is freed, we will never
109 * see a vm_page with assigned swap here.
93 */
110 */
111
94static int
95default_pager_getpages(object, m, count, reqpage)
96 vm_object_t object;
97 vm_page_t *m;
98 int count;
99 int reqpage;
100{
101 return VM_PAGER_FAIL;
102}
103
112static int
113default_pager_getpages(object, m, count, reqpage)
114 vm_object_t object;
115 vm_page_t *m;
116 int count;
117 int reqpage;
118{
119 return VM_PAGER_FAIL;
120}
121
122/*
123 * Store pages to backing store. We should assign swap and initiate
124 * I/O. We do not actually convert the object to OBJT_SWAP here. The
125 * object will be converted when the written-out vm_page_t is moved from the
126 * cache to the free list.
127 */
128
104static int
105default_pager_putpages(object, m, c, sync, rtvals)
106 vm_object_t object;
107 vm_page_t *m;
108 int c;
109 boolean_t sync;
110 int *rtvals;
111{
129static int
130default_pager_putpages(object, m, c, sync, rtvals)
131 vm_object_t object;
132 vm_page_t *m;
133 int c;
134 boolean_t sync;
135 int *rtvals;
136{
112 int i;
113
114 /*
115 * Try to convert the object type into a OBJT_SWAP.
116 * If the swp structure allocation fails, convert it
117 * back to OBJT_DEFAULT and return failure. Otherwise
118 * pass this putpages to the swap pager.
119 */
120 object->type = OBJT_SWAP;
121
122 if (swap_pager_swp_alloc(object, M_KERNEL) != 0) {
123 object->type = OBJT_DEFAULT;
124 for (i = 0; i < c; i++)
125 rtvals[i] = VM_PAGER_FAIL;
126 return VM_PAGER_FAIL;
127 }
128
129 return swap_pager_putpages(object, m, c, sync, rtvals);
130}
131
137 return swap_pager_putpages(object, m, c, sync, rtvals);
138}
139
140/*
141 * Tell us whether the backing store for the requested (object,index) is
142 * synchronized. i.e. tell us whether we can throw the page away and
143 * reload it later. So, for example, if we are in the process of writing
144 * the page to its backing store, or if no backing store has been assigned,
145 * it is not yet synchronized.
146 *
147 * It is possible to have fully-synchronized swap assigned without the
148 * object having been converted. We just call swap_pager_haspage() to
149 * deal with it since it must already deal with it plus deal with swap
150 * meta-data structures.
151 */
152
132static boolean_t
133default_pager_haspage(object, pindex, before, after)
134 vm_object_t object;
135 vm_pindex_t pindex;
136 int *before;
137 int *after;
138{
139 return FALSE;
140}
141
153static boolean_t
154default_pager_haspage(object, pindex, before, after)
155 vm_object_t object;
156 vm_pindex_t pindex;
157 int *before;
158 int *after;
159{
160 return FALSE;
161}
162
142void
143default_pager_convert_to_swap(object)
144 vm_object_t object;
145{
146 object->type = OBJT_SWAP;
147 if (swap_pager_swp_alloc(object, M_KERNEL) != 0) {
148 object->type = OBJT_DEFAULT;
149 }
150}
151
152void
153default_pager_convert_to_swapq(object)
154 vm_object_t object;
155{
156 if (object &&
157 (object->type == OBJT_DEFAULT) &&
158 (object != kernel_object && object != kmem_object) &&
159 (object->size > ((cnt.v_page_count - cnt.v_wire_count) / 4)))
160 default_pager_convert_to_swap(object);
161}
162