OpenAFS
OpenAFS distributed network file system
/cygdrive/c/src/openafs/openafs.git/repo/src/ubik/ubik.c File Reference

This system is organized in a hierarchical set of related modules. More...

#include <afsconfig.h>
#include <afs/param.h>
#include <roken.h>
#include <afs/opr.h>
#include <lock.h>
#include <rx/rx.h>
#include <afs/cellconfig.h>
#include "ubik.h"
#include "ubik_int.h"
#include <lwp.h>

Defines

#define UBIK_INTERNALS
#define ERROR_EXIT(code)
#define CStampVersion   1

Functions

static_inline struct
rx_connection
Quorum_StartIO (struct ubik_trans *atrans, struct ubik_server *as)
static_inline void Quorum_EndIO (struct ubik_trans *atrans, struct rx_connection *aconn)
afs_int32 ContactQuorum_NoArguments (afs_int32(*proc)(struct rx_connection *, ubik_tid *), struct ubik_trans *atrans, int aflags)
 Perform an operation at a quorum, handling error conditions.
afs_int32 ContactQuorum_DISK_Lock (struct ubik_trans *atrans, int aflags, afs_int32 file, afs_int32 position, afs_int32 length, afs_int32 type)
afs_int32 ContactQuorum_DISK_Write (struct ubik_trans *atrans, int aflags, afs_int32 file, afs_int32 position, bulkdata *data)
afs_int32 ContactQuorum_DISK_Truncate (struct ubik_trans *atrans, int aflags, afs_int32 file, afs_int32 length)
afs_int32 ContactQuorum_DISK_WriteV (struct ubik_trans *atrans, int aflags, iovec_wrt *io_vector, iovec_buf *io_buffer)
afs_int32 ContactQuorum_DISK_SetVersion (struct ubik_trans *atrans, int aflags, ubik_version *OldVersion, ubik_version *NewVersion)
int ubik_ServerInitByInfo (afs_uint32 myHost, short myPort, struct afsconf_cell *info, char clones[], const char *pathName, struct ubik_dbase **dbase)
int ubik_ServerInit (afs_uint32 myHost, short myPort, afs_uint32 serverList[], const char *pathName, struct ubik_dbase **dbase)
int ubik_BeginTrans (struct ubik_dbase *dbase, afs_int32 transMode, struct ubik_trans **transPtr)
int ubik_BeginTransReadAny (struct ubik_dbase *dbase, afs_int32 transMode, struct ubik_trans **transPtr)
int ubik_BeginTransReadAnyWrite (struct ubik_dbase *dbase, afs_int32 transMode, struct ubik_trans **transPtr)
int ubik_AbortTrans (struct ubik_trans *transPtr)
 This routine ends a read or write transaction by aborting it.
int ubik_EndTrans (struct ubik_trans *transPtr)
 This routine ends a read or write transaction on the open transaction identified by transPtr.
int ubik_Read (struct ubik_trans *transPtr, void *buffer, afs_int32 length)
 This routine reads length bytes into buffer from the current position in the database.
int ubik_Flush (struct ubik_trans *transPtr)
 This routine will flush the io data in the iovec structures.
int ubik_Write (struct ubik_trans *transPtr, void *vbuffer, afs_int32 length)
int ubik_Seek (struct ubik_trans *transPtr, afs_int32 fileid, afs_int32 position)
 This sets the file pointer associated with the current transaction to the appropriate file and byte position.
int ubik_Tell (struct ubik_trans *transPtr, afs_int32 *fileid, afs_int32 *position)
 This call returns the file pointer associated with the specified transaction in fileid and position.
int ubik_Truncate (struct ubik_trans *transPtr, afs_int32 length)
 This sets the file size for the currently-selected file to length bytes, if length is less than the file's current size.
int ubik_SetLock (struct ubik_trans *atrans, afs_int32 apos, afs_int32 alen, int atype)
 set a lock; all locks are released on transaction end (commit/abort)
int ubik_WaitVersion (struct ubik_dbase *adatabase, struct ubik_version *aversion)
 utility to wait for a version # to change
int ubik_GetVersion (struct ubik_trans *atrans, struct ubik_version *avers)
 utility to get the version of the dbase a transaction is dealing with
int ubik_CheckCache (struct ubik_trans *atrans, ubik_updatecache_func cbf, void *rock)
void panic (char *format,...)
 "Who said anything about panicking?" snapped Arthur.
afs_uint32 ubikGetPrimaryInterfaceAddr (afs_uint32 addr)
 This function takes an IP addresses as its parameter.
int ubik_CheckAuth (struct rx_call *acall)
void ubik_SetServerSecurityProcs (void(*buildproc)(void *, struct rx_securityClass ***, afs_int32 *), int(*checkproc)(void *, struct rx_call *), void *rock)

Variables

afs_int32 ubik_quorum = 0
struct ubik_dbaseubik_dbase = 0
struct ubik_stats ubik_stats
afs_uint32 ubik_host [UBIK_MAX_INTERFACE_ADDR]
afs_int32 ubik_epochTime = 0
afs_int32 urecovery_state = 0
int(* ubik_SyncWriterCacheProc )(void)
struct ubik_server * ubik_servers
short ubik_callPortal
int(* ubik_SRXSecurityProc )(void *, struct rx_securityClass **, afs_int32 *)
void * ubik_SRXSecurityRock
int(* ubik_CheckRXSecurityProc )(void *, struct rx_call *)
void * ubik_CheckRXSecurityRock
struct version_data version_globals

