FreeBSD/Linux Kernel Cross Reference
sys/fs/coda/cnode.h
1 /*-
2 *
3 * Coda: an Experimental Distributed File System
4 * Release 3.1
5 *
6 * Copyright (c) 1987-1998 Carnegie Mellon University
7 * All Rights Reserved
8 *
9 * Permission to use, copy, modify and distribute this software and its
10 * documentation is hereby granted, provided that both the copyright
11 * notice and this permission notice appear in all copies of the
12 * software, derivative works or modified versions, and any portions
13 * thereof, and that both notices appear in supporting documentation, and
14 * that credit is given to Carnegie Mellon University in all documents
15 * and publicity pertaining to direct or indirect use of this code or its
16 * derivatives.
17 *
18 * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS KNOWN TO HAVE BUGS,
19 * SOME OF WHICH MAY HAVE SERIOUS CONSEQUENCES. CARNEGIE MELLON ALLOWS
20 * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION. CARNEGIE MELLON
21 * DISCLAIMS ANY LIABILITY OF ANY KIND FOR ANY DAMAGES WHATSOEVER
22 * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE OR OF
23 * ANY DERIVATIVE WORK.
24 *
25 * Carnegie Mellon encourages users of this software to return any
26 * improvements or extensions that they make, and to grant Carnegie
27 * Mellon the rights to redistribute these changes without encumbrance.
28 *
29 * @(#) src/sys/coda/cnode.h,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
30 * $FreeBSD: releng/8.4/sys/fs/coda/cnode.h 208702 2010-06-01 14:29:26Z rwatson $
31 *
32 */
33
34 /*-
35 * Mach Operating System
36 * Copyright (c) 1990 Carnegie-Mellon University
37 * Copyright (c) 1989 Carnegie-Mellon University
38 * All rights reserved. The CMU software License Agreement specifies
39 * the terms and conditions for use and redistribution.
40 */
41
42 /*
43 * This code was written for the Coda filesystem at Carnegie Mellon University.
44 * Contributers include David Steere, James Kistler, and M. Satyanarayanan.
45 */
46
47 #ifndef _CNODE_H_
48 #define _CNODE_H_
49
50 #include <sys/vnode.h>
51 #include <sys/lock.h>
52
53 MALLOC_DECLARE(M_CODA);
54
55 /*
56 * Cnode lookup stuff.
57 *
58 * NOTE: CODA_CACHESIZE must be a power of 2 for cfshash to work!
59 */
60 #define CODA_CACHESIZE 512
61
62 #define CODA_ALLOC(ptr, cast, size) do { \
63 ptr = (cast)malloc((unsigned long) size, M_CODA, M_WAITOK); \
64 if (ptr == NULL) \
65 panic("kernel malloc returns 0 at %s:%d\n", __FILE__, \
66 __LINE__); \
67 } while (0)
68
69 #define CODA_FREE(ptr, size) free((ptr), M_CODA)
70
71 /*
72 * Used to select debugging statements throughout the cfs code.
73 */
74 extern int codadebug;
75 extern int coda_printf_delay;
76 extern int coda_vnop_print_entry;
77 extern int coda_psdev_print_entry;
78 extern int coda_vfsop_print_entry;
79
80 #define CODADBGMSK(N) (1 << N)
81
82 #define CODADEBUG(N, STMT) do { \
83 if (codadebug & CODADBGMSK(N)) { \
84 STMT \
85 } \
86 } while (0)
87
88 #define myprintf(args) do { \
89 if (coda_printf_delay) \
90 DELAY(coda_printf_delay); \
91 printf args ; \
92 } while (0)
93
94 struct cnode {
95 struct vnode *c_vnode;
96 u_short c_flags; /* flags (see below) */
97 struct CodaFid c_fid; /* file handle */
98 struct vnode *c_ovp; /* open vnode pointer */
99 u_short c_ocount; /* count of openers */
100 u_short c_owrite; /* count of open for write */
101 struct vattr c_vattr; /* attributes */
102 char *c_symlink; /* pointer to symbolic link */
103 u_short c_symlen; /* length of symbolic link */
104 uid_t c_cached_uid; /* cached uid */
105 accmode_t c_cached_mode; /* cached access mode */
106 struct cnode *c_next; /* links if on FreeBSD machine */
107 };
108 #define VTOC(vp) ((struct cnode *)(vp)->v_data)
109 #define CTOV(cp) ((struct vnode *)((cp)->c_vnode))
110
111 /* flags */
112 #define C_VATTR 0x01 /* Validity of vattr in the cnode */
113 #define C_SYMLINK 0x02 /* Validity of symlink pointer in the Code */
114 #define C_ACCCACHE 0x04 /* Validity of access cache */
115 #define C_WANTED 0x08 /* Set if lock wanted */
116 #define C_LOCKED 0x10 /* Set if lock held */
117 #define C_UNMOUNTING 0X20 /* Set if unmounting */
118 #define C_PURGING 0x40 /* Set if purging a fid */
119
120 #define VALID_VATTR(cp) ((cp->c_flags) & C_VATTR)
121 #define VALID_SYMLINK(cp) ((cp->c_flags) & C_SYMLINK)
122 #define VALID_ACCCACHE(cp) ((cp->c_flags) & C_ACCCACHE)
123 #define IS_UNMOUNTING(cp) ((cp)->c_flags & C_UNMOUNTING)
124
125 struct vcomm {
126 u_long vc_seq;
127 struct selinfo vc_selproc;
128 TAILQ_HEAD(, vmsg) vc_requests;
129 TAILQ_HEAD(, vmsg) vc_replies;
130 int vc_open;
131 };
132
133 #define VC_OPEN(vcp) ((vcp)->vc_open == 1)
134 #define MARK_VC_CLOSED(vcp) (vcp)->vc_open = 0
135 #define MARK_VC_OPEN(vcp) (vcp)->vc_open = 1
136
137 struct coda_clstat {
138 int ncalls; /* client requests */
139 int nbadcalls; /* upcall failures */
140 int reqs[CODA_NCALLS]; /* count of each request */
141 };
142 extern struct coda_clstat coda_clstat;
143
144 /*
145 * CODA structure to hold mount/filesystem information.
146 */
147 struct coda_mntinfo {
148 struct vnode *mi_rootvp;
149 struct mount *mi_vfsp;
150 struct vcomm mi_vcomm;
151 struct cdev *dev;
152 int mi_started;
153 LIST_ENTRY(coda_mntinfo) mi_list;
154 };
155 struct coda_mntinfo *dev2coda_mntinfo(struct cdev *dev);
156
157 /*
158 * vfs pointer to mount info.
159 */
160 #define vftomi(vfsp) ((struct coda_mntinfo *)(vfsp->mnt_data))
161 #define CODA_MOUNTED(vfsp) (vftomi((vfsp)) != NULL)
162
163 /*
164 * vnode pointer to mount info.
165 */
166 #define vtomi(vp) ((struct coda_mntinfo *)(vp->v_mount->mnt_data))
167
168 /*
169 * Used for identifying usage of "Control" object.
170 */
171 extern struct vnode *coda_ctlvp;
172 #define IS_CTL_VP(vp) ((vp) == coda_ctlvp)
173 #define IS_CTL_NAME(vp, name, l) ((l == CODA_CONTROLLEN) \
174 && ((vp) == vtomi((vp))->mi_rootvp) && \
175 strncmp(name, CODA_CONTROL, l) == 0)
176
177 /*
178 * An enum to tell us whether something that will remove a reference to a
179 * cnode was a downcall or not.
180 */
181 enum dc_status {
182 IS_DOWNCALL = 6,
183 NOT_DOWNCALL = 7
184 };
185
186 /* cfs_psdev.h */
187 int coda_call(struct coda_mntinfo *mntinfo, int inSize, int *outSize,
188 caddr_t buffer);
189
190 extern int coda_kernel_version;
191
192 /* cfs_subr.h */
193 int handleDownCall(struct coda_mntinfo *mnt, int opcode,
194 union outputArgs *out);
195 void coda_unmounting(struct mount *whoIam);
196 int coda_vmflush(struct cnode *cp);
197
198 /* cfs_vnodeops.h */
199 struct cnode *make_coda_node(struct CodaFid *fid, struct mount *vfsp,
200 short type);
201 int coda_vnodeopstats_init(void);
202
203 /* sigh */
204 #define CODA_RDWR ((u_long) 31)
205
206 #endif /* _CNODE_H_ */
Cache object: d5889ae21d1e3eb0c27c27555eba282d
|