]> git.saurik.com Git - apple/xnu.git/blobdiff - bsd/vm/vnode_pager.c
xnu-4570.1.46.tar.gz
[apple/xnu.git] / bsd / vm / vnode_pager.c
index b90ca5366cbb6fa312da165d1f27ae9982969c42..69dad298104bb6e094d20a828773cd35841e7097 100644 (file)
 
 #include <kern/assert.h>
 #include <sys/kdebug.h>
-#include <machine/spl.h>
-
 #include <nfs/rpcv2.h>
 #include <nfs/nfsproto.h>
 #include <nfs/nfs.h>
 
 #include <vm/vm_protos.h>
 
+#include <vfs/vfs_disk_conditioner.h>
 
 void
 vnode_pager_throttle()
@@ -93,15 +92,39 @@ vnode_pager_throttle()
                throttle_lowpri_io(1);
 }
 
-
 boolean_t
 vnode_pager_isSSD(vnode_t vp)
 {
-       if (vp->v_mount->mnt_kern_flag & MNTK_SSD)
-               return (TRUE);
-       return (FALSE);
+       return disk_conditioner_mount_is_ssd(vp->v_mount);
 }
 
+#if CONFIG_IOSCHED
+void
+vnode_pager_issue_reprioritize_io(struct vnode *devvp, uint64_t blkno, uint32_t len, int priority)
+{
+       u_int32_t blocksize = 0;
+       dk_extent_t extent;
+        dk_set_tier_t set_tier;
+       int error = 0;
+
+       error = VNOP_IOCTL(devvp, DKIOCGETBLOCKSIZE, (caddr_t)&blocksize, 0, vfs_context_kernel());
+       if (error)
+               return;
+
+       memset(&extent, 0, sizeof(dk_extent_t));
+       memset(&set_tier, 0, sizeof(dk_set_tier_t));
+       
+       extent.offset = blkno * (u_int64_t) blocksize;
+       extent.length = len;
+
+       set_tier.extents = &extent; 
+       set_tier.extentsCount = 1;
+       set_tier.tier = priority;
+               
+       error = VNOP_IOCTL(devvp, DKIOCSETTIER, (caddr_t)&set_tier, 0, vfs_context_kernel());
+       return;
+}
+#endif
 
 uint32_t
 vnode_pager_isinuse(struct vnode *vp)
