2 * Copyright (c) 1999, 2000-2002 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
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.
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
20 * @APPLE_LICENSE_HEADER_END@
24 * Author: Umesh Vaishampayan [umeshv@apple.com]
25 * 05-Aug-1999 umeshv Created.
27 * Header file for Unified Buffer Cache.
34 #include <sys/appleapiopts.h>
35 #include <sys/types.h>
36 #include <sys/ucred.h>
37 #include <sys/vnode.h>
39 #include <sys/cdefs.h>
41 #include <mach/memory_object_types.h>
43 #define UBC_INFO_NULL ((struct ubc_info *) 0)
44 #define UBC_NOINFO ((struct ubc_info *)0xDEADD1ED)
46 #ifdef __APPLE_API_PRIVATE
47 extern struct zone
*ubc_info_zone
;
50 * The following data structure keeps the information to associate
51 * a vnode to the correspondig VM objects.
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 */
65 /* Defines for ui_flags */
66 #define UI_NONE 0x00000000 /* none */
67 #define UI_HASPAGER 0x00000001 /* has a pager associated */
68 #define UI_INITED 0x00000002 /* newly initialized vnode */
69 #define UI_HASOBJREF 0x00000004 /* hold a reference on object */
70 #define UI_WASMAPPED 0x00000008 /* vnode was mapped */
71 #define UI_DONTCACHE 0x00000010 /* do not cache object */
73 #endif /* __APPLE_API_PRIVATE */
75 #ifdef __APPLE_API_EVOLVING
77 * exported primitives for loadable file systems.
81 int ubc_info_init
__P((struct vnode
*));
82 void ubc_info_deallocate
__P((struct ubc_info
*));
83 int ubc_setsize
__P((struct vnode
*, off_t
));
84 off_t ubc_getsize
__P((struct vnode
*));
85 int ubc_uncache
__P((struct vnode
*));
86 int ubc_umount
__P((struct mount
*));
87 void ubc_unmountall
__P(());
88 int ubc_setcred
__P((struct vnode
*, struct proc
*));
89 struct ucred
*ubc_getcred
__P((struct vnode
*));
90 memory_object_t ubc_getpager
__P((struct vnode
*));
91 memory_object_control_t ubc_getobject
__P((struct vnode
*, int));
92 int ubc_setpager
__P((struct vnode
*, memory_object_t
));
93 int ubc_setflags
__P((struct vnode
*, int));
94 int ubc_clearflags
__P((struct vnode
*, int));
95 int ubc_issetflags
__P((struct vnode
*, int));
96 off_t ubc_blktooff
__P((struct vnode
*, daddr_t
));
97 daddr_t ubc_offtoblk
__P((struct vnode
*, off_t
));
98 int ubc_clean
__P((struct vnode
*, int));
99 int ubc_pushdirty
__P((struct vnode
*));
100 int ubc_pushdirty_range
__P((struct vnode
*, off_t
, off_t
));
101 int ubc_hold
__P((struct vnode
*));
102 void ubc_rele
__P((struct vnode
*));
103 void ubc_map
__P((struct vnode
*));
104 int ubc_destroy_named
__P((struct vnode
*));
105 int ubc_release_named
__P((struct vnode
*));
106 int ubc_invalidate
__P((struct vnode
*, off_t
, size_t));
107 int ubc_isinuse
__P((struct vnode
*, int));
109 int ubc_page_op
__P((struct vnode
*, off_t
, int, vm_offset_t
*, int *));
111 /* cluster IO routines */
112 int cluster_read
__P((struct vnode
*, struct uio
*, off_t
, int, int));
113 int advisory_read
__P((struct vnode
*, off_t
, off_t
, int, int));
114 int cluster_write
__P((struct vnode
*, struct uio
*, off_t
, off_t
,
115 off_t
, off_t
, int, int));
116 int cluster_push
__P((struct vnode
*));
117 int cluster_pageout
__P((struct vnode
*, upl_t
, vm_offset_t
, off_t
, int,
119 int cluster_pagein
__P((struct vnode
*, upl_t
, vm_offset_t
, off_t
, int,
121 int cluster_bp
__P((struct buf
*));
124 int ubc_create_upl
__P((struct vnode
*, off_t
, long, upl_t
*,
125 upl_page_info_t
**, int));
126 int ubc_upl_map
__P((upl_t
, vm_offset_t
*));
127 int ubc_upl_unmap
__P((upl_t
));
128 int ubc_upl_commit
__P((upl_t
));
129 int ubc_upl_commit_range
__P((upl_t
, vm_offset_t
, vm_size_t
, int));
130 int ubc_upl_abort
__P((upl_t
, int));
131 int ubc_upl_abort_range
__P((upl_t
, vm_offset_t
, vm_size_t
, int));
132 upl_page_info_t
*ubc_upl_pageinfo
__P((upl_t
));
135 #define UBCINFOMISSING(vp) \
136 ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_INFO_NULL))
138 #define UBCINFORECLAIMED(vp) \
139 ((vp) && ((vp)->v_type == VREG) && ((vp)->v_ubcinfo == UBC_NOINFO))
141 #define UBCINFOEXISTS(vp) \
142 ((vp) && ((vp)->v_type == VREG) && \
143 ((vp)->v_ubcinfo) && ((vp)->v_ubcinfo != UBC_NOINFO))
145 #define UBCISVALID(vp) \
146 ((vp) && ((vp)->v_type == VREG) && !((vp)->v_flag & VSYSTEM))
148 #define UBCINVALID(vp) \
149 (((vp) == NULL) || ((vp) && ((vp)->v_type != VREG)) \
150 || ((vp) && ((vp)->v_flag & VSYSTEM)))
152 #define UBCINFOCHECK(fun, vp) \
153 if ((vp) && ((vp)->v_type == VREG) && \
154 (((vp)->v_ubcinfo == UBC_INFO_NULL) \
155 || ((vp)->v_ubcinfo == UBC_NOINFO))) \
156 panic("%s: lost ubc_info", (fun));
158 /* Flags for ubc_getobject() */
159 #define UBC_FLAGS_NONE 0x0000
160 #define UBC_HOLDOBJECT 0x0001
162 #endif /* __APPLE_API_EVOLVING */
164 #endif /* _SYS_UBC_H_ */