Detailed Description

This system is organized in a hierarchical set of related modules.

Modules at one level can only call modules at the same level or below.

At the bottom level (0) we have R, RFTP, LWP and IOMGR, i.e. the basic operating system primitives.

At the next level (1) we have

  • VOTER--The module responsible for casting votes when asked. It is also responsible for determining whether this server should try to become a synchronization site.
  • BEACONER--The module responsible for sending keep-alives out when a server is actually the sync site, or trying to become a sync site.
  • DISK--The module responsible for representing atomic transactions on the local disk. It maintains a new-value only log.
  • LOCK--The module responsible for locking byte ranges in the database file.

At the next level (2) we have

  • RECOVERY--The module responsible for ensuring that all members of a quorum have the same up-to-date database after a new synchronization site is elected. This module runs only on the synchronization site.

At the next level (3) we have

  • REMOTE--The module responsible for interpreting requests from the sync site and applying them to the database, after obtaining the appropriate locks.

At the next level (4) we have

  • UBIK--The module users call to perform operations on the database.

Define Documentation

#define ERROR_EXIT (   code)
Value:
do { \
    error = (code); \
    goto error_exit; \
} while (0)

Function Documentation

afs_int32 ContactQuorum_NoArguments ( afs_int32(*)(struct rx_connection *, ubik_tid *)  proc,
struct ubik_trans atrans,
int  aflags 
)

Perform an operation at a quorum, handling error conditions.

Returns:
0 if all worked and a quorum was contacted successfully
otherwise mark failing server as down and return #UERROR
Note:
If any server misses an update, we must wait #BIGTIME seconds before allowing the transaction to commit, to ensure that the missing and possibly still functioning server times out and stops handing out old data. This is done in the commit code, where we wait for a server marked down to have stayed down for #BIGTIME seconds before we allow a transaction to commit. A server that fails but comes back up won't give out old data because it is sent the sync count along with the beacon message that marks it as really up (beaconSinceDown).
void panic ( char *  format,
  ... 
)

"Who said anything about panicking?" snapped Arthur.

"This is still just the culture shock. You wait till I've settled down into the situation and found my bearings. \em Then I'll start panicking!" --Authur Dent

Returns:
There is no return from panic.
int ubik_BeginTrans ( struct ubik_dbase dbase,
afs_int32  transMode,
struct ubik_trans **  transPtr 
)
See also:
BeginTrans()
int ubik_BeginTransReadAny ( struct ubik_dbase dbase,
afs_int32  transMode,
struct ubik_trans **  transPtr 
)
See also:
BeginTrans()
int ubik_BeginTransReadAnyWrite ( struct ubik_dbase dbase,
afs_int32  transMode,
struct ubik_trans **  transPtr 
)
See also:
BeginTrans()
int ubik_CheckCache ( struct ubik_trans atrans,
ubik_updatecache_func  cbf,
void *  rock 
)

check and possibly update cache of ubik db.

If the version of the cached db data is out of date, this calls (*check) to update the cache. If (*check) returns success, we update the version of the cached db data.

Checking the version of the cached db data is done under a read lock; updating the cache (and thus calling (*check)) is done under a write lock so is guaranteed not to interfere with another thread's (*check). On successful return, a read lock on the cached db data is obtained, which will be released by ubik_EndTrans or ubik_AbortTrans.

Parameters:
[in]atransubik transaction
[in]checkfunction to call to check/update cache
[in]rockrock to pass to *check
Returns:
operation status
Return values:
0success
nonzeroerror; cachedVersion not updated
Postcondition:
On success, application cache is read-locked, and cache data is up-to-date
int ubik_EndTrans ( struct ubik_trans transPtr)

This routine ends a read or write transaction on the open transaction identified by transPtr.

Returns:
an error code.
int ubik_Flush ( struct ubik_trans transPtr)

This routine will flush the io data in the iovec structures.

It first flushes to the local disk and then uses ContactQuorum to write it to the other servers.

int ubik_Read ( struct ubik_trans transPtr,
void *  buffer,
afs_int32  length 
)

This routine reads length bytes into buffer from the current position in the database.

The file pointer is updated appropriately (by adding the number of bytes actually transferred), and the length actually transferred is stored in the long integer pointed to by length. A short read returns zero for an error code.

Note:
*length is an INOUT parameter: at the start it represents the size of the buffer, and when done, it contains the number of bytes actually transferred.
int ubik_Seek ( struct ubik_trans transPtr,
afs_int32  fileid,
afs_int32  position 
)

This sets the file pointer associated with the current transaction to the appropriate file and byte position.

Unlike Unix files, a transaction is labelled by both a file number fileid and a byte position relative to the specified file position.

int ubik_ServerInit ( afs_uint32  myHost,
short  myPort,
afs_uint32  serverList[],
const char *  pathName,
struct ubik_dbase **  dbase 
)
See also:
ubik_ServerInitCommon()
int ubik_ServerInitByInfo ( afs_uint32  myHost,
short  myPort,
struct afsconf_cell info,
char  clones[],
const char *  pathName,
struct ubik_dbase **  dbase 
)
See also:
ubik_ServerInitCommon()
afs_uint32 ubikGetPrimaryInterfaceAddr ( afs_uint32  addr)

This function takes an IP addresses as its parameter.

It returns the the primary IP address that is on the host passed in, or 0 if not found.

 All Data Structures Files Functions Variables