Coda Distributed File System
srv.h
Go to the documentation of this file.
1/* BLURB lgpl
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 Library General Public Licence Version 2, as
11shown in the file LICENSE. The technical and financial contributors to
12Coda are listed in the file CREDITS.
13
14 Additional copyrights
15
16#*/
17
18/*
19 IBM COPYRIGHT NOTICE
20
21 Copyright (C) 1986
22 International Business Machines Corporation
23 All Rights Reserved
24
25This file contains some code identical to or derived from the 1986
26version of the Andrew File System ("AFS"), which is owned by the IBM
27Corporation. This code is provided "AS IS" and IBM does not warrant
28that it is free of infringement of any intellectual rights of any
29third party. IBM disclaims liability of any kind for any damages
30whatsoever resulting directly or indirectly from use of this software
31or of any derivative work. Carnegie Mellon University has obtained
32permission to modify, distribute and sublicense this code, which is
33based on Version 2 of AFS and does not contain the features and
34enhancements that are part of Version 3 of AFS. Version 3 of AFS is
35commercially available and supported by Transarc Corporation,
36Pittsburgh, PA.
37
38*/
39
40#ifndef _VICE_SRV_H_
41#define _VICE_SRV_H_ 1
42
43#ifdef __cplusplus
44extern "C" {
45#endif
46
47#include <sys/file.h>
48#include <stdio.h>
49#include <errno.h>
50
51#include <lwp/lwp.h>
52#include <lwp/lock.h>
53#include <rpc2/rpc2.h>
54#include <rpc2/errors.h>
55
56#ifdef __cplusplus
57}
58#endif
59
60#include <prs.h>
61#include <voltypes.h>
62#include <inconsist.h>
63#include <vice.h>
64#include <cvnode.h>
65#include <auth2.h>
66#include <deprecations.h>
67
68/* From Vol package. */
69#define ThisHostAddr ((unsigned long)(HostAddress[ThisServerId]))
70#define VolToHostAddr(volnum) ((unsigned long)(HostAddress[(volnum) >> 24]))
71#define VolToServerId(volnum) ((uint8_t)((volnum) >> 24))
72
73#define ISDIR(fid) ((fid).Vnode & 1)
74
77extern long rvm_no_yield;
78
80int VCheckVLDB();
81void VPrintCacheStats(FILE * = stdout);
82void ViceUpdateDB();
83void SwapLog(int ign);
84void SwapMalloc();
85void ViceTerminate();
86
87#define VSLEEP(seconds) \
88 { \
89 struct timeval delay; \
90 delay.tv_sec = seconds; \
91 delay.tv_usec = 0; \
92 IOMGR_Select(0, 0, 0, 0, &delay); \
93 }
94
95#define STREQ(a, b) (strcmp((a), (b)) == 0)
96#define STRNEQ(a, b, n) (strncmp((a), (b), (n)) == 0)
97
98#define SetAccessList(vptr, ACL, ACLSize) \
99 { \
100 CODA_ASSERT((vptr)->disk.type == vDirectory); \
101 (ACL) = VVnodeACL((vptr)); \
102 (ACLSize) = VAclSize((vptr)); \
103 }
104
105#define MAXHOSTTABLEENTRIES 1000
106#define MAXNAMELENGTH 64
107#define MAXHOSTLENGTH 32
108
109/* from vice/srvproc.c */
110#define EMPTYFILEBLOCKS 1
111#define EMPTYDIRBLOCKS 2
112#define EMPTYSYMLINKBLOCKS 1
113
114typedef struct HostTable {
115 RPC2_Handle id; /* cid for call back connection */
116 struct dllist_head Clients; /* list of incoming rpc2 conns */
117 struct in_addr host; /* IP address of host */
118 unsigned int port; /* port address of host */
119 time_t LastCall; /* time of last call from host */
120 time_t ActiveCall; /* time of any call but gettime */
121 struct Lock lock; /* lock used for client sync */
123
124typedef struct ClientEntry {
125 RPC2_Handle RPCid; /* cid for connection */
126 struct dllist_head Clients; /* next incoming rpc2 conn */
127 PRS_InternalCPS *CPS; /* cps for authentication */
128 RPC2_Integer Id; /* Vice ID of user */
129 RPC2_Integer SecurityLevel; /* Security level of conn */
130 int SEType; /* Type of side effect */
131 time_t LastCall; /* time of last call */
132 HostTable *VenusId; /* ptr to host entry */
133 RPC2_Integer LastOp; /* op code of last call */
134 int DoUnbind; /* true if Unbind needed */
135 char UserName[MAXNAMELENGTH]; /* name of user */
136 RPC2_Integer EndTimestamp; /* expiration time from token */
138
139#define NEWCONNECT "NEWCONNECT"
140#define MAXMSG 100
141#define MAXMSGLN 128
142
143/* first srvOPARRAYSIZE reserved for Vice operations */
144#define MAXCNTRS (srvOPARRAYSIZE + 17)
145#define TOTAL 0
146
147#define DISCONNECT ViceDisconnectFS_OP
148#define GETATTRPLUSSHA ViceGetAttrPlusSHA_OP
149#define GETACL ViceGetACL_OP
150#define FETCH ViceFetch_OP
151#define SETACL ViceSetACL_OP
152#define REMOVECALLBACK ViceRemoveCallBack_OP
153#define SETLOCK ViceSetLock_OP
154#define RELEASELOCK ViceReleaseLock_OP
155#define GETROOTVOLUME ViceGetRootVolume_OP
156#define GETVOLUMESTAT ViceGetVolumeStatus_OP
157#define SETVOLUMESTAT ViceSetVolumeStatus_OP
158#define GETTIME ViceGetTime_OP
159#define GETSTATISTICS ViceGetStatistics_OP
160#define GETVOLUMEINFO ViceGetVolumeInfo_OP
161#define RESOLVE ViceResolve_OP
162#define REPAIR ViceRepair_OP
163#define SETVV ViceSetVV_OP
164#define REINTEGRATE ViceReintegrate_OP
165#define ALLOCFIDS ViceAllocFids_OP
166#define VALIDATEATTRSPLUSSHA ViceValidateAttrsPlusSHA_OP
167#define NEWCONNECTFS ViceNewConnectFS_OP
168#define GETVOLVS ViceGetVolVS_OP
169#define VALIDATEVOLS ViceValidateVols_OP
170
171#define FETCHDATAOP (srvOPARRAYSIZE + 1)
172#define FETCHDATA (srvOPARRAYSIZE + 2)
173#define FETCHD1 (srvOPARRAYSIZE + 3)
174#define FETCHD2 (srvOPARRAYSIZE + 4)
175#define FETCHD3 (srvOPARRAYSIZE + 5)
176#define FETCHD4 (srvOPARRAYSIZE + 6)
177#define FETCHD5 (srvOPARRAYSIZE + 7)
178#define FETCHTIME (srvOPARRAYSIZE + 8)
179#define STOREDATAOP (srvOPARRAYSIZE + 9)
180#define STOREDATA (srvOPARRAYSIZE + 10)
181#define STORED1 (srvOPARRAYSIZE + 11)
182#define STORED2 (srvOPARRAYSIZE + 12)
183#define STORED3 (srvOPARRAYSIZE + 13)
184#define STORED4 (srvOPARRAYSIZE + 14)
185#define STORED5 (srvOPARRAYSIZE + 15)
186#define STORETIME (srvOPARRAYSIZE + 16)
187#define SIZE1 1024
188#define SIZE2 SIZE1 * 8
189#define SIZE3 SIZE2 * 8
190#define SIZE4 SIZE3 * 8
191
192/* Timing macros. */
193#define SubTimes(end, start) \
194 ((end.tv_usec > start.tv_usec) ? \
195 (((float)(end.tv_sec - start.tv_sec) * 1000) + \
196 (float)((end.tv_usec - start.tv_usec) / 1000)) : \
197 ((float)((end.tv_sec - start.tv_sec - 1) * 1000) + \
198 (float)((end.tv_usec + 1000000 - start.tv_usec) / 1000)))
199
200/* Macro to perform time_value subtraction t3 = t1 - t2 */
201/* Assume t1 > t2 always */
202#define time_value_sub(t1, t2, t3) \
203 { \
204 if ((t1).microseconds < (t2).microseconds) { \
205 (t1).microseconds += 1000000; \
206 (t1).seconds -= 1; \
207 } \
208 (t3).microseconds = (t1).microseconds - (t2).microseconds; \
209 (t3).seconds = (t1).seconds - (t2).seconds; \
210 }
211#ifdef CODA_DEBUG
212#define START_TIMING(id) \
213 struct timeval start##id, end##id; \
214 if (SrvDebugLevel > 1) \
215 gettimeofday(&start##id, 0);
216
217#define END_TIMING(id) \
218 if (SrvDebugLevel > 1) \
219 gettimeofday(&end##id, 0); \
220 LogMsg(2, SrvDebugLevel, stdout, "%s: start:(%#x.%x) end:(%#x.%x)\n", #id, \
221 start##id.tv_sec, start##id.tv_usec, end##id.tv_sec, \
222 end##id.tv_usec); \
223 LogMsg(2, SrvDebugLevel, stdout, "%s: elapsed = %7.1f", #id, \
224 (float)SubTimes(end##id, start##id));
225#else
226#define START_TIMING(id)
227#define END_TIMING(id)
228#endif
229
230/* ViceErrorMsg.c */
231char *ViceErrorMsg(int);
232
233/* codaproc.c */
234extern ViceVersionVector NullVV;
235long InternalCOP2(RPC2_Handle, ViceStoreId *,
236 ViceVersionVector *) EXCLUDES_TRANSACTION;
237void NewCOP1Update(Volume *, Vnode *, ViceStoreId *, RPC2_Integer * = NULL,
238 bool isReplicated = true);
239void COP2Update(Volume *, Vnode *, ViceVersionVector *);
240long InternalCOP2(RPC2_Handle, ViceStoreId *, ViceVersionVector *);
241void PollAndYield();
242int GetSubTree(ViceFid *, Volume *, dlist *);
243void GetMyVS(Volume *, RPC2_CountedBS *, RPC2_Integer *, int voltype);
244void SetVSStatus(ClientEntry *, Volume *, RPC2_Integer *, CallBackStatus *,
245 int voltype);
246
247/* codaproc2.c */
248int LookupChild(Volume *, Vnode *, char *, ViceFid *);
249int AddChild(Volume **, dlist *, ViceFid *, char *,
250 int = 0) EXCLUDES_TRANSACTION;
251
252/* codasrv.c */
253extern int SystemId, AnyUserId;
254extern int SrvDebugLevel;
255extern unsigned StartTime;
256extern int CurrentConnections;
257extern int Authenticate;
258extern int Counters[];
259extern const ViceFid NullFid;
260extern const int MaxVols;
261extern int pollandyield;
262extern int probingon;
263extern const char *CodaSrvIp;
264
265#ifdef PERFORMANCE
266thread_t *lwpth;
267thread_array_t thread_list;
268int thread_count;
269#endif
270
271void Die(const char *);
272
273/* srv.c */
274void SetStatus(Vnode *, ViceStatus *, Rights, Rights);
275int GetRights(PRS_InternalCPS *, AL_AccessList *, int, Rights *, Rights *);
276int GetFsObj(ViceFid *, Volume **, Vnode **, int, int, int, int,
279int AdjustDiskUsage(Volume *, int);
280void ChangeDiskUsage(Volume *, int);
281int GetVolObj(VolumeId, Volume **, int, int = 0, unsigned = 0);
282void PutVolObj(Volume **, int, int = 0);
283int CheckDiskUsage(Volume *, int);
284void PrintCounters(FILE *fp = stdout);
285
286/* srvproc2.c */
287extern int supported;
288extern unsigned int etherWrites;
289extern unsigned int etherRetries;
290extern unsigned int etherInterupts;
291extern unsigned int etherGoodReads;
292extern unsigned int etherBytesRead;
293extern unsigned int etherBytesWritten;
294int GetEtherStats();
295
296/* vicecb.c */
297extern int CBEs;
298extern int CBEBlocks;
299extern int FEs;
300extern int FEBlocks;
301int InitCallBack();
302CallBackStatus AddCallBack(HostTable *, ViceFid *);
303void BreakCallBack(HostTable *, ViceFid *);
304void DeleteCallBack(HostTable *, ViceFid *);
305void DeleteVenus(HostTable *);
306void DeleteFile(ViceFid *);
307void PrintCallBackState(FILE *);
308void PrintCallBacks(ViceFid *, FILE *);
309CallBackStatus CodaAddCallBack(HostTable *, ViceFid *, VolumeId);
310void CodaBreakCallBack(HostTable *, ViceFid *, VolumeId);
311void CodaDeleteCallBack(HostTable *, ViceFid *, VolumeId);
312
313/* resolution */
314extern int AllowResolution;
315
316/* lookaside */
317extern int AllowSHA;
318
319/* coppend.c */
320void AddToCopPendingTable(ViceStoreId *, ViceFid *);
321
322/* volutil.c */
323void InitVolUtil(int stacksize) EXCLUDES_TRANSACTION;
324
325#endif /* _VICE_SRV_H_ */
Definition: dlist.h:50
unsigned char uint8_t
Definition: coda.h:101
#define EXCLUDES_TRANSACTION
Definition: coda_tsa.h:108
stdout
Definition: volusage.py:12
int32_t RPC2_Integer
Definition: rpc2.h:297
RPC2_Integer RPC2_Handle
Definition: rpc2.h:345
struct HostTable HostTable
int AddChild(Volume **, dlist *, ViceFid *, char *, int=0) EXCLUDES_TRANSACTION
Definition: codaproc2.cc:2054
int AnyUserId
Definition: srv.h:253
int AllowResolution
Definition: dummy.cc:35
void DeleteCallBack(HostTable *, ViceFid *)
Definition: vicecb.cc:492
int InitCallBack()
Definition: vicecb.cc:264
int FEBlocks
Definition: vicecb.cc:87
void GetMyVS(Volume *, RPC2_CountedBS *, RPC2_Integer *, int voltype)
Definition: codaproc.cc:2520
int SystemId
Definition: srv.cc:126
unsigned int etherGoodReads
Definition: srvproc2.cc:101
const ViceFid NullFid
Definition: venusutil.cc:85
int Authenticate
Definition: srv.cc:136
int CBEBlocks
Definition: vicecb.cc:85
#define MAXNAMELENGTH
Definition: srv.h:106
void SetVSStatus(ClientEntry *, Volume *, RPC2_Integer *, CallBackStatus *, int voltype)
Definition: codaproc.cc:2557
int probingon
Definition: srv.cc:134
unsigned StartTime
Definition: srv.cc:127
int SystemUser(ClientEntry *)
Definition: srvproc.cc:982
void ViceUpdateDB()
Definition: srv.cc:975
unsigned int etherBytesRead
Definition: srvproc2.cc:102
void SetStatus(Vnode *, ViceStatus *, Rights, Rights)
Definition: srvproc.cc:696
const int MaxVols
Definition: srv.cc:131
void VPrintCacheStats(FILE *=stdout)
Definition: volume.cc:1880
int AdjustDiskUsage(Volume *, int)
Definition: srvproc.cc:987
int Counters[]
Definition: srv.cc:129
void SwapMalloc()
Definition: srv.cc:1246
void AddToCopPendingTable(ViceStoreId *, ViceFid *)
Definition: coppend.cc:50
int CurrentConnections
Definition: srv.cc:128
void ChangeDiskUsage(Volume *, int)
Definition: srvproc.cc:1026
void SwapLog(int ign)
Definition: srv.cc:1304
void Die(const char *)
Definition: dummy.cc:53
long rvm_no_yield
Definition: rvm_logrecovr.c:46
void CodaDeleteCallBack(HostTable *, ViceFid *, VolumeId)
Definition: vicecb.cc:623
unsigned int etherRetries
Definition: srvproc2.cc:99
int VCheckVLDB()
Definition: vldb.cc:74
CallBackStatus AddCallBack(HostTable *, ViceFid *)
Definition: vicecb.cc:276
int SrvDebugLevel
Definition: util.c:70
unsigned int etherBytesWritten
Definition: srvproc2.cc:103
void PrintCallBacks(ViceFid *, FILE *)
Definition: vicecb.cc:817
int GetVolObj(VolumeId, Volume **, int, int=0, unsigned=0)
Definition: volume.cc:1933
void PutVolObj(Volume **, int, int=0)
Definition: volume.cc:1991
void BreakCallBack(HostTable *, ViceFid *)
Definition: vicecb.cc:343
void DeleteFile(ViceFid *)
Definition: vicecb.cc:553
int GetRights(PRS_InternalCPS *, AL_AccessList *, int, Rights *, Rights *)
Definition: srvproc.cc:731
char * ViceErrorMsg(int)
Definition: ViceErrorMsg.c:66
struct ClientEntry ClientEntry
int GetSubTree(ViceFid *, Volume *, dlist *)
Definition: codaproc.cc:1799
int LookupChild(Volume *, Vnode *, char *, ViceFid *)
Definition: codaproc2.cc:2106
int pollandyield
Definition: srv.cc:142
int AllowSHA
Definition: srv.cc:138
ViceVersionVector NullVV
Definition: dummy.cc:41
void ViceTerminate()
Definition: srv.cc:1347
uint8_t ThisServerId
Definition: volume.cc:102
int CBEs
Definition: vicecb.cc:84
void VAdjustDiskUsage(Error *, Volume *, int)
void NewCOP1Update(Volume *, Vnode *, ViceStoreId *, RPC2_Integer *=NULL, bool isReplicated=true)
Definition: codaproc.cc:2309
bit32 HostAddress[] WARN_SINGLE_HOMING
void InitVolUtil(int stacksize) EXCLUDES_TRANSACTION
Definition: volutil.cc:76
int GetEtherStats()
Definition: srvproc2.cc:827
void PollAndYield()
Definition: dummy.cc:43
void COP2Update(Volume *, Vnode *, ViceVersionVector *)
int FEs
Definition: vicecb.cc:86
int GetFsObj(ViceFid *, Volume **, Vnode **, int, int, int, int, int) EXCLUDES_TRANSACTION
Definition: dummy.cc:60
void CodaBreakCallBack(HostTable *, ViceFid *, VolumeId)
Definition: vicecb.cc:602
const char * CodaSrvIp
Definition: dummy.cc:39
long InternalCOP2(RPC2_Handle, ViceStoreId *, ViceVersionVector *) EXCLUDES_TRANSACTION
Definition: codaproc.cc:2146
CallBackStatus CodaAddCallBack(HostTable *, ViceFid *, VolumeId)
Definition: vicecb.cc:583
void DeleteVenus(HostTable *)
Definition: vicecb.cc:536
void PrintCallBackState(FILE *)
Definition: vicecb.cc:648
int CheckDiskUsage(Volume *, int)
Definition: srvproc.cc:1005
void PrintCounters(FILE *fp=stdout)
Definition: srv.cc:1003
unsigned int etherWrites
Definition: srvproc2.cc:98
int supported
unsigned int etherInterupts
Definition: srvproc2.cc:100
Definition: al.h:48
Definition: srv.h:124
struct dllist_head Clients
Definition: srv.h:126
RPC2_Integer EndTimestamp
Definition: srv.h:136
time_t LastCall
Definition: srv.h:131
RPC2_Integer Id
Definition: srv.h:128
PRS_InternalCPS * CPS
Definition: srv.h:127
RPC2_Integer LastOp
Definition: srv.h:133
HostTable * VenusId
Definition: srv.h:132
RPC2_Handle RPCid
Definition: srv.h:125
int SEType
Definition: srv.h:130
int DoUnbind
Definition: srv.h:134
char UserName[MAXNAMELENGTH]
Definition: srv.h:135
RPC2_Integer SecurityLevel
Definition: srv.h:129
Definition: srv.h:114
time_t ActiveCall
Definition: srv.h:120
struct dllist_head Clients
Definition: srv.h:116
time_t LastCall
Definition: srv.h:119
unsigned int port
Definition: srv.h:118
struct in_addr host
Definition: srv.h:117
RPC2_Handle id
Definition: srv.h:115
struct Lock lock
Definition: srv.h:121
Definition: lock.h:68
Definition: prs.h:46
Definition: rpc2.h:316
Definition: cvnode.h:155
Definition: volume.h:234
Definition: dllist.h:30
uint32_t bit32
Definition: voltypes.h:56
#define NULL
Definition: voltypes.h:44
bit32 Error
Definition: voltypes.h:62
bit32 HostAddress[N_SERVERIDS]
Definition: volume.cc:103