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