cnode.h revision 1.2 1 1.2 rvb /* $NetBSD: cnode.h,v 1.2 1998/09/08 17:12:49 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.2 rvb * @(#) cfs/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.2 rvb * Revision 1.2 1998/09/08 17:12:49 rvb
51 1.2 rvb * Pass2 complete
52 1.2 rvb *
53 1.1 rvb * Revision 1.1.1.1 1998/08/29 21:26:46 rvb
54 1.1 rvb * Very Preliminary Coda
55 1.1 rvb *
56 1.1 rvb * Revision 1.10 1998/08/28 18:12:25 rvb
57 1.1 rvb * Now it also works on FreeBSD -current. This code will be
58 1.1 rvb * committed to the FreeBSD -current and NetBSD -current
59 1.1 rvb * trees. It will then be tailored to the particular platform
60 1.1 rvb * by flushing conditional code.
61 1.1 rvb *
62 1.1 rvb * Revision 1.9 1998/08/18 17:05:24 rvb
63 1.1 rvb * Don't use __RCSID now
64 1.1 rvb *
65 1.1 rvb * Revision 1.8 1998/08/18 16:31:49 rvb
66 1.1 rvb * Sync the code for NetBSD -current; test on 1.3 later
67 1.1 rvb *
68 1.1 rvb * Revision 1.7 98/02/24 22:22:53 rvb
69 1.1 rvb * Fixes up mainly to flush iopen and friends
70 1.1 rvb *
71 1.1 rvb * Revision 1.6 98/01/31 20:53:19 rvb
72 1.1 rvb * First version that works on FreeBSD 2.2.5
73 1.1 rvb *
74 1.1 rvb * Revision 1.5 98/01/23 11:53:51 rvb
75 1.1 rvb * Bring RVB_CFS1_1 to HEAD
76 1.1 rvb *
77 1.1 rvb * Revision 1.4.2.5 98/01/23 11:21:14 rvb
78 1.1 rvb * Sync with 2.2.5
79 1.1 rvb *
80 1.1 rvb * Revision 1.4.2.4 98/01/22 13:03:38 rvb
81 1.1 rvb * Had Breaken ls .
82 1.1 rvb *
83 1.1 rvb * Revision 1.4.2.3 97/12/19 14:26:09 rvb
84 1.1 rvb * session id
85 1.1 rvb *
86 1.1 rvb * Revision 1.4.2.2 97/12/16 12:40:24 rvb
87 1.1 rvb * Sync with 1.3
88 1.1 rvb *
89 1.1 rvb * Revision 1.4.2.1 97/12/06 17:41:28 rvb
90 1.1 rvb * Sync with peters coda.h
91 1.1 rvb *
92 1.1 rvb * Revision 1.4 97/12/05 10:39:30 rvb
93 1.1 rvb * Read CHANGES
94 1.1 rvb *
95 1.1 rvb * Revision 1.3.18.2 97/11/12 12:09:45 rvb
96 1.1 rvb * reorg pass1
97 1.1 rvb *
98 1.1 rvb * Revision 1.3.18.1 97/10/29 16:06:31 rvb
99 1.1 rvb * Kill DYING
100 1.1 rvb *
101 1.1 rvb * Revision 1.3 1996/12/12 22:11:03 bnoble
102 1.1 rvb * Fixed the "downcall invokes venus operation" deadlock in all known cases.
103 1.1 rvb * There may be more.
104 1.1 rvb *
105 1.1 rvb * Revision 1.2 1996/01/02 16:57:26 bnoble
106 1.1 rvb * Added support for Coda MiniCache and raw inode calls (final commit)
107 1.1 rvb *
108 1.1 rvb * Revision 1.1.2.1 1995/12/20 01:57:53 bnoble
109 1.1 rvb * Added CFS-specific files
110 1.1 rvb *
111 1.1 rvb * Revision 3.1.1.1 1995/03/04 19:08:23 bnoble
112 1.1 rvb * Branch for NetBSD port revisions
113 1.1 rvb *
114 1.1 rvb * Revision 3.1 1995/03/04 19:08:23 bnoble
115 1.1 rvb * Bump to major revision 3 to prepare for NetBSD port
116 1.1 rvb *
117 1.1 rvb * Revision 2.2 1994/12/06 13:39:18 dcs
118 1.1 rvb * Add a flag value to indicate a cnode was orphaned, e.g. the venus
119 1.1 rvb * that created it has exited. This will allow one to restart venus
120 1.1 rvb * even though some process may be cd'd into /coda.
121 1.1 rvb *
122 1.1 rvb * Revision 2.1 94/07/21 16:25:33 satya
123 1.1 rvb * Conversion to C++ 3.0; start of Coda Release 2.0
124 1.1 rvb *
125 1.1 rvb * Revision 1.2.7.1 94/06/16 11:26:02 raiff
126 1.1 rvb * Branch for release beta-16Jun1994_39118
127 1.1 rvb *
128 1.1 rvb * Revision 1.2 92/10/27 17:58:41 lily
129 1.1 rvb * merge kernel/latest and alpha/src/cfs
130 1.1 rvb *
131 1.1 rvb * Revision 2.3 92/09/30 14:16:53 mja
132 1.1 rvb * Picked up fixed #ifdef _KERNEL. Also...
133 1.1 rvb *
134 1.1 rvb * Substituted rvb's history blurb so that we agree with Mach 2.5 sources.
135 1.1 rvb * [91/02/09 jjk]
136 1.1 rvb *
137 1.1 rvb * Added contributors blurb.
138 1.1 rvb * [90/12/13 jjk]
139 1.1 rvb *
140 1.1 rvb * Revision 2.2 90/07/05 11:27:24 mrt
141 1.1 rvb * Created for the Coda File System.
142 1.1 rvb * [90/05/23 dcs]
143 1.1 rvb *
144 1.1 rvb * Revision 1.4 90/05/31 17:02:16 dcs
145 1.1 rvb * Prepare for merge with facilities kernel.
146 1.1 rvb *
147 1.1 rvb *
148 1.1 rvb *
149 1.1 rvb */
150 1.1 rvb
151 1.1 rvb #ifndef _CNODE_H_
152 1.1 rvb #define _CNODE_H_
153 1.1 rvb
154 1.1 rvb #include <sys/vnode.h>
155 1.1 rvb
156 1.1 rvb /*
157 1.1 rvb * tmp below since we need struct queue
158 1.1 rvb */
159 1.1 rvb #include <cfs/cfsk.h>
160 1.1 rvb
161 1.1 rvb /*
162 1.1 rvb * Cnode lookup stuff.
163 1.1 rvb * NOTE: CFS_CACHESIZE must be a power of 2 for cfshash to work!
164 1.1 rvb */
165 1.1 rvb #define CFS_CACHESIZE 512
166 1.1 rvb
167 1.1 rvb #define CFS_ALLOC(ptr, cast, size) \
168 1.1 rvb do { \
169 1.1 rvb ptr = (cast)malloc((unsigned long) size, M_CFS, M_WAITOK); \
170 1.1 rvb if (ptr == 0) { \
171 1.1 rvb panic("kernel malloc returns 0 at %s:%d\n", __FILE__, __LINE__); \
172 1.1 rvb } \
173 1.1 rvb } while (0)
174 1.1 rvb
175 1.1 rvb #define CFS_FREE(ptr, size) free((ptr), M_CFS)
176 1.1 rvb
177 1.1 rvb /*
178 1.1 rvb * global cache state control
179 1.1 rvb */
180 1.1 rvb extern int cfsnc_use;
181 1.1 rvb
182 1.1 rvb /*
183 1.1 rvb * Used to select debugging statements throughout the cfs code.
184 1.1 rvb */
185 1.1 rvb extern int cfsdebug;
186 1.1 rvb extern int cfsnc_debug;
187 1.1 rvb extern int cfs_printf_delay;
188 1.1 rvb extern int cfs_vnop_print_entry;
189 1.1 rvb extern int cfs_psdev_print_entry;
190 1.1 rvb extern int cfs_vfsop_print_entry;
191 1.1 rvb
192 1.1 rvb #define CFSDBGMSK(N) (1 << N)
193 1.1 rvb #define CFSDEBUG(N, STMT) { if (cfsdebug & CFSDBGMSK(N)) { STMT } }
194 1.1 rvb #define myprintf(args) \
195 1.1 rvb do { \
196 1.1 rvb if (cfs_printf_delay) \
197 1.1 rvb DELAY(cfs_printf_delay);\
198 1.1 rvb printf args ; \
199 1.1 rvb } while (0)
200 1.1 rvb
201 1.1 rvb struct cnode {
202 1.1 rvb struct vnode *c_vnode;
203 1.1 rvb u_short c_flags; /* flags (see below) */
204 1.1 rvb ViceFid c_fid; /* file handle */
205 1.1 rvb struct lock c_lock; /* new lock protocol */
206 1.1 rvb struct vnode *c_ovp; /* open vnode pointer */
207 1.1 rvb u_short c_ocount; /* count of openers */
208 1.1 rvb u_short c_owrite; /* count of open for write */
209 1.1 rvb struct vattr c_vattr; /* attributes */
210 1.1 rvb char *c_symlink; /* pointer to symbolic link */
211 1.1 rvb u_short c_symlen; /* length of symbolic link */
212 1.1 rvb dev_t c_device; /* associated vnode device */
213 1.1 rvb ino_t c_inode; /* associated vnode inode */
214 1.1 rvb struct cnode *c_next; /* links if on NetBSD machine */
215 1.1 rvb };
216 1.1 rvb #define VTOC(vp) ((struct cnode *)(vp)->v_data)
217 1.1 rvb #define CTOV(cp) ((struct vnode *)((cp)->c_vnode))
218 1.1 rvb
219 1.1 rvb /* flags */
220 1.1 rvb #define C_VATTR 0x01 /* Validity of vattr in the cnode */
221 1.1 rvb #define C_SYMLINK 0x02 /* Validity of symlink pointer in the Code */
222 1.1 rvb #define C_WANTED 0x08 /* Set if lock wanted */
223 1.1 rvb #define C_LOCKED 0x10 /* Set if lock held */
224 1.1 rvb #define C_UNMOUNTING 0X20 /* Set if unmounting */
225 1.1 rvb #define C_PURGING 0x40 /* Set if purging a fid */
226 1.1 rvb
227 1.1 rvb #define VALID_VATTR(cp) ((cp->c_flags) & C_VATTR)
228 1.1 rvb #define VALID_SYMLINK(cp) ((cp->c_flags) & C_SYMLINK)
229 1.1 rvb #define IS_UNMOUNTING(cp) ((cp)->c_flags & C_UNMOUNTING)
230 1.1 rvb
231 1.1 rvb struct vcomm {
232 1.1 rvb u_long vc_seq;
233 1.1 rvb struct selinfo vc_selproc;
234 1.1 rvb struct queue vc_requests;
235 1.1 rvb struct queue vc_replys;
236 1.1 rvb };
237 1.1 rvb
238 1.1 rvb #define VC_OPEN(vcp) ((vcp)->vc_requests.forw != NULL)
239 1.1 rvb #define MARK_VC_CLOSED(vcp) (vcp)->vc_requests.forw = NULL;
240 1.1 rvb #define MARK_VC_OPEN(vcp) /* MT */
241 1.1 rvb
242 1.1 rvb struct cfs_clstat {
243 1.1 rvb int ncalls; /* client requests */
244 1.1 rvb int nbadcalls; /* upcall failures */
245 1.1 rvb int reqs[CFS_NCALLS]; /* count of each request */
246 1.1 rvb };
247 1.1 rvb extern struct cfs_clstat cfs_clstat;
248 1.1 rvb
249 1.1 rvb /*
250 1.1 rvb * CFS structure to hold mount/file system information
251 1.1 rvb */
252 1.1 rvb struct cfs_mntinfo {
253 1.1 rvb struct vnode *mi_rootvp;
254 1.1 rvb struct mount *mi_vfsp;
255 1.1 rvb struct vcomm mi_vcomm;
256 1.1 rvb };
257 1.1 rvb extern struct cfs_mntinfo cfs_mnttbl[]; /* indexed by minor device number */
258 1.1 rvb
259 1.1 rvb /*
260 1.1 rvb * vfs pointer to mount info
261 1.1 rvb */
262 1.1 rvb #define vftomi(vfsp) ((struct cfs_mntinfo *)(vfsp->mnt_data))
263 1.1 rvb #define CFS_MOUNTED(vfsp) (vftomi((vfsp)) != (struct cfs_mntinfo *)0)
264 1.1 rvb
265 1.1 rvb /*
266 1.1 rvb * vnode pointer to mount info
267 1.1 rvb */
268 1.1 rvb #define vtomi(vp) ((struct cfs_mntinfo *)(vp->v_mount->mnt_data))
269 1.1 rvb
270 1.1 rvb /*
271 1.1 rvb * Used for identifying usage of "Control" object
272 1.1 rvb */
273 1.1 rvb extern struct vnode *cfs_ctlvp;
274 1.1 rvb #define IS_CTL_VP(vp) ((vp) == cfs_ctlvp)
275 1.1 rvb #define IS_CTL_NAME(vp, name, l)((l == CFS_CONTROLLEN) \
276 1.1 rvb && ((vp) == vtomi((vp))->mi_rootvp) \
277 1.1 rvb && strncmp(name, CFS_CONTROL, l) == 0)
278 1.1 rvb
279 1.1 rvb /*
280 1.1 rvb * An enum to tell us whether something that will remove a reference
281 1.1 rvb * to a cnode was a downcall or not
282 1.1 rvb */
283 1.1 rvb enum dc_status {
284 1.1 rvb IS_DOWNCALL = 6,
285 1.1 rvb NOT_DOWNCALL = 7
286 1.1 rvb };
287 1.1 rvb
288 1.1 rvb /* cfs_psdev.h */
289 1.1 rvb int cfscall(struct cfs_mntinfo *mntinfo, int inSize, int *outSize, caddr_t buffer);
290 1.1 rvb
291 1.1 rvb /* cfs_subr.h */
292 1.1 rvb int handleDownCall(int opcode, union outputArgs *out);
293 1.1 rvb void cfs_unmounting(struct mount *whoIam);
294 1.1 rvb int cfs_vmflush(struct cnode *cp);
295 1.1 rvb
296 1.1 rvb /* cfs_vnodeops.h */
297 1.1 rvb struct cnode *makecfsnode(ViceFid *fid, struct mount *vfsp, short type);
298 1.1 rvb int cfs_vnodeopstats_init(void);
299 1.1 rvb
300 1.1 rvb /* cfs_vfsops.h */
301 1.1 rvb struct mount *devtomp(dev_t dev);
302 1.1 rvb
303 1.1 rvb /* sigh */
304 1.1 rvb #define CFS_RDWR ((u_long) 31)
305
306 #endif /* _CNODE_H_ */
307
308