]> git.saurik.com Git - apple/xnu.git/blame_incremental - bsd/sys/ubc.h
xnu-517.12.7.tar.gz
[apple/xnu.git] / bsd / sys / ubc.h
... / ...
CommitLineData
1/*
2 * Copyright (c) 1999, 2000-2002 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
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.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22/*
23 * File: ubc.h
24 * Author: Umesh Vaishampayan [umeshv@apple.com]
25 * 05-Aug-1999 umeshv Created.
26 *
27 * Header file for Unified Buffer Cache.
28 *
29 */
30
31#ifndef _SYS_UBC_H_
32#define _SYS_UBC_H_
33
34#include <sys/appleapiopts.h>
35#include <sys/types.h>
36#include <sys/ucred.h>
37#include <sys/vnode.h>
38
39#include <sys/cdefs.h>
40
41#include <mach/memory_object_types.h>
42
43#define UBC_INFO_NULL ((struct ubc_info *) 0)
44#define UBC_NOINFO ((struct ubc_info *)0xDEADD1ED)
45
46#ifdef __APPLE_API_PRIVATE
47extern struct zone *ubc_info_zone;
48
49/*
50 * The following data structure keeps the information to associate
51 * a vnode to the correspondig VM objects.
52 */
53
54struct ubc_info {
55 memory_object_t ui_pager; /* pager */
56 memory_object_control_t ui_control; /* VM control for the pager */
57 long ui_flags; /* flags */
58 struct vnode *ui_vnode; /* The vnode for this ubc_info */
59 struct ucred *ui_ucred; /* holds credentials for NFS paging */
60 int ui_refcount;/* ref count on the ubc_info */
61 off_t ui_size; /* file size for the vnode */
62 long ui_mapped; /* is it currently mapped */
63 void *ui_owner; /* for recursive ubc_busy */
64};
65
66/* Defines for ui_flags */
67#define UI_NONE 0x00000000 /* none */
68#define UI_HASPAGER 0x00000001 /* has a pager associated */
69#define UI_INITED 0x00000002 /* newly initialized vnode */
70#define UI_HASOBJREF 0x00000004 /* hold a reference on object */
71#define UI_WASMAPPED 0x00000008 /* vnode was mapped */
72#define UI_DONTCACHE 0x00000010 /* do not cache object */
73#define UI_BUSY 0x00000020 /* for VM synchronization */
74#define UI_WANTED 0x00000040 /* for VM synchronization */
75
76#endif /* __APPLE_API_PRIVATE */
77
78#ifdef __APPLE_API_EVOLVING
79/*
80 * exported primitives for loadable file systems.
81 */
82
83__BEGIN_DECLS
84int ubc_info_init __P((struct vnode *));
85void ubc_info_deallocate __P((struct ubc_info *));
86int ubc_setsize __P((struct vnode *, off_t));
87off_t ubc_getsize __P((struct vnode *));
88int ubc_uncache __P((struct vnode *));
89int ubc_umount __P((struct mount *));
90void ubc_unmountall __P(());
91int ubc_setcred __P((struct vnode *, struct proc *));
92struct ucred *ubc_getcred __P((struct vnode *));
93memory_object_t ubc_getpager __P((struct vnode *));
94memory_object_control_t ubc_getobject __P((struct vnode *, int));
95int ubc_setpager __P((struct vnode *, memory_object_t));
96int ubc_setflags __P((struct vnode *, int));
97int ubc_clearflags __P((struct vnode *, int));
98int ubc_issetflags __P((struct vnode *, int));
99off_t ubc_blktooff __P((struct vnode *, daddr_t));
100daddr_t ubc_offtoblk __P((struct vnode *, off_t));
101int ubc_clean __P((struct vnode *, int));
102int ubc_pushdirty __P((struct vnode *));
103int ubc_pushdirty_range __P((struct vnode *, off_t, off_t));
104int ubc_hold __P((struct vnode *));
105void ubc_rele __P((struct vnode *));
106void ubc_map __P((struct vnode *));
107int ubc_destroy_named __P((struct vnode *));
108int ubc_release_named __P((struct vnode *));
109int ubc_invalidate __P((struct vnode *, off_t, size_t));
110int ubc_isinuse __P((struct vnode *, int));
111
112int ubc_page_op __P((struct vnode *, off_t, int, ppnum_t *, int *));
113
114/* cluster IO routines */
115int cluster_read __P((struct vnode *, struct uio *, off_t, int, int));
116int advisory_read __P((struct vnode *, off_t, off_t, int, int));
117int cluster_write __P((struct vnode *, struct uio*, off_t, off_t,
118 off_t, off_t, int, int));
119int cluster_push __P((struct vnode *));
120int cluster_release __P((struct vnode *));
121int cluster_pageout __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
122 off_t, int, int));
123int cluster_pagein __P((struct vnode *, upl_t, vm_offset_t, off_t, int,
124 off_t, int, int));
125int cluster_bp __P((struct buf *));
126int cluster_copy_upl_data __P((struct uio *, upl_t, int, int));
127int cluster_copy_ubc_data __P((struct vnode *, struct uio *, int *, int));
128
129/* UPL routines */
130int ubc_create_upl __P((struct vnode *, off_t, long, upl_t *,
131 upl_page_info_t **, int));
132int ubc_upl_map __P((upl_t, vm_offset_t *));
133int ubc_upl_unmap __P((upl_t));
134int ubc_upl_commit __P((upl_t));
135int ubc_upl_commit_range __P((upl_t, vm_offset_t, vm_size_t, int));
136int ubc_upl_abort __P((upl_t, int));
137int ubc_upl_abort_range __P((upl_t, vm_offset_t, vm_size_t, int));
138upl_page_info_t *ubc_upl_pageinfo __P((upl_t));
139__END_DECLS
140
141#define UBCINFOMISSING(vp) \
142 ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL))
143
144#define UBCINFORECLAIMED(vp) \
145 ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO))
146
147#define UBCINFOEXISTS(vp) \
148 ((vp) && ((vp)->v_type == VREG) && \
149 ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO))
150
151#define UBCISVALID(vp) \
152 ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM))
153
154#define UBCINVALID(vp) \
155 (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \
156 || ((vp) && ((vp)->v_flag & VSYSTEM)))
157
158#define UBCINFOCHECK(fun, vp) \
159 if ((vp) && ((vp)->v_type == VREG) && \
160 (((vp)->v_ubcinfo == UBC_INFO_NULL) \
161 || ((vp)->v_ubcinfo == UBC_NOINFO))) \
162 panic("%s: lost ubc_info", (fun));
163
164/* Flags for ubc_getobject() */
165#define UBC_FLAGS_NONE 0x0000
166#define UBC_HOLDOBJECT 0x0001
167#define UBC_FOR_PAGEOUT 0x0002
168
169#endif /* __APPLE_API_EVOLVING */
170
171#endif /* _SYS_UBC_H_ */
172