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