Sat Jan 23 16:02:09 2016 UTC ()
protect more kernel stuff.


(christos)
diff -r1.257 -r1.258 src/sys/sys/vnode.h
diff -r1.16 -r1.17 src/sys/sys/wapbl.h

cvs diff -r1.257 -r1.258 src/sys/sys/vnode.h (switch to unified diff)

--- src/sys/sys/vnode.h 2016/01/22 22:43:25 1.257
+++ src/sys/sys/vnode.h 2016/01/23 16:02:09 1.258
@@ -1,606 +1,610 @@ @@ -1,606 +1,610 @@
1/* $NetBSD: vnode.h,v 1.257 2016/01/22 22:43:25 dholland Exp $ */ 1/* $NetBSD: vnode.h,v 1.258 2016/01/23 16:02:09 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 16 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 17 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 18 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 19 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26 * POSSIBILITY OF SUCH DAMAGE. 26 * POSSIBILITY OF SUCH DAMAGE.
27 */ 27 */
28 28
29/* 29/*
30 * Copyright (c) 1989, 1993 30 * Copyright (c) 1989, 1993
31 * The Regents of the University of California. All rights reserved. 31 * The Regents of the University of California. All rights reserved.
32 * 32 *
33 * Redistribution and use in source and binary forms, with or without 33 * Redistribution and use in source and binary forms, with or without
34 * modification, are permitted provided that the following conditions 34 * modification, are permitted provided that the following conditions
35 * are met: 35 * are met:
36 * 1. Redistributions of source code must retain the above copyright 36 * 1. Redistributions of source code must retain the above copyright
37 * notice, this list of conditions and the following disclaimer. 37 * notice, this list of conditions and the following disclaimer.
38 * 2. Redistributions in binary form must reproduce the above copyright 38 * 2. Redistributions in binary form must reproduce the above copyright
39 * notice, this list of conditions and the following disclaimer in the 39 * notice, this list of conditions and the following disclaimer in the
40 * documentation and/or other materials provided with the distribution. 40 * documentation and/or other materials provided with the distribution.
41 * 3. Neither the name of the University nor the names of its contributors 41 * 3. Neither the name of the University nor the names of its contributors
42 * may be used to endorse or promote products derived from this software 42 * may be used to endorse or promote products derived from this software
43 * without specific prior written permission. 43 * without specific prior written permission.
44 * 44 *
45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 45 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 46 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 47 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 48 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 49 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 50 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 51 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 52 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 53 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 54 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
55 * SUCH DAMAGE. 55 * SUCH DAMAGE.
56 * 56 *
57 * @(#)vnode.h 8.17 (Berkeley) 5/20/95 57 * @(#)vnode.h 8.17 (Berkeley) 5/20/95
58 */ 58 */
59 59
60#ifndef _SYS_VNODE_H_ 60#ifndef _SYS_VNODE_H_
61#define _SYS_VNODE_H_ 61#define _SYS_VNODE_H_
62 62
63#include <sys/event.h> 63#include <sys/event.h>
64#include <sys/queue.h> 64#include <sys/queue.h>
65#include <sys/condvar.h> 65#include <sys/condvar.h>
66#include <sys/rwlock.h> 66#include <sys/rwlock.h>
67#include <sys/mutex.h> 67#include <sys/mutex.h>
68#include <sys/time.h> 68#include <sys/time.h>
69 69
70/* XXX: clean up includes later */ 70/* XXX: clean up includes later */
 71#if defined(_KERNEL) || defined(_KMEMUSER)
71#include <uvm/uvm_param.h> /* XXX */ 72#include <uvm/uvm_param.h> /* XXX */
72#include <uvm/uvm_pglist.h> /* XXX */ 73#include <uvm/uvm_pglist.h> /* XXX */
73#include <uvm/uvm_object.h> /* XXX */ 74#include <uvm/uvm_object.h> /* XXX */
74#include <uvm/uvm_extern.h> /* XXX */ 75#include <uvm/uvm_extern.h> /* XXX */
75 76
76struct namecache; 77struct namecache;
77struct uvm_ractx; 78struct uvm_ractx;
 79#endif
78 80
79/* 81/*
80 * The vnode is the focus of all file activity in UNIX. There is a 82 * The vnode is the focus of all file activity in UNIX. There is a
81 * unique vnode allocated for each active file, each current directory, 83 * unique vnode allocated for each active file, each current directory,
82 * each mounted-on file, text file, and the root. 84 * each mounted-on file, text file, and the root.
83 */ 85 */
84 86
85/* 87/*
86 * Vnode types. VNON means no type. 88 * Vnode types. VNON means no type.
87 */ 89 */
88enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD }; 90enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD };
89 91
90#define VNODE_TYPES \ 92#define VNODE_TYPES \
91 "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD" 93 "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD"
92 94
93/* 95/*
94 * Vnode tag types. 96 * Vnode tag types.
95 * These are for the benefit of external programs only (e.g., pstat) 97 * These are for the benefit of external programs only (e.g., pstat)
96 * and should NEVER be inspected by the kernel. 98 * and should NEVER be inspected by the kernel.
97 */ 99 */
98enum vtagtype { 100enum vtagtype {
99 VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS, 101 VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS,
100 VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, 102 VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS,
101 VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA, 103 VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA,
102 VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS, 104 VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS,
103 VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS, 105 VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS,
104 VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS 106 VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS
105}; 107};
106 108
107#define VNODE_TAGS \ 109#define VNODE_TAGS \
108 "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \ 110 "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \
109 "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \ 111 "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \
110 "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \ 112 "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \
111 "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \ 113 "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \
112 "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \ 114 "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \
113 "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS" 115 "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS"
114 116
 117#if defined(_KERNEL) || defined(_KMEMUSER)
