Deleted Added
full compact
vm_pager.c (285993) vm_pager.c (292373)
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

59 */
60
61/*
62 * Paging space routine stubs. Emulates a matchmaker-like interface
63 * for builtin pagers.
64 */
65
66#include <sys/cdefs.h>
1/*-
2 * Copyright (c) 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * The Mach Operating System project at Carnegie-Mellon University.
7 *
8 * Redistribution and use in source and binary forms, with or without

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

59 */
60
61/*
62 * Paging space routine stubs. Emulates a matchmaker-like interface
63 * for builtin pagers.
64 */
65
66#include <sys/cdefs.h>
67__FBSDID("$FreeBSD: head/sys/vm/vm_pager.c 285993 2015-07-29 02:26:57Z jeff $");
67__FBSDID("$FreeBSD: head/sys/vm/vm_pager.c 292373 2015-12-16 21:30:45Z glebius $");
68
69#include <sys/param.h>
70#include <sys/systm.h>
71#include <sys/kernel.h>
72#include <sys/vnode.h>
73#include <sys/bio.h>
74#include <sys/buf.h>
75#include <sys/ucred.h>

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

83#include <vm/vm_page.h>
84#include <vm/vm_pager.h>
85#include <vm/vm_extern.h>
86
87int cluster_pbuf_freecnt = -1; /* unlimited to begin with */
88
89struct buf *swbuf;
90
68
69#include <sys/param.h>
70#include <sys/systm.h>
71#include <sys/kernel.h>
72#include <sys/vnode.h>
73#include <sys/bio.h>
74#include <sys/buf.h>
75#include <sys/ucred.h>

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

83#include <vm/vm_page.h>
84#include <vm/vm_pager.h>
85#include <vm/vm_extern.h>
86
87int cluster_pbuf_freecnt = -1; /* unlimited to begin with */
88
89struct buf *swbuf;
90
91static int dead_pager_getpages(vm_object_t, vm_page_t *, int, int);
91static int dead_pager_getpages(vm_object_t, vm_page_t *, int, int *, int *);
92static vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t,
93 vm_ooffset_t, struct ucred *);
94static void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *);
95static boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *);
96static void dead_pager_dealloc(vm_object_t);
97
98static int
92static vm_object_t dead_pager_alloc(void *, vm_ooffset_t, vm_prot_t,
93 vm_ooffset_t, struct ucred *);
94static void dead_pager_putpages(vm_object_t, vm_page_t *, int, int, int *);
95static boolean_t dead_pager_haspage(vm_object_t, vm_pindex_t, int *, int *);
96static void dead_pager_dealloc(vm_object_t);
97
98static int
99dead_pager_getpages(obj, ma, count, req)
100 vm_object_t obj;
101 vm_page_t *ma;
102 int count;
103 int req;
99dead_pager_getpages(vm_object_t obj, vm_page_t *ma, int count, int *rbehind,
100 int *rahead)
104{
101{
105 return VM_PAGER_FAIL;
102
103 return (VM_PAGER_FAIL);
106}
107
108static vm_object_t
109dead_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
110 vm_ooffset_t off, struct ucred *cred)
111{
112 return NULL;
113}

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

277#endif
278}
279
280/*
281 * Page in the pages for the object using its associated pager.
282 * The requested page must be fully valid on successful return.
283 */
284int
104}
105
106static vm_object_t
107dead_pager_alloc(void *handle, vm_ooffset_t size, vm_prot_t prot,
108 vm_ooffset_t off, struct ucred *cred)
109{
110 return NULL;
111}

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

