Initial IBM OpenAFS 1.0 tree
[openafs.git] / src / vlserver / vldbint.xg
1 /*
2  * (C) COPYRIGHT IBM CORPORATION 1987, 1988
3  * LICENSED MATERIALS - PROPERTY OF IBM
4  */
5
6 package VL_
7 statindex 15
8
9 #include        "vl_opcodes.h"
10 %#include       "vl_opcodes.h"  /* directly to other places */
11
12 %#ifdef KERNEL
13 %#define        xdr_array(a,b,c,d,e,f)  xdr_arrayN(a,b,c,d,e,f)
14 %#include "../afs/longc_procs.h"
15 %#endif
16
17 /* Current limitations on parameters that affect other packages (i.e. volume) */
18 const   VLDBVERSION_4   =       4;
19 const   VLDBVERSION     =       3;
20 const   OVLDBVERSION    =       2;
21 const   VL_MAXNAMELEN   =       65;
22 const   OMAXNSERVERS    =       8;
23 const   NMAXNSERVERS    =       13;
24 const   MAXTYPES        =       3;
25
26 /* Structure used by the VLUpdateEntry routine; multiple entries can be updated at once by setting the appropriate Mask bits. */
27 struct VldbUpdateEntry {
28         afs_uint32      Mask;
29         char    name[VL_MAXNAMELEN];
30         afs_int32       spares3;
31         afs_int32       flags;
32         afs_uint32      ReadOnlyId;
33         afs_uint32      BackupId;
34         afs_int32       cloneId;
35         afs_int32       nModifiedRepsites;
36         afs_uint32      RepsitesMask[OMAXNSERVERS];
37         afs_int32       RepsitesTargetServer[OMAXNSERVERS];
38         afs_int32       RepsitesTargetPart[OMAXNSERVERS];
39         afs_int32       RepsitesNewServer[OMAXNSERVERS];
40         afs_int32       RepsitesNewPart[OMAXNSERVERS];
41         afs_int32       RepsitesNewFlags[OMAXNSERVERS];
42 };
43
44 /* struct VldbUpdateEntry Mask bit values */
45 const   VLUPDATE_VOLUMENAME     =       0x0001;
46 /*const VLUPDATE_VOLUMETYPE     =       0x0002;*/
47 const   VLUPDATE_FLAGS          =       0x0004;
48 const   VLUPDATE_READONLYID     =       0x0008;
49 const   VLUPDATE_BACKUPID               =       0x0010;
50 const   VLUPDATE_REPSITES               =       0x0020;
51 const   VLUPDATE_CLONEID                =       0x0080;
52 const   VLUPDATE_VOLNAMEHASH    =       0x0100;
53 const   VLUPDATE_RWID           =       0x0200;
54
55 /* struct VldbUpdateEntry RepsitesMask[i] bit values */
56 const   VLUPDATE_REPS_DELETE    =       0x0100;
57 const   VLUPDATE_REPS_ADD               =       0x0200;
58 const   VLUPDATE_REPS_MODSERV   =       0x0400;
59 const   VLUPDATE_REPS_MODPART   =       0x0800;
60 const   VLUPDATE_REPS_MODFLAG   =       0x1000;
61
62 const   VLSERVER_FLAG_UUID      =       0x0010;
63
64 /*typedef       string volumename<VL_MAXNAMELEN>;*/
65
66 const   DEFAULTBULK     =       10000;
67 typedef opaque bulk<DEFAULTBULK>;
68
69 /*  Structure used by the VLListAttributes routine */
70 struct VldbListByAttributes {
71         afs_uint32      Mask;
72         afs_int32       server;
73         afs_int32       partition;
74         afs_int32       spares3;
75         afs_int32       volumeid;
76         afs_int32       flag;
77 };
78
79 /* struct VldbListByAttributes Mask bit values */
80 const   VLLIST_SERVER   =       0x1;
81 const   VLLIST_PARTITION=       0x2;
82 /*const VLLIST_VOLUMETYPE=      0x4;*/
83 const   VLLIST_VOLUMEID=                0x8;
84 const   VLLIST_FLAG=            0x10;
85
86 /* External (visible) representation of an individual vldb entry */
87 struct vldbentry   {
88         char    name[VL_MAXNAMELEN];            /* Volume name */
89         afs_int32       spares3;
90         afs_int32       nServers;                       /* Number of servers that have this volume */
91         afs_int32       serverNumber[OMAXNSERVERS];     /* Server # for each server that holds volume */
92         afs_int32       serverPartition[OMAXNSERVERS];  /* Server Partition number */
93         afs_int32       serverFlags[OMAXNSERVERS];      /* Server flags */
94         afs_uint32      volumeId[MAXTYPES];             /* Corresponding volume of each type */
95         afs_int32       cloneId;                                /* Used during cloning */
96         afs_int32       flags;                          /* General flags */
97 };
98
99 struct nvldbentry   {
100         char    name[VL_MAXNAMELEN];            /* Volume name */
101         afs_int32       nServers;                       /* Number of servers that have this volume */
102         afs_int32       serverNumber[NMAXNSERVERS];     /* Server # for each server that holds volume */
103         afs_int32       serverPartition[NMAXNSERVERS];  /* Server Partition number */
104         afs_int32       serverFlags[NMAXNSERVERS];      /* Server flags */
105         afs_uint32      volumeId[MAXTYPES];             /* Corresponding volume of each type */
106         afs_int32       cloneId;                        /* Used during cloning */
107         afs_int32       flags;                          /* General flags */
108         afs_int32       matchindex;
109         afs_int32       spares2;
110         afs_int32       spares3;
111         afs_int32       spares4;
112         afs_int32       spares5;
113         afs_int32       spares6;
114         afs_int32       spares7;
115         afs_int32       spares8;
116         afs_int32       spares9;
117 };
118
119
120 struct ListAddrByAttributes {
121         afs_int32       Mask;
122         afs_uint32      ipaddr;
123         afs_int32       index;
124         afs_int32       spare1;
125         afsUUID uuid;
126 };
127 const   VLADDR_IPADDR   =       0x1;
128 const   VLADDR_INDEX    =       0x2;
129 const   VLADDR_UUID     =       0x4;
130
131 struct uvldbentry   {
132         char    name[VL_MAXNAMELEN];            /* Volume name */
133         afs_int32       nServers;                       /* Number of servers that have this volume */
134         afsUUID serverNumber[NMAXNSERVERS];     /* Server # for each server that holds volume */
135         afs_int32       serverUnique[NMAXNSERVERS];     /* Server unique address */
136         afs_int32       serverPartition[NMAXNSERVERS];  /* Server Partition number */
137         afs_int32       serverFlags[NMAXNSERVERS];      /* Server flags */
138         afs_uint32      volumeId[MAXTYPES];             /* Corresponding volume of each type */
139         afs_int32       cloneId;                        /* Used during cloning */
140         afs_int32       flags;                          /* General flags */
141         afs_int32       spares1;                        /* The server index we matched */
142         afs_int32       spares2;
143         afs_int32       spares3;
144         afs_int32       spares4;
145         afs_int32       spares5;
146         afs_int32       spares6;
147         afs_int32       spares7;
148         afs_int32       spares8;
149         afs_int32       spares9;
150 };
151
152
153 /* Leading section of the vldb header (vlheader); contains frequently used globals and general statistics information */
154 struct vital_vlheader {
155     afs_int32    vldbversion;               /* vldb version number--must be 1st */
156     afs_int32    headersize;                /* total bytes in header */
157     afs_int32    freePtr;                           /* first (if any) free enry in freelist */
158     afs_int32    eofPtr;                            /* first free byte in file */
159     afs_int32    allocs;                            /* total calls to AllocBlock */
160     afs_int32    frees;                     /* total calls to FreeBlock */
161     afs_int32    MaxVolumeId;               /* Global volume id holder */
162     afs_int32    totalEntries[MAXTYPES];            /* Total entries by voltype in vldb */
163 };
164
165 /* General stats on opcode hit frequency */
166 const   MAX_NUMBER_OPCODES      = 50;
167 struct vldstats {
168     afs_uint32 start_time;                      /* Time statistics were last cleared */
169     afs_int32 requests[MAX_NUMBER_OPCODES];     /* requests of each type */
170     afs_int32 aborts[MAX_NUMBER_OPCODES];               /* aborts of each type */
171     afs_int32 reserved[5];                              /* for future usage */
172 };
173
174
175 /* defines for convenience of vl users */
176 %#define        VLF_RWEXISTS        0x1000  /* flags for whole vldb entry */
177 %#define        VLF_ROEXISTS        0x2000
178 %#define        VLF_BACKEXISTS      0x4000
179 %#define        VLF_DFSFILESET      0x8000  /* Volume is really DFS fileset */
180 %#define        VLSF_NEWREPSITE     0x01    /* flags for indiv. server entry */
181 %#define        VLSF_ROVOL          0x02
182 %#define        VLSF_RWVOL          0x04
183 %#define        VLSF_BACKVOL        0x08
184 %#define        VLSF_DONTUSE        0x20    /* no conflict with VLSERVER_FLAG_UUID */
185
186 typedef vldbentry bulkentries<>;
187 typedef nvldbentry nbulkentries<>;
188 typedef uvldbentry ubulkentries<>;
189 typedef afs_uint32 bulkaddrs<>;
190
191 struct VLCallBack {
192     afs_uint32 CallBackVersion;
193     afs_uint32 ExpirationTime;
194     afs_uint32 CallBackType;
195     afs_uint32 Handle;
196 };
197
198 /* vldb interface calls */
199
200 /*
201  * The kernel needs to be able to use a subset of these.
202  *
203  * Rather than try to make sure the all the kernels have
204  * all the necessary xdr routines for *all* the interfaces,
205  * we arrange that only the ones necessary for the kernel
206  * get compiled in the kernel.
207  */
208
209 /*
210  * VL_Probe was renamed to VL_ProbeServer to avoid namespace collisions
211  * with DFS clients.
212  */
213
214 ProbeServer(
215 ) = VLPROBE;
216
217 /*
218  * VL_GetEntryByName was renamed to VL_GetEntryByNameO to avoid
219  * namespace collisions with DFS clients.
220  */
221
222 GetEntryByNameO(
223   IN string volumename<VL_MAXNAMELEN>,
224   OUT vldbentry *entry
225 ) = VLGETENTRYBYNAME;
226
227 GetEntryByNameN(
228   IN string volumename<VL_MAXNAMELEN>,
229   OUT nvldbentry *entry
230 ) = VLGETENTRYBYNAMEN;
231
232 GetEntryByNameU(
233   IN string volumename<VL_MAXNAMELEN>,
234   OUT uvldbentry *entry
235 ) = VLGETENTRYBYNAMEU;
236
237 GetAddrsU(
238   IN ListAddrByAttributes *inaddr,
239   OUT afsUUID *uuidp1,
240   OUT afs_int32 *uniquifier,
241   OUT afs_int32 *nentries,
242   OUT bulkaddrs *blkaddrs
243 ) = VLGETADDRSU;
244
245 /*
246  * The rest of the interfaces are not needed in the kernel
247  */
248
249 %#if !defined(KERNEL)
250
251 typedef struct single_vldbentry  *vldblist;
252
253 struct single_vldbentry {
254         vldbentry VldbEntry;
255         vldblist next_vldb;
256 };
257
258 struct vldb_list {
259 vldblist node;
260 };
261
262 typedef struct single_nvldbentry  *nvldblist;
263
264 struct single_nvldbentry {
265         nvldbentry VldbEntry;
266         nvldblist next_vldb;
267 };
268
269 struct nvldb_list {
270 nvldblist node;
271 };
272
273 CreateEntry(
274   IN vldbentry *newentry
275 ) = VLCREATEENTRY;
276
277 DeleteEntry(
278   IN afs_int32 Volid,
279   afs_int32 voltype
280 ) = VLDELETEENTRY;
281
282 GetEntryByID(
283   IN afs_int32 Volid,
284   afs_int32 voltype,
285   OUT vldbentry *entry
286 ) = VLGETENTRYBYID;
287
288 GetNewVolumeId(
289   IN afs_int32 bumpcount,
290   OUT afs_int32 *newvolumid
291 ) = VLGETNEWVOLUMEID;
292
293 ReplaceEntry(
294   IN afs_int32 Volid,
295   afs_int32 voltype,
296   vldbentry *newentry,
297   afs_int32 ReleaseType
298 ) = VLREPLACEENTRY;
299
300 UpdateEntry(
301   IN afs_int32 Volid,
302   afs_int32 voltype,
303   VldbUpdateEntry *UpdateEntry,
304   afs_int32 ReleaseType
305 ) = VLUPDATEENTRY;
306
307 SetLock(
308   IN afs_int32 Volid,
309   afs_int32 voltype,
310   afs_int32 voloper
311 ) = VLSETLOCK;
312
313 ReleaseLock(
314   IN afs_int32 Volid,
315   afs_int32 voltype,
316   afs_int32 ReleaseType
317 ) = VLRELEASELOCK;
318
319 ListEntry(
320   IN afs_int32 previous_index,
321   OUT afs_int32 *count,
322   afs_int32 *next_index,
323   vldbentry *entry
324 ) = VLLISTENTRY;
325
326 ListAttributes(
327   IN VldbListByAttributes *attributes,
328   OUT afs_int32 *nentries,
329   OUT bulkentries *blkentries
330 ) = VLLISTATTRIBUTES;
331
332 LinkedList(
333   IN VldbListByAttributes *attributes,
334   OUT afs_int32 *nentries,
335   OUT vldb_list *linkedentries
336 ) = VLLINKEDLIST;
337
338 GetStats(
339   OUT vldstats *stats,
340   vital_vlheader *vital_header
341 ) = VLGETSTATS;
342
343 GetAddrs(
344   IN afs_int32 Handle,
345   afs_int32 spare2,
346   OUT VLCallBack *spare3,
347   OUT afs_int32 *nentries,
348   OUT bulkaddrs *blkaddrs
349 ) = VLGETADDRS;
350
351 ChangeAddr(
352   IN afs_int32 ip1,
353   afs_int32 ip2
354 ) = VLCHANGEADDR;
355
356
357 CreateEntryN(
358   IN nvldbentry *newentry
359 ) = VLCREATEENTRYN;
360
361 GetEntryByIDN(
362   IN afs_int32 Volid,
363   afs_int32 voltype,
364   OUT nvldbentry *entry
365 ) = VLGETENTRYBYIDN;
366
367 ReplaceEntryN(
368   IN afs_int32 Volid,
369   afs_int32 voltype,
370   nvldbentry *newentry,
371   afs_int32 ReleaseType
372 ) = VLREPLACEENTRYN;
373
374 ListEntryN(
375   IN afs_int32 previous_index,
376   OUT afs_int32 *count,
377   afs_int32 *next_index,
378   nvldbentry *entry
379 ) = VLLISTENTRYN;
380
381 ListAttributesN(
382   IN VldbListByAttributes *attributes,
383   OUT afs_int32 *nentries,
384   OUT nbulkentries *blkentries
385 ) = VLLISTATTRIBUTESN;
386
387 LinkedListN(
388   IN VldbListByAttributes *attributes,
389   OUT afs_int32 *nentries,
390   OUT nvldb_list *linkedentries
391 ) = VLLINKEDLISTN;
392
393 UpdateEntryByName(
394   IN string volumename<VL_MAXNAMELEN>,
395   VldbUpdateEntry *UpdateEntry,
396   afs_int32 ReleaseType
397 ) = VLUPDATEENTRYBYNAME;
398
399 RegisterAddrs(
400   IN afsUUID *uuidp,
401   IN afs_int32 spare1,
402   IN bulkaddrs *ipaddr
403 ) = VLREGADDR;
404
405 ListAttributesN2(
406   IN VldbListByAttributes *attributes,
407   IN string volumename<VL_MAXNAMELEN>,
408   IN  afs_int32 startindex,
409   OUT afs_int32 *nentries,
410   OUT nbulkentries *blkentries,
411   OUT afs_int32 *nextstartindex
412 ) = VLLISTATTRIBUTESN2;
413
414 %#endif /* !defined(KERNEL) */