cnode.h revision 1.1.1.1 1 1.1 rvb /*
2 1.1 rvb
3 1.1 rvb Coda: an Experimental Distributed File System
4 1.1 rvb Release 3.1
5 1.1 rvb
6 1.1 rvb Copyright (c) 1987-1998 Carnegie Mellon University
7 1.1 rvb All Rights Reserved
8 1.1 rvb
9 1.1 rvb Permission to use, copy, modify and distribute this software and its
10 1.1 rvb documentation is hereby granted, provided that both the copyright
11 1.1 rvb notice and this permission notice appear in all copies of the
12 1.1 rvb software, derivative works or modified versions, and any portions
13 1.1 rvb thereof, and that both notices appear in supporting documentation, and
14 1.1 rvb that credit is given to Carnegie Mellon University in all documents
15 1.1 rvb and publicity pertaining to direct or indirect use of this code or its
16 1.1 rvb derivatives.
17 1.1 rvb
18 1.1 rvb CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
19 1.1 rvb SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
20 1.1 rvb FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
21 1.1 rvb DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
22 1.1 rvb RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
23 1.1 rvb ANY DERIVATIVE WORK.
24 1.1 rvb
25 1.1 rvb Carnegie Mellon encourages users of this software to return any
26 1.1 rvb improvements or extensions that they make, and to grant Carnegie
27 1.1 rvb Mellon the rights to redistribute these changes without encumbrance.
28 1.1 rvb */
29 1.1 rvb
30 1.1 rvb /* $Header: /tank/opengrok/rsync2/NetBSD/src/sys/coda/cnode.h,v 1.1.1.1 1998/08/29 21:26:46 rvb Exp $ */
31 1.1 rvb
32 1.1 rvb /*
33 1.1 rvb * Mach Operating System
34 1.1 rvb * Copyright (c) 1990 Carnegie-Mellon University
35 1.1 rvb * Copyright (c) 1989 Carnegie-Mellon University
36 1.1 rvb * All rights reserved. The CMU software License Agreement specifies
37 1.1 rvb * the terms and conditions for use and redistribution.
38 1.1 rvb */
39 1.1 rvb
40 1.1 rvb /*
41 1.1 rvb * This code was written for the Coda file system at Carnegie Mellon University.
42 1.1 rvb * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
43 1.1 rvb */
44 1.1 rvb
45 1.1 rvb /*
46 1.1 rvb * HISTORY
47 1.1 rvb * $Log: cnode.h,v $
48 1.1 rvb * Revision 1.1.1.1 1998/08/29 21:26:46 rvb
49 1.1 rvb * Very Preliminary Coda
50 1.1 rvb *
51 1.1 rvb * Revision 1.10 1998/08/28 18:12:25 rvb
52 1.1 rvb * Now it also works on FreeBSD -current. This code will be
53 1.1 rvb * committed to the FreeBSD -current and NetBSD -current
54 1.1 rvb * trees. It will then be tailored to the particular platform
55 1.1 rvb * by flushing conditional code.
56 1.1 rvb *
57 1.1 rvb * Revision 1.9 1998/08/18 17:05:24 rvb
58 1.1 rvb * Don't use __RCSID now
59 1.1 rvb *
60 1.1 rvb * Revision 1.8 1998/08/18 16:31:49 rvb
61 1.1 rvb * Sync the code for NetBSD -current; test on 1.3 later
62 1.1 rvb *
63 1.1 rvb * Revision 1.7 98/02/24 22:22:53 rvb
64 1.1 rvb * Fixes up mainly to flush iopen and friends
65 1.1 rvb *
66 1.1 rvb * Revision 1.6 98/01/31 20:53:19 rvb
67 1.1 rvb * First version that works on FreeBSD 2.2.5
68 1.1 rvb *
69 1.1 rvb * Revision 1.5 98/01/23 11:53:51 rvb
70 1.1 rvb * Bring RVB_CFS1_1 to HEAD
71 1.1 rvb *
72 1.1 rvb * Revision 1.4.2.5 98/01/23 11:21:14 rvb
73 1.1 rvb * Sync with 2.2.5
74 1.1 rvb *
75 1.1 rvb * Revision 1.4.2.4 98/01/22 13:03:38 rvb
76 1.1 rvb * Had Breaken ls .
77 1.1 rvb *
78 1.1 rvb * Revision 1.4.2.3 97/12/19 14:26:09 rvb
79 1.1 rvb * session id
80 1.1 rvb *
81 1.1 rvb * Revision 1.4.2.2 97/12/16 12:40:24 rvb
82 1.1 rvb * Sync with 1.3
83 1.1 rvb *
84 1.1 rvb * Revision 1.4.2.1 97/12/06 17:41:28 rvb
85 1.1 rvb * Sync with peters coda.h
86 1.1 rvb *
87 1.1 rvb * Revision 1.4 97/12/05 10:39:30 rvb
88 1.1 rvb * Read CHANGES
89 1.1 rvb *
90 1.1 rvb * Revision 1.3.18.2 97/11/12 12:09:45 rvb
91 1.1 rvb * reorg pass1
92 1.1 rvb *
93 1.1 rvb * Revision 1.3.18.1 97/10/29 16:06:31 rvb
94 1.1 rvb * Kill DYING
95 1.1 rvb *
96 1.1 rvb * Revision 1.3 1996/12/12 22:11:03 bnoble
97 1.1 rvb * Fixed the "downcall invokes venus operation" deadlock in all known cases.
98 1.1 rvb * There may be more.
99 1.1 rvb *
100 1.1 rvb * Revision 1.2 1996/01/02 16:57:26 bnoble
101 1.1 rvb * Added support for Coda MiniCache and raw inode calls (final commit)
102 1.1 rvb *
103 1.1 rvb * Revision 1.1.2.1 1995/12/20 01:57:53 bnoble
104 1.1 rvb * Added CFS-specific files
105 1.1 rvb *
106 1.1 rvb * Revision 3.1.1.1 1995/03/04 19:08:23 bnoble
107 1.1 rvb * Branch for NetBSD port revisions
108 1.1 rvb *
109 1.1 rvb * Revision 3.1 1995/03/04 19:08:23 bnoble
110 1.1 rvb * Bump to major revision 3 to prepare for NetBSD port
111 1.1 rvb *
112 1.1 rvb * Revision 2.2 1994/12/06 13:39:18 dcs
113 1.1 rvb * Add a flag value to indicate a cnode was orphaned, e.g. the venus
114 1.1 rvb * that created it has exited. This will allow one to restart venus
115 1.1 rvb * even though some process may be cd'd into /coda.
116 1.1 rvb *
117 1.1 rvb * Revision 2.1 94/07/21 16:25:33 satya
118 1.1 rvb * Conversion to C++ 3.0; start of Coda Release 2.0
119 1.1 rvb *
120 1.1 rvb * Revision 1.2.7.1 94/06/16 11:26:02 raiff
121 1.1 rvb * Branch for release beta-16Jun1994_39118
122 1.1 rvb *
123 1.1 rvb * Revision 1.2 92/10/27 17:58:41 lily
124 1.1 rvb * merge kernel/latest and alpha/src/cfs
125 1.1 rvb *
126 1.1 rvb * Revision 2.3 92/09/30 14:16:53 mja
127 1.1 rvb * Picked up fixed #ifdef _KERNEL. Also...
128 1.1 rvb *
129 1.1 rvb * Substituted rvb's history blurb so that we agree with Mach 2.5 sources.
130 1.1 rvb * [91/02/09 jjk]
131 1.1 rvb *
132 1.1 rvb * Added contributors blurb.
133 1.1 rvb * [90/12/13 jjk]
134 1.1 rvb *
135 1.1 rvb * Revision 2.2 90/07/05 11:27:24 mrt
136 1.1 rvb * Created for the Coda File System.
137 1.1 rvb * [90/05/23 dcs]
138 1.1 rvb *
139 1.1 rvb * Revision 1.4 90/05/31 17:02:16 dcs
140 1.1 rvb * Prepare for merge with facilities kernel.
141 1.1 rvb *
142 1.1 rvb *
143 1.1 rvb *
144 1.1 rvb */
145 1.1 rvb
146 1.1 rvb #ifndef _CNODE_H_
147 1.1 rvb #define _CNODE_H_
148 1.1 rvb
149 1.1 rvb #include <sys/vnode.h>
150 1.1 rvb
151 1.1 rvb #ifdef __FreeBSD__
152 1.1 rvb
153 1.1 rvb /* for the prototype of DELAY() */
154 1.1 rvb #include <machine/clock.h>
155 1.1 rvb
156 1.1 rvb #ifdef __FreeBSD_version
157 1.1 rvb /* You would think that <sys/param.h> or something would include this */
158 1.1 rvb #include <sys/lock.h>
159 1.1 rvb
160 1.1 rvb MALLOC_DECLARE(M_CFS);
161 1.1 rvb
162 1.1 rvb #else
163 1.1 rvb
164 1.1 rvb /* yuck yuck yuck */
165 1.1 rvb #define vref(x) cvref(x)
166 1.1 rvb extern void cvref(struct vnode *vp);
167 1.1 rvb /* yuck yuck yuck */
168 1.1 rvb
169 1.1 rvb #endif
170 1.1 rvb #endif
171 1.1 rvb
172 1.1 rvb #if defined(__NetBSD__) && defined(NetBSD1_3) && (NetBSD1_3 >= 7)
173 1.1 rvb #define NEW_LOCKMGR(l, f, i) lockmgr(l, f, i)
174 1.1 rvb #define VOP_X_LOCK(vn, fl) vn_lock(vn, fl)
175 1.1 rvb #define VOP_X_UNLOCK(vn, fl) VOP_UNLOCK(vn, fl)
176 1.1 rvb
177 1.1 rvb #elif defined(__FreeBSD_version)
178 1.1 rvb #define NEW_LOCKMGR(l, f, i) lockmgr(l, f, i, curproc)
179 1.1 rvb #define VOP_X_LOCK(vn, fl) vn_lock(vn, fl, curproc)
180 1.1 rvb #define VOP_X_UNLOCK(vn, fl) VOP_UNLOCK(vn, fl, curproc)
181 1.1 rvb
182 1.1 rvb /* NetBSD 1.3 & FreeBSD 2.2.x */
183 1.1 rvb #else
184 1.1 rvb #undef NEW_LOCKMGR
185 1.1 rvb #define VOP_X_LOCK(vn, fl) VOP_LOCK(vn)
186 1.1 rvb #define VOP_X_UNLOCK(vn, fl) VOP_UNLOCK(vn)
187 1.1 rvb #endif
188 1.1 rvb
189 1.1 rvb /*
190 1.1 rvb * tmp below since we need struct queue
191 1.1 rvb */
192 1.1 rvb #include <cfs/cfsk.h>
193 1.1 rvb
194 1.1 rvb /*
195 1.1 rvb * Cnode lookup stuff.
196 1.1 rvb * NOTE: CFS_CACHESIZE must be a power of 2 for cfshash to work!
197 1.1 rvb */
198 1.1 rvb #define CFS_CACHESIZE 512
199 1.1 rvb
200 1.1 rvb #define CFS_ALLOC(ptr, cast, size) \
201 1.1 rvb do { \
202 1.1 rvb ptr = (cast)malloc((unsigned long) size, M_CFS, M_WAITOK); \
203 1.1 rvb if (ptr == 0) { \
204 1.1 rvb panic("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
205 1.1 rvb } \
206 1.1 rvb } while (0)
207 1.1 rvb
208 1.1 rvb #define CFS_FREE(ptr, size) free((ptr), M_CFS)
209 1.1 rvb
210 1.1 rvb /*
211 1.1 rvb * global cache state control
212 1.1 rvb */
213 1.1 rvb extern int cfsnc_use;
214 1.1 rvb
215 1.1 rvb /*
216 1.1 rvb * Used to select debugging statements throughout the cfs code.
217 1.1 rvb */
218 1.1 rvb extern int cfsdebug;
219 1.1 rvb extern int cfsnc_debug;
220 1.1 rvb extern int cfs_printf_delay;
221 1.1 rvb extern int cfs_vnop_print_entry;
222 1.1 rvb extern int cfs_psdev_print_entry;
223 1.1 rvb extern int cfs_vfsop_print_entry;
224 1.1 rvb
225 1.1 rvb #define CFSDBGMSK(N) (1 << N)
226 1.1 rvb #define CFSDEBUG(N, STMT) { if (cfsdebug & CFSDBGMSK(N)) { STMT } }
227 1.1 rvb #define myprintf(args) \
228 1.1 rvb do { \
229 1.1 rvb if (cfs_printf_delay) \
230 1.1 rvb DELAY(cfs_printf_delay);\
231 1.1 rvb printf args ; \
232 1.1 rvb } while (0)
233 1.1 rvb
234 1.1 rvb struct cnode {
235 1.1 rvb struct vnode *c_vnode;
236 1.1 rvb u_short c_flags; /* flags (see below) */
237 1.1 rvb ViceFid c_fid; /* file handle */
238 1.1 rvb #ifdef NEW_LOCKMGR
239 1.1 rvb struct lock c_lock; /* new lock protocol */
240 1.1 rvb #endif
241 1.1 rvb struct vnode *c_ovp; /* open vnode pointer */
242 1.1 rvb u_short c_ocount; /* count of openers */
243 1.1 rvb u_short c_owrite; /* count of open for write */
244 1.1 rvb struct vattr c_vattr; /* attributes */
245 1.1 rvb char *c_symlink; /* pointer to symbolic link */
246 1.1 rvb u_short c_symlen; /* length of symbolic link */
247 1.1 rvb dev_t c_device; /* associated vnode device */
248 1.1 rvb ino_t c_inode; /* associated vnode inode */
249 1.1 rvb struct cnode *c_next; /* links if on NetBSD machine */
250 1.1 rvb };
251 1.1 rvb #define VTOC(vp) ((struct cnode *)(vp)->v_data)
252 1.1 rvb #define CTOV(cp) ((struct vnode *)((cp)->c_vnode))
253 1.1 rvb
254 1.1 rvb /* flags */
255 1.1 rvb #define C_VATTR 0x01 /* Validity of vattr in the cnode */
256 1.1 rvb #define C_SYMLINK 0x02 /* Validity of symlink pointer in the Code */
257 1.1 rvb #define C_WANTED 0x08 /* Set if lock wanted */
258 1.1 rvb #define C_LOCKED 0x10 /* Set if lock held */
259 1.1 rvb #define C_UNMOUNTING 0X20 /* Set if unmounting */
260 1.1 rvb #define C_PURGING 0x40 /* Set if purging a fid */
261 1.1 rvb
262 1.1 rvb #define VALID_VATTR(cp) ((cp->c_flags) & C_VATTR)
263 1.1 rvb #define VALID_SYMLINK(cp) ((cp->c_flags) & C_SYMLINK)
264 1.1 rvb #define IS_UNMOUNTING(cp) ((cp)->c_flags & C_UNMOUNTING)
265 1.1 rvb
266 1.1 rvb struct vcomm {
267 1.1 rvb u_long vc_seq;
268 1.1 rvb struct selinfo vc_selproc;
269 1.1 rvb struct queue vc_requests;
270 1.1 rvb struct queue vc_replys;
271 1.1 rvb };
272 1.1 rvb
273 1.1 rvb #define VC_OPEN(vcp) ((vcp)->vc_requests.forw != NULL)
274 1.1 rvb #define MARK_VC_CLOSED(vcp) (vcp)->vc_requests.forw = NULL;
275 1.1 rvb #define MARK_VC_OPEN(vcp) /* MT */
276 1.1 rvb
277 1.1 rvb struct cfs_clstat {
278 1.1 rvb int ncalls; /* client requests */
279 1.1 rvb int nbadcalls; /* upcall failures */
280 1.1 rvb int reqs[CFS_NCALLS]; /* count of each request */
281 1.1 rvb };
282 1.1 rvb extern struct cfs_clstat cfs_clstat;
283 1.1 rvb
284 1.1 rvb /*
285 1.1 rvb * CFS structure to hold mount/file system information
286 1.1 rvb */
287 1.1 rvb struct cfs_mntinfo {
288 1.1 rvb struct vnode *mi_rootvp;
289 1.1 rvb struct mount *mi_vfsp;
290 1.1 rvb struct vcomm mi_vcomm;
291 1.1 rvb };
292 1.1 rvb extern struct cfs_mntinfo cfs_mnttbl[]; /* indexed by minor device number */
293 1.1 rvb
294 1.1 rvb /*
295 1.1 rvb * vfs pointer to mount info
296 1.1 rvb */
297 1.1 rvb #define vftomi(vfsp) ((struct cfs_mntinfo *)(vfsp->mnt_data))
298 1.1 rvb #define CFS_MOUNTED(vfsp) (vftomi((vfsp)) != (struct cfs_mntinfo *)0)
299 1.1 rvb
300 1.1 rvb /*
301 1.1 rvb * vnode pointer to mount info
302 1.1 rvb */
303 1.1 rvb #define vtomi(vp) ((struct cfs_mntinfo *)(vp->v_mount->mnt_data))
304 1.1 rvb
305 1.1 rvb /*
306 1.1 rvb * Used for identifying usage of "Control" object
307 1.1 rvb */
308 1.1 rvb extern struct vnode *cfs_ctlvp;
309 1.1 rvb #define IS_CTL_VP(vp) ((vp) == cfs_ctlvp)
310 1.1 rvb #define IS_CTL_NAME(vp, name, l)((l == CFS_CONTROLLEN) \
311 1.1 rvb && ((vp) == vtomi((vp))->mi_rootvp) \
312 1.1 rvb && strncmp(name, CFS_CONTROL, l) == 0)
313 1.1 rvb
314 1.1 rvb /*
315 1.1 rvb * An enum to tell us whether something that will remove a reference
316 1.1 rvb * to a cnode was a downcall or not
317 1.1 rvb */
318 1.1 rvb enum dc_status {
319 1.1 rvb IS_DOWNCALL = 6,
320 1.1 rvb NOT_DOWNCALL = 7
321 1.1 rvb };
322 1.1 rvb
323 1.1 rvb /* cfs_psdev.h */
324 1.1 rvb int cfscall(struct cfs_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer);
325 1.1 rvb
326 1.1 rvb /* cfs_subr.h */
327 1.1 rvb int handleDownCall(int opcode, union outputArgs *out);
328 1.1 rvb void cfs_unmounting(struct mount *whoIam);
329 1.1 rvb int cfs_vmflush(struct cnode *cp);
330 1.1 rvb
331 1.1 rvb /* cfs_vnodeops.h */
332 1.1 rvb struct cnode *makecfsnode(ViceFid *fid, struct mount *vfsp, short type);
333 1.1 rvb int cfs_vnodeopstats_init(void);
334 1.1 rvb
335 1.1 rvb /* cfs_vfsops.h */
336 1.1 rvb struct mount *devtomp(dev_t dev);
337 1.1 rvb
338 1.1 rvb #if !(defined NetBSD1_3) && !defined(__FreeBSD_version)
339 1.1 rvb #define __RCSID(x) static char *rcsid = x
340 1.1 rvb #endif
341 1.1 rvb
342 1.1 rvb /* sigh */
343 1.1 rvb #define CFS_RDWR ((u_long) 31)
344
345 #endif /* _CNODE_H_ */
346
347