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