275#endif
276}
277
278/*
279 * Page in the pages for the object using its associated pager.
280 * The requested page must be fully valid on successful return.
281 */
282int
285vm_pager_get_pages(vm_object_t object, vm_page_t *m, int count, int reqpage)
283vm_pager_get_pages(vm_object_t object, vm_page_t *m, int count, int *rbehind,
284 int *rahead)
286{
285{
286#ifdef INVARIANTS
287 vm_pindex_t pindex = m[0]->pindex;
288#endif
287 int r;
288
289 vm_pager_assert_in(object, m, count);
290
289 int r;
290
291 vm_pager_assert_in(object, m, count);
292
291 r = (*pagertab[object->type]->pgo_getpages)(object, m, count, reqpage);
293 r = (*pagertab[object->type]->pgo_getpages)(object, m, count, rbehind,
294 rahead);
292 if (r != VM_PAGER_OK)
293 return (r);
294
295 if (r != VM_PAGER_OK)
296 return (r);
297
295 /*
296 * If pager has replaced the page, assert that it had
297 * updated the array. Also assert that page is still
298 * busied.
299 */
300 KASSERT(m[reqpage] == vm_page_lookup(object, m[reqpage]->pindex),
301 ("%s: mismatch page %p pindex %ju", __func__,
302 m[reqpage], (uintmax_t )m[reqpage]->pindex));
303 vm_page_assert_xbusied(m[reqpage]);
304
305 /*
306 * Pager didn't fill up entire page. Zero out
307 * partially filled data.
308 */
309 if (m[reqpage]->valid != VM_PAGE_BITS_ALL)
310 vm_page_zero_invalid(m[reqpage], TRUE);
311
298 for (int i = 0; i < count; i++) {
299 /*
300 * If pager has replaced a page, assert that it had
301 * updated the array.
302 */
303 KASSERT(m[i] == vm_page_lookup(object, pindex++),
304 ("%s: mismatch page %p pindex %ju", __func__,
305 m[i], (uintmax_t )pindex - 1));
306 /*
307 * Zero out partially filled data.
308 */
309 if (m[i]->valid != VM_PAGE_BITS_ALL)
310 vm_page_zero_invalid(m[i], TRUE);
311 }
312 return (VM_PAGER_OK);
313}
314
315int
316vm_pager_get_pages_async(vm_object_t object, vm_page_t *m, int count,
312 return (VM_PAGER_OK);
313}
314
315int
316vm_pager_get_pages_async(vm_object_t object, vm_page_t *m, int count,
317 int reqpage, pgo_getpages_iodone_t iodone, void *arg)
317 int *rbehind, int *rahead, pgo_getpages_iodone_t iodone, void *arg)
318{
319
320 vm_pager_assert_in(object, m, count);
321
322 return ((*pagertab[object->type]->pgo_getpages_async)(object, m,
318{
319
320 vm_pager_assert_in(object, m, count);
321
322 return ((*pagertab[object->type]->pgo_getpages_async)(object, m,
323 count, reqpage, iodone, arg));
323 count, rbehind, rahead, iodone, arg));
324}
325
326/*
327 * vm_pager_put_pages() - inline, see vm/vm_pager.h
328 * vm_pager_has_page() - inline, see vm/vm_pager.h
329 */
330
331/*

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

350 }
351 VM_OBJECT_WUNLOCK(object);
352 }
353 }
354 return (object);
355}
356
357/*
324}
325
326/*
327 * vm_pager_put_pages() - inline, see vm/vm_pager.h
328 * vm_pager_has_page() - inline, see vm/vm_pager.h
329 */
330
331/*

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

350 }
351 VM_OBJECT_WUNLOCK(object);
352 }
353 }
354 return (object);
355}
356
357/*
358 * Free the non-requested pages from the given array. To remove all pages,
359 * caller should provide out of range reqpage number.
360 */
361void
362vm_pager_free_nonreq(vm_object_t object, vm_page_t ma[], int reqpage,
363 int npages, boolean_t object_locked)
364{
365 enum { UNLOCKED, CALLER_LOCKED, INTERNALLY_LOCKED } locked;
366 int i;
367
368 if (object_locked) {
369 VM_OBJECT_ASSERT_WLOCKED(object);
370 locked = CALLER_LOCKED;
371 } else {
372 VM_OBJECT_ASSERT_UNLOCKED(object);
373 locked = UNLOCKED;
374 }
375 for (i = 0; i < npages; ++i) {
376 if (i != reqpage) {
377 if (locked == UNLOCKED) {
378 VM_OBJECT_WLOCK(object);
379 locked = INTERNALLY_LOCKED;
380 }
381 vm_page_lock(ma[i]);
382 vm_page_free(ma[i]);
383 vm_page_unlock(ma[i]);
384 }
385 }
386 if (locked == INTERNALLY_LOCKED)
387 VM_OBJECT_WUNLOCK(object);
388}
389
390/*
391 * initialize a physical buffer
392 */
393
394/*
395 * XXX This probably belongs in vfs_bio.c
396 */
397static void
398initpbuf(struct buf *bp)

--- 197 unchanged lines hidden ---
358 * initialize a physical buffer
359 */
360
361/*
362 * XXX This probably belongs in vfs_bio.c
363 */
364static void
365initpbuf(struct buf *bp)

--- 197 unchanged lines hidden ---