]>
Commit | Line | Data |
---|---|---|
91447636 A |
1 | /* |
2 | * Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved. | |
3 | * | |
4 | * @APPLE_LICENSE_HEADER_START@ | |
5 | * | |
ff6e181a 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. Please obtain a copy of the License at | |
10 | * http://www.opensource.apple.com/apsl/ and read it before using this | |
11 | * file. | |
91447636 | 12 | * |
ff6e181a A |
13 | * The Original Code and all software distributed under the License are |
14 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
91447636 A |
15 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
16 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
ff6e181a A |
17 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
18 | * Please see the License for the specific language governing rights and | |
19 | * limitations under the License. | |
91447636 A |
20 | * |
21 | * @APPLE_LICENSE_HEADER_END@ | |
22 | */ | |
23 | /* | |
24 | * File: ubc.h | |
25 | * Author: Umesh Vaishampayan [umeshv@apple.com] | |
26 | * 05-Aug-1999 umeshv Created. | |
27 | * | |
28 | * Header file for Unified Buffer Cache. | |
29 | * | |
30 | */ | |
31 | ||
32 | #ifndef _SYS_UBC_INTERNAL_H_ | |
33 | #define _SYS_UBC_INTERNAL_H_ | |
34 | ||
35 | #include <sys/appleapiopts.h> | |
36 | #include <sys/types.h> | |
37 | #include <sys/kernel_types.h> | |
38 | #include <sys/ucred.h> | |
39 | #include <sys/vnode.h> | |
40 | #include <sys/ubc.h> | |
41 | #include <sys/mman.h> | |
42 | ||
43 | #include <sys/cdefs.h> | |
44 | ||
45 | #include <kern/locks.h> | |
46 | #include <mach/memory_object_types.h> | |
47 | ||
48 | ||
49 | #define UBC_INFO_NULL ((struct ubc_info *) 0) | |
50 | ||
51 | ||
52 | extern struct zone *ubc_info_zone; | |
53 | ||
54 | ||
55 | #define MAX_CLUSTERS 4 /* maximum number of vfs clusters per vnode */ | |
56 | ||
57 | struct cl_extent { | |
58 | daddr64_t b_addr; | |
59 | daddr64_t e_addr; | |
60 | }; | |
61 | ||
62 | struct cl_wextent { | |
63 | daddr64_t b_addr; | |
64 | daddr64_t e_addr; | |
65 | int io_nocache; | |
66 | }; | |
67 | ||
68 | struct cl_readahead { | |
69 | lck_mtx_t cl_lockr; | |
70 | daddr64_t cl_lastr; /* last block read by client */ | |
71 | daddr64_t cl_maxra; /* last block prefetched by the read ahead */ | |
72 | int cl_ralen; /* length of last prefetch */ | |
73 | }; | |
74 | ||
75 | struct cl_writebehind { | |
76 | lck_mtx_t cl_lockw; | |
77 | int cl_hasbeenpaged; /* if set, indicates pager has cleaned pages associated with this file */ | |
78 | void * cl_scmap; /* pointer to sparse cluster map */ | |
79 | int cl_scdirty; /* number of dirty pages in the sparse cluster map */ | |
80 | int cl_number; /* number of packed write behind clusters currently valid */ | |
81 | struct cl_wextent cl_clusters[MAX_CLUSTERS]; /* packed write behind clusters */ | |
82 | }; | |
83 | ||
84 | ||
85 | /* | |
86 | * The following data structure keeps the information to associate | |
87 | * a vnode to the correspondig VM objects. | |
88 | */ | |
89 | struct ubc_info { | |
90 | memory_object_t ui_pager; /* pager */ | |
91 | memory_object_control_t ui_control; /* VM control for the pager */ | |
92 | long ui_flags; /* flags */ | |
93 | vnode_t *ui_vnode; /* The vnode for this ubc_info */ | |
94 | ucred_t *ui_ucred; /* holds credentials for NFS paging */ | |
95 | off_t ui_size; /* file size for the vnode */ | |
96 | ||
97 | struct cl_readahead *cl_rahead; /* cluster read ahead context */ | |
98 | struct cl_writebehind *cl_wbehind; /* cluster write behind context */ | |
99 | }; | |
100 | ||
101 | /* Defines for ui_flags */ | |
102 | #define UI_NONE 0x00000000 /* none */ | |
103 | #define UI_HASPAGER 0x00000001 /* has a pager associated */ | |
104 | #define UI_INITED 0x00000002 /* newly initialized vnode */ | |
105 | #define UI_HASOBJREF 0x00000004 /* hold a reference on object */ | |
106 | #define UI_WASMAPPED 0x00000008 /* vnode was mapped */ | |
107 | #define UI_ISMAPPED 0x00000010 /* vnode is currently mapped */ | |
108 | ||
109 | /* | |
110 | * exported primitives for loadable file systems. | |
111 | */ | |
112 | ||
113 | __BEGIN_DECLS | |
114 | __private_extern__ int ubc_umount(struct mount *mp); | |
115 | __private_extern__ void ubc_unmountall(void); | |
116 | __private_extern__ memory_object_t ubc_getpager(struct vnode *); | |
117 | __private_extern__ int ubc_map(struct vnode *, int); | |
118 | __private_extern__ int ubc_destroy_named(struct vnode *); | |
119 | ||
120 | /* internal only */ | |
121 | __private_extern__ void cluster_release(struct ubc_info *); | |
122 | ||
123 | ||
124 | /* Flags for ubc_getobject() */ | |
125 | #define UBC_FLAGS_NONE 0x0000 | |
126 | #define UBC_HOLDOBJECT 0x0001 | |
127 | #define UBC_FOR_PAGEOUT 0x0002 | |
128 | ||
129 | memory_object_control_t ubc_getobject(struct vnode *, int); | |
130 | ||
131 | int ubc_info_init(struct vnode *); | |
132 | void ubc_info_deallocate (struct ubc_info *); | |
133 | ||
134 | int ubc_isinuse(struct vnode *, int); | |
135 | ||
136 | int ubc_page_op(vnode_t, off_t, int, ppnum_t *, int *); | |
137 | int ubc_range_op(vnode_t, off_t, off_t, int, int *); | |
138 | ||
139 | ||
140 | int cluster_copy_upl_data(struct uio *, upl_t, int, int); | |
141 | int cluster_copy_ubc_data(vnode_t, struct uio *, int *, int); | |
142 | ||
143 | ||
144 | int UBCINFOMISSING(vnode_t); | |
145 | int UBCINFORECLAIMED(vnode_t); | |
146 | int UBCINFOEXISTS(vnode_t); | |
147 | int UBCISVALID(vnode_t); | |
148 | int UBCINVALID(vnode_t); | |
149 | int UBCINFOCHECK(const char *, vnode_t); | |
150 | ||
151 | __END_DECLS | |
152 | ||
153 | ||
154 | #endif /* _SYS_UBC_INTERNAL_H_ */ | |
155 |