]> git.saurik.com Git - apple/xnu.git/blame - bsd/vm/vnode_pager.h
xnu-792.17.14.tar.gz
[apple/xnu.git] / bsd / vm / vnode_pager.h
CommitLineData
1c79356b 1/*
5d5c5d0d
A
2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
3 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
A
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
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b
A
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#ifndef _VNODE_PAGER_
36#define _VNODE_PAGER_ 1
37
38#include <mach/kern_return.h>
39#include <sys/types.h>
40#include <kern/queue.h>
41
42#ifdef KERNEL
1c79356b 43#include <mach/boolean.h>
91447636
A
44#include <mach/memory_object_types.h>
45#include <mach/vm_types.h>
1c79356b
A
46#include <vm/vm_pager.h>
47
91447636 48vm_pager_t vnode_pager_setup(struct vnode *, memory_object_t);
1c79356b
A
49
50/*
51 * Vstructs are the internal (to us) description of a unit of backing store.
52 * The are the link between memory objects and the backing store they represent.
53 * For the vnode pager, backing store comes in two flavors: normal files and
54 * swap files.
55 *
56 * For objects that page to and from normal files (e.g. objects that represent
57 * program text segments), we maintain some simple parameters that allow us to
58 * access the file's contents directly through the vnode interface.
59 *
60 * Data for objects without associated vnodes is maintained in the swap files.
61 * Each object that uses one of these as backing store has a vstruct indicating
62 * the swap file of preference (vs_pf) and a mapping between contiguous object
63 * offsets and swap file offsets (vs_pmap). Each entry in this mapping specifies
64 * the pager file to use, and the offset of the page in that pager file. These
65 * mapping entries are of type pfMapEntry.
66 */
67
68/*
69 * Pager file structure. One per swap file.
70 */
71typedef struct pager_file {
72 queue_chain_t pf_chain; /* link to other paging files */
73 struct vnode *pf_vp; /* vnode of paging file */
74 u_int pf_count; /* Number of vstruct using this file */
75 u_char *pf_bmap; /* Map of used blocks */
76 long pf_npgs; /* Size of file in pages */
77 long pf_pfree; /* Number of unused pages */
78 long pf_lowat; /* Low water page */
79 long pf_hipage; /* Highest page allocated */
80 long pf_hint; /* Lowest page unallocated */
81 char *pf_name; /* Filename of this file */
82 boolean_t pf_prefer;
83 int pf_index; /* index into the pager_file array */
84 void * pf_lock; /* Lock for alloc and dealloc */
85} *pager_file_t;
86
87#define PAGER_FILE_NULL (pager_file_t) 0
88
89#define MAXPAGERFILES 16
90
91#define MAX_BACKING_STORE 100
92
93struct bs_map {
94 struct vnode *vp;
95 void *bs;
96};
91447636 97extern struct bs_map bs_port_table[];
1c79356b
A
98
99
100
101/*
102 * Pager file data structures.
103 */
104#define INDEX_NULL 0
105typedef struct {
106 unsigned int index:8; /* paging file this block is in */
107 unsigned int offset:24; /* page number where block resides */
108} pf_entry;
109
110typedef enum {
111 IS_INODE, /* Local disk */
112 IS_RNODE /* NFS */
113 } vpager_fstype;
114
115/*
116 * Basic vnode pager structure. One per object, backing-store pair.
117 */
118typedef struct vstruct {
119 boolean_t is_device; /* Must be first - see vm_pager.h */
120 pager_file_t vs_pf; /* Pager file this uses */
121 pf_entry **vs_pmap; /* Map of pages into paging file */
122 unsigned int
123 /* boolean_t */ vs_swapfile:1; /* vnode is a swapfile */
124 short vs_count; /* use count */
125 int vs_size; /* size of this chunk in pages*/
126 struct vnode *vs_vp; /* vnode to page to */
127} *vnode_pager_t;
128
129#define VNODE_PAGER_NULL ((vnode_pager_t) 0)
130
131
91447636
A
132pager_return_t vnode_pagein(struct vnode *, upl_t,
133 upl_offset_t, vm_object_offset_t,
134 upl_size_t, int, int *);
135pager_return_t vnode_pageout(struct vnode *, upl_t,
136 upl_offset_t, vm_object_offset_t,
137 upl_size_t, int, int *);
1c79356b 138
91447636
A
139extern vm_object_offset_t vnode_pager_get_filesize(
140 struct vnode *vp);
1c79356b
A
141
142#endif /* KERNEL */
143
144#endif /* _VNODE_PAGER_ */