From: Jeffrey Altman Date: Thu, 14 Oct 2010 21:24:33 +0000 (-0400) Subject: down with assert, up with osi_Assert X-Git-Tag: openafs-devel-1_5_78~27 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=a6a318c12cda5b7d8309a64f12ecab6bd879d8e8;p=packages%2Fo%2Fopenafs.git down with assert, up with osi_Assert because NDEBUG breaks things which happen inside an assert, be done with that. instead, call osi_Assert wherever possible. doesn't work for code which builds before rx; those cases we handle by ensuring no operations happen inside the assert(). side effect: move all pthread operations wrapped in asserts to MUTEX_mumble and CV_mumble calls where those exist, so the assertions happen all in one set of macroes. Change-Id: I449d0822a39554a1f45b5b509d70e093e7ceb690 Reviewed-on: http://gerrit.openafs.org/3171 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- diff --git a/src/afsd/afsd.c b/src/afsd/afsd.c index 712318fbf..451015d4e 100644 --- a/src/afsd/afsd.c +++ b/src/afsd/afsd.c @@ -68,8 +68,7 @@ #include "afsd.h" -#include -#include +#include #include #include #include @@ -270,7 +269,7 @@ static int sawBiod = 0; static int sawCacheStatEntries = 0; char afsd_cacheMountDir[1024]; /*Mount directory for AFS */ static char rootVolume[64] = "root.afs"; /*AFS root volume name */ -static afs_int32 cacheSetTime = FALSE; /*Keep checking time to avoid drift? */ +static afs_int32 cacheSetTime = 0; /*Keep checking time to avoid drift? */ #ifdef AFS_XBSD_ENV static int createAndTrunc = O_RDWR | O_CREAT | O_TRUNC; /*Create & truncate on open */ #else @@ -1726,7 +1725,7 @@ mainproc(struct cmd_syndesc *as, void *arock) } if (as->parms[8].items) { /* -nosettime */ - cacheSetTime = FALSE; + cacheSetTime = 0; } if (as->parms[9].items) { /* -verbose */ @@ -1858,7 +1857,7 @@ mainproc(struct cmd_syndesc *as, void *arock) } if (as->parms[32].items) { /* -settime */ - cacheSetTime = TRUE; + cacheSetTime = 1; } /* set rx_extraPackets */ @@ -1891,7 +1890,7 @@ mainproc(struct cmd_syndesc *as, void *arock) if (as->parms[35].items) { #ifdef AFS_MAXVCOUNT_ENV /* -disable-dynamic-vcaches */ - afsd_dynamic_vcaches = FALSE; + afsd_dynamic_vcaches = 0; #else printf("afsd: Error toggling flag, dynamically allocated vcaches not supported on your platform\n"); exit(1); @@ -1900,7 +1899,7 @@ mainproc(struct cmd_syndesc *as, void *arock) #ifdef AFS_MAXVCOUNT_ENV else { /* -dynamic-vcaches */ - afsd_dynamic_vcaches = TRUE; + afsd_dynamic_vcaches = 1; } if (afsd_verbose) diff --git a/src/afsd/afsd_kernel.c b/src/afsd/afsd_kernel.c index c5c457ed8..2213fb03f 100644 --- a/src/afsd/afsd_kernel.c +++ b/src/afsd/afsd_kernel.c @@ -17,7 +17,6 @@ #include "afsd.h" #include -#include #include #include #include diff --git a/src/audit/audit.c b/src/audit/audit.c index 3b42cde3f..dacbef7e8 100644 --- a/src/audit/audit.c +++ b/src/audit/audit.c @@ -292,7 +292,7 @@ static pthread_once_t audit_lock_once = PTHREAD_ONCE_INIT; static void osi_audit_init_lock(void) { - pthread_mutex_init(&audit_lock, NULL); + MUTEX_INIT(&audit_lock, "audit", MUTEX_DEFAULT, 0); audit_lock_initialized = 1; } #endif @@ -328,7 +328,7 @@ osi_audit_internal(char *audEvent, /* Event name (15 chars or less) */ /* i'm pretty sure all the server apps now call osi_audit_init(), * but to be extra careful we'll leave this assert in here for a * while to make sure */ - assert(audit_lock_initialized); + osi_Assert(audit_lock_initialized); #endif /* AFS_PTHREAD_ENV */ if ((osi_audit_all < 0) || (osi_echo_trail < 0)) @@ -362,9 +362,7 @@ osi_audit_internal(char *audEvent, /* Event name (15 chars or less) */ } #endif -#ifdef AFS_PTHREAD_ENV - pthread_mutex_lock(&audit_lock); -#endif + MUTEX_ENTER(&audit_lock); #ifdef AFS_AIX32_ENV bufferPtr = BUFFER; @@ -383,9 +381,7 @@ osi_audit_internal(char *audEvent, /* Event name (15 chars or less) */ printbuf(0, audEvent, afsName, hostId, errCode, vaList); } #endif -#ifdef AFS_PTHREAD_ENV - pthread_mutex_unlock(&audit_lock); -#endif + MUTEX_EXIT(&audit_lock); return 0; } diff --git a/src/budb/db_dump.c b/src/budb/db_dump.c index c7a1e1a95..dbecce45a 100644 --- a/src/budb/db_dump.c +++ b/src/budb/db_dump.c @@ -74,7 +74,7 @@ canWrite(int fid) if (dumpSyncPtr->ds_readerStatus == DS_WAITING) { dumpSyncPtr->ds_readerStatus = 0; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dumpSyncPtr->ds_readerStatus_cond) == 0); + CV_BROADCAST(&dumpSyncPtr->ds_readerStatus_cond); #else code = LWP_SignalProcess(&dumpSyncPtr->ds_readerStatus); if (code) @@ -84,9 +84,9 @@ canWrite(int fid) dumpSyncPtr->ds_writerStatus = DS_WAITING; ReleaseWriteLock(&dumpSyncPtr->ds_lock); #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_lock(&dumpSyncPtr->ds_writerStatus_mutex) == 0); - assert(pthread_cond_wait(&dumpSyncPtr->ds_writerStatus_cond, &dumpSyncPtr->ds_writerStatus_mutex) == 0); - assert(pthread_mutex_unlock(&dumpSyncPtr->ds_writerStatus_mutex) == 0); + MUTEX_ENTER(&dumpSyncPtr->ds_writerStatus_mutex); + CV_WAIT(&dumpSyncPtr->ds_writerStatus_cond, &dumpSyncPtr->ds_writerStatus_mutex); + MUTEX_EXIT(&dumpSyncPtr->ds_writerStatus_mutex); #else LWP_WaitProcess(&dumpSyncPtr->ds_writerStatus); #endif @@ -115,7 +115,7 @@ haveWritten(afs_int32 nbytes) if (dumpSyncPtr->ds_readerStatus == DS_WAITING) { dumpSyncPtr->ds_readerStatus = 0; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dumpSyncPtr->ds_readerStatus_cond) == 0); + CV_BROADCAST(&dumpSyncPtr->ds_readerStatus_cond); #else code = LWP_SignalProcess(&dumpSyncPtr->ds_readerStatus); if (code) @@ -144,9 +144,9 @@ doneWriting(afs_int32 error) dumpSyncPtr->ds_writerStatus = DS_WAITING; ReleaseWriteLock(&dumpSyncPtr->ds_lock); #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_lock(&dumpSyncPtr->ds_writerStatus_mutex) == 0); - assert(pthread_cond_wait(&dumpSyncPtr->ds_writerStatus_cond, &dumpSyncPtr->ds_writerStatus_mutex) == 0); - assert(pthread_mutex_unlock(&dumpSyncPtr->ds_writerStatus_mutex) == 0); + MUTEX_ENTER(&dumpSyncPtr->ds_writerStatus_mutex); + CV_WAIT(&dumpSyncPtr->ds_writerStatus_cond, &dumpSyncPtr->ds_writerStatus_mutex); + MUTEX_EXIT(&dumpSyncPtr->ds_writerStatus_mutex); #else LWP_WaitProcess(&dumpSyncPtr->ds_writerStatus); #endif @@ -162,7 +162,7 @@ doneWriting(afs_int32 error) dumpSyncPtr->ds_writerStatus = DS_DONE; dumpSyncPtr->ds_readerStatus = 0; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dumpSyncPtr->ds_readerStatus_cond) == 0); + CV_BROADCAST(&dumpSyncPtr->ds_readerStatus_cond); #else code = LWP_NoYieldSignal(&dumpSyncPtr->ds_readerStatus); if (code) diff --git a/src/budb/dbs_dump.c b/src/budb/dbs_dump.c index 6007b6993..d980f26d3 100644 --- a/src/budb/dbs_dump.c +++ b/src/budb/dbs_dump.c @@ -162,16 +162,16 @@ DumpDB(struct rx_call *call, /* Initialize the condition variables and the mutexes we use * to signal and synchronize the reader and writer threads. */ - assert(pthread_cond_init(&dumpSyncPtr->ds_readerStatus_cond, (const pthread_condattr_t *)0) == 0); - assert(pthread_cond_init(&dumpSyncPtr->ds_writerStatus_cond, (const pthread_condattr_t *)0) == 0); - assert(pthread_mutex_init(&dumpSyncPtr->ds_readerStatus_mutex, (const pthread_mutexattr_t *)0) == 0); - assert(pthread_mutex_init(&dumpSyncPtr->ds_writerStatus_mutex, (const pthread_mutexattr_t *)0) == 0); + CV_INIT(&dumpSyncPtr->ds_readerStatus_cond, "reader cond", CV_DEFAULT, 0); + CV_INIT(&dumpSyncPtr->ds_writerStatus_cond, "writer cond", CV_DEFAULT, 0); + MUTEX_INIT(&dumpSyncPtr->ds_readerStatus_mutex, "reader", MUTEX_DEFAULT, 0); + MUTEX_INIT(&dumpSyncPtr->ds_writerStatus_mutex, "writer", MUTEX_DEFAULT, 0); /* Initialize the thread attributes and launch the thread */ - assert(pthread_attr_init(&dumperPid_tattr) == 0); - assert(pthread_attr_setdetachstate(&dumperPid_tattr, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&dumperPid, &dumperPid_tattr, (void *)setupDbDump, NULL) == 0); + osi_Assert(pthread_attr_init(&dumperPid_tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&dumperPid_tattr, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_create(&dumperPid, &dumperPid_tattr, (void *)setupDbDump, NULL) == 0); #else code = @@ -188,9 +188,9 @@ DumpDB(struct rx_call *call, #ifdef AFS_PTHREAD_ENV /* Initialize the thread attributes and launch the thread */ - assert(pthread_attr_init(&watcherPid_tattr) == 0); - assert(pthread_attr_setdetachstate(&watcherPid_tattr, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&watcherPid, &watcherPid_tattr, (void *)dumpWatcher, NULL) == 0); + osi_Assert(pthread_attr_init(&watcherPid_tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&watcherPid_tattr, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_create(&watcherPid, &watcherPid_tattr, (void *)dumpWatcher, NULL) == 0); #else /* now create the watcher thread */ code = @@ -214,7 +214,7 @@ DumpDB(struct rx_call *call, LogDebug(6, "wakup writer\n"); dumpSyncPtr->ds_writerStatus = 0; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dumpSyncPtr->ds_writerStatus_cond) == 0); + CV_BROADCAST(&dumpSyncPtr->ds_writerStatus_cond); #else code = LWP_SignalProcess(&dumpSyncPtr->ds_writerStatus); if (code) @@ -225,9 +225,9 @@ DumpDB(struct rx_call *call, dumpSyncPtr->ds_readerStatus = DS_WAITING; ReleaseWriteLock(&dumpSyncPtr->ds_lock); #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_lock(&dumpSyncPtr->ds_readerStatus_mutex) == 0); - assert(pthread_cond_wait(&dumpSyncPtr->ds_readerStatus_cond, &dumpSyncPtr->ds_readerStatus_mutex) == 0); - assert(pthread_mutex_unlock(&dumpSyncPtr->ds_readerStatus_mutex) == 0); + MUTEX_ENTER(&dumpSyncPtr->ds_readerStatus_mutex); + CV_WAIT(&dumpSyncPtr->ds_readerStatus_cond, &dumpSyncPtr->ds_readerStatus_mutex); + MUTEX_EXIT(&dumpSyncPtr->ds_readerStatus_mutex); #else LWP_WaitProcess(&dumpSyncPtr->ds_readerStatus); #endif @@ -256,7 +256,7 @@ DumpDB(struct rx_call *call, if (dumpSyncPtr->ds_writerStatus == DS_WAITING) { dumpSyncPtr->ds_writerStatus = 0; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dumpSyncPtr->ds_writerStatus_cond) == 0); + CV_BROADCAST(&dumpSyncPtr->ds_writerStatus_cond); #else code = LWP_SignalProcess(&dumpSyncPtr->ds_writerStatus); if (code) @@ -352,7 +352,7 @@ dumpWatcher(void *unused) close(dumpSyncPtr->pipeFid[0]); close(dumpSyncPtr->pipeFid[1]); #ifdef AFS_PTHREAD_ENV - assert(pthread_cancel(dumpSyncPtr->dumperPid) == 0); + osi_Assert(pthread_cancel(dumpSyncPtr->dumperPid) == 0); #else code = LWP_DestroyProcess(dumpSyncPtr->dumperPid); if (code) diff --git a/src/butc/tcmain.c b/src/butc/tcmain.c index e63209295..bdfb98039 100644 --- a/src/butc/tcmain.c +++ b/src/butc/tcmain.c @@ -27,11 +27,7 @@ #include #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else #include -#endif #include #include #include diff --git a/src/kauth/kalog.c b/src/kauth/kalog.c index 326cddf3c..6929b6f74 100644 --- a/src/kauth/kalog.c +++ b/src/kauth/kalog.c @@ -29,7 +29,6 @@ #include #include #include -#include #include #include "kauth.h" #include "kalog.h" diff --git a/src/libafsrpc/afsrpc.def b/src/libafsrpc/afsrpc.def index 2bf61c045..577351305 100755 --- a/src/libafsrpc/afsrpc.def +++ b/src/libafsrpc/afsrpc.def @@ -266,6 +266,8 @@ EXPORTS ; rx_FreeStatistics @271 rx_SetConnHardDeadTime @272 rx_SetConnIdleDeadTime @273 + rx_InterruptCall @274 + osi_Panic @275 ; for performance testing rx_TSFPQGlobSize @2001 DATA diff --git a/src/log/unlog.c b/src/log/unlog.c index e807c0a9a..3542e7f24 100644 --- a/src/log/unlog.c +++ b/src/log/unlog.c @@ -31,7 +31,6 @@ #include -#include #ifdef AFS_AIX32_ENV #include #endif diff --git a/src/lwp/iomgr.c b/src/lwp/iomgr.c index ecc36d8d9..74df51754 100644 --- a/src/lwp/iomgr.c +++ b/src/lwp/iomgr.c @@ -73,9 +73,9 @@ void IOMGR_Sleep (seconds) itv.tv_sec = seconds; itv.tv_nsec = 0; - assert(pthread_mutex_unlock(&lwp_mutex) == 0); - assert(pthread_delay_np(&itv) == 0); - assert(pthread_mutex_lock(&lwp_mutex) == 0); + MUTEX_EXIT(&lwp_mutex); + osi_Assert(pthread_delay_np(&itv) == 0); + MUTEX_ENTER(&lwp_mutex); } #else diff --git a/src/lwp/lock.c b/src/lwp/lock.c index d2897f93b..ca8fc55a8 100644 --- a/src/lwp/lock.c +++ b/src/lwp/lock.c @@ -25,12 +25,14 @@ #include #include - -#ifndef AFS_PTHREAD_ENV +#ifdef AFS_PTHREAD_ENV #include -#else /* AFS_PTHREAD_ENV */ +/* can't include this in lwp, rx hasn't built yet */ +#include +#else #include -#endif /* AFS_PTHRED_ENV */ +#endif + #include "lwp.h" #include "lock.h" #include @@ -46,23 +48,20 @@ Lock_Init(struct Lock *lock) lock->wait_states = 0; lock->num_waiting = 0; #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_init(&lock->mutex, (const pthread_mutexattr_t *)0) == - 0); - assert(pthread_cond_init(&lock->read_cv, (const pthread_condattr_t *)0) == - 0); - assert(pthread_cond_init(&lock->write_cv, (const pthread_condattr_t *)0) - == 0); -#endif /* AFS_PTHRED_ENV */ + MUTEX_INIT(&lock->mutex, "lock", MUTEX_DEFAULT, 0); + CV_INIT(&lock->read_cv, "read", CV_DEFAULT, 0); + CV_INIT(&lock->write_cv, "write", CV_DEFAULT, 0); +#endif /* AFS_PTHREAD_ENV */ } void Lock_Destroy(struct Lock *lock) { #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_destroy(&lock->mutex) == 0); - assert(pthread_cond_destroy(&lock->read_cv) == 0); - assert(pthread_cond_destroy(&lock->write_cv) == 0); -#endif /* AFS_PTHRED_ENV */ + MUTEX_DESTROY(&lock->mutex); + CV_DESTROY(&lock->read_cv); + CV_DESTROY(&lock->write_cv); +#endif /* AFS_PTHREAD_ENV */ } void @@ -75,7 +74,7 @@ Afs_Lock_Obtain(struct Lock *lock, int how) do { lock->wait_states |= READ_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_wait(&lock->read_cv, &lock->mutex) == 0); + CV_WAIT(&lock->read_cv, &lock->mutex); #else /* AFS_PTHREAD_ENV */ LWP_WaitProcess(&lock->readers_reading); #endif /* AFS_PTHREAD_ENV */ @@ -89,7 +88,7 @@ Afs_Lock_Obtain(struct Lock *lock, int how) do { lock->wait_states |= WRITE_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_wait(&lock->write_cv, &lock->mutex) == 0); + CV_WAIT(&lock->write_cv, &lock->mutex); #else /* AFS_PTHREAD_ENV */ LWP_WaitProcess(&lock->excl_locked); #endif /* AFS_PTHREAD_ENV */ @@ -103,7 +102,7 @@ Afs_Lock_Obtain(struct Lock *lock, int how) do { lock->wait_states |= SHARED_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_wait(&lock->write_cv, &lock->mutex) == 0); + CV_WAIT(&lock->write_cv, &lock->mutex); #else /* AFS_PTHREAD_ENV */ LWP_WaitProcess(&lock->excl_locked); #endif /* AFS_PTHREAD_ENV */ @@ -117,7 +116,7 @@ Afs_Lock_Obtain(struct Lock *lock, int how) do { lock->wait_states |= WRITE_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_wait(&lock->write_cv, &lock->mutex) == 0); + CV_WAIT(&lock->write_cv, &lock->mutex); #else /* AFS_PTHREAD_ENV */ LWP_WaitProcess(&lock->excl_locked); #endif /* AFS_PTHREAD_ENV */ @@ -139,7 +138,7 @@ Afs_Lock_WakeupR(struct Lock *lock) if (lock->wait_states & READ_LOCK) { lock->wait_states &= ~READ_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&lock->read_cv) == 0); + CV_BROADCAST(&lock->read_cv); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(&lock->readers_reading); #endif /* AFS_PTHREAD_ENV */ @@ -153,14 +152,14 @@ Afs_Lock_ReleaseR(struct Lock *lock) if (lock->wait_states & READ_LOCK) { lock->wait_states &= ~READ_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&lock->read_cv) == 0); + CV_BROADCAST(&lock->read_cv); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(&lock->readers_reading); #endif /* AFS_PTHREAD_ENV */ } else { lock->wait_states &= ~EXCL_LOCKS; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&lock->write_cv) == 0); + CV_BROADCAST(&lock->write_cv); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(&lock->excl_locked); #endif /* AFS_PTHREAD_ENV */ @@ -174,14 +173,14 @@ Afs_Lock_ReleaseW(struct Lock *lock) if (lock->wait_states & EXCL_LOCKS) { lock->wait_states &= ~EXCL_LOCKS; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&lock->write_cv) == 0); + CV_BROADCAST(&lock->write_cv); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(&lock->excl_locked); #endif /* AFS_PTHREAD_ENV */ } else { lock->wait_states &= ~READ_LOCK; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&lock->read_cv) == 0); + CV_BROADCAST(&lock->read_cv); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(&lock->readers_reading); #endif /* AFS_PTHREAD_ENV */ diff --git a/src/lwp/lock.h b/src/lwp/lock.h index cac86e101..7bda37588 100644 --- a/src/lwp/lock.h +++ b/src/lwp/lock.h @@ -43,10 +43,12 @@ #define ENDMAC } while (0) #ifdef AFS_PTHREAD_ENV -#include #include -#define LOCK_LOCK(A) assert(pthread_mutex_lock(&(A)->mutex) == 0) -#define LOCK_UNLOCK(A) assert(pthread_mutex_unlock(&(A)->mutex) == 0) +#include +/* can't include in non-lwp case; rx builds later */ +#include +#define LOCK_LOCK(A) MUTEX_ENTER(&(A)->mutex); +#define LOCK_UNLOCK(A) MUTEX_EXIT(&(A)->mutex); #else /* AFS_PTHREAD_ENV */ #define LOCK_LOCK(A) #define LOCK_UNLOCK(A) diff --git a/src/lwp/lwp.c b/src/lwp/lwp.c index 403e534c7..2e53d0dd2 100644 --- a/src/lwp/lwp.c +++ b/src/lwp/lwp.c @@ -1354,13 +1354,15 @@ static PROCESS lwp_alloc_process(char *name, pthread_startroutine_t ep, pthread_addr_t arg) { PROCESS lp; - assert(lp = (PROCESS) malloc(sizeof(*lp))); + lp = (PROCESS) malloc(sizeof(*lp)); + assert(lp); memset(lp, 0, sizeof(*lp)); if (!name) { char temp[100]; static procnum; sprintf(temp, "unnamed_process_%04d", ++procnum); - assert(name = (char *)malloc(strlen(temp) + 1)); + name = (char *)malloc(strlen(temp) + 1); + assert(name); strcpy(name, temp); } lp->name = name; @@ -1377,7 +1379,8 @@ lwp_thread_process(PROCESS lp) { lp->next = lwp_process_list; lwp_process_list = lp; - assert(!pthread_setspecific(lwp_process_key, (pthread_addr_t) lp)); + if (pthread_setspecific(lwp_process_key, (pthread_addr_t) lp) != 0) + assert(0); } /* The top-level routine used as entry point to explicitly created LWP @@ -1388,10 +1391,10 @@ lwp_top_level(pthread_addr_t argp) { PROCESS lp = (PROCESS) argp; - assert(!pthread_mutex_lock(&lwp_mutex)); + MUTEX_ENTER(&lwp_mutex); lwp_thread_process(lp); (lp->ep) (lp->arg); - assert(!pthread_mutex_unlock(&lwp_mutex)); + MUTEX_EXIT(&lwp_mutex); /* Should cleanup state */ } @@ -1408,10 +1411,13 @@ LWP_CreateProcess(pthread_startroutine_t ep, int stacksize, int priority, if (!cmalwp_pri_inrange(priority)) return LWP_EBADPRI; #endif - assert(!pthread_attr_create(&attr)); - assert(!pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)); + if (pthread_attr_create(&attr)) + assert(0); + if (pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED)) + assert(0); if (stacksize) - assert(!pthread_attr_setstacksize(&attr, stacksize)); + if (pthread_attr_setstacksize(&attr, stacksize)) + assert(0); #ifndef BDE_THREADS (void)pthread_attr_setinheritsched(&attr, PTHREAD_DEFAULT_SCHED); (void)pthread_attr_setsched(&attr, SCHED_FIFO); @@ -1423,14 +1429,16 @@ LWP_CreateProcess(pthread_startroutine_t ep, int stacksize, int priority, (pthread_addr_t) parm); /* allow new thread to run if higher priority */ - assert(!pthread_mutex_unlock(&lwp_mutex)); + MUTEX_EXIT(&lwp_mutex); /* process is only added to active list after first time it runs (it adds itself) */ status = pthread_create(&lp->handle, attr, (pthread_startroutine_t) lwp_top_level, (pthread_addr_t) lp); - assert(!pthread_attr_delete(&attr)); - assert(!pthread_mutex_lock(&lwp_mutex)); + if (pthread_attr_delete(&attr)) + assert(0); + if (pthread_mutex_lock(&lwp_mutex)) + assert(0); if (status != 0) { free(lp); return LWP_ENOMEM; @@ -1443,14 +1451,16 @@ PROCESS LWP_ActiveProcess(void) { /* returns pid of current process */ PROCESS pid; - assert(!pthread_getspecific(lwp_process_key, (pthread_addr_t *) & pid)); + if (pthread_getspecific(lwp_process_key, (pthread_addr_t *) & pid)) + assert(0); return pid; } int LWP_CurrentProcess(PROCESS * pid) { /* get pid of current process */ - assert(!pthread_getspecific(lwp_process_key, (pthread_addr_t *) pid)); + if (pthread_getspecific(lwp_process_key, (pthread_addr_t *) pid)) + assert(0); return LWP_SUCCESS; } @@ -1463,9 +1473,9 @@ LWP_DestroyProcess(PROCESS pid) int LWP_DispatchProcess(void) { /* explicit voluntary preemption */ - assert(!pthread_mutex_unlock(&lwp_mutex)); + MUTEX_EXIT(&lwp_mutex); pthread_yield(); - assert(!pthread_mutex_lock(&lwp_mutex)); + MUTEX_ENTER(&lwp_mutex); return LWP_SUCCESS; } @@ -1494,8 +1504,9 @@ LWP_InitializeProcessSupport(int priority, PROCESS * pid) /* Create pthread key to associate LWP process descriptor with each * LWP-created thread */ - assert(!pthread_keycreate(&lwp_process_key, (pthread_destructor_t) - lwp_process_key_destructor)); + if (pthread_keycreate(&lwp_process_key, (pthread_destructor_t) + lwp_process_key_destructor)) + assert(0); lp = lwp_alloc_process("main process", main, 0); lp->handle = pthread_self(); @@ -1505,8 +1516,8 @@ LWP_InitializeProcessSupport(int priority, PROCESS * pid) cmalwp_lwppri_to_cmapri(priority)); #endif - assert(pthread_mutex_init(&lwp_mutex, MUTEX_FAST_NP) == 0); - assert(pthread_mutex_lock(&lwp_mutex) == 0); + MUTEX_INIT(&lwp_mutex, "lwp", MUTEX_DEFAULT, 0); + MUTEX_ENTER(&lwp_mutex); initialized = 1; *pid = lp; return LWP_SUCCESS; @@ -1542,7 +1553,8 @@ getevent(void *event) assert(newp); newp->next = hashtable[hashcode]; hashtable[hashcode] = newp; - assert(!pthread_cond_init(&newp->cond, ((pthread_condattr_t) 0))); + if (pthread_cond_init(&newp->cond, ((pthread_condattr_t) 0))) + assert(0); newp->seq = 0; } newp->event = event; @@ -1564,7 +1576,8 @@ LWP_WaitProcess(void *event) ev = getevent(event); seq = ev->seq; while (seq == ev->seq) { - assert(pthread_cond_wait(&ev->cond, &lwp_mutex) == 0); + if (pthread_cond_wait(&ev->cond, &lwp_mutex)) + assert(0); } debugf(("%s: Woken up (%x)\n", lwp_process_string(), event)); relevent(ev); @@ -1587,7 +1600,8 @@ LWP_NoYieldSignal(void *event) ev = getevent(event); if (ev->refcount > 1) { ev->seq++; - assert(pthread_cond_broadcast(&ev->cond) == 0); + if (pthread_cond_broadcast(&ev->cond)) + assert(0); } relevent(ev); return LWP_SUCCESS; @@ -1603,10 +1617,10 @@ LWP_SignalProcess(void *event) ev = getevent(event); if (ev->refcount > 1) { ev->seq++; - assert(!pthread_mutex_unlock(&lwp_mutex)); - assert(!pthread_cond_broadcast(&ev->cond)); + MUTEX_EXIT(&lwp_mutex); + CV_BROADCAST(&ev->cond); pthread_yield(); - assert(!pthread_mutex_lock(&lwp_mutex)); + MUTEX_ENTER(&lwp_mutex); } relevent(ev); return LWP_SUCCESS; diff --git a/src/lwp/lwp.h b/src/lwp/lwp.h index 12923d1c1..81050b0d5 100644 --- a/src/lwp/lwp.h +++ b/src/lwp/lwp.h @@ -178,8 +178,8 @@ struct rock { /* to hide things associated with this LWP under */ * program. They simply acquire/release the global LWP mutex . */ extern pthread_mutex_t lwp_mutex; -#define LWP_EXIT_LWP_CONTEXT() pthread_mutex_unlock(&lwp_mutex) -#define LWP_ENTER_LWP_CONTEXT() pthread_mutex_lock(&lwp_mutex) +#define LWP_EXIT_LWP_CONTEXT() MUTEX_EXIT(&lwp_mutex) +#define LWP_ENTER_LWP_CONTEXT() MUTEX_ENTER(&lwp_mutex) #else #ifndef AFS_NT40_ENV #define lwp_abort() abort() diff --git a/src/lwp/rw.c b/src/lwp/rw.c index a416515cf..6fff9c75e 100644 --- a/src/lwp/rw.c +++ b/src/lwp/rw.c @@ -55,8 +55,7 @@ init() } char -empty(q) - queue *q; +empty(queue *q) { return (q->prev == q && q->next == q); } @@ -75,15 +74,14 @@ insert(queue * q, char *s) } char * -Remove(q) - queue *q; +Remove(queue *q) { queue *old; char *s; if (empty(q)) { printf("Remove from empty queue"); - assert(0); + osi_Assert(0); } old = q->next; @@ -100,8 +98,7 @@ int asleep; /* Number of processes sleeping -- used for * clean termination */ static int -read_process(id) - int *id; +read_process(int *id) { printf("\t[Reader %d]\n", *id); LWP_DispatchProcess(); /* Just relinquish control for now */ @@ -202,9 +199,8 @@ write_process() #include "AFS_component_version_number.c" -main(argc, argv) - int argc; - char **argv; +int +main(int argc, char **argv) { int nreaders, i; PROCESS pid; diff --git a/src/ptserver/utils.c b/src/ptserver/utils.c index 737c5732c..230e76041 100644 --- a/src/ptserver/utils.c +++ b/src/ptserver/utils.c @@ -10,7 +10,6 @@ #include #include -#include #include #include #include @@ -292,7 +291,7 @@ FindByID(struct ubik_trans *at, afs_int32 aid) return 0; if (aid == tentry.id) return entry; - assert(entry != tentry.nextID); + osi_Assert(entry != tentry.nextID); entry = tentry.nextID; while (entry != 0) { memset(&tentry, 0, sizeof(tentry)); @@ -301,7 +300,7 @@ FindByID(struct ubik_trans *at, afs_int32 aid) return 0; if (aid == tentry.id) return entry; - assert(entry != tentry.nextID); + osi_Assert(entry != tentry.nextID); entry = tentry.nextID; } return 0; @@ -325,7 +324,7 @@ FindByName(struct ubik_trans *at, char aname[PR_MAXNAMELEN], struct prentry *ten return 0; if ((strncmp(aname, tentryp->name, PR_MAXNAMELEN)) == 0) return entry; - assert(entry != tentryp->nextName); + osi_Assert(entry != tentryp->nextName); entry = tentryp->nextName; while (entry != 0) { memset(tentryp, 0, sizeof(struct prentry)); @@ -334,7 +333,7 @@ FindByName(struct ubik_trans *at, char aname[PR_MAXNAMELEN], struct prentry *ten return 0; if ((strncmp(aname, tentryp->name, PR_MAXNAMELEN)) == 0) return entry; - assert(entry != tentryp->nextName); + osi_Assert(entry != tentryp->nextName); entry = tentryp->nextName; } return 0; @@ -464,7 +463,7 @@ RemoveFromIDHash(struct ubik_trans *tt, afs_int32 aid, afs_int32 *loc) /* ??? i if (code) return PRDBFAIL; while (aid != tentry.id) { - assert(trail != current); + osi_Assert(trail != current); trail = current; current = tentry.nextID; if (current == 0) @@ -542,7 +541,7 @@ RemoveFromNameHash(struct ubik_trans *tt, char *aname, afs_int32 *loc) if (code) return PRDBFAIL; while (strcmp(aname, tentry.name)) { - assert(trail != current); + osi_Assert(trail != current); trail = current; current = tentry.nextName; if (current == 0) diff --git a/src/rx/rx.c b/src/rx/rx.c index 2f885ded7..e167e4341 100644 --- a/src/rx/rx.c +++ b/src/rx/rx.c @@ -216,10 +216,9 @@ rxi_InitPthread(void) MUTEX_INIT(&rxkad_random_mutex, "rxkad random", MUTEX_DEFAULT, 0); MUTEX_INIT(&rx_debug_mutex, "debug", MUTEX_DEFAULT, 0); - osi_Assert(pthread_cond_init - (&rx_event_handler_cond, (const pthread_condattr_t *)0) == 0); - osi_Assert(pthread_cond_init(&rx_listener_cond, (const pthread_condattr_t *)0) - == 0); + CV_INIT(&rx_event_handler_cond, "evhand", CV_DEFAULT, 0); + CV_INIT(&rx_listener_cond, "rxlisten", CV_DEFAULT, 0); + osi_Assert(pthread_key_create(&rx_thread_id_key, NULL) == 0); osi_Assert(pthread_key_create(&rx_ts_info_key, NULL) == 0); diff --git a/src/rx/rx_lwp.h b/src/rx/rx_lwp.h index d3feb0894..c77ad9ca4 100644 --- a/src/rx/rx_lwp.h +++ b/src/rx/rx_lwp.h @@ -28,6 +28,10 @@ #define MUTEX_ISMINE(a) #define CV_INIT(a,b,c,d) #define CV_DESTROY(a) +#define CV_WAIT(cv, l) +#define CV_SIGNAL(cv) +#define CV_BROADCAST(cv) +#define CV_TIMEDWAIT(cv, l, t) #define osirx_AssertMine(a, b) #endif /* KERNEL */ diff --git a/src/shlibafsrpc/libafsrpc.map b/src/shlibafsrpc/libafsrpc.map index 846ef7025..f4eec0f9e 100755 --- a/src/shlibafsrpc/libafsrpc.map +++ b/src/shlibafsrpc/libafsrpc.map @@ -19,6 +19,8 @@ des_pcbc_encrypt; ktohl; life_to_time; + osi_AssertFailU; + osi_Panic; rx_DestroyConnection; rx_EndCall; rx_Finalize; @@ -27,6 +29,7 @@ rx_GetIFInfo; rx_GetSpecific; rx_Init; + rx_InitHost; rx_KeyCreate; rx_NewCall; rx_NewConnection; diff --git a/src/tsalvaged/Makefile.in b/src/tsalvaged/Makefile.in index f0f57cfe3..c45c3c28b 100644 --- a/src/tsalvaged/Makefile.in +++ b/src/tsalvaged/Makefile.in @@ -54,9 +54,10 @@ SSSDEBUG_OBJS = salvsync-debug.o physio.o common.o ${UTILOBJS} ${VLIBOBJS} ${DIR LIBS=${TOP_LIBDIR}/libafsauthent.a ${TOP_LIBDIR}/libafsrpc.a ${TOP_LIBDIR}/util.a ${TOP_LIBDIR}/libcmd.a -SLIBS=${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libdir.a \ - ${TOP_LIBDIR}/libvlib.a ${TOP_LIBDIR}/liblwp.a \ - ${TOP_LIBDIR}/libacl.a ${TOP_LIBDIR}/util.a +SLIBS=${TOP_LIBDIR}/libcmd.a ${TOP_LIBDIR}/libdir.a \ + ${TOP_LIBDIR}/libvlib.a ${TOP_LIBDIR}/librx.a \ + ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libacl.a \ + ${TOP_LIBDIR}/util.a all: salvageserver dafssync-debug salvsync-debug dasalvager diff --git a/src/ubik/disk.c b/src/ubik/disk.c index 9a9da8f88..fe42cdc05 100644 --- a/src/ubik/disk.c +++ b/src/ubik/disk.c @@ -854,7 +854,7 @@ udisk_commit(struct ubik_trans *atrans) dbase->version.counter++; /* bump commit count */ #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dbase->version_cond) == 0); + CV_BROADCAST(&dbase->version_cond); #else LWP_NoYieldSignal(&dbase->version); #endif @@ -978,7 +978,7 @@ udisk_end(struct ubik_trans *atrans) /* Wakeup any writers waiting in BeginTrans() */ #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&dbase->flags_cond) == 0); + CV_BROADCAST(&dbase->flags_cond); #else LWP_NoYieldSignal(&dbase->flags); #endif diff --git a/src/ubik/recovery.c b/src/ubik/recovery.c index 23d4d145a..e94dceedc 100644 --- a/src/ubik/recovery.c +++ b/src/ubik/recovery.c @@ -15,7 +15,6 @@ #include #include #include -#include #ifdef AFS_NT40_ENV #include @@ -385,7 +384,7 @@ InitializeDB(struct ubik_dbase *adbase) (*adbase->setlabel) (adbase, 0, &adbase->version); } #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&adbase->version_cond) == 0); + CV_BROADCAST(&adbase->version_cond); #else LWP_NoYieldSignal(&adbase->version); #endif @@ -716,7 +715,7 @@ urecovery_Interact(void *dummy) } udisk_Invalidate(ubik_dbase, 0); /* data has changed */ #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&ubik_dbase->version_cond) == 0); + CV_BROADCAST(&ubik_dbase->version_cond); #else LWP_NoYieldSignal(&ubik_dbase->version); #endif @@ -744,7 +743,7 @@ urecovery_Interact(void *dummy) (*ubik_dbase->setlabel) (ubik_dbase, 0, &ubik_dbase->version); udisk_Invalidate(ubik_dbase, 0); /* data may have changed */ #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&ubik_dbase->version_cond) == 0); + CV_BROADCAST(&ubik_dbase->version_cond); #else LWP_NoYieldSignal(&ubik_dbase->version); #endif @@ -887,7 +886,7 @@ DoProbe(struct ubik_server *server) break; } } - assert(i); /* at least one interface address for this server */ + osi_Assert(i); /* at least one interface address for this server */ multi_Rx(conns, i) { multi_DISK_Probe(); diff --git a/src/ubik/ubik.c b/src/ubik/ubik.c index fd8caa6c7..aeebae58f 100644 --- a/src/ubik/ubik.c +++ b/src/ubik/ubik.c @@ -416,7 +416,7 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, memset(&tdb->version, 0, sizeof(struct ubik_version)); memset(&tdb->cachedVersion, 0, sizeof(struct ubik_version)); #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_init(&tdb->versionLock, NULL) == 0); + MUTEX_INIT(&tdb->versionLock, "version lock", MUTEX_DEFAULT, 0); #else Lock_Init(&tdb->versionLock); #endif @@ -437,8 +437,8 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, 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 - assert(pthread_cond_init(&tdb->version_cond, NULL) == 0); - assert(pthread_cond_init(&tdb->flags_cond, NULL) == 0); + CV_INIT(&tdb->version_cond, "version", CV_DEFAULT, 0); + CV_INIT(&tdb->flags_cond, "flags", CV_DEFAULT, 0); #endif /* AFS_PTHREAD_ENV */ /* initialize RX */ @@ -502,11 +502,11 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, */ #ifdef AFS_PTHREAD_ENV /* do assert stuff */ - assert(pthread_attr_init(&rxServer_tattr) == 0); - assert(pthread_attr_setdetachstate(&rxServer_tattr, PTHREAD_CREATE_DETACHED) == 0); -/* assert(pthread_attr_setstacksize(&rxServer_tattr, rx_stackSize) == 0); */ + osi_Assert(pthread_attr_init(&rxServer_tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&rxServer_tattr, PTHREAD_CREATE_DETACHED) == 0); +/* osi_Assert(pthread_attr_setstacksize(&rxServer_tattr, rx_stackSize) == 0); */ - assert(pthread_create(&rxServerThread, &rxServer_tattr, (void *)rx_ServerProc, NULL) == 0); + osi_Assert(pthread_create(&rxServerThread, &rxServer_tattr, (void *)rx_ServerProc, NULL) == 0); #else LWP_CreateProcess(rx_ServerProc, rx_stackSize, RX_PROCESS_PRIORITY, NULL, "rx_ServerProc", &junk); @@ -529,12 +529,12 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, /* now start up async processes */ #ifdef AFS_PTHREAD_ENV /* do assert stuff */ - assert(pthread_attr_init(&ubeacon_Interact_tattr) == 0); - assert(pthread_attr_setdetachstate(&ubeacon_Interact_tattr, PTHREAD_CREATE_DETACHED) == 0); -/* assert(pthread_attr_setstacksize(&ubeacon_Interact_tattr, 16384) == 0); */ + osi_Assert(pthread_attr_init(&ubeacon_Interact_tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&ubeacon_Interact_tattr, PTHREAD_CREATE_DETACHED) == 0); +/* osi_Assert(pthread_attr_setstacksize(&ubeacon_Interact_tattr, 16384) == 0); */ /* need another attr set here for priority??? - klm */ - assert(pthread_create(&ubeacon_InteractThread, &ubeacon_Interact_tattr, + osi_Assert(pthread_create(&ubeacon_InteractThread, &ubeacon_Interact_tattr, (void *)ubeacon_Interact, NULL) == 0); #else code = LWP_CreateProcess(ubeacon_Interact, 16384 /*8192 */ , @@ -546,12 +546,12 @@ ubik_ServerInitCommon(afs_uint32 myHost, short myPort, #ifdef AFS_PTHREAD_ENV /* do assert stuff */ - assert(pthread_attr_init(&urecovery_Interact_tattr) == 0); - assert(pthread_attr_setdetachstate(&urecovery_Interact_tattr, PTHREAD_CREATE_DETACHED) == 0); -/* assert(pthread_attr_setstacksize(&urecovery_Interact_tattr, 16384) == 0); */ + osi_Assert(pthread_attr_init(&urecovery_Interact_tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&urecovery_Interact_tattr, PTHREAD_CREATE_DETACHED) == 0); +/* osi_Assert(pthread_attr_setstacksize(&urecovery_Interact_tattr, 16384) == 0); */ /* need another attr set here for priority??? - klm */ - assert(pthread_create(&urecovery_InteractThread, &urecovery_Interact_tattr, + osi_Assert(pthread_create(&urecovery_InteractThread, &urecovery_Interact_tattr, (void *)urecovery_Interact, NULL) == 0); return 0; /* is this correct? - klm */ @@ -666,7 +666,7 @@ BeginTrans(struct ubik_dbase *dbase, afs_int32 transMode, /* if we're writing already, wait */ while (dbase->flags & DBWRITING) { #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_wait(&dbase->flags_cond, &dbase->versionLock) == 0); + CV_WAIT(&dbase->flags_cond, &dbase->versionLock); #else DBRELE(dbase); LWP_WaitProcess(&dbase->flags); @@ -1231,7 +1231,7 @@ ubik_WaitVersion(struct ubik_dbase *adatabase, return 0; } #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_wait(&adatabase->version_cond, &adatabase->versionLock) == 0); + CV_WAIT(&adatabase->version_cond, &adatabase->versionLock); #else DBRELE(adatabase); LWP_WaitProcess(&adatabase->version); /* same vers, just wait */ diff --git a/src/ubik/ubik.p.h b/src/ubik/ubik.p.h index 939501f38..8aef56b32 100644 --- a/src/ubik/ubik.p.h +++ b/src/ubik/ubik.p.h @@ -75,9 +75,9 @@ #define CFLastFailed 1 /*!< last call failed to this guy (to detect down hosts) */ /*\}*/ +#include #ifdef AFS_PTHREAD_ENV #include -#include #else #include #endif @@ -96,8 +96,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) @@ -307,8 +307,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)) diff --git a/src/ubik/ubikclient.c b/src/ubik/ubikclient.c index f649a2039..e6c9de665 100644 --- a/src/ubik/ubikclient.c +++ b/src/ubik/ubikclient.c @@ -94,9 +94,9 @@ ubik_ParseClientList(int argc, char **argv, afs_uint32 * aothers) return 0; } +#include #ifdef AFS_PTHREAD_ENV #include -#include static pthread_once_t random_once = PTHREAD_ONCE_INIT; static int called_afs_random_once; @@ -105,7 +105,7 @@ static pthread_key_t random_number_key; static void afs_random_once(void) { - assert(pthread_key_create(&random_number_key, NULL) == 0); + osi_Assert(pthread_key_create(&random_number_key, NULL) == 0); called_afs_random_once = 1; } @@ -333,15 +333,16 @@ ubik_RefreshConn(struct rx_connection *tc) pthread_once_t ubik_client_once = PTHREAD_ONCE_INIT; pthread_mutex_t ubik_client_mutex; -#define LOCK_UCLNT_CACHE \ - assert(pthread_once(&ubik_client_once, ubik_client_init_mutex) == 0 && \ - pthread_mutex_lock(&ubik_client_mutex)==0) -#define UNLOCK_UCLNT_CACHE assert(pthread_mutex_unlock(&ubik_client_mutex)==0) +#define LOCK_UCLNT_CACHE do { \ + osi_Assert(pthread_once(&ubik_client_once, ubik_client_init_mutex) == 0); \ + MUTEX_ENTER(&ubik_client_mutex); \ + } while (0) +#define UNLOCK_UCLNT_CACHE MUTEX_EXIT(&ubik_client_mutex) void ubik_client_init_mutex(void) { - assert(pthread_mutex_init(&ubik_client_mutex, NULL) == 0); + MUTEX_INIT(&ubik_client_mutex, "client init", MUTEX_DEFAULT, 0); } #else diff --git a/src/util/Makefile.in b/src/util/Makefile.in index 6fd3776cb..60fae6968 100644 --- a/src/util/Makefile.in +++ b/src/util/Makefile.in @@ -37,8 +37,7 @@ includes = \ ${TOP_INCDIR}/afs/pthread_glock.h \ ${TOP_INCDIR}/afs/afs_atomlist.h \ ${TOP_INCDIR}/afs/afs_lhash.h \ - ${TOP_INCDIR}/afs/softsig.h \ - ${TOP_INCDIR}/potpourri.h + ${TOP_INCDIR}/afs/softsig.h all: ${includes} \ ${TOP_LIBDIR}/util.a \ @@ -98,9 +97,6 @@ ${TOP_INCDIR}/afs/afs_lhash.h: ${srcdir}/afs_lhash.h ${TOP_INCDIR}/afs/softsig.h: ${srcdir}/softsig.h ${INSTALL_DATA} $? $@ -${TOP_INCDIR}/potpourri.h: ${srcdir}/potpourri.h - ${INSTALL_DATA} $? $@ - ${TOP_LIBDIR}/util.a: util.a ${INSTALL_DATA} $? $@ @@ -248,7 +244,6 @@ install: dirpath.h util.a sys ${INSTALL_DATA} ${srcdir}/afs_atomlist.h ${DESTDIR}${includedir}/afs/afs_atomlist.h ${INSTALL_DATA} ${srcdir}/afs_lhash.h ${DESTDIR}${includedir}/afs/afs_lhash.h ${INSTALL_DATA} ${srcdir}/softsig.h ${DESTDIR}${includedir}/afs/softsig.h - ${INSTALL_DATA} ${srcdir}/potpourri.h ${DESTDIR}${includedir}/potpourri.h ${INSTALL_DATA} util.a ${DESTDIR}${libdir}/afs/util.a ${INSTALL_DATA} util.a ${DESTDIR}${libdir}/afs/libafsutil.a ${INSTALL_PROGRAM} sys ${DESTDIR}${bindir}/sys @@ -273,7 +268,6 @@ dest: dirpath.h util.a sys ${INSTALL_DATA} ${srcdir}/afs_atomlist.h ${DEST}/include/afs/afs_atomlist.h ${INSTALL_DATA} ${srcdir}/afs_lhash.h ${DEST}/include/afs/afs_lhash.h ${INSTALL_DATA} ${srcdir}/softsig.h ${DEST}/include/afs/softsig.h - ${INSTALL_DATA} ${srcdir}/potpourri.h ${DEST}/include/potpourri.h ${INSTALL_DATA} util.a ${DEST}/lib/afs/util.a ${INSTALL_DATA} util.a ${DEST}/lib/afs/libafsutil.a ${INSTALL_PROGRAM} sys ${DEST}/bin/sys diff --git a/src/util/netutils.c b/src/util/netutils.c index 7dc2ac9b3..4f47f456b 100644 --- a/src/util/netutils.c +++ b/src/util/netutils.c @@ -42,11 +42,7 @@ #include -#ifdef AFS_PTHREAD_ENV -#include -#else #include "afs_assert.h" -#endif #include "afsutil.h" #include @@ -144,12 +140,12 @@ parseNetRestrictFile_int(afs_uint32 outAddrs[], afs_uint32 * mask, afs_uint32 i, neaddrs, nOutaddrs; afs_uint32 addr, eAddrs[MAXIPADDRS], eMask[MAXIPADDRS], eMtu[MAXIPADDRS]; - assert(outAddrs); - assert(reason); - assert(fileName); - assert(nAddrs); + osi_Assert(outAddrs); + osi_Assert(reason); + osi_Assert(fileName); + osi_Assert(nAddrs); if (mask) - assert(mtu); + osi_Assert(mtu); /* Initialize */ *nAddrs = 0; @@ -265,11 +261,11 @@ ParseNetInfoFile_int(afs_uint32 * final, afs_uint32 * mask, afs_uint32 * mtu, int lineNo = 0; int l; - assert(fileName); - assert(final); - assert(mask); - assert(mtu); - assert(reason); + osi_Assert(fileName); + osi_Assert(final); + osi_Assert(mask); + osi_Assert(mtu); + osi_Assert(reason); /* get all network interfaces from the kernel */ existNu = @@ -395,12 +391,12 @@ filterAddrs(afs_uint32 addr1[], afs_uint32 addr2[], afs_uint32 mask1[], afs_uint32 tmtu[MAXIPADDRS]; int count = 0, i = 0, j = 0, found = 0; - assert(addr1); - assert(addr2); - assert(mask1); - assert(mask2); - assert(mtu1); - assert(mtu2); + osi_Assert(addr1); + osi_Assert(addr2); + osi_Assert(mask1); + osi_Assert(mask2); + osi_Assert(mtu1); + osi_Assert(mtu2); for (i = 0; i < n1; i++) { found = 0; diff --git a/src/util/potpourri.h b/src/util/potpourri.h deleted file mode 100644 index d60b5198a..000000000 --- a/src/util/potpourri.h +++ /dev/null @@ -1,110 +0,0 @@ -/* - * 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 - */ - -/* Standard Preamble for .h files - -Abstract: Contains miscellaneous general-purpose macros. - -*/ - -#define MAXSELECT 20 /* Max no. of file desc. to be checked in select() calls */ - -/*------------------------------------------------------------*/ -#define IN /* Input parameter */ -#define OUT /* Output parameter */ -#define INOUT /* Obvious */ -/*------------------------------------------------------------*/ - - -/* Ha, ha!! I did not realize C has a builtin XOR operator! */ -#define XOR(a,b) (unsigned char) (((a&~b)|(~a&b)) & 0377) /* NOTE: a and b should be unsigned char */ - - -/* Conditional debugging output macros */ - -#ifndef NOSAY -#define say(when, what, how)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf how;fflush(stdout);}\ - else -#else -#define say(when, what, how) /* null macro; BEWARE: avoid side effects in say() */ -#endif - -/* the ones below are obsolete and are here for upward compatibility only */ -#define say0(when, what, how)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how);fflush(stdout);} -#define say1(when, what, how, x1)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1); fflush(stdout);} -#define say2(when, what, how, x1, x2)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2); fflush(stdout);} -#define say3(when, what, how, x1, x2, x3)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3); fflush(stdout);} -#define say4(when, what, how, x1, x2, x3, x4)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4); fflush(stdout);} -#define say5(when, what, how, x1, x2, x3, x4, x5)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5); fflush(stdout);} -#define say6(when, what, how, x1, x2, x3, x4, x5, x6)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6); fflush(stdout);} -#define say7(when, what, how, x1, x2, x3, x4, x5, x6, x7)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6, x7); fflush(stdout);} -#define say8(when, what, how, x1, x2, x3, x4, x5, x6, x7, x8)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6, x7, x8); fflush(stdout);} -#define say9(when, what, how, x1, x2, x3, x4, x5, x6, x7, x8, x9)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6, x7, x8, x9); fflush(stdout);} -#define say10(when, what, how, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10); fflush(stdout);} -#define say11(when, what, how, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11); fflush(stdout);} -#define say12(when, what, how, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12)\ - if (when < what){printf("\"%s\", line %d: ", __FILE__, __LINE__);\ - printf(how, x1, x2, x3, x4, x5, x6, x7, x8, x9, x10, x11, x12); fflush(stdout);} - - -/* length-checked string routines: return 0 on success, -1 on length violation */ -#define SafeStrCat(dest,src,totalspace)\ - ((strlen(dest)+strlen(src) < totalspace) ? strcat(dest,src),0 : -1) - -#define SafeStrCpy(dest,src,totalspace)\ - ((strlen(src) < totalspace) ? strcpy(dest,src),0 : -1) - - -/* The following definition of assert is slightly modified from the standard 4.2BSD one. - This prints out the failing assertion, in addition to the file and line number. - BEWARE: avoid quotes in the assertion!! - Also beware: you cannot make the NOASSERT case a null macro, because of side effects */ - -#undef assert -#ifndef NOASSERT -#define assert(ex) {if (!(ex)){fprintf(stderr,"Assertion failed: file %s, line %d\n", __FILE__, __LINE__);fprintf(stderr, "\t%s\n", # ex); abort();}} -#else -#define assert(ex) {if (!(ex)) abort();} -#endif - - -#define TRUE 1 -#define FALSE 0 - -#ifdef LWP -#define SystemError(y) (fprintf(stderr, "%d(%s): ", getpid(), LWP_ActiveProcess->name), perror(y)) -#else -#define SystemError(y) (fprintf(stderr, "%d: ", getpid()), perror(y)) -#endif diff --git a/src/util/pthread_glock.h b/src/util/pthread_glock.h index 19d6891bf..c6414c96c 100644 --- a/src/util/pthread_glock.h +++ b/src/util/pthread_glock.h @@ -12,7 +12,7 @@ #ifdef AFS_PTHREAD_ENV #include -#include +#include typedef struct { pthread_mutex_t mut; @@ -35,10 +35,10 @@ extern int pthread_recursive_mutex_lock(pthread_recursive_mutex_p); extern int pthread_recursive_mutex_unlock(pthread_recursive_mutex_p); #define LOCK_GLOBAL_MUTEX \ - assert(pthread_recursive_mutex_lock(&grmutex)==0) + osi_Assert(pthread_recursive_mutex_lock(&grmutex)==0) #define UNLOCK_GLOBAL_MUTEX \ - assert(pthread_recursive_mutex_unlock(&grmutex)==0) + osi_Assert(pthread_recursive_mutex_unlock(&grmutex)==0) #else diff --git a/src/util/serverLog.c b/src/util/serverLog.c index 1fd7c9a5a..773080785 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -45,11 +45,13 @@ # include #endif #if defined(AFS_PTHREAD_ENV) -#include +#include +/* can't include rx when we are libutil; it's too early */ +#include #include static pthread_mutex_t serverLogMutex; -#define LOCK_SERVERLOG() assert(pthread_mutex_lock(&serverLogMutex)==0) -#define UNLOCK_SERVERLOG() assert(pthread_mutex_unlock(&serverLogMutex)==0) +#define LOCK_SERVERLOG() MUTEX_ENTER(&serverLogMutex) +#define UNLOCK_SERVERLOG() MUTEX_EXIT(&serverLogMutex) #ifdef AFS_NT40_ENV #define NULLDEV "NUL" @@ -353,7 +355,7 @@ OpenLog(const char *fileName) #endif #if defined(AFS_PTHREAD_ENV) - assert(pthread_mutex_init(&serverLogMutex, NULL) == 0); + MUTEX_INIT(&serverLogMutex, "serverlog", MUTEX_DEFAULT, 0); #endif /* AFS_PTHREAD_ENV */ serverLogFD = tempfd; diff --git a/src/viced/afsfileprocs.c b/src/viced/afsfileprocs.c index fc831e700..ef439bf51 100644 --- a/src/viced/afsfileprocs.c +++ b/src/viced/afsfileprocs.c @@ -346,7 +346,7 @@ CallPreamble(struct rx_call *acall, int activecall, code = hpr_Initialize(&uclient); if (!code) - assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); + osi_Assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); H_LOCK; #else code = pr_Initialize(2, AFSDIR_SERVER_ETC_DIRPATH, 0); @@ -493,7 +493,7 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock) errorCode = 0; *volptr = VGetVolumeNoWait(&local_errorCode, &errorCode, (afs_int32) fid->Volume); if (!errorCode) { - assert(*volptr); + osi_Assert(*volptr); break; } if ((errorCode == VOFFLINE) && (VInit < 2)) { @@ -586,7 +586,7 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock) return (errorCode); } } - assert(*volptr); + osi_Assert(*volptr); /* get the vnode */ *vptr = VGetVnode(&errorCode, *volptr, fid->Vnode, lock); @@ -594,7 +594,7 @@ CheckVnode(AFSFid * fid, Volume ** volptr, Vnode ** vptr, int lock) return (errorCode); if ((*vptr)->disk.uniquifier != fid->Unique) { VPutVnode(&fileCode, *vptr); - assert(fileCode == 0); + osi_Assert(fileCode == 0); *vptr = 0; return (VNOVNODE); /* return the right error code, at least */ } @@ -618,7 +618,7 @@ SetAccessList(Vnode ** targetptr, Volume ** volume, *ACLSize = VAclSize(*targetptr); return (0); } else { - assert(Fid != 0); + osi_Assert(Fid != 0); while (1) { VnodeId parentvnode; Error errorCode = 0; @@ -702,7 +702,7 @@ GetRights(struct client *client, struct acl_accessList *ACL, while (client->host->hostFlags & HCPS_INPROGRESS) { client->host->hostFlags |= HCPS_WAITING; /* I am waiting */ #ifdef AFS_PTHREAD_ENV - pthread_cond_wait(&client->host->cond, &host_glock_mutex); + CV_WAIT(&client->host->cond, &host_glock_mutex); #else /* AFS_PTHREAD_ENV */ if ((code = LWP_WaitProcess(&(client->host->hostFlags))) != LWP_SUCCESS) @@ -776,7 +776,7 @@ GetVolumePackage(struct rx_connection *tcon, AFSFid * Fid, Volume ** volptr, (chkforDir == MustBeDIR ? 0 : locktype))) != 0) return (errorCode); if (chkforDir == MustBeDIR) - assert((*parent) == 0); + osi_Assert((*parent) == 0); if (!(*client)) { if ((errorCode = GetClient(tcon, client)) != 0) return (errorCode); @@ -814,15 +814,15 @@ PutVolumePackage(Vnode * parentwhentargetnotdir, Vnode * targetptr, if (parentwhentargetnotdir) { VPutVnode(&fileCode, parentwhentargetnotdir); - assert(!fileCode || (fileCode == VSALVAGE)); + osi_Assert(!fileCode || (fileCode == VSALVAGE)); } if (targetptr) { VPutVnode(&fileCode, targetptr); - assert(!fileCode || (fileCode == VSALVAGE)); + osi_Assert(!fileCode || (fileCode == VSALVAGE)); } if (parentptr) { VPutVnode(&fileCode, parentptr); - assert(!fileCode || (fileCode == VSALVAGE)); + osi_Assert(!fileCode || (fileCode == VSALVAGE)); } if (volptr) { VPutVolume(volptr); @@ -1173,7 +1173,7 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len) } IH_INIT(newH, V_device(volptr), V_id(volptr), ino); newFdP = IH_OPEN(newH); - assert(newFdP != NULL); + osi_Assert(newFdP != NULL); FDH_SEEK(targFdP, off, SEEK_SET); FDH_SEEK(newFdP, off, SEEK_SET); @@ -1248,11 +1248,11 @@ CopyOnWrite(Vnode * targetptr, Volume * volptr, afs_foff_t off, afs_fsize_t len) FDH_REALLYCLOSE(targFdP); rc = IH_DEC(V_linkHandle(volptr), VN_GET_INO(targetptr), V_parentId(volptr)); - assert(!rc); + osi_Assert(!rc); IH_RELEASE(targetptr->handle); rc = FDH_SYNC(newFdP); - assert(rc == 0); + osi_Assert(rc == 0); FDH_CLOSE(newFdP); targetptr->handle = newH; VN_SET_INO(targetptr, ino); @@ -1352,7 +1352,7 @@ DeleteTarget(Vnode * parentptr, Volume * volptr, Vnode ** targetptr, } else if ((*targetptr)->disk.type == vDirectory) return (EISDIR); - /*assert((*targetptr)->disk.uniquifier == fileFid->Unique); */ + /*osi_Assert((*targetptr)->disk.uniquifier == fileFid->Unique); */ /** * If the uniquifiers dont match then instead of asserting * take the volume offline and return VSALVAGE @@ -1943,21 +1943,21 @@ RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg, *name = malloc(temp); if (!*name) { ViceLog(0, ("Failed malloc in RXGetVolumeStatus\n")); - assert(0); + osi_Panic("Failed malloc in RXGetVolumeStatus\n"); } strcpy(*name, V_name(volptr)); temp = strlen(V_offlineMessage(volptr)) + 1; *offMsg = malloc(temp); if (!*offMsg) { ViceLog(0, ("Failed malloc in RXGetVolumeStatus\n")); - assert(0); + osi_Panic("Failed malloc in RXGetVolumeStatus\n"); } strcpy(*offMsg, V_offlineMessage(volptr)); #if OPENAFS_VOL_STATS *motd = malloc(1); if (!*motd) { ViceLog(0, ("Failed malloc in RXGetVolumeStatus\n")); - assert(0); + osi_Panic("Failed malloc in RXGetVolumeStatus\n"); } strcpy(*motd, nullString); #else @@ -1965,7 +1965,7 @@ RXGetVolumeStatus(AFSFetchVolumeStatus * status, char **name, char **offMsg, *motd = malloc(temp); if (!*motd) { ViceLog(0, ("Failed malloc in RXGetVolumeStatus\n")); - assert(0); + osi_Panic("Failed malloc in RXGetVolumeStatus\n"); } strcpy(*motd, V_motd(volptr)); #endif /* FS_STATS_DETAILED */ @@ -2055,7 +2055,7 @@ AllocSendBuffer() tmp = malloc(sendBufSize); if (!tmp) { ViceLog(0, ("Failed malloc in AllocSendBuffer\n")); - assert(0); + osi_Panic("Failed malloc in AllocSendBuffer\n"); } return tmp; } @@ -2214,7 +2214,7 @@ common_FetchData64(struct rx_call *acall, struct AFSFid *Fid, if (parentwhentargetnotdir != NULL) { tparentwhentargetnotdir = *parentwhentargetnotdir; VPutVnode(&fileCode, parentwhentargetnotdir); - assert(!fileCode || (fileCode == VSALVAGE)); + osi_Assert(!fileCode || (fileCode == VSALVAGE)); parentwhentargetnotdir = NULL; } #if FS_STATS_DETAILED @@ -2433,7 +2433,7 @@ SRXAFS_FetchACL(struct rx_call * acall, struct AFSFid * Fid, AccessList->AFSOpaque_val = malloc(AFSOPAQUEMAX); if (!AccessList->AFSOpaque_val) { ViceLog(0, ("Failed malloc in SRXAFS_FetchACL\n")); - assert(0); + osi_Panic("Failed malloc in SRXAFS_FetchACL\n"); } /* @@ -2623,14 +2623,14 @@ SRXAFS_BulkStatus(struct rx_call * acall, struct AFSCBFids * Fids, malloc(nfiles * sizeof(struct AFSFetchStatus)); if (!OutStats->AFSBulkStats_val) { ViceLog(0, ("Failed malloc in SRXAFS_BulkStatus\n")); - assert(0); + osi_Panic("Failed malloc in SRXAFS_BulkStatus\n"); } OutStats->AFSBulkStats_len = nfiles; CallBacks->AFSCBs_val = (struct AFSCallBack *) malloc(nfiles * sizeof(struct AFSCallBack)); if (!CallBacks->AFSCBs_val) { ViceLog(0, ("Failed malloc in SRXAFS_BulkStatus\n")); - assert(0); + osi_Panic("Failed malloc in SRXAFS_BulkStatus\n"); } CallBacks->AFSCBs_len = nfiles; @@ -2774,14 +2774,14 @@ SRXAFS_InlineBulkStatus(struct rx_call * acall, struct AFSCBFids * Fids, malloc(nfiles * sizeof(struct AFSFetchStatus)); if (!OutStats->AFSBulkStats_val) { ViceLog(0, ("Failed malloc in SRXAFS_FetchStatus\n")); - assert(0); + osi_Panic("Failed malloc in SRXAFS_FetchStatus\n"); } OutStats->AFSBulkStats_len = nfiles; CallBacks->AFSCBs_val = (struct AFSCallBack *) malloc(nfiles * sizeof(struct AFSCallBack)); if (!CallBacks->AFSCBs_val) { ViceLog(0, ("Failed malloc in SRXAFS_FetchStatus\n")); - assert(0); + osi_Panic("Failed malloc in SRXAFS_FetchStatus\n"); } CallBacks->AFSCBs_len = nfiles; @@ -3052,7 +3052,7 @@ common_StoreData64(struct rx_call *acall, struct AFSFid *Fid, if (parentwhentargetnotdir != NULL) { tparentwhentargetnotdir = *parentwhentargetnotdir; VPutVnode(&fileCode, parentwhentargetnotdir); - assert(!fileCode || (fileCode == VSALVAGE)); + osi_Assert(!fileCode || (fileCode == VSALVAGE)); parentwhentargetnotdir = NULL; } #if FS_STATS_DETAILED @@ -3301,7 +3301,7 @@ SRXAFS_StoreACL(struct rx_call * acall, struct AFSFid * Fid, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* break call backs on the directory */ BreakCallBack(client->host, Fid, 0); @@ -3407,7 +3407,7 @@ SAFSS_StoreStatus(struct rx_call *acall, struct AFSFid *Fid, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* Break call backs on Fid */ BreakCallBack(client->host, Fid, 0); @@ -3564,14 +3564,14 @@ SAFSS_RemoveFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name, DeleteFileCallBacks(&fileFid); /* convert the parent lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); } else { /* convert the parent lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* convert the target lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* tell all the file has changed */ BreakCallBack(client->host, &fileFid, 1); } @@ -3736,7 +3736,7 @@ SAFSS_CreateFile(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* break call back on parent dir */ BreakCallBack(client->host, DirFid, 0); @@ -4083,7 +4083,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, } if (testnode == 1) top = 1; testvptr = VGetVnode(&errorCode, volptr, testnode, READ_LOCK); - assert(errorCode == 0); + osi_Assert(errorCode == 0); testnode = testvptr->disk.parent; VPutVnode(&errorCode, testvptr); if ((top == 1) && (testnode != 0)) { @@ -4094,7 +4094,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, errorCode = EIO; goto Bad_Rename; } - assert(errorCode == 0); + osi_Assert(errorCode == 0); } } @@ -4129,7 +4129,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, if (newfileptr) { /* Delete NewName from its directory */ code = Delete(&newdir, NewName); - assert(code == 0); + osi_Assert(code == 0); /* Drop the link count */ newfileptr->disk.linkCount--; @@ -4176,7 +4176,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, goto Bad_Rename; /* Delete the old name */ - assert(Delete(&olddir, (char *)OldName) == 0); + osi_Assert(Delete(&olddir, (char *)OldName) == 0); /* if the directory length changes, reflect it in the statistics */ #if FS_STATS_DETAILED @@ -4202,13 +4202,13 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, /* if we are dealing with a rename of a directory, and we need to * update the .. entry of that directory */ if (updatefile) { - assert(!fileptr->disk.cloned); + osi_Assert(!fileptr->disk.cloned); fileptr->changed_newTime = 1; /* status change of moved file */ /* fix .. to point to the correct place */ Delete(&filedir, ".."); /* No assert--some directories may be bad */ - assert(Create(&filedir, "..", NewDirFid) == 0); + osi_Assert(Create(&filedir, "..", NewDirFid) == 0); fileptr->disk.dataVersion++; /* if the parent directories are different the link counts have to be */ @@ -4230,15 +4230,15 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, /* convert the write locks to a read locks before breaking callbacks */ VVnodeWriteToRead(&errorCode, newvptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); if (oldvptr != newvptr) { VVnodeWriteToRead(&errorCode, oldvptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); } if (newfileptr && !doDelete) { /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, newfileptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); } /* break call back on NewDirFid, OldDirFid, NewDirFid and newFileFid */ @@ -4268,7 +4268,7 @@ SAFSS_Rename(struct rx_call *acall, struct AFSFid *OldDirFid, char *OldName, Bad_Rename: if (newfileptr) { VPutVnode(&fileCode, newfileptr); - assert(fileCode == 0); + osi_Assert(fileCode == 0); } (void)PutVolumePackage(fileptr, (newvptr && newvptr != oldvptr ? newvptr : 0), oldvptr, volptr, &client); @@ -4475,7 +4475,7 @@ SAFSS_Symlink(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* break call back on the parent dir */ BreakCallBack(client->host, DirFid, 0); @@ -4675,9 +4675,9 @@ SAFSS_Link(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write locks to read locks before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* break call back on DirFid */ BreakCallBack(client->host, DirFid, 0); @@ -4855,10 +4855,10 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name, #endif /* FS_STATS_DETAILED */ /* Point to target's ACL buffer and copy the parent's ACL contents to it */ - assert((SetAccessList + osi_Assert((SetAccessList (&targetptr, &volptr, &newACL, &newACLSize, &parentwhentargetnotdir, (AFSFid *) 0, 0)) == 0); - assert(parentwhentargetnotdir == 0); + osi_Assert(parentwhentargetnotdir == 0); memcpy((char *)newACL, (char *)VVnodeACL(parentptr), VAclSize(parentptr)); /* update the status for the target vnode */ @@ -4867,7 +4867,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* Actually create the New directory in the directory package */ SetDirHandle(&dir, targetptr); - assert(!(MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid))); + osi_Assert(!(MakeDir(&dir, (afs_int32 *)OutFid, (afs_int32 *)DirFid))); DFlush(); VN_SET_LEN(targetptr, (afs_fsize_t) Length(&dir)); @@ -4877,7 +4877,7 @@ SAFSS_MakeDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* break call back on DirFid */ BreakCallBack(client->host, DirFid, 0); @@ -5043,7 +5043,7 @@ SAFSS_RemoveDir(struct rx_call *acall, struct AFSFid *DirFid, char *Name, /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, parentptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); /* break call back on DirFid and fileFid */ BreakCallBack(client->host, DirFid, 0); @@ -5428,7 +5428,7 @@ SAFSS_ReleaseLock(struct rx_call *acall, struct AFSFid *Fid, if (targetptr->disk.lock.lockCount <= 0) { /* convert the write lock to a read lock before breaking callbacks */ VVnodeWriteToRead(&errorCode, targetptr); - assert(!errorCode || errorCode == VSALVAGE); + osi_Assert(!errorCode || errorCode == VSALVAGE); BreakCallBack(client->host, Fid, 0); } @@ -7087,7 +7087,7 @@ FetchData_RXStyle(Volume * volptr, Vnode * targetptr, { afs_int32 high, low; SplitOffsetOrSize(Len, high, low); - assert(Int64Mode || (Len >= 0 && high == 0) || Len < 0); + osi_Assert(Int64Mode || (Len >= 0 && high == 0) || Len < 0); if (Int64Mode) { high = htonl(high); rx_Write(Call, (char *)&high, sizeof(afs_int32)); /* High order bits */ @@ -7482,7 +7482,7 @@ StoreData_RXStyle(Volume * volptr, Vnode * targetptr, struct AFSFid * Fid, } if (errorCode) { afs_sfsize_t nfSize = FDH_SIZE(fdP); - assert(nfSize >= 0); + osi_Assert(nfSize >= 0); /* something went wrong: adjust size and return */ VN_SET_LEN(targetptr, nfSize); /* set new file size. */ /* changed_newTime is tested in StoreData to detemine if we diff --git a/src/viced/callback.c b/src/viced/callback.c index 23e08a62f..c2d9d65e9 100644 --- a/src/viced/callback.c +++ b/src/viced/callback.c @@ -354,7 +354,8 @@ CDel(struct CallBack *cb, int deletefe) for (safety = 0, cbp = &fe->firstcb; *cbp && *cbp != cbi; cbp = &itocb(*cbp)->cnext, safety++) { if (safety > cbstuff.nblks + 10) { - assert(0); + osi_Panic("CDel: Internal Error -- shutting down: wanted %d from %d, now at %d\n", + cbi, fe->firstcb, *cbp); ViceLog(0, ("CDel: Internal Error -- shutting down: wanted %d from %d, now at %d\n", cbi, fe->firstcb, *cbp)); @@ -422,7 +423,7 @@ FDel(struct FileEntry *fe) while (*p && *p != fei) p = &itofe(*p)->fnext; - assert(*p); + osi_Assert(*p); *p = fe->fnext; FreeFE(fe); return 0; @@ -439,7 +440,7 @@ InitCallBack(int nblks) FE = ((struct FileEntry *)(calloc(nblks, sizeof(struct FileEntry)))); if (!FE) { ViceLog(0, ("Failed malloc in InitCallBack\n")); - assert(0); + osi_Panic("Failed malloc in InitCallBack\n"); } FE--; /* FE[0] is supposed to point to junk */ cbstuff.nFEs = nblks; @@ -448,7 +449,7 @@ InitCallBack(int nblks) CB = ((struct CallBack *)(calloc(nblks, sizeof(struct CallBack)))); if (!CB) { ViceLog(0, ("Failed malloc in InitCallBack\n")); - assert(0); + osi_Panic("Failed malloc in InitCallBack\n"); } CB--; /* CB[0] is supposed to point to junk */ cbstuff.nCBs = nblks; @@ -693,7 +694,7 @@ MultiBreakCallBack_r(struct cbstruct cba[], int ncbas, static struct AFSCBs tc = { 0, 0 }; int multi_to_cba_map[MAX_CB_HOSTS]; - assert(ncbas <= MAX_CB_HOSTS); + osi_Assert(ncbas <= MAX_CB_HOSTS); /* sort cba list to avoid makecall issues */ qsort(cba, ncbas, sizeof(struct cbstruct), CompareCBA); @@ -1146,7 +1147,7 @@ MultiBreakVolumeCallBack_r(struct host *host, int isheld, h_Unlock_r(host); return 0; /* parent will release hold */ } - assert(parms->ncbas <= MAX_CB_HOSTS); + osi_Assert(parms->ncbas <= MAX_CB_HOSTS); /* Do not call MultiBreakCallBack on the current host structure ** because it would prematurely release the hold on the host @@ -1239,7 +1240,7 @@ BreakVolumeCallBacksLater(afs_uint32 volume) ViceLog(25, ("Fsync thread wakeup\n")); #ifdef AFS_PTHREAD_ENV FSYNC_LOCK; - assert(pthread_cond_broadcast(&fsync_cond) == 0); + CV_BROADCAST(&fsync_cond); FSYNC_UNLOCK; #else LWP_NoYieldSignal(fsync_wait); @@ -2967,7 +2968,7 @@ MultiBreakCallBackAlternateAddress_r(struct host *host, if (!interfaces || !conns) { ViceLog(0, ("Failed malloc in MultiBreakCallBackAlternateAddress_r\n")); - assert(0); + osi_Panic("Failed malloc in MultiBreakCallBackAlternateAddress_r\n"); } /* initialize alternate rx connections */ @@ -2986,7 +2987,7 @@ MultiBreakCallBackAlternateAddress_r(struct host *host, j++; } - assert(j); /* at least one alternate address */ + osi_Assert(j); /* at least one alternate address */ ViceLog(125, ("Starting multibreakcall back on all addr for host %p (%s:%d)\n", host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); @@ -3062,7 +3063,7 @@ MultiProbeAlternateAddress_r(struct host *host) conns = calloc(i, sizeof(struct rx_connection *)); if (!interfaces || !conns) { ViceLog(0, ("Failed malloc in MultiProbeAlternateAddress_r\n")); - assert(0); + osi_Panic("Failed malloc in MultiProbeAlternateAddress_r\n"); } /* initialize alternate rx connections */ @@ -3081,7 +3082,7 @@ MultiProbeAlternateAddress_r(struct host *host) j++; } - assert(j); /* at least one alternate address */ + osi_Assert(j); /* at least one alternate address */ ViceLog(125, ("Starting multiprobe on all addr for host %p (%s:%d)\n", host, afs_inet_ntoa_r(host->host, hoststr), diff --git a/src/viced/host.c b/src/viced/host.c index 0b9427350..e81196c79 100644 --- a/src/viced/host.c +++ b/src/viced/host.c @@ -218,7 +218,7 @@ GetHTBlock(void) } #ifdef AFS_PTHREAD_ENV for (i = 0; i < (h_HTSPERBLOCK); i++) - assert(pthread_cond_init(&block->entry[i].cond, NULL) == 0); + CV_INIT(&block->entry[i].cond, "block entry", CV_DEFAULT, 0); #endif /* AFS_PTHREAD_ENV */ for (i = 0; i < (h_HTSPERBLOCK); i++) Lock_Init(&block->entry[i].lock); @@ -241,7 +241,7 @@ GetHT(void) if (HTFree == NULL) GetHTBlock(); - assert(HTFree != NULL); + osi_Assert(HTFree != NULL); entry = HTFree; HTFree = entry->next; HTs++; @@ -358,7 +358,7 @@ hpr_GetHostCPS(afs_int32 host, prlist *CPS) if (!uclient) { code = hpr_Initialize(&uclient); if (!code) - assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); + osi_Assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); else return code; } @@ -392,7 +392,7 @@ hpr_NameToId(namelist *names, idlist *ids) if (!uclient) { code = hpr_Initialize(&uclient); if (!code) - assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); + osi_Assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); else return code; } @@ -417,7 +417,7 @@ hpr_IdToName(idlist *ids, namelist *names) if (!uclient) { code = hpr_Initialize(&uclient); if (!code) - assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); + osi_Assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); else return code; } @@ -441,7 +441,7 @@ hpr_GetCPS(afs_int32 id, prlist *CPS) if (!uclient) { code = hpr_Initialize(&uclient); if (!code) - assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); + osi_Assert(pthread_setspecific(viced_uclient_key, (void *)uclient) == 0); else return code; } @@ -592,7 +592,7 @@ h_gethostcps_r(struct host *host, afs_int32 now) slept = 1; /* I did sleep */ host->hostFlags |= HCPS_WAITING; /* I am sleeping now */ #ifdef AFS_PTHREAD_ENV - pthread_cond_wait(&host->cond, &host_glock_mutex); + CV_WAIT(&host->cond, &host_glock_mutex); #else /* AFS_PTHREAD_ENV */ if ((code = LWP_WaitProcess(&(host->hostFlags))) != LWP_SUCCESS) ViceLog(0, ("LWP_WaitProcess returned %d\n", code)); @@ -653,7 +653,7 @@ h_gethostcps_r(struct host *host, afs_int32 now) if (host->hostFlags & HCPS_WAITING) { /* somebody is waiting */ host->hostFlags &= ~HCPS_WAITING; #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&host->cond) == 0); + CV_BROADCAST(&host->cond); #else /* AFS_PTHREAD_ENV */ if ((code = LWP_NoYieldSignal(&(host->hostFlags))) != LWP_SUCCESS) ViceLog(0, ("LWP_NoYieldSignal returns %d\n", code)); @@ -775,7 +775,7 @@ h_Lookup_r(afs_uint32 haddr, afs_uint16 hport, struct host **hostp) restart: for (chain = hostAddrHashTable[index]; chain; chain = chain->next) { host = chain->hostPtr; - assert(host); + osi_Assert(host); if (!(host->hostFlags & HOSTDELETED) && chain->addr == haddr && chain->port == hport) { if ((host->hostFlags & HWHO_INPROGRESS) && @@ -822,7 +822,7 @@ h_LookupUuid_r(afsUUID * uuidp) for (chain = hostUuidHashTable[index]; chain; chain = chain->next) { host = chain->hostPtr; - assert(host); + osi_Assert(host); if (!(host->hostFlags & HOSTDELETED) && host->interface && afs_uuid_equal(&host->interface->uuid, uuidp)) { return host; @@ -990,12 +990,12 @@ h_Enumerate(int (*proc) (struct host*, int, void *), void *param) list = (struct host **)malloc(hostCount * sizeof(struct host *)); if (!list) { ViceLog(0, ("Failed malloc in h_Enumerate (list)\n")); - assert(0); + osi_Panic("Failed malloc in h_Enumerate (list)\n"); } flags = (int *)malloc(hostCount * sizeof(int)); if (!flags) { ViceLog(0, ("Failed malloc in h_Enumerate (flags)\n")); - assert(0); + osi_Panic("Failed malloc in h_Enumerate (flags)\n"); } for (totalCount = count = 0, host = hostList; host && totalCount < hostCount; @@ -1155,7 +1155,7 @@ h_AddHostToUuidHashTable_r(struct afsUUID *uuid, struct host *host) chain = (struct h_UuidHashChain *)malloc(sizeof(struct h_UuidHashChain)); if (!chain) { ViceLog(0, ("Failed malloc in h_AddHostToUuidHashTable_r\n")); - assert(0); + osi_Panic("Failed malloc in h_AddHostToUuidHashTable_r\n"); } chain->hostPtr = host; chain->next = hostUuidHashTable[index]; @@ -1187,7 +1187,7 @@ h_DeleteHostFromUuidHashTable_r(struct host *host) if (LogLevel >= 125) afsUUID_to_string(&host->interface->uuid, uuid1, 127); for (uhp = &hostUuidHashTable[index]; (uth = *uhp); uhp = &uth->next) { - assert(uth->hostPtr); + osi_Assert(uth->hostPtr); if (uth->hostPtr == host) { ViceLog(125, ("h_DeleteHostFromUuidHashTable_r: host %" AFS_PTR_FMT " (uuid %s %s:%d)\n", @@ -1218,8 +1218,8 @@ invalidateInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port) struct Interface *interface; char hoststr[16], hoststr2[16]; - assert(host); - assert(host->interface); + osi_Assert(host); + osi_Assert(host->interface); ViceLog(125, ("invalidateInterfaceAddr : host %" AFS_PTR_FMT " (%s:%d) addr %s:%d\n", host, afs_inet_ntoa_r(host->host, hoststr), @@ -1342,7 +1342,7 @@ createHostAddrHashChain_r(int index, afs_uint32 addr, afs_uint16 port, struct ho chain = (struct h_AddrHashChain *)malloc(sizeof(struct h_AddrHashChain)); if (!chain) { ViceLog(0, ("Failed malloc in h_AddHostToAddrHashTable_r\n")); - assert(0); + osi_Panic("Failed malloc in h_AddHostToAddrHashTable_r\n"); } chain->hostPtr = host; chain->next = hostAddrHashTable[index]; @@ -1378,7 +1378,7 @@ reconcileHosts_r(afs_uint32 addr, afs_uint16 port, struct host *newHost, AFS_PTR_FMT, afs_inet_ntoa_r(addr, hoststr), ntohs(port), newHost, oldHost)); - assert(oldHost != newHost); + osi_Assert(oldHost != newHost); caps.Capabilities_val = NULL; if (!sc) { @@ -1528,8 +1528,8 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port) struct Interface *interface; char hoststr[16], hoststr2[16]; - assert(host); - assert(host->interface); + osi_Assert(host); + osi_Assert(host->interface); /* * Make sure this address is on the list of known addresses @@ -1563,7 +1563,7 @@ addInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port) malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * number)); if (!interface) { ViceLog(0, ("Failed malloc in addInterfaceAddr_r\n")); - assert(0); + osi_Panic("Failed malloc in addInterfaceAddr_r\n"); } interface->numberOfInterfaces = number + 1; interface->uuid = host->interface->uuid; @@ -1595,8 +1595,8 @@ removeInterfaceAddr_r(struct host *host, afs_uint32 addr, afs_uint16 port) struct Interface *interface; char hoststr[16], hoststr2[16]; - assert(host); - assert(host->interface); + osi_Assert(host); + osi_Assert(host->interface); ViceLog(125, ("removeInterfaceAddr : host %" AFS_PTR_FMT " (%s:%d) addr %s:%d\n", host, afs_inet_ntoa_r(host->host, hoststr), @@ -1756,7 +1756,7 @@ h_GetHost_r(struct rx_connection *tcon) identP = (struct Identity *)malloc(sizeof(struct Identity)); if (!identP) { ViceLog(0, ("Failed malloc in h_GetHost_r\n")); - assert(0); + osi_Panic("Failed malloc in h_GetHost_r\n"); } identP->valid = 0; rx_SetSpecific(tcon, rxcon_ident_key, identP); @@ -1798,7 +1798,7 @@ h_GetHost_r(struct rx_connection *tcon) identP = (struct Identity *)malloc(sizeof(struct Identity)); if (!identP) { ViceLog(0, ("Failed malloc in h_GetHost_r\n")); - assert(0); + osi_Panic("Failed malloc in h_GetHost_r\n"); } identP->valid = 1; identP->uuid = interf.uuid; @@ -1987,7 +1987,7 @@ h_GetHost_r(struct rx_connection *tcon) if (!identP) { ViceLog(0, ("Failed malloc in h_GetHost_r\n")); - assert(0); + osi_Panic("Failed malloc in h_GetHost_r\n"); } identP->valid = 0; if (!pident) @@ -2006,7 +2006,7 @@ h_GetHost_r(struct rx_connection *tcon) if (!identP) { ViceLog(0, ("Failed malloc in h_GetHost_r\n")); - assert(0); + osi_Panic("Failed malloc in h_GetHost_r\n"); } identP->valid = 1; interfValid = 1; @@ -2158,7 +2158,7 @@ h_GetHost_r(struct rx_connection *tcon) ("InitCallBackState3 success on host %" AFS_PTR_FMT " (%s:%d)\n", host, afs_inet_ntoa_r(host->host, hoststr), ntohs(host->port))); - assert(interfValid == 1); + osi_Assert(interfValid == 1); initInterfaceAddr_r(host, &interf); } } @@ -2232,9 +2232,7 @@ h_InitHostPackage(void) } rxcon_ident_key = rx_KeyCreate((rx_destructor_t) free); rxcon_client_key = rx_KeyCreate((rx_destructor_t) 0); -#ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_init(&host_glock_mutex, NULL) == 0); -#endif /* AFS_PTHREAD_ENV */ + MUTEX_INIT(&host_glock_mutex, "host glock", MUTEX_DEFAULT, 0); } static int @@ -2273,7 +2271,7 @@ MapName_r(char *aname, char *acell, afs_int32 * aval) tname = (char *)malloc(PR_MAXNAMELEN); if (!tname) { ViceLog(0, ("Failed malloc in MapName_r\n")); - assert(0); + osi_Panic("Failed malloc in MapName_r\n"); } strcpy(tname, aname); tname[anamelen] = '@'; @@ -2543,7 +2541,7 @@ h_FindClient_r(struct rx_connection *tcon) * possible failure modes that we will disable it again */ /* Turn off System:Administrator for safety * if (AL_IsAMember(SystemId, client->CPS) == 0) - * assert(AL_DisableGroup(SystemId, client->CPS) == 0); */ + * osi_Assert(AL_DisableGroup(SystemId, client->CPS) == 0); */ } /* Now, tcon may already be set to a rock, since we blocked with no host @@ -2628,7 +2626,7 @@ h_FindClient_r(struct rx_connection *tcon) int h_ReleaseClient_r(struct client *client) { - assert(client->refCount > 0); + osi_Assert(client->refCount > 0); client->refCount--; return 0; } @@ -2706,7 +2704,7 @@ h_UserName(struct client *client) lids.idlist_val = (afs_int32 *) malloc(1 * sizeof(afs_int32)); if (!lids.idlist_val) { ViceLog(0, ("Failed malloc in h_UserName\n")); - assert(0); + osi_Panic("Failed malloc in h_UserName\n"); } lnames.namelist_len = 0; lnames.namelist_val = (prname *) 0; @@ -3241,7 +3239,7 @@ h_stateSaveHost(struct host * host, int flags, void* rock) if_len = sizeof(struct Interface) + ((host->interface->numberOfInterfaces-1) * sizeof(struct AddrPort)); ifp = (struct Interface *) malloc(if_len); - assert(ifp != NULL); + osi_Assert(ifp != NULL); memcpy(ifp, host->interface, if_len); hdr.interfaces = host->interface->numberOfInterfaces; iov[iovcnt].iov_base = (char *) ifp; @@ -3252,7 +3250,7 @@ h_stateSaveHost(struct host * host, int flags, void* rock) hdr.hcps = host->hcps.prlist_len; hcps_len = hdr.hcps * sizeof(afs_int32); hcps = (afs_int32 *) malloc(hcps_len); - assert(hcps != NULL); + osi_Assert(hcps != NULL); memcpy(hcps, host->hcps.prlist_val, hcps_len); iov[iovcnt].iov_base = (char *) hcps; iov[iovcnt].iov_len = hcps_len; @@ -3324,7 +3322,7 @@ h_stateRestoreHost(struct fs_dump_state * state) ifp_len = sizeof(struct Interface) + ((hdr.interfaces-1) * sizeof(struct AddrPort)); ifp = (struct Interface *) malloc(ifp_len); - assert(ifp != NULL); + osi_Assert(ifp != NULL); iov[iovcnt].iov_base = (char *) ifp; iov[iovcnt].iov_len = ifp_len; iovcnt++; @@ -3332,7 +3330,7 @@ h_stateRestoreHost(struct fs_dump_state * state) if (hdr.hcps) { hcps_len = hdr.hcps * sizeof(afs_int32); hcps = (afs_int32 *) malloc(hcps_len); - assert(hcps != NULL); + osi_Assert(hcps != NULL); iov[iovcnt].iov_base = (char *) hcps; iov[iovcnt].iov_len = hcps_len; iovcnt++; @@ -3353,11 +3351,11 @@ h_stateRestoreHost(struct fs_dump_state * state) if (!hdr.hcps && hdsk.hcps_valid) { /* valid, zero-length host cps ; does this ever happen? */ hcps = (afs_int32 *) malloc(sizeof(afs_int32)); - assert(hcps != NULL); + osi_Assert(hcps != NULL); } host = GetHT(); - assert(host != NULL); + osi_Assert(host != NULL); if (ifp) { host->interface = ifp; @@ -3960,8 +3958,8 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf) char uuidstr[128]; afs_uint16 port7001 = htons(7001); - assert(host); - assert(interf); + osi_Assert(host); + osi_Assert(interf); number = interf->numberOfInterfaces; myAddr = host->host; /* current interface address */ @@ -4037,7 +4035,7 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf) (sizeof(struct AddrPort) * (count - 1))); if (!interface) { ViceLog(0, ("Failed malloc in initInterfaceAddr_r 1\n")); - assert(0); + osi_Panic("Failed malloc in initInterfaceAddr_r 1\n"); } interface->numberOfInterfaces = count; } else { @@ -4045,7 +4043,7 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf) malloc(sizeof(struct Interface) + (sizeof(struct AddrPort) * count)); if (!interface) { ViceLog(0, ("Failed malloc in initInterfaceAddr_r 2\n")); - assert(0); + osi_Panic("Failed malloc in initInterfaceAddr_r 2\n"); } interface->numberOfInterfaces = count + 1; interface->interface[count].addr = myAddr; @@ -4067,7 +4065,7 @@ initInterfaceAddr_r(struct host *host, struct interfaceAddr *interf) interface->uuid = interf->uuid; - assert(!host->interface); + osi_Assert(!host->interface); host->interface = interface; if (LogLevel >= 125) { @@ -4098,7 +4096,7 @@ h_DeleteHostFromAddrHashTable_r(afs_uint32 addr, afs_uint16 port, for (hp = &hostAddrHashTable[h_HashIndex(addr)]; (th = *hp); hp = &th->next) { - assert(th->hostPtr); + osi_Assert(th->hostPtr); if (th->hostPtr == host && th->addr == addr && th->port == port) { ViceLog(125, ("h_DeleteHostFromAddrHashTable_r: host %" AFS_PTR_FMT " (%s:%d)\n", host, afs_inet_ntoa_r(host->host, hoststr), diff --git a/src/viced/host.h b/src/viced/host.h index 3e7b3c06a..e02e4426b 100644 --- a/src/viced/host.h +++ b/src/viced/host.h @@ -23,13 +23,11 @@ * precedence is host_listlock_mutex, host->mutex, host_glock_mutex. */ #include -#include +#include #include extern pthread_mutex_t host_glock_mutex; -#define H_LOCK \ - assert(pthread_mutex_lock(&host_glock_mutex) == 0) -#define H_UNLOCK \ - assert(pthread_mutex_unlock(&host_glock_mutex) == 0) +#define H_LOCK MUTEX_ENTER(&host_glock_mutex); +#define H_UNLOCK MUTEX_EXIT(&host_glock_mutex); extern pthread_key_t viced_uclient_key; #else /* AFS_PTHREAD_ENV */ #define H_LOCK @@ -193,7 +191,7 @@ do { \ hostList ? (hostList->prev = (h)):0; \ hostList = (h); \ hostCount++; -#define h_DeleteList_r(h) assert(hostCount>0); \ +#define h_DeleteList_r(h) osi_Assert(hostCount>0); \ hostCount--; \ (h)->next ? ((h)->next->prev = (h)->prev):0;\ (h)->prev ? ((h)->prev->next = (h)->next):0;\ diff --git a/src/viced/viced.c b/src/viced/viced.c index e94bbff30..b1b9298e2 100644 --- a/src/viced/viced.c +++ b/src/viced/viced.c @@ -52,11 +52,7 @@ #undef SHARED #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -269,8 +265,8 @@ static int fs_stateInit(void) fs_state.options.fs_state_verify_before_save = 1; fs_state.options.fs_state_verify_after_restore = 1; - assert(pthread_cond_init(&fs_state.worker_done_cv, NULL) == 0); - assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0); + CV_INIT(&fs_state.worker_done_cv, "worker done", CV_DEFAULT, 0); + osi_Assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0); } #endif /* AFS_NT40_ENV */ #endif /* AFS_DEMAND_ATTACH_FS */ @@ -511,7 +507,7 @@ FiveMinuteCheckLWP(void *unused) #ifdef AFS_DEMAND_ATTACH_FS fs_state.FiveMinuteLWP_tranquil = 1; FS_LOCK; - assert(pthread_cond_broadcast(&fs_state.worker_done_cv)==0); + CV_BROADCAST(&fs_state.worker_done_cv); FS_UNLOCK; FS_STATE_UNLOCK; #endif @@ -563,7 +559,7 @@ HostCheckLWP(void *unused) #ifdef AFS_DEMAND_ATTACH_FS fs_state.HostCheckLWP_tranquil = 1; FS_LOCK; - assert(pthread_cond_broadcast(&fs_state.worker_done_cv)==0); + CV_BROADCAST(&fs_state.worker_done_cv); FS_UNLOCK; FS_STATE_UNLOCK; #endif @@ -599,9 +595,8 @@ FsyncCheckLWP(void *unused) fsync_next.tv_nsec = 0; fsync_next.tv_sec = time(0) + fiveminutes; - code = - pthread_cond_timedwait(&fsync_cond, &fsync_glock_mutex, - &fsync_next); + code = CV_TIMEDWAIT(&fsync_cond, &fsync_glock_mutex, + &fsync_next); if (code != 0 && code != ETIMEDOUT) ViceLog(0, ("pthread_cond_timedwait returned %d\n", code)); #else /* AFS_PTHREAD_ENV */ @@ -630,7 +625,7 @@ FsyncCheckLWP(void *unused) #ifdef AFS_DEMAND_ATTACH_FS fs_state.FsyncCheckLWP_tranquil = 1; FS_LOCK; - assert(pthread_cond_broadcast(&fs_state.worker_done_cv)==0); + CV_BROADCAST(&fs_state.worker_done_cv); FS_UNLOCK; FS_STATE_UNLOCK; #endif /* AFS_DEMAND_ATTACH_FS */ @@ -790,7 +785,8 @@ ShutdownWatchdogLWP(void *unused) sleep(panic_timeout); ViceLog(0, ("ShutdownWatchdogLWP: Failed to shutdown and panic " "within %d seconds; forcing panic\n", panic_timeout)); - assert(0); + osi_Panic("ShutdownWatchdogLWP: Failed to shutdown and panic " + "within %d seconds; forcing panic\n", panic_timeout); return NULL; } @@ -804,11 +800,11 @@ ShutDownAndCore(int dopanic) #ifdef AFS_PTHREAD_ENV pthread_t watchdogPid; pthread_attr_t tattr; - assert(pthread_attr_init(&tattr) == 0); - assert(pthread_create(&watchdogPid, &tattr, ShutdownWatchdogLWP, NULL) == 0); + osi_Assert(pthread_attr_init(&tattr) == 0); + osi_Assert(pthread_create(&watchdogPid, &tattr, ShutdownWatchdogLWP, NULL) == 0); #else PROCESS watchdogPid; - assert(LWP_CreateProcess + osi_Assert(LWP_CreateProcess (ShutdownWatchdogLWP, stack * 1024, LWP_MAX_PRIORITY - 2, NULL, "ShutdownWatchdog", &watchdogPid) == LWP_SUCCESS); #endif @@ -866,7 +862,7 @@ ShutDownAndCore(int dopanic) FS_LOCK; FS_STATE_UNLOCK; ViceLog(0, ("waiting for background host/callback threads to quiesce before saving fileserver state...\n")); - assert(pthread_cond_wait(&fs_state.worker_done_cv, &fileproc_glock_mutex) == 0); + CV_WAIT(&fs_state.worker_done_cv, &fileproc_glock_mutex); FS_UNLOCK; FS_STATE_RDLOCK; } @@ -895,8 +891,8 @@ ShutDownAndCore(int dopanic) afs_ctime(&now, tbuffer, sizeof(tbuffer)))); } - if (dopanic) - assert(0); + if (dopanic) /* XXX pass in file and line? */ + osi_Panic("Panic requested\n"); exit(0); } @@ -1567,7 +1563,7 @@ void Die(char *msg) { ViceLog(0, ("%s\n", msg)); - assert(0); + osi_Panic("%s\n", msg); } /*Die */ @@ -1589,7 +1585,7 @@ InitPR(void) } #ifdef AFS_PTHREAD_ENV - assert(pthread_key_create(&viced_uclient_key, NULL) == 0); + osi_Assert(pthread_key_create(&viced_uclient_key, NULL) == 0); #endif SystemId = SYSADMINID; @@ -1981,7 +1977,7 @@ main(int argc, char *argv[]) exit(-1); } #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_init(&fileproc_glock_mutex, NULL) == 0); + MUTEX_INIT(&fileproc_glock_mutex, "fileproc", MUTEX_DEFAULT, 0); #endif /* AFS_PTHREAD_ENV */ #ifdef AFS_SGI_VNODE_GLUE @@ -2032,7 +2028,7 @@ main(int argc, char *argv[]) nice(-5); /* TODO: */ #endif #endif - assert(DInit(buffs) == 0); + osi_Assert(DInit(buffs) == 0); #ifdef AFS_DEMAND_ATTACH_FS FS_STATE_INIT; #endif @@ -2085,7 +2081,7 @@ main(int argc, char *argv[]) curLimit, lwps, vol_io_params.fd_max_cachesize)); } #ifndef AFS_PTHREAD_ENV - assert(LWP_InitializeProcessSupport(LWP_MAX_PRIORITY - 2, &parentPid) == + osi_Assert(LWP_InitializeProcessSupport(LWP_MAX_PRIORITY - 2, &parentPid) == LWP_SUCCESS); #endif /* !AFS_PTHREAD_ENV */ @@ -2207,10 +2203,8 @@ main(int argc, char *argv[]) /* allow super users to manage RX statistics */ rx_SetRxStatUserOk(fs_rxstat_userok); -#ifdef AFS_PTHREAD_ENV - assert(pthread_cond_init(&fsync_cond, NULL) == 0); - assert(pthread_mutex_init(&fsync_glock_mutex, NULL) == 0); -#endif + CV_INIT(&fsync_cond, "fsync", CV_DEFAULT, 0); + MUTEX_INIT(&fsync_glock_mutex, "fsync", MUTEX_DEFAULT, 0); #if !defined(AFS_DEMAND_ATTACH_FS) /* @@ -2296,27 +2290,27 @@ main(int argc, char *argv[]) #ifdef AFS_PTHREAD_ENV ViceLog(5, ("Starting pthreads\n")); - assert(pthread_attr_init(&tattr) == 0); - assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_attr_init(&tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create + osi_Assert(pthread_create (&serverPid, &tattr, FiveMinuteCheckLWP, &fiveminutes) == 0); - assert(pthread_create + osi_Assert(pthread_create (&serverPid, &tattr, HostCheckLWP, &fiveminutes) == 0); - assert(pthread_create + osi_Assert(pthread_create (&serverPid, &tattr, FsyncCheckLWP, &fiveminutes) == 0); #else /* AFS_PTHREAD_ENV */ ViceLog(5, ("Starting LWP\n")); - assert(LWP_CreateProcess + osi_Assert(LWP_CreateProcess (FiveMinuteCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2, (void *)&fiveminutes, "FiveMinuteChecks", &serverPid) == LWP_SUCCESS); - assert(LWP_CreateProcess + osi_Assert(LWP_CreateProcess (HostCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2, (void *)&fiveminutes, "HostCheck", &serverPid) == LWP_SUCCESS); - assert(LWP_CreateProcess + osi_Assert(LWP_CreateProcess (FsyncCheckLWP, stack * 1024, LWP_MAX_PRIORITY - 2, (void *)&fiveminutes, "FsyncCheck", &serverPid) == LWP_SUCCESS); #endif /* AFS_PTHREAD_ENV */ @@ -2362,7 +2356,7 @@ main(int argc, char *argv[]) sleep(1000); /* long time */ } #else /* AFS_PTHREAD_ENV */ - assert(LWP_WaitProcess(&parentPid) == LWP_SUCCESS); + osi_Assert(LWP_WaitProcess(&parentPid) == LWP_SUCCESS); #endif /* AFS_PTHREAD_ENV */ return 0; } diff --git a/src/viced/viced.h b/src/viced/viced.h index a2e64dbb5..09e2bf395 100644 --- a/src/viced/viced.h +++ b/src/viced/viced.h @@ -195,17 +195,13 @@ extern int saneacls; * HostCheck, Signal, min 2 for RXSTATS */ #ifdef AFS_PTHREAD_ENV #include -#include +#include extern pthread_mutex_t fileproc_glock_mutex; -#define FS_LOCK \ - assert(pthread_mutex_lock(&fileproc_glock_mutex) == 0) -#define FS_UNLOCK \ - assert(pthread_mutex_unlock(&fileproc_glock_mutex) == 0) +#define FS_LOCK MUTEX_ENTER(&fileproc_glock_mutex); +#define FS_UNLOCK MUTEX_EXIT(&fileproc_glock_mutex); extern pthread_mutex_t fsync_glock_mutex; -#define FSYNC_LOCK \ - assert(pthread_mutex_lock(&fsync_glock_mutex) == 0) -#define FSYNC_UNLOCK \ - assert(pthread_mutex_unlock(&fsync_glock_mutex) == 0) +#define FSYNC_LOCK MUTEX_ENTER(&fsync_glock_mutex); +#define FSYNC_UNLOCK MUTEX_EXIT(&fsync_glock_mutex); #else /* AFS_PTHREAD_ENV */ #define FS_LOCK #define FS_UNLOCK @@ -248,11 +244,11 @@ extern struct fs_state fs_state; #ifdef AFS_NT40_ENV #define FS_STATE_INIT fs_stateInit() #else -#define FS_STATE_INIT assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0) +#define FS_STATE_INIT osi_Assert(pthread_rwlock_init(&fs_state.state_lock, NULL) == 0) #endif -#define FS_STATE_RDLOCK assert(pthread_rwlock_rdlock(&fs_state.state_lock) == 0) -#define FS_STATE_WRLOCK assert(pthread_rwlock_wrlock(&fs_state.state_lock) == 0) -#define FS_STATE_UNLOCK assert(pthread_rwlock_unlock(&fs_state.state_lock) == 0) +#define FS_STATE_RDLOCK osi_Assert(pthread_rwlock_rdlock(&fs_state.state_lock) == 0) +#define FS_STATE_WRLOCK osi_Assert(pthread_rwlock_wrlock(&fs_state.state_lock) == 0) +#define FS_STATE_UNLOCK osi_Assert(pthread_rwlock_unlock(&fs_state.state_lock) == 0) #define FS_MODE_NORMAL 0 #define FS_MODE_SHUTDOWN 1 diff --git a/src/vol/Makefile.in b/src/vol/Makefile.in index 1eb8cff9b..ca6a7a04a 100644 --- a/src/vol/Makefile.in +++ b/src/vol/Makefile.in @@ -17,8 +17,9 @@ HELPER_SPLINT=@HELPER_SPLINT@ LIBS=${TOP_LIBDIR}/libcmd.a vlib.a ${TOP_LIBDIR}/util.a \ - ${TOP_LIBDIR}/libsys.a ${TOP_LIBDIR}/libdir.a \ - ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libacl.a + ${TOP_LIBDIR}/libdir.a ${TOP_LIBDIR}/librx.a \ + ${TOP_LIBDIR}/liblwp.a ${TOP_LIBDIR}/libsys.a \ + ${TOP_LIBDIR}/libacl.a CFLAGS = ${COMMON_CFLAGS} -D${SYS_NAME} ${FSINCLUDES} ${XCFLAGS} ${ARCHFLAGS} -DFSSYNC_BUILD_SERVER -DFSSYNC_BUILD_CLIENT diff --git a/src/vol/NTMakefile b/src/vol/NTMakefile index 2eb0fe00e..cba51dd59 100644 --- a/src/vol/NTMakefile +++ b/src/vol/NTMakefile @@ -173,6 +173,7 @@ EXEC_LIBS = \ $(DESTDIR)\lib\afs\afsvol.lib \ $(DESTDIR)\lib\afs\afsutil.lib \ $(DESTDIR)\lib\afs\afsdir.lib \ + $(DESTDIR)\lib\afsrx.lib \ $(DESTDIR)\lib\afslwp.lib \ $(DESTDIR)\lib\afs\afsacl.lib \ $(DESTDIR)\lib\afs\afsreg.lib \ diff --git a/src/vol/clone.c b/src/vol/clone.c index adc3f86fb..f6d637917 100644 --- a/src/vol/clone.c +++ b/src/vol/clone.c @@ -21,11 +21,7 @@ #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #ifdef AFS_NT40_ENV #include #include @@ -91,7 +87,7 @@ ci_AddItem(struct clone_head *ah, Inode aino) ti = (struct clone_items *)malloc(sizeof(struct clone_items)); if (!ti) { Log("ci_AddItem: malloc failed\n"); - assert(0); + osi_Panic("ci_AddItem: malloc failed\n"); } ti->nitems = 0; ti->next = (struct clone_items *)0; diff --git a/src/vol/daemon_com.c b/src/vol/daemon_com.c index a530c2133..c532b8623 100644 --- a/src/vol/daemon_com.c +++ b/src/vol/daemon_com.c @@ -36,7 +36,7 @@ #include #endif #include -#include +#include #include #include @@ -131,7 +131,7 @@ osi_socket SYNC_getSock(SYNC_endpoint_t * endpoint) { osi_socket sd; - assert((sd = socket(endpoint->domain, SOCK_STREAM, 0)) >= 0); + osi_Assert((sd = socket(endpoint->domain, SOCK_STREAM, 0)) >= 0); return sd; } diff --git a/src/vol/fssync-client.c b/src/vol/fssync-client.c index 10c05a0f6..8a7f35d3a 100644 --- a/src/vol/fssync-client.c +++ b/src/vol/fssync-client.c @@ -49,11 +49,7 @@ #include #endif #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include @@ -88,10 +84,8 @@ static SYNC_client_state fssync_state = #ifdef AFS_PTHREAD_ENV static pthread_mutex_t vol_fsync_mutex; static volatile int vol_fsync_mutex_init = 0; -#define VFSYNC_LOCK \ - assert(pthread_mutex_lock(&vol_fsync_mutex) == 0) -#define VFSYNC_UNLOCK \ - assert(pthread_mutex_unlock(&vol_fsync_mutex) == 0) +#define VFSYNC_LOCK MUTEX_ENTER(&vol_fsync_mutex) +#define VFSYNC_UNLOCK MUTEX_EXIT(&vol_fsync_mutex) #else #define VFSYNC_LOCK #define VFSYNC_UNLOCK @@ -103,7 +97,7 @@ FSYNC_clientInit(void) #ifdef AFS_PTHREAD_ENV /* this is safe since it gets called with VOL_LOCK held, or before we go multithreaded */ if (!vol_fsync_mutex_init) { - assert(pthread_mutex_init(&vol_fsync_mutex, NULL) == 0); + MUTEX_INIT(&vol_fsync_mutex, "vol fsync", MUTEX_DEFAULT, 0); vol_fsync_mutex_init = 1; } #endif diff --git a/src/vol/fssync-debug.c b/src/vol/fssync-debug.c index ea2aa441f..15e08a973 100644 --- a/src/vol/fssync-debug.c +++ b/src/vol/fssync-debug.c @@ -311,7 +311,7 @@ common_volop_prolog(struct cmd_syndesc * as, struct state * state) struct cmd_item *ti; state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state)); - assert(state->vop != NULL); + osi_Assert(state->vop != NULL); if ((ti = as->parms[COMMON_VOLOP_PARMS_OFFSET].items)) { /* -volumeid */ state->vop->volume = atoi(ti->data); @@ -903,7 +903,7 @@ vn_prolog(struct cmd_syndesc * as, struct state * state) struct cmd_item *ti; state->vop = (struct volop_state *) calloc(1, sizeof(struct volop_state)); - assert(state->vop != NULL); + osi_Assert(state->vop != NULL); if ((ti = as->parms[CUSTOM_PARMS_OFFSET].items)) { /* -volumeid */ state->vop->volume = atoi(ti->data); diff --git a/src/vol/fssync-server.c b/src/vol/fssync-server.c index 3c6eb09a0..5db43fa33 100644 --- a/src/vol/fssync-server.c +++ b/src/vol/fssync-server.c @@ -61,11 +61,7 @@ #include #endif #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include @@ -222,19 +218,19 @@ FSYNC_fsInit(void) Lock_Init(&FSYNC_handler_lock); #ifdef AFS_PTHREAD_ENV - assert(pthread_attr_init(&tattr) == 0); - assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&tid, &tattr, FSYNC_sync, NULL) == 0); + osi_Assert(pthread_attr_init(&tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_create(&tid, &tattr, FSYNC_sync, NULL) == 0); #else /* AFS_PTHREAD_ENV */ - assert(LWP_CreateProcess + osi_Assert(LWP_CreateProcess (FSYNC_sync, USUAL_STACK_SIZE, USUAL_PRIORITY, (void *)0, "FSYNC_sync", &pid) == LWP_SUCCESS); #endif /* AFS_PTHREAD_ENV */ #ifdef AFS_DEMAND_ATTACH_FS queue_Init(&fsync_salv.head); - assert(pthread_cond_init(&fsync_salv.cv, NULL) == 0); - assert(pthread_create(&tid, &tattr, FSYNC_salvageThread, NULL) == 0); + CV_INIT(&fsync_salv.cv, "fsync salv", CV_DEFAULT, 0); + osi_Assert(pthread_create(&tid, &tattr, FSYNC_salvageThread, NULL) == 0); #endif /* AFS_DEMAND_ATTACH_FS */ } @@ -295,7 +291,7 @@ FSYNC_sync(void * args) } state->fd = SYNC_getSock(&state->endpoint); code = SYNC_bindSock(state); - assert(!code); + osi_Assert(!code); #ifdef AFS_DEMAND_ATTACH_FS /* @@ -310,10 +306,10 @@ FSYNC_sync(void * args) } memcpy(thread_opts, &VThread_defaults, sizeof(VThread_defaults)); thread_opts->disallow_salvsync = 1; - assert(pthread_setspecific(VThread_key, thread_opts) == 0); + osi_Assert(pthread_setspecific(VThread_key, thread_opts) == 0); code = VVGCache_PkgInit(); - assert(code == 0); + osi_Assert(code == 0); #endif InitHandler(); @@ -423,7 +419,7 @@ FSYNC_backgroundSalvage(Volume *vp) } queue_Append(&fsync_salv.head, node); - assert(pthread_cond_broadcast(&fsync_salv.cv) == 0); + CV_BROADCAST(&fsync_salv.cv); } #endif /* AFS_DEMAND_ATTACH_FS */ @@ -441,10 +437,10 @@ FSYNC_newconnection(osi_socket afd) fd = accept(afd, (struct sockaddr *)&other, &junk); if (fd == -1) { Log("FSYNC_newconnection: accept failed, errno==%d\n", errno); - assert(1 == 2); + osi_Assert(1 == 2); } else if (!AddHandler(fd, FSYNC_com)) { AcceptOff(); - assert(AddHandler(fd, FSYNC_com)); + osi_Assert(AddHandler(fd, FSYNC_com)); } } @@ -1047,7 +1043,7 @@ FSYNC_com_VolOff(FSSYNC_VolOp_command * vcom, SYNC_response * res) #ifdef AFS_DEMAND_ATTACH_FS VOfflineForVolOp_r(&error, vp, "A volume utility is running."); if (error==0) { - assert(vp->nUsers==0); + osi_Assert(vp->nUsers==0); vp->pending_vol_op->vol_op_state = FSSYNC_VolOpRunningOffline; } else { @@ -1499,7 +1495,7 @@ FSYNC_com_VolOpQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res) vp = VLookupVolume_r(&error, vcom->vop->volume, NULL); if (vp && vp->pending_vol_op) { - assert(sizeof(FSSYNC_VolOp_info) <= res->payload.len); + osi_Assert(sizeof(FSSYNC_VolOp_info) <= res->payload.len); memcpy(res->payload.buf, vp->pending_vol_op, sizeof(FSSYNC_VolOp_info)); res->hdr.response_len += sizeof(FSSYNC_VolOp_info); } else { @@ -1531,7 +1527,7 @@ FSYNC_com_VGQuery(FSSYNC_VolOp_command * vcom, SYNC_response * res) goto done; } - assert(sizeof(FSSYNC_VGQry_response_t) <= res->payload.len); + osi_Assert(sizeof(FSSYNC_VGQry_response_t) <= res->payload.len); rc = VVGCache_query_r(dp, vcom->vop->volume, res->payload.buf); switch (rc) { @@ -1943,7 +1939,7 @@ static void AcceptOn(void) { if (AcceptHandler == -1) { - assert(AddHandler(fssync_server_state.fd, FSYNC_newconnection)); + osi_Assert(AddHandler(fssync_server_state.fd, FSYNC_newconnection)); AcceptHandler = FindHandler(fssync_server_state.fd); } } @@ -1952,7 +1948,7 @@ static void AcceptOff(void) { if (AcceptHandler != -1) { - assert(RemoveHandler(fssync_server_state.fd)); + osi_Assert(RemoveHandler(fssync_server_state.fd)); AcceptHandler = -1; } } @@ -2037,7 +2033,7 @@ FindHandler(osi_socket afd) return i; } ReleaseReadLock(&FSYNC_handler_lock); /* just in case */ - assert(1 == 2); + osi_Assert(1 == 2); return -1; /* satisfy compiler */ } @@ -2049,7 +2045,7 @@ FindHandler_r(osi_socket afd) if (HandlerFD[i] == afd) { return i; } - assert(1 == 2); + osi_Assert(1 == 2); return -1; /* satisfy compiler */ } @@ -2071,7 +2067,7 @@ GetHandler(struct pollfd *fds, int maxfds, int events, int *nfds) ObtainReadLock(&FSYNC_handler_lock); for (i = 0; i < MAXHANDLERS; i++) if (HandlerFD[i] != -1) { - assert(fdi -#else /* AFS_PTHREAD_ENV */ #include "afs/afs_assert.h" -#endif /* AFS_PTHREAD_ENV */ #include #ifndef AFS_NT40_ENV @@ -125,7 +121,7 @@ void ih_PkgDefaults(void) void ih_glock_init(void) { - assert(pthread_mutex_init(&ih_glock_mutex, NULL) == 0); + MUTEX_INIT(&ih_glock_mutex, "ih glock", MUTEX_DEFAULT, 0); } #endif /* AFS_PTHREAD_ENV */ @@ -134,7 +130,7 @@ void ih_Initialize(void) { int i; - assert(!ih_Inited); + osi_Assert(!ih_Inited); ih_Inited = 1; DLL_INIT_LIST(ihAvailHead, ihAvailTail); DLL_INIT_LIST(fdAvailHead, fdAvailTail); @@ -147,9 +143,9 @@ ih_Initialize(void) #elif defined(AFS_SUN5_ENV) || defined(AFS_NBSD_ENV) { struct rlimit rlim; - assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0); + osi_Assert(getrlimit(RLIMIT_NOFILE, &rlim) == 0); rlim.rlim_cur = rlim.rlim_max; - assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); + osi_Assert(setrlimit(RLIMIT_NOFILE, &rlim) == 0); fdMaxCacheSize = rlim.rlim_cur - vol_io_params.fd_handle_setaside; #ifdef AFS_NBSD_ENV /* XXX this is to avoid using up all system fd netbsd is @@ -163,7 +159,7 @@ ih_Initialize(void) fdMaxCacheSize /= 4; #endif fdMaxCacheSize = MIN(fdMaxCacheSize, vol_io_params.fd_max_cachesize); - assert(fdMaxCacheSize > 0); + osi_Assert(fdMaxCacheSize > 0); } #elif defined(AFS_HPUX_ENV) /* Avoid problems with "UFSOpen: igetinode failed" panics on HPUX 11.0 */ @@ -225,9 +221,9 @@ iHandleAllocateChunk(void) int i; IHandle_t *ihP; - assert(ihAvailHead == NULL); + osi_Assert(ihAvailHead == NULL); ihP = (IHandle_t *) malloc(I_HANDLE_MALLOCSIZE * sizeof(IHandle_t)); - assert(ihP != NULL); + osi_Assert(ihP != NULL); for (i = 0; i < I_HANDLE_MALLOCSIZE; i++) { ihP[i].ih_refcnt = 0; DLL_INSERT_TAIL(&ihP[i], ihAvailHead, ihAvailTail, ih_next, ih_prev); @@ -264,7 +260,7 @@ ih_init(int dev, int vid, Inode ino) iHandleAllocateChunk(); } ihP = ihAvailHead; - assert(ihP->ih_refcnt == 0); + osi_Assert(ihP->ih_refcnt == 0); DLL_DELETE(ihP, ihAvailHead, ihAvailTail, ih_next, ih_prev); ihP->ih_dev = dev; ihP->ih_vid = vid; @@ -284,8 +280,8 @@ IHandle_t * ih_copy(IHandle_t * ihP) { IH_LOCK; - assert(ih_Inited); - assert(ihP->ih_refcnt > 0); + osi_Assert(ih_Inited); + osi_Assert(ihP->ih_refcnt > 0); ihP->ih_refcnt++; IH_UNLOCK; return ihP; @@ -298,9 +294,9 @@ fdHandleAllocateChunk(void) int i; FdHandle_t *fdP; - assert(fdAvailHead == NULL); + osi_Assert(fdAvailHead == NULL); fdP = (FdHandle_t *) malloc(FD_HANDLE_MALLOCSIZE * sizeof(FdHandle_t)); - assert(fdP != NULL); + osi_Assert(fdP != NULL); for (i = 0; i < FD_HANDLE_MALLOCSIZE; i++) { fdP[i].fd_status = FD_HANDLE_AVAIL; fdP[i].fd_ih = NULL; @@ -316,10 +312,10 @@ streamHandleAllocateChunk(void) int i; StreamHandle_t *streamP; - assert(streamAvailHead == NULL); + osi_Assert(streamAvailHead == NULL); streamP = (StreamHandle_t *) malloc(STREAM_HANDLE_MALLOCSIZE * sizeof(StreamHandle_t)); - assert(streamP != NULL); + osi_Assert(streamP != NULL); for (i = 0; i < STREAM_HANDLE_MALLOCSIZE; i++) { streamP[i].str_fd = INVALID_FD; DLL_INSERT_TAIL(&streamP[i], streamAvailHead, streamAvailTail, @@ -345,7 +341,6 @@ ih_open(IHandle_t * ihP) /* Do we already have an open file handle for this Inode? */ for (fdP = ihP->ih_fdtail; fdP != NULL; fdP = fdP->fd_ihprev) { if (fdP->fd_status != FD_HANDLE_INUSE) { - assert(fdP->fd_status == FD_HANDLE_OPEN); fdP->fd_status = FD_HANDLE_INUSE; DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev); ihP->ih_refcnt++; @@ -375,7 +370,7 @@ ih_open_retry: * of open files reaches the size of the cache */ if ((fdInUseCount > fdCacheSize || fd == INVALID_FD) && fdLruHead != NULL) { fdP = fdLruHead; - assert(fdP->fd_status == FD_HANDLE_OPEN); + osi_Assert(fdP->fd_status == FD_HANDLE_OPEN); DLL_DELETE(fdP, fdLruHead, fdLruTail, fd_next, fd_prev); DLL_DELETE(fdP, fdP->fd_ih->ih_fdhead, fdP->fd_ih->ih_fdtail, fd_ihnext, fd_ihprev); @@ -395,7 +390,7 @@ ih_open_retry: fdHandleAllocateChunk(); } fdP = fdAvailHead; - assert(fdP->fd_status == FD_HANDLE_AVAIL); + osi_Assert(fdP->fd_status == FD_HANDLE_AVAIL); DLL_DELETE(fdP, fdAvailHead, fdAvailTail, fd_next, fd_prev); closeFd = INVALID_FD; } @@ -433,9 +428,9 @@ fd_close(FdHandle_t * fdP) return 0; IH_LOCK; - assert(ih_Inited); - assert(fdInUseCount > 0); - assert(fdP->fd_status == FD_HANDLE_INUSE); + osi_Assert(ih_Inited); + osi_Assert(fdInUseCount > 0); + osi_Assert(fdP->fd_status == FD_HANDLE_INUSE); ihP = fdP->fd_ih; @@ -481,9 +476,9 @@ fd_reallyclose(FdHandle_t * fdP) return 0; IH_LOCK; - assert(ih_Inited); - assert(fdInUseCount > 0); - assert(fdP->fd_status == FD_HANDLE_INUSE); + osi_Assert(ih_Inited); + osi_Assert(fdInUseCount > 0); + osi_Assert(fdP->fd_status == FD_HANDLE_INUSE); ihP = fdP->fd_ih; closeFd = fdP->fd_fd; @@ -562,7 +557,7 @@ stream_open(const char *filename, const char *mode) } else if (strcmp(mode, "a+") == 0) { fd = OS_OPEN(filename, O_RDWR | O_APPEND | O_CREAT, 0); } else { - assert(FALSE); /* not implemented */ + osi_Assert(FALSE); /* not implemented */ } if (fd == INVALID_FD) { @@ -585,7 +580,7 @@ stream_read(void *ptr, afs_fsize_t size, afs_fsize_t nitems, streamP->str_bufoff = 0; streamP->str_buflen = 0; } else { - assert(streamP->str_direction == STREAM_DIRECTION_READ); + osi_Assert(streamP->str_direction == STREAM_DIRECTION_READ); } bytesRead = 0; @@ -638,7 +633,7 @@ stream_write(void *ptr, afs_fsize_t size, afs_fsize_t nitems, streamP->str_bufoff = 0; streamP->str_buflen = STREAM_HANDLE_BUFSIZE; } else { - assert(streamP->str_direction == STREAM_DIRECTION_WRITE); + osi_Assert(streamP->str_direction == STREAM_DIRECTION_WRITE); } nbytes = size * nitems; @@ -728,7 +723,7 @@ stream_close(StreamHandle_t * streamP, int reallyClose) ssize_t rc; int retval = 0; - assert(streamP != NULL); + osi_Assert(streamP != NULL); if (streamP->str_direction == STREAM_DIRECTION_WRITE && streamP->str_bufoff > 0) { rc = OS_WRITE(streamP->str_fd, streamP->str_buffer, @@ -763,7 +758,7 @@ ih_fdclose(IHandle_t * ihP) int closeCount, closedAll; FdHandle_t *fdP, *head, *tail, *next; - assert(ihP->ih_refcnt > 0); + osi_Assert(ihP->ih_refcnt > 0); closedAll = 1; DLL_INIT_LIST(head, tail); @@ -776,8 +771,8 @@ ih_fdclose(IHandle_t * ihP) */ for (fdP = ihP->ih_fdhead; fdP != NULL; fdP = next) { next = fdP->fd_ihnext; - assert(fdP->fd_ih == ihP); - assert(fdP->fd_status == FD_HANDLE_OPEN + osi_Assert(fdP->fd_ih == ihP); + osi_Assert(fdP->fd_status == FD_HANDLE_OPEN || fdP->fd_status == FD_HANDLE_INUSE); if (fdP->fd_status == FD_HANDLE_OPEN) { DLL_DELETE(fdP, ihP->ih_fdhead, ihP->ih_fdtail, fd_ihnext, @@ -794,9 +789,9 @@ ih_fdclose(IHandle_t * ihP) * closed all file descriptors. */ if (ihP->ih_refcnt == 1 || closedAll) { - assert(closedAll); - assert(!ihP->ih_fdhead); - assert(!ihP->ih_fdtail); + osi_Assert(closedAll); + osi_Assert(!ihP->ih_fdhead); + osi_Assert(!ihP->ih_fdtail); } if (head == NULL) { @@ -817,7 +812,7 @@ ih_fdclose(IHandle_t * ihP) } IH_LOCK; - assert(fdInUseCount >= closeCount); + osi_Assert(fdInUseCount >= closeCount); fdInUseCount -= closeCount; /* @@ -857,7 +852,7 @@ ih_reallyclose(IHandle_t * ihP) IH_LOCK; } - assert(ihP->ih_refcnt > 0); + osi_Assert(ihP->ih_refcnt > 0); ihP->ih_synced = 0; ih_fdclose(ihP); @@ -884,7 +879,7 @@ ih_release(IHandle_t * ihP) return 0; IH_LOCK; - assert(ihP->ih_refcnt > 0); + osi_Assert(ihP->ih_refcnt > 0); if (ihP->ih_refcnt > 1) { ihP->ih_refcnt--; diff --git a/src/vol/ihandle.h b/src/vol/ihandle.h index 0786e9f10..d3b98e1e4 100644 --- a/src/vol/ihandle.h +++ b/src/vol/ihandle.h @@ -69,16 +69,15 @@ #define _IHANDLE_H_ #ifdef AFS_PTHREAD_ENV -#include #include extern pthread_once_t ih_glock_once; extern pthread_mutex_t ih_glock_mutex; extern void ih_glock_init(void); #define IH_LOCK \ - assert(pthread_once(&ih_glock_once, ih_glock_init) == 0 && \ - pthread_mutex_lock(&ih_glock_mutex) == 0) -#define IH_UNLOCK \ - assert(pthread_mutex_unlock(&ih_glock_mutex) == 0) + do { osi_Assert(pthread_once(&ih_glock_once, ih_glock_init) == 0); \ + MUTEX_ENTER(&ih_glock_mutex); \ + } while (0) +#define IH_UNLOCK MUTEX_EXIT(&ih_glock_mutex) #else /* AFS_PTHREAD_ENV */ #define IH_LOCK #define IH_UNLOCK @@ -108,7 +107,7 @@ extern void ih_glock_init(void); else \ (head) = (ptr)->next; \ (ptr)->next = (ptr)->prev = NULL; \ - assert(!(head) || !((head)->prev)); \ + osi_Assert(!(head) || !((head)->prev)); \ } while(0) /* @@ -123,7 +122,7 @@ extern void ih_glock_init(void); (ptr)->prev->next = (ptr); \ else \ (head) = (ptr); \ - assert((head) && ((head)->prev == NULL)); \ + osi_Assert((head) && ((head)->prev == NULL)); \ } while(0) #endif /* DLL_INIT_LIST */ diff --git a/src/vol/listinodes.c b/src/vol/listinodes.c index 9773f2eba..44ab446b2 100644 --- a/src/vol/listinodes.c +++ b/src/vol/listinodes.c @@ -99,11 +99,7 @@ ListViceInodes(char *devname, char *mountedOn, FILE *inodeFile, #if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV) #include #endif -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #if defined(AFS_HPUX101_ENV) #include #endif @@ -299,7 +295,7 @@ ListViceInodes(char *devname, char *mountedOn, FILE *inodeFile, * LAST_RSVD_I is a vice inode, with dead beef, and * di_nlink == 2 to indicate the FORCE. */ - assert(p = ginode(LAST_RSVD_I)); + osi_Assert(p = ginode(LAST_RSVD_I)); if (p->di_vicemagic == VICEMAGIC && p->di_vicep1 == 0xdeadbeef && p->di_nlink == 2) { @@ -1170,7 +1166,7 @@ ListViceInodes(char *devname, char *mountedOn, FILE *inodeFile, goto out; } #else - assert(0); /* define AFS_3DISPARES in param.h */ + osi_Panic("Tru64 needs AFS_3DISPARES\n"); #endif #endif #if defined(AFS_SUN56_ENV) diff --git a/src/vol/namei_ops.c b/src/vol/namei_ops.c index d31edeabf..520f2f068 100644 --- a/src/vol/namei_ops.c +++ b/src/vol/namei_ops.c @@ -966,7 +966,6 @@ namei_GetLCOffsetAndIndexFromIno(Inode ino, afs_foff_t * offset, int *index) *index = (tindex << 1) + tindex; } - /* namei_GetLinkCount * If lockit is set, lock the file and leave it locked upon a successful * return. @@ -1339,8 +1338,6 @@ namei_ListAFSFiles(char *dev, return ninodes; } - - /* namei_ListAFSSubDirs * * @@ -1862,7 +1859,7 @@ static zlcList_t *zlcCur = NULL; static void AddToZLCDeleteList(char dir, char *name) { - assert(strlen(name) <= MAX_ZLC_NAMELEN - 3); + osi_Assert(strlen(name) <= MAX_ZLC_NAMELEN - 3); if (!zlcCur || zlcCur->zlc_n >= MAX_ZLC_NAMES) { if (zlcCur && zlcCur->zlc_next) diff --git a/src/vol/ntops.c b/src/vol/ntops.c index 48b51f0e8..a9e69c984 100644 --- a/src/vol/ntops.c +++ b/src/vol/ntops.c @@ -1295,7 +1295,7 @@ static zlcList_t *zlcCur = NULL; static void AddToZLCDeleteList(char dir, char *name) { - assert(strlen(name) <= MAX_ZLC_NAMELEN - 3); + osi_Assert(strlen(name) <= MAX_ZLC_NAMELEN - 3); if (!zlcCur || zlcCur->zlc_n >= MAX_ZLC_NAMES) { if (zlcCur && zlcCur->zlc_next) diff --git a/src/vol/nuke.c b/src/vol/nuke.c index 151f0bd62..f1add7bcf 100644 --- a/src/vol/nuke.c +++ b/src/vol/nuke.c @@ -14,11 +14,7 @@ #include #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include #include diff --git a/src/vol/partition.c b/src/vol/partition.c index 3ec83b656..6f304bb4c 100644 --- a/src/vol/partition.c +++ b/src/vol/partition.c @@ -127,11 +127,7 @@ #include "vnode.h" #include "volume.h" #include "partition.h" -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #if defined(AFS_HPUX_ENV) #include @@ -284,7 +280,7 @@ VInitPartition_r(char *path, char *devname, Device dev) #ifdef AFS_DEMAND_ATTACH_FS AddPartitionToTable_r(dp); queue_Init(&dp->vol_list.head); - assert(pthread_cond_init(&dp->vol_list.cv, NULL) == 0); + CV_INIT(&dp->vol_list.cv, "vol list", CV_DEFAULT, 0); dp->vol_list.len = 0; dp->vol_list.busy = 0; { @@ -362,7 +358,7 @@ VCheckPartition(char *part, char *devname) struct dirent *dp; dirp = opendir(part); - assert(dirp); + osi_Assert(dirp); while ((dp = readdir(dirp))) { if (dp->d_name[0] == 'V') { Log("This program is compiled with AFS_NAMEI_ENV, but partition %s seems to contain volumes which don't use the namei-interface; aborting\n", part); @@ -924,7 +920,7 @@ VGetPartition_r(char *name, int abortp) } #endif /* AFS_DEMAND_ATTACH_FS */ if (abortp) - assert(dp != NULL); + osi_Assert(dp != NULL); return dp; } @@ -1172,12 +1168,12 @@ VLockPartition_r(char *name) (FD_t)CreateFile(path, GENERIC_WRITE, FILE_SHARE_READ | FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_HIDDEN, NULL); - assert(dp->lock_fd != INVALID_FD); + osi_Assert(dp->lock_fd != INVALID_FD); memset(&lap, 0, sizeof(lap)); rc = LockFileEx((HANDLE) dp->lock_fd, LOCKFILE_EXCLUSIVE_LOCK, 0, 1, 0, &lap); - assert(rc); + osi_Assert(rc); } } @@ -1262,11 +1258,11 @@ VLockPartition_r(char *name) pausing.tv_usec = 500000; select(0, NULL, NULL, NULL, &pausing); } - assert(retries != 0); + osi_Assert(retries != 0); #if defined (AFS_HPUX_ENV) - assert(getprivgrp(privGrpList) == 0); + osi_Assert(getprivgrp(privGrpList) == 0); /* * In general, it will difficult and time-consuming ,if not impossible, @@ -1287,26 +1283,26 @@ VLockPartition_r(char *name) if (((*globalMask) & privmask(PRIV_LOCKRDONLY)) == 0) { /* allow everybody to set a lock on a read-only file descriptor */ (*globalMask) |= privmask(PRIV_LOCKRDONLY); - assert(setprivgrp(PRIV_GLOBAL, privGrpList[globalMaskIndex].priv_mask) + osi_Assert(setprivgrp(PRIV_GLOBAL, privGrpList[globalMaskIndex].priv_mask) == 0); lockfRtn = lockf(dp->lock_fd, F_LOCK, 0); /* remove the privilege granted to everybody to lock a read-only fd */ (*globalMask) &= ~(privmask(PRIV_LOCKRDONLY)); - assert(setprivgrp(PRIV_GLOBAL, privGrpList[globalMaskIndex].priv_mask) + osi_Assert(setprivgrp(PRIV_GLOBAL, privGrpList[globalMaskIndex].priv_mask) == 0); } else { /* in this case, we should be able to do this with impunity, anyway */ lockfRtn = lockf(dp->lock_fd, F_LOCK, 0); } - assert(lockfRtn != -1); + osi_Assert(lockfRtn != -1); #else #if defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) - assert(lockf(dp->lock_fd, F_LOCK, 0) != -1); + osi_Assert(lockf(dp->lock_fd, F_LOCK, 0) != -1); #else - assert(flock(dp->lock_fd, LOCK_EX) == 0); + osi_Assert(flock(dp->lock_fd, LOCK_EX) == 0); #endif /* defined(AFS_AIX_ENV) || defined(AFS_SUN5_ENV) */ #endif } @@ -1413,7 +1409,7 @@ VGetPartitionById_r(afs_int32 id, int abortp) } if (abortp) { - assert(dp != NULL); + osi_Assert(dp != NULL); } return dp; } @@ -1457,7 +1453,7 @@ VLookupPartition_r(char * path) static void AddPartitionToTable_r(struct DiskPartition64 *dp) { - assert(dp->index >= 0 && dp->index <= VOLMAXPARTS); + osi_Assert(dp->index >= 0 && dp->index <= VOLMAXPARTS); DiskPartitionTable[dp->index] = dp; } @@ -1465,7 +1461,7 @@ AddPartitionToTable_r(struct DiskPartition64 *dp) static void DeletePartitionFromTable_r(struct DiskPartition64 *dp) { - assert(dp->index >= 0 && dp->index <= VOLMAXPARTS); + osi_Assert(dp->index >= 0 && dp->index <= VOLMAXPARTS); DiskPartitionTable[dp->index] = NULL; } #endif diff --git a/src/vol/physio.c b/src/vol/physio.c index 1ede75672..70f254b30 100644 --- a/src/vol/physio.c +++ b/src/vol/physio.c @@ -173,5 +173,5 @@ void Die(char *msg) { printf("%s\n", msg); - assert(1 == 2); + osi_Panic("%s\n", msg); } diff --git a/src/vol/salvaged.c b/src/vol/salvaged.c index 563222ff5..087325888 100644 --- a/src/vol/salvaged.c +++ b/src/vol/salvaged.c @@ -508,7 +508,7 @@ SalvageServer(int argc, char **argv) ObtainSharedSalvageLock(); child_slot = (int *) malloc(Parallel * sizeof(int)); - assert(child_slot != NULL); + osi_Assert(child_slot != NULL); memset(child_slot, 0, Parallel * sizeof(int)); /* initialize things */ @@ -520,22 +520,22 @@ SalvageServer(int argc, char **argv) DInit(10); queue_Init(&pending_q); queue_Init(&log_cleanup_queue); - assert(pthread_mutex_init(&worker_lock, NULL) == 0); - assert(pthread_cond_init(&worker_cv, NULL) == 0); - assert(pthread_cond_init(&log_cleanup_queue.queue_change_cv, NULL) == 0); - assert(pthread_attr_init(&attrs) == 0); + MUTEX_INIT(&worker_lock, "worker", MUTEX_DEFAULT, 0); + CV_INIT(&worker_cv, "worker", CV_DEFAULT, 0); + CV_INIT(&log_cleanup_queue.queue_change_cv, "queuechange", CV_DEFAULT, 0); + osi_Assert(pthread_attr_init(&attrs) == 0); /* start up the reaper and log cleaner threads */ - assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&tid, + osi_Assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_create(&tid, &attrs, &SalvageChildReaperThread, NULL) == 0); - assert(pthread_create(&tid, + osi_Assert(pthread_create(&tid, &attrs, &SalvageLogCleanupThread, NULL) == 0); - assert(pthread_create(&tid, + osi_Assert(pthread_create(&tid, &attrs, &SalvageLogScanningThread, NULL) == 0); @@ -543,7 +543,7 @@ SalvageServer(int argc, char **argv) /* loop forever serving requests */ while (1) { node = SALVSYNC_getWork(); - assert(node != NULL); + osi_Assert(node != NULL); Log("dispatching child to salvage volume %u...\n", node->command.sop.parent); @@ -554,7 +554,7 @@ SalvageServer(int argc, char **argv) if (!child_slot[slot]) break; } - assert (slot < Parallel); + osi_Assert (slot < Parallel); do_fork: pid = Fork(); @@ -571,17 +571,17 @@ SalvageServer(int argc, char **argv) node->pid = pid; VOL_UNLOCK; - assert(pthread_mutex_lock(&worker_lock) == 0); + MUTEX_ENTER(&worker_lock); current_workers++; /* let the reaper thread know another worker was spawned */ - assert(pthread_cond_broadcast(&worker_cv) == 0); + CV_BROADCAST(&worker_cv); /* if we're overquota, wait for the reaper */ while (current_workers >= Parallel) { - assert(pthread_cond_wait(&worker_cv, &worker_lock) == 0); + CV_WAIT(&worker_cv, &worker_lock); } - assert(pthread_mutex_unlock(&worker_lock) == 0); + MUTEX_EXIT(&worker_lock); } } } @@ -639,17 +639,17 @@ SalvageChildReaperThread(void * args) int slot, pid, status; struct log_cleanup_node * cleanup; - assert(pthread_mutex_lock(&worker_lock) == 0); + MUTEX_ENTER(&worker_lock); /* loop reaping our children */ while (1) { /* wait() won't block unless we have children, so * block on the cond var if we're childless */ while (current_workers == 0) { - assert(pthread_cond_wait(&worker_cv, &worker_lock) == 0); + CV_WAIT(&worker_cv, &worker_lock); } - assert(pthread_mutex_unlock(&worker_lock) == 0); + MUTEX_EXIT(&worker_lock); cleanup = (struct log_cleanup_node *) malloc(sizeof(struct log_cleanup_node)); @@ -663,23 +663,23 @@ SalvageChildReaperThread(void * args) if (child_slot[slot] == pid) break; } - assert(slot < Parallel); + osi_Assert(slot < Parallel); child_slot[slot] = 0; VOL_UNLOCK; SALVSYNC_doneWorkByPid(pid, status); - assert(pthread_mutex_lock(&worker_lock) == 0); + MUTEX_ENTER(&worker_lock); if (cleanup) { cleanup->pid = pid; queue_Append(&log_cleanup_queue, cleanup); - assert(pthread_cond_signal(&log_cleanup_queue.queue_change_cv) == 0); + CV_SIGNAL(&log_cleanup_queue.queue_change_cv); } /* ok, we've reaped a child */ current_workers--; - assert(pthread_cond_broadcast(&worker_cv) == 0); + CV_BROADCAST(&worker_cv); } return NULL; @@ -714,24 +714,24 @@ SalvageLogCleanupThread(void * arg) { struct log_cleanup_node * cleanup; - assert(pthread_mutex_lock(&worker_lock) == 0); + MUTEX_ENTER(&worker_lock); while (1) { while (queue_IsEmpty(&log_cleanup_queue)) { - assert(pthread_cond_wait(&log_cleanup_queue.queue_change_cv, &worker_lock) == 0); + CV_WAIT(&log_cleanup_queue.queue_change_cv, &worker_lock); } while (queue_IsNotEmpty(&log_cleanup_queue)) { cleanup = queue_First(&log_cleanup_queue, log_cleanup_node); queue_Remove(cleanup); - assert(pthread_mutex_unlock(&worker_lock) == 0); + MUTEX_EXIT(&worker_lock); SalvageLogCleanup(cleanup->pid); free(cleanup); - assert(pthread_mutex_lock(&worker_lock) == 0); + MUTEX_ENTER(&worker_lock); } } - assert(pthread_mutex_unlock(&worker_lock) == 0); + MUTEX_EXIT(&worker_lock); return NULL; } @@ -793,7 +793,7 @@ SalvageLogScanningThread(void * arg) prefix_len = strlen(prefix); dp = opendir(AFSDIR_LOGS_DIR); - assert(dp); + osi_Assert(dp); while ((dirp = readdir(dp)) != NULL) { pid_t pid; @@ -859,7 +859,7 @@ ScanLogs(struct rx_queue *log_watch_queue) { struct log_cleanup_node *cleanup, *next; - assert(pthread_mutex_lock(&worker_lock) == 0); + MUTEX_ENTER(&worker_lock); for (queue_Scan(log_watch_queue, cleanup, next, log_cleanup_node)) { /* if a process is still running, assume it's the salvage process @@ -867,9 +867,9 @@ ScanLogs(struct rx_queue *log_watch_queue) if (kill(cleanup->pid, 0) < 0 && errno == ESRCH) { queue_Remove(cleanup); queue_Append(&log_cleanup_queue, cleanup); - assert(pthread_cond_signal(&log_cleanup_queue.queue_change_cv) == 0); + CV_SIGNAL(&log_cleanup_queue.queue_change_cv); } } - assert(pthread_mutex_unlock(&worker_lock) == 0); + MUTEX_EXIT(&worker_lock); } diff --git a/src/vol/salvsync-client.c b/src/vol/salvsync-client.c index 814cbcaf6..84d65ed43 100644 --- a/src/vol/salvsync-client.c +++ b/src/vol/salvsync-client.c @@ -31,7 +31,6 @@ #include #endif #include -#include #include #include diff --git a/src/vol/salvsync-server.c b/src/vol/salvsync-server.c index db5848a02..348eba4d2 100644 --- a/src/vol/salvsync-server.c +++ b/src/vol/salvsync-server.c @@ -40,7 +40,7 @@ #include #endif #include -#include +#include #include #include @@ -274,27 +274,27 @@ SALVSYNC_salvInit(void) /* initialize the queues */ Lock_Init(&SALVSYNC_handler_lock); - assert(pthread_cond_init(&salvageQueue.cv, NULL) == 0); + CV_INIT(&salvageQueue.cv, "sq", CV_DEFAULT, 0); for (i = 0; i <= VOLMAXPARTS; i++) { queue_Init(&salvageQueue.part[i]); salvageQueue.len[i] = 0; } - assert(pthread_cond_init(&pendingQueue.queue_change_cv, NULL) == 0); + CV_INIT(&pendingQueue.queue_change_cv, "queuechange", CV_DEFAULT, 0); queue_Init(&pendingQueue); salvageQueue.total_len = pendingQueue.len = 0; salvageQueue.last_insert = -1; memset(partition_salvaging, 0, sizeof(partition_salvaging)); for (i = 0; i < VSHASH_SIZE; i++) { - assert(pthread_cond_init(&SalvageHashTable[i].queue_change_cv, NULL) == 0); + CV_INIT(&SalvageHashTable[i].queue_change_cv, "queuechange", CV_DEFAULT, 0); SalvageHashTable[i].len = 0; queue_Init(&SalvageHashTable[i]); } /* start the salvsync thread */ - assert(pthread_attr_init(&tattr) == 0); - assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&tid, &tattr, SALVSYNC_syncThread, NULL) == 0); + osi_Assert(pthread_attr_init(&tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_create(&tid, &tattr, SALVSYNC_syncThread, NULL) == 0); } static void @@ -324,7 +324,7 @@ SALVSYNC_syncThread(void * args) /* when we fork, the child needs to close the salvsync server sockets, * otherwise, it may get salvsync requests, instead of the parent * salvageserver */ - assert(pthread_atfork(NULL, NULL, CleanFDs) == 0); + osi_Assert(pthread_atfork(NULL, NULL, CleanFDs) == 0); SYNC_getAddr(&state->endpoint, &state->addr); SYNC_cleanupSock(state); @@ -335,7 +335,7 @@ SALVSYNC_syncThread(void * args) state->fd = SYNC_getSock(&state->endpoint); code = SYNC_bindSock(state); - assert(!code); + osi_Assert(!code); InitHandler(); AcceptOn(); @@ -367,11 +367,10 @@ SALVSYNC_newconnection(int afd) junk = sizeof(other); fd = accept(afd, (struct sockaddr *)&other, &junk); if (fd == -1) { - Log("SALVSYNC_newconnection: accept failed, errno==%d\n", errno); - assert(1 == 2); + osi_Panic("SALVSYNC_newconnection: accept failed, errno==%d\n", errno); } else if (!AddHandler(fd, SALVSYNC_com)) { AcceptOff(); - assert(AddHandler(fd, SALVSYNC_com)); + osi_Assert(AddHandler(fd, SALVSYNC_com)); } } @@ -777,7 +776,7 @@ static void AcceptOn(void) { if (AcceptHandler == -1) { - assert(AddHandler(salvsync_server_state.fd, SALVSYNC_newconnection)); + osi_Assert(AddHandler(salvsync_server_state.fd, SALVSYNC_newconnection)); AcceptHandler = FindHandler(salvsync_server_state.fd); } } @@ -786,7 +785,7 @@ static void AcceptOff(void) { if (AcceptHandler != -1) { - assert(RemoveHandler(salvsync_server_state.fd)); + osi_Assert(RemoveHandler(salvsync_server_state.fd)); AcceptHandler = -1; } } @@ -849,7 +848,7 @@ FindHandler(osi_socket afd) return i; } ReleaseReadLock(&SALVSYNC_handler_lock); /* just in case */ - assert(1 == 2); + osi_Panic("Failed to find handler\n"); return -1; /* satisfy compiler */ } @@ -861,7 +860,7 @@ FindHandler_r(osi_socket afd) if (HandlerFD[i] == afd) { return i; } - assert(1 == 2); + osi_Panic("Failed to find handler\n"); return -1; /* satisfy compiler */ } @@ -1066,7 +1065,7 @@ AddToSalvageQueue(struct SalvageQueueNode * node) UpdateCommandPrio(node); } - assert(pthread_cond_broadcast(&salvageQueue.cv) == 0); + CV_BROADCAST(&salvageQueue.cv); return 0; } @@ -1078,7 +1077,7 @@ DeleteFromSalvageQueue(struct SalvageQueueNode * node) salvageQueue.len[node->partition_id]--; salvageQueue.total_len--; node->state = SALVSYNC_STATE_UNKNOWN; - assert(pthread_cond_broadcast(&salvageQueue.cv) == 0); + CV_BROADCAST(&salvageQueue.cv); } } @@ -1088,7 +1087,7 @@ AddToPendingQueue(struct SalvageQueueNode * node) queue_Append(&pendingQueue, node); pendingQueue.len++; node->state = SALVSYNC_STATE_SALVAGING; - assert(pthread_cond_broadcast(&pendingQueue.queue_change_cv) == 0); + CV_BROADCAST(&pendingQueue.queue_change_cv); } static void @@ -1098,7 +1097,7 @@ DeleteFromPendingQueue(struct SalvageQueueNode * node) queue_Remove(node); pendingQueue.len--; node->state = SALVSYNC_STATE_UNKNOWN; - assert(pthread_cond_broadcast(&pendingQueue.queue_change_cv) == 0); + CV_BROADCAST(&pendingQueue.queue_change_cv); } } @@ -1145,7 +1144,7 @@ UpdateCommandPrio(struct SalvageQueueNode * node) afs_int32 id; afs_uint32 prio; - assert(queue_IsOnQueue(node)); + osi_Assert(queue_IsOnQueue(node)); prio = node->command.sop.prio; id = node->partition_id; @@ -1234,10 +1233,10 @@ SALVSYNC_getWork(void) } /* we should never reach this line */ - assert(1==2); + osi_Panic("Node not found\n"); have_node: - assert(node != NULL); + osi_Assert(node != NULL); node->pid = 0; partition_salvaging[node->partition_id]++; DeleteFromSalvageQueue(node); diff --git a/src/vol/vg_cache.c b/src/vol/vg_cache.c index ce6376da5..17d3fa352 100644 --- a/src/vol/vg_cache.c +++ b/src/vol/vg_cache.c @@ -110,7 +110,7 @@ VVGCache_PkgInit(void) for (i = 0; i <= VOLMAXPARTS; i++) { VVGCache.part[i].state = VVGC_PART_STATE_INVALID; VVGCache.part[i].dlist_hash_buckets = NULL; - code = pthread_cond_init(&VVGCache.part[i].cv, NULL); + CV_INIT(&VVGCache.part[i].cv, "cache part", CV_DEFAULT, 0); if (code) { goto error; } @@ -142,7 +142,7 @@ VVGCache_PkgShutdown(void) /* destroy per-partition VVGC state */ for (i = 0; i <= VOLMAXPARTS; i++) { VVGCache.part[i].state = VVGC_PART_STATE_INVALID; - pthread_cond_destroy(&VVGCache.part[i].cv); + CV_DESTROY(&VVGCache.part[i].cv); } return EOPNOTSUPP; @@ -191,7 +191,7 @@ _VVGC_entry_free(VVGCache_entry_t * entry) { int code = 0; - assert(entry->refcnt == 0); + osi_Assert(entry->refcnt == 0); free(entry); return code; @@ -380,7 +380,7 @@ _VVGC_entry_put(struct DiskPartition64 * dp, VVGCache_entry_t * entry) { int code = 0; - assert(entry->refcnt > 0); + osi_Assert(entry->refcnt > 0); if (--entry->refcnt == 0) { VVGCache_entry_t *nentry; @@ -772,7 +772,7 @@ VVGCache_entry_add_r(struct DiskPartition64 * dp, } } - assert(!child_ent); + osi_Assert(!child_ent); child_ent = parent_ent; code = _VVGC_hash_entry_add(dp, child, @@ -1185,7 +1185,7 @@ _VVGC_state_change(struct DiskPartition64 * part, VVGCache.part[part->index].state = state; if (old_state != state) { - pthread_cond_broadcast(&VVGCache.part[part->index].cv); + CV_BROADCAST(&VVGCache.part[part->index].cv); } return old_state; diff --git a/src/vol/vg_scan.c b/src/vol/vg_scan.c index df8759121..752187822 100644 --- a/src/vol/vg_scan.c +++ b/src/vol/vg_scan.c @@ -431,7 +431,7 @@ _VVGC_scan_start(struct DiskPartition64 * dp) ViceLog(0, ("_VVGC_scan_start: pthread_create failed with %d\n", code)); old_state = _VVGC_state_change(dp, VVGC_PART_STATE_INVALID); - assert(old_state == VVGC_PART_STATE_UPDATING); + osi_Assert(old_state == VVGC_PART_STATE_UPDATING); } error: diff --git a/src/vol/vnode.c b/src/vol/vnode.c index 5f0db2abe..57be1fe4c 100644 --- a/src/vol/vnode.c +++ b/src/vol/vnode.c @@ -24,11 +24,7 @@ #include #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include "rx/rx_queue.h" @@ -381,7 +377,7 @@ VInitVnodes(VnodeClass class, int nVnodes) vcp->cacheSize = nVnodes; switch (class) { case vSmall: - assert(CHECKSIZE_SMALLVNODE); + osi_Assert(CHECKSIZE_SMALLVNODE); vcp->lruHead = NULL; vcp->residentSize = SIZEOF_SMALLVNODE; vcp->diskSize = SIZEOF_SMALLDISKVNODE; @@ -406,13 +402,13 @@ VInitVnodes(VnodeClass class, int nVnodes) return 0; va = (byte *) calloc(nVnodes, vcp->residentSize); - assert(va != NULL); + osi_Assert(va != NULL); while (nVnodes--) { Vnode *vnp = (Vnode *) va; Vn_refcount(vnp) = 0; /* no context switches */ Vn_stateFlags(vnp) |= VN_ON_LRU; #ifdef AFS_DEMAND_ATTACH_FS - assert(pthread_cond_init(&Vn_stateCV(vnp), NULL) == 0); + CV_INIT(&Vn_stateCV(vnp), "vnode state", CV_DEFAULT, 0); Vn_state(vnp) = VN_STATE_INVALID; Vn_readers(vnp) = 0; #else /* !AFS_DEMAND_ATTACH_FS */ @@ -1080,7 +1076,7 @@ VnStore(Error * ec, Volume * vp, Vnode * vnp, VnChangeState_r(vnp, VN_STATE_ERROR); VRequestSalvage_r(ec, vp, SALVSYNC_ERROR, 0); #else - assert(1 == 2); + osi_Assert(1 == 2); #endif } @@ -1328,10 +1324,10 @@ VPutVnode_r(Error * ec, Vnode * vnp) struct VnodeClassInfo *vcp; *ec = 0; - assert(Vn_refcount(vnp) != 0); + osi_Assert(Vn_refcount(vnp) != 0); class = vnodeIdToClass(Vn_id(vnp)); vcp = &VnodeClassInfo[class]; - assert(vnp->disk.vnodeMagic == vcp->magic); + osi_Assert(vnp->disk.vnodeMagic == vcp->magic); VNLog(200, 2, Vn_id(vnp), (intptr_t) vnp, 0, 0); #ifdef AFS_DEMAND_ATTACH_FS @@ -1360,7 +1356,7 @@ VPutVnode_r(Error * ec, Vnode * vnp) if (vnp->changed_oldTime || vnp->changed_newTime || vnp->delete) { Volume *vp = Vn_volume(vnp); afs_uint32 now = FT_ApproxTime(); - assert(Vn_cacheCheck(vnp) == vp->cacheCheck); + osi_Assert(Vn_cacheCheck(vnp) == vp->cacheCheck); if (vnp->delete) { /* No longer any directory entries for this vnode. Free the Vnode */ @@ -1382,7 +1378,7 @@ VPutVnode_r(Error * ec, Vnode * vnp) #ifdef AFS_DEMAND_ATTACH_FS VRequestSalvage_r(ec, vp, SALVSYNC_ERROR, 0); #else - assert(V_needsSalvaged(vp)); + osi_Assert(V_needsSalvaged(vp)); *ec = VSALVAGE; #endif } else { @@ -1469,10 +1465,10 @@ VVnodeWriteToRead_r(Error * ec, Vnode * vnp) #endif /* AFS_PTHREAD_ENV */ *ec = 0; - assert(Vn_refcount(vnp) != 0); + osi_Assert(Vn_refcount(vnp) != 0); class = vnodeIdToClass(Vn_id(vnp)); vcp = &VnodeClassInfo[class]; - assert(vnp->disk.vnodeMagic == vcp->magic); + osi_Assert(vnp->disk.vnodeMagic == vcp->magic); VNLog(300, 2, Vn_id(vnp), (intptr_t) vnp, 0, 0); #ifdef AFS_DEMAND_ATTACH_FS @@ -1506,7 +1502,7 @@ VVnodeWriteToRead_r(Error * ec, Vnode * vnp) if (vnp->changed_oldTime || vnp->changed_newTime) { Volume *vp = Vn_volume(vnp); afs_uint32 now = FT_ApproxTime(); - assert(Vn_cacheCheck(vnp) == vp->cacheCheck); + osi_Assert(Vn_cacheCheck(vnp) == vp->cacheCheck); if (vnp->changed_newTime) vnp->disk.serverModifyTime = now; if (vnp->changed_newTime) @@ -1517,7 +1513,7 @@ VVnodeWriteToRead_r(Error * ec, Vnode * vnp) #ifdef AFS_DEMAND_ATTACH_FS VRequestSalvage_r(ec, vp, SALVSYNC_ERROR, 0); #else - assert(V_needsSalvaged(vp)); + osi_Assert(V_needsSalvaged(vp)); *ec = VSALVAGE; #endif } else { @@ -1661,7 +1657,7 @@ VCloseVnodeFiles_r(Volume * vp) #endif /* AFS_DEMAND_ATTACH_FS */ /* XXX need better error handling here */ - assert(VInvalidateVnodesByVolume_r(vp, + osi_Assert(VInvalidateVnodesByVolume_r(vp, &ih_vec, &vec_len) == 0); @@ -1725,7 +1721,7 @@ VReleaseVnodeFiles_r(Volume * vp) #endif /* AFS_DEMAND_ATTACH_FS */ /* XXX need better error handling here */ - assert(VInvalidateVnodesByVolume_r(vp, + osi_Assert(VInvalidateVnodesByVolume_r(vp, &ih_vec, &vec_len) == 0); diff --git a/src/vol/vnode_inline.h b/src/vol/vnode_inline.h index 506922d60..f31c5ca29 100644 --- a/src/vol/vnode_inline.h +++ b/src/vol/vnode_inline.h @@ -168,7 +168,7 @@ VnChangeState_r(Vnode * vnp, VnState new_state) VnState old_state = Vn_state(vnp); Vn_state(vnp) = new_state; - assert(pthread_cond_broadcast(&Vn_stateCV(vnp)) == 0); + CV_BROADCAST(&Vn_stateCV(vnp)); return old_state; } @@ -259,11 +259,11 @@ VnWaitStateChange_r(Vnode * vnp) { VnState state_save = Vn_state(vnp); - assert(Vn_refcount(vnp)); + osi_Assert(Vn_refcount(vnp)); do { VOL_CV_WAIT(&Vn_stateCV(vnp)); } while (Vn_state(vnp) == state_save); - assert(!(Vn_stateFlags(vnp) & VN_ON_LRU)); + osi_Assert(!(Vn_stateFlags(vnp) & VN_ON_LRU)); } /** @@ -280,11 +280,11 @@ VnWaitStateChange_r(Vnode * vnp) static_inline void VnWaitExclusiveState_r(Vnode * vnp) { - assert(Vn_refcount(vnp)); + osi_Assert(Vn_refcount(vnp)); while (VnIsExclusiveState(Vn_state(vnp))) { VOL_CV_WAIT(&Vn_stateCV(vnp)); } - assert(!(Vn_stateFlags(vnp) & VN_ON_LRU)); + osi_Assert(!(Vn_stateFlags(vnp) & VN_ON_LRU)); } /** @@ -301,12 +301,12 @@ VnWaitExclusiveState_r(Vnode * vnp) static_inline void VnWaitQuiescent_r(Vnode * vnp) { - assert(Vn_refcount(vnp)); + osi_Assert(Vn_refcount(vnp)); while (VnIsExclusiveState(Vn_state(vnp)) || Vn_readers(vnp)) { VOL_CV_WAIT(&Vn_stateCV(vnp)); } - assert(!(Vn_stateFlags(vnp) & VN_ON_LRU)); + osi_Assert(!(Vn_stateFlags(vnp) & VN_ON_LRU)); } /** @@ -329,11 +329,11 @@ static_inline void VnBeginRead_r(Vnode * vnp) { if (!Vn_readers(vnp)) { - assert(Vn_state(vnp) == VN_STATE_ONLINE); + osi_Assert(Vn_state(vnp) == VN_STATE_ONLINE); VnChangeState_r(vnp, VN_STATE_READ); } Vn_readers(vnp)++; - assert(Vn_state(vnp) == VN_STATE_READ); + osi_Assert(Vn_state(vnp) == VN_STATE_READ); } /** @@ -356,10 +356,10 @@ VnBeginRead_r(Vnode * vnp) static_inline void VnEndRead_r(Vnode * vnp) { - assert(Vn_readers(vnp) > 0); + osi_Assert(Vn_readers(vnp) > 0); Vn_readers(vnp)--; if (!Vn_readers(vnp)) { - assert(pthread_cond_broadcast(&Vn_stateCV(vnp)) == 0); + CV_BROADCAST(&Vn_stateCV(vnp)); VnChangeState_r(vnp, VN_STATE_ONLINE); } } diff --git a/src/vol/vol-salvage.c b/src/vol/vol-salvage.c index 76b3e668d..419087ad0 100644 --- a/src/vol/vol-salvage.c +++ b/src/vol/vol-salvage.c @@ -394,7 +394,7 @@ IsPartitionMounted(char *part) FILE *mntfp; struct mntent *mntent; - assert(mntfp = setmntent(MOUNTED, "r")); + osi_Assert(mntfp = setmntent(MOUNTED, "r")); while (mntent = getmntent(mntfp)) { if (!strcmp(part, mntent->mnt_dir)) break; @@ -573,12 +573,12 @@ SalvageFileSysParallel(struct DiskPartition64 *partP) * job to finish. When it's done, clean up after it. */ pid = wait(&wstatus); - assert(pid != -1); + osi_Assert(pid != -1); for (j = 0; j < numjobs; j++) { /* Find which job it is */ if (pid == jobs[j]->pid) break; } - assert(j < numjobs); + osi_Assert(j < numjobs); if (WCOREDUMP(wstatus)) { /* Say if the job core dumped */ Log("Salvage of %s core dumped!\n", jobs[j]->partP->name); } @@ -808,7 +808,7 @@ SalvageFileSys1(struct DiskPartition64 *partP, VolumeId singleVolumeNumber) DIR *dirp; struct dirent *dp; - assert((dirp = opendir(fileSysPath)) != NULL); + osi_Assert((dirp = opendir(fileSysPath)) != NULL); while ((dp = readdir(dirp))) { if (!strncmp(dp->d_name, "salvage.inodes.", 15) || !strncmp(dp->d_name, "salvage.temp.", 13)) { @@ -1242,16 +1242,16 @@ GetInodeSummary(FILE *inodeFile, VolumeId singleVolumeNumber) Exit(1); /* salvage of this partition aborted */ } } - assert(afs_fstat(fileno(summaryFile), &status) != -1); + osi_Assert(afs_fstat(fileno(summaryFile), &status) != -1); if (status.st_size != 0) { int ret; unsigned long st_status=(unsigned long)status.st_size; inodeSummary = (struct InodeSummary *)malloc(st_status); - assert(inodeSummary != NULL); + osi_Assert(inodeSummary != NULL); /* For GNU we need to do lseek to get the file pointer moved. */ - assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0); + osi_Assert(afs_lseek(fileno(summaryFile), 0, SEEK_SET) == 0); ret = read(fileno(summaryFile), inodeSummary, st_status); - assert(ret == st_status); + osi_Assert(ret == st_status); } nVolumesInInodeFile =(unsigned long)(status.st_size) / sizeof(struct InodeSummary); Log("%d nVolumesInInodeFile %lu \n",nVolumesInInodeFile,(unsigned long)(status.st_size)); @@ -1373,7 +1373,7 @@ AskVolumeSummary(VolumeId singleVolumeNumber) } volumeSummaryp = malloc(VOL_VG_MAX_VOLS * sizeof(struct VolumeSummary)); - assert(volumeSummaryp != NULL); + osi_Assert(volumeSummaryp != NULL); nVolumes = 0; vsp = volumeSummaryp; @@ -1686,7 +1686,7 @@ GetVolumeSummary(VolumeId singleVolumeNumber) } volumeSummaryp = malloc(nvols * sizeof(struct VolumeSummary)); - assert(volumeSummaryp != NULL); + osi_Assert(volumeSummaryp != NULL); params.singleVolumeNumber = singleVolumeNumber; params.vsp = volumeSummaryp; @@ -1854,10 +1854,10 @@ DoSalvageVolumeGroup(struct InodeSummary *isp, int nVols) allInodes = inodes - isp->index; /* this would the base of all the inodes * for the partition, if all the inodes * had been read into memory */ - assert(afs_lseek + osi_Assert(afs_lseek (inodeFd, isp->index * sizeof(struct ViceInodeInfo), SEEK_SET) != -1); - assert(read(inodeFd, inodes, size) == size); + osi_Assert(read(inodeFd, inodes, size) == size); /* Don't try to salvage a read write volume if there isn't one on this * partition */ @@ -2519,16 +2519,16 @@ SalvageIndex(Inode ino, VnodeClass class, int RW, volumeNumber = volSummary->header.id; IH_INIT(handle, fileSysDevice, volSummary->header.parent, ino); fdP = IH_OPEN(handle); - assert(fdP != NULL); + osi_Assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r+"); - assert(file != NULL); + osi_Assert(file != NULL); vcp = &VnodeClassInfo[class]; size = OS_SIZE(fdP->fd_fd); - assert(size != -1); + osi_Assert(size != -1); nVnodes = (size / vcp->diskSize) - 1; if (nVnodes > 0) { - assert((nVnodes + 1) * vcp->diskSize == size); - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); + osi_Assert((nVnodes + 1) * vcp->diskSize == size); + osi_Assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); } else { nVnodes = 0; } @@ -2741,9 +2741,9 @@ SalvageIndex(Inode ino, VnodeClass class, int RW, } } /* VNDISK_GET_INO(vnode) != 0 */ vnodeDone: - assert(!(vnodeChanged && check)); + osi_Assert(!(vnodeChanged && check)); if (vnodeChanged && !Testing) { - assert(IH_IWRITE + osi_Assert(IH_IWRITE (handle, vnodeIndexOffset(vcp, vnodeNumber), (char *)vnode, vcp->diskSize) == vcp->diskSize); @@ -2790,7 +2790,7 @@ CopyOnWrite(struct DirSummary *dir) IH_IREAD(vnodeInfo[vLarge].handle, vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode, sizeof(vnode)); - assert(code == sizeof(vnode)); + osi_Assert(code == sizeof(vnode)); oldinode = VNDISK_GET_INO(&vnode); /* Increment the version number by a whole lot to avoid problems with * clients that were promised new version numbers--but the file server @@ -2800,15 +2800,15 @@ CopyOnWrite(struct DirSummary *dir) IH_CREATE(dir->ds_linkH, fileSysDevice, fileSysPath, 0, dir->rwVid, dir->vnodeNumber, vnode.uniquifier, vnode.dataVersion += 200); - assert(VALID_INO(newinode)); - assert(CopyInode(fileSysDevice, oldinode, newinode, dir->rwVid) == 0); + osi_Assert(VALID_INO(newinode)); + osi_Assert(CopyInode(fileSysDevice, oldinode, newinode, dir->rwVid) == 0); vnode.cloned = 0; VNDISK_SET_INO(&vnode, newinode); code = IH_IWRITE(vnodeInfo[vLarge].handle, vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode, sizeof(vnode)); - assert(code == sizeof(vnode)); + osi_Assert(code == sizeof(vnode)); SetSalvageDirHandle(&dir->dirHandle, dir->dirHandle.dirh_handle->ih_vid, fileSysDevice, newinode); @@ -2845,7 +2845,7 @@ CopyAndSalvage(struct DirSummary *dir) IH_IREAD(vnodeInfo[vLarge].handle, vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode, sizeof(vnode)); - assert(lcode == sizeof(vnode)); + osi_Assert(lcode == sizeof(vnode)); oldinode = VNDISK_GET_INO(&vnode); /* Increment the version number by a whole lot to avoid problems with * clients that were promised new version numbers--but the file server @@ -2855,7 +2855,7 @@ CopyAndSalvage(struct DirSummary *dir) IH_CREATE(dir->ds_linkH, fileSysDevice, fileSysPath, 0, dir->rwVid, dir->vnodeNumber, vnode.uniquifier, vnode.dataVersion += 200); - assert(VALID_INO(newinode)); + osi_Assert(VALID_INO(newinode)); SetSalvageDirHandle(&newdir, dir->rwVid, fileSysDevice, newinode); /* Assign . and .. vnode numbers from dir and vnode.parent. @@ -2880,14 +2880,14 @@ CopyAndSalvage(struct DirSummary *dir) if (code) { Log("also failed to decrement link count on new inode"); } - assert(1 == 2); + osi_Assert(1 == 2); } Log("Checking the results of the directory salvage...\n"); if (!DirOK(&newdir)) { Log("Directory salvage failed!!!; restoring old version of the directory.\n"); code = IH_DEC(dir->ds_linkH, newinode, dir->rwVid); - assert(code == 0); - assert(1 == 2); + osi_Assert(code == 0); + osi_Assert(1 == 2); } vnode.cloned = 0; VNDISK_SET_INO(&vnode, newinode); @@ -2897,7 +2897,7 @@ CopyAndSalvage(struct DirSummary *dir) IH_IWRITE(vnodeInfo[vLarge].handle, vnodeIndexOffset(vcp, dir->vnodeNumber), (char *)&vnode, sizeof(vnode)); - assert(lcode == sizeof(vnode)); + osi_Assert(lcode == sizeof(vnode)); #if 0 #ifdef AFS_NT40_ENV nt_sync(fileSysDevice); @@ -2914,7 +2914,7 @@ CopyAndSalvage(struct DirSummary *dir) FDH_REALLYCLOSE(fdP); code = IH_DEC(dir->ds_linkH, oldinode, dir->rwVid); - assert(code == 0); + osi_Assert(code == 0); dir->dirHandle = newdir; } @@ -2935,7 +2935,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, } if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0); + osi_Assert(Delete(&dir->dirHandle, name) == 0); } return 0; } @@ -2949,7 +2949,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, Log("dir vnode %d: invalid entry: %s/%s has no inode (vnode %d, unique %d)%s\n", dir->vnodeNumber, (dir->name ? dir->name : "??"), name, vnodeNumber, unique, (Testing ? "-- would have deleted" : " -- deleted")); if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0); + osi_Assert(Delete(&dir->dirHandle, name) == 0); } return 0; } @@ -2967,7 +2967,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, if (!unique) { if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0); + osi_Assert(Delete(&dir->dirHandle, name) == 0); } return 0; } @@ -2997,9 +2997,9 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, fid.Vnode = vnodeNumber; fid.Unique = vnodeEssence->unique; CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0); + osi_Assert(Delete(&dir->dirHandle, name) == 0); if (!todelete) - assert(Create(&dir->dirHandle, name, &fid) == 0); + osi_Assert(Create(&dir->dirHandle, name, &fid) == 0); } if (todelete) return 0; /* no need to continue */ @@ -3012,10 +3012,10 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, Log("directory vnode %u.%u: bad '.' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique); if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, ".") == 0); + osi_Assert(Delete(&dir->dirHandle, ".") == 0); fid.Vnode = dir->vnodeNumber; fid.Unique = dir->unique; - assert(Create(&dir->dirHandle, ".", &fid) == 0); + osi_Assert(Create(&dir->dirHandle, ".", &fid) == 0); } vnodeNumber = fid.Vnode; /* Get the new Essence */ @@ -3029,7 +3029,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, struct VnodeEssence *dotdot; pa.Vnode = dir->parent; dotdot = CheckVnodeNumber(pa.Vnode); - assert(dotdot != NULL); /* XXX Should not be assert */ + osi_Assert(dotdot != NULL); /* XXX Should not be assert */ pa.Unique = dotdot->unique; } else { pa.Vnode = dir->vnodeNumber; @@ -3040,8 +3040,8 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, Log("directory vnode %u.%u: bad '..' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique); if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, "..") == 0); - assert(Create(&dir->dirHandle, "..", &pa) == 0); + osi_Assert(Delete(&dir->dirHandle, "..") == 0); + osi_Assert(Create(&dir->dirHandle, "..", &pa) == 0); } vnodeNumber = pa.Vnode; /* Get the new Essence */ @@ -3055,7 +3055,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, } if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0); + osi_Assert(Delete(&dir->dirHandle, name) == 0); } vnodeEssence->claimed = 0; /* Not claimed: Orphaned */ vnodeEssence->todelete = 1; /* Will later delete vnode and decr inode */ @@ -3149,7 +3149,7 @@ JudgeEntry(void *dirVal, char *name, afs_int32 vnodeNumber, } if (!Testing) { CopyOnWrite(dir); - assert(Delete(&dir->dirHandle, name) == 0); + osi_Assert(Delete(&dir->dirHandle, name) == 0); } return 0; } @@ -3176,19 +3176,19 @@ DistilVnodeEssence(VolumeId rwVId, VnodeClass class, Inode ino, Unique * maxu) IH_INIT(vip->handle, fileSysDevice, rwVId, ino); fdP = IH_OPEN(vip->handle); - assert(fdP != NULL); + osi_Assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r+"); - assert(file != NULL); + osi_Assert(file != NULL); size = OS_SIZE(fdP->fd_fd); - assert(size != -1); + osi_Assert(size != -1); vip->nVnodes = (size / vcp->diskSize) - 1; if (vip->nVnodes > 0) { - assert((vip->nVnodes + 1) * vcp->diskSize == size); - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); - assert((vip->vnodes = (struct VnodeEssence *) + osi_Assert((vip->nVnodes + 1) * vcp->diskSize == size); + osi_Assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); + osi_Assert((vip->vnodes = (struct VnodeEssence *) calloc(vip->nVnodes, sizeof(struct VnodeEssence))) != NULL); if (class == vLarge) { - assert((vip->inodes = (Inode *) + osi_Assert((vip->inodes = (Inode *) calloc(vip->nVnodes, sizeof(Inode))) != NULL); } else { vip->inodes = NULL; @@ -3342,7 +3342,7 @@ SalvageDir(char *name, VolumeId rwVid, struct VnodeInfo *dirVnodeInfo, /* If enumeration failed for random reasons, we will probably delete * too much stuff, so we guard against this instead. */ - assert(EnumerateDir(&dirHandle, JudgeEntry, &dir) == 0); + osi_Assert(EnumerateDir(&dirHandle, JudgeEntry, &dir) == 0); } /* Delete the old directory if it was copied in order to salvage. @@ -3353,7 +3353,7 @@ SalvageDir(char *name, VolumeId rwVid, struct VnodeInfo *dirVnodeInfo, DFlush(); if (dir.copied && !Testing) { code = IH_DEC(dir.ds_linkH, dirHandle.dirh_handle->ih_ino, rwVid); - assert(code == 0); + osi_Assert(code == 0); dirVnodeInfo->inodes[i] = dir.dirHandle.dirh_inode; } @@ -3590,8 +3590,8 @@ CreateRootDir(VolumeDiskData *volHeader, IHandle_t *alinkH, VolumeId vid, vnodeInfo[vLarge].vnodes = calloc(1, sizeof(struct VnodeEssence)); vnodeInfo[vLarge].inodes = calloc(1, sizeof(Inode)); - assert(vnodeInfo[vLarge].vnodes); - assert(vnodeInfo[vLarge].inodes); + osi_Assert(vnodeInfo[vLarge].vnodes); + osi_Assert(vnodeInfo[vLarge].inodes); } vep = &vnodeInfo[vLarge].vnodes[vnodeIdToBitNumber(1)]; @@ -3760,9 +3760,9 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) vid = rwIsp->volSummary->header.id; IH_INIT(h, fileSysDevice, vid, rwIsp->volSummary->header.volumeInfo); nBytes = IH_IREAD(h, 0, (char *)&volHeader, sizeof(volHeader)); - assert(nBytes == sizeof(volHeader)); - assert(volHeader.stamp.magic == VOLUMEINFOMAGIC); - assert(volHeader.destroyMe != DESTROY_ME); + osi_Assert(nBytes == sizeof(volHeader)); + osi_Assert(volHeader.stamp.magic == VOLUMEINFOMAGIC); + osi_Assert(volHeader.destroyMe != DESTROY_ME); /* (should not have gotten this far with DESTROY_ME flag still set!) */ DistilVnodeEssence(vid, vLarge, rwIsp->volSummary->header.largeVnodeIndex, @@ -3869,8 +3869,8 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) vnodeInfo[class].inodes[v]); pa.Vnode = LFVnode; pa.Unique = LFUnique; - assert(Delete(&dh, "..") == 0); - assert(Create(&dh, "..", &pa) == 0); + osi_Assert(Delete(&dh, "..") == 0); + osi_Assert(Create(&dh, "..", &pa) == 0); /* The original parent's link count was decremented above. * Here we increment the new parent's link count. @@ -3900,7 +3900,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) ThisUnique += 50; /* Try creating a different file */ } - assert(code == 0); + osi_Assert(code == 0); Log("Attaching orphaned %s to volume's root dir as %s\n", ((class == vLarge) ? "directory" : "file"), npath); } @@ -3913,7 +3913,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) code = IH_DEC(oldrootdir.ds_linkH, oldrootdir.dirHandle.dirh_inode, oldrootdir.rwVid); - assert(code == 0); + osi_Assert(code == 0); /* dirVnodeInfo->inodes[?] is not updated with new inode number */ } @@ -3951,7 +3951,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) IH_IREAD(vnodeInfo[class].handle, vnodeIndexOffset(vcp, vnodeNumber), (char *)&vnode, sizeof(vnode)); - assert(nBytes == sizeof(vnode)); + osi_Assert(nBytes == sizeof(vnode)); vnode.parent = vnp->parent; oldCount = vnode.linkCount; @@ -3962,7 +3962,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) if (orphaned) { if (!vnp->todelete) { /* Orphans should have already been attached (if requested) */ - assert(orphans != ORPH_ATTACH); + osi_Assert(orphans != ORPH_ATTACH); oblocks += vnp->blockCount; ofiles++; } @@ -3973,7 +3973,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) if (VNDISK_GET_INO(&vnode)) { code = IH_DEC(alinkH, VNDISK_GET_INO(&vnode), vid); - assert(code == 0); + osi_Assert(code == 0); } memset(&vnode, 0, sizeof(vnode)); } @@ -3991,7 +3991,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) IH_IWRITE(vnodeInfo[class].handle, vnodeIndexOffset(vcp, vnodeNumber), (char *)&vnode, sizeof(vnode)); - assert(nBytes == sizeof(vnode)); + osi_Assert(nBytes == sizeof(vnode)); } VolumeChanged = 1; } @@ -4061,7 +4061,7 @@ SalvageVolume(struct InodeSummary *rwIsp, IHandle_t * alinkH) VolumeChanged = 0; if (!Testing) { nBytes = IH_IWRITE(h, 0, (char *)&volHeader, sizeof(volHeader)); - assert(nBytes == sizeof(volHeader)); + osi_Assert(nBytes == sizeof(volHeader)); } if (!Showmode) { Log("%sSalvaged %s (%u): %d files, %d blocks\n", @@ -4083,15 +4083,15 @@ ClearROInUseBit(struct VolumeSummary *summary) VolumeDiskData volHeader; nBytes = IH_IREAD(h, 0, (char *)&volHeader, sizeof(volHeader)); - assert(nBytes == sizeof(volHeader)); - assert(volHeader.stamp.magic == VOLUMEINFOMAGIC); + osi_Assert(nBytes == sizeof(volHeader)); + osi_Assert(volHeader.stamp.magic == VOLUMEINFOMAGIC); volHeader.inUse = 0; volHeader.needsSalvaged = 0; volHeader.inService = 1; volHeader.dontSalvage = DONT_SALVAGE; if (!Testing) { nBytes = IH_IWRITE(h, 0, (char *)&volHeader, sizeof(volHeader)); - assert(nBytes == sizeof(volHeader)); + osi_Assert(nBytes == sizeof(volHeader)); } } @@ -4223,7 +4223,7 @@ LockVolume(VolumeId volumeId) * case). But if it's there enough that we can read it, but * somehow we cannot write to it to signify we're salvaging it, * we've got a big problem and we cannot continue. */ - assert(IH_IWRITE(h, 0, (char*)&volHeader, sizeof(volHeader)) == sizeof(volHeader)); + osi_Assert(IH_IWRITE(h, 0, (char*)&volHeader, sizeof(volHeader)) == sizeof(volHeader)); IH_RELEASE(h); } @@ -4317,12 +4317,12 @@ CopyInode(Device device, Inode inode1, Inode inode2, int rwvolume) IH_INIT(srcH, device, rwvolume, inode1); srcFdP = IH_OPEN(srcH); - assert(srcFdP != NULL); + osi_Assert(srcFdP != NULL); IH_INIT(destH, device, rwvolume, inode2); destFdP = IH_OPEN(destH); while ((nBytes = FDH_READ(srcFdP, buf, sizeof(buf))) > 0) - assert(FDH_WRITE(destFdP, buf, nBytes) == nBytes); - assert(nBytes == 0); + osi_Assert(FDH_WRITE(destFdP, buf, nBytes) == nBytes); + osi_Assert(nBytes == 0); FDH_REALLYCLOSE(srcFdP); FDH_REALLYCLOSE(destFdP); IH_RELEASE(srcH); @@ -4338,11 +4338,11 @@ PrintInodeList(void) struct afs_stat status; int nInodes; - assert(afs_fstat(inodeFd, &status) == 0); + osi_Assert(afs_fstat(inodeFd, &status) == 0); buf = (struct ViceInodeInfo *)malloc(status.st_size); - assert(buf != NULL); + osi_Assert(buf != NULL); nInodes = status.st_size / sizeof(struct ViceInodeInfo); - assert(read(inodeFd, buf, status.st_size) == status.st_size); + osi_Assert(read(inodeFd, buf, status.st_size) == status.st_size); for (ip = buf; nInodes--; ip++) { Log("Inode:%s, linkCount=%d, size=%#llx, p=(%u,%u,%u,%u)\n", PrintInode(NULL, ip->inodeNumber), ip->linkCount, @@ -4381,10 +4381,10 @@ Fork(void) int f; #ifdef AFS_NT40_ENV f = 0; - assert(0); /* Fork is never executed in the NT code path */ + osi_Assert(0); /* Fork is never executed in the NT code path */ #else f = fork(); - assert(f >= 0); + osi_Assert(f >= 0); #ifdef AFS_DEMAND_ATTACH_FS if ((f == 0) && (programType == salvageServer)) { /* we are a salvageserver child */ @@ -4433,7 +4433,7 @@ Wait(char *prog) int status; int pid; pid = wait(&status); - assert(pid != -1); + osi_Assert(pid != -1); if (WCOREDUMP(status)) Log("\"%s\" core dumped!\n", prog); if (WIFSIGNALED(status) != 0 || WEXITSTATUS(status) != 0) @@ -4587,7 +4587,7 @@ ToString(const char *s) { char *p; p = (char *)malloc(strlen(s) + 1); - assert(p != NULL); + osi_Assert(p != NULL); strcpy(p, s); return p; } diff --git a/src/vol/volume.c b/src/vol/volume.c index 792912890..4530d3557 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -124,12 +124,7 @@ #include "partition.h" #include "volume_inline.h" #include "common.h" - -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include "afs/afs_assert.h" -#endif /* AFS_PTHREAD_ENV */ #include "vutils.h" #ifndef AFS_NT40_ENV #include @@ -563,15 +558,15 @@ VInitVolumePackage2(ProgramType pt, VolumePackageOptions * opts) } else { VLRU_SetOptions(VLRU_SET_ENABLED, 0); } - assert(pthread_key_create(&VThread_key, NULL) == 0); + osi_Assert(pthread_key_create(&VThread_key, NULL) == 0); #endif #ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_init(&vol_glock_mutex, NULL) == 0); - assert(pthread_mutex_init(&vol_trans_mutex, NULL) == 0); - assert(pthread_cond_init(&vol_put_volume_cond, NULL) == 0); - assert(pthread_cond_init(&vol_sleep_cond, NULL) == 0); - assert(pthread_cond_init(&vol_init_attach_cond, NULL) == 0); + MUTEX_INIT(&vol_glock_mutex, "vol glock", MUTEX_DEFAULT, 0); + MUTEX_INIT(&vol_trans_mutex, "vol trans", MUTEX_DEFAULT, 0); + CV_INIT(&vol_put_volume_cond, "vol put", CV_DEFAULT, 0); + CV_INIT(&vol_sleep_cond, "vol sleep", CV_DEFAULT, 0); + CV_INIT(&vol_init_attach_cond, "vol init attach", CV_DEFAULT, 0); #else /* AFS_PTHREAD_ENV */ IOMGR_Initialize(); #endif /* AFS_PTHREAD_ENV */ @@ -580,7 +575,7 @@ VInitVolumePackage2(ProgramType pt, VolumePackageOptions * opts) srandom(time(0)); /* For VGetVolumeInfo */ #ifdef AFS_DEMAND_ATTACH_FS - assert(pthread_mutex_init(&vol_salvsync_mutex, NULL) == 0); + MUTEX_INIT(&vol_salvsync_mutex, "salvsync", MUTEX_DEFAULT, 0); #endif /* AFS_DEMAND_ATTACH_FS */ /* Ok, we have done enough initialization that fileserver can @@ -602,7 +597,7 @@ VInitVolumePackage2(ProgramType pt, VolumePackageOptions * opts) #if defined(AFS_DEMAND_ATTACH_FS) && defined(SALVSYNC_BUILD_CLIENT) if (VCanUseSALVSYNC()) { /* establish a connection to the salvager at this point */ - assert(VConnectSALV() != 0); + osi_Assert(VConnectSALV() != 0); } #endif /* AFS_DEMAND_ATTACH_FS */ @@ -656,13 +651,13 @@ VInitVolumePackage2(ProgramType pt, VolumePackageOptions * opts) int VInitAttachVolumes(ProgramType pt) { - assert(VInit==1); + osi_Assert(VInit==1); if (pt == fileServer) { struct DiskPartition64 *diskP; /* Attach all the volumes in this partition */ for (diskP = DiskPartitionList; diskP; diskP = diskP->next) { int nAttached = 0, nUnattached = 0; - assert(VAttachVolumesByPartition(diskP, &nAttached, &nUnattached) == 0); + osi_Assert(VAttachVolumesByPartition(diskP, &nAttached, &nUnattached) == 0); } } VOL_LOCK; @@ -687,7 +682,7 @@ VInitAttachVolumes(ProgramType pt) int VInitAttachVolumes(ProgramType pt) { - assert(VInit==1); + osi_Assert(VInit==1); if (pt == fileServer) { struct DiskPartition64 *diskP; struct vinitvolumepackage_thread_t params; @@ -696,14 +691,14 @@ VInitAttachVolumes(ProgramType pt) pthread_t tid; pthread_attr_t attrs; - assert(pthread_cond_init(¶ms.thread_done_cv,NULL) == 0); + CV_INIT(¶ms.thread_done_cv, "thread done", CV_DEFAULT, 0); queue_Init(¶ms); params.n_threads_complete = 0; /* create partition work queue */ for (parts=0, diskP = DiskPartitionList; diskP; diskP = diskP->next, parts++) { dpq = (diskpartition_queue_t *) malloc(sizeof(struct diskpartition_queue_t)); - assert(dpq != NULL); + osi_Assert(dpq != NULL); dpq->diskP = diskP; queue_Append(¶ms,dpq); } @@ -712,8 +707,8 @@ VInitAttachVolumes(ProgramType pt) if (threads > 1) { /* spawn off a bunch of initialization threads */ - assert(pthread_attr_init(&attrs) == 0); - assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_attr_init(&attrs) == 0); + osi_Assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); Log("VInitVolumePackage: beginning parallel fileserver startup\n"); Log("VInitVolumePackage: using %d threads to attach volumes on %d partitions\n", @@ -723,7 +718,7 @@ VInitAttachVolumes(ProgramType pt) for (i=0; i < threads; i++) { AFS_SIGSET_DECL; AFS_SIGSET_CLEAR(); - assert(pthread_create + osi_Assert(pthread_create (&tid, &attrs, &VInitVolumePackageThread, ¶ms) == 0); AFS_SIGSET_RESTORE(); @@ -734,7 +729,7 @@ VInitAttachVolumes(ProgramType pt) } VOL_UNLOCK; - assert(pthread_attr_destroy(&attrs) == 0); + osi_Assert(pthread_attr_destroy(&attrs) == 0); } else { /* if we're only going to run one init thread, don't bother creating * another LWP */ @@ -745,11 +740,11 @@ VInitAttachVolumes(ProgramType pt) VInitVolumePackageThread(¶ms); } - assert(pthread_cond_destroy(¶ms.thread_done_cv) == 0); + CV_DESTROY(¶ms.thread_done_cv); } VOL_LOCK; VInit = 2; /* Initialized, and all volumes have been attached */ - assert(pthread_cond_broadcast(&vol_init_attach_cond) == 0); + CV_BROADCAST(&vol_init_attach_cond); VOL_UNLOCK; return 0; } @@ -780,14 +775,14 @@ VInitVolumePackageThread(void * args) { diskP = dpq->diskP; free(dpq); - assert(VAttachVolumesByPartition(diskP, &nAttached, &nUnattached) == 0); + osi_Assert(VAttachVolumesByPartition(diskP, &nAttached, &nUnattached) == 0); VOL_LOCK; } done: params->n_threads_complete++; - pthread_cond_signal(¶ms->thread_done_cv); + CV_SIGNAL(¶ms->thread_done_cv); VOL_UNLOCK; return NULL; } @@ -807,7 +802,7 @@ done: int VInitAttachVolumes(ProgramType pt) { - assert(VInit==1); + osi_Assert(VInit==1); if (pt == fileServer) { struct DiskPartition64 *diskP; @@ -820,12 +815,12 @@ VInitAttachVolumes(ProgramType pt) /* create partition work queue */ queue_Init(&pq); - assert(pthread_cond_init(&(pq.cv), NULL) == 0); - assert(pthread_mutex_init(&(pq.mutex), NULL) == 0); + CV_INIT(&(pq.cv), "partq", CV_DEFAULT, 0); + MUTEX_INIT(&(pq.mutex), "partq", MUTEX_DEFAULT, 0); for (parts = 0, diskP = DiskPartitionList; diskP; diskP = diskP->next, parts++) { struct diskpartition_queue_t *dp; dp = (struct diskpartition_queue_t*)malloc(sizeof(struct diskpartition_queue_t)); - assert(dp != NULL); + osi_Assert(dp != NULL); dp->diskP = diskP; queue_Append(&pq, dp); } @@ -835,11 +830,11 @@ VInitAttachVolumes(ProgramType pt) /* create volume work queue */ queue_Init(&vq); - assert(pthread_cond_init(&(vq.cv), NULL) == 0); - assert(pthread_mutex_init(&(vq.mutex), NULL) == 0); + CV_INIT(&(vq.cv), "volq", CV_DEFAULT, 0); + MUTEX_INIT(&(vq.mutex), "volq", MUTEX_DEFAULT, 0); - assert(pthread_attr_init(&attrs) == 0); - assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_attr_init(&attrs) == 0); + osi_Assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); Log("VInitVolumePackage: beginning parallel fileserver startup\n"); Log("VInitVolumePackage: using %d threads to pre-attach volumes on %d partitions\n", @@ -851,29 +846,29 @@ VInitAttachVolumes(ProgramType pt) AFS_SIGSET_DECL; params = (struct vinitvolumepackage_thread_param *)malloc(sizeof(struct vinitvolumepackage_thread_param)); - assert(params); + osi_Assert(params); params->pq = &pq; params->vq = &vq; params->nthreads = threads; params->thread = i+1; AFS_SIGSET_CLEAR(); - assert(pthread_create (&tid, &attrs, &VInitVolumePackageThread, (void*)params) == 0); + osi_Assert(pthread_create (&tid, &attrs, &VInitVolumePackageThread, (void*)params) == 0); AFS_SIGSET_RESTORE(); } VInitPreAttachVolumes(threads, &vq); - assert(pthread_attr_destroy(&attrs) == 0); - assert(pthread_cond_destroy(&pq.cv) == 0); - assert(pthread_mutex_destroy(&pq.mutex) == 0); - assert(pthread_cond_destroy(&vq.cv) == 0); - assert(pthread_mutex_destroy(&vq.mutex) == 0); + osi_Assert(pthread_attr_destroy(&attrs) == 0); + CV_DESTROY(&pq.cv); + MUTEX_DESTROY(&pq.mutex); + CV_DESTROY(&vq.cv); + MUTEX_DESTROY(&vq.mutex); } VOL_LOCK; VInit = 2; /* Initialized, and all volumes have been attached */ - assert(pthread_cond_broadcast(&vol_init_attach_cond) == 0); + CV_BROADCAST(&vol_init_attach_cond); VOL_UNLOCK; return 0; @@ -894,15 +889,15 @@ VInitVolumePackageThread(void *args) struct volume_init_queue *vq; struct volume_init_batch *vb; - assert(args); + osi_Assert(args); params = (struct vinitvolumepackage_thread_param *)args; pq = params->pq; vq = params->vq; - assert(pq); - assert(vq); + osi_Assert(pq); + osi_Assert(vq); vb = (struct volume_init_batch*)malloc(sizeof(struct volume_init_batch)); - assert(vb); + osi_Assert(vb); vb->thread = params->thread; vb->last = 0; vb->size = 0; @@ -920,23 +915,23 @@ VInitVolumePackageThread(void *args) } while ((vid = VInitNextVolumeId(dirp))) { Volume *vp = (Volume*)malloc(sizeof(Volume)); - assert(vp); + osi_Assert(vp); memset(vp, 0, sizeof(Volume)); vp->device = partition->device; vp->partition = partition; vp->hashid = vid; queue_Init(&vp->vnode_list); - assert(pthread_cond_init(&V_attachCV(vp), NULL) == 0); + CV_INIT(&V_attachCV(vp), "partattach", CV_DEFAULT, 0); vb->batch[vb->size++] = vp; if (vb->size == VINIT_BATCH_MAX_SIZE) { - assert(pthread_mutex_lock(&vq->mutex) == 0); + MUTEX_ENTER(&vq->mutex); queue_Append(vq, vb); - assert(pthread_cond_broadcast(&vq->cv) == 0); - assert(pthread_mutex_unlock(&vq->mutex) == 0); + CV_BROADCAST(&vq->cv); + MUTEX_EXIT(&vq->mutex); vb = (struct volume_init_batch*)malloc(sizeof(struct volume_init_batch)); - assert(vb); + osi_Assert(vb); vb->thread = params->thread; vb->size = 0; vb->last = 0; @@ -946,10 +941,10 @@ VInitVolumePackageThread(void *args) } vb->last = 1; - assert(pthread_mutex_lock(&vq->mutex) == 0); + MUTEX_ENTER(&vq->mutex); queue_Append(vq, vb); - assert(pthread_cond_broadcast(&vq->cv) == 0); - assert(pthread_mutex_unlock(&vq->mutex) == 0); + CV_BROADCAST(&vq->cv); + MUTEX_EXIT(&vq->mutex); Log("Partition scan thread %d of %d ended\n", params->thread, params->nthreads); free(params); @@ -971,17 +966,17 @@ VInitNextPartition(struct partition_queue *pq) } /* get next partition to scan */ - assert(pthread_mutex_lock(&pq->mutex) == 0); + MUTEX_ENTER(&pq->mutex); if (queue_IsEmpty(pq)) { - assert(pthread_mutex_unlock(&pq->mutex) == 0); + MUTEX_EXIT(&pq->mutex); return NULL; } dp = queue_First(pq, diskpartition_queue_t); queue_Remove(dp); - assert(pthread_mutex_unlock(&pq->mutex) == 0); + MUTEX_EXIT(&pq->mutex); - assert(dp); - assert(dp->diskP); + osi_Assert(dp); + osi_Assert(dp->diskP); partition = dp->diskP; free(dp); @@ -1026,13 +1021,13 @@ VInitPreAttachVolumes(int nthreads, struct volume_init_queue *vq) while (nthreads) { /* dequeue next volume */ - pthread_mutex_lock(&vq->mutex); + MUTEX_ENTER(&vq->mutex); if (queue_IsEmpty(vq)) { - pthread_cond_wait(&vq->cv, &vq->mutex); + CV_WAIT(&vq->cv, &vq->mutex); } vb = queue_First(vq, volume_init_batch); queue_Remove(vb); - pthread_mutex_unlock(&vq->mutex); + MUTEX_EXIT(&vq->mutex); if (vb->size) { VOL_LOCK; @@ -1209,11 +1204,11 @@ VShutdown_r(void) if (vol_attach_threads > 1) { /* prepare for parallel shutdown */ params.n_threads = vol_attach_threads; - assert(pthread_mutex_init(¶ms.lock, NULL) == 0); - assert(pthread_cond_init(¶ms.cv, NULL) == 0); - assert(pthread_cond_init(¶ms.master_cv, NULL) == 0); - assert(pthread_attr_init(&attrs) == 0); - assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); + MUTEX_INIT(¶ms.lock, "params", MUTEX_DEFAULT, 0); + CV_INIT(¶ms.cv, "params", CV_DEFAULT, 0); + CV_INIT(¶ms.master_cv, "params master", CV_DEFAULT, 0); + osi_Assert(pthread_attr_init(&attrs) == 0); + osi_Assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); queue_Init(¶ms); /* setup the basic partition information structures for @@ -1239,7 +1234,7 @@ VShutdown_r(void) /* build up the pass 0 shutdown work queue */ dpq = (struct diskpartition_queue_t *) malloc(sizeof(struct diskpartition_queue_t)); - assert(dpq != NULL); + osi_Assert(dpq != NULL); dpq->diskP = diskP; queue_Prepend(¶ms, dpq); @@ -1251,21 +1246,21 @@ VShutdown_r(void) vol_attach_threads, params.n_parts, params.n_parts > 1 ? "s" : "" ); /* do pass 0 shutdown */ - assert(pthread_mutex_lock(¶ms.lock) == 0); + MUTEX_ENTER(¶ms.lock); for (i=0; i < params.n_threads; i++) { - assert(pthread_create + osi_Assert(pthread_create (&tid, &attrs, &VShutdownThread, ¶ms) == 0); } /* wait for all the pass 0 shutdowns to complete */ while (params.n_threads_complete < params.n_threads) { - assert(pthread_cond_wait(¶ms.master_cv, ¶ms.lock) == 0); + CV_WAIT(¶ms.master_cv, ¶ms.lock); } params.n_threads_complete = 0; params.pass = 1; - assert(pthread_cond_broadcast(¶ms.cv) == 0); - assert(pthread_mutex_unlock(¶ms.lock) == 0); + CV_BROADCAST(¶ms.cv); + MUTEX_EXIT(¶ms.lock); Log("VShutdown: pass 0 completed using the 1 thread per partition algorithm\n"); Log("VShutdown: starting passes 1 through 3 using finely-granular mp-fast algorithm\n"); @@ -1278,10 +1273,10 @@ VShutdown_r(void) VOL_CV_WAIT(¶ms.cv); } - assert(pthread_attr_destroy(&attrs) == 0); - assert(pthread_cond_destroy(¶ms.cv) == 0); - assert(pthread_cond_destroy(¶ms.master_cv) == 0); - assert(pthread_mutex_destroy(¶ms.lock) == 0); + osi_Assert(pthread_attr_destroy(&attrs) == 0); + CV_DESTROY(¶ms.cv); + CV_DESTROY(¶ms.master_cv); + MUTEX_DESTROY(¶ms.lock); /* drop the VByPList exclusive reservations */ for (diskP = DiskPartitionList; diskP; diskP = diskP->next) { @@ -1350,7 +1345,7 @@ VShutdown_r(void) void VShutdown(void) { - assert(VInit>0); + osi_Assert(VInit>0); VOL_LOCK; VShutdown_r(); VOL_UNLOCK; @@ -1557,14 +1552,14 @@ VShutdownThread(void * args) params = (vshutdown_thread_t *) args; /* acquire the shutdown pass 0 lock */ - assert(pthread_mutex_lock(¶ms->lock) == 0); + MUTEX_ENTER(¶ms->lock); /* if there's still pass 0 work to be done, * get a work entry, and do a pass 0 shutdown */ if (queue_IsNotEmpty(params)) { dpq = queue_First(params, diskpartition_queue_t); queue_Remove(dpq); - assert(pthread_mutex_unlock(¶ms->lock) == 0); + MUTEX_EXIT(¶ms->lock); diskP = dpq->diskP; free(dpq); id = diskP->index; @@ -1573,24 +1568,24 @@ VShutdownThread(void * args) while (ShutdownVolumeWalk_r(diskP, 0, ¶ms->part_pass_head[id])) count++; params->stats[0][diskP->index] = count; - assert(pthread_mutex_lock(¶ms->lock) == 0); + MUTEX_ENTER(¶ms->lock); } params->n_threads_complete++; if (params->n_threads_complete == params->n_threads) { - /* notify control thread that all workers have completed pass 0 */ - assert(pthread_cond_signal(¶ms->master_cv) == 0); + /* notify control thread that all workers have completed pass 0 */ + CV_SIGNAL(¶ms->master_cv); } while (params->pass == 0) { - assert(pthread_cond_wait(¶ms->cv, ¶ms->lock) == 0); + CV_WAIT(¶ms->cv, ¶ms->lock); } /* switch locks */ - assert(pthread_mutex_unlock(¶ms->lock) == 0); + MUTEX_EXIT(¶ms->lock); VOL_LOCK; pass = params->pass; - assert(pass > 0); + osi_Assert(pass > 0); /* now escalate through the more complicated shutdowns */ while (pass <= 3) { @@ -1670,7 +1665,7 @@ VShutdownThread(void * args) ShutdownCreateSchedule(params); /* wake up all the workers */ - assert(pthread_cond_broadcast(¶ms->cv) == 0); + CV_BROADCAST(¶ms->cv); VOL_UNLOCK; Log("VShutdown: pass %d completed using %d threads on %d partitions\n", @@ -1824,7 +1819,7 @@ VShutdownVolume_r(Volume * vp) /* wait for other blocking ops to finish */ VWaitExclusiveState_r(vp); - assert(VIsValidState(V_attachState(vp))); + osi_Assert(VIsValidState(V_attachState(vp))); switch(V_attachState(vp)) { case VOL_STATE_SALVAGING: @@ -2081,7 +2076,7 @@ VPreAttachVolumeById_r(Error * ec, *ec = 0; - assert(programType == fileServer); + osi_Assert(programType == fileServer); if (!(partp = VGetPartition_r(partition, 0))) { *ec = VNOVOL; @@ -2165,10 +2160,10 @@ VPreAttachVolumeByVp_r(Error * ec, /* allocate the volume structure */ vp = nvp = (Volume *) malloc(sizeof(Volume)); - assert(vp != NULL); + osi_Assert(vp != NULL); memset(vp, 0, sizeof(Volume)); queue_Init(&vp->vnode_list); - assert(pthread_cond_init(&V_attachCV(vp), NULL) == 0); + CV_INIT(&V_attachCV(vp), "vp attach", CV_DEFAULT, 0); } /* link the volume with its associated vice partition */ @@ -2255,7 +2250,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) } if (VRequiresPartLock()) { - assert(VInit == 3); + osi_Assert(VInit == 3); VLockPartition_r(partition); } else if (programType == fileServer) { #ifdef AFS_DEMAND_ATTACH_FS @@ -2330,7 +2325,7 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) } } - assert(vp != NULL); + osi_Assert(vp != NULL); /* handle pre-attach races * @@ -2391,13 +2386,13 @@ VAttachVolumeByName_r(Error * ec, char *partition, char *name, int mode) if (!vp) { vp = (Volume *) calloc(1, sizeof(Volume)); - assert(vp != NULL); + osi_Assert(vp != NULL); vp->hashid = volumeId; vp->device = partp->device; vp->partition = partp; queue_Init(&vp->vnode_list); #ifdef AFS_DEMAND_ATTACH_FS - assert(pthread_cond_init(&V_attachCV(vp), NULL) == 0); + CV_INIT(&V_attachCV(vp), "vp attach", CV_DEFAULT, 0); #endif /* AFS_DEMAND_ATTACH_FS */ } @@ -2535,7 +2530,7 @@ VAttachVolumeByVp_r(Error * ec, Volume * vp, int mode) *ec = 0; /* volume utility should never call AttachByVp */ - assert(programType == fileServer); + osi_Assert(programType == fileServer); volumeId = vp->hashid; partp = vp->partition; @@ -2579,7 +2574,7 @@ VAttachVolumeByVp_r(Error * ec, Volume * vp, int mode) } } - assert(vp != NULL); + osi_Assert(vp != NULL); VChangeState_r(vp, VOL_STATE_ATTACHING); /* restore monotonically increasing stats */ @@ -2677,8 +2672,8 @@ VLockVolumeNB(Volume *vp, int locktype) { int code; - assert(programType != fileServer || VIsExclusiveState(V_attachState(vp))); - assert(!(V_attachFlags(vp) & VOL_LOCKED)); + osi_Assert(programType != fileServer || VIsExclusiveState(V_attachState(vp))); + osi_Assert(!(V_attachFlags(vp) & VOL_LOCKED)); code = VLockVolumeByIdNB(vp->hashid, vp->partition, locktype); if (code == 0) { @@ -2700,8 +2695,8 @@ VLockVolumeNB(Volume *vp, int locktype) static void VUnlockVolume(Volume *vp) { - assert(programType != fileServer || VIsExclusiveState(V_attachState(vp))); - assert((V_attachFlags(vp) & VOL_LOCKED)); + osi_Assert(programType != fileServer || VIsExclusiveState(V_attachState(vp))); + osi_Assert((V_attachFlags(vp) & VOL_LOCKED)); VUnlockVolumeById(vp->hashid, vp->partition); @@ -3010,12 +3005,12 @@ attach_check_vop(Error *ec, VolumeId volid, struct DiskPartition64 *partp, switch (vp->pending_vol_op->vol_op_state) { case FSSYNC_VolOpPending: /* this should never happen */ - assert(vp->pending_vol_op->vol_op_state != FSSYNC_VolOpPending); + osi_Assert(vp->pending_vol_op->vol_op_state != FSSYNC_VolOpPending); break; case FSSYNC_VolOpRunningUnknown: /* this should never happen; we resolved 'unknown' above */ - assert(vp->pending_vol_op->vol_op_state != FSSYNC_VolOpRunningUnknown); + osi_Assert(vp->pending_vol_op->vol_op_state != FSSYNC_VolOpRunningUnknown); break; case FSSYNC_VolOpRunningOffline: @@ -3443,7 +3438,7 @@ VAttachVolume_r(Error * ec, VolumeId volumeId, int mode) Error error; vp = VGetVolume_r(&error, volumeId); if (vp) { - assert(V_inUse(vp) == 0); + osi_Assert(V_inUse(vp) == 0); VDetachVolume_r(ec, vp); } return NULL; @@ -3526,7 +3521,7 @@ VHold(Volume * vp) void VPutVolume_r(Volume * vp) { - assert(--vp->nUsers >= 0); + osi_Assert(--vp->nUsers >= 0); if (vp->nUsers == 0) { VCheckOffline(vp); ReleaseVolumeHeader(vp->header); @@ -3793,7 +3788,7 @@ GetVolume(Error * ec, Error * client_ec, VolId volumeId, Volume * hint, int nowa */ /* only valid before/during demand attachment */ - assert(!vp->pending_vol_op || vp->pending_vol_op->vol_op_state != FSSYNC_VolOpRunningUnknown); + osi_Assert(!vp->pending_vol_op || vp->pending_vol_op->vol_op_state != FSSYNC_VolOpRunningUnknown); /* deny getvolume due to running mutually exclusive vol op */ if (vp->pending_vol_op && vp->pending_vol_op->vol_op_state==FSSYNC_VolOpRunningOffline) { @@ -3916,7 +3911,7 @@ GetVolume(Error * ec, Error * client_ec, VolId volumeId, Volume * hint, int nowa #endif /* AFS_DEMAND_ATTACH_FS */ not_inited: - assert(vp || *ec); + osi_Assert(vp || *ec); return vp; } @@ -3932,8 +3927,8 @@ VTakeOffline_r(Volume * vp) { Error error; - assert(vp->nUsers > 0); - assert(programType == fileServer); + osi_Assert(vp->nUsers > 0); + osi_Assert(programType == fileServer); VCreateReservation_r(vp); VWaitExclusiveState_r(vp); @@ -3948,8 +3943,8 @@ VTakeOffline_r(Volume * vp) void VTakeOffline_r(Volume * vp) { - assert(vp->nUsers > 0); - assert(programType == fileServer); + osi_Assert(vp->nUsers > 0); + osi_Assert(programType == fileServer); vp->goingOffline = 1; V_needsSalvaged(vp) = 1; @@ -4021,7 +4016,7 @@ VForceOffline_r(Volume * vp, int flags) #endif /* AFS_DEMAND_ATTACH_FS */ #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&vol_put_volume_cond) == 0); + CV_BROADCAST(&vol_put_volume_cond); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(VPutVolume); #endif /* AFS_PTHREAD_ENV */ @@ -4056,7 +4051,7 @@ VOffline_r(Volume * vp, char *message) VolumeId vid = V_id(vp); #endif - assert(programType != volumeUtility && programType != volumeServer); + osi_Assert(programType != volumeUtility && programType != volumeServer); if (!V_inUse(vp)) { VPutVolume_r(vp); return; @@ -4115,7 +4110,7 @@ VOffline_r(Volume * vp, char *message) void VOfflineForVolOp_r(Error *ec, Volume *vp, char *message) { - assert(vp->pending_vol_op); + osi_Assert(vp->pending_vol_op); if (!V_inUse(vp)) { VPutVolume_r(vp); *ec = 1; @@ -4412,9 +4407,9 @@ VSyncVolume_r(Error * ec, Volume * vp, int flags) VOL_UNLOCK; #endif fdP = IH_OPEN(V_diskDataHandle(vp)); - assert(fdP != NULL); + osi_Assert(fdP != NULL); code = FDH_SYNC(fdP); - assert(code == 0); + osi_Assert(code == 0); FDH_CLOSE(fdP); #ifdef AFS_DEMAND_ATTACH_FS VOL_LOCK; @@ -4506,7 +4501,7 @@ VCheckDetach(Volume * vp) VCheckSalvage(vp); ReallyFreeVolume(vp); if (programType == fileServer) { - assert(pthread_cond_broadcast(&vol_put_volume_cond) == 0); + CV_BROADCAST(&vol_put_volume_cond); } } return ret; @@ -4540,7 +4535,7 @@ VCheckDetach(Volume * vp) ReallyFreeVolume(vp); if (programType == fileServer) { #if defined(AFS_PTHREAD_ENV) - assert(pthread_cond_broadcast(&vol_put_volume_cond) == 0); + CV_BROADCAST(&vol_put_volume_cond); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(VPutVolume); #endif /* AFS_PTHREAD_ENV */ @@ -4560,8 +4555,8 @@ VCheckOffline(Volume * vp) if (vp->goingOffline && !vp->nUsers) { Error error; - assert(programType == fileServer); - assert((V_attachState(vp) != VOL_STATE_ATTACHED) && + osi_Assert(programType == fileServer); + osi_Assert((V_attachState(vp) != VOL_STATE_ATTACHED) && (V_attachState(vp) != VOL_STATE_FREED) && (V_attachState(vp) != VOL_STATE_PREATTACHED) && (V_attachState(vp) != VOL_STATE_UNATTACHED) && @@ -4621,7 +4616,7 @@ VCheckOffline(Volume * vp) if (vp->goingOffline && !vp->nUsers) { Error error; - assert(programType == fileServer); + osi_Assert(programType == fileServer); ret = 1; vp->goingOffline = 0; @@ -4637,7 +4632,7 @@ VCheckOffline(Volume * vp) } FreeVolumeHeader(vp); #ifdef AFS_PTHREAD_ENV - assert(pthread_cond_broadcast(&vol_put_volume_cond) == 0); + CV_BROADCAST(&vol_put_volume_cond); #else /* AFS_PTHREAD_ENV */ LWP_NoYieldSignal(VPutVolume); #endif /* AFS_PTHREAD_ENV */ @@ -4688,7 +4683,7 @@ VCheckOffline(Volume * vp) void VCancelReservation_r(Volume * vp) { - assert(--vp->nWaiters >= 0); + osi_Assert(--vp->nWaiters >= 0); if (vp->nWaiters == 0) { VCheckOffline(vp); if (!VCheckDetach(vp)) { @@ -4745,7 +4740,7 @@ VRegisterVolOp_r(Volume * vp, FSSYNC_VolOp_info * vopinfo) /* attach a vol op info node to the volume struct */ info = (FSSYNC_VolOp_info *) malloc(sizeof(FSSYNC_VolOp_info)); - assert(info != NULL); + osi_Assert(info != NULL); memcpy(info, vopinfo, sizeof(FSSYNC_VolOp_info)); vp->pending_vol_op = info; @@ -5146,7 +5141,7 @@ VScheduleSalvage_r(Volume * vp) VThreadOptions_t * thread_opts; char partName[16]; - assert(VCanUseSALVSYNC() || VCanUseFSSYNC()); + osi_Assert(VCanUseSALVSYNC() || VCanUseFSSYNC()); if (vp->nWaiters || vp->nUsers) { return 1; @@ -5184,7 +5179,7 @@ VScheduleSalvage_r(Volume * vp) state_save = VChangeState_r(vp, VOL_STATE_SALVSYNC_REQ); VOL_UNLOCK; - assert(try_SALVSYNC(vp, partName, &code) || + osi_Assert(try_SALVSYNC(vp, partName, &code) || try_FSSYNC(vp, partName, &code)); VOL_LOCK; @@ -5436,7 +5431,7 @@ int VConnectFS_r(void) { int rc; - assert((VInit == 2) && + osi_Assert((VInit == 2) && (programType != fileServer) && (programType != salvager)); rc = FSYNC_clientInit(); @@ -5464,7 +5459,7 @@ VConnectFS_r(void) void VDisconnectFS_r(void) { - assert((programType != fileServer) && + osi_Assert((programType != fileServer) && (programType != salvager)); FSYNC_clientFinis(); VInit = 2; @@ -5672,7 +5667,7 @@ VAllocBitmapEntry_r(Error * ec, Volume * vp, /* No bit map entry--must grow bitmap */ bp = (byte *) realloc(index->bitmap, index->bitmapSize + VOLUME_BITMAP_GROWSIZE); - assert(bp != NULL); + osi_Assert(bp != NULL); index->bitmap = bp; bp += index->bitmapSize; memset(bp, 0, VOLUME_BITMAP_GROWSIZE); @@ -5764,13 +5759,13 @@ VGetBitmap_r(Error * ec, Volume * vp, VnodeClass class) VOL_UNLOCK; fdP = IH_OPEN(vip->handle); - assert(fdP != NULL); + osi_Assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r"); - assert(file != NULL); + osi_Assert(file != NULL); vnode = (VnodeDiskObject *) malloc(vcp->diskSize); - assert(vnode != NULL); + osi_Assert(vnode != NULL); size = OS_SIZE(fdP->fd_fd); - assert(size != -1); + osi_Assert(size != -1); nVnodes = (size <= vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize; vip->bitmapSize = ((nVnodes / 8) + 10) / 4 * 4; /* The 10 is a little extra so @@ -5780,10 +5775,10 @@ VGetBitmap_r(Error * ec, Volume * vp, VnodeClass class) * it that way */ #ifdef BITMAP_LATER BitMap = (byte *) calloc(1, vip->bitmapSize); - assert(BitMap != NULL); + osi_Assert(BitMap != NULL); #else /* BITMAP_LATER */ vip->bitmap = (byte *) calloc(1, vip->bitmapSize); - assert(vip->bitmap != NULL); + osi_Assert(vip->bitmap != NULL); vip->bitmapOffset = 0; #endif /* BITMAP_LATER */ if (STREAM_SEEK(file, vcp->diskSize, 0) != -1) { @@ -6180,7 +6175,7 @@ VAddToVolumeUpdateList_r(Error * ec, Volume * vp) sizeof(VolumeId) * updateSize); } } - assert(UpdateList != NULL); + osi_Assert(UpdateList != NULL); UpdateList[nUpdatedVolumes++] = V_id(vp); #endif /* !AFS_DEMAND_ATTACH_FS */ } @@ -6436,7 +6431,7 @@ VInitVLRU(void) queue_Init(&volume_LRU.q[i]); volume_LRU.q[i].len = 0; volume_LRU.q[i].busy = 0; - assert(pthread_cond_init(&volume_LRU.q[i].cv, NULL) == 0); + CV_INIT(&volume_LRU.q[i].cv, "vol lru", CV_DEFAULT, 0); } /* setup the timing constants */ @@ -6454,10 +6449,10 @@ VInitVLRU(void) /* start up the VLRU scanner */ volume_LRU.scanner_state = VLRU_SCANNER_STATE_OFFLINE; if (programType == fileServer) { - assert(pthread_cond_init(&volume_LRU.cv, NULL) == 0); - assert(pthread_attr_init(&attrs) == 0); - assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&tid, &attrs, &VLRU_ScannerThread, NULL) == 0); + CV_INIT(&volume_LRU.cv, "vol lru", CV_DEFAULT, 0); + osi_Assert(pthread_attr_init(&attrs) == 0); + osi_Assert(pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_create(&tid, &attrs, &VLRU_ScannerThread, NULL) == 0); } } @@ -6483,7 +6478,7 @@ VLRU_Init_Node_r(Volume * vp) if (!VLRU_enabled) return; - assert(queue_IsNotOnQueue(&vp->vlru)); + osi_Assert(queue_IsNotOnQueue(&vp->vlru)); vp->vlru.idx = VLRU_QUEUE_INVALID; } @@ -6627,7 +6622,7 @@ VLRU_UpdateAccess_r(Volume * vp) if (queue_IsNotOnQueue(&vp->vlru)) return; - assert(V_attachFlags(vp) & VOL_ON_VLRU); + osi_Assert(V_attachFlags(vp) & VOL_ON_VLRU); /* update the access timestamp */ vp->stats.last_get = FT_ApproxTime(); @@ -6760,7 +6755,7 @@ VLRU_ScannerThread(void * args) /* check to see if we've been asked to pause */ if (volume_LRU.scanner_state == VLRU_SCANNER_STATE_PAUSING) { volume_LRU.scanner_state = VLRU_SCANNER_STATE_PAUSED; - assert(pthread_cond_broadcast(&volume_LRU.cv) == 0); + CV_BROADCAST(&volume_LRU.cv); do { VOL_CV_WAIT(&volume_LRU.cv); } while (volume_LRU.scanner_state == VLRU_SCANNER_STATE_PAUSED); @@ -6836,7 +6831,7 @@ VLRU_ScannerThread(void * args) /* signal that scanner is down */ volume_LRU.scanner_state = VLRU_SCANNER_STATE_OFFLINE; - assert(pthread_cond_broadcast(&volume_LRU.cv) == 0); + CV_BROADCAST(&volume_LRU.cv); VOL_UNLOCK; return NULL; } @@ -6939,7 +6934,7 @@ VLRU_Demote_r(int idx) Volume ** salv_flag_vec = NULL; int salv_vec_offset = 0; - assert(idx == VLRU_QUEUE_MID || idx == VLRU_QUEUE_OLD); + osi_Assert(idx == VLRU_QUEUE_MID || idx == VLRU_QUEUE_OLD); /* get exclusive access to two chains, and drop the glock */ VLRU_Wait_r(&volume_LRU.q[idx-1]); @@ -7038,7 +7033,7 @@ VLRU_Scan_r(int idx) Volume * vp; int i, locked = 1; - assert(idx == VLRU_QUEUE_NEW || idx == VLRU_QUEUE_CANDIDATE); + osi_Assert(idx == VLRU_QUEUE_NEW || idx == VLRU_QUEUE_CANDIDATE); /* gain exclusive access to the idx VLRU */ VLRU_Wait_r(&volume_LRU.q[idx]); @@ -7129,7 +7124,7 @@ VCheckSoftDetachCandidate(Volume * vp, afs_uint32 thresh) idx = vp->vlru.idx; - assert(idx == VLRU_QUEUE_NEW); + osi_Assert(idx == VLRU_QUEUE_NEW); if (vp->stats.last_get <= thresh) { /* move to candidate pool */ @@ -7149,7 +7144,7 @@ VCheckSoftDetachCandidate(Volume * vp, afs_uint32 thresh) static void VLRU_BeginExclusive_r(struct VLRU_q * q) { - assert(q->busy == 0); + osi_Assert(q->busy == 0); q->busy = 1; } @@ -7157,9 +7152,9 @@ VLRU_BeginExclusive_r(struct VLRU_q * q) static void VLRU_EndExclusive_r(struct VLRU_q * q) { - assert(q->busy); + osi_Assert(q->busy); q->busy = 0; - assert(pthread_cond_broadcast(&q->cv) == 0); + CV_BROADCAST(&q->cv); } /* wait for another thread to end exclusive access on VLRU */ @@ -7181,7 +7176,7 @@ VSoftDetachVolume_r(Volume * vp, afs_uint32 thresh) afs_uint32 ts_save; int ret = 0; - assert(vp->vlru.idx == VLRU_QUEUE_CANDIDATE); + osi_Assert(vp->vlru.idx == VLRU_QUEUE_CANDIDATE); ts_save = vp->stats.last_get; if (ts_save > thresh) @@ -7236,7 +7231,7 @@ VSoftDetachVolume_r(Volume * vp, afs_uint32 thresh) vp = NULL; } else { /* pull it off the VLRU */ - assert(vp->vlru.idx == VLRU_QUEUE_CANDIDATE); + osi_Assert(vp->vlru.idx == VLRU_QUEUE_CANDIDATE); volume_LRU.q[VLRU_QUEUE_CANDIDATE].len--; queue_Remove(&vp->vlru); vp->vlru.idx = VLRU_QUEUE_INVALID; @@ -7298,7 +7293,7 @@ VInitVolumeHeaderCache(afs_uint32 howMany) volume_hdr_LRU.stats.used = howMany; volume_hdr_LRU.stats.attached = 0; hp = (struct volHeader *)(calloc(howMany, sizeof(struct volHeader))); - assert(hp != NULL); + osi_Assert(hp != NULL); while (howMany--) /* We are using ReleaseVolumeHeader to initialize the values on the header list @@ -7356,7 +7351,7 @@ GetVolumeHeader(Volume * vp) /* for volume utilities, we allocate volHeaders as needed */ if (!vp->header) { hd = (struct volHeader *)calloc(1, sizeof(*vp->header)); - assert(hd != NULL); + osi_Assert(hd != NULL); vp->header = hd; hd->back = vp; #ifdef AFS_DEMAND_ATTACH_FS @@ -7370,7 +7365,7 @@ GetVolumeHeader(Volume * vp) * still available. pull it off the lru and return */ hd = vp->header; queue_Remove(hd); - assert(hd->back == vp); + osi_Assert(hd->back == vp); #ifdef AFS_DEMAND_ATTACH_FS V_attachFlags(vp) &= ~(VOL_HDR_IN_LRU); #endif @@ -7384,7 +7379,7 @@ GetVolumeHeader(Volume * vp) /* LRU is empty, so allocate a new volHeader * this is probably indicative of a leak, so let the user know */ hd = (struct volHeader *)calloc(1, sizeof(struct volHeader)); - assert(hd != NULL); + osi_Assert(hd != NULL); if (!everLogged) { Log("****Allocated more volume headers, probably leak****\n"); everLogged = 1; @@ -7399,7 +7394,7 @@ GetVolumeHeader(Volume * vp) #ifdef AFS_DEMAND_ATTACH_FS /* if hd->back were in an exclusive state, then * its volHeader would not be on the LRU... */ - assert(!VIsExclusiveState(V_attachState(hd->back))); + osi_Assert(!VIsExclusiveState(V_attachState(hd->back))); #endif if (hd->diskstuff.inUse) { @@ -7629,12 +7624,12 @@ VInitVolumeHash(void) VolumeHashTable.Table = (VolumeHashChainHead *) calloc(VolumeHashTable.Size, sizeof(VolumeHashChainHead)); - assert(VolumeHashTable.Table != NULL); + osi_Assert(VolumeHashTable.Table != NULL); for (i=0; i < VolumeHashTable.Size; i++) { queue_Init(&VolumeHashTable.Table[i]); #ifdef AFS_DEMAND_ATTACH_FS - assert(pthread_cond_init(&VolumeHashTable.Table[i].chain_busy_cv, NULL) == 0); + CV_INIT(&VolumeHashTable.Table[i].chain_busy_cv, "vhash busy", CV_DEFAULT, 0); #endif /* AFS_DEMAND_ATTACH_FS */ } } @@ -7903,7 +7898,7 @@ VReorderHash_r(VolumeHashChainHead * head, Volume * pp, Volume * vp) static void VHashBeginExclusive_r(VolumeHashChainHead * head) { - assert(head->busy == 0); + osi_Assert(head->busy == 0); head->busy = 1; } @@ -7927,9 +7922,9 @@ VHashBeginExclusive_r(VolumeHashChainHead * head) static void VHashEndExclusive_r(VolumeHashChainHead * head) { - assert(head->busy); + osi_Assert(head->busy); head->busy = 0; - assert(pthread_cond_broadcast(&head->chain_busy_cv) == 0); + CV_BROADCAST(&head->chain_busy_cv); } /** @@ -8067,7 +8062,7 @@ DeleteVolumeFromVByPList_r(Volume * vp) static void VVByPListBeginExclusive_r(struct DiskPartition64 * dp) { - assert(dp->vol_list.busy == 0); + osi_Assert(dp->vol_list.busy == 0); dp->vol_list.busy = 1; } @@ -8091,9 +8086,9 @@ VVByPListBeginExclusive_r(struct DiskPartition64 * dp) static void VVByPListEndExclusive_r(struct DiskPartition64 * dp) { - assert(dp->vol_list.busy); + osi_Assert(dp->vol_list.busy); dp->vol_list.busy = 0; - assert(pthread_cond_broadcast(&dp->vol_list.cv) == 0); + CV_BROADCAST(&dp->vol_list.cv); } /** diff --git a/src/vol/volume.h b/src/vol/volume.h index d4ab62faf..fe70dbdd9 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -36,9 +36,9 @@ typedef bit32 FileOffset; /* Offset in this file */ #ifdef VOL_LOCK_DEBUG #define VOL_LOCK_ASSERT_HELD \ - assert(vol_glock_holder == pthread_self()) + osi_Assert(vol_glock_holder == pthread_self()) #define VOL_LOCK_ASSERT_UNHELD \ - assert(vol_glock_holder == 0) + osi_Assert(vol_glock_holder == 0) #define _VOL_LOCK_SET_HELD \ vol_glock_holder = pthread_self() #define _VOL_LOCK_SET_UNHELD \ @@ -62,7 +62,6 @@ typedef bit32 FileOffset; /* Offset in this file */ #ifdef AFS_PTHREAD_ENV -#include #include extern pthread_mutex_t vol_glock_mutex; extern pthread_mutex_t vol_trans_mutex; @@ -74,37 +73,31 @@ extern int vol_attach_threads; extern pthread_t vol_glock_holder; #define VOL_LOCK \ do { \ - assert(pthread_mutex_lock(&vol_glock_mutex) == 0); \ - assert(vol_glock_holder == 0); \ - vol_glock_holder = pthread_self(); \ + MUTEX_ENTER(&vol_glock_mutex); \ + VOL_LOCK_ASSERT_UNHELD; \ + _VOL_LOCK_SET_HELD; \ } while (0) #define VOL_UNLOCK \ do { \ VOL_LOCK_ASSERT_HELD; \ - vol_glock_holder = 0; \ - assert(pthread_mutex_unlock(&vol_glock_mutex) == 0); \ + _VOL_LOCK_SET_UNHELD; \ + MUTEX_EXIT(&vol_glock_mutex); \ } while (0) #define VOL_CV_WAIT(cv) \ do { \ VOL_LOCK_DBG_CV_WAIT_BEGIN; \ - assert(pthread_cond_wait((cv), &vol_glock_mutex) == 0); \ + CV_WAIT((cv), &vol_glock_mutex); \ VOL_LOCK_DBG_CV_WAIT_END; \ } while (0) #else /* !VOL_LOCK_DEBUG */ -#define VOL_LOCK \ - assert(pthread_mutex_lock(&vol_glock_mutex) == 0) -#define VOL_UNLOCK \ - assert(pthread_mutex_unlock(&vol_glock_mutex) == 0) -#define VOL_CV_WAIT(cv) assert(pthread_cond_wait((cv), &vol_glock_mutex) == 0) +#define VOL_LOCK MUTEX_ENTER(&vol_glock_mutex) +#define VOL_UNLOCK MUTEX_EXIT(&vol_glock_mutex) +#define VOL_CV_WAIT(cv) CV_WAIT((cv), &vol_glock_mutex) #endif /* !VOL_LOCK_DEBUG */ -#define VSALVSYNC_LOCK \ - assert(pthread_mutex_lock(&vol_salvsync_mutex) == 0) -#define VSALVSYNC_UNLOCK \ - assert(pthread_mutex_unlock(&vol_salvsync_mutex) == 0) -#define VTRANS_LOCK \ - assert(pthread_mutex_lock(&vol_trans_mutex) == 0) -#define VTRANS_UNLOCK \ - assert(pthread_mutex_unlock(&vol_trans_mutex) == 0) +#define VSALVSYNC_LOCK MUTEX_ENTER(&vol_salvsync_mutex) +#define VSALVSYNC_UNLOCK MUTEX_EXIT(&vol_salvsync_mutex) +#define VTRANS_LOCK MUTEX_ENTER(&vol_trans_mutex) +#define VTRANS_UNLOCK MUTEX_EXIT(&vol_trans_mutex) #else /* AFS_PTHREAD_ENV */ #define VOL_LOCK #define VOL_UNLOCK diff --git a/src/vol/volume_inline.h b/src/vol/volume_inline.h index acdc21dad..1c717aeb8 100644 --- a/src/vol/volume_inline.h +++ b/src/vol/volume_inline.h @@ -233,7 +233,7 @@ VVolLockType(int mode, int writeable) return 0; default: - assert(0 /* unknown checkout mode */); + osi_Assert(0 /* unknown checkout mode */); return 0; } } @@ -382,11 +382,11 @@ VWaitStateChange_r(Volume * vp) { VolState state_save = V_attachState(vp); - assert(vp->nWaiters || vp->nUsers); + osi_Assert(vp->nWaiters || vp->nUsers); do { VOL_CV_WAIT(&V_attachCV(vp)); } while (V_attachState(vp) == state_save); - assert(V_attachState(vp) != VOL_STATE_FREED); + osi_Assert(V_attachState(vp) != VOL_STATE_FREED); } /** @@ -403,11 +403,11 @@ VWaitStateChange_r(Volume * vp) static_inline void VWaitExclusiveState_r(Volume * vp) { - assert(vp->nWaiters || vp->nUsers); + osi_Assert(vp->nWaiters || vp->nUsers); while (VIsExclusiveState(V_attachState(vp))) { VOL_CV_WAIT(&V_attachCV(vp)); } - assert(V_attachState(vp) != VOL_STATE_FREED); + osi_Assert(V_attachState(vp) != VOL_STATE_FREED); } /** @@ -435,7 +435,7 @@ VChangeState_r(Volume * vp, VolState new_state) VStats.state_levels[new_state]++; V_attachState(vp) = new_state; - assert(pthread_cond_broadcast(&V_attachCV(vp)) == 0); + CV_BROADCAST(&V_attachCV(vp)); return old_state; } diff --git a/src/vol/vutil.c b/src/vol/vutil.c index e06564623..a8e5b25af 100644 --- a/src/vol/vutil.c +++ b/src/vol/vutil.c @@ -31,11 +31,7 @@ #endif #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include @@ -871,14 +867,6 @@ VWalkVolumeHeaders(struct DiskPartition64 *dp, const char *partpath, return code; } -#ifdef AFS_PTHREAD_ENV -# define AFS_LF_LOCK(lf) assert(pthread_mutex_lock(&((lf)->mutex)) == 0) -# define AFS_LF_UNLOCK(lf) assert(pthread_mutex_unlock(&((lf)->mutex)) == 0) -#else -# define AFS_LF_LOCK(lf) -# define AFS_LF_UNLOCK(lf) -#endif /* AFS_PTHREAD_ENV */ - /** * initialize a struct VLockFile. * @@ -892,9 +880,7 @@ VLockFileInit(struct VLockFile *lf, const char *path) memset(lf, 0, sizeof(*lf)); lf->path = strdup(path); lf->fd = INVALID_FD; -#ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_init(&lf->mutex, NULL) == 0); -#endif /* AFS_PTHREAD_ENV */ + MUTEX_INIT(&lf->mutex, "vlockfile", MUTEX_DEFAULT, 0); } #ifdef AFS_NT40_ENV @@ -1095,9 +1081,7 @@ _VUnlockFd(int fd, afs_uint32 offset) void VLockFileReinit(struct VLockFile *lf) { -#ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_lock(&lf->mutex) == 0); -#endif /* AFS_PTHREAD_ENV */ + MUTEX_ENTER(&lf->mutex); if (lf->fd != INVALID_FD) { _VCloseFd(lf->fd); @@ -1106,9 +1090,7 @@ VLockFileReinit(struct VLockFile *lf) lf->refcount = 0; -#ifdef AFS_PTHREAD_ENV - assert(pthread_mutex_unlock(&lf->mutex) == 0); -#endif /* AFS_PTHREAD_ENV */ + MUTEX_EXIT(&lf->mutex); } /** @@ -1138,31 +1120,31 @@ VLockFileLock(struct VLockFile *lf, afs_uint32 offset, int locktype, int nonbloc { int code; - assert(locktype == READ_LOCK || locktype == WRITE_LOCK); + osi_Assert(locktype == READ_LOCK || locktype == WRITE_LOCK); - AFS_LF_LOCK(lf); + MUTEX_ENTER(&lf->mutex); if (lf->fd == INVALID_FD) { lf->fd = _VOpenPath(lf->path); if (lf->fd == INVALID_FD) { - AFS_LF_UNLOCK(lf); + MUTEX_EXIT(&lf->mutex); return EIO; } } lf->refcount++; - AFS_LF_UNLOCK(lf); + MUTEX_EXIT(&lf->mutex); code = _VLockFd(lf->fd, offset, locktype, nonblock); if (code) { - AFS_LF_LOCK(lf); + MUTEX_ENTER(&lf->mutex); if (--lf->refcount < 1) { _VCloseFd(lf->fd); lf->fd = INVALID_FD; } - AFS_LF_UNLOCK(lf); + MUTEX_EXIT(&lf->mutex); } return code; @@ -1171,9 +1153,9 @@ VLockFileLock(struct VLockFile *lf, afs_uint32 offset, int locktype, int nonbloc void VLockFileUnlock(struct VLockFile *lf, afs_uint32 offset) { - AFS_LF_LOCK(lf); + MUTEX_ENTER(&lf->mutex); - assert(lf->fd != INVALID_FD); + osi_Assert(lf->fd != INVALID_FD); if (--lf->refcount < 1) { _VCloseFd(lf->fd); @@ -1182,7 +1164,7 @@ VLockFileUnlock(struct VLockFile *lf, afs_uint32 offset) _VUnlockFd(lf->fd, offset); } - AFS_LF_UNLOCK(lf); + MUTEX_EXIT(&lf->mutex); } #ifdef AFS_DEMAND_ATTACH_FS @@ -1196,11 +1178,11 @@ VLockFileUnlock(struct VLockFile *lf, afs_uint32 offset) void VDiskLockInit(struct VDiskLock *dl, struct VLockFile *lf, afs_uint32 offset) { - assert(lf); + osi_Assert(lf); memset(dl, 0, sizeof(*dl)); Lock_Init(&dl->rwlock); - assert(pthread_mutex_init(&dl->mutex, NULL) == 0); - assert(pthread_cond_init(&dl->cv, NULL) == 0); + MUTEX_INIT(&dl->mutex, "disklock", MUTEX_DEFAULT, 0); + CV_INIT(&dl->cv, "disklock cv", CV_DEFAULT, 0); dl->lockfile = lf; dl->offset = offset; } @@ -1231,7 +1213,7 @@ int VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) { int code = 0; - assert(locktype == READ_LOCK || locktype == WRITE_LOCK); + osi_Assert(locktype == READ_LOCK || locktype == WRITE_LOCK); if (nonblock) { if (locktype == READ_LOCK) { @@ -1250,7 +1232,7 @@ VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) ObtainWriteLock(&dl->rwlock); } - assert(pthread_mutex_lock(&dl->mutex) == 0); + MUTEX_ENTER(&dl->mutex); if ((dl->flags & VDISKLOCK_ACQUIRING)) { /* Some other thread is waiting to acquire an fs lock. If nonblock=1, @@ -1261,7 +1243,7 @@ VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) code = EBUSY; } else { while ((dl->flags & VDISKLOCK_ACQUIRING)) { - assert(pthread_cond_wait(&dl->cv, &dl->mutex) == 0); + CV_WAIT(&dl->cv, &dl->mutex); } } } @@ -1278,9 +1260,9 @@ VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) /* mark that we are waiting on the fs lock */ dl->flags |= VDISKLOCK_ACQUIRING; - assert(pthread_mutex_unlock(&dl->mutex) == 0); + MUTEX_EXIT(&dl->mutex); code = VLockFileLock(dl->lockfile, dl->offset, locktype, nonblock); - assert(pthread_mutex_lock(&dl->mutex) == 0); + MUTEX_ENTER(&dl->mutex); dl->flags &= ~VDISKLOCK_ACQUIRING; @@ -1288,7 +1270,7 @@ VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) dl->flags |= VDISKLOCK_ACQUIRED; } - assert(pthread_cond_broadcast(&dl->cv) == 0); + CV_BROADCAST(&dl->cv); } } @@ -1304,7 +1286,7 @@ VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) ++dl->lockers; } - assert(pthread_mutex_unlock(&dl->mutex) == 0); + MUTEX_EXIT(&dl->mutex); return code; } @@ -1322,10 +1304,10 @@ VGetDiskLock(struct VDiskLock *dl, int locktype, int nonblock) void VReleaseDiskLock(struct VDiskLock *dl, int locktype) { - assert(locktype == READ_LOCK || locktype == WRITE_LOCK); + osi_Assert(locktype == READ_LOCK || locktype == WRITE_LOCK); - assert(pthread_mutex_lock(&dl->mutex) == 0); - assert(dl->lockers > 0); + MUTEX_ENTER(&dl->mutex); + osi_Assert(dl->lockers > 0); if (--dl->lockers < 1) { /* no threads are holding this lock anymore, so we can release the @@ -1334,7 +1316,7 @@ VReleaseDiskLock(struct VDiskLock *dl, int locktype) dl->flags &= ~VDISKLOCK_ACQUIRED; } - assert(pthread_mutex_unlock(&dl->mutex) == 0); + MUTEX_EXIT(&dl->mutex); if (locktype == READ_LOCK) { ReleaseReadLock(&dl->rwlock); diff --git a/src/volser/Makefile.in b/src/volser/Makefile.in index e4a2d3b53..3ffc825da 100644 --- a/src/volser/Makefile.in +++ b/src/volser/Makefile.in @@ -50,10 +50,11 @@ VOLDUMP_LIBS = \ ../vol/vlib.a \ ${TOP_LIBDIR}/libcmd.a \ ${TOP_LIBDIR}/util.a \ - ${TOP_LIBDIR}/libsys.a \ ${TOP_LIBDIR}/libcom_err.a \ ${TOP_LIBDIR}/libdir.a \ + ${TOP_LIBDIR}/librx.a \ ${TOP_LIBDIR}/liblwp.a \ + ${TOP_LIBDIR}/libsys.a \ ${TOP_LIBDIR}/libacl.a VSOBJS=vsprocs.o vsutils.o lockprocs.o volint.xdr.o volerr.o diff --git a/src/volser/dumpstuff.c b/src/volser/dumpstuff.c index 78e28d299..30c3c20e2 100644 --- a/src/volser/dumpstuff.c +++ b/src/volser/dumpstuff.c @@ -26,11 +26,7 @@ #include #endif #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -177,7 +173,7 @@ iod_Write(struct iod *iodp, char *buf, int nbytes) int code, i; int one_success = 0; - assert((iodp->call && iodp->ncalls == 1 && !iodp->calls) + osi_Assert((iodp->call && iodp->ncalls == 1 && !iodp->calls) || (!iodp->call && iodp->ncalls >= 1 && iodp->calls)); if (iodp->call) { @@ -999,15 +995,15 @@ DumpVnodeIndex(struct iod *iodp, Volume * vp, VnodeClass class, int vnodeIndex; fdP = IH_OPEN(vp->vnodeIndex[class].handle); - assert(fdP != NULL); + osi_Assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r+"); - assert(file != NULL); + osi_Assert(file != NULL); size = OS_SIZE(fdP->fd_fd); - assert(size != -1); + osi_Assert(size != -1); nVnodes = (size / vcp->diskSize) - 1; if (nVnodes > 0) { - assert((nVnodes + 1) * vcp->diskSize == size); - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); + osi_Assert((nVnodes + 1) * vcp->diskSize == size); + osi_Assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); } else nVnodes = 0; for (vnodeIndex = 0; @@ -1166,7 +1162,7 @@ ProcessIndex(Volume * vp, VnodeClass class, afs_int32 ** Bufp, int *sizep, OS_SYNC(afile->str_fd); } else { size = OS_SIZE(fdP->fd_fd); - assert(size != -1); + osi_Assert(size != -1); nVnodes = (size <= vcp->diskSize ? 0 : size - vcp->diskSize) >> vcp->logSize; @@ -1887,15 +1883,15 @@ SizeDumpVnodeIndex(struct iod *iodp, Volume * vp, VnodeClass class, int vnodeIndex; fdP = IH_OPEN(vp->vnodeIndex[class].handle); - assert(fdP != NULL); + osi_Assert(fdP != NULL); file = FDH_FDOPEN(fdP, "r+"); - assert(file != NULL); + osi_Assert(file != NULL); size = OS_SIZE(fdP->fd_fd); - assert(size != -1); + osi_Assert(size != -1); nVnodes = (size / vcp->diskSize) - 1; if (nVnodes > 0) { - assert((nVnodes + 1) * vcp->diskSize == size); - assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); + osi_Assert((nVnodes + 1) * vcp->diskSize == size); + osi_Assert(STREAM_SEEK(file, vcp->diskSize, 0) == 0); } else nVnodes = 0; for (vnodeIndex = 0; diff --git a/src/volser/physio.c b/src/volser/physio.c index e9025bb2a..95467d464 100644 --- a/src/volser/physio.c +++ b/src/volser/physio.c @@ -167,5 +167,5 @@ void Die(char *msg) { printf("%s\n", msg); - assert(1 == 2); + osi_Panic("%s\n", msg); } diff --git a/src/volser/vol_split.c b/src/volser/vol_split.c index 71e285df0..c4480801c 100644 --- a/src/volser/vol_split.c +++ b/src/volser/vol_split.c @@ -11,11 +11,7 @@ #if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV) #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #ifdef AFS_NT40_ENV #include #include diff --git a/src/volser/volmain.c b/src/volser/volmain.c index cbe53fa1b..4d837d481 100644 --- a/src/volser/volmain.c +++ b/src/volser/volmain.c @@ -31,11 +31,7 @@ #include #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -478,10 +474,10 @@ main(int argc, char **argv) #ifdef AFS_PTHREAD_ENV pthread_t tid; pthread_attr_t tattr; - assert(pthread_attr_init(&tattr) == 0); - assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); + osi_Assert(pthread_attr_init(&tattr) == 0); + osi_Assert(pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_DETACHED) == 0); - assert(pthread_create(&tid, &tattr, BKGLoop, NULL) == 0); + osi_Assert(pthread_create(&tid, &tattr, BKGLoop, NULL) == 0); #else PROCESS pid; LWP_CreateProcess(BKGLoop, 16*1024, 3, 0, "vol bkg daemon", &pid); diff --git a/src/volser/volprocs.c b/src/volser/volprocs.c index 8155a3998..ce09cbf58 100644 --- a/src/volser/volprocs.c +++ b/src/volser/volprocs.c @@ -34,11 +34,7 @@ #include #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include #include @@ -349,14 +345,14 @@ ViceCreateRoot(Volume *vp) IH_CREATE(V_linkHandle(vp), V_device(vp), VPartitionPath(V_partition(vp)), nearInode, V_parentId(vp), 1, 1, 0); - assert(VALID_INO(inodeNumber)); + osi_Assert(VALID_INO(inodeNumber)); SetSalvageDirHandle(&dir, V_parentId(vp), vp->device, inodeNumber); did.Volume = V_id(vp); did.Vnode = (VnodeId) 1; did.Unique = 1; - assert(!(MakeDir(&dir, (afs_int32 *)&did, (afs_int32 *)&did))); + osi_Assert(!(MakeDir(&dir, (afs_int32 *)&did, (afs_int32 *)&did))); DFlush(); /* flush all modified dir buffers out */ DZap((afs_int32 *)&dir); /* Remove all buffers for this dir */ length = Length(&dir); /* Remember size of this directory */ @@ -396,11 +392,11 @@ ViceCreateRoot(Volume *vp) IH_INIT(h, vp->device, V_parentId(vp), vp->vnodeIndex[vLarge].handle->ih_ino); fdP = IH_OPEN(h); - assert(fdP != NULL); + osi_Assert(fdP != NULL); off = FDH_SEEK(fdP, vnodeIndexOffset(vcp, 1), SEEK_SET); - assert(off >= 0); + osi_Assert(off >= 0); nBytes = FDH_WRITE(fdP, vnode, SIZEOF_LARGEDISKVNODE); - assert(nBytes == SIZEOF_LARGEDISKVNODE); + osi_Assert(nBytes == SIZEOF_LARGEDISKVNODE); FDH_REALLYCLOSE(fdP); IH_RELEASE(h); VNDISK_GET_LEN(length, vnode); diff --git a/src/volser/volser.p.h b/src/volser/volser.p.h index eb974b77c..e174f9f47 100644 --- a/src/volser/volser.p.h +++ b/src/volser/volser.p.h @@ -10,8 +10,8 @@ #ifndef _VOLSER_ #define _VOLSER_ 1 +#include #ifdef AFS_PTHREAD_ENV -#include #include #endif @@ -71,13 +71,13 @@ struct volser_trans { #ifdef AFS_PTHREAD_ENV #define VTRANS_OBJ_LOCK_INIT(tt) \ - assert(pthread_mutex_init(&((tt)->lock),NULL) == 0) + MUTEX_INIT(&((tt)->lock), "vtrans obj", MUTEX_DEFAULT, 0); #define VTRANS_OBJ_LOCK_DESTROY(tt) \ - assert(pthread_mutex_destroy(&((tt)->lock)) == 0) + MUTEX_DESTROY(&((tt)->lock)) #define VTRANS_OBJ_LOCK(tt) \ - assert(pthread_mutex_lock(&((tt)->lock)) == 0) + MUTEX_ENTER(&((tt)->lock)) #define VTRANS_OBJ_UNLOCK(tt) \ - assert(pthread_mutex_unlock(&((tt)->lock)) == 0) + MUTEX_EXIT(&((tt)->lock)) #else #define VTRANS_OBJ_LOCK_INIT(tt) #define VTRANS_OBJ_LOCK_DESTROY(tt) diff --git a/src/volser/voltrans.c b/src/volser/voltrans.c index 3fe499d8c..6a0f365e8 100644 --- a/src/volser/voltrans.c +++ b/src/volser/voltrans.c @@ -40,11 +40,7 @@ #include #include #include -#ifdef AFS_PTHREAD_ENV -#include -#else /* AFS_PTHREAD_ENV */ #include -#endif /* AFS_PTHREAD_ENV */ #include #include #include