cfd12f790a9c693987a6c6c00019a6a2cb1de32a
[openafs.git] / src / ubik / ubik.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 UBIK_H
11 #define UBIK_H
12
13 #include <stdarg.h>
14
15 #include <ubik_int.h>
16
17 /*! \name ubik_trans types */
18 #define UBIK_READTRANS      0
19 #define UBIK_WRITETRANS     1
20 /*\}*/
21
22 /*! \name ubik_lock types */
23 #define LOCKREAD            1
24 #define LOCKWRITE           2
25 #define LOCKWAIT            3
26 /*\}*/
27
28 /*! \name ubik client flags */
29 #define UPUBIKONLY          1   /*!< only check servers presumed functional */
30 #define UBIK_CALL_NEW       2   /*!< use the semantics of ubik_Call_New */
31 /*\}*/
32
33 /*! \name RX services types */
34 #define VOTE_SERVICE_ID     50
35 #define DISK_SERVICE_ID     51
36 #define USER_SERVICE_ID     52  /*!< Since most applications use same port! */
37 /*\}*/
38
39 #define UBIK_MAGIC      0x354545
40
41 /*! \name global ubik parameters */
42 #define MAXSERVERS          20  /*!< max number of servers */
43 /*\}*/
44
45 /*! version comparison macro */
46 #define vcmp(a,b) ((a).epoch == (b).epoch? ((a).counter - (b).counter) : ((a).epoch - (b).epoch))
47
48 /*! \name ubik_client state bits */
49 #define CFLastFailed        1   /*!< last call failed to this guy (to detect down hosts) */
50 /*\}*/
51
52 #ifdef AFS_PTHREAD_ENV
53 #include <pthread.h>
54 #else
55 #include <lwp.h>
56 #endif
57
58 /*! Sanity check: This macro represents an arbitrary date in the past
59  * (Tue Jun 20 15:36:43 2017). The database epoch must be greater or
60  * equal to this value. */
61 #define UBIK_MILESTONE      1497987403
62
63 /*!
64  * \brief per-client structure for ubik
65  */
66 struct ubik_client {
67     short initializationState;  /*!< ubik client init state */
68     short states[MAXSERVERS];   /*!< state bits */
69     struct rx_connection *conns[MAXSERVERS];
70     afs_int32 syncSite;
71 #ifdef AFS_PTHREAD_ENV
72     pthread_mutex_t cm;
73 #endif
74 };
75
76 #ifdef AFS_PTHREAD_ENV
77 #define LOCK_UBIK_CLIENT(client) opr_mutex_enter(&client->cm)
78 #define UNLOCK_UBIK_CLIENT(client) opr_mutex_exit(&client->cm)
79 #else
80 #define LOCK_UBIK_CLIENT(client)
81 #define UNLOCK_UBIK_CLIENT(client)
82 #endif
83
84 #define ubik_GetRPCConn(astr,aindex)    ((aindex) >= MAXSERVERS? 0 : (astr)->conns[aindex])
85 #define ubik_GetRPCHost(astr,aindex)    ((aindex) >= MAXSERVERS? 0 : (astr)->hosts[aindex])
86
87 /*!
88  * \brief ubik header file structure
89  */
90 struct ubik_hdr {
91     afs_int32 magic;            /*!< magic number */
92     short pad1;                 /*!< some 0-initd padding */
93     short size;                 /*!< header allocation size */
94     struct ubik_version version;        /*!< the version for this file */
95 };
96
97 /*!
98  * \brief representation of a ubik transaction
99  */
100 struct ubik_trans {
101     struct ubik_dbase *dbase;   /*!< corresponding database */
102     struct ubik_trans *next;    /*!< in the list */
103     afs_int32 locktype;         /*!< transaction lock */
104     struct ubik_trunc *activeTruncs;    /*!< queued truncates */
105     struct ubik_tid tid;        /*!< transaction id of this trans (if write trans.) */
106     afs_int32 minCommitTime;    /*!< time before which this trans can't commit */
107     afs_int32 seekFile;         /*!< seek ptr: file number */
108     afs_int32 seekPos;          /*!< seek ptr: offset therein */
109     short flags;                /*!< trans flag bits */
110     char type;                  /*!< type of trans */
111     iovec_wrt iovec_info;
112     iovec_buf iovec_data;
113 };
114
115 /*!
116  * \brief representation of a truncation operation
117  */
118 struct ubik_trunc {
119     struct ubik_trunc *next;
120     afs_int32 file;             /*!< file to truncate */
121     afs_int32 length;           /*!< new size */
122 };
123
124 struct ubik_stat {
125     afs_int32 size;
126 };
127
128 #include <lock.h>               /* just to make sure we've got this */
129
130 /*!
131  * \brief representation of a ubik database.
132  *
133  * Contains info on low-level disk access routines
134  * for use by disk transaction module.
135  */
136 struct ubik_dbase {
137     char *pathName;             /*!< root name for dbase */
138     struct ubik_trans *activeTrans;     /*!< active transaction list */
139     struct ubik_version version;        /*!< version number */
140 #ifdef AFS_PTHREAD_ENV
141     pthread_mutex_t versionLock;        /*!< lock on version number */
142 #else
143     struct Lock versionLock;    /*!< lock on version number */
144 #endif
145     afs_int32 tidCounter;       /*!< last RW or RO trans tid counter */
146     afs_int32 writeTidCounter;  /*!< last write trans tid counter */
147     afs_int32 dbFlags;          /*!< flags */
148     /* physio procedures */
149     int (*read) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
150                  afs_int32 apos, afs_int32 alength);
151     int (*write) (struct ubik_dbase * adbase, afs_int32 afile, void *abuffer,
152                   afs_int32 apos, afs_int32 alength);
153     int (*truncate) (struct ubik_dbase * adbase, afs_int32 afile,
154                      afs_int32 asize);
155     int (*sync) (struct ubik_dbase * adbase, afs_int32 afile);
156     int (*stat) (struct ubik_dbase * adbase, afs_int32 afid,
157                  struct ubik_stat * astat);
158     void (*open) (struct ubik_dbase * adbase, afs_int32 afid);
159     int (*setlabel) (struct ubik_dbase * adbase, afs_int32 afile, struct ubik_version * aversion);      /*!< set the version label */
160     int (*getlabel) (struct ubik_dbase * adbase, afs_int32 afile, struct ubik_version * aversion);      /*!< retrieve the version label */
161     int (*getnfiles) (struct ubik_dbase * adbase);      /*!< find out number of files */
162     int (*buffered_append)(struct ubik_dbase *adbase, afs_int32 afid, void *adata, afs_int32 alength);
163     short readers;              /*!< number of current read transactions */
164     struct ubik_version cachedVersion;  /*!< version of caller's cached data */
165     struct Lock cache_lock; /*!< protects cached application data */
166 #ifdef AFS_PTHREAD_ENV
167     pthread_cond_t flags_cond;      /*!< condition variable to manage changes to flags */
168 #endif
169 };
170
171 /**
172  * ubik_CheckCache callback function.
173  *
174  * @param[in] atrans  ubik transaction
175  * @param[in] rock    rock passed to ubik_CheckCache
176  *
177  * @return operation status
178  *   @retval 0        cache was read properly
179  */
180 typedef int (*ubik_updatecache_func) (struct ubik_trans *atrans, void *rock);
181
182 /*! \name procedures for automatically authenticating ubik connections */
183 extern int (*ubik_CRXSecurityProc) (void *, struct rx_securityClass **,
184                                     afs_int32 *);
185 extern void *ubik_CRXSecurityRock;
186 extern int (*ubik_SRXSecurityProc) (void *, struct rx_securityClass **,
187                                     afs_int32 *);
188 extern void *ubik_SRXSecurityRock;
189 extern int (*ubik_CheckRXSecurityProc) (void *, struct rx_call *);
190 extern void *ubik_CheckRXSecurityRock;
191
192 extern void ubik_SetClientSecurityProcs(int (*scproc)(void *,
193                                                       struct rx_securityClass **,
194                                                       afs_int32 *),
195                                         int (*checkproc) (void *),
196                                         void *rock);
197 extern void ubik_SetServerSecurityProcs
198                 (void (*buildproc) (void *,
199                                     struct rx_securityClass ***,
200                                     afs_int32 *),
201                  int (*checkproc) (void *, struct rx_call *),
202                  void *rock);
203
204 /*\}*/
205
206 /*
207  * For applications that make use of ubik_BeginTransReadAnyWrite, writing
208  * processes must not update the application-level cache as they write,
209  * or else readers can read the new cache before the data is committed to
210  * the db. So, when a commit occurs, the cache must be updated right then.
211  * If set, this function will be called during commits of write transactions,
212  * to update the application-level cache after a write. This will be called
213  * immediately after the local disk commit succeeds, and it will be called
214  * with a lock held that prevents other threads from reading from the cache
215  * or the db in general.
216  *
217  * Note that this function MUST be set in order to make use of
218  * ubik_BeginTransReadAnyWrite.
219  */
220 extern int (*ubik_SyncWriterCacheProc) (void);
221
222 /****************INTERNALS BELOW ****************/
223
224 #ifdef UBIK_INTERNALS
225 /*! \name some ubik parameters */
226 #define UBIK_PAGESIZE       1024        /*!< fits in current r packet */
227 #define UBIK_LOGPAGESIZE    10  /*!< base 2 log thereof */
228 #define NBUFFERS            20  /*!< number of 1K buffers */
229 #define HDRSIZE             64  /*!< bytes of header per dbfile */
230 /*\}*/
231
232 /*! \name ubik_dbase flags */
233 #define DBWRITING           1   /*!< are any write trans. in progress */
234 /*\}*/
235
236 /*!\name ubik trans flags */
237 #define TRDONE              1   /*!< commit or abort done */
238 #define TRABORT             2   /*!< if #TRDONE, tells if aborted */
239 #define TRREADANY           4   /*!< read any data available in trans */
240 #define TRCACHELOCKED       32  /*!< this trans has locked dbase->cache_lock
241                                  *   (meaning, this trans has called
242                                  *   ubik_CheckCache at some point */
243 #define TRREADWRITE         64  /*!< read even if there's a conflicting ubik-
244                                  *   level write lock */
245 /*\}*/
246
247 /*! \name ubik_lock flags */
248 #define LWANT               1
249 /*\}*/
250
251 /*! \name ubik system database numbers */
252 #define LOGFILE             (-1)
253 /*\}*/
254
255 /*! \name define log opcodes */
256 #define LOGNEW              100 /*!< start transaction */
257 #define LOGEND              101 /*!< commit (good) end transaction */
258 #define LOGABORT            102 /*!< abort (fail) transaction */
259 #define LOGDATA             103 /*!< data */
260 #define LOGTRUNCATE         104 /*!< truncate operation */
261 /*\}*/
262
263 /*!
264  * \name timer constants
265  * time constant for replication algorithms: the R time period is 20 seconds.  Both
266  * #SMALLTIME and #BIGTIME must be larger than #RPCTIMEOUT+max(#RPCTIMEOUT, #POLLTIME),
267  * so that timeouts do not prevent us from getting through to our servers in time.
268  *
269  * We use multi-R to time out multiple down hosts concurrently.
270  * The only other restrictions:  #BIGTIME > #SMALLTIME and
271  * #BIGTIME-#SMALLTIME > #MAXSKEW (the clock skew).
272  */
273 #define MAXSKEW 10
274 #define POLLTIME 15
275 #define RPCTIMEOUT 20
276 #define BIGTIME 75
277 #define SMALLTIME 60
278 /*\}*/
279
280 /*!
281  * \brief the per-server state, used by the sync site to keep track of its charges
282  */
283 struct ubik_server {
284     struct ubik_server *next;   /*!< next ptr */
285     afs_uint32 addr[UBIK_MAX_INTERFACE_ADDR];   /*!< network order, addr[0] is primary */
286     afs_int32 lastVoteTime;     /*!< last time yes vote received */
287     afs_int32 lastBeaconSent;   /*!< last time beacon attempted */
288     struct ubik_version version;        /*!< version, only used during recovery */
289     struct rx_connection *vote_rxcid;   /*!< cid to use to contact dude for votes */
290     struct rx_connection *disk_rxcid;   /*!< cid to use to contact dude for disk reqs */
291     char lastVote;              /*!< true if last vote was yes */
292     char up;                    /*!< is it up? */
293     char beaconSinceDown;       /*!< did beacon get through since last crash? */
294     char currentDB;             /*!< is dbase up-to-date */
295     char magic;                 /*!< the one whose vote counts twice */
296     char isClone;               /*!< is only a clone, doesn't vote */
297 };
298
299 /*! \name hold and release functions on a database */
300 #ifdef AFS_PTHREAD_ENV
301 # define        DBHOLD(a)       opr_mutex_enter(&((a)->versionLock))
302 # define        DBRELE(a)       opr_mutex_exit(&((a)->versionLock))
303 #else /* !AFS_PTHREAD_ENV */
304 # define        DBHOLD(a)       ObtainWriteLock(&((a)->versionLock))
305 # define        DBRELE(a)       ReleaseWriteLock(&((a)->versionLock))
306 #endif /* !AFS_PTHREAD_ENV */
307 /*\}*/
308
309 /* globals */
310
311 /*!name list of all servers in the system */
312 extern struct ubik_server *ubik_servers;
313 extern char amIClone;
314 /*\}*/
315
316 /*! \name network port info */
317 extern short ubik_callPortal;
318 /*\}*/
319
320 /*! \name urecovery state bits for sync site */
321 #define UBIK_RECSYNCSITE        1       /* am sync site */
322 #define UBIK_RECFOUNDDB         2       /* found acceptable dbase from quorum */
323 #define UBIK_RECHAVEDB          4       /* fetched best dbase */
324 #define UBIK_RECLABELDB         8       /* relabelled dbase */
325 #define UBIK_RECSENTDB          0x10    /* sent best db to *everyone* */
326 #define UBIK_RECSBETTER         UBIK_RECLABELDB /* last state */
327 /*\}*/
328
329 extern afs_int32 ubik_quorum;   /* min hosts in quorum */
330 extern struct ubik_dbase *ubik_dbase;   /* the database handled by this server */
331 extern afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR];   /* this host addr, in net order */
332 extern int ubik_amSyncSite;     /* sleep on this waiting to be sync site */
333 extern struct ubik_stats {      /* random stats */
334     afs_int32 escapes;
335 } ubik_stats;
336 extern afs_int32 urecovery_state;       /* sync site recovery process state */
337 extern struct ubik_trans *ubik_currentTrans;    /* current trans */
338 extern afs_int32 ubik_debugFlag;        /* ubik debug flag */
339 extern int ubikPrimaryAddrOnly; /* use only primary address */
340
341 /*
342  * Lock ordering
343  *
344  * Any of the locks may be acquired singly; when acquiring multiple locks, they
345  * should be acquired in the listed order:
346  *      application cache lock  (dbase->cache_lock)
347  *      database lock           DBHOLD/DBRELE
348  *      beacon lock             UBIK_BEACON_LOCK/UNLOCK
349  *      vote lock               UBIK_VOTE_LOCK/UNLOCK
350  *      version lock            UBIK_VERSION_LOCK/UNLOCK
351  *      server address lock     UBIK_ADDR_LOCK/UNLOCK
352  */
353
354 /*!
355  * \brief Global beacon data.  All values are protected by beacon_lock
356  * This lock also protects some values in the ubik_server structures:
357  *      lastVoteTime
358  *      lastBeaconSent
359  *      lastVote
360  *      up
361  *      beaconSinceDown
362  */
363 struct beacon_data {
364 #ifdef AFS_PTHREAD_ENV
365     pthread_mutex_t beacon_lock;
366 #endif
367     int ubik_amSyncSite;                /*!< flag telling if I'm sync site */
368     afs_int32 syncSiteUntil;            /*!< valid only if amSyncSite */
369     int ubik_syncSiteAdvertised;        /*!< flag telling if remotes are aware we have quorum */
370 };
371
372 #define UBIK_BEACON_LOCK opr_mutex_enter(&beacon_globals.beacon_lock)
373 #define UBIK_BEACON_UNLOCK opr_mutex_exit(&beacon_globals.beacon_lock)
374
375 /*!
376  * \brief Global vote data.  All values are protected by vote_lock
377  */
378 struct vote_data {
379 #ifdef AFS_PTHREAD_ENV
380     pthread_mutex_t vote_lock;
381 #endif
382     struct ubik_version ubik_dbVersion; /* sync site's dbase version */
383     struct ubik_tid ubik_dbTid;         /* sync site's tid, or 0 if none */
384     /* Used by all sites in nominating new sync sites */
385     afs_int32 ubik_lastYesTime;         /* time we sent the last yes vote */
386     afs_uint32 lastYesHost;             /* host to which we sent yes vote */
387     /* Next is time sync site began this vote: guarantees sync site until this + SMALLTIME */
388     afs_int32 lastYesClaim;
389     int lastYesState;                   /* did last site we voted for claim to be sync site? */
390     /* Used to guarantee that nomination process doesn't loop */
391     afs_int32 lowestTime;
392     afs_uint32 lowestHost;
393     afs_int32 syncTime;
394     afs_int32 syncHost;
395 };
396
397 #define UBIK_VOTE_LOCK opr_mutex_enter(&vote_globals.vote_lock)
398 #define UBIK_VOTE_UNLOCK opr_mutex_exit(&vote_globals.vote_lock)
399
400 /*!
401  * \brief Server address data.  All values are protected by addr_lock
402  *
403  * This lock also protects:
404  *     ubik_server: addr[], vote_rxcid, disk_rxcid
405  *
406  */
407 struct addr_data {
408 #ifdef AFS_PTHREAD_ENV
409     pthread_mutex_t addr_lock;
410 #endif
411     afs_int32 ubikSecIndex;
412     struct rx_securityClass *ubikSecClass;
413 };
414
415 #define UBIK_ADDR_LOCK opr_mutex_enter(&addr_globals.addr_lock)
416 #define UBIK_ADDR_UNLOCK opr_mutex_exit(&addr_globals.addr_lock)
417
418 /*!
419  * \brief The version lock protects the structure member, as well as
420  * the database version, dbFlags, tidCounter, writeTidCounter. Reading these
421  * values can be done while holding either UBIK_VERSION_LOCK or DBHOLD. Writing
422  * these requires holding both locks.
423  */
424 struct version_data {
425 #ifdef AFS_PTHREAD_ENV
426     pthread_mutex_t version_lock;
427 #endif
428     afs_int32 ubik_epochTime;   /* time when this site started */
429 };
430
431 #define UBIK_VERSION_LOCK opr_mutex_enter(&version_globals.version_lock)
432 #define UBIK_VERSION_UNLOCK opr_mutex_exit(&version_globals.version_lock)
433
434 /* phys.c */
435 extern int uphys_stat(struct ubik_dbase *adbase, afs_int32 afid,
436                       struct ubik_stat *astat);
437 extern int uphys_read(struct ubik_dbase *adbase, afs_int32 afile,
438                       void *abuffer, afs_int32 apos,
439                       afs_int32 alength);
440 extern int uphys_write(struct ubik_dbase *adbase, afs_int32 afile,
441                        void *abuffer, afs_int32 apos,
442                        afs_int32 alength);
443 extern int uphys_truncate(struct ubik_dbase *adbase, afs_int32 afile,
444                           afs_int32 asize);
445 extern int uphys_getnfiles(struct ubik_dbase *adbase);
446 extern int uphys_getlabel(struct ubik_dbase *adbase, afs_int32 afile,
447                           struct ubik_version *aversion);
448 extern int uphys_setlabel(struct ubik_dbase *adbase, afs_int32 afile,
449                           struct ubik_version *aversion);
450 extern int uphys_sync(struct ubik_dbase *adbase, afs_int32 afile);
451 extern void uphys_invalidate(struct ubik_dbase *adbase,
452                              afs_int32 afid);
453 extern int uphys_buf_append(struct ubik_dbase *adbase, afs_int32 afid,
454                             void *buf, afs_int32 alength);
455
456 /*! \name recovery.c */
457 extern int urecovery_ResetState(void);
458 extern int urecovery_LostServer(struct ubik_server *server);
459 extern int urecovery_AllBetter(struct ubik_dbase *adbase,
460                                int areadAny);
461 extern int urecovery_AbortAll(struct ubik_dbase *adbase);
462 extern int urecovery_CheckTid(struct ubik_tid *atid, int abortalways);
463 extern int urecovery_Initialize(struct ubik_dbase *adbase);
464 extern void *urecovery_Interact(void *);
465 extern int DoProbe(struct ubik_server *server);
466 /*\}*/
467
468 /*! \name ubik.c */
469 extern afs_int32 ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans,
470                                                int aflags,
471                                                ubik_version *OldVersion,
472                                                ubik_version *NewVersion);
473
474 extern void panic(char *format, ...)
475     AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
476
477 extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
478
479 extern int ubik_CheckAuth(struct rx_call *);
480
481 /*\}*/
482
483 /*! \name beacon.c */
484 struct afsconf_cell;
485 extern void ubeacon_InitSecurityClass(void);
486 extern void ubeacon_ReinitServer(struct ubik_server *ts);
487 extern void ubeacon_Debug(struct ubik_debug *aparm);
488 extern int ubeacon_AmSyncSite(void);
489 extern int ubeacon_SyncSiteAdvertised(void);
490 extern int ubeacon_InitServerListByInfo(afs_uint32 ame,
491                                         struct afsconf_cell *info,
492                                         char clones[]);
493 extern int ubeacon_InitServerList(afs_uint32 ame, afs_uint32 aservers[]);
494 extern void *ubeacon_Interact(void *);
495 extern int ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[]);
496 extern struct beacon_data beacon_globals;
497 extern struct addr_data addr_globals;
498
499 /*\}*/
500
501 /*! \name disk.c */
502 extern int udisk_Init(int nBUffers);
503 extern void udisk_Debug(struct ubik_debug *aparm);
504 extern int udisk_Invalidate(struct ubik_dbase *adbase, afs_int32 afid);
505 extern int udisk_read(struct ubik_trans *atrans, afs_int32 afile,
506                       void *abuffer, afs_int32 apos, afs_int32 alen);
507 extern int udisk_truncate(struct ubik_trans *atrans, afs_int32 afile,
508                           afs_int32 alength);
509 extern int udisk_write(struct ubik_trans *atrans, afs_int32 afile,
510                        void *abuffer, afs_int32 apos, afs_int32 alen);
511 extern int udisk_begin(struct ubik_dbase *adbase, int atype,
512                        struct ubik_trans **atrans);
513 extern int udisk_commit(struct ubik_trans *atrans);
514 extern int udisk_abort(struct ubik_trans *atrans);
515 extern int udisk_end(struct ubik_trans *atrans);
516 /*\}*/
517
518 /*! \name lock.c */
519 extern void ulock_Init(void);
520 extern int  ulock_getLock(struct ubik_trans *atrans, int atype, int await);
521 extern void ulock_relLock(struct ubik_trans *atrans);
522 extern void ulock_Debug(struct ubik_debug *aparm);
523 /*\}*/
524
525 /*! \name vote.c */
526 extern int uvote_ShouldIRun(void);
527 extern afs_int32 uvote_GetSyncSite(void);
528 extern int uvote_Init(void);
529 extern struct vote_data vote_globals;
530 extern void uvote_set_dbVersion(struct ubik_version);
531 extern int uvote_eq_dbVersion(struct ubik_version);
532 extern int uvote_HaveSyncAndVersion(struct ubik_version);
533 /*\}*/
534
535 #endif /* UBIK_INTERNALS */
536
537 extern afs_int32 ubik_nBuffers;
538
539 /*!
540  * \name Public function prototypes
541  */
542
543 /*! \name ubik.c */
544 struct afsconf_cell;
545 extern int ubik_ServerInitByInfo(afs_uint32 myHost, short myPort,
546                                  struct afsconf_cell *info, char clones[],
547                                  const char *pathName,
548                                  struct ubik_dbase **dbase);
549 extern int ubik_ServerInit(afs_uint32 myHost, short myPort,
550                            afs_uint32 serverList[],
551                            const char *pathName, struct ubik_dbase **dbase);
552 extern int ubik_BeginTrans(struct ubik_dbase *dbase,
553                            afs_int32 transMode, struct ubik_trans **transPtr);
554 extern int ubik_BeginTransReadAny(struct ubik_dbase *dbase,
555                                   afs_int32 transMode,
556                                   struct ubik_trans **transPtr);
557 extern int ubik_BeginTransReadAnyWrite(struct ubik_dbase *dbase,
558                                        afs_int32 transMode,
559                                        struct ubik_trans **transPtr);
560 extern int ubik_AbortTrans(struct ubik_trans *transPtr);
561
562 extern int ubik_EndTrans(struct ubik_trans *transPtr);
563 extern int ubik_Read(struct ubik_trans *transPtr, void *buffer,
564                      afs_int32 length);
565 extern int ubik_Flush(struct ubik_trans *transPtr);
566 extern int ubik_Write(struct ubik_trans *transPtr, void *buffer,
567                       afs_int32 length);
568 extern int ubik_Seek(struct ubik_trans *transPtr, afs_int32 fileid,
569                      afs_int32 position);
570 extern int ubik_Tell(struct ubik_trans *transPtr, afs_int32 * fileid,
571                      afs_int32 * position);
572 extern int ubik_Truncate(struct ubik_trans *transPtr,
573                          afs_int32 length);
574 extern int ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos,
575                         afs_int32 alen, int atype);
576 extern int ubik_CheckCache(struct ubik_trans *atrans,
577                            ubik_updatecache_func check,
578                            void *rock);
579 extern struct version_data version_globals;
580 /*\}*/
581
582 /*! \name ubikclient.c */
583
584 extern int ubik_ParseClientList(int argc, char **argv, afs_uint32 * aothers);
585 extern unsigned int afs_random(void);
586 extern int ubik_ClientInit(struct rx_connection **serverconns,
587                            struct ubik_client **aclient);
588 extern afs_int32 ubik_ClientDestroy(struct ubik_client *aclient);
589 extern struct rx_connection *ubik_RefreshConn(struct rx_connection *tc);
590
591 struct ubik_callrock_info {
592     struct rx_connection *conn;
593 };
594 typedef afs_int32 (*ubik_callrock_func)(struct ubik_callrock_info *info, void *rock);
595 extern afs_int32 ubik_CallRock(struct ubik_client *aclient, afs_int32 aflags,
596                                ubik_callrock_func proc, void *rock)
597                                AFS_NONNULL((3));
598
599 #ifdef UBIK_LEGACY_CALLITER
600 extern afs_int32 ubik_CallIter(int (*aproc) (), struct ubik_client *aclient,
601                                afs_int32 aflags, int *apos, long p1, long p2,
602                                long p3, long p4, long p5, long p6, long p7,
603                                long p8, long p9, long p10, long p11, long p12,
604                                long p13, long p14, long p15, long p16);
605 extern afs_int32 ubik_Call_New(int (*aproc) (), struct ubik_client
606                                *aclient, afs_int32 aflags, long p1, long p2,
607                                long p3, long p4, long p5, long p6, long p7,
608                                long p8, long p9, long p10, long p11, long p12,
609                                long p13, long p14, long p15, long p16);
610 #endif
611 /*\}*/
612
613 /* \name ubikcmd.c */
614 extern int ubik_ParseServerList(int argc, char **argv, afs_uint32 *ahost,
615                                 afs_uint32 *aothers);
616 /*\}*/
617
618 /* \name uinit.c */
619
620 struct rx_securityClass;
621 struct afsconf_dir;
622 typedef int (*ugen_secproc_func)(struct rx_securityClass *, afs_int32);
623 extern int ugen_ClientInitCell(struct afsconf_dir *dir,
624                                struct afsconf_cell *info,
625                                int secFlags,
626                                struct ubik_client **uclientp,
627                                int maxservers, const char *serviceid,
628                                int deadtime);
629 extern int ugen_ClientInitServer(const char *confDir, char *cellName,
630                                  int secFlags, struct ubik_client **uclientp,
631                                  int maxservers, char *serviceid,
632                                  int deadtime, afs_uint32 server,
633                                  afs_uint32 port);
634 extern int ugen_ClientInitFlags(const char *confDir, char *cellName,
635                                 int secFlags, struct ubik_client **uclientp,
636                                 ugen_secproc_func secproc,
637                                 int maxservers, char *serviceid,
638                                 int deadtime);
639 extern afs_int32 ugen_ClientInit(int noAuthFlag, const char *confDir,
640                                  char *cellName, afs_int32 sauth,
641                                  struct ubik_client **uclientp,
642                                  ugen_secproc_func secproc,
643                                  char *funcName,
644                                  afs_int32 gen_rxkad_level,
645                                  afs_int32 maxservers, char *serviceid,
646                                  afs_int32 deadtime, afs_uint32 server,
647                                  afs_uint32 port, afs_int32 usrvid);
648
649 #endif /* UBIK_H */