From 354fef1f0af9272cd5bf1e8a6466a3b727dcc08d Mon Sep 17 00:00:00 2001 From: Michael Meffie Date: Mon, 25 Apr 2016 11:06:11 -0400 Subject: [PATCH] ubik: convert ubik_print to ViceLog Use the server logging macros instead of the utility functions to avoid function call overhead, especially at logging level 25. The server logging macros perform a logging level check in-line to avoid the unnecessary ubik_dprint* calls. Reviewed-on: https://gerrit.openafs.org/12619 Reviewed-by: Andrew Deason Reviewed-by: Marcio Brito Barbosa Reviewed-by: Michael Meffie Reviewed-by: Mark Vitale Reviewed-by: Benjamin Kaduk Tested-by: BuildBot (cherry picked from commit 343234d221ae8388f55748f5c494a42d5d69bfa0) Change-Id: Icdb60f75a0c6c6efc7793d545f0565c0cd587eae Reviewed-on: https://gerrit.openafs.org/13153 Reviewed-by: Andrew Deason Reviewed-by: Michael Meffie Reviewed-by: Marcio Brito Barbosa Reviewed-by: Mark Vitale Reviewed-by: Cheyenne Wills Tested-by: BuildBot Reviewed-by: Stephan Wiesand --- src/ubik/beacon.c | 65 +++++++++++++++++++++---------------------- src/ubik/disk.c | 10 +++---- src/ubik/lock.c | 19 +++++++------ src/ubik/recovery.c | 68 ++++++++++++++++++++++----------------------- src/ubik/remote.c | 39 +++++++++++++------------- src/ubik/ubik.c | 17 ++++++------ src/ubik/ubik.p.h | 11 -------- src/ubik/vote.c | 55 ++++++------------------------------ 8 files changed, 117 insertions(+), 167 deletions(-) diff --git a/src/ubik/beacon.c b/src/ubik/beacon.c index 4351cc8b8..7e1cfb650 100644 --- a/src/ubik/beacon.c +++ b/src/ubik/beacon.c @@ -24,9 +24,7 @@ #include #include #include -#ifndef AFS_NT40_ENV #include -#endif #define UBIK_INTERNALS #include "ubik.h" @@ -117,7 +115,7 @@ amSyncSite(void) now = FT_ApproxTime(); if (beacon_globals.syncSiteUntil <= now) { /* if my votes have expired, say so */ if (beacon_globals.ubik_amSyncSite) - ubik_dprint("Ubik: I am no longer the sync site\n"); + ViceLog(5, ("Ubik: I am no longer the sync site\n")); beacon_globals.ubik_amSyncSite = 0; beacon_globals.ubik_syncSiteAdvertised = 0; rcode = 0; @@ -126,7 +124,7 @@ amSyncSite(void) } } UBIK_BEACON_UNLOCK; - ubik_dprint("beacon: amSyncSite is %d\n", rcode); + ViceLog(5, ("beacon: amSyncSite is %d\n", rcode)); return rcode; } @@ -412,7 +410,7 @@ ubeacon_InitServerListCommon(afs_uint32 ame, struct afsconf_cell *info, if (ubik_singleServer) { if (!beacon_globals.ubik_amSyncSite) { - ubik_dprint("Ubik: I am the sync site - 1 server\n"); + ViceLog(5, ("Ubik: I am the sync site - 1 server\n")); DBHOLD(ubik_dbase); UBIK_VERSION_LOCK; version_globals.ubik_epochTime = FT_ApproxTime(); @@ -549,14 +547,14 @@ ubeacon_Interact(void *dummy) * happen due to errors with the rx security class in play * (rxkad, rxgk, etc). treat the host as if we got a * timeout, since this is not a valid vote. */ - ubik_print("assuming distant vote time %d from %s is an error; marking host down\n", - (int)code, afs_inet_ntoa_r(ts->addr[0], hoststr)); + ViceLog(0, ("assuming distant vote time %d from %s is an error; marking host down\n", + (int)code, afs_inet_ntoa_r(ts->addr[0], hoststr))); code = -1; } if (code > 0 && rx_ConnError(connections[multi_i])) { - ubik_print("assuming vote from %s is invalid due to conn error %d; marking host down\n", + ViceLog(0, ("assuming vote from %s is invalid due to conn error %d; marking host down\n", afs_inet_ntoa_r(ts->addr[0], hoststr), - (int)rx_ConnError(connections[multi_i])); + (int)rx_ConnError(connections[multi_i]))); code = -1; } @@ -565,8 +563,8 @@ ubeacon_Interact(void *dummy) * the latter down below if we got enough votes to go with */ if (code > 0) { if ((code & ~0xff) == ERROR_TABLE_BASE_RXK) { - ubik_dprint("token error %d from host %s\n", - code, afs_inet_ntoa_r(ts->addr[0], hoststr)); + ViceLog(5, ("token error %d from host %s\n", + code, afs_inet_ntoa_r(ts->addr[0], hoststr))); ts->up = 0; ts->beaconSinceDown = 0; urecovery_LostServer(ts); @@ -581,21 +579,21 @@ ubeacon_Interact(void *dummy) yesVotes++; /* the extra epsilon */ ts->up = 1; /* server is up (not really necessary: recovery does this for real) */ ts->beaconSinceDown = 1; - ubik_dprint("yes vote from host %s\n", - afs_inet_ntoa_r(ts->addr[0], hoststr)); + ViceLog(5, ("yes vote from host %s\n", + afs_inet_ntoa_r(ts->addr[0], hoststr))); } } else if (code == 0) { ts->lastVoteTime = temp; ts->lastVote = 0; ts->beaconSinceDown = 1; - ubik_dprint("no vote from %s\n", - afs_inet_ntoa_r(ts->addr[0], hoststr)); + ViceLog(5, ("no vote from %s\n", + afs_inet_ntoa_r(ts->addr[0], hoststr))); } else if (code < 0) { ts->up = 0; ts->beaconSinceDown = 0; urecovery_LostServer(ts); - ubik_dprint("time out from %s\n", - afs_inet_ntoa_r(ts->addr[0], hoststr)); + ViceLog(5, ("time out from %s\n", + afs_inet_ntoa_r(ts->addr[0], hoststr))); } UBIK_BEACON_UNLOCK; } @@ -620,7 +618,7 @@ ubeacon_Interact(void *dummy) if (yesVotes > nServers) { /* yesVotes is bumped by 2 or 3 for each site */ UBIK_BEACON_LOCK; if (!beacon_globals.ubik_amSyncSite) { - ubik_dprint("Ubik: I am the sync site\n"); + ViceLog(5, ("Ubik: I am the sync site\n")); /* Defer actually changing any variables until we can take the * DB lock (which is before the beacon lock in the lock order). */ becameSyncSite = 1; @@ -634,7 +632,7 @@ ubeacon_Interact(void *dummy) } else { UBIK_BEACON_LOCK; if (beacon_globals.ubik_amSyncSite) - ubik_dprint("Ubik: I am no longer the sync site\n"); + ViceLog(5, ("Ubik: I am no longer the sync site\n")); beacon_globals.ubik_amSyncSite = 0; beacon_globals.ubik_syncSiteAdvertised = 0; UBIK_BEACON_UNLOCK; @@ -711,9 +709,9 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info, AFSDIR_SERVER_NETINFO_FILEPATH, AFSDIR_SERVER_NETRESTRICT_FILEPATH); if (count < 0) { - ubik_print("ubik: Can't register any valid addresses:%s\n", - reason); - ubik_print("Aborting..\n"); + ViceLog(0, ("ubik: Can't register any valid addresses:%s\n", + reason)); + ViceLog(0, ("Aborting..\n")); return UBADHOST; } usednetfiles++; @@ -723,7 +721,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info, } if (count <= 0) { /* no address found */ - ubik_print("ubik: No network addresses found, aborting..\n"); + ViceLog(0, ("ubik: No network addresses found, aborting..\n")); return UBADHOST; } @@ -736,8 +734,8 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info, } if (!found) { - ubik_print("ubik: primary address %s does not exist\n", - afs_inet_ntoa_r(*ame, hoststr)); + ViceLog(0, ("ubik: primary address %s does not exist\n", + afs_inet_ntoa_r(*ame, hoststr))); /* if we had the result of rx_getAllAddr already, avoid subverting * the "is gethostbyname(gethostname()) us" check. If we're * using NetInfo/NetRestrict, we assume they have enough clue @@ -747,7 +745,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info, *ame = myAddr[0]; tcount = rx_getAllAddr(myAddr2, UBIK_MAX_INTERFACE_ADDR); if (tcount <= 0) { /* no address found */ - ubik_print("ubik: No network addresses found, aborting..\n"); + ViceLog(0, ("ubik: No network addresses found, aborting..\n")); return UBADHOST; } @@ -782,7 +780,7 @@ verifyInterfaceAddress(afs_uint32 *ame, struct afsconf_cell *info, } } if (found) - ubik_print("Using %s as my primary address\n", afs_inet_ntoa_r(*ame, hoststr)); + ViceLog(0, ("Using %s as my primary address\n", afs_inet_ntoa_r(*ame, hoststr))); if (!info) { /* get rid of servers which were purged because all @@ -864,9 +862,9 @@ ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR]) if (ts->addr[0] != htonl(outAddr.hostAddr[0])) { code = UBADHOST; strcpy(buffer, afs_inet_ntoa_r(ts->addr[0], hoststr)); - ubik_print("ubik:Two primary addresses for same server \ + ViceLog(0, ("ubik:Two primary addresses for same server \ %s %s\n", buffer, - afs_inet_ntoa_r(htonl(outAddr.hostAddr[0]), hoststr)); + afs_inet_ntoa_r(htonl(outAddr.hostAddr[0]), hoststr))); } else { for (j = 1; j < UBIK_MAX_INTERFACE_ADDR; j++) ts->addr[j] = htonl(outAddr.hostAddr[j]); @@ -874,16 +872,15 @@ ubeacon_updateUbikNetworkAddress(afs_uint32 ubik_host[UBIK_MAX_INTERFACE_ADDR]) UBIK_ADDR_UNLOCK; } else if (multi_error == RXGEN_OPCODE) { /* pre 3.5 remote server */ UBIK_ADDR_LOCK; - ubik_print - ("ubik server %s does not support UpdateInterfaceAddr RPC\n", - afs_inet_ntoa_r(ts->addr[0], hoststr)); + ViceLog(0, ("ubik server %s does not support UpdateInterfaceAddr RPC\n", + afs_inet_ntoa_r(ts->addr[0], hoststr))); UBIK_ADDR_UNLOCK; } else if (multi_error == UBADHOST) { code = UBADHOST; /* remote CellServDB inconsistency */ - ubik_print("Inconsistent Cell Info on server:\n"); + ViceLog(0, ("Inconsistent Cell Info on server:\n")); UBIK_ADDR_LOCK; for (j = 0; j < UBIK_MAX_INTERFACE_ADDR && ts->addr[j]; j++) - ubik_print("... %s\n", afs_inet_ntoa_r(ts->addr[j], hoststr)); + ViceLog(0, ("... %s\n", afs_inet_ntoa_r(ts->addr[j], hoststr))); UBIK_ADDR_UNLOCK; } else { UBIK_BEACON_LOCK; diff --git a/src/ubik/disk.c b/src/ubik/disk.c index 2cf419afe..24d6a68ee 100644 --- a/src/ubik/disk.c +++ b/src/ubik/disk.c @@ -18,6 +18,7 @@ #else # include #endif +#include #define UBIK_INTERNALS #include "ubik.h" @@ -380,7 +381,7 @@ DRead(struct ubik_trans *atrans, afs_int32 fid, int page) tb->file = BADFID; Dlru(tb); tb->lockers--; - ubik_print("Ubik: Error reading database file: errno=%d\n", errno); + ViceLog(0, ("Ubik: Error reading database file: errno=%d\n", errno)); return 0; } ios++; @@ -545,8 +546,7 @@ newslot(struct ubik_dbase *adbase, afs_int32 afid, afs_int32 apage) if (pp == 0) { /* There are no unlocked buffers that don't need to be written to the disk. */ - ubik_print - ("Ubik: Internal Error: Unable to find free buffer in ubik cache\n"); + ViceLog(0, ("Ubik: Internal Error: Unable to find free buffer in ubik cache\n")); return NULL; } @@ -878,9 +878,9 @@ udisk_commit(struct ubik_trans *atrans) UBIK_VERSION_LOCK; if (version_globals.ubik_epochTime < UBIK_MILESTONE || version_globals.ubik_epochTime > now) { - ubik_print + ViceLog(0, ("Ubik: New database label %d is out of the valid range (%d - %d)\n", - version_globals.ubik_epochTime, UBIK_MILESTONE, now); + version_globals.ubik_epochTime, UBIK_MILESTONE, now)); panic("Writing Ubik DB label\n"); } oldversion = dbase->version; diff --git a/src/ubik/lock.c b/src/ubik/lock.c index ba368937f..c13837522 100644 --- a/src/ubik/lock.c +++ b/src/ubik/lock.c @@ -17,6 +17,7 @@ # include #endif #include +#include #define UBIK_INTERNALS 1 #include "ubik.h" @@ -83,13 +84,13 @@ ulock_getLock(struct ubik_trans *atrans, int atype, int await) } if (atrans->locktype != 0) { - ubik_print("Ubik: Internal Error: attempted to take lock twice\n"); + ViceLog(0, ("Ubik: Internal Error: attempted to take lock twice\n")); abort(); } /* - *ubik_print("Ubik: DEBUG: Thread 0x%x request %s lock\n", lwp_cpptr, - * ((atype == LOCKREAD) ? "READ" : "WRITE")); + *ViceLog(0, ("Ubik: DEBUG: Thread 0x%x request %s lock\n", lwp_cpptr, + * ((atype == LOCKREAD) ? "READ" : "WRITE"))); */ /* Check if the lock would would block */ @@ -120,8 +121,8 @@ ulock_getLock(struct ubik_trans *atrans, int atype, int await) atrans->locktype = atype; /* - *ubik_print("Ubik: DEBUG: Thread 0x%x took %s lock\n", lwp_cpptr, - * ((atype == LOCKREAD) ? "READ" : "WRITE")); + *ViceLog(0, ("Ubik: DEBUG: Thread 0x%x took %s lock\n", lwp_cpptr, + * ((atype == LOCKREAD) ? "READ" : "WRITE"))); */ return 0; } @@ -133,8 +134,8 @@ void ulock_relLock(struct ubik_trans *atrans) { if (atrans->locktype == LOCKWRITE && (atrans->flags & TRREADWRITE)) { - ubik_print("Ubik: Internal Error: unlocking write lock with " - "TRREADWRITE?\n"); + ViceLog(0, ("Ubik: Internal Error: unlocking write lock with " + "TRREADWRITE?\n")); abort(); } @@ -147,8 +148,8 @@ ulock_relLock(struct ubik_trans *atrans) } /* - *ubik_print("Ubik: DEBUG: Thread 0x%x %s unlock\n", lwp_cpptr, - * ((atrans->locktype == LOCKREAD) ? "READ" : "WRITE")); + *ViceLog(0, ("Ubik: DEBUG: Thread 0x%x %s unlock\n", lwp_cpptr, + * ((atrans->locktype == LOCKREAD) ? "READ" : "WRITE"))); */ atrans->locktype = 0; diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index 1d2f85ae5..199d15fc7 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -99,7 +99,7 @@ urecovery_AllBetter(struct ubik_dbase *adbase, int areadAny) { afs_int32 rcode; - ubik_dprint_25("allbetter checking\n"); + ViceLog(25, ("allbetter checking\n")); rcode = 0; @@ -122,7 +122,7 @@ urecovery_AllBetter(struct ubik_dbase *adbase, int areadAny) rcode = 1; } - ubik_dprint_25("allbetter: returning %d\n", rcode); + ViceLog(25, ("allbetter: returning %d\n", rcode)); return rcode; } @@ -236,8 +236,8 @@ ReplayLog(struct ubik_dbase *adbase) /* otherwise, skip over the data bytes, too */ tpos += ntohl(buffer[2]) + 3 * sizeof(afs_int32); } else { - ubik_print("corrupt log opcode (%d) at position %d\n", opcode, - tpos); + ViceLog(0, ("corrupt log opcode (%d) at position %d\n", opcode, + tpos)); break; /* corrupt log! */ } } @@ -272,9 +272,9 @@ ReplayLog(struct ubik_dbase *adbase) code = (*adbase->setlabel) (adbase, 0, &version); if (code) return code; - ubik_print("Successfully replayed log for interrupted " + ViceLog(0, ("Successfully replayed log for interrupted " "transaction; db version is now %ld.%ld\n", - (long) version.epoch, (long) version.counter); + (long) version.epoch, (long) version.counter)); logIsGood = 1; break; /* all done now */ } else if (opcode == LOGTRUNCATE) { @@ -330,8 +330,8 @@ ReplayLog(struct ubik_dbase *adbase) len -= thisSize; } } else { - ubik_print("corrupt log opcode (%d) at position %d\n", - opcode, tpos); + ViceLog(0, ("corrupt log opcode (%d) at position %d\n", + opcode, tpos)); break; /* corrupt log! */ } } @@ -341,7 +341,7 @@ ReplayLog(struct ubik_dbase *adbase) if (code) return code; } else { - ubik_print("Log read error on pass 2\n"); + ViceLog(0, ("Log read error on pass 2\n")); return UBADLOG; } } @@ -472,7 +472,7 @@ urecovery_Interact(void *dummy) IOMGR_Select(0, 0, 0, 0, &tv); #endif - ubik_dprint("recovery running in state %x\n", urecovery_state); + ViceLog(5, ("recovery running in state %x\n", urecovery_state)); /* Every 30 seconds, check all the down servers and mark them * as up if they respond. When a server comes up or found to @@ -599,19 +599,19 @@ urecovery_Interact(void *dummy) UBIK_ADDR_LOCK; rxcall = rx_NewCall(bestServer->disk_rxcid); - ubik_print("Ubik: Synchronize database with server %s\n", - afs_inet_ntoa_r(bestServer->addr[0], hoststr)); + ViceLog(0, ("Ubik: Synchronize database with server %s\n", + afs_inet_ntoa_r(bestServer->addr[0], hoststr))); UBIK_ADDR_UNLOCK; code = StartDISK_GetFile(rxcall, file); if (code) { - ubik_dprint("StartDiskGetFile failed=%d\n", code); + ViceLog(5, ("StartDiskGetFile failed=%d\n", code)); goto FetchEndCall; } nbytes = rx_Read(rxcall, (char *)&length, sizeof(afs_int32)); length = ntohl(length); if (nbytes != sizeof(afs_int32)) { - ubik_dprint("Rx-read length error=%d\n", code = BULK_ERROR); + ViceLog(5, ("Rx-read length error=%d\n", code = BULK_ERROR)); code = EIO; goto FetchEndCall; } @@ -622,7 +622,7 @@ urecovery_Interact(void *dummy) code = (*ubik_dbase->setlabel) (ubik_dbase, file, &tversion); UBIK_VERSION_UNLOCK; if (code) { - ubik_dprint("setlabel io error=%d\n", code); + ViceLog(5, ("setlabel io error=%d\n", code)); goto FetchEndCall; } snprintf(pbuffer, sizeof(pbuffer), "%s.DB%s%d.TMP", @@ -648,7 +648,7 @@ urecovery_Interact(void *dummy) #endif nbytes = rx_Read(rxcall, tbuffer, tlen); if (nbytes != tlen) { - ubik_dprint("Rx-read bulk error=%d\n", code = BULK_ERROR); + ViceLog(5, ("Rx-read bulk error=%d\n", code = BULK_ERROR)); code = EIO; close(fd); goto FetchEndCall; @@ -716,10 +716,10 @@ urecovery_Interact(void *dummy) ubik_dbase->version.epoch = 0; ubik_dbase->version.counter = 0; UBIK_VERSION_UNLOCK; - ubik_print("Ubik: Synchronize database failed (error = %d)\n", - code); + ViceLog(0, ("Ubik: Synchronize database failed (error = %d)\n", + code)); } else { - ubik_print("Ubik: Synchronize database completed\n"); + ViceLog(0, ("Ubik: Synchronize database completed\n")); urecovery_state |= UBIK_RECHAVEDB; } udisk_Invalidate(ubik_dbase, 0); /* data has changed */ @@ -798,16 +798,16 @@ urecovery_Interact(void *dummy) UBIK_BEACON_LOCK; if (!ts->up) { UBIK_BEACON_UNLOCK; - ubik_dprint("recovery cannot send version to %s\n", - afs_inet_ntoa_r(inAddr.s_addr, hoststr)); + ViceLog(5, ("recovery cannot send version to %s\n", + afs_inet_ntoa_r(inAddr.s_addr, hoststr))); dbok = 0; continue; } UBIK_BEACON_UNLOCK; - ubik_dprint("recovery sending version to %s\n", - afs_inet_ntoa_r(inAddr.s_addr, hoststr)); + ViceLog(5, ("recovery sending version to %s\n", + afs_inet_ntoa_r(inAddr.s_addr, hoststr))); if (vcmp(ts->version, ubik_dbase->version) != 0) { - ubik_dprint("recovery stating local database\n"); + ViceLog(5, ("recovery stating local database\n")); /* Rx code to do the Bulk Store */ code = (*ubik_dbase->stat) (ubik_dbase, 0, &ubikstat); @@ -821,8 +821,8 @@ urecovery_Interact(void *dummy) StartDISK_SendFile(rxcall, file, length, &ubik_dbase->version); if (code) { - ubik_dprint("StartDiskSendFile failed=%d\n", - code); + ViceLog(5, ("StartDiskSendFile failed=%d\n", + code)); goto StoreEndCall; } while (length > 0) { @@ -833,14 +833,14 @@ urecovery_Interact(void *dummy) (*ubik_dbase->read) (ubik_dbase, file, tbuffer, offset, tlen); if (nbytes != tlen) { - ubik_dprint("Local disk read error=%d\n", - code = UIOERROR); + ViceLog(5, ("Local disk read error=%d\n", + code = UIOERROR)); goto StoreEndCall; } nbytes = rx_Write(rxcall, tbuffer, tlen); if (nbytes != tlen) { - ubik_dprint("Rx-write bulk error=%d\n", code = - BULK_ERROR); + ViceLog(5, ("Rx-write bulk error=%d\n", code = + BULK_ERROR)); goto StoreEndCall; } offset += tlen; @@ -928,8 +928,8 @@ DoProbe(struct ubik_server *server) connSuccess = conns[success_i]; strcpy(buffer, afs_inet_ntoa_r(server->addr[0], hoststr)); - ubik_print("ubik:server %s is back up: will be contacted through %s\n", - buffer, afs_inet_ntoa_r(addr, hoststr)); + ViceLog(0, ("ubik:server %s is back up: will be contacted through %s\n", + buffer, afs_inet_ntoa_r(addr, hoststr))); UBIK_ADDR_UNLOCK; } @@ -939,8 +939,8 @@ DoProbe(struct ubik_server *server) rx_DestroyConnection(conns[i]); if (!connSuccess) - ubik_dprint("ubik:server %s still down\n", - afs_inet_ntoa_r(server->addr[0], hoststr)); + ViceLog(5, ("ubik:server %s still down\n", + afs_inet_ntoa_r(server->addr[0], hoststr))); if (connSuccess) return 0; /* success */ diff --git a/src/ubik/remote.c b/src/ubik/remote.c index 2fca3b15b..6b78d530b 100644 --- a/src/ubik/remote.c +++ b/src/ubik/remote.c @@ -412,7 +412,7 @@ SDISK_GetFile(struct rx_call *rxcall, afs_int32 file, code = rx_Write(rxcall, (char *)&tlen, sizeof(afs_int32)); if (code != sizeof(afs_int32)) { DBRELE(dbase); - ubik_dprint("Rx-write length error=%d\n", code); + ViceLog(5, ("Rx-write length error=%d\n", code)); return BULK_ERROR; } offset = 0; @@ -421,13 +421,13 @@ SDISK_GetFile(struct rx_call *rxcall, afs_int32 file, code = (*dbase->read) (dbase, file, tbuffer, offset, tlen); if (code != tlen) { DBRELE(dbase); - ubik_dprint("read failed error=%d\n", code); + ViceLog(5, ("read failed error=%d\n", code)); return UIOERROR; } code = rx_Write(rxcall, tbuffer, tlen); if (code != tlen) { DBRELE(dbase); - ubik_dprint("Rx-write length error=%d\n", code); + ViceLog(5, ("Rx-write length error=%d\n", code)); return BULK_ERROR; } length -= tlen; @@ -483,10 +483,10 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file, if (offset && offset != otherHost) { /* we *know* this is the wrong guy */ char sync_hoststr[16]; - ubik_print + ViceLog(0, ("Ubik: Refusing synchronization with server %s since it is not the sync-site (%s).\n", afs_inet_ntoa_r(otherHost, hoststr), - afs_inet_ntoa_r(offset, sync_hoststr)); + afs_inet_ntoa_r(offset, sync_hoststr))); return USYNC; } @@ -495,8 +495,8 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file, /* abort any active trans that may scribble over the database */ urecovery_AbortAll(dbase); - ubik_print("Ubik: Synchronize database with server %s\n", - afs_inet_ntoa_r(otherHost, hoststr)); + ViceLog(0, ("Ubik: Synchronize database with server %s\n", + afs_inet_ntoa_r(otherHost, hoststr))); offset = 0; UBIK_VERSION_LOCK; @@ -526,7 +526,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file, #endif code = rx_Read(rxcall, tbuffer, tlen); if (code != tlen) { - ubik_dprint("Rx-read length error=%d\n", code); + ViceLog(5, ("Rx-read length error=%d\n", code)); code = BULK_ERROR; close(fd); goto failed; @@ -534,7 +534,7 @@ SDISK_SendFile(struct rx_call *rxcall, afs_int32 file, code = write(fd, tbuffer, tlen); pass++; if (code != tlen) { - ubik_dprint("write failed error=%d\n", code); + ViceLog(5, ("write failed error=%d\n", code)); code = UIOERROR; close(fd); goto failed; @@ -594,12 +594,11 @@ failed: (*dbase->setlabel) (dbase, file, &tversion); UBIK_VERSION_UNLOCK; } - ubik_print - ("Ubik: Synchronize database with server %s failed (error = %d)\n", - afs_inet_ntoa_r(otherHost, hoststr), code); + ViceLog(0, ("Ubik: Synchronize database with server %s failed (error = %d)\n", + afs_inet_ntoa_r(otherHost, hoststr), code)); } else { uvote_set_dbVersion(*avers); - ubik_print("Ubik: Synchronize database completed\n"); + ViceLog(0, ("Ubik: Synchronize database completed\n")); } DBRELE(dbase); return code; @@ -663,9 +662,9 @@ SDISK_UpdateInterfaceAddr(struct rx_call *rxcall, /* if (probableMatch) */ /* inconsistent addresses in CellServDB */ if (!probableMatch || found) { - ubik_print("Inconsistent Cell Info from server:\n"); + ViceLog(0, ("Inconsistent Cell Info from server:\n")); for (i = 0; i < UBIK_MAX_INTERFACE_ADDR && inAddr->hostAddr[i]; i++) - ubik_print("... %s\n", afs_inet_ntoa_r(htonl(inAddr->hostAddr[i]), hoststr)); + ViceLog(0, ("... %s\n", afs_inet_ntoa_r(htonl(inAddr->hostAddr[i]), hoststr))); fflush(stdout); fflush(stderr); printServerInfo(); @@ -677,9 +676,9 @@ SDISK_UpdateInterfaceAddr(struct rx_call *rxcall, for (i = 1; i < UBIK_MAX_INTERFACE_ADDR; i++) ts->addr[i] = htonl(inAddr->hostAddr[i]); - ubik_print("ubik: A Remote Server has addresses:\n"); + ViceLog(0, ("ubik: A Remote Server has addresses:\n")); for (i = 0; i < UBIK_MAX_INTERFACE_ADDR && ts->addr[i]; i++) - ubik_print("... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr)); + ViceLog(0, ("... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr))); UBIK_ADDR_UNLOCK; @@ -704,11 +703,11 @@ printServerInfo(void) int i, j = 1; char hoststr[16]; - ubik_print("Local CellServDB:\n"); + ViceLog(0, ("Local CellServDB:\n")); for (ts = ubik_servers; ts; ts = ts->next, j++) { - ubik_print(" Server %d:\n", j); + ViceLog(0, (" Server %d:\n", j)); for (i = 0; (i < UBIK_MAX_INTERFACE_ADDR) && ts->addr[i]; i++) - ubik_print(" ... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr)); + ViceLog(0, (" ... %s\n", afs_inet_ntoa_r(ts->addr[i], hoststr))); } } diff --git a/src/ubik/ubik.c b/src/ubik/ubik.c index bc04f9972..fb764c5c6 100644 --- a/src/ubik/ubik.c +++ b/src/ubik/ubik.c @@ -23,6 +23,7 @@ #include #include #include +#include #define UBIK_INTERNALS @@ -499,7 +500,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, rx_NewService(0, VOTE_SERVICE_ID, "VOTE", ubik_sc, numClasses, VOTE_ExecuteRequest); if (tservice == (struct rx_service *)0) { - ubik_dprint("Could not create VOTE rx service!\n"); + ViceLog(5, ("Could not create VOTE rx service!\n")); return -1; } rx_SetMinProcs(tservice, 2); @@ -509,7 +510,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, rx_NewService(0, DISK_SERVICE_ID, "DISK", ubik_sc, numClasses, DISK_ExecuteRequest); if (tservice == (struct rx_service *)0) { - ubik_dprint("Could not create DISK rx service!\n"); + ViceLog(5, ("Could not create DISK rx service!\n")); return -1; } rx_SetMinProcs(tservice, 2); @@ -612,9 +613,9 @@ BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode, /* it's not safe to use ubik_BeginTransReadAnyWrite without a * cache-syncing function; fall back to ubik_BeginTransReadAny, * which is safe but slower */ - ubik_print("ubik_BeginTransReadAnyWrite called, but " + ViceLog(0, ("ubik_BeginTransReadAnyWrite called, but " "ubik_SyncWriterCacheProc not set; pretending " - "ubik_BeginTransReadAny was called instead\n"); + "ubik_BeginTransReadAny was called instead\n")); readAny = 1; } @@ -905,7 +906,7 @@ ubik_EndTrans(struct ubik_trans *transPtr) * to us, or timeout. Put safety check in anyway */ if (now - realStart > 10 * BIGTIME) { ubik_stats.escapes++; - ubik_print("ubik escaping from commit wait\n"); + ViceLog(0, ("ubik escaping from commit wait\n")); break; } for (ts = ubik_servers; ts; ts = ts->next) { @@ -1392,12 +1393,12 @@ panic(char *format, ...) va_list ap; va_start(ap, format); - ubik_print("Ubik PANIC:\n"); - ubik_vprint(format, ap); + ViceLog(0, ("Ubik PANIC:\n")); + vViceLog(0, (format, ap)); va_end(ap); abort(); - ubik_print("BACK FROM ABORT\n"); /* shouldn't come back */ + ViceLog(0, ("BACK FROM ABORT\n")); /* shouldn't come back */ exit(1); /* never know, though */ } diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h index 3f3d41ba7..a84ca586d 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -547,17 +547,6 @@ extern void ulock_Debug(struct ubik_debug *aparm); extern int uvote_ShouldIRun(void); extern afs_int32 uvote_GetSyncSite(void); extern int uvote_Init(void); -extern void ubik_vprint(const char *format, va_list ap) - AFS_ATTRIBUTE_FORMAT(__printf__, 1, 0); - -extern void ubik_print(const char *format, ...) - AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); - -extern void ubik_dprint(const char *format, ...) - AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); - -extern void ubik_dprint_25(const char *format, ...) - AFS_ATTRIBUTE_FORMAT(__printf__, 1, 2); extern struct vote_data vote_globals; extern void uvote_set_dbVersion(struct ubik_version); extern int uvote_eq_dbVersion(struct ubik_version); diff --git a/src/ubik/vote.c b/src/ubik/vote.c index 2cf1887ec..87cfb3911 100644 --- a/src/ubik/vote.c +++ b/src/ubik/vote.c @@ -201,8 +201,8 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate, /* This is the identifier that ubik uses. */ otherHost = ubikGetPrimaryInterfaceAddr(otherHost); if (!otherHost) { - ubik_dprint("Received beacon from unknown host %s\n", - afs_inet_ntoa_r(rx_HostOf(rxp), hoststr)); + ViceLog(5, ("Received beacon from unknown host %s\n", + afs_inet_ntoa_r(rx_HostOf(rxp), hoststr))); return 0; /* I don't know about you: vote no */ } for (ts = ubik_servers; ts; ts = ts->next) { @@ -210,7 +210,7 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate, break; } if (!ts) - ubik_dprint("Unknown host %x has sent a beacon\n", otherHost); + ViceLog(5, ("Unknown host %x has sent a beacon\n", otherHost)); if (ts && ts->isClone) isClone = 1; } else { @@ -218,8 +218,8 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate, isClone = amIClone; } - ubik_dprint("Received beacon type %d from host %s\n", astate, - afs_inet_ntoa_r(otherHost, hoststr)); + ViceLog(5, ("Received beacon type %d from host %s\n", astate, + afs_inet_ntoa_r(otherHost, hoststr))); /* compute the lowest server we've heard from. We'll try to only vote for * this dude if we don't already have a synchronization site. Also, don't @@ -269,9 +269,8 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate, vote_globals.syncTime = now; } else if (vote_globals.syncTime + BIGTIME < now) { if (vote_globals.syncHost) { - ubik_dprint - ("Ubik: Lost contact with sync-site %s (NOT in quorum)\n", - afs_inet_ntoa_r(vote_globals.syncHost, hoststr)); + ViceLog(5, ("Ubik: Lost contact with sync-site %s (NOT in quorum)\n", + afs_inet_ntoa_r(vote_globals.syncHost, hoststr))); } vote_globals.syncHost = 0; } @@ -316,9 +315,9 @@ SVOTE_Beacon(struct rx_call * rxcall, afs_int32 astate, if ((vote_globals.ubik_lastYesTime + BIGTIME < now) || (otherHost != vote_globals.lastYesHost) || (vote_globals.lastYesState != astate)) { /* A new vote or a change in the vote or changed quorum */ - ubik_dprint("Ubik: vote 'yes' for %s %s\n", + ViceLog(5, ("Ubik: vote 'yes' for %s %s\n", afs_inet_ntoa_r(otherHost, hoststr), - (astate ? "(in quorum)" : "(NOT in quorum)")); + (astate ? "(in quorum)" : "(NOT in quorum)"))); } vote = now; /* vote yes */ @@ -553,42 +552,6 @@ SVOTE_GetSyncSite(struct rx_call * rxcall, return 0; } -void -ubik_dprint_25(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - vViceLog(25, (format, ap)); - va_end(ap); -} - -void -ubik_dprint(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - vViceLog(5, (format, ap)); - va_end(ap); -} - -void -ubik_vprint(const char *format, va_list ap) -{ - vViceLog(0, (format, ap)); -} - -void -ubik_print(const char *format, ...) -{ - va_list ap; - - va_start(ap, format); - ubik_vprint(format, ap); - va_end(ap); -} - /*! * \brief Called once/run to init the vote module */ -- 2.39.5