]> git.saurik.com Git - apple/xnu.git/blob - bsd/vm/vnode_pager.c
4bc408e876b17254250db28e975b39ea5a50f6a8
[apple/xnu.git] / bsd / vm / vnode_pager.c
1 /*
2 * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
5 *
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
14 *
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
17 *
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
27 */
28 /*
29 * Mach Operating System
30 * Copyright (c) 1987 Carnegie-Mellon University
31 * All rights reserved. The CMU software License Agreement specifies
32 * the terms and conditions for use and redistribution.
33 */
34 /*
35 * File: vnode_pager.c
36 *
37 * "Swap" pager that pages to/from vnodes. Also
38 * handles demand paging from files.
39 *
40 */
41
42 #include <mach/boolean.h>
43 #include <sys/param.h>
44 #include <sys/systm.h>
45 #include <sys/user.h>
46 #include <sys/proc.h>
47 #include <sys/kauth.h>
48 #include <sys/buf.h>
49 #include <sys/uio.h>
50 #include <sys/vnode_internal.h>
51 #include <sys/namei.h>
52 #include <sys/mount_internal.h> /* needs internal due to fhandle_t */
53 #include <sys/ubc_internal.h>
54 #include <sys/lock.h>
55 #include <sys/disk.h> /* For DKIOC calls */
56
57 #include <mach/mach_types.h>
58 #include <mach/memory_object_types.h>
59 #include <mach/memory_object_control.h>
60 #include <mach/vm_map.h>
61 #include <mach/mach_vm.h>
62 #include <mach/upl.h>
63 #include <mach/sdt.h>
64
65 #include <vm/vm_map.h>
66 #include <vm/vm_kern.h>
67 #include <kern/zalloc.h>
68 #include <kern/kalloc.h>
69 #include <libkern/libkern.h>
70
71 #include <vm/vnode_pager.h>
72 #include <vm/vm_pageout.h>
73
74 #include <kern/assert.h>
75 #include <sys/kdebug.h>
76 #include <machine/spl.h>
77
78 #include <nfs/rpcv2.h>
79 #include <nfs/nfsproto.h>
80 #include <nfs/nfs.h>
81
82 #include <vm/vm_protos.h>
83
84
85 void
86 vnode_pager_throttle()
87 {
88 struct uthread *ut;
89
90 ut = get_bsdthread_info(current_thread());
91
92 if (ut->uu_lowpri_window)
93 throttle_lowpri_io(1);
94 }
95
96
97 boolean_t
98 vnode_pager_isSSD(vnode_t vp)
99 {
100 if (vp->v_mount->mnt_kern_flag & MNTK_SSD)
101 return (TRUE);
102 return (FALSE);
103 }
104
105
106 uint32_t
107 vnode_pager_isinuse(struct vnode *vp)
108 {
109 if (vp->v_usecount > vp->v_kusecount)
110 return (1);
111 return (0);
112 }
113
114 uint32_t
115 vnode_pager_return_throttle_io_limit(struct vnode *vp, uint32_t *limit)
116 {
117 return(cluster_throttle_io_limit(vp, limit));
118 }
119
120 vm_object_offset_t
121 vnode_pager_get_filesize(struct vnode *vp)
122 {
123 return (vm_object_offset_t) ubc_getsize(vp);
124 }
125
126 kern_return_t
127 vnode_pager_get_pathname(
128 struct vnode *vp,
129 char *pathname,
130 vm_size_t *length_p)
131 {
132 int error, len;
133
134 len = (int) *length_p;
135 error = vn_getpath(vp, pathname, &len);
136 if (error != 0) {
137 return KERN_FAILURE;
138 }
139 *length_p = (vm_size_t) len;
140 return KERN_SUCCESS;
141 }
142
143 kern_return_t
144 vnode_pager_get_filename(
145 struct vnode *vp,
146 const char **filename)
147 {
148 *filename = vp->v_name;
149 return KERN_SUCCESS;
150 }
151
152 kern_return_t
153 vnode_pager_get_cs_blobs(
154 struct vnode *vp,
155 void **blobs)
156 {
157 *blobs = ubc_get_cs_blobs(vp);
158 return KERN_SUCCESS;
159 }
160
161 /*
162 * vnode_trim:
163 * Used to call the DKIOCUNMAP ioctl on the underlying disk device for the specified vnode.
164 * Trims the region at offset bytes into the file, for length bytes.
165 *
166 * Care must be taken to ensure that the vnode is sufficiently reference counted at the time this
167 * function is called; no iocounts or usecounts are taken on the vnode.
168 * This function is non-idempotent in error cases; We cannot un-discard the blocks if only some of them
169 * are successfully discarded.
170 */
171 u_int32_t vnode_trim (
172 struct vnode *vp,
173 off_t offset,
174 size_t length)
175 {
176 daddr64_t io_blockno; /* Block number corresponding to the start of the extent */
177 size_t io_bytecount; /* Number of bytes in current extent for the specified range */
178 size_t trimmed = 0;
179 off_t current_offset = offset;
180 size_t remaining_length = length;
181 int error = 0;
182 u_int32_t blocksize = 0;
183 struct vnode *devvp;
184 dk_extent_t extent;
185 dk_unmap_t unmap;
186
187
188 /* Get the underlying device vnode */
189 devvp = vp->v_mount->mnt_devvp;
190
191 /* Figure out the underlying device block size */
192 error = VNOP_IOCTL(devvp, DKIOCGETBLOCKSIZE, (caddr_t)&blocksize, 0, vfs_context_kernel());
193 if (error) {
194 goto trim_exit;
195 }
196
197 /*
198 * We may not get the entire range from offset -> offset+length in a single
199 * extent from the blockmap call. Keep looping/going until we are sure we've hit
200 * the whole range or if we encounter an error.
201 */
202 while (trimmed < length) {
203 /*
204 * VNOP_BLOCKMAP will tell us the logical to physical block number mapping for the
205 * specified offset. It returns blocks in contiguous chunks, so if the logical range is
206 * broken into multiple extents, it must be called multiple times, increasing the offset
207 * in each call to ensure that the entire range is covered.
208 */
209 error = VNOP_BLOCKMAP (vp, current_offset, remaining_length,
210 &io_blockno, &io_bytecount, NULL, VNODE_READ, NULL);
211
212 if (error) {
213 goto trim_exit;
214 }
215 /*
216 * We have a contiguous run. Prepare & issue the ioctl for the device.
217 * the DKIOCUNMAP ioctl takes offset in bytes from the start of the device.
218 */
219 memset (&extent, 0, sizeof(dk_extent_t));
220 memset (&unmap, 0, sizeof(dk_unmap_t));
221 extent.offset = (uint64_t) io_blockno * (u_int64_t) blocksize;
222 extent.length = io_bytecount;
223 unmap.extents = &extent;
224 unmap.extentsCount = 1;
225 error = VNOP_IOCTL(devvp, DKIOCUNMAP, (caddr_t)&unmap, 0, vfs_context_kernel());
226
227 if (error) {
228 goto trim_exit;
229 }
230 remaining_length = remaining_length - io_bytecount;
231 trimmed = trimmed + io_bytecount;
232 current_offset = current_offset + io_bytecount;
233 }
234 trim_exit:
235
236 return error;
237
238 }
239
240 pager_return_t
241 vnode_pageout(struct vnode *vp,
242 upl_t upl,
243 upl_offset_t upl_offset,
244 vm_object_offset_t f_offset,
245 upl_size_t size,
246 int flags,
247 int *errorp)
248 {
249 int result = PAGER_SUCCESS;
250 int error = 0;
251 int error_ret = 0;
252 daddr64_t blkno;
253 int isize;
254 int pg_index;
255 int base_index;
256 upl_offset_t offset;
257 upl_page_info_t *pl;
258 vfs_context_t ctx = vfs_context_current(); /* pager context */
259
260 isize = (int)size;
261
262 if (isize <= 0) {
263 result = PAGER_ERROR;
264 error_ret = EINVAL;
265 goto out;
266 }
267
268 if (UBCINFOEXISTS(vp) == 0) {
269 result = PAGER_ERROR;
270 error_ret = EINVAL;
271
272 if (upl && !(flags & UPL_NOCOMMIT))
273 ubc_upl_abort_range(upl, upl_offset, size, UPL_ABORT_FREE_ON_EMPTY);
274 goto out;
275 }
276 if ( !(flags & UPL_VNODE_PAGER)) {
277 /*
278 * This is a pageout from the default pager,
279 * just go ahead and call vnop_pageout since
280 * it has already sorted out the dirty ranges
281 */
282 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE,
283 (MACHDBG_CODE(DBG_MACH_VM, 1)) | DBG_FUNC_START,
284 size, 1, 0, 0, 0);
285
286 if ( (error_ret = VNOP_PAGEOUT(vp, upl, upl_offset, (off_t)f_offset,
287 (size_t)size, flags, ctx)) )
288 result = PAGER_ERROR;
289
290 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE,
291 (MACHDBG_CODE(DBG_MACH_VM, 1)) | DBG_FUNC_END,
292 size, 1, 0, 0, 0);
293
294 goto out;
295 }
296 if (upl == NULL) {
297 int request_flags;
298
299 if (vp->v_mount->mnt_vtable->vfc_vfsflags & VFC_VFSVNOP_PAGEOUTV2) {
300 /*
301 * filesystem has requested the new form of VNOP_PAGEOUT for file
302 * backed objects... we will not grab the UPL befofe calling VNOP_PAGEOUT...
303 * it is the fileystem's responsibility to grab the range we're denoting
304 * via 'f_offset' and 'size' into a UPL... this allows the filesystem to first
305 * take any locks it needs, before effectively locking the pages into a UPL...
306 */
307 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE,
308 (MACHDBG_CODE(DBG_MACH_VM, 1)) | DBG_FUNC_START,
309 size, (int)f_offset, 0, 0, 0);
310
311 if ( (error_ret = VNOP_PAGEOUT(vp, NULL, upl_offset, (off_t)f_offset,
312 size, flags, ctx)) ) {
313 result = PAGER_ERROR;
314 }
315 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE,
316 (MACHDBG_CODE(DBG_MACH_VM, 1)) | DBG_FUNC_END,
317 size, 0, 0, 0, 0);
318
319 goto out;
320 }
321 if (flags & UPL_MSYNC)
322 request_flags = UPL_UBC_MSYNC | UPL_RET_ONLY_DIRTY;
323 else
324 request_flags = UPL_UBC_PAGEOUT | UPL_RET_ONLY_DIRTY;
325
326 if (ubc_create_upl(vp, f_offset, size, &upl, &pl, request_flags) != KERN_SUCCESS) {
327 result = PAGER_ERROR;
328 error_ret = EINVAL;
329 goto out;
330 }
331 upl_offset = 0;
332 } else
333 pl = ubc_upl_pageinfo(upl);
334
335 /*
336 * we come here for pageouts to 'real' files and
337 * for msyncs... the upl may not contain any
338 * dirty pages.. it's our responsibility to sort
339 * through it and find the 'runs' of dirty pages
340 * to call VNOP_PAGEOUT on...
341 */
342 if (ubc_getsize(vp) == 0) {
343 /*
344 * if the file has been effectively deleted, then
345 * we need to go through the UPL and invalidate any
346 * buffer headers we might have that reference any
347 * of it's pages
348 */
349 for (offset = upl_offset; isize; isize -= PAGE_SIZE, offset += PAGE_SIZE) {
350 #if NFSCLIENT
351 if (vp->v_tag == VT_NFS)
352 /* check with nfs if page is OK to drop */
353 error = nfs_buf_page_inval(vp, (off_t)f_offset);
354 else
355 #endif
356 {
357 blkno = ubc_offtoblk(vp, (off_t)f_offset);
358 error = buf_invalblkno(vp, blkno, 0);
359 }
360 if (error) {
361 if ( !(flags & UPL_NOCOMMIT))
362 ubc_upl_abort_range(upl, offset, PAGE_SIZE, UPL_ABORT_FREE_ON_EMPTY);
363 if (error_ret == 0)
364 error_ret = error;
365 result = PAGER_ERROR;
366
367 } else if ( !(flags & UPL_NOCOMMIT)) {
368 ubc_upl_commit_range(upl, offset, PAGE_SIZE, UPL_COMMIT_FREE_ON_EMPTY);
369 }
370 f_offset += PAGE_SIZE;
371 }
372 goto out;
373 }
374 /*
375 * Ignore any non-present pages at the end of the
376 * UPL so that we aren't looking at a upl that
377 * may already have been freed by the preceeding
378 * aborts/completions.
379 */
380 base_index = upl_offset / PAGE_SIZE;
381
382 for (pg_index = (upl_offset + isize) / PAGE_SIZE; pg_index > base_index;) {
383 if (upl_page_present(pl, --pg_index))
384 break;
385 if (pg_index == base_index) {
386 /*
387 * no pages were returned, so release
388 * our hold on the upl and leave
389 */
390 if ( !(flags & UPL_NOCOMMIT))
391 ubc_upl_abort_range(upl, upl_offset, isize, UPL_ABORT_FREE_ON_EMPTY);
392
393 goto out;
394 }
395 }
396 isize = ((pg_index + 1) - base_index) * PAGE_SIZE;
397
398 offset = upl_offset;
399 pg_index = base_index;
400
401 while (isize) {
402 int xsize;
403 int num_of_pages;
404
405 if ( !upl_page_present(pl, pg_index)) {
406 /*
407 * we asked for RET_ONLY_DIRTY, so it's possible
408 * to get back empty slots in the UPL
409 * just skip over them
410 */
411 f_offset += PAGE_SIZE;
412 offset += PAGE_SIZE;
413 isize -= PAGE_SIZE;
414 pg_index++;
415
416 continue;
417 }
418 if ( !upl_dirty_page(pl, pg_index)) {
419 /*
420 * if the page is not dirty and reached here it is
421 * marked precious or it is due to invalidation in
422 * memory_object_lock request as part of truncation
423 * We also get here from vm_object_terminate()
424 * So all you need to do in these
425 * cases is to invalidate incore buffer if it is there
426 * Note we must not sleep here if the buffer is busy - that is
427 * a lock inversion which causes deadlock.
428 */
429 #if NFSCLIENT
430 if (vp->v_tag == VT_NFS)
431 /* check with nfs if page is OK to drop */
432 error = nfs_buf_page_inval(vp, (off_t)f_offset);
433 else
434 #endif
435 {
436 blkno = ubc_offtoblk(vp, (off_t)f_offset);
437 error = buf_invalblkno(vp, blkno, 0);
438 }
439 if (error) {
440 if ( !(flags & UPL_NOCOMMIT))
441 ubc_upl_abort_range(upl, offset, PAGE_SIZE, UPL_ABORT_FREE_ON_EMPTY);
442 if (error_ret == 0)
443 error_ret = error;
444 result = PAGER_ERROR;
445
446 } else if ( !(flags & UPL_NOCOMMIT)) {
447 ubc_upl_commit_range(upl, offset, PAGE_SIZE, UPL_COMMIT_FREE_ON_EMPTY);
448 }
449 f_offset += PAGE_SIZE;
450 offset += PAGE_SIZE;
451 isize -= PAGE_SIZE;
452 pg_index++;
453
454 continue;
455 }
456 num_of_pages = 1;
457 xsize = isize - PAGE_SIZE;
458
459 while (xsize) {
460 if ( !upl_dirty_page(pl, pg_index + num_of_pages))
461 break;
462 num_of_pages++;
463 xsize -= PAGE_SIZE;
464 }
465 xsize = num_of_pages * PAGE_SIZE;
466
467 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE,
468 (MACHDBG_CODE(DBG_MACH_VM, 1)) | DBG_FUNC_START,
469 xsize, (int)f_offset, 0, 0, 0);
470
471 if ( (error = VNOP_PAGEOUT(vp, upl, offset, (off_t)f_offset,
472 xsize, flags, ctx)) ) {
473 if (error_ret == 0)
474 error_ret = error;
475 result = PAGER_ERROR;
476 }
477 KERNEL_DEBUG_CONSTANT_IST(KDEBUG_TRACE,
478 (MACHDBG_CODE(DBG_MACH_VM, 1)) | DBG_FUNC_END,
479 xsize, 0, 0, 0, 0);
480
481 f_offset += xsize;
482 offset += xsize;
483 isize -= xsize;
484 pg_index += num_of_pages;
485 }
486 out:
487 if (errorp)
488 *errorp = error_ret;
489
490 return (result);
491 }
492
493
494 pager_return_t
495 vnode_pagein(
496 struct vnode *vp,
497 upl_t upl,
498 upl_offset_t upl_offset,
499 vm_object_offset_t f_offset,
500 upl_size_t size,
501 int flags,
502 int *errorp)
503 {
504 upl_page_info_t *pl;
505 int result = PAGER_SUCCESS;
506 int error = 0;
507 int pages_in_upl;
508 int start_pg;
509 int last_pg;
510 int first_pg;
511 int xsize;
512 int must_commit = 1;
513 int ignore_valid_page_check = 0;
514
515 if (flags & UPL_NOCOMMIT)
516 must_commit = 0;
517
518 if (flags & UPL_IGNORE_VALID_PAGE_CHECK)
519 ignore_valid_page_check = 1;
520
521 if (UBCINFOEXISTS(vp) == 0) {
522 result = PAGER_ERROR;
523 error = PAGER_ERROR;
524
525 if (upl && must_commit)
526 ubc_upl_abort_range(upl, upl_offset, size, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_ERROR);
527
528 goto out;
529 }
530 if (upl == (upl_t)NULL) {
531 flags &= ~UPL_NOCOMMIT;
532
533 if (size > (MAX_UPL_SIZE * PAGE_SIZE)) {
534 result = PAGER_ERROR;
535 error = PAGER_ERROR;
536 goto out;
537 }
538 if (vp->v_mount->mnt_vtable->vfc_vfsflags & VFC_VFSVNOP_PAGEINV2) {
539 /*
540 * filesystem has requested the new form of VNOP_PAGEIN for file
541 * backed objects... we will not grab the UPL befofe calling VNOP_PAGEIN...
542 * it is the fileystem's responsibility to grab the range we're denoting
543 * via 'f_offset' and 'size' into a UPL... this allows the filesystem to first
544 * take any locks it needs, before effectively locking the pages into a UPL...
545 * so we pass a NULL into the filesystem instead of a UPL pointer... the 'upl_offset'
546 * is used to identify the "must have" page in the extent... the filesystem is free
547 * to clip the extent to better fit the underlying FS blocksize if it desires as
548 * long as it continues to include the "must have" page... 'f_offset' + 'upl_offset'
549 * identifies that page
550 */
551 if ( (error = VNOP_PAGEIN(vp, NULL, upl_offset, (off_t)f_offset,
552 size, flags, vfs_context_current())) ) {
553 result = PAGER_ERROR;
554 error = PAGER_ERROR;
555 }
556 goto out;
557 }
558 ubc_create_upl(vp, f_offset, size, &upl, &pl, UPL_UBC_PAGEIN | UPL_RET_ONLY_ABSENT);
559
560 if (upl == (upl_t)NULL) {
561 result = PAGER_ABSENT;
562 error = PAGER_ABSENT;
563 goto out;
564 }
565 ubc_upl_range_needed(upl, upl_offset / PAGE_SIZE, 1);
566
567 upl_offset = 0;
568 first_pg = 0;
569
570 /*
571 * if we get here, we've created the upl and
572 * are responsible for commiting/aborting it
573 * regardless of what the caller has passed in
574 */
575 must_commit = 1;
576 } else {
577 pl = ubc_upl_pageinfo(upl);
578 first_pg = upl_offset / PAGE_SIZE;
579 }
580 pages_in_upl = size / PAGE_SIZE;
581 DTRACE_VM2(pgpgin, int, pages_in_upl, (uint64_t *), NULL);
582
583 /*
584 * before we start marching forward, we must make sure we end on
585 * a present page, otherwise we will be working with a freed
586 * upl
587 */
588 for (last_pg = pages_in_upl - 1; last_pg >= first_pg; last_pg--) {
589 if (upl_page_present(pl, last_pg))
590 break;
591 if (last_pg == first_pg) {
592 /*
593 * empty UPL, no pages are present
594 */
595 if (must_commit)
596 ubc_upl_abort_range(upl, upl_offset, size, UPL_ABORT_FREE_ON_EMPTY);
597 goto out;
598 }
599 }
600 pages_in_upl = last_pg + 1;
601 last_pg = first_pg;
602
603 while (last_pg < pages_in_upl) {
604 /*
605 * skip over missing pages...
606 */
607 for ( ; last_pg < pages_in_upl; last_pg++) {
608 if (upl_page_present(pl, last_pg))
609 break;
610 }
611
612 if (ignore_valid_page_check == 1) {
613 start_pg = last_pg;
614 } else {
615 /*
616 * skip over 'valid' pages... we don't want to issue I/O for these
617 */
618 for (start_pg = last_pg; last_pg < pages_in_upl; last_pg++) {
619 if (!upl_valid_page(pl, last_pg))
620 break;
621 }
622 }
623
624 if (last_pg > start_pg) {
625 /*
626 * we've found a range of valid pages
627 * if we've got COMMIT responsibility
628 * commit this range of pages back to the
629 * cache unchanged
630 */
631 xsize = (last_pg - start_pg) * PAGE_SIZE;
632
633 if (must_commit)
634 ubc_upl_abort_range(upl, start_pg * PAGE_SIZE, xsize, UPL_ABORT_FREE_ON_EMPTY);
635 }
636 if (last_pg == pages_in_upl)
637 /*
638 * we're done... all pages that were present
639 * have either had I/O issued on them or
640 * were aborted unchanged...
641 */
642 break;
643
644 if (!upl_page_present(pl, last_pg)) {
645 /*
646 * we found a range of valid pages
647 * terminated by a missing page...
648 * bump index to the next page and continue on
649 */
650 last_pg++;
651 continue;
652 }
653 /*
654 * scan from the found invalid page looking for a valid
655 * or non-present page before the end of the upl is reached, if we
656 * find one, then it will be the last page of the request to
657 * 'cluster_io'
658 */
659 for (start_pg = last_pg; last_pg < pages_in_upl; last_pg++) {
660 if (( !ignore_valid_page_check && upl_valid_page(pl, last_pg)) || !upl_page_present(pl, last_pg))
661 break;
662 }
663 if (last_pg > start_pg) {
664 int xoff;
665 xsize = (last_pg - start_pg) * PAGE_SIZE;
666 xoff = start_pg * PAGE_SIZE;
667
668 if ( (error = VNOP_PAGEIN(vp, upl, (upl_offset_t) xoff,
669 (off_t)f_offset + xoff,
670 xsize, flags, vfs_context_current())) ) {
671 /*
672 * Usually this UPL will be aborted/committed by the lower cluster layer.
673 *
674 * a) In the case of decmpfs, however, we may return an error (EAGAIN) to avoid
675 * a deadlock with another thread already inflating the file.
676 *
677 * b) In the case of content protection, EPERM is a valid error and we should respect it.
678 *
679 * In those cases, we must take care of our UPL at this layer itself.
680 */
681 if (must_commit) {
682 if(error == EAGAIN) {
683 ubc_upl_abort_range(upl, (upl_offset_t) xoff, xsize, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_RESTART);
684 }
685 #if CONFIG_PROTECT
686 if(error == EPERM) {
687 ubc_upl_abort_range(upl, (upl_offset_t) xoff, xsize, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_ERROR);
688 }
689 #endif
690 }
691 result = PAGER_ERROR;
692 error = PAGER_ERROR;
693
694 }
695 }
696 }
697 out:
698 if (errorp)
699 *errorp = result;
700
701 return (error);
702 }
703
704 void
705 vnode_pager_shutdown(void)
706 {
707 int i;
708 vnode_t vp;
709
710 for(i = 0; i < MAX_BACKING_STORE; i++) {
711 vp = (vnode_t)(bs_port_table[i]).vp;
712 if (vp) {
713 (bs_port_table[i]).vp = 0;
714
715 /* get rid of macx_swapon() reference */
716 vnode_rele(vp);
717 }
718 }
719 }
720
721
722 void *
723 upl_get_internal_page_list(upl_t upl)
724 {
725 return(UPL_GET_INTERNAL_PAGE_LIST(upl));
726
727 }