2 * Copyright (c) 1999-2004 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_OSREFERENCE_HEADER_START@
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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
32 * Author: Umesh Vaishampayan [umeshv@apple.com]
33 * 05-Aug-1999 umeshv Created.
35 * Header file for Unified Buffer Cache.
39 #ifndef _SYS_UBC_INTERNAL_H_
40 #define _SYS_UBC_INTERNAL_H_
42 #include <sys/appleapiopts.h>
43 #include <sys/types.h>
44 #include <sys/kernel_types.h>
45 #include <sys/ucred.h>
46 #include <sys/vnode.h>
50 #include <sys/cdefs.h>
52 #include <kern/locks.h>
53 #include <mach/memory_object_types.h>
56 #define UBC_INFO_NULL ((struct ubc_info *) 0)
59 extern struct zone
*ubc_info_zone
;
62 #define MAX_CLUSTERS 4 /* maximum number of vfs clusters per vnode */
77 daddr64_t cl_lastr
; /* last block read by client */
78 daddr64_t cl_maxra
; /* last block prefetched by the read ahead */
79 int cl_ralen
; /* length of last prefetch */
82 struct cl_writebehind
{
84 int cl_hasbeenpaged
; /* if set, indicates pager has cleaned pages associated with this file */
85 void * cl_scmap
; /* pointer to sparse cluster map */
86 int cl_scdirty
; /* number of dirty pages in the sparse cluster map */
87 int cl_number
; /* number of packed write behind clusters currently valid */
88 struct cl_wextent cl_clusters
[MAX_CLUSTERS
]; /* packed write behind clusters */
93 * The following data structure keeps the information to associate
94 * a vnode to the correspondig VM objects.
97 memory_object_t ui_pager
; /* pager */
98 memory_object_control_t ui_control
; /* VM control for the pager */
99 long ui_flags
; /* flags */
100 vnode_t
*ui_vnode
; /* The vnode for this ubc_info */
101 ucred_t
*ui_ucred
; /* holds credentials for NFS paging */
102 off_t ui_size
; /* file size for the vnode */
104 struct cl_readahead
*cl_rahead
; /* cluster read ahead context */
105 struct cl_writebehind
*cl_wbehind
; /* cluster write behind context */
108 /* Defines for ui_flags */
109 #define UI_NONE 0x00000000 /* none */
110 #define UI_HASPAGER 0x00000001 /* has a pager associated */
111 #define UI_INITED 0x00000002 /* newly initialized vnode */
112 #define UI_HASOBJREF 0x00000004 /* hold a reference on object */
113 #define UI_WASMAPPED 0x00000008 /* vnode was mapped */
114 #define UI_ISMAPPED 0x00000010 /* vnode is currently mapped */
117 * exported primitives for loadable file systems.
121 __private_extern__
int ubc_umount(struct mount
*mp
);
122 __private_extern__
void ubc_unmountall(void);
123 __private_extern__ memory_object_t
ubc_getpager(struct vnode
*);
124 __private_extern__
int ubc_map(struct vnode
*, int);
125 __private_extern__
int ubc_destroy_named(struct vnode
*);
128 __private_extern__
void cluster_release(struct ubc_info
*);
131 /* Flags for ubc_getobject() */
132 #define UBC_FLAGS_NONE 0x0000
133 #define UBC_HOLDOBJECT 0x0001
134 #define UBC_FOR_PAGEOUT 0x0002
136 memory_object_control_t
ubc_getobject(struct vnode
*, int);
138 int ubc_info_init(struct vnode
*);
139 void ubc_info_deallocate (struct ubc_info
*);
141 int ubc_isinuse(struct vnode
*, int);
143 int ubc_page_op(vnode_t
, off_t
, int, ppnum_t
*, int *);
144 int ubc_range_op(vnode_t
, off_t
, off_t
, int, int *);
147 int cluster_copy_upl_data(struct uio
*, upl_t
, int, int);
148 int cluster_copy_ubc_data(vnode_t
, struct uio
*, int *, int);
151 int UBCINFOMISSING(vnode_t
);
152 int UBCINFORECLAIMED(vnode_t
);
153 int UBCINFOEXISTS(vnode_t
);
154 int UBCISVALID(vnode_t
);
155 int UBCINVALID(vnode_t
);
156 int UBCINFOCHECK(const char *, vnode_t
);
161 #endif /* _SYS_UBC_INTERNAL_H_ */