2 * Copyright (c) 1999-2004 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.
31 #ifndef _SYS_UBC_INTERNAL_H_
32 #define _SYS_UBC_INTERNAL_H_
34 #include <sys/appleapiopts.h>
35 #include <sys/types.h>
36 #include <sys/kernel_types.h>
37 #include <sys/ucred.h>
38 #include <sys/vnode.h>
42 #include <sys/cdefs.h>
44 #include <kern/locks.h>
45 #include <mach/memory_object_types.h>
48 #define UBC_INFO_NULL ((struct ubc_info *) 0)
51 extern struct zone
*ubc_info_zone
;
54 #define MAX_CLUSTERS 4 /* maximum number of vfs clusters per vnode */
69 daddr64_t cl_lastr
; /* last block read by client */
70 daddr64_t cl_maxra
; /* last block prefetched by the read ahead */
71 int cl_ralen
; /* length of last prefetch */
74 struct cl_writebehind
{
76 int cl_hasbeenpaged
; /* if set, indicates pager has cleaned pages associated with this file */
77 void * cl_scmap
; /* pointer to sparse cluster map */
78 int cl_scdirty
; /* number of dirty pages in the sparse cluster map */
79 int cl_number
; /* number of packed write behind clusters currently valid */
80 struct cl_wextent cl_clusters
[MAX_CLUSTERS
]; /* packed write behind clusters */
85 * The following data structure keeps the information to associate
86 * a vnode to the correspondig VM objects.
89 memory_object_t ui_pager
; /* pager */
90 memory_object_control_t ui_control
; /* VM control for the pager */
91 long ui_flags
; /* flags */
92 vnode_t
*ui_vnode
; /* The vnode for this ubc_info */
93 ucred_t
*ui_ucred
; /* holds credentials for NFS paging */
94 off_t ui_size
; /* file size for the vnode */
96 struct cl_readahead
*cl_rahead
; /* cluster read ahead context */
97 struct cl_writebehind
*cl_wbehind
; /* cluster write behind context */
100 /* Defines for ui_flags */
101 #define UI_NONE 0x00000000 /* none */
102 #define UI_HASPAGER 0x00000001 /* has a pager associated */
103 #define UI_INITED 0x00000002 /* newly initialized vnode */
104 #define UI_HASOBJREF 0x00000004 /* hold a reference on object */
105 #define UI_WASMAPPED 0x00000008 /* vnode was mapped */
106 #define UI_ISMAPPED 0x00000010 /* vnode is currently mapped */
109 * exported primitives for loadable file systems.
113 __private_extern__
int ubc_umount(struct mount
*mp
);
114 __private_extern__
void ubc_unmountall(void);
115 __private_extern__ memory_object_t
ubc_getpager(struct vnode
*);
116 __private_extern__
int ubc_map(struct vnode
*, int);
117 __private_extern__
int ubc_destroy_named(struct vnode
*);
120 __private_extern__
void cluster_release(struct ubc_info
*);
123 /* Flags for ubc_getobject() */
124 #define UBC_FLAGS_NONE 0x0000
125 #define UBC_HOLDOBJECT 0x0001
126 #define UBC_FOR_PAGEOUT 0x0002
128 memory_object_control_t
ubc_getobject(struct vnode
*, int);
130 int ubc_info_init(struct vnode
*);
131 void ubc_info_deallocate (struct ubc_info
*);
133 int ubc_isinuse(struct vnode
*, int);
135 int ubc_page_op(vnode_t
, off_t
, int, ppnum_t
*, int *);
136 int ubc_range_op(vnode_t
, off_t
, off_t
, int, int *);
139 int cluster_copy_upl_data(struct uio
*, upl_t
, int, int);
140 int cluster_copy_ubc_data(vnode_t
, struct uio
*, int *, int);
143 int UBCINFOMISSING(vnode_t
);
144 int UBCINFORECLAIMED(vnode_t
);
145 int UBCINFOEXISTS(vnode_t
);
146 int UBCISVALID(vnode_t
);
147 int UBCINVALID(vnode_t
);
148 int UBCINFOCHECK(const char *, vnode_t
);
153 #endif /* _SYS_UBC_INTERNAL_H_ */