add-volupdate-counter-20051015
[openafs.git] / src / volser / volint.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 /*
11  *  Module:         Volint.xg
12  *  System:         Volser
13  *  Instituition:           ITC, CMU
14  *  Date:                   December, 88
15  */
16
17 package AFSVol
18 prefix S
19 statindex 16
20
21 #define     VOLCREATEVOLUME     100
22 #define     VOLDELETEVOLUME     101
23 #define     VOLRESTORE          102
24 #define     VOLFORWARD          103
25 #define     VOLENDTRANS         104
26 #define     VOLCLONE            105
27 #define     VOLSETFLAGS         106
28 #define     VOLGETFLAGS         107
29 #define     VOLTRANSCREATE      108
30 #define     VOLDUMP             109
31 #define     VOLGETNTHVOLUME     110
32 #define     VOLSETFORWARDING    111  /* defunct */
33 #define     VOLGETNAME          112
34 #define     VOLGETSTATUS        113
35 #define             VOLSIGRESTORE       114
36 #define     VOLLISTPARTITIONS   115
37 #define     VOLLISTVOLS         116
38 #define             VOLSETIDSTYPES      117
39 #define             VOLMONITOR          118
40 #define             VOLDISKPART 119
41 #define         VOLRECLONE      120
42 #define     VOLLISTONEVOL       121
43 #define         VOLNUKE         122
44 #define         VOLSETDATE      123
45 #define         VOLXLISTVOLS    124
46 #define         VOLXLISTONEVOL  125
47 #define     VOLSETINFO          126
48 #define     VOLXLISTPARTITIONS  127
49 #define     VOLFORWARDMULTIPLE  128
50 #define     VOLCONVERTRO        65536
51 #define     VOLGETSIZE          65537
52
53 const SIZE = 1024;
54
55 struct volser_status {
56         afs_int32 volID;                /* Volume id--unique over all systems */
57         afs_int32 nextUnique;           /* Next vnode uniquifier for this volume */
58         int type;                       /* readwrite, etc. */
59         afs_int32 parentID;             /* Id of parent, if type==readonly or backup */
60         afs_int32 cloneID;              /* Latest read-only clone, if type==readwrite */
61         afs_int32 backupID;             /* Latest backup copy of this read write volume */
62         afs_int32 restoredFromID;       /* The id in a dump this volume was restored from--used simply
63                                    to make sure that an incremental dump is not restored on top
64                                    of something inappropriate:  Note:  this field itself is NEVER
65                                    dumped!!! */
66         afs_int32 maxQuota;             /* Quota maximum, 1K blocks */
67         afs_int32 minQuota;             /* Quota minimum, 1K blocks */
68         afs_int32 owner;                /* The person responsible for this volume */
69         afs_int32 creationDate;         /* Creation date for a read/write
70                                    volume; cloning date for original copy of
71                                    a readonly volume (replicated volumes have
72                                    the same creation date) */
73         afs_int32 accessDate;           /* Last access time by a user, large granularity */
74         afs_int32 updateDate;           /* Last modification by user */
75         afs_int32 expirationDate;               /* 0 if it never expires */
76         afs_int32 backupDate;           /* last time a backup clone was taken */
77         afs_int32 copyDate;             /* Time that this copy of this volume was created */
78 };
79
80 struct destServer {
81     afs_int32 destHost;
82     afs_int32 destPort;
83     afs_int32 destSSID;
84 };
85
86
87 struct volintInfo {
88 #define VNAMESIZE 32
89     char name[VNAMESIZE];
90     afs_int32 volid;            /* volume's id */
91     afs_int32 type;             /* read-only, read-write, backup */
92     afs_int32 backupID;
93     afs_int32 parentID;
94     afs_int32 cloneID;
95     afs_int32 status;
96     afs_int32 copyDate;
97     unsigned char inUse;
98     unsigned char needsSalvaged;
99     unsigned char destroyMe;
100     afs_int32 creationDate;
101     afs_int32 accessDate;
102     afs_int32 updateDate;
103     afs_int32 backupDate;
104     int dayUse;
105     int filecount;
106     int maxquota;
107     int size;
108     afs_int32 flags;            /* used by the backup system */
109     afs_int32 spare0;           /* Used to hold the minquota value */
110     afs_int32 spare1;           /* Used to hold the weekuse value */
111     afs_int32 spare2;           /* Used to hold volUpdateCounter */
112     afs_int32 spare3;
113 };
114
115 /*
116  * Define some values needed for the detailed volume info structure.
117  */
118 const VOLINT_STATS_NUM_RWINFO_FIELDS = 4;
119
120 const VOLINT_STATS_SAME_NET      = 0;   /*Within same site (total)*/
121 const VOLINT_STATS_SAME_NET_AUTH = 1;   /*Within same site (authenticated);
122                                           (must be 1 more than above)*/
123 const VOLINT_STATS_DIFF_NET      = 2;   /*From external site (total)*/
124 const VOLINT_STATS_DIFF_NET_AUTH = 3;   /*From external site (authenticated)
125                                           (must be 1 more than above)*/
126
127 const VOLINT_STATS_NUM_TIME_RANGES = 6;
128
129 const VOLINT_STATS_TIME_CAP_0   =     60;  /*60 seconds*/
130 const VOLINT_STATS_TIME_CAP_1   =    600;  /*10 minutes, in seconds*/
131 const VOLINT_STATS_TIME_CAP_2   =   3600;  /*1 hour, in seconds*/
132 const VOLINT_STATS_TIME_CAP_3   =  86400;  /*1 day, in seconds*/
133 const VOLINT_STATS_TIME_CAP_4   = 604800;  /*1 week, in seconds*/
134
135 const VOLINT_STATS_NUM_TIME_FIELDS = 6;
136
137 const VOLINT_STATS_TIME_IDX_0 = 0;      /*0 secs to 60 secs*/
138 const VOLINT_STATS_TIME_IDX_1 = 1;      /*1 min to 10 mins*/
139 const VOLINT_STATS_TIME_IDX_2 = 2;      /*10 mins to 60 mins*/
140 const VOLINT_STATS_TIME_IDX_3 = 3;      /*1 hr to 24 hrs*/
141 const VOLINT_STATS_TIME_IDX_4 = 4;      /*1 day to 7 days*/
142 const VOLINT_STATS_TIME_IDX_5 = 5;      /*Greater than 1 week*/
143
144 /*
145  * More detailed volume info
146  */
147 struct volintXInfo {
148     char name[VNAMESIZE];
149     afs_int32 volid;                    /*Volume's ID*/
150     afs_int32 type;                     /*RWVOL, ROVOL, BACKVOL*/
151     afs_int32 backupID;         /*Backup volume ID*/
152     afs_int32 parentID;         /*Parent volume ID*/
153     afs_int32 cloneID;          /*Clone volume ID*/
154     afs_int32 status;           /*Volume status*/
155     afs_int32 copyDate;         /*Date when this volume INSTANCE created*/
156     unsigned char inUse;        /*In use at time of last crash?*/
157     afs_int32 creationDate;             /*Date when this volume was created*/
158     afs_int32 accessDate;               /*Date when this volume was last accessed*/
159     afs_int32 updateDate;               /*Date when this volume was last updated*/
160     afs_int32 backupDate;               /*Date when this volume was last backed up*/
161     int dayUse;                 /*Number of accesses since midnight*/
162     int filecount;              /*Number of files in the volume*/
163     int maxquota;               /*Max volume quota, in Kbytes*/
164     int size;                   /*Current size in Kbytes*/
165     /*
166      * Detailed statistics for reads/writes and authorship.
167      */
168     afs_int32 stat_reads[VOLINT_STATS_NUM_RWINFO_FIELDS];
169     afs_int32 stat_writes[VOLINT_STATS_NUM_RWINFO_FIELDS];
170     afs_int32 stat_fileSameAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
171     afs_int32 stat_fileDiffAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
172     afs_int32 stat_dirSameAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
173     afs_int32 stat_dirDiffAuthor[VOLINT_STATS_NUM_TIME_FIELDS];
174 };
175
176 struct transDebugInfo {
177         afs_int32 tid;           /*transaction id */
178         afs_int32 time;  /* time transaction was last active (for timeouts) */
179         afs_int32 creationTime;    /* time the transaction started */
180         afs_int32 returnCode;       /* transaction error code */
181         afs_int32 volid;        /*sequence number of the next packet to be read*/ /* open volume's id */
182         afs_int32 partition;        /* open volume's partition */
183         short iflags;       /* initial attach mode flags (IT*) */
184         char vflags;        /* current volume status flags (VT*) */
185         char tflags;        /* transaction flags (TT*) */
186         char lastProcName[30];  /* name of the last procedure which used transaction */
187         int callValid;  /*flag which determines if following data is valid*/
188         afs_int32 readNext;     /*sequence number of the next packet to be read*/
189         afs_int32 transmitNext; /*sequence number of the next packet to be transmitted*/
190         int lastSendTime;
191         int lastReceiveTime;
192 };
193
194 struct pIDs {
195         afs_int32 partIds[26];
196 };
197
198 struct diskPartition {
199          char   name[32];       /* Mounted partition name */
200          char   devName[32];    
201          int    lock_fd;
202         int     totalUsable;
203         int     free;
204         int     minFree;
205
206 };
207
208 struct restoreCookie {
209         char name[32];
210         afs_int32 type;
211         afs_int32 clone;
212         afs_int32 parent;
213 };
214
215 struct replica {
216         afs_int32 trans;
217         struct destServer server;
218 };
219
220 /*  Various size parameters of the volume  */
221 struct volintSize {
222     afs_uint64 dump_size;
223 };
224
225 typedef  replica manyDests<>;
226 typedef  afs_int32 manyResults<>;
227 typedef  transDebugInfo transDebugEntries<>;
228 typedef  volintInfo volEntries<>;
229 typedef  afs_int32 partEntries<>;
230 typedef  volintXInfo volXEntries<>;
231
232 proc CreateVolume(
233   IN afs_int32 partition,
234   string name<>,
235   IN afs_int32 type,
236   IN afs_int32 parent,
237   INOUT afs_int32 *volid,
238   OUT afs_int32 *trans
239 ) = VOLCREATEVOLUME;
240
241 proc DeleteVolume(
242   IN afs_int32 trans
243 ) = VOLDELETEVOLUME;
244
245 proc Restore(
246   IN afs_int32 toTrans,
247   IN afs_int32 flags,
248   IN struct restoreCookie *cookie
249 ) split = VOLRESTORE;
250
251 proc Forward(
252   IN afs_int32 fromTrans,
253   IN afs_int32 fromDate,
254   IN struct destServer *destination,
255   IN afs_int32 destTrans,
256   IN struct restoreCookie *cookie
257 ) = VOLFORWARD;
258
259 proc EndTrans(
260   IN afs_int32 trans,
261   OUT afs_int32 *rcode
262 ) = VOLENDTRANS;
263
264 proc Clone(
265   IN afs_int32 trans,
266   IN afs_int32 purgeVol,
267   IN afs_int32 newType,
268   IN string newName<>,
269   INOUT afs_int32 *newVol
270 ) = VOLCLONE;
271
272 proc SetFlags(
273   IN afs_int32 trans,
274   IN afs_int32 flags
275 ) = VOLSETFLAGS;
276
277 proc GetFlags(
278   IN afs_int32 trans,
279   OUT afs_int32 *flags
280 ) = VOLGETFLAGS;
281
282 proc TransCreate(
283   IN afs_int32 volume,
284   IN afs_int32 partition,
285   IN afs_int32 flags,
286   OUT afs_int32 *trans
287 ) = VOLTRANSCREATE;
288
289 proc Dump(
290   IN afs_int32 fromTrans,
291   IN afs_int32 fromDate
292 ) split = VOLDUMP;
293
294 proc GetNthVolume(
295   IN afs_int32 index,
296   OUT afs_int32 *volume,
297   OUT afs_int32 *partition
298 ) = VOLGETNTHVOLUME;
299
300 proc SetForwarding(
301   IN afs_int32 tid,
302   IN afs_int32 newsite
303 ) = VOLSETFORWARDING;
304
305 proc GetName(
306   IN afs_int32 tid,
307   OUT string tname<256>
308 ) = VOLGETNAME;
309
310 proc GetStatus(
311   IN afs_int32 tid,
312   OUT struct volser_status *status
313 ) = VOLGETSTATUS;
314
315 proc SignalRestore(
316   IN string name<>,
317   int type,
318   afs_int32 pid,
319   afs_int32 cloneid
320 ) = VOLSIGRESTORE;
321
322 proc ListPartitions(
323   OUT struct pIDs *partIDs
324 ) = VOLLISTPARTITIONS;
325
326 proc ListVolumes(
327   IN afs_int32 partID,
328   afs_int32 flags,
329   OUT volEntries *resultEntries
330 ) = VOLLISTVOLS;
331
332 proc SetIdsTypes(
333   IN afs_int32 tId,
334   string name<>,
335   afs_int32 type,
336   afs_int32 pId,
337   afs_int32 cloneId,
338   afs_int32 backupId
339 ) = VOLSETIDSTYPES;
340
341 proc Monitor(
342   OUT transDebugEntries *result
343 ) = VOLMONITOR;
344
345 proc PartitionInfo(
346   IN string name<>,
347   OUT struct diskPartition *partition
348 ) = VOLDISKPART;
349
350 proc ReClone(
351   IN afs_int32 tid,
352   afs_int32 cloneID
353 ) = VOLRECLONE;
354
355 proc ListOneVolume(
356   IN afs_int32 partID,
357   afs_int32 volid,
358   OUT volEntries *resultEntries
359 ) = VOLLISTONEVOL;
360
361 proc NukeVolume(
362   IN afs_int32 partID,
363   afs_int32 volID
364 ) = VOLNUKE;
365
366 proc SetDate(
367   IN afs_int32 tid,
368   afs_int32 newDate
369 ) = VOLSETDATE;
370
371 proc XListVolumes(
372   IN afs_int32 partID,
373   afs_int32 flags,
374   OUT volXEntries *resultXEntriesP
375 ) = VOLXLISTVOLS;
376
377 proc XListOneVolume(
378   IN afs_int32 partID,
379   afs_int32 volid,
380   OUT volXEntries *resultXEntries
381 ) = VOLXLISTONEVOL;
382
383 proc SetInfo(
384   IN afs_int32 tid,
385   struct volintInfo *status
386 ) = VOLSETINFO;
387
388 proc XListPartitions(
389   OUT struct partEntries *partIDs
390 ) = VOLXLISTPARTITIONS;
391
392 proc ForwardMultiple(
393   IN afs_int32 fromTrans,
394   IN afs_int32 fromDate,
395   IN manyDests *destinations,
396   IN afs_int32 spare,
397   IN struct restoreCookie *cookie,
398   OUT manyResults *results
399 ) = VOLFORWARDMULTIPLE;
400
401 proc ConvertROtoRWvolume(
402   IN afs_int32 partid,
403   IN afs_int32 volid
404 ) = VOLCONVERTRO;
405
406 proc GetSize(
407   IN afs_int32 fromTrans,
408   IN afs_int32 fromDate,
409   OUT struct volintSize *size
410 ) = VOLGETSIZE;