Coda Distributed File System
venus.private.h
Go to the documentation of this file.
1/* BLURB gpl
2
3 Coda File System
4 Release 8
5
6 Copyright (c) 1987-2021 Carnegie Mellon University
7 Additional copyrights listed below
8
9This code is distributed "AS IS" without warranty of any kind under
10the terms of the GNU General Public Licence Version 2, as shown in the
11file LICENSE. The technical and financial contributors to Coda are
12listed in the file CREDITS.
13
14 Additional copyrights
15 none currently
16
17#*/
18
19/*
20 * Manifest constants for Venus, plus declarations for source files without
21 * their own headers.
22 */
23
24#ifndef _VENUS_PRIVATE_H_
25#define _VENUS_PRIVATE_H_
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31#include <stdio.h>
32#include <sys/types.h>
33#include <sys/time.h>
34#include <sys/resource.h>
35#include <sys/param.h>
36#include <ctype.h>
37#include <errno.h>
38
39#include <lwp/lock.h>
40#include <rpc2/rpc2.h>
41#include <util.h>
42#ifdef __cplusplus
43}
44#endif
45
46#include "coda_assert.h"
47
48/* interfaces */
49#include <vice.h>
50
51/* from vv */
52#include <inconsist.h>
53
54/* from venus */
55#include "venusstats.h"
56#include "venusfid.h"
57
58#ifndef O_BINARY
59#define O_BINARY 0
60#endif
61
62/* Replica Control Rights. */
63/* Note that we presently do not distinguish between read and write rights. */
64/* We may well do so in the future, however. */
65#define RC_STATUSREAD 1
66#define RC_STATUSWRITE 2
67#define RC_STATUS (RC_STATUSREAD | RC_STATUSWRITE)
68#define RC_DATAREAD 4
69#define RC_DATAWRITE 8
70#define RC_DATA (RC_DATAREAD | RC_DATAWRITE)
71
72#define EMULTRSLTS ETOOMANYREFS /* external */
73#define ESYNRESOLVE 155 /* internal */
74#define EASYRESOLVE 156 /* internal */
75#define ERETRY 157 /* internal */
76/* The next three are internal, but defined in other modules. */
77/*
78#define EVOLUME 158
79#define EINCOMPATIBLE 198
80#define EINCONS 199
81*/
82/* added for implementing ASRs. Used to tell the vfs layer that
83 an ASR was started and it should block */
84#define EASRSTARTED 200
85
86#define ASR_INTERVAL 300
87
88/* ***** parameter defaults. ***** */
89#define DFLT_VR "/coda" /* venus root */
90#define DFLT_CD "/usr/coda/venus.cache" /* cache directory */
91/* the next two are relative to cachedir if they do not start with '/' */
92#define DFLT_PIDFILE "pid" /* default pid file */
93#define DFLT_CTRLFILE "VENUS_CTRL" /* default control file */
94
95#define DFLT_LOGFILE "/usr/coda/etc/venus.log" /* venus log file */
96#define DFLT_ERRLOG "/usr/coda/etc/console" /* venus error log */
97#define MIN_CS "2MB"
98
99/* rule of thumb */
100const int BLOCKS_PER_FILE = 24;
101const int MLES_PER_FILE = 4;
102const int FILES_PER_HDBE = 2;
103
104const int MIN_CB = 2048;
108
109#define UNSET_PRIMARYUSER 0 /* primary user of this machine */
110const int FREE_FACTOR = 16;
111
112/* ***** Manifest constants for Venus. ***** */
113#ifdef __CYGWIN32__
114extern uid_t V_UID; /* UID that the venus process runs under. */
115#else
116const uid_t V_UID = (uid_t)0; /* UID that the venus process runs under. */
117#endif
118/* Group id fields are 32 bits in BSD44 (not 16 bits); the use of a small
119 negative number (-2) means its unsigned long representation is huge
120 (4294967294). This causes the "ar" program to screw up because it
121 blindly does a sprintf() of the gid into the ".a" file. (Satya, 1/11/97) */
122/* In linux kernel, gid_t is unsigned short, but in venus vgid_t is
123 unsigned int which is 32-bit, so we also need to hardcode the number
124 here. (Clement 6/10/97) */
125#if defined(__CYGWIN32__)
126const gid_t V_GID = 513; /* GID that the venus process runs under. */
127#else
128const gid_t V_GID = 65534; /* GID that the venus process runs under. */
129#endif
130const uid_t ANYUSER_UID = (uid_t)-1;
131const uid_t HOARD_UID = (uid_t)-2; /* uid of hoard daemon */
132const uid_t UNSET_UID = (uid_t)-666; /* beastly but recognizable */
133const unsigned short V_MODE = 0600;
134const int OWNERBITS = 0700;
135const int OWNERREAD = 0400;
136const int OWNERWRITE = 0200;
137const int OWNEREXEC = 0100;
140const int V_BLKSIZE = 8192;
141const int TIMERINTERVAL = 5;
142const int GETDATA = 1;
143#define ALL_FIDS (&NullFid)
144typedef void (*PROC_V_UL)(unsigned long);
145#define STREQ(a, b) (strcmp((a), (b)) == 0)
146#define STRNEQ(a, b, n) (strncmp((a), (b), (n)) == 0)
147#define NBLOCKS(bytes) ((bytes + 1023) >> 10)
148#define NBLOCKS_BYTES(bytes) (NBLOCKS(bytes) << 10)
149
150/* Flags for the various vproc/fsobj name/object lookup routines. */
151#define FOLLOW_SYMLINKS \
152 0x1 /* should lookup follow symlinks for last component? */
153#define TRAVERSE_MTPTS 0x2 /* should lookup cross covered mount points? */
154#define REFERENCE 0x8 /* should cache references be noted? */
155
156/* ***** Debugging macros. ***** */
157#ifdef VENUSDEBUG
158#define LOG(level, stmt) \
159 do { \
160 if (LogLevel >= (level)) \
161 dprint stmt; \
162 } while (0)
163#else
164#define LOG(level, stmt)
165#endif /* !VENUSDEBUG */
166
167/* ***** Locking macros. ***** */
168
170{
174 WR
176
177#define ObtainLock(lock, level) \
178 { \
179 switch (level) { \
180 case RD: \
181 ObtainReadLock(lock); \
182 break; \
183 \
184 case SH: \
185 ObtainSharedLock(lock); \
186 break; \
187 \
188 case WR: \
189 ObtainWriteLock(lock); \
190 break; \
191 \
192 case NL: \
193 default: \
194 CODA_ASSERT(0); \
195 } \
196 }
197
198#define ReleaseLock(lock, level) \
199 { \
200 switch (level) { \
201 case RD: \
202 ReleaseReadLock(lock); \
203 break; \
204 \
205 case SH: \
206 ReleaseSharedLock(lock); \
207 break; \
208 \
209 case WR: \
210 ReleaseWriteLock(lock); \
211 break; \
212 \
213 case NL: \
214 default: \
215 CODA_ASSERT(0); \
216 } \
217 }
218
219/* ***** Timing macros. ***** */
220#ifdef TIMING
221#define SubTimes(end, start) \
222 ((((end)->tv_sec - (start)->tv_sec) * 1000.0) + \
223 (((end)->tv_usec - (start)->tv_usec) / 1000.0))
224
225#define START_TIMING() \
226 struct timeval StartTV, EndTV; \
227 gettimeofday(&StartTV, 0);
228
229#define END_TIMING() \
230 gettimeofday(&EndTV, 0); \
231 float elapsed; \
232 elapsed = SubTimes(&EndTV, &StartTV);
233#else
234#define SubTimes(end, start) (0.0)
235#define START_TIMING()
236#define END_TIMING() float elapsed = 0.0;
237#endif /* !TIMING */
238
239/* ***** Cache Stuff ***** */
241{
243 DATA
245
246#undef WRITE
247
249{
259 REPLACE
261
262/* "blocks" field is not relevant for all events */
263/* "blocks" is constant for (relevant) ATTR events */
264/* Now the same struct named CacheEventEntry is generated from mond.rpc2 */
266 int count;
268};
269
271 CacheEventRecord events[10]; /* indexed by CacheEvent type! */
272};
273
274/* ***** Misc stuff ***** */
275#define TRANSLATE_TO_LOWER(s) \
276 { \
277 for (char *c = s; *c; c++) \
278 if (isupper(*c)) \
279 *c = tolower(*c); \
280 }
281#define TRANSLATE_TO_UPPER(s) \
282 { \
283 for (char *c = s; *c; c++) \
284 if (islower(*c)) \
285 *c = toupper(*c); \
286 }
287
288#define CHOKE(me...) choke(__FILE__, __LINE__, ##me)
289
290/* ***** Declarations for source files without their own headers. ***** */
291void dprint(const char *...);
292void choke(const char *file, int line, const char *...);
293void rds_printer(char *...);
294void VenusPrint(int argc, const char **argv);
295void VenusPrint(FILE *, int argc, const char **argv);
296void VenusPrint(int, int argc, const char **argv);
297const char *VenusOpStr(int);
298const char *IoctlOpStr(unsigned char nr);
299const char *VenusRetStr(int);
300void VVPrint(FILE *, ViceVersionVector **);
301int binaryfloor(int);
302void LogInit();
303void DebugOn();
304void DebugOff();
305void Terminate();
306void DumpState();
307void RusagePrint(int);
308void VFSPrint(int);
309void RPCPrint(int);
312void MallocPrint(int);
313void StatsInit();
314void SwapLog();
315void ToggleMallocTrace();
316const char *lvlstr(LockLevel);
317int GetTime(long *, long *);
318time_t Vtime();
319int FAV_Compare(ViceFidAndVV *, ViceFidAndVV *);
320void DaemonInit();
321void FireAndForget(const char *name, void (*f)(void), int interval,
322 int stacksize = 32 * 1024) EXCLUDES_TRANSACTION;
323void RegisterDaemon(unsigned long, char *);
324void DispatchDaemons();
325
326/* Helper to add a file descriptor with callback to main select loop. */
327void MUX_add_callback(int fd, void (*cb)(int fd, void *udata), void *udata);
328
329extern FILE *logFile;
330extern int LogLevel;
331extern long int RPC2_DebugLevel;
332extern long int SFTP_DebugLevel;
333extern long int RPC2_Trace;
334extern int MallocTrace;
335extern const VenusFid NullFid;
336extern const ViceVersionVector NullVV;
339extern struct timeval DaemonExpiry;
340
341/* venus.c */
342class vproc;
343extern vproc *Main;
344extern VenusFid rootfid;
345extern int parent_fd;
346extern long rootnodeid;
347extern int CleanShutDown;
348extern const char *venusRoot;
349extern const char *kernDevice;
350extern const char *realmtab;
351extern const char *CacheDir;
352extern const char *CachePrefix;
353extern uint64_t CacheBlocks;
354extern const char *SpoolDir;
355extern uid_t PrimaryUser;
356extern const char *VenusPidFile;
357extern const char *VenusControlFile;
358extern const char *VenusLogFile;
359extern const char *consoleFile;
360extern const char *MarinerSocketPath;
361extern int mariner_tcp_enable;
362extern int plan9server_enabled;
363extern int nofork;
364extern int allow_reattach;
365extern int masquerade_port;
366extern int PiggyValidations;
367extern int T1Interval;
368extern const char *ASRLauncherFile;
369extern const char *ASRPolicyFile;
370extern int option_isr;
373
374/* spool.cc */
375extern void MakeUserSpoolDir(char *, uid_t);
376
377/* ASR misc */
378/* Note: At some point, it would be nice to run ASRs in different
379 * volumes concurrently. This requires replacing the globals
380 * below with a table or other data structure. Due to token
381 * assignment constraints, though, this is not possible as of 06/2006.
382 */
383
384extern pid_t ASRpid;
385extern VenusFid ASRfid;
386extern uid_t ASRuid;
387
391 struct in_addr *hosts;
393 int ph_ix;
394 unsigned long ph;
396};
397
398#endif /* _VENUS_PRIVATE_H_ */
Definition: vproc.h:151
unsigned int uint32_t
Definition: coda.h:105
#define EXCLUDES_TRANSACTION
Definition: coda_tsa.h:108
char * argv[]
Definition: dir.cc:35
FILE * file
Definition: dirtest.c:723
name
Definition: pwdtopdbtool.py:40
int32_t RPC2_Integer
Definition: rpc2.h:297
uint32_t RPC2_Unsigned
Definition: rpc2.h:300
RPC2_Integer RPC2_Handle
Definition: rpc2.h:345
@ f
Definition: rvm_private.h:416
Definition: venus.private.h:265
int count
Definition: venus.private.h:266
int blocks
Definition: venus.private.h:267
Definition: venus.private.h:270
CacheEventRecord events[10]
Definition: venus.private.h:271
Definition: venus.private.h:388
RPC2_Handle * handles
Definition: venus.private.h:390
RPC2_Integer * retcodes
Definition: venus.private.h:392
unsigned long ph
Definition: venus.private.h:394
int ph_ix
Definition: venus.private.h:393
RPC2_Unsigned nservers
Definition: venus.private.h:389
struct in_addr * hosts
Definition: venus.private.h:391
RPC2_Multicast * MIp
Definition: venus.private.h:395
Definition: rpc2.h:601
Definition: venusstats.h:110
Definition: venusstats.h:114
Definition: venusstats.h:50
Definition: venusfid.h:24
const char * venusRoot
Definition: venus.cc:90
VenusFid ASRfid
Definition: venus.cc:109
const char * VenusLogFile
Definition: venus.cc:102
const char * VenusOpStr(int)
Definition: venusutil.cc:292
int option_isr
Definition: venus.cc:112
LockLevel
Definition: venus.private.h:170
@ SH
Definition: venus.private.h:173
@ RD
Definition: venus.private.h:172
@ WR
Definition: venus.private.h:174
@ NL
Definition: venus.private.h:171
RPCOpStatistics RPCOpStats
Definition: venusutil.cc:88
const unsigned short V_MODE
Definition: venus.private.h:133
void ToggleMallocTrace()
Definition: venusutil.cc:833
const char * VenusControlFile
Definition: venus.cc:101
int binaryfloor(int)
Definition: venusutil.cc:522
int CleanShutDown
Definition: venus.cc:84
const int MIN_CF
Definition: venus.private.h:105
VenusFid rootfid
Definition: venus.cc:82
const int OWNERWRITE
Definition: venus.private.h:136
const char * MarinerSocketPath
Definition: venus.cc:105
time_t Vtime()
Definition: venusutil.cc:884
int FAV_Compare(ViceFidAndVV *, ViceFidAndVV *)
Definition: venusutil.cc:893
const char * VenusRetStr(int)
Definition: venusutil.cc:494
void LogInit()
Definition: venusutil.cc:532
void SwapLog()
Definition: venusutil.cc:851
long int RPC2_DebugLevel
Definition: globals.c:53
void MUX_add_callback(int fd, void(*cb)(int fd, void *udata), void *udata)
Definition: venus.cc:213
void rds_printer(char *...)
Definition: srv.cc:1282
uid_t PrimaryUser
Definition: venus.cc:97
const ViceVersionVector NullVV
Definition: dummy.cc:41
void RPCPrint(int)
Definition: venusutil.cc:618
FILE * logFile
Definition: venusutil.cc:82
vproc * Main
Definition: venus.cc:81
void dprint(const char *...)
Definition: venusutil.cc:106
int PiggyValidations
Definition: venus.cc:107
uid_t ASRuid
Definition: venus.cc:110
const int MIN_CB
Definition: venus.private.h:104
const int FILES_PER_HDBE
Definition: venus.private.h:102
const int OWNEREXEC
Definition: venus.private.h:137
const char * realmtab
Definition: venus.cc:92
const char * ASRLauncherFile
Definition: venus.cc:103
int T1Interval
Definition: comm_daemon.cc:46
const uint32_t V_MAXACLLEN
Definition: venus.private.h:139
const int V_BLKSIZE
Definition: venus.private.h:140
void DumpState()
Definition: venusutil.cc:565
int masquerade_port
Definition: venus.cc:106
void StatsInit()
Definition: venusutil.cc:816
long rootnodeid
Definition: venus.cc:83
const gid_t V_GID
Definition: venus.private.h:128
int yellowzone_limit
Definition: venus.private.h:372
int redzone_limit
Definition: venus.cc:133
CacheType
Definition: venus.private.h:241
@ DATA
Definition: venus.private.h:243
@ ATTR
Definition: venus.private.h:242
void SubCSSs(RPCPktStatistics *, RPCPktStatistics *)
Definition: venusutil.cc:706
int nofork
Definition: venus.cc:130
const int BLOCKS_PER_FILE
Definition: venus.private.h:100
long int RPC2_Trace
Definition: globals.c:53
void VVPrint(FILE *, ViceVersionVector **)
Definition: venusutil.cc:513
const int MIN_HDBE
Definition: venus.private.h:107
uint64_t CacheBlocks
Definition: venus.cc:96
void choke(const char *file, int line, const char *...)
Definition: venusutil.cc:141
int LogLevel
Definition: proctest.cc:26
const uid_t UNSET_UID
Definition: venus.private.h:132
const int MLES_PER_FILE
Definition: venus.private.h:101
const char * ASRPolicyFile
Definition: venus.cc:104
void DebugOff()
Definition: venusutil.cc:554
const char * IoctlOpStr(unsigned char nr)
Definition: venusutil.cc:303
const int FREE_FACTOR
Definition: venus.private.h:110
pid_t ASRpid
Definition: venus.cc:108
void Terminate()
Definition: rvm_basher.c:132
const VenusFid NullFid
Definition: venusutil.cc:85
const int MIN_MLE
Definition: venus.private.h:106
const int TIMERINTERVAL
Definition: venus.private.h:141
int GetTime(long *, long *)
void DaemonInit()
Definition: daemon.cc:53
CacheEvent
Definition: venus.private.h:249
@ CREATE
Definition: venus.private.h:256
@ WRITE
Definition: venus.private.h:257
@ REPLACE
Definition: venus.private.h:259
@ RETRY
Definition: venus.private.h:252
@ NOSPACE
Definition: venus.private.h:254
@ REMOVE
Definition: venus.private.h:258
@ FAILURE
Definition: venus.private.h:255
@ TIMEOUT
Definition: venus.private.h:253
@ HIT
Definition: venus.private.h:250
@ MISS
Definition: venus.private.h:251
const int OWNERBITS
Definition: venus.private.h:134
const char * SpoolDir
Definition: venus.cc:98
void RusagePrint(int)
Definition: venusutil.cc:576
const uid_t V_UID
Definition: venus.private.h:116
void MallocPrint(int)
Definition: venusutil.cc:788
const char * CachePrefix
Definition: venus.cc:95
int parent_fd
Definition: venus.cc:158
VFSStatistics VFSStats
Definition: venusutil.cc:87
void VFSPrint(int)
Definition: venusutil.cc:594
const char * lvlstr(LockLevel)
Definition: venusutil.cc:863
struct timeval DaemonExpiry
Definition: venus.cc:140
const char * VenusPidFile
Definition: venus.cc:100
void MakeUserSpoolDir(char *, uid_t)
Definition: spool.cc:54
void FireAndForget(const char *name, void(*f)(void), int interval, int stacksize=32 *1024) EXCLUDES_TRANSACTION
Definition: daemon.cc:177
const uid_t HOARD_UID
Definition: venus.private.h:131
void GetCSS(RPCPktStatistics *)
Definition: venusutil.cc:694
const char * consoleFile
Definition: venus.cc:89
int MallocTrace
Definition: venusutil.cc:84
void RegisterDaemon(unsigned long, char *)
Definition: daemon.cc:62
int mariner_tcp_enable
Definition: venus.cc:126
const char * CacheDir
Definition: venus.cc:94
long int SFTP_DebugLevel
int detect_reintegration_retry
Definition: venus.cc:111
const int OWNERREAD
Definition: venus.private.h:135
void DispatchDaemons()
Definition: daemon.cc:104
void(* PROC_V_UL)(unsigned long)
Definition: venus.private.h:144
int allow_reattach
Definition: worker.cc:127
void VenusPrint(int argc, const char **argv)
Definition: venusutil.cc:179
const int GETDATA
Definition: venus.private.h:142
int plan9server_enabled
Definition: venus.cc:129
const uint32_t NO_HOST
Definition: venus.private.h:138
const char * kernDevice
Definition: venus.cc:91
void DebugOn()
Definition: venusutil.cc:548
const uid_t ANYUSER_UID
Definition: venus.private.h:130