/*
* Copyright 2000, International Business Machines Corporation and others.
* All Rights Reserved.
- *
+ *
* This software has been released under the terms of the IBM Public
* License. For details, see the LICENSE file in the top-level source
* directory or online at http://www.openafs.org/dl/license10.html
#include <stdarg.h>
-/* these are now appended by the error table compiler */
-#if 0
-/* ubik error codes */
-#define UMINCODE 100000 /* lowest ubik error code */
-#define UNOQUORUM 100000 /* no quorum elected */
-#define UNOTSYNC 100001 /* not synchronization site (should work on sync site) */
-#define UNHOSTS 100002 /* too many hosts */
-#define UIOERROR 100003 /* I/O error writing dbase or log */
-#define UINTERNAL 100004 /* mysterious internal error */
-#define USYNC 100005 /* major synchronization error */
-#define UNOENT 100006 /* file not found when processing dbase */
-#define UBADLOCK 100007 /* bad lock range size (must be 1) */
-#define UBADLOG 100008 /* read error reprocessing log */
-#define UBADHOST 100009 /* problems with host name */
-#define UBADTYPE 100010 /* bad operation for this transaction type */
-#define UTWOENDS 100011 /* two commits or aborts done to transaction */
-#define UDONE 100012 /* operation done after abort (or commmit) */
-#define UNOSERVERS 100013 /* no servers appear to be up */
-#define UEOF 100014 /* premature EOF */
-#define ULOGIO 100015 /* error writing log file */
-#define UMAXCODE 100100 /* largest ubik error code */
-
-#endif
-
#include <ubik_int.h>
/*! \name ubik_trans types */
/*! \name ubik_lock types */
#define LOCKREAD 1
#define LOCKWRITE 2
-#if !defined(UBIK_PAUSE)
#define LOCKWAIT 3
-#endif /* UBIK_PAUSE */
/*\}*/
/*! \name ubik client flags */
#define CFLastFailed 1 /*!< last call failed to this guy (to detect down hosts) */
/*\}*/
+#include <afs/afs_assert.h>
#ifdef AFS_PTHREAD_ENV
#include <pthread.h>
-#include <assert.h>
#else
#include <lwp.h>
#endif
};
#ifdef AFS_PTHREAD_ENV
-#define LOCK_UBIK_CLIENT(client) assert(pthread_mutex_lock(&client->cm)==0)
-#define UNLOCK_UBIK_CLIENT(client) assert(pthread_mutex_unlock(&client->cm)==0)
+#define LOCK_UBIK_CLIENT(client) MUTEX_ENTER(&client->cm)
+#define UNLOCK_UBIK_CLIENT(client) MUTEX_EXIT(&client->cm)
#else
#define LOCK_UBIK_CLIENT(client)
#define UNLOCK_UBIK_CLIENT(client)
/*!
* \brief representation of a ubik database.
*
- * Contains info on low-level disk access routines
+ * Contains info on low-level disk access routines
* for use by disk transaction module.
*/
struct ubik_dbase {
extern void *ubik_SRXSecurityRock;
extern int (*ubik_CheckRXSecurityProc) (void *, struct rx_call *);
extern void *ubik_CheckRXSecurityRock;
+
+extern void ubik_SetClientSecurityProcs(int (*scproc)(void *,
+ struct rx_securityClass **,
+ afs_int32 *),
+ int (*checkproc) (void *),
+ void *rock);
+extern void ubik_SetServerSecurityProcs
+ (void (*buildproc) (void *,
+ struct rx_securityClass ***,
+ afs_int32 *),
+ int (*checkproc) (void *, struct rx_call *),
+ void *rock);
+
/*\}*/
+/*
+ * For applications that make use of ubik_BeginTransReadAnyWrite, writing
+ * processes must not update the application-level cache as they write,
+ * or else readers can read the new cache before the data is committed to
+ * the db. So, when a commit occurs, the cache must be updated right then.
+ * If set, this function will be called during commits of write transactions,
+ * to update the application-level cache after a write. This will be called
+ * immediately after the local disk commit succeeds, and it will be called
+ * with a lock held that prevents other threads from reading from the cache
+ * or the db in general.
+ *
+ * Note that this function MUST be set in order to make use of
+ * ubik_BeginTransReadAnyWrite.
+ */
+extern int (*ubik_SyncWriterCacheProc) (void);
+
/****************INTERNALS BELOW ****************/
#ifdef UBIK_INTERNALS
/*! \name ubik_dbase flags */
#define DBWRITING 1 /*!< are any write trans. in progress */
-#if defined(UBIK_PAUSE)
-#define DBVOTING 2 /*!< the beacon task is polling */
-#endif /* UBIK_PAUSE */
/*\}*/
/*!\name ubik trans flags */
#define TRDONE 1 /*!< commit or abort done */
#define TRABORT 2 /*!< if #TRDONE, tells if aborted */
#define TRREADANY 4 /*!< read any data available in trans */
-#if defined(UBIK_PAUSE)
-#define TRSETLOCK 8 /*!< SetLock is using trans */
-#define TRSTALE 16 /*!< udisk_end during getLock */
-#endif /* UBIK_PAUSE */
#define TRCACHELOCKED 32 /*!< this trans has locked dbase->cache_lock
* (meaning, this trans has called
* ubik_CheckCache at some point */
+#define TRREADWRITE 64 /*!< read even if there's a conflicting ubik-
+ * level write lock */
/*\}*/
/*! \name ubik_lock flags */
/*!
* \name timer constants
- * time constant for replication algorithms: the R time period is 20 seconds. Both
+ * time constant for replication algorithms: the R time period is 20 seconds. Both
* #SMALLTIME and #BIGTIME must be larger than #RPCTIMEOUT+max(#RPCTIMEOUT, #POLLTIME),
* so that timeouts do not prevent us from getting through to our servers in time.
*
/*! \name hold and release functions on a database */
#ifdef AFS_PTHREAD_ENV
-# define DBHOLD(a) assert(pthread_mutex_lock(&((a)->versionLock)) == 0)
-# define DBRELE(a) assert(pthread_mutex_unlock(&((a)->versionLock)) == 0)
+# define DBHOLD(a) MUTEX_ENTER(&((a)->versionLock))
+# define DBRELE(a) MUTEX_EXIT(&((a)->versionLock))
#else /* !AFS_PTHREAD_ENV */
# define DBHOLD(a) ObtainWriteLock(&((a)->versionLock))
# define DBRELE(a) ReleaseWriteLock(&((a)->versionLock))
/* this extern gives the sync site's db version, with epoch of 0 if none yet */
/* phys.c */
-extern int uphys_close(int afd);
extern int uphys_stat(struct ubik_dbase *adbase, afs_int32 afid,
struct ubik_stat *astat);
extern int uphys_read(struct ubik_dbase *adbase, afs_int32 afile,
extern int uphys_setlabel(struct ubik_dbase *adbase, afs_int32 afile,
struct ubik_version *aversion);
extern int uphys_sync(struct ubik_dbase *adbase, afs_int32 afile);
-extern void uphys_invalidate(struct ubik_dbase *adbase,
+extern void uphys_invalidate(struct ubik_dbase *adbase,
afs_int32 afid);
/*! \name recovery.c */
extern int urecovery_ResetState(void);
-extern int urecovery_LostServer(void);
+extern int urecovery_LostServer(struct ubik_server *server);
extern int urecovery_AllBetter(struct ubik_dbase *adbase,
int areadAny);
extern int urecovery_AbortAll(struct ubik_dbase *adbase);
-extern int urecovery_CheckTid(struct ubik_tid *atid);
+extern int urecovery_CheckTid(struct ubik_tid *atid, int abortalways);
extern int urecovery_Initialize(struct ubik_dbase *adbase);
extern void *urecovery_Interact(void *);
extern int DoProbe(struct ubik_server *server);
/*! \name ubik.c */
extern afs_int32 ContactQuorum_NoArguments(afs_int32 (*proc)
- (struct rx_connection *,
+ (struct rx_connection *,
ubik_tid *),
struct ubik_trans *atrans,
int aflags);
extern afs_int32 ContactQuorum_DISK_Lock(struct ubik_trans *atrans,
int aflags,
- afs_int32 file, afs_int32 position,
+ afs_int32 file, afs_int32 position,
afs_int32 length, afs_int32 type);
extern afs_int32 ContactQuorum_DISK_Write(struct ubik_trans *atrans,
- int aflags,
- afs_int32 file, afs_int32 position,
+ int aflags,
+ afs_int32 file, afs_int32 position,
bulkdata *data);
extern afs_int32 ContactQuorum_DISK_Truncate(struct ubik_trans *atrans,
extern afs_int32 ContactQuorum_DISK_WriteV(struct ubik_trans *atrans,
int aflags,
- iovec_wrt * io_vector,
+ iovec_wrt * io_vector,
iovec_buf *io_buffer);
-extern afs_int32 ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans,
+extern afs_int32 ContactQuorum_DISK_SetVersion(struct ubik_trans *atrans,
int aflags,
ubik_version *OldVersion,
ubik_version *NewVersion);
-
+
extern void panic(char *format, ...)
AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2);
-extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
+extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
+
+extern int ubik_CheckAuth(struct rx_call *);
+
/*\}*/
/*! \name beacon.c */
struct afsconf_cell;
+extern void ubeacon_InitSecurityClass(void);
+extern void ubeacon_ReinitServer(struct ubik_server *ts);
extern void ubeacon_Debug(struct ubik_debug *aparm);
extern int ubeacon_AmSyncSite(void);
extern int ubeacon_InitServerListByInfo(afs_uint32 ame,
/*\}*/
/*! \name disk.c */
+extern int udisk_Init(int nBUffers);
extern void udisk_Debug(struct ubik_debug *aparm);
extern int udisk_Invalidate(struct ubik_dbase *adbase, afs_int32 afid);
-extern int udisk_read(struct ubik_trans *atrans, afs_int32 afile,
+extern int udisk_read(struct ubik_trans *atrans, afs_int32 afile,
void *abuffer, afs_int32 apos, afs_int32 alen);
-extern int udisk_truncate(struct ubik_trans *atrans, afs_int32 afile,
+extern int udisk_truncate(struct ubik_trans *atrans, afs_int32 afile,
afs_int32 alength);
-extern int udisk_write(struct ubik_trans *atrans, afs_int32 afile,
+extern int udisk_write(struct ubik_trans *atrans, afs_int32 afile,
void *abuffer, afs_int32 apos, afs_int32 alen);
-extern int udisk_begin(struct ubik_dbase *adbase, int atype,
+extern int udisk_begin(struct ubik_dbase *adbase, int atype,
struct ubik_trans **atrans);
extern int udisk_commit(struct ubik_trans *atrans);
extern int udisk_abort(struct ubik_trans *atrans);
/*\}*/
/*! \name lock.c */
+extern void ulock_Init(void);
extern int ulock_getLock(struct ubik_trans *atrans, int atype, int await);
extern void ulock_relLock(struct ubik_trans *atrans);
extern void ulock_Debug(struct ubik_debug *aparm);
extern int ubik_BeginTransReadAny(struct ubik_dbase *dbase,
afs_int32 transMode,
struct ubik_trans **transPtr);
-extern int ubik_AbortTrans(struct ubik_trans *transPtr);
+extern int ubik_BeginTransReadAnyWrite(struct ubik_dbase *dbase,
+ afs_int32 transMode,
+ struct ubik_trans **transPtr);
+extern int ubik_AbortTrans(struct ubik_trans *transPtr);
extern int ubik_EndTrans(struct ubik_trans *transPtr);
extern int ubik_Read(struct ubik_trans *transPtr, void *buffer,
afs_int32 length);
extern int ubik_Flush(struct ubik_trans *transPtr);
extern int ubik_Write(struct ubik_trans *transPtr, void *buffer,
- afs_int32 length);
+ afs_int32 length);
extern int ubik_Seek(struct ubik_trans *transPtr, afs_int32 fileid,
afs_int32 position);
extern int ubik_Tell(struct ubik_trans *transPtr, afs_int32 * fileid,
afs_int32 * position);
-extern int ubik_Truncate(struct ubik_trans *transPtr,
+extern int ubik_Truncate(struct ubik_trans *transPtr,
afs_int32 length);
-extern int ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos,
+extern int ubik_SetLock(struct ubik_trans *atrans, afs_int32 apos,
afs_int32 alen, int atype);
extern int ubik_WaitVersion(struct ubik_dbase *adatabase,
struct ubik_version *aversion);
char *cellName, afs_int32 sauth,
struct ubik_client **uclientp,
int (*secproc) (struct rx_securityClass *sc,
- afs_int32 scIndex),
- char *funcName,
- afs_int32 gen_rxkad_level,
- afs_int32 maxservers, char *serviceid,
- afs_int32 deadtime, afs_uint32 server,
+ afs_int32 scIndex),
+ char *funcName,
+ afs_int32 gen_rxkad_level,
+ afs_int32 maxservers, char *serviceid,
+ afs_int32 deadtime, afs_uint32 server,
afs_uint32 port, afs_int32 usrvid);
#endif /* UBIK_H */