ubik: rename DInit, call from initialization sequence
[openafs.git] / src / ubik / ubik.p.h
index 939501f..eb24e9d 100644 (file)
 
 #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 */
@@ -46,9 +22,7 @@
 /*! \name ubik_lock types */
 #define        LOCKREAD            1
 #define        LOCKWRITE           2
-#if !defined(UBIK_PAUSE)
 #define        LOCKWAIT            3
-#endif /* UBIK_PAUSE */
 /*\}*/
 
 /*! \name ubik client flags */
@@ -75,9 +49,9 @@
 #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
@@ -96,8 +70,8 @@ struct ubik_client {
 };
 
 #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)
@@ -223,6 +197,22 @@ extern int (*ubik_CheckRXSecurityProc) (void *, struct rx_call *);
 extern void *ubik_CheckRXSecurityRock;
 /*\}*/
 
+/*
+ * 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
@@ -235,22 +225,17 @@ extern void *ubik_CheckRXSecurityRock;
 
 /*! \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 */
@@ -307,8 +292,8 @@ struct ubik_server {
 
 /*! \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))
@@ -374,11 +359,11 @@ extern void uphys_invalidate(struct ubik_dbase *adbase,
 
 /*! \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);
@@ -423,6 +408,8 @@ extern afs_uint32 ubikGetPrimaryInterfaceAddr(afs_uint32 addr);
 
 /*! \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,
@@ -433,6 +420,7 @@ extern void *ubeacon_Interact(void *);
 /*\}*/
 
 /*! \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,
@@ -493,6 +481,9 @@ extern int ubik_BeginTrans(struct ubik_dbase *dbase,
 extern int ubik_BeginTransReadAny(struct ubik_dbase *dbase,
                                  afs_int32 transMode,
                                  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);