589e84555c273ebf27e9847d4c3f3e7daec03110
[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 statindex 15
12
13 #include        "vl_opcodes.h"
14 %#include       "vl_opcodes.h"  /* directly to other places */
15
16 %#ifdef KERNEL
17 %#define        xdr_array(a,b,c,d,e,f)  xdr_arrayN(a,b,c,d,e,f)
18 %#include "../afs/longc_procs.h"
19 %#endif
20
21 /* Current limitations on parameters that affect other packages (i.e. volume) */
22 const   VLDBVERSION_4   =       4;
23 const   VLDBVERSION     =       3;
24 const   OVLDBVERSION    =       2;
25 const   VL_MAXNAMELEN   =       65;
26 const   OMAXNSERVERS    =       8;
27 const   NMAXNSERVERS    =       13;
28 const   MAXTYPES        =       3;
29
30 /* Structure used by the VLUpdateEntry routine; multiple entries can be updated at once by setting the appropriate Mask bits. */
31 struct VldbUpdateEntry {
32         afs_uint32      Mask;
33         char    name[VL_MAXNAMELEN];
34         afs_int32       spares3;
35         afs_int32       flags;
36         afs_uint32      ReadOnlyId;
37         afs_uint32      BackupId;
38         afs_int32       cloneId;
39         afs_int32       nModifiedRepsites;
40         afs_uint32      RepsitesMask[OMAXNSERVERS];
41         afs_int32       RepsitesTargetServer[OMAXNSERVERS];
42         afs_int32       RepsitesTargetPart[OMAXNSERVERS];
43         afs_int32       RepsitesNewServer[OMAXNSERVERS];
44         afs_int32       RepsitesNewPart[OMAXNSERVERS];
45         afs_int32       RepsitesNewFlags[OMAXNSERVERS];
46 };
47
48 /* struct VldbUpdateEntry Mask bit values */
49 const   VLUPDATE_VOLUMENAME     =       0x0001;
50 /*const VLUPDATE_VOLUMETYPE     =       0x0002;*/
51 const   VLUPDATE_FLAGS          =       0x0004;
52 const   VLUPDATE_READONLYID     =       0x0008;
53 const   VLUPDATE_BACKUPID               =       0x0010;
54 const   VLUPDATE_REPSITES               =       0x0020;
55 const   VLUPDATE_CLONEID                =       0x0080;
56 const   VLUPDATE_VOLNAMEHASH    =       0x0100;
57 const   VLUPDATE_RWID           =       0x0200;
58
59 /* struct VldbUpdateEntry RepsitesMask[i] bit values */
60 const   VLUPDATE_REPS_DELETE    =       0x0100;
61 const   VLUPDATE_REPS_ADD               =       0x0200;
62 const   VLUPDATE_REPS_MODSERV   =       0x0400;
63 const   VLUPDATE_REPS_MODPART   =       0x0800;
64 const   VLUPDATE_REPS_MODFLAG   =       0x1000;
65
66 const   VLSERVER_FLAG_UUID      =       0x0010;
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_int32       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_int32       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_int32       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_int32       cloneId;                        /* Used during cloning */
144         afs_int32       flags;                          /* General flags */
145         afs_int32       spares1;                        /* 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_int32    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
179 /* defines for convenience of vl users */
180 %#define        VLF_RWEXISTS        0x1000  /* flags for whole vldb entry */
181 %#define        VLF_ROEXISTS        0x2000
182 %#define        VLF_BACKEXISTS      0x4000
183 %#define        VLF_DFSFILESET      0x8000  /* Volume is really DFS fileset */
184 %#define        VLSF_NEWREPSITE     0x01    /* flags for indiv. server entry */
185 %#define        VLSF_ROVOL          0x02
186 %#define        VLSF_RWVOL          0x04
187 %#define        VLSF_BACKVOL        0x08
188 %#define        VLSF_DONTUSE        0x20    /* no conflict with VLSERVER_FLAG_UUID */
189
190 typedef vldbentry bulkentries<>;
191 typedef nvldbentry nbulkentries<>;
192 typedef uvldbentry ubulkentries<>;
193 typedef afs_uint32 bulkaddrs<>;
194
195 struct VLCallBack {
196     afs_uint32 CallBackVersion;
197     afs_uint32 ExpirationTime;
198     afs_uint32 CallBackType;
199     afs_uint32 Handle;
200 };
201
202 /* vldb interface calls */
203
204 /*
205  * The kernel needs to be able to use a subset of these.
206  *
207  * Rather than try to make sure the all the kernels have
208  * all the necessary xdr routines for *all* the interfaces,
209  * we arrange that only the ones necessary for the kernel
210  * get compiled in the kernel.
211  */
212
213 /*
214  * VL_Probe was renamed to VL_ProbeServer to avoid namespace collisions
215  * with DFS clients.
216  */
217
218 ProbeServer(
219 ) = VLPROBE;
220
221 /*
222  * VL_GetEntryByName was renamed to VL_GetEntryByNameO to avoid
223  * namespace collisions with DFS clients.
224  */
225
226 GetEntryByNameO(
227   IN string volumename<VL_MAXNAMELEN>,
228   OUT vldbentry *entry
229 ) = VLGETENTRYBYNAME;
230
231 GetEntryByNameN(
232   IN string volumename<VL_MAXNAMELEN>,
233   OUT nvldbentry *entry
234 ) = VLGETENTRYBYNAMEN;
235
236 GetEntryByNameU(
237   IN string volumename<VL_MAXNAMELEN>,
238   OUT uvldbentry *entry
239 ) = VLGETENTRYBYNAMEU;
240
241 GetAddrsU(
242   IN ListAddrByAttributes *inaddr,
243   OUT afsUUID *uuidp1,
244   OUT afs_int32 *uniquifier,
245   OUT afs_int32 *nentries,
246   OUT bulkaddrs *blkaddrs
247 ) = VLGETADDRSU;
248
249 /*
250  * The rest of the interfaces are not needed in the kernel
251  */
252
253 %#if !defined(KERNEL)
254
255 typedef struct single_vldbentry  *vldblist;
256
257 struct single_vldbentry {
258         vldbentry VldbEntry;
259         vldblist next_vldb;
260 };
261
262 struct vldb_list {
263 vldblist node;
264 };
265
266 typedef struct single_nvldbentry  *nvldblist;
267
268 struct single_nvldbentry {
269         nvldbentry VldbEntry;
270         nvldblist next_vldb;
271 };
272
273 struct nvldb_list {
274 nvldblist node;
275 };
276
277 CreateEntry(
278   IN vldbentry *newentry
279 ) = VLCREATEENTRY;
280
281 DeleteEntry(
282   IN afs_int32 Volid,
283   afs_int32 voltype
284 ) = VLDELETEENTRY;
285
286 GetEntryByID(
287   IN afs_int32 Volid,
288   afs_int32 voltype,
289   OUT vldbentry *entry
290 ) = VLGETENTRYBYID;
291
292 GetNewVolumeId(
293   IN afs_int32 bumpcount,
294   OUT afs_int32 *newvolumid
295 ) = VLGETNEWVOLUMEID;
296
297 ReplaceEntry(
298   IN afs_int32 Volid,
299   afs_int32 voltype,
300   vldbentry *newentry,
301   afs_int32 ReleaseType
302 ) = VLREPLACEENTRY;
303
304 UpdateEntry(
305   IN afs_int32 Volid,
306   afs_int32 voltype,
307   VldbUpdateEntry *UpdateEntry,
308   afs_int32 ReleaseType
309 ) = VLUPDATEENTRY;
310
311 SetLock(
312   IN afs_int32 Volid,
313   afs_int32 voltype,
314   afs_int32 voloper
315 ) = VLSETLOCK;
316
317 ReleaseLock(
318   IN afs_int32 Volid,
319   afs_int32 voltype,
320   afs_int32 ReleaseType
321 ) = VLRELEASELOCK;
322
323 ListEntry(
324   IN afs_int32 previous_index,
325   OUT afs_int32 *count,
326   afs_int32 *next_index,
327   vldbentry *entry
328 ) = VLLISTENTRY;
329
330 ListAttributes(
331   IN VldbListByAttributes *attributes,
332   OUT afs_int32 *nentries,
333   OUT bulkentries *blkentries
334 ) = VLLISTATTRIBUTES;
335
336 LinkedList(
337   IN VldbListByAttributes *attributes,
338   OUT afs_int32 *nentries,
339   OUT vldb_list *linkedentries
340 ) = VLLINKEDLIST;
341
342 GetStats(
343   OUT vldstats *stats,
344   vital_vlheader *vital_header
345 ) = VLGETSTATS;
346
347 GetAddrs(
348   IN afs_int32 Handle,
349   afs_int32 spare2,
350   OUT VLCallBack *spare3,
351   OUT afs_int32 *nentries,
352   OUT bulkaddrs *blkaddrs
353 ) = VLGETADDRS;
354
355 ChangeAddr(
356   IN afs_int32 ip1,
357   afs_int32 ip2
358 ) = VLCHANGEADDR;
359
360
361 CreateEntryN(
362   IN nvldbentry *newentry
363 ) = VLCREATEENTRYN;
364
365 GetEntryByIDN(
366   IN afs_int32 Volid,
367   afs_int32 voltype,
368   OUT nvldbentry *entry
369 ) = VLGETENTRYBYIDN;
370
371 ReplaceEntryN(
372   IN afs_int32 Volid,
373   afs_int32 voltype,
374   nvldbentry *newentry,
375   afs_int32 ReleaseType
376 ) = VLREPLACEENTRYN;
377
378 ListEntryN(
379   IN afs_int32 previous_index,
380   OUT afs_int32 *count,
381   afs_int32 *next_index,
382   nvldbentry *entry
383 ) = VLLISTENTRYN;
384
385 ListAttributesN(
386   IN VldbListByAttributes *attributes,
387   OUT afs_int32 *nentries,
388   OUT nbulkentries *blkentries
389 ) = VLLISTATTRIBUTESN;
390
391 LinkedListN(
392   IN VldbListByAttributes *attributes,
393   OUT afs_int32 *nentries,
394   OUT nvldb_list *linkedentries
395 ) = VLLINKEDLISTN;
396
397 UpdateEntryByName(
398   IN string volumename<VL_MAXNAMELEN>,
399   VldbUpdateEntry *UpdateEntry,
400   afs_int32 ReleaseType
401 ) = VLUPDATEENTRYBYNAME;
402
403 RegisterAddrs(
404   IN afsUUID *uuidp,
405   IN afs_int32 spare1,
406   IN bulkaddrs *ipaddr
407 ) = VLREGADDR;
408
409 ListAttributesN2(
410   IN VldbListByAttributes *attributes,
411   IN string volumename<VL_MAXNAMELEN>,
412   IN  afs_int32 startindex,
413   OUT afs_int32 *nentries,
414   OUT nbulkentries *blkentries,
415   OUT afs_int32 *nextstartindex
416 ) = VLLISTATTRIBUTESN2;
417
418 %#endif /* !defined(KERNEL) */