]> git.saurik.com Git - apple/xnu.git/blame - bsd/vm/vnode_pager.h
xnu-792.10.96.tar.gz
[apple/xnu.git] / bsd / vm / vnode_pager.h
CommitLineData
1c79356b 1/*
91447636 2 * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
1c79356b
A
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
37839358
A
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
1c79356b 11 *
37839358
A
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
1c79356b
A
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
37839358
A
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
18 * under the License.
1c79356b
A
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * Mach Operating System
24 * Copyright (c) 1987 Carnegie-Mellon University
25 * All rights reserved. The CMU software License Agreement specifies
26 * the terms and conditions for use and redistribution.
27 */
28
29#ifndef _VNODE_PAGER_
30#define _VNODE_PAGER_ 1
31
32#include <mach/kern_return.h>
33#include <sys/types.h>
34#include <kern/queue.h>
35
36#ifdef KERNEL
1c79356b 37#include <mach/boolean.h>
91447636
A
38#include <mach/memory_object_types.h>
39#include <mach/vm_types.h>
1c79356b
A
40#include <vm/vm_pager.h>
41
91447636 42vm_pager_t vnode_pager_setup(struct vnode *, memory_object_t);
1c79356b
A
43
44/*
45 * Vstructs are the internal (to us) description of a unit of backing store.
46 * The are the link between memory objects and the backing store they represent.
47 * For the vnode pager, backing store comes in two flavors: normal files and
48 * swap files.
49 *
50 * For objects that page to and from normal files (e.g. objects that represent
51 * program text segments), we maintain some simple parameters that allow us to
52 * access the file's contents directly through the vnode interface.
53 *
54 * Data for objects without associated vnodes is maintained in the swap files.
55 * Each object that uses one of these as backing store has a vstruct indicating
56 * the swap file of preference (vs_pf) and a mapping between contiguous object
57 * offsets and swap file offsets (vs_pmap). Each entry in this mapping specifies
58 * the pager file to use, and the offset of the page in that pager file. These
59 * mapping entries are of type pfMapEntry.
60 */
61
62/*
63 * Pager file structure. One per swap file.
64 */
65typedef struct pager_file {
66 queue_chain_t pf_chain; /* link to other paging files */
67 struct vnode *pf_vp; /* vnode of paging file */
68 u_int pf_count; /* Number of vstruct using this file */
69 u_char *pf_bmap; /* Map of used blocks */
70 long pf_npgs; /* Size of file in pages */
71 long pf_pfree; /* Number of unused pages */
72 long pf_lowat; /* Low water page */
73 long pf_hipage; /* Highest page allocated */
74 long pf_hint; /* Lowest page unallocated */
75 char *pf_name; /* Filename of this file */
76 boolean_t pf_prefer;
77 int pf_index; /* index into the pager_file array */
78 void * pf_lock; /* Lock for alloc and dealloc */
79} *pager_file_t;
80
81#define PAGER_FILE_NULL (pager_file_t) 0
82
83#define MAXPAGERFILES 16
84
85#define MAX_BACKING_STORE 100
86
87struct bs_map {
88 struct vnode *vp;
89 void *bs;
90};
91447636 91extern struct bs_map bs_port_table[];
1c79356b
A
92
93
94
95/*
96 * Pager file data structures.
97 */
98#define INDEX_NULL 0
99typedef struct {
100 unsigned int index:8; /* paging file this block is in */
101 unsigned int offset:24; /* page number where block resides */
102} pf_entry;
103
104typedef enum {
105 IS_INODE, /* Local disk */
106 IS_RNODE /* NFS */
107 } vpager_fstype;
108
109/*
110 * Basic vnode pager structure. One per object, backing-store pair.
111 */
112typedef struct vstruct {
113 boolean_t is_device; /* Must be first - see vm_pager.h */
114 pager_file_t vs_pf; /* Pager file this uses */
115 pf_entry **vs_pmap; /* Map of pages into paging file */
116 unsigned int
117 /* boolean_t */ vs_swapfile:1; /* vnode is a swapfile */
118 short vs_count; /* use count */
119 int vs_size; /* size of this chunk in pages*/
120 struct vnode *vs_vp; /* vnode to page to */
121} *vnode_pager_t;
122
123#define VNODE_PAGER_NULL ((vnode_pager_t) 0)
124
125
91447636
A
126pager_return_t vnode_pagein(struct vnode *, upl_t,
127 upl_offset_t, vm_object_offset_t,
128 upl_size_t, int, int *);
129pager_return_t vnode_pageout(struct vnode *, upl_t,
130 upl_offset_t, vm_object_offset_t,
131 upl_size_t, int, int *);
1c79356b 132
91447636
A
133extern vm_object_offset_t vnode_pager_get_filesize(
134 struct vnode *vp);
1c79356b 135
c0fea474
A
136extern kern_return_t vnode_pager_get_pathname(
137 struct vnode *vp,
138 char *pathname,
139 vm_size_t *length_p);
140
141extern kern_return_t vnode_pager_get_filename(
142 struct vnode *vp,
143 char **filename);
144
1c79356b
A
145#endif /* KERNEL */
146
147#endif /* _VNODE_PAGER_ */