static int
ContactQuorum_iterate(struct ubik_trans *atrans, int aflags, struct ubik_server **ts,
struct rx_connection **conn, afs_int32 *rcode,
- afs_int32 *okcalls, afs_int32 code)
+ afs_int32 *okcalls, afs_int32 code, const char *procname)
{
if (!*ts) {
/* Initial call - start iterating over servers */
Quorum_EndIO(atrans, *conn);
*conn = NULL;
if (code) { /* failure */
+ char hoststr[16];
+
*rcode = code;
UBIK_BEACON_LOCK;
(*ts)->up = 0; /* mark as down now; beacons will no longer be sent */
UBIK_BEACON_UNLOCK;
(*ts)->currentDB = 0;
urecovery_LostServer(*ts); /* tell recovery to try to resend dbase later */
+ ViceLog(0, ("Server %s is marked down due to %s code %d\n",
+ afs_inet_ntoa_r((*ts)->addr[0], hoststr), procname, *rcode));
} else { /* success */
if (!(*ts)->isClone)
(*okcalls)++; /* count up how many worked */
* because it is sent the sync count along with the beacon message that
* marks it as \b really up (\p beaconSinceDown).
*/
-afs_int32
+static afs_int32
ContactQuorum_NoArguments(afs_int32 (*proc)(struct rx_connection *, ubik_tid *),
- struct ubik_trans *atrans, int aflags)
+ struct ubik_trans *atrans, int aflags, const char *procname)
{
struct ubik_server *ts = NULL;
afs_int32 code = 0, rcode, okcalls;
struct rx_connection *conn;
int done;
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
while (!done) {
if (conn)
code = (*proc)(conn, &atrans->tid);
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
}
return ContactQuorum_rcode(okcalls, rcode);
}
-afs_int32
+static 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 code = 0, rcode, okcalls;
struct rx_connection *conn;
int done;
+ char *procname = "DISK_Lock";
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
while (!done) {
if (conn)
code = DISK_Lock(conn, &atrans->tid, file, position, length, type);
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
}
return ContactQuorum_rcode(okcalls, rcode);
}
-
-afs_int32
-ContactQuorum_DISK_Write(struct ubik_trans *atrans, int aflags,
- afs_int32 file, afs_int32 position, bulkdata *data)
-{
- struct ubik_server *ts = NULL;
- afs_int32 code = 0, rcode, okcalls;
- struct rx_connection *conn;
- int done;
-
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
- while (!done) {
- if (conn)
- code = DISK_Write(conn, &atrans->tid, file, position, data);
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
- }
- return ContactQuorum_rcode(okcalls, rcode);
-}
-
-
-afs_int32
+static afs_int32
ContactQuorum_DISK_Truncate(struct ubik_trans *atrans, int aflags,
afs_int32 file, afs_int32 length)
{
afs_int32 code = 0, rcode, okcalls;
struct rx_connection *conn;
int done;
+ char *procname = "DISK_Truncate";
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
while (!done) {
if (conn)
code = DISK_Truncate(conn, &atrans->tid, file, length);
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
}
return ContactQuorum_rcode(okcalls, rcode);
}
-afs_int32
+static afs_int32
ContactQuorum_DISK_WriteV(struct ubik_trans *atrans, int aflags,
iovec_wrt * io_vector, iovec_buf *io_buffer)
{
afs_int32 code = 0, rcode, okcalls;
struct rx_connection *conn;
int done;
+ char *procname = "DISK_WriteV";
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
while (!done) {
if (conn) {
+ procname = "DISK_WriteV"; /* in case previous fallback to DISK_Write */
code = DISK_WriteV(conn, &atrans->tid, io_vector, io_buffer);
if ((code <= -450) && (code > -500)) {
/* An RPC interface mismatch (as defined in comerr/error_msg.c).
bulkdata tcbs;
afs_int32 i, offset;
+ procname = "DISK_Write"; /* for accurate error msg, if any */
for (i = 0, offset = 0; i < io_vector->iovec_wrt_len; i++) {
/* Sanity check for going off end of buffer */
if ((offset + iovec[i].length) > io_buffer->iovec_buf_len) {
}
}
}
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
}
return ContactQuorum_rcode(okcalls, rcode);
}
afs_int32 code = 0, rcode, okcalls;
struct rx_connection *conn;
int done;
+ char *procname = "DISK_SetVersion";
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
while (!done) {
if (conn)
code = DISK_SetVersion(conn, &atrans->tid, OldVersion, NewVersion);
- done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code);
+ done = ContactQuorum_iterate(atrans, aflags, &ts, &conn, &rcode, &okcalls, code, procname);
}
return ContactQuorum_rcode(okcalls, rcode);
}
initialize_U_error_table();
- tdb = malloc(sizeof(struct ubik_dbase));
+ tdb = calloc(1, sizeof(*tdb));
tdb->pathName = strdup(pathName);
- tdb->activeTrans = (struct ubik_trans *)0;
- memset(&tdb->version, 0, sizeof(struct ubik_version));
- memset(&tdb->cachedVersion, 0, sizeof(struct ubik_version));
#ifdef AFS_PTHREAD_ENV
opr_mutex_init(&tdb->versionLock);
opr_mutex_init(&beacon_globals.beacon_lock);
Lock_Init(&tdb->versionLock);
#endif
Lock_Init(&tdb->cache_lock);
- tdb->flags = 0;
tdb->read = uphys_read;
tdb->write = uphys_write;
tdb->truncate = uphys_truncate;
tdb->getlabel = uphys_getlabel;
tdb->setlabel = uphys_setlabel;
tdb->getnfiles = uphys_getnfiles;
- tdb->readers = 0;
- tdb->tidCounter = tdb->writeTidCounter = 0;
+ tdb->buffered_append = uphys_buf_append;
*dbase = tdb;
ubik_dbase = tdb; /* for now, only one db per server; can fix later when we have names for the other dbases */
#ifdef AFS_PTHREAD_ENV
- opr_cv_init(&tdb->version_cond);
opr_cv_init(&tdb->flags_cond);
#endif /* AFS_PTHREAD_ENV */
rx_NewService(0, VOTE_SERVICE_ID, "VOTE", ubik_sc, numClasses,
VOTE_ExecuteRequest);
if (tservice == (struct rx_service *)0) {
- ViceLog(5, ("Could not create VOTE rx service!\n"));
+ ViceLog(0, ("Could not create VOTE rx service!\n"));
return -1;
}
rx_SetMinProcs(tservice, 2);
rx_NewService(0, DISK_SERVICE_ID, "DISK", ubik_sc, numClasses,
DISK_ExecuteRequest);
if (tservice == (struct rx_service *)0) {
- ViceLog(5, ("Could not create DISK rx service!\n"));
+ ViceLog(0, ("Could not create DISK rx service!\n"));
return -1;
}
rx_SetMinProcs(tservice, 2);
* don't know how to restore one without possibly picking up some data from the other. */
if (transMode == UBIK_WRITETRANS) {
/* if we're writing already, wait */
- while (dbase->flags & DBWRITING) {
+ while (dbase->dbFlags & DBWRITING) {
#ifdef AFS_PTHREAD_ENV
opr_cv_wait(&dbase->flags_cond, &dbase->versionLock);
#else
DBRELE(dbase);
- LWP_WaitProcess(&dbase->flags);
+ LWP_WaitProcess(&dbase->dbFlags);
DBHOLD(dbase);
#endif
}
if (transMode == UBIK_WRITETRANS) {
/* next try to start transaction on appropriate number of machines */
- code = ContactQuorum_NoArguments(DISK_Begin, tt, CCheckSyncAdvertised);
+ code = ContactQuorum_NoArguments(DISK_Begin, tt, CCheckSyncAdvertised, "DISK_Begin");
if (code) {
/* we must abort the operation */
udisk_abort(tt);
- ContactQuorum_NoArguments(DISK_Abort, tt, 0); /* force aborts to the others */
+ /* force aborts to the others */
+ ContactQuorum_NoArguments(DISK_Abort, tt, 0, "DISK_Abort");
udisk_end(tt);
DBRELE(dbase);
return code;
}
/* now it is safe to try remote abort */
- code = ContactQuorum_NoArguments(DISK_Abort, transPtr, 0);
+ code = ContactQuorum_NoArguments(DISK_Abort, transPtr, 0, "DISK_Abort");
code2 = udisk_abort(transPtr);
udisk_end(transPtr);
DBRELE(dbase);
ReleaseWriteLock(&dbase->cache_lock);
- code = ContactQuorum_NoArguments(DISK_Commit, transPtr, CStampVersion);
+ code = ContactQuorum_NoArguments(DISK_Commit, transPtr, CStampVersion, "DISK_Commit");
} else {
memset(&dbase->cachedVersion, 0, sizeof(struct ubik_version));
* we lose. If we contact a majority of sites, then we won't be here: contacting
* a majority guarantees commit, since it guarantees that one dude will be a
* member of the next quorum. */
- ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0);
+ ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0, "DISK_ReleaseLocks");
udisk_end(transPtr);
DBRELE(dbase);
goto error;
* The transaction is committed anyway, since we succeeded in contacting a quorum
* at the start (when invoking the DiskCommit function).
*/
- ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0);
+ ContactQuorum_NoArguments(DISK_ReleaseLocks, transPtr, 0, "DISK_ReleaseLocks");
success:
udisk_end(transPtr);
&transPtr->iovec_data);
if (code) {
udisk_abort(transPtr);
- ContactQuorum_NoArguments(DISK_Abort, transPtr, 0); /* force aborts to the others */
+ /* force aborts to the others */
+ ContactQuorum_NoArguments(DISK_Abort, transPtr, 0, "DISK_Abort");
transPtr->iovec_info.iovec_wrt_len = 0;
transPtr->iovec_data.iovec_buf_len = 0;
ERROR_EXIT(code);
if (code) {
/* we must abort the operation */
udisk_abort(transPtr);
- ContactQuorum_NoArguments(DISK_Abort, transPtr, 0); /* force aborts to the others */
+ /* force aborts to the others */
+ ContactQuorum_NoArguments(DISK_Abort, transPtr, 0, "DISK_Abort");
ERROR_EXIT(code);
}
if (code) {
/* we must abort the operation */
udisk_abort(atrans);
- ContactQuorum_NoArguments(DISK_Abort, atrans, 0); /* force aborts to the others */
+ /* force aborts to the others */
+ ContactQuorum_NoArguments(DISK_Abort, atrans, 0, "DISK_Abort");
ERROR_EXIT(code);
}
}
}
/*!
- * \brief utility to wait for a version # to change
- */
-int
-ubik_WaitVersion(struct ubik_dbase *adatabase,
- struct ubik_version *aversion)
-{
- DBHOLD(adatabase);
- while (1) {
- /* wait until version # changes, and then return */
- if (vcmp(*aversion, adatabase->version) != 0) {
- DBRELE(adatabase);
- return 0;
- }
-#ifdef AFS_PTHREAD_ENV
- opr_cv_wait(&adatabase->version_cond, &adatabase->versionLock);
-#else
- DBRELE(adatabase);
- LWP_WaitProcess(&adatabase->version); /* same vers, just wait */
- DBHOLD(adatabase);
-#endif
- }
-}
-
-/*!
- * \brief utility to get the version of the dbase a transaction is dealing with
- */
-int
-ubik_GetVersion(struct ubik_trans *atrans,
- struct ubik_version *avers)
-{
- DBHOLD(atrans->dbase);
- *avers = atrans->dbase->version;
- DBRELE(atrans->dbase);
- return 0;
-}
-
-/*!
* \brief Facility to simplify database caching.
* \return zero if last trans was done on the local server and was successful.
* \return -1 means bad (NULL) argument.
va_end(ap);
abort();
- ViceLog(0, ("BACK FROM ABORT\n")); /* shouldn't come back */
- exit(1); /* never know, though */
+ AFS_UNREACHED(ViceLog(0, ("BACK FROM ABORT\n")));
+ AFS_UNREACHED(exit(1));
}
/*!