115struct vnode; 118struct vnode;
116struct buf; 119struct buf;
117 120
118LIST_HEAD(buflists, buf); 121LIST_HEAD(buflists, buf);
119TAILQ_HEAD(vnodelst, vnode); 122TAILQ_HEAD(vnodelst, vnode);
120 123
121/* 124/*
122 * Reading or writing any of these items requires holding the appropriate 125 * Reading or writing any of these items requires holding the appropriate
123 * lock. Field markings and the corresponding locks: 126 * lock. Field markings and the corresponding locks:
124 * 127 *
125 * : stable, reference to the vnode is required 128 * : stable, reference to the vnode is required
126 * f vnode_free_list_lock, or vrele_lock for vrele_list 129 * f vnode_free_list_lock, or vrele_lock for vrele_list
127 * i v_interlock 130 * i v_interlock
128 * m mntvnode_lock 131 * m mntvnode_lock
129 * n namecache_lock 132 * n namecache_lock
130 * s syncer_data_lock 133 * s syncer_data_lock
131 * u locked by underlying filesystem 134 * u locked by underlying filesystem
132 * v vnode lock 135 * v vnode lock
133 * x v_interlock + bufcache_lock to modify, either to inspect 136 * x v_interlock + bufcache_lock to modify, either to inspect
134 * 137 *
135 * Each underlying filesystem allocates its own private area and hangs 138 * Each underlying filesystem allocates its own private area and hangs
136 * it from v_data. 139 * it from v_data.
137 */ 140 */
138struct vnode { 141struct vnode {
139 struct uvm_object v_uobj; /* i: the VM object */ 142 struct uvm_object v_uobj; /* i: the VM object */
140 kcondvar_t v_cv; /* i: synchronization */ 143 kcondvar_t v_cv; /* i: synchronization */
141 voff_t v_size; /* i: size of file */ 144 voff_t v_size; /* i: size of file */
142 voff_t v_writesize; /* i: new size after write */ 145 voff_t v_writesize; /* i: new size after write */
143 int v_iflag; /* i: VI_* flags */ 146 int v_iflag; /* i: VI_* flags */
144 int v_vflag; /* v: VV_* flags */ 147 int v_vflag; /* v: VV_* flags */
145 int v_uflag; /* u: VU_* flags */ 148 int v_uflag; /* u: VU_* flags */
146 int v_numoutput; /* i: # of pending writes */ 149 int v_numoutput; /* i: # of pending writes */
147 int v_writecount; /* i: ref count of writers */ 150 int v_writecount; /* i: ref count of writers */
148 int v_holdcnt; /* i: page & buffer refs */ 151 int v_holdcnt; /* i: page & buffer refs */
149 int v_synclist_slot; /* s: synclist slot index */ 152 int v_synclist_slot; /* s: synclist slot index */
150 struct mount *v_mount; /* v: ptr to vfs we are in */ 153 struct mount *v_mount; /* v: ptr to vfs we are in */
151 int (**v_op)(void *); /* :: vnode operations vector */ 154 int (**v_op)(void *); /* :: vnode operations vector */
152 TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */ 155 TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */
153 struct vnodelst *v_freelisthd; /* f: which freelist? */ 156 struct vnodelst *v_freelisthd; /* f: which freelist? */
154 TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */ 157 TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */
155 struct buflists v_cleanblkhd; /* x: clean blocklist head */ 158 struct buflists v_cleanblkhd; /* x: clean blocklist head */
156 struct buflists v_dirtyblkhd; /* x: dirty blocklist head */ 159 struct buflists v_dirtyblkhd; /* x: dirty blocklist head */
157 TAILQ_ENTRY(vnode) v_synclist; /* s: vnodes with dirty bufs */ 160 TAILQ_ENTRY(vnode) v_synclist; /* s: vnodes with dirty bufs */
158 LIST_HEAD(, namecache) v_dnclist; /* n: namecaches (children) */ 161 LIST_HEAD(, namecache) v_dnclist; /* n: namecaches (children) */
159 LIST_HEAD(, namecache) v_nclist; /* n: namecaches (parent) */ 162 LIST_HEAD(, namecache) v_nclist; /* n: namecaches (parent) */
160 union { 163 union {
161 struct mount *vu_mountedhere;/* v: ptr to vfs (VDIR) */ 164 struct mount *vu_mountedhere;/* v: ptr to vfs (VDIR) */
162 struct socket *vu_socket; /* v: unix ipc (VSOCK) */ 165 struct socket *vu_socket; /* v: unix ipc (VSOCK) */
163 struct specnode *vu_specnode; /* v: device (VCHR, VBLK) */ 166 struct specnode *vu_specnode; /* v: device (VCHR, VBLK) */
164 struct fifoinfo *vu_fifoinfo; /* v: fifo (VFIFO) */ 167 struct fifoinfo *vu_fifoinfo; /* v: fifo (VFIFO) */
165 struct uvm_ractx *vu_ractx; /* i: read-ahead ctx (VREG) */ 168 struct uvm_ractx *vu_ractx; /* i: read-ahead ctx (VREG) */
166 } v_un; 169 } v_un;
167 enum vtype v_type; /* :: vnode type */ 170 enum vtype v_type; /* :: vnode type */
168 enum vtagtype v_tag; /* :: type of underlying data */ 171 enum vtagtype v_tag; /* :: type of underlying data */
169 krwlock_t v_lock; /* v: lock for this vnode */ 172 krwlock_t v_lock; /* v: lock for this vnode */
170 void *v_data; /* :: private data for fs */ 173 void *v_data; /* :: private data for fs */
171 struct klist v_klist; /* i: notes attached to vnode */ 174 struct klist v_klist; /* i: notes attached to vnode */
172}; 175};
173#define v_usecount v_uobj.uo_refs 176#define v_usecount v_uobj.uo_refs
174#define v_interlock v_uobj.vmobjlock 177#define v_interlock v_uobj.vmobjlock
175#define v_mountedhere v_un.vu_mountedhere 178#define v_mountedhere v_un.vu_mountedhere
176#define v_socket v_un.vu_socket 179#define v_socket v_un.vu_socket
177#define v_specnode v_un.vu_specnode 180#define v_specnode v_un.vu_specnode
178#define v_fifoinfo v_un.vu_fifoinfo 181#define v_fifoinfo v_un.vu_fifoinfo
179#define v_ractx v_un.vu_ractx 182#define v_ractx v_un.vu_ractx
180 183
181typedef struct vnodelst vnodelst_t; 184typedef struct vnodelst vnodelst_t;
182typedef struct vnode vnode_t; 185typedef struct vnode vnode_t;
 186#endif