@@ -224,7 +247,7 @@ u_int32_t vnode_trim (
                 * in each call to ensure that the entire range is covered.
                 */
                error = VNOP_BLOCKMAP (vp, current_offset, remaining_length, 
-                               &io_blockno, &io_bytecount, NULL, VNODE_READ, NULL);
+                               &io_blockno, &io_bytecount, NULL, VNODE_READ | VNODE_BLOCKMAP_NO_TRACK, NULL);
 
                if (error) {
                        goto trim_exit;
@@ -340,7 +363,7 @@ vnode_pageout(struct vnode *vp,
                else
                        request_flags = UPL_UBC_PAGEOUT | UPL_RET_ONLY_DIRTY;
                
-               if (ubc_create_upl(vp, f_offset, size, &upl, &pl, request_flags) != KERN_SUCCESS) {
+               if (ubc_create_upl_kernel(vp, f_offset, size, &upl, &pl, request_flags, VM_KERN_MEMORY_FILE) != KERN_SUCCESS) {
                        result    = PAGER_ERROR;
                        error_ret = EINVAL;
                        goto out;
@@ -349,6 +372,30 @@ vnode_pageout(struct vnode *vp,
        } else 
                pl = ubc_upl_pageinfo(upl);
 
+       /*
+        * Ignore any non-present pages at the end of the
+        * UPL so that we aren't looking at a upl that 
+        * may already have been freed by the preceeding
+        * aborts/completions.
+        */
+       base_index = upl_offset / PAGE_SIZE;
+
+       for (pg_index = (upl_offset + isize) / PAGE_SIZE; pg_index > base_index;) {
+               if (upl_page_present(pl, --pg_index))
+                       break;
+               if (pg_index == base_index) {
+                       /*
+                        * no pages were returned, so release
+                        * our hold on the upl and leave
+                        */
+                       if ( !(flags & UPL_NOCOMMIT))
+                               ubc_upl_abort_range(upl, upl_offset, isize, UPL_ABORT_FREE_ON_EMPTY);
+
+                       goto out;
+               }
+       }
+       isize = ((pg_index + 1) - base_index) * PAGE_SIZE;
+
        /*
         * we come here for pageouts to 'real' files and
         * for msyncs...  the upl may not contain any
@@ -356,6 +403,7 @@ vnode_pageout(struct vnode *vp,
         * through it and find the 'runs' of dirty pages
         * to call VNOP_PAGEOUT on...
         */
+
        if (ubc_getsize(vp) == 0) {
                /*
                 * if the file has been effectively deleted, then
@@ -388,29 +436,6 @@ vnode_pageout(struct vnode *vp,
                }
                goto out;
        }
-       /*
-        * Ignore any non-present pages at the end of the
-        * UPL so that we aren't looking at a upl that 
-        * may already have been freed by the preceeding
-        * aborts/completions.
-        */
-       base_index = upl_offset / PAGE_SIZE;
-
-       for (pg_index = (upl_offset + isize) / PAGE_SIZE; pg_index > base_index;) {
-               if (upl_page_present(pl, --pg_index))
-                       break;
-               if (pg_index == base_index) {
-                       /*
-                        * no pages were returned, so release
-                        * our hold on the upl and leave
-                        */
-                       if ( !(flags & UPL_NOCOMMIT))
-                               ubc_upl_abort_range(upl, upl_offset, isize, UPL_ABORT_FREE_ON_EMPTY);
-
-                       goto out;
-               }
-       }
-       isize = ((pg_index + 1) - base_index) * PAGE_SIZE;
 
        offset = upl_offset;
        pg_index = base_index;
@@ -547,7 +572,7 @@ vnode_pagein(
        if (upl == (upl_t)NULL) {
                flags &= ~UPL_NOCOMMIT;
 
-               if (size > (MAX_UPL_SIZE * PAGE_SIZE)) {
+               if (size > MAX_UPL_SIZE_BYTES) {
                        result = PAGER_ERROR;
                        error  = PAGER_ERROR;
                        goto out;
@@ -572,7 +597,7 @@ vnode_pagein(
                        }
                        goto out;
                }
-               ubc_create_upl(vp, f_offset, size, &upl, &pl, UPL_UBC_PAGEIN | UPL_RET_ONLY_ABSENT);
+               ubc_create_upl_kernel(vp, f_offset, size, &upl, &pl, UPL_UBC_PAGEIN | UPL_RET_ONLY_ABSENT, VM_KERN_MEMORY_FILE);
 
                if (upl == (upl_t)NULL) {
                        result =  PAGER_ABSENT;
@@ -699,11 +724,9 @@ vnode_pagein(
                                        if(error == EAGAIN) {
                                                ubc_upl_abort_range(upl, (upl_offset_t) xoff, xsize, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_RESTART);
                                        }
-#if CONFIG_PROTECT
                                        if(error == EPERM) {
                                                ubc_upl_abort_range(upl, (upl_offset_t) xoff, xsize, UPL_ABORT_FREE_ON_EMPTY | UPL_ABORT_ERROR);
                                        }
-#endif
                                }
                                result = PAGER_ERROR;
                                error  = PAGER_ERROR;
@@ -718,24 +741,6 @@ out:
        return (error);
 }
 
-void
-vnode_pager_shutdown(void)
-{
-       int i;
-       vnode_t vp;
-
-       for(i = 0; i < MAX_BACKING_STORE; i++) {
-               vp = (vnode_t)(bs_port_table[i]).vp;
-               if (vp) {
-                       (bs_port_table[i]).vp = 0;
-
-                       /* get rid of macx_swapon() reference */
-                       vnode_rele(vp);
-               }
-       }
-}
-
-
 void *
 upl_get_internal_page_list(upl_t upl)
 {