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