183 187
184/* 188/*
185 * Vnode flags. The first set are locked by vnode lock or are stable. 189 * Vnode flags. The first set are locked by vnode lock or are stable.
186 * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used 190 * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used
187 * when reading dead vnodes. 191 * when reading dead vnodes.
188 */ 192 */
189#define VV_ROOT 0x00000001 /* root of its file system */ 193#define VV_ROOT 0x00000001 /* root of its file system */
190#define VV_SYSTEM 0x00000002 /* vnode being used by kernel */ 194#define VV_SYSTEM 0x00000002 /* vnode being used by kernel */
191#define VV_ISTTY 0x00000004 /* vnode represents a tty */ 195#define VV_ISTTY 0x00000004 /* vnode represents a tty */
192#define VV_MAPPED 0x00000008 /* vnode might have user mappings */ 196#define VV_MAPPED 0x00000008 /* vnode might have user mappings */
193#define VV_MPSAFE 0x00000010 /* file system code is MP safe */ 197#define VV_MPSAFE 0x00000010 /* file system code is MP safe */
194#define VV_LOCKSWORK 0x00000020 /* FS supports locking discipline */ 198#define VV_LOCKSWORK 0x00000020 /* FS supports locking discipline */
195 199
196/* 200/*
197 * The second set are locked by vp->v_interlock. 201 * The second set are locked by vp->v_interlock.
198 */ 202 */
199#define VI_TEXT 0x00000100 /* vnode is a pure text prototype */ 203#define VI_TEXT 0x00000100 /* vnode is a pure text prototype */
200#define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */ 204#define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */
201#define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */ 205#define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */
202#define VI_WRMAPDIRTY 0x00000800 /* might have dirty pages */ 206#define VI_WRMAPDIRTY 0x00000800 /* might have dirty pages */
203#ifdef _VFS_VNODE_PRIVATE 207#ifdef _VFS_VNODE_PRIVATE
204#define VI_XLOCK 0x00001000 /* vnode is locked to change type */ 208#define VI_XLOCK 0x00001000 /* vnode is locked to change type */
205#endif /* _VFS_VNODE_PRIVATE */ 209#endif /* _VFS_VNODE_PRIVATE */
206#define VI_ONWORKLST 0x00004000 /* On syncer work-list */ 210#define VI_ONWORKLST 0x00004000 /* On syncer work-list */
207#ifdef _VFS_VNODE_PRIVATE 211#ifdef _VFS_VNODE_PRIVATE
208#define VI_MARKER 0x00008000 /* Dummy marker vnode */ 212#define VI_MARKER 0x00008000 /* Dummy marker vnode */
209#endif /* _VFS_VNODE_PRIVATE */ 213#endif /* _VFS_VNODE_PRIVATE */
210#ifdef _VFS_VNODE_PRIVATE 214#ifdef _VFS_VNODE_PRIVATE
211#define VI_CLEAN 0x00080000 /* has been reclaimed */ 215#define VI_CLEAN 0x00080000 /* has been reclaimed */
212#define VI_CHANGING 0x00100000 /* vnode changes state */ 216#define VI_CHANGING 0x00100000 /* vnode changes state */
213#endif /* _VFS_VNODE_PRIVATE */ 217#endif /* _VFS_VNODE_PRIVATE */
214 218
215/* 219/*
216 * The third set are locked by the underlying file system. 220 * The third set are locked by the underlying file system.
217 */ 221 */
218#define VU_DIROP 0x01000000 /* LFS: involved in a directory op */ 222#define VU_DIROP 0x01000000 /* LFS: involved in a directory op */
219 223
220#define VNODE_FLAGBITS \ 224#define VNODE_FLAGBITS \
221 "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \ 225 "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \
222 "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \ 226 "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \
223 "\24CLEAN\25CHANGING\31DIROP" 227 "\24CLEAN\25CHANGING\31DIROP"
224 228
225#define VSIZENOTSET ((voff_t)-1) 229#define VSIZENOTSET ((voff_t)-1)
226 230
227/* 231/*
228 * vnode lock flags 232 * vnode lock flags
229 */ 233 */
230#define LK_SHARED 0x00000001 /* shared lock */ 234#define LK_SHARED 0x00000001 /* shared lock */
231#define LK_EXCLUSIVE 0x00000002 /* exclusive lock */ 235#define LK_EXCLUSIVE 0x00000002 /* exclusive lock */
232#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */ 236#define LK_NOWAIT 0x00000010 /* do not sleep to await lock */
233#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */ 237#define LK_RETRY 0x00020000 /* vn_lock: retry until locked */
234 238
235/* 239/*
236 * Vnode attributes. A field value of VNOVAL represents a field whose value 240 * Vnode attributes. A field value of VNOVAL represents a field whose value
237 * is unavailable (getattr) or which is not to be changed (setattr). 241 * is unavailable (getattr) or which is not to be changed (setattr).
238 */ 242 */
239struct vattr { 243struct vattr {
240 enum vtype va_type; /* vnode type (for create) */ 244 enum vtype va_type; /* vnode type (for create) */
241 mode_t va_mode; /* files access mode and type */ 245 mode_t va_mode; /* files access mode and type */
242 nlink_t va_nlink; /* number of references to file */ 246 nlink_t va_nlink; /* number of references to file */
243 uid_t va_uid; /* owner user id */ 247 uid_t va_uid; /* owner user id */
244 gid_t va_gid; /* owner group id */ 248 gid_t va_gid; /* owner group id */
245 dev_t va_fsid; /* file system id (dev for now) */ 249 dev_t va_fsid; /* file system id (dev for now) */
246 ino_t va_fileid; /* file id */ 250 ino_t va_fileid; /* file id */
247 u_quad_t va_size; /* file size in bytes */ 251 u_quad_t va_size; /* file size in bytes */
248 long va_blocksize; /* blocksize preferred for i/o */ 252 long va_blocksize; /* blocksize preferred for i/o */
249 struct timespec va_atime; /* time of last access */ 253 struct timespec va_atime; /* time of last access */
250 struct timespec va_mtime; /* time of last modification */ 254 struct timespec va_mtime; /* time of last modification */
251 struct timespec va_ctime; /* time file changed */ 255 struct timespec va_ctime; /* time file changed */
252 struct timespec va_birthtime; /* time file created */ 256 struct timespec va_birthtime; /* time file created */
253 u_long va_gen; /* generation number of file */ 257 u_long va_gen; /* generation number of file */
254 u_long va_flags; /* flags defined for file */ 258 u_long va_flags; /* flags defined for file */
255 dev_t va_rdev; /* device the special file represents */ 259 dev_t va_rdev; /* device the special file represents */
256 u_quad_t va_bytes; /* bytes of disk space held by file */ 260 u_quad_t va_bytes; /* bytes of disk space held by file */
257 u_quad_t va_filerev; /* file modification number */ 261 u_quad_t va_filerev; /* file modification number */
258 u_int va_vaflags; /* operations flags, see below */ 262 u_int va_vaflags; /* operations flags, see below */
259 long va_spare; /* remain quad aligned */ 263 long va_spare; /* remain quad aligned */
260}; 264};
261 265
262/* 266/*
263 * Flags for va_vaflags. 267 * Flags for va_vaflags.
264 */ 268 */
265#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ 269#define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */
266#define VA_EXCLUSIVE 0x02 /* exclusive create request */ 270#define VA_EXCLUSIVE 0x02 /* exclusive create request */
267 271
268#ifdef _KERNEL 272#ifdef _KERNEL
269 273
270/* 274/*
271 * Flags for ioflag. 275 * Flags for ioflag.
272 */ 276 */
273#define IO_UNIT 0x00010 /* do I/O as atomic unit */ 277#define IO_UNIT 0x00010 /* do I/O as atomic unit */
274#define IO_APPEND 0x00020 /* append write to end */ 278#define IO_APPEND 0x00020 /* append write to end */
275#define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */ 279#define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */
276#define IO_NODELOCKED 0x00080 /* underlying node already locked */ 280#define IO_NODELOCKED 0x00080 /* underlying node already locked */
277#define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */ 281#define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */
278#define IO_DSYNC 0x00200 /* sync I/O data integrity completion */ 282#define IO_DSYNC 0x00200 /* sync I/O data integrity completion */
279#define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */ 283#define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */
280#define IO_NORMAL 0x00800 /* operate on regular data */ 284#define IO_NORMAL 0x00800 /* operate on regular data */
281#define IO_EXT 0x01000 /* operate on extended attributes */ 285#define IO_EXT 0x01000 /* operate on extended attributes */
282#define IO_DIRECT 0x02000 /* direct I/O hint */ 286#define IO_DIRECT 0x02000 /* direct I/O hint */
283#define IO_JOURNALLOCKED 0x04000 /* journal is already locked */ 287#define IO_JOURNALLOCKED 0x04000 /* journal is already locked */
284#define IO_ADV_MASK 0x00003 /* access pattern hint */ 288#define IO_ADV_MASK 0x00003 /* access pattern hint */
285 289
286#define IO_ADV_SHIFT 0 290#define IO_ADV_SHIFT 0
287#define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK) 291#define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK)
288#define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT) 292#define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT)
289 293
290/* 294/*
291 * Modes. 295 * Modes.
292 */ 296 */
293#define VREAD 00004 /* read, write, execute permissions */ 297#define VREAD 00004 /* read, write, execute permissions */
294#define VWRITE 00002 298#define VWRITE 00002
295#define VEXEC 00001 299#define VEXEC 00001
296 300
297/* 301/*
298 * Token indicating no attribute value yet assigned. 302 * Token indicating no attribute value yet assigned.
299 */ 303 */
300#define VNOVAL (-1) 304#define VNOVAL (-1)
301 305
302/* 306/*
303 * Convert between vnode types and inode formats (since POSIX.1 307 * Convert between vnode types and inode formats (since POSIX.1
304 * defines mode word of stat structure in terms of inode formats). 308 * defines mode word of stat structure in terms of inode formats).
305 */ 309 */
306extern const enum vtype iftovt_tab[]; 310extern const enum vtype iftovt_tab[];
307extern const int vttoif_tab[]; 311extern const int vttoif_tab[];
308#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) 312#define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12])
309#define VTTOIF(indx) (vttoif_tab[(int)(indx)]) 313#define VTTOIF(indx) (vttoif_tab[(int)(indx)])
310#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) 314#define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode))
311 315
312/* 316/*
313 * Flags to various vnode functions. 317 * Flags to various vnode functions.
314 */ 318 */
315#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */ 319#define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */
316#define FORCECLOSE 0x0002 /* vflush: force file closeure */ 320#define FORCECLOSE 0x0002 /* vflush: force file closeure */
317#define WRITECLOSE 0x0004 /* vflush: only close writable files */ 321#define WRITECLOSE 0x0004 /* vflush: only close writable files */
318#define V_SAVE 0x0001 /* vinvalbuf: sync file first */ 322#define V_SAVE 0x0001 /* vinvalbuf: sync file first */
319 323
320/* 324/*
321 * Flags to various vnode operations. 325 * Flags to various vnode operations.
322 */ 326 */
323#define REVOKEALL 0x0001 /* revoke: revoke all aliases */ 327#define REVOKEALL 0x0001 /* revoke: revoke all aliases */
324 328
325#define FSYNC_WAIT 0x0001 /* fsync: wait for completion */ 329#define FSYNC_WAIT 0x0001 /* fsync: wait for completion */
326#define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */ 330#define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */
327#define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */ 331#define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */
328#define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */ 332#define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */
329#define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */ 333#define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */
330#define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */ 334#define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */
331 335
332#define UPDATE_WAIT 0x0001 /* update: wait for completion */ 336#define UPDATE_WAIT 0x0001 /* update: wait for completion */
333#define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */ 337#define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */
334#define UPDATE_CLOSE 0x0004 /* update: clean up on close */ 338#define UPDATE_CLOSE 0x0004 /* update: clean up on close */
335 339
336#define VDEAD_NOWAIT 0x0001 /* vdead_check: do not sleep */ 340#define VDEAD_NOWAIT 0x0001 /* vdead_check: do not sleep */
337 341
338void holdrelel(struct vnode *); 342void holdrelel(struct vnode *);
339void vholdl(struct vnode *); 343void vholdl(struct vnode *);
340void vref(struct vnode *); 344void vref(struct vnode *);
341 345
342static __inline void holdrele(struct vnode *) __unused; 346static __inline void holdrele(struct vnode *) __unused;
343static __inline void vhold(struct vnode *) __unused; 347static __inline void vhold(struct vnode *) __unused;
344 348
345/* 349/*
346 * decrease buf or page ref 350 * decrease buf or page ref
347 */ 351 */
348static __inline void 352static __inline void
349holdrele(struct vnode *vp) 353holdrele(struct vnode *vp)
350{ 354{
351 355
352 mutex_enter(vp->v_interlock); 356 mutex_enter(vp->v_interlock);
353 holdrelel(vp); 357 holdrelel(vp);
354 mutex_exit(vp->v_interlock); 358 mutex_exit(vp->v_interlock);
355} 359}
356 360
357/* 361/*
358 * increase buf or page ref 362 * increase buf or page ref
359 */ 363 */
360static __inline void 364static __inline void
361vhold(struct vnode *vp) 365vhold(struct vnode *vp)
362{ 366{
363 367
364 mutex_enter(vp->v_interlock); 368 mutex_enter(vp->v_interlock);
365 vholdl(vp); 369 vholdl(vp);
366 mutex_exit(vp->v_interlock); 370 mutex_exit(vp->v_interlock);
367} 371}
368 372
369#define NULLVP ((struct vnode *)NULL) 373#define NULLVP ((struct vnode *)NULL)
370 374
371static __inline void 375static __inline void
372VN_KNOTE(struct vnode *vp, long hint) 376VN_KNOTE(struct vnode *vp, long hint)
373{ 377{
374 378
375 mutex_enter(vp->v_interlock); 379 mutex_enter(vp->v_interlock);
376 KNOTE(&vp->v_klist, hint); 380 KNOTE(&vp->v_klist, hint);
377 mutex_exit(vp->v_interlock); 381 mutex_exit(vp->v_interlock);
378} 382}
379 383
380/* 384/*
381 * Global vnode data. 385 * Global vnode data.
382 */ 386 */
383extern struct vnode *rootvnode; /* root (i.e. "/") vnode */ 387extern struct vnode *rootvnode; /* root (i.e. "/") vnode */
384extern int desiredvnodes; /* number of vnodes desired */ 388extern int desiredvnodes; /* number of vnodes desired */
385extern u_int numvnodes; /* current number of vnodes */ 389extern u_int numvnodes; /* current number of vnodes */
386 390
387#endif /* _KERNEL */ 391#endif /* _KERNEL */
388 392
389 393
390/* 394/*
391 * Mods for exensibility. 395 * Mods for exensibility.
392 */ 396 */
393 397
394/* 398/*
395 * Flags for vdesc_flags: 399 * Flags for vdesc_flags:
396 */ 400 */
397#define VDESC_MAX_VPS 8 401#define VDESC_MAX_VPS 8
398/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */ 402/* Low order 16 flag bits are reserved for willrele flags for vp arguments. */
399#define VDESC_VP0_WILLRELE 0x00000001 403#define VDESC_VP0_WILLRELE 0x00000001
400#define VDESC_VP1_WILLRELE 0x00000002 404#define VDESC_VP1_WILLRELE 0x00000002
401#define VDESC_VP2_WILLRELE 0x00000004 405#define VDESC_VP2_WILLRELE 0x00000004
402#define VDESC_VP3_WILLRELE 0x00000008 406#define VDESC_VP3_WILLRELE 0x00000008
403#define VDESC_VP0_WILLUNLOCK 0x00000100 407#define VDESC_VP0_WILLUNLOCK 0x00000100
404#define VDESC_VP1_WILLUNLOCK 0x00000200 408#define VDESC_VP1_WILLUNLOCK 0x00000200
405#define VDESC_VP2_WILLUNLOCK 0x00000400 409#define VDESC_VP2_WILLUNLOCK 0x00000400
406#define VDESC_VP3_WILLUNLOCK 0x00000800 410#define VDESC_VP3_WILLUNLOCK 0x00000800
407#define VDESC_VP0_WILLPUT 0x00000101 411#define VDESC_VP0_WILLPUT 0x00000101
408#define VDESC_VP1_WILLPUT 0x00000202 412#define VDESC_VP1_WILLPUT 0x00000202
409#define VDESC_VP2_WILLPUT 0x00000404 413#define VDESC_VP2_WILLPUT 0x00000404
410#define VDESC_VP3_WILLPUT 0x00000808 414#define VDESC_VP3_WILLPUT 0x00000808
411 415
412/* 416/*
413 * VDESC_NO_OFFSET is used to identify the end of the offset list 417 * VDESC_NO_OFFSET is used to identify the end of the offset list
414 * and in places where no such field exists. 418 * and in places where no such field exists.
415 */ 419 */
416#define VDESC_NO_OFFSET -1 420#define VDESC_NO_OFFSET -1
417 421
418/* 422/*
419 * This structure describes the vnode operation taking place. 423 * This structure describes the vnode operation taking place.
420 */ 424 */
421struct vnodeop_desc { 425struct vnodeop_desc {
422 int vdesc_offset; /* offset in vector--first for speed */ 426 int vdesc_offset; /* offset in vector--first for speed */
423 const char *vdesc_name; /* a readable name for debugging */ 427 const char *vdesc_name; /* a readable name for debugging */
424 int vdesc_flags; /* VDESC_* flags */ 428 int vdesc_flags; /* VDESC_* flags */
425 429
426 /* 430 /*
427 * These ops are used by bypass routines to map and locate arguments. 431 * These ops are used by bypass routines to map and locate arguments.
428 * Creds and procs are not needed in bypass routines, but sometimes 432 * Creds and procs are not needed in bypass routines, but sometimes
429 * they are useful to (for example) transport layers. 433 * they are useful to (for example) transport layers.
430 * Nameidata is useful because it has a cred in it. 434 * Nameidata is useful because it has a cred in it.
431 */ 435 */
432 const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ 436 const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */
433 int vdesc_vpp_offset; /* return vpp location */ 437 int vdesc_vpp_offset; /* return vpp location */
434 int vdesc_cred_offset; /* cred location, if any */ 438 int vdesc_cred_offset; /* cred location, if any */
435 int vdesc_componentname_offset; /* if any */ 439 int vdesc_componentname_offset; /* if any */
436}; 440};
437 441
438#ifdef _KERNEL 442#ifdef _KERNEL
439 443
440/* 444/*
441 * Interlock for scanning list of vnodes attached to a mountpoint 445 * Interlock for scanning list of vnodes attached to a mountpoint
442 */ 446 */
443extern kmutex_t mntvnode_lock; 447extern kmutex_t mntvnode_lock;
444 448
445/* 449/*
446 * Union filesystem hook for vn_readdir(). 450 * Union filesystem hook for vn_readdir().
447 */ 451 */
448extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *); 452extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *);
449 453
450/* 454/*
451 * Macros for offsets in the vdesc struct. 455 * Macros for offsets in the vdesc struct.
452 */ 456 */
453#define VOPARG_OFFSETOF(type, member) offsetof(type, member) 457#define VOPARG_OFFSETOF(type, member) offsetof(type, member)
454#define VOPARG_OFFSETTO(type,offset,sp) ((type)(((char *)(sp)) + (offset))) 458#define VOPARG_OFFSETTO(type,offset,sp) ((type)(((char *)(sp)) + (offset)))
455 459
456/* 460/*
457 * This structure is used to configure the new vnodeops vector. 461 * This structure is used to configure the new vnodeops vector.
458 */ 462 */
459struct vnodeopv_entry_desc { 463struct vnodeopv_entry_desc {
460 const struct vnodeop_desc *opve_op; /* which operation this is */ 464 const struct vnodeop_desc *opve_op; /* which operation this is */
461 int (*opve_impl)(void *); /* code implementing this operation */ 465 int (*opve_impl)(void *); /* code implementing this operation */
462}; 466};
463 467
464struct vnodeopv_desc { 468struct vnodeopv_desc {
465 /* ptr to the ptr to the vector where op should go */ 469 /* ptr to the ptr to the vector where op should go */
466 int (***opv_desc_vector_p)(void *); 470 int (***opv_desc_vector_p)(void *);
467 const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */ 471 const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */
468}; 472};
469 473
470/* 474/*
471 * A default routine which just returns an error. 475 * A default routine which just returns an error.
472 */ 476 */
473int vn_default_error(void *); 477int vn_default_error(void *);
474 478
475/* 479/*
476 * A generic structure. 480 * A generic structure.
477 * This can be used by bypass routines to identify generic arguments. 481 * This can be used by bypass routines to identify generic arguments.
478 */ 482 */
479struct vop_generic_args { 483struct vop_generic_args {
480 struct vnodeop_desc *a_desc; 484 struct vnodeop_desc *a_desc;
481 /* other random data follows, presumably */ 485 /* other random data follows, presumably */
482}; 486};
483 487
484/* 488/*
485 * VOCALL calls an op given an ops vector. We break it out because BSD's 489 * VOCALL calls an op given an ops vector. We break it out because BSD's
486 * vclean changes the ops vector and then wants to call ops with the old 490 * vclean changes the ops vector and then wants to call ops with the old
487 * vector. 491 * vector.
488 */ 492 */
489/* 493/*
490 * actually, vclean doesn't use it anymore, but nfs does, 494 * actually, vclean doesn't use it anymore, but nfs does,
491 * for device specials and fifos. 495 * for device specials and fifos.
492 */ 496 */
493#define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP)) 497#define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP))
494 498
495/* 499/*
496 * This call works for vnodes in the kernel. 500 * This call works for vnodes in the kernel.
497 */ 501 */
498#define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP)) 502#define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP))
499#define VDESC(OP) (& __CONCAT(OP,_desc)) 503#define VDESC(OP) (& __CONCAT(OP,_desc))
500#define VOFFSET(OP) (VDESC(OP)->vdesc_offset) 504#define VOFFSET(OP) (VDESC(OP)->vdesc_offset)
501 505
502/* XXX This include should go away */ 506/* XXX This include should go away */
503#include <sys/mount.h> 507#include <sys/mount.h>
504 508
505/* 509/*
506 * Finally, include the default set of vnode operations. 510 * Finally, include the default set of vnode operations.
507 */ 511 */
508#include <sys/vnode_if.h> 512#include <sys/vnode_if.h>
509 513
510/* 514/*
511 * Public vnode manipulation functions. 515 * Public vnode manipulation functions.
512 */ 516 */
513struct file; 517struct file;
514struct filedesc; 518struct filedesc;
515struct nameidata; 519struct nameidata;
516struct proc; 520struct proc;
517struct stat; 521struct stat;
518struct uio; 522struct uio;
519struct vattr; 523struct vattr;
520struct vnode; 524struct vnode;
521 525
522/* see vnode(9) */ 526/* see vnode(9) */
523void vfs_vnode_sysinit(void); 527void vfs_vnode_sysinit(void);
524int bdevvp(dev_t, struct vnode **); 528int bdevvp(dev_t, struct vnode **);
525int cdevvp(dev_t, struct vnode **); 529int cdevvp(dev_t, struct vnode **);
526int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t); 530int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t);
527void vattr_null(struct vattr *); 531void vattr_null(struct vattr *);
528void vdevgone(int, int, int, enum vtype); 532void vdevgone(int, int, int, enum vtype);
529int vfinddev(dev_t, enum vtype, struct vnode **); 533int vfinddev(dev_t, enum vtype, struct vnode **);
530int vflush(struct mount *, struct vnode *, int); 534int vflush(struct mount *, struct vnode *, int);
531int vflushbuf(struct vnode *, int); 535int vflushbuf(struct vnode *, int);
532int vget(struct vnode *, int, bool); 536int vget(struct vnode *, int, bool);
533void vgone(struct vnode *); 537void vgone(struct vnode *);
534int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int); 538int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int);
535void vprint(const char *, struct vnode *); 539void vprint(const char *, struct vnode *);
536void vput(struct vnode *); 540void vput(struct vnode *);
537bool vrecycle(struct vnode *); 541bool vrecycle(struct vnode *);
538void vrele(struct vnode *); 542void vrele(struct vnode *);
539void vrele_async(struct vnode *); 543void vrele_async(struct vnode *);
540void vrele_flush(void); 544void vrele_flush(void);
541int vtruncbuf(struct vnode *, daddr_t, bool, int); 545int vtruncbuf(struct vnode *, daddr_t, bool, int);
542void vwakeup(struct buf *); 546void vwakeup(struct buf *);
543int vdead_check(struct vnode *, int); 547int vdead_check(struct vnode *, int);
544void vrevoke(struct vnode *); 548void vrevoke(struct vnode *);
545struct vnode * 549struct vnode *
546 vnalloc(struct mount *); 550 vnalloc(struct mount *);
547void vnfree(struct vnode *); 551void vnfree(struct vnode *);
548void vremfree(struct vnode *); 552void vremfree(struct vnode *);
549int vcache_get(struct mount *, const void *, size_t, struct vnode **); 553int vcache_get(struct mount *, const void *, size_t, struct vnode **);
550int vcache_new(struct mount *, struct vnode *, 554int vcache_new(struct mount *, struct vnode *,
551 struct vattr *, kauth_cred_t, struct vnode **); 555 struct vattr *, kauth_cred_t, struct vnode **);
552int vcache_rekey_enter(struct mount *, struct vnode *, 556int vcache_rekey_enter(struct mount *, struct vnode *,
553 const void *, size_t, const void *, size_t); 557 const void *, size_t, const void *, size_t);
554void vcache_rekey_exit(struct mount *, struct vnode *, 558void vcache_rekey_exit(struct mount *, struct vnode *,
555 const void *, size_t, const void *, size_t); 559 const void *, size_t, const void *, size_t);
556void vcache_remove(struct mount *, const void *, size_t); 560void vcache_remove(struct mount *, const void *, size_t);
557 561
558/* see vnsubr(9) */ 562/* see vnsubr(9) */
559int vn_bwrite(void *); 563int vn_bwrite(void *);
560int vn_close(struct vnode *, int, kauth_cred_t); 564int vn_close(struct vnode *, int, kauth_cred_t);
561int vn_isunder(struct vnode *, struct vnode *, struct lwp *); 565int vn_isunder(struct vnode *, struct vnode *, struct lwp *);
562int vn_lock(struct vnode *, int); 566int vn_lock(struct vnode *, int);
563void vn_markexec(struct vnode *); 567void vn_markexec(struct vnode *);
564int vn_marktext(struct vnode *); 568int vn_marktext(struct vnode *);
565int vn_open(struct nameidata *, int, int); 569int vn_open(struct nameidata *, int, int);
566int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg, 570int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg,
567 int, kauth_cred_t, size_t *, struct lwp *); 571 int, kauth_cred_t, size_t *, struct lwp *);
568int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *, 572int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *,
569 off_t **, int *); 573 off_t **, int *);
570int vn_stat(struct vnode *, struct stat *); 574int vn_stat(struct vnode *, struct stat *);
571int vn_kqfilter(struct file *, struct knote *); 575int vn_kqfilter(struct file *, struct knote *);
572int vn_writechk(struct vnode *); 576int vn_writechk(struct vnode *);
573int vn_openchk(struct vnode *, kauth_cred_t, int); 577int vn_openchk(struct vnode *, kauth_cred_t, int);
574int vn_extattr_get(struct vnode *, int, int, const char *, size_t *, 578int vn_extattr_get(struct vnode *, int, int, const char *, size_t *,
575 void *, struct lwp *); 579 void *, struct lwp *);
576int vn_extattr_set(struct vnode *, int, int, const char *, size_t, 580int vn_extattr_set(struct vnode *, int, int, const char *, size_t,
577 const void *, struct lwp *); 581 const void *, struct lwp *);
578int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *); 582int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *);
579void vn_ra_allocctx(struct vnode *); 583void vn_ra_allocctx(struct vnode *);
580int vn_fifo_bypass(void *); 584int vn_fifo_bypass(void *);
581 585
582/* initialise global vnode management */ 586/* initialise global vnode management */
583void vntblinit(void); 587void vntblinit(void);
584 588
585/* misc stuff */ 589/* misc stuff */
586void sched_sync(void *); 590void sched_sync(void *);
587void vn_syncer_add_to_worklist(struct vnode *, int); 591void vn_syncer_add_to_worklist(struct vnode *, int);
588void vn_syncer_remove_from_worklist(struct vnode *); 592void vn_syncer_remove_from_worklist(struct vnode *);
589int dorevoke(struct vnode *, kauth_cred_t); 593int dorevoke(struct vnode *, kauth_cred_t);
590int rawdev_mounted(struct vnode *, struct vnode **); 594int rawdev_mounted(struct vnode *, struct vnode **);
591uint8_t vtype2dt(enum vtype); 595uint8_t vtype2dt(enum vtype);
592 596
593/* see vfssubr(9) */ 597/* see vfssubr(9) */
594void vfs_getnewfsid(struct mount *); 598void vfs_getnewfsid(struct mount *);
595int vfs_drainvnodes(long); 599int vfs_drainvnodes(long);
596void vfs_timestamp(struct timespec *); 600void vfs_timestamp(struct timespec *);
597#if defined(DDB) || defined(DEBUGPRINT) 601#if defined(DDB) || defined(DEBUGPRINT)
598void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...) 602void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...)
599 __printflike(1, 2)); 603 __printflike(1, 2));
600void vfs_mount_print(struct mount *, int, void (*)(const char *, ...) 604void vfs_mount_print(struct mount *, int, void (*)(const char *, ...)
601 __printflike(1, 2)); 605 __printflike(1, 2));
602#endif /* DDB */ 606#endif /* DDB */
603 607
604#endif /* _KERNEL */ 608#endif /* _KERNEL */
605 609
606#endif /* !_SYS_VNODE_H_ */ 610#endif /* !_SYS_VNODE_H_ */

