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