Clean up assertion
[openafs.git] / src / volser / volser.p.h
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 #ifndef _VOLSER_
11 #define _VOLSER_ 1
12
13 #ifdef AFS_PTHREAD_ENV
14 #include <pthread.h>
15 #endif
16
17 #include <afs/voldefs.h>
18
19 /* vflags, representing state of the volume */
20 #define VTDeleteOnSalvage       1       /* delete on next salvage */
21 #define VTOutOfService          2       /* never put this volume online */
22 #define VTDeleted               4       /* deleted, don't do anything else */
23
24 /* iflags, representing "attach mode" for this volume at the start of this transaction */
25 #define ITOffline       1       /* volume offline on server (returns VOFFLINE) */
26 #define ITBusy          2       /* volume busy on server (returns VBUSY) */
27 #define ITReadOnly      8       /* volume readonly on client, readwrite on server -DO NOT USE */
28 #define ITCreate        0x10    /* volume does not exist correctly yet */
29 #define ITCreateVolID   0x1000  /* create volid */
30
31 /* tflags, representing transaction state */
32 #define TTDeleted       1       /* delete transaction not yet freed due  to high refCount */
33
34 /* other names for volumes in voldefs.h */
35 #define volser_RW       0
36 #define volser_RO       1
37 #define volser_BACK     2
38
39 #define THOLD(tt)       ((tt)->refCount++)
40
41 struct volser_trans {
42     struct volser_trans *next;  /* next ptr in active trans list */
43     afs_int32 tid;              /* transaction id */
44     afs_int32 time;             /* time transaction was last active (for timeouts) */
45     afs_int32 creationTime;     /* time the transaction started */
46     afs_int32 returnCode;       /* transaction error code */
47     struct Volume *volume;      /* pointer to open volume */
48     afs_uint32 volid;           /* open volume's id */
49     afs_int32 partition;        /* open volume's partition */
50     afs_int32 dumpTransId;      /* other side's trans id during a dump */
51     afs_int32 dumpSeq;          /* next sequence number to use during a dump */
52     short refCount;             /* reference count on this structure */
53     short iflags;               /* initial attach mode flags (IT*) */
54     char vflags;                /* current volume status flags (VT*) */
55     char tflags;                /* transaction flags (TT*) */
56     char incremental;           /* do an incremental restore */
57     /* the fields below are useful for debugging */
58     char lastProcName[30];      /* name of the last procedure which used transaction */
59     struct rx_call *rxCallPtr;  /* pointer to latest associated rx_call */
60 #ifdef AFS_PTHREAD_ENV
61     pthread_mutex_t lock;       /* per transaction lock */
62 #endif
63
64 };
65
66 /* This is how often the garbage collection thread wakes up and
67  * checks for transactions that have timed out: BKGLoop()
68  */
69 #define GCWAKEUP            30
70
71 #ifdef AFS_PTHREAD_ENV
72 #define VTRANS_OBJ_LOCK_INIT(tt) \
73   MUTEX_INIT(&((tt)->lock), "vtrans obj", MUTEX_DEFAULT, 0);
74 #define VTRANS_OBJ_LOCK_DESTROY(tt) \
75   MUTEX_DESTROY(&((tt)->lock))
76 #define VTRANS_OBJ_LOCK(tt) \
77   MUTEX_ENTER(&((tt)->lock))
78 #define VTRANS_OBJ_UNLOCK(tt) \
79   MUTEX_EXIT(&((tt)->lock))
80 #else
81 #define VTRANS_OBJ_LOCK_INIT(tt)
82 #define VTRANS_OBJ_LOCK_DESTROY(tt)
83 #define VTRANS_OBJ_LOCK(tt)
84 #define VTRANS_OBJ_UNLOCK(tt)
85 #endif /* AFS_PTHREAD_ENV */
86
87 #define MAXHELPERS          10
88 /* flags for vol helper busyFlags array.  First, VHIdle goes on when a server
89  * becomes idle.  Next, idle flag is cleared and VHRequest goes on when
90  * trans is queued.  Finally, VHRequest goes off (but VHIdle stays off) when
91  * helper is done.  VHIdle goes on again when an lwp waits for work.
92  */
93 #define VHIdle              1   /* vol helper is waiting for a request here */
94 #define VHRequest           2   /* a request has been queued here */
95 extern struct volser_trans *QI_GlobalWriteTrans;
96
97 /* the stuff below is from errors.h in vol directory */
98 #define VICE_SPECIAL_ERRORS     101     /* Lowest special error code */
99
100 #define VSALVAGE        101     /* Volume needs salvage */
101 #define VNOVNODE        102     /* Bad vnode number quoted */
102 #define VNOVOL          103     /* Volume not attached, doesn't exist,
103                                  * not created or not online */
104 #define VVOLEXISTS      104     /* Volume already exists */
105 #define VNOSERVICE      105     /* Volume is not in service (i.e. it's
106                                  * is out of funds, is obsolete, or somesuch) */
107 #define VOFFLINE        106     /* Volume is off line, for the reason
108                                  * given in the offline message */
109 #define VONLINE         107     /* Volume is already on line */
110 #define VDISKFULL       108     /* Partition is "full", i.e. rougly within
111                                  * n% of full */
112 #define VOVERQUOTA      109     /* Volume max quota exceeded */
113 #define VBUSY           110     /* Volume temporarily unavailable; try again.
114                                  * The volume should be available again shortly; if
115                                  * it isn't something is wrong.  Not normally to be
116                                  * propagated to the application level */
117 #define VMOVED          111     /* Volume has moved to another server; do a VGetVolumeInfo
118                                  * to THIS server to find out where */
119
120 #define VLDB_MAXSERVERS 10
121 #define VOLSERVICE_ID 4
122 #define INVALID_BID 0
123 #define VOLSER_MAXVOLNAME 65
124 #define VOLSER_OLDMAXVOLNAME 32
125
126 /*flags used for interfacing with the  backup system */
127 struct volDescription {         /*used for interfacing with the backup system */
128     char volName[VOLSER_MAXVOLNAME];    /* should be VNAMESIZE as defined in volume.h */
129     afs_uint32 volId;
130     int volSize;
131     afs_int32 volFlags;
132     afs_uint32 volCloneId;
133 };
134
135 struct partList {               /*used by the backup system */
136     afs_int32 partId[VOLMAXPARTS];
137     afs_int32 partFlags[VOLMAXPARTS];
138 };
139
140 #define STDERR  stderr
141 #define STDOUT  stdout
142
143 #define ISNAMEVALID(name) (strlen(name) < (VOLSER_OLDMAXVOLNAME - 9))
144
145 /* values for flags in struct nvldbEntry */
146 #define RW_EXISTS 0x1000
147 #define RO_EXISTS 0x2000
148 #define BACK_EXISTS 0x4000
149
150 /* values for serverFlags in struct nvldbEntry */
151 #define NEW_REPSITE 0x01
152 #define ITSROVOL    0x02
153 #define ITSRWVOL    0x04
154 #define ITSBACKVOL  0x08
155 #define RO_DONTUSE  0x20
156
157 #define VLOP_RESTORE 0x100      /*this is bogus, clashes with VLOP_DUMP */
158 #define VLOP_ADDSITE 0x80       /*this is bogus, clashes with VLOP_DELETE */
159 #define PARTVALID 0x01
160 #define CLONEVALID 0x02
161 #define CLONEZAPPED 0x04
162 #define IDVALID 0x08
163 #define NAMEVALID 0x10
164 #define SIZEVALID 0x20
165 #define ENTRYVALID 0x40
166 #define REUSECLONEID 0x80
167 #define VOK 0x02
168
169 /* Values for the UV_RestoreVolume flags parameter */
170 /* Also used for UV_CopyVolume and UV_CloneVolume */
171 #define RV_FULLRST      0x000001
172 #define RV_OFFLINE      0x000002
173 #define RV_CRDUMP       0x000010
174 #define RV_CRKEEP       0x000020
175 #define RV_CRNEW        0x000040
176 #define RV_LUDUMP       0x000100
177 #define RV_LUKEEP       0x000200
178 #define RV_LUNEW        0x000400
179 #define RV_RDONLY       0x010000
180 #define RV_CPINCR       0x020000
181 #define RV_NOVLDB       0x040000
182 #define RV_NOCLONE      0x080000
183 #define RV_NODEL        0x100000
184
185 struct ubik_client;
186 extern afs_uint32 vsu_GetVolumeID(char *astring, struct ubik_client *acstruct, afs_int32 *errp);
187 extern int vsu_ExtractName(char rname[], char name[]);
188 extern afs_int32 vsu_ClientInit(int noAuthFlag, const char *confDir,
189                                 char *cellName, afs_int32 sauth,
190                                 struct ubik_client **uclientp,
191                                 int (*secproc)(struct rx_securityClass *, afs_int32));
192 extern void vsu_SetCrypt(int cryptflag);
193
194 #endif /* _VOLSER_ */