cvs diff -r1.16 -r1.17 src/sys/sys/wapbl.h (switch to unified diff)

--- src/sys/sys/wapbl.h 2014/09/05 05:42:50 1.16
+++ src/sys/sys/wapbl.h 2016/01/23 16:02:09 1.17
@@ -1,268 +1,270 @@ @@ -1,268 +1,270 @@
1/* $NetBSD: wapbl.h,v 1.16 2014/09/05 05:42:50 matt Exp $ */ 1/* $NetBSD: wapbl.h,v 1.17 2016/01/23 16:02:09 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2003,2008 The NetBSD Foundation, Inc. 4 * Copyright (c) 2003,2008 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Wasabi Systems, Inc. 8 * by Wasabi Systems, Inc.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright 15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the 16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution. 17 * documentation and/or other materials provided with the distribution.
18 * 18 *
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#ifndef _SYS_WAPBL_H 32#ifndef _SYS_WAPBL_H
33#define _SYS_WAPBL_H 33#define _SYS_WAPBL_H
34 34
35#include <sys/mutex.h> 35#include <sys/mutex.h>
36 36
 37#if defined(_KERNEL) || defined(_KMEMUSER)
37#include <miscfs/specfs/specdev.h> 38#include <miscfs/specfs/specdev.h>
 39#endif
38 40
39/* This header file describes the api and data structures for 41/* This header file describes the api and data structures for
40 * write ahead physical block logging (WAPBL) support. 42 * write ahead physical block logging (WAPBL) support.
41 */ 43 */
42 44
43#if defined(_KERNEL_OPT) 45#if defined(_KERNEL_OPT)
44#include "opt_wapbl.h" 46#include "opt_wapbl.h"
45#endif 47#endif
46 48
47#ifdef WAPBL_DEBUG 49#ifdef WAPBL_DEBUG
48#ifndef WAPBL_DEBUG_PRINT 50#ifndef WAPBL_DEBUG_PRINT
49#define WAPBL_DEBUG_PRINT (WAPBL_PRINT_REPLAY | WAPBL_PRINT_OPEN) 51#define WAPBL_DEBUG_PRINT (WAPBL_PRINT_REPLAY | WAPBL_PRINT_OPEN)
50#endif 52#endif
51 53
52#if 0 54#if 0
53#define WAPBL_DEBUG_BUFBYTES 55#define WAPBL_DEBUG_BUFBYTES
54#endif 56#endif
55 57
56#endif 58#endif
57 59
58#ifdef WAPBL_DEBUG_PRINT 60#ifdef WAPBL_DEBUG_PRINT
59 61
60enum { 62enum {
61 WAPBL_PRINT_OPEN = 0x1, 63 WAPBL_PRINT_OPEN = 0x1,
62 WAPBL_PRINT_FLUSH = 0x2, 64 WAPBL_PRINT_FLUSH = 0x2,
63 WAPBL_PRINT_TRUNCATE = 0x4, 65 WAPBL_PRINT_TRUNCATE = 0x4,
64 WAPBL_PRINT_TRANSACTION = 0x8, 66 WAPBL_PRINT_TRANSACTION = 0x8,
65 WAPBL_PRINT_BUFFER = 0x10, 67 WAPBL_PRINT_BUFFER = 0x10,
66 WAPBL_PRINT_BUFFER2 = 0x20, 68 WAPBL_PRINT_BUFFER2 = 0x20,
67 WAPBL_PRINT_ALLOC = 0x40, 69 WAPBL_PRINT_ALLOC = 0x40,
68 WAPBL_PRINT_INODE = 0x80, 70 WAPBL_PRINT_INODE = 0x80,
69 WAPBL_PRINT_WRITE = 0x100, 71 WAPBL_PRINT_WRITE = 0x100,
70 WAPBL_PRINT_IO = 0x200, 72 WAPBL_PRINT_IO = 0x200,
71 WAPBL_PRINT_REPLAY = 0x400, 73 WAPBL_PRINT_REPLAY = 0x400,
72 WAPBL_PRINT_ERROR = 0x800, 74 WAPBL_PRINT_ERROR = 0x800,
73 WAPBL_PRINT_DISCARD = 0x1000, 75 WAPBL_PRINT_DISCARD = 0x1000,
74 WAPBL_PRINT_BIODONE = 0x2000, 76 WAPBL_PRINT_BIODONE = 0x2000,
75}; 77};
76 78
77#define WAPBL_PRINTF(mask, a) if (wapbl_debug_print & (mask)) printf a 79#define WAPBL_PRINTF(mask, a) if (wapbl_debug_print & (mask)) printf a
78extern int wapbl_debug_print; 80extern int wapbl_debug_print;
79#else 81#else
80#define WAPBL_PRINTF(mask, a) 82#define WAPBL_PRINTF(mask, a)
81#endif 83#endif
82 84
83/****************************************************************/ 85/****************************************************************/
84 86
85#include <sys/queue.h> 87#include <sys/queue.h>
86#include <sys/vnode.h> 88#include <sys/vnode.h>
87#include <sys/buf.h> 89#include <sys/buf.h>
88 90
89#ifdef _KERNEL 91#ifdef _KERNEL
90 92
91struct wapbl_entry; 93struct wapbl_entry;
92struct wapbl_replay; 94struct wapbl_replay;
93struct wapbl; 95struct wapbl;
94 96
95typedef void (*wapbl_flush_fn_t)(struct mount *, daddr_t *, int *, int); 97typedef void (*wapbl_flush_fn_t)(struct mount *, daddr_t *, int *, int);
96 98
97/* 99/*
98 * This structure holds per transaction log information 100 * This structure holds per transaction log information
99 */ 101 */
100struct wapbl_entry { 102struct wapbl_entry {
101 struct wapbl *we_wapbl; 103 struct wapbl *we_wapbl;
102 SIMPLEQ_ENTRY(wapbl_entry) we_entries; 104 SIMPLEQ_ENTRY(wapbl_entry) we_entries;
103 size_t we_bufcount; /* Count of unsynced buffers */ 105 size_t we_bufcount; /* Count of unsynced buffers */
104 size_t we_reclaimable_bytes; /* Number on disk bytes for this 106 size_t we_reclaimable_bytes; /* Number on disk bytes for this
105 transaction */ 107 transaction */
106 int we_error; 108 int we_error;
107#ifdef WAPBL_DEBUG_BUFBYTES 109#ifdef WAPBL_DEBUG_BUFBYTES
108 size_t we_unsynced_bufbytes; /* Byte count of unsynced buffers */ 110 size_t we_unsynced_bufbytes; /* Byte count of unsynced buffers */
109#endif 111#endif
110}; 112};
111 113
112/* Start using a log */ 114/* Start using a log */
113int wapbl_start(struct wapbl **, struct mount *, struct vnode *, daddr_t, 115int wapbl_start(struct wapbl **, struct mount *, struct vnode *, daddr_t,
114 size_t, size_t, struct wapbl_replay *, 116 size_t, size_t, struct wapbl_replay *,
115 wapbl_flush_fn_t, wapbl_flush_fn_t); 117 wapbl_flush_fn_t, wapbl_flush_fn_t);
116 118
117/* Discard the current transaction, potentially dangerous */ 119/* Discard the current transaction, potentially dangerous */
118void wapbl_discard(struct wapbl *); 120void wapbl_discard(struct wapbl *);
119 121
120/* stop using a log */ 122/* stop using a log */
121int wapbl_stop(struct wapbl *, int); 123int wapbl_stop(struct wapbl *, int);
122 124
123/* 125/*
124 * Begin a new transaction or increment transaction recursion 126 * Begin a new transaction or increment transaction recursion
125 * level if called while a transaction is already in progress 127 * level if called while a transaction is already in progress
126 * by the current process. 128 * by the current process.
127 */ 129 */
128int wapbl_begin(struct wapbl *, const char *, int); 130int wapbl_begin(struct wapbl *, const char *, int);
129 131
130 132
131/* End a transaction or decrement the transaction recursion level */ 133/* End a transaction or decrement the transaction recursion level */
132void wapbl_end(struct wapbl *); 134void wapbl_end(struct wapbl *);
133 135
134/* 136/*
135 * Add a new buffer to the current transaction. The buffers 137 * Add a new buffer to the current transaction. The buffers
136 * data will be copied to the current transaction log and the 138 * data will be copied to the current transaction log and the
137 * buffer will be marked B_LOCKED so that it will not be 139 * buffer will be marked B_LOCKED so that it will not be
138 * flushed to disk by the syncer or reallocated. 140 * flushed to disk by the syncer or reallocated.
139 */ 141 */
140void wapbl_add_buf(struct wapbl *, struct buf *); 142void wapbl_add_buf(struct wapbl *, struct buf *);
141 143
142/* Remove a buffer from the current transaction. */ 144/* Remove a buffer from the current transaction. */
143void wapbl_remove_buf(struct wapbl *, struct buf *); 145void wapbl_remove_buf(struct wapbl *, struct buf *);
144 146
145void wapbl_resize_buf(struct wapbl *, struct buf *, long, long); 147void wapbl_resize_buf(struct wapbl *, struct buf *, long, long);
146 148
147/* 149/*
148 * This will flush all completed transactions to disk and 150 * This will flush all completed transactions to disk and
149 * start asynchronous writes on the associated buffers 151 * start asynchronous writes on the associated buffers
150 */ 152 */
151int wapbl_flush(struct wapbl *, int); 153int wapbl_flush(struct wapbl *, int);
152 154
153/* 155/*
154 * Inodes that are allocated but have zero link count 156 * Inodes that are allocated but have zero link count
155 * must be registered with the current transaction 157 * must be registered with the current transaction
156 * so they may be recorded in the log and cleaned up later. 158 * so they may be recorded in the log and cleaned up later.
157 * registration/unregistration of ino numbers already registered is ok. 159 * registration/unregistration of ino numbers already registered is ok.
158 */ 160 */
159void wapbl_register_inode(struct wapbl *, ino_t, mode_t); 161void wapbl_register_inode(struct wapbl *, ino_t, mode_t);
160void wapbl_unregister_inode(struct wapbl *, ino_t, mode_t); 162void wapbl_unregister_inode(struct wapbl *, ino_t, mode_t);
161 163
162/* 164/*
163 * Metadata block deallocations must be registered so 165 * Metadata block deallocations must be registered so
164 * that revocations records can be written and to prevent 166 * that revocations records can be written and to prevent
165 * the corresponding blocks from being reused as data 167 * the corresponding blocks from being reused as data
166 * blocks until the log is on disk. 168 * blocks until the log is on disk.
167 */ 169 */
168void wapbl_register_deallocation(struct wapbl *, daddr_t, int); 170void wapbl_register_deallocation(struct wapbl *, daddr_t, int);
169 171
170void wapbl_jlock_assert(struct wapbl *wl); 172void wapbl_jlock_assert(struct wapbl *wl);
171void wapbl_junlock_assert(struct wapbl *wl); 173void wapbl_junlock_assert(struct wapbl *wl);
172 174
173void wapbl_print(struct wapbl *wl, int full, void (*pr)(const char *, ...) 175void wapbl_print(struct wapbl *wl, int full, void (*pr)(const char *, ...)
174 __printflike(1, 2)); 176 __printflike(1, 2));
175 177
176#if defined(WAPBL_DEBUG) || defined(DDB) 178#if defined(WAPBL_DEBUG) || defined(DDB)
177void wapbl_dump(struct wapbl *); 179void wapbl_dump(struct wapbl *);
178#endif 180#endif
179 181
180void wapbl_biodone(struct buf *); 182void wapbl_biodone(struct buf *);
181 183
182extern struct wapbl_ops wapbl_ops; 184extern struct wapbl_ops wapbl_ops;
183 185
184static __inline struct mount * 186static __inline struct mount *
185wapbl_vptomp(struct vnode *vp) 187wapbl_vptomp(struct vnode *vp)
186{ 188{
187 struct mount *mp; 189 struct mount *mp;
188 190
189 mp = NULL; 191 mp = NULL;
190 if (vp != NULL) { 192 if (vp != NULL) {
191 if (vp->v_type == VBLK) 193 if (vp->v_type == VBLK)
192 mp = spec_node_getmountedfs(vp); 194 mp = spec_node_getmountedfs(vp);
193 else 195 else
194 mp = vp->v_mount; 196 mp = vp->v_mount;
195 } 197 }
196 198
197 return mp; 199 return mp;
198} 200}
199 201
200static __inline bool 202static __inline bool
201wapbl_vphaswapbl(struct vnode *vp) 203wapbl_vphaswapbl(struct vnode *vp)
202{ 204{
203 struct mount *mp; 205 struct mount *mp;
204 206
205 if (vp == NULL) 207 if (vp == NULL)
206 return false; 208 return false;
207 209
208 mp = wapbl_vptomp(vp); 210 mp = wapbl_vptomp(vp);
209 return mp && mp->mnt_wapbl; 211 return mp && mp->mnt_wapbl;
210} 212}
211 213
212#endif /* _KERNEL */ 214#endif /* _KERNEL */
213 215
214/****************************************************************/ 216/****************************************************************/
215/* Replay support */ 217/* Replay support */
216 218
217#ifdef WAPBL_INTERNAL 219#ifdef WAPBL_INTERNAL
218LIST_HEAD(wapbl_blk_head, wapbl_blk); 220LIST_HEAD(wapbl_blk_head, wapbl_blk);
219struct wapbl_replay { 221struct wapbl_replay {
220 struct vnode *wr_logvp; 222 struct vnode *wr_logvp;
221 struct vnode *wr_devvp; 223 struct vnode *wr_devvp;
222 daddr_t wr_logpbn; 224 daddr_t wr_logpbn;
223 225
224 int wr_log_dev_bshift; 226 int wr_log_dev_bshift;
225 int wr_fs_dev_bshift; 227 int wr_fs_dev_bshift;
226 int64_t wr_circ_off; 228 int64_t wr_circ_off;
227 int64_t wr_circ_size;  229 int64_t wr_circ_size;
228 uint32_t wr_generation; 230 uint32_t wr_generation;
229 231
230 void *wr_scratch; 232 void *wr_scratch;
231 233
232 struct wapbl_blk_head *wr_blkhash; 234 struct wapbl_blk_head *wr_blkhash;
233 u_long wr_blkhashmask; 235 u_long wr_blkhashmask;
234 int wr_blkhashcnt; 236 int wr_blkhashcnt;
235 237
236 off_t wr_inodeshead; 238 off_t wr_inodeshead;
237 off_t wr_inodestail; 239 off_t wr_inodestail;
238 int wr_inodescnt; 240 int wr_inodescnt;
239 struct { 241 struct {
240 uint32_t wr_inumber; 242 uint32_t wr_inumber;
241 uint32_t wr_imode; 243 uint32_t wr_imode;
242 } *wr_inodes; 244 } *wr_inodes;
243}; 245};
244 246
245#define wapbl_replay_isopen(wr) ((wr)->wr_scratch != 0) 247#define wapbl_replay_isopen(wr) ((wr)->wr_scratch != 0)
246 248
247/* Supply this to provide i/o support */ 249/* Supply this to provide i/o support */
248int wapbl_write(void *, size_t, struct vnode *, daddr_t); 250int wapbl_write(void *, size_t, struct vnode *, daddr_t);
249int wapbl_read(void *, size_t, struct vnode *, daddr_t); 251int wapbl_read(void *, size_t, struct vnode *, daddr_t);
250 252
251/****************************************************************/ 253/****************************************************************/
252#else 254#else
253struct wapbl_replay; 255struct wapbl_replay;
254#endif /* WAPBL_INTERNAL */ 256#endif /* WAPBL_INTERNAL */
255 257
256/****************************************************************/ 258/****************************************************************/
257 259
258int wapbl_replay_start(struct wapbl_replay **, struct vnode *, 260int wapbl_replay_start(struct wapbl_replay **, struct vnode *,
259 daddr_t, size_t, size_t); 261 daddr_t, size_t, size_t);
260void wapbl_replay_stop(struct wapbl_replay *); 262void wapbl_replay_stop(struct wapbl_replay *);
261void wapbl_replay_free(struct wapbl_replay *); 263void wapbl_replay_free(struct wapbl_replay *);
262int wapbl_replay_write(struct wapbl_replay *, struct vnode *); 264int wapbl_replay_write(struct wapbl_replay *, struct vnode *);
263int wapbl_replay_can_read(struct wapbl_replay *, daddr_t, long); 265int wapbl_replay_can_read(struct wapbl_replay *, daddr_t, long);
264int wapbl_replay_read(struct wapbl_replay *, void *, daddr_t, long); 266int wapbl_replay_read(struct wapbl_replay *, void *, daddr_t, long);
265 267
266/****************************************************************/ 268/****************************************************************/
267 269
268#endif /* !_SYS_WAPBL_H */ 270#endif /* !_SYS_WAPBL_H */