#include "afsd.h"
-#include <assert.h>
-#include <potpourri.h>
+#include <afs/afs_assert.h>
#include <afs/afsutil.h>
#include <stdlib.h>
#include <stdio.h>
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
}
if (as->parms[8].items) {
/* -nosettime */
- cacheSetTime = FALSE;
+ cacheSetTime = 0;
}
if (as->parms[9].items) {
/* -verbose */
}
if (as->parms[32].items) {
/* -settime */
- cacheSetTime = TRUE;
+ cacheSetTime = 1;
}
/* set rx_extraPackets */
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);
#ifdef AFS_MAXVCOUNT_ENV
else {
/* -dynamic-vcaches */
- afsd_dynamic_vcaches = TRUE;
+ afsd_dynamic_vcaches = 1;
}
if (afsd_verbose)
#include "afsd.h"
#include <assert.h>
-#include <potpourri.h>
#include <afs/afsutil.h>
#include <stdlib.h>
#include <stdio.h>
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
/* 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))
}
#endif
-#ifdef AFS_PTHREAD_ENV
- pthread_mutex_lock(&audit_lock);
-#endif
+ MUTEX_ENTER(&audit_lock);
#ifdef AFS_AIX32_ENV
bufferPtr = BUFFER;
printbuf(0, audEvent, afsName, hostId, errCode, vaList);
}
#endif
-#ifdef AFS_PTHREAD_ENV
- pthread_mutex_unlock(&audit_lock);
-#endif
+ MUTEX_EXIT(&audit_lock);
return 0;
}
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)
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
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)
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
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)
/* 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 =
#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 =
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)
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
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)
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)
#include <rx/xdr.h>
#include <afs/afsint.h>
#include <stdio.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else
#include <afs/afs_assert.h>
-#endif
#include <afs/prs_fs.h>
#include <afs/nfs.h>
#include <string.h>
#include <sys/types.h>
#include <time.h>
#include <signal.h>
-#include <assert.h>
#include <afs/afsutil.h>
#include "kauth.h"
#include "kalog.h"
rx_SetConnHardDeadTime @272
rx_SetConnIdleDeadTime @273
rx_InterruptCall @274
+ osi_Panic @275
; for performance testing
rx_TSFPQGlobSize @2001 DATA
#include <stdio.h>
-#include <potpourri.h>
#ifdef AFS_AIX32_ENV
#include <signal.h>
#endif
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
#include <afsconfig.h>
#include <afs/param.h>
-
-#ifndef AFS_PTHREAD_ENV
+#ifdef AFS_PTHREAD_ENV
#include <afs/afs_assert.h>
-#else /* AFS_PTHREAD_ENV */
+/* can't include this in lwp, rx hasn't built yet */
+#include <rx/rx.h>
+#else
#include <assert.h>
-#endif /* AFS_PTHRED_ENV */
+#endif
+
#include "lwp.h"
#include "lock.h"
#include <stdio.h>
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
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 */
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 */
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 */
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 */
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 */
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 */
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 */
#define ENDMAC } while (0)
#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
#include <pthread.h>
-#define LOCK_LOCK(A) assert(pthread_mutex_lock(&(A)->mutex) == 0)
-#define LOCK_UNLOCK(A) assert(pthread_mutex_unlock(&(A)->mutex) == 0)
+#include <afs/afs_assert.h>
+/* can't include in non-lwp case; rx builds later */
+#include <rx/rx.h>
+#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)
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;
{
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
{
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 */
}
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);
(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;
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;
}
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;
}
/* 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();
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;
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;
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);
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;
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;
* 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()
}
char
-empty(q)
- queue *q;
+empty(queue *q)
{
return (q->prev == q && q->next == q);
}
}
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;
* 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 */
#include "AFS_component_version_number.c"
-main(argc, argv)
- int argc;
- char **argv;
+int
+main(int argc, char **argv)
{
int nreaders, i;
PROCESS pid;
#include <afsconfig.h>
#include <afs/param.h>
-#include <assert.h>
#include <sys/types.h>
#include <lock.h>
#include <ubik.h>
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));
return 0;
if (aid == tentry.id)
return entry;
- assert(entry != tentry.nextID);
+ osi_Assert(entry != tentry.nextID);
entry = tentry.nextID;
}
return 0;
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));
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;
if (code)
return PRDBFAIL;
while (aid != tentry.id) {
- assert(trail != current);
+ osi_Assert(trail != current);
trail = current;
current = tentry.nextID;
if (current == 0)
if (code)
return PRDBFAIL;
while (strcmp(aname, tentry.name)) {
- assert(trail != current);
+ osi_Assert(trail != current);
trail = current;
current = tentry.nextName;
if (current == 0)
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);
#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 */
des_pcbc_encrypt;
ktohl;
life_to_time;
+ osi_AssertFailU;
+ osi_Panic;
rx_DestroyConnection;
rx_EndCall;
rx_Finalize;
rx_GetIFInfo;
rx_GetSpecific;
rx_Init;
+ rx_InitHost;
rx_KeyCreate;
rx_NewCall;
rx_NewConnection;
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
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
/* 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
#include <string.h>
#include <stdarg.h>
#include <errno.h>
-#include <assert.h>
#ifdef AFS_NT40_ENV
#include <winsock2.h>
(*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
}
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
(*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
break;
}
}
- assert(i); /* at least one interface address for this server */
+ osi_Assert(i); /* at least one interface address for this server */
#ifdef AFS_PTHREAD_ENV
DBRELE(ubik_dbase);
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
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 */
*/
#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);
/* 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 */ ,
#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 */
/* 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);
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 */
#define CFLastFailed 1 /*!< last call failed to this guy (to detect down hosts) */
/*\}*/
+#include <afs/afs_assert.h>
#ifdef AFS_PTHREAD_ENV
#include <pthread.h>
-#include <assert.h>
#else
#include <lwp.h>
#endif
};
#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)
/*! \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))
return 0;
}
+#include <afs/afs_assert.h>
#ifdef AFS_PTHREAD_ENV
#include <pthread.h>
-#include <assert.h>
static pthread_once_t random_once = PTHREAD_ONCE_INIT;
static int called_afs_random_once;
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;
}
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
${TOP_INCDIR}/afs/work_queue.h \
${TOP_INCDIR}/afs/work_queue_types.h \
${TOP_INCDIR}/afs/thread_pool.h \
- ${TOP_INCDIR}/afs/thread_pool_types.h \
- ${TOP_INCDIR}/potpourri.h
+ ${TOP_INCDIR}/afs/thread_pool_types.h
all: ${includes} \
${TOP_LIBDIR}/util.a \
${TOP_INCDIR}/afs/thread_pool_types.h: ${srcdir}/thread_pool_types.h
${INSTALL_DATA} $? $@
-${TOP_INCDIR}/potpourri.h: ${srcdir}/potpourri.h
- ${INSTALL_DATA} $? $@
-
${TOP_LIBDIR}/util.a: util.a
${INSTALL_DATA} $? $@
${INSTALL_DATA} ${srcdir}/work_queue_types.h ${DESTDIR}${includedir}/afs/work_queue_types.h
${INSTALL_DATA} ${srcdir}/thread_pool.h ${DESTDIR}${includedir}/afs/thread_pool.h
${INSTALL_DATA} ${srcdir}/thread_pool_types.h ${DESTDIR}${includedir}/afs/thread_pool_types.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
${INSTALL_DATA} ${srcdir}/work_queue_types.h ${DEST}/include/afs/work_queue_types.h
${INSTALL_DATA} ${srcdir}/thread_pool.h ${DEST}/include/afs/thread_pool.h
${INSTALL_DATA} ${srcdir}/thread_pool_types.h ${DEST}/include/afs/thread_pool_types.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
#include <rx/rx.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else
#include "afs_assert.h"
-#endif
#include "afsutil.h"
#include <afs/dirpath.h>
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;
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 =
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;
+++ /dev/null
-/*
- * 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
#ifdef AFS_PTHREAD_ENV
#include <pthread.h>
-#include <assert.h>
+#include <afs/afs_assert.h>
typedef struct {
pthread_mutex_t mut;
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
# include <stdint.h>
#endif
#if defined(AFS_PTHREAD_ENV)
-#include <assert.h>
+#include <afs/afs_assert.h>
+/* can't include rx when we are libutil; it's too early */
+#include <rx/rx.h>
#include <pthread.h>
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"
#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;
struct afs_thread_pool * pool = worker->pool;
/* register worker with pool */
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
queue_Append(&pool->thread_list, worker);
pool->nthreads++;
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
/* call high-level entry point */
worker->ret = (*pool->entry)(pool, worker, pool->work_queue, pool->rock);
/* adjust pool live thread count */
- assert(pthread_mutex_lock(&pool->lock) == 0);
- assert(pool->nthreads);
+ MUTEX_ENTER(&pool->lock);
+ osi_Assert(pool->nthreads);
queue_Remove(worker);
pool->nthreads--;
if (!pool->nthreads) {
- assert(pthread_cond_broadcast(&pool->shutdown_cv) == 0);
+ CV_BROADCAST(&pool->shutdown_cv);
pool->state = AFS_TP_STATE_STOPPED;
}
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
_afs_tp_worker_free(worker);
worker->pool = pool;
worker->req_shutdown = 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);
ret = pthread_create(&worker->tid, &attrs, &_afs_tp_worker_run, worker);
}
pool = *pool_out;
- assert(pthread_mutex_init(&pool->lock, NULL) == 0);
- assert(pthread_cond_init(&pool->shutdown_cv, NULL) == 0);
+ MUTEX_INIT(&pool->lock, "pool", MUTEX_DEFAULT, 0);
+ CV_INIT(&pool->shutdown_cv, "pool shutdown", CV_DEFAULT, 0);
queue_Init(&pool->thread_list);
pool->work_queue = queue;
pool->entry = &_afs_tp_worker_default;
{
int ret = 0;
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
switch (pool->state) {
case AFS_TP_STATE_INIT:
case AFS_TP_STATE_STOPPED:
default:
ret = AFS_TP_ERROR;
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
}
return ret;
{
int ret = 0;
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
if (pool->state != AFS_TP_STATE_INIT) {
ret = AFS_TP_ERROR;
} else {
pool->max_threads = threads;
}
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
return ret;
}
{
int ret = 0;
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
if (pool->state != AFS_TP_STATE_INIT) {
ret = AFS_TP_ERROR;
} else {
pool->entry = entry;
pool->rock = rock;
}
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
return ret;
}
struct afs_thread_pool_worker * worker;
afs_uint32 i;
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
if (pool->state != AFS_TP_STATE_INIT) {
ret = AFS_TP_ERROR;
goto done_sync;
}
pool->state = AFS_TP_STATE_STARTING;
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
for (i = 0; i < pool->max_threads; i++) {
code = _afs_tp_worker_start(pool, &worker);
}
}
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
pool->state = AFS_TP_STATE_RUNNING;
done_sync:
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
return ret;
}
int ret = 0;
struct afs_thread_pool_worker * worker, *nn;
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
if (pool->state == AFS_TP_STATE_STOPPED
|| pool->state == AFS_TP_STATE_STOPPING) {
goto done_stopped;
pool->state = AFS_TP_STATE_STOPPED;
}
/* need to drop lock to get a membar here */
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
ret = afs_wq_shutdown(pool->work_queue);
if (ret) {
goto error;
}
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
done_stopped:
if (block) {
while (pool->nthreads) {
- assert(pthread_cond_wait(&pool->shutdown_cv,
- &pool->lock) == 0);
+ CV_WAIT(&pool->shutdown_cv, &pool->lock);
}
}
done_sync:
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
error:
return ret;
{
int ret;
- assert(pthread_mutex_lock(&pool->lock) == 0);
+ MUTEX_ENTER(&pool->lock);
ret = (pool->state == AFS_TP_STATE_RUNNING);
- assert(pthread_mutex_unlock(&pool->lock) == 0);
+ MUTEX_EXIT(&pool->lock);
return ret;
}
old_state = node->state;
node->state = new_state;
- assert(pthread_cond_broadcast(&node->state_cv) == 0);
+ CV_BROADCAST(&node->state_cv);
return old_state;
}
_afs_wq_node_state_wait_busy(struct afs_work_queue_node * node)
{
while (node->state == AFS_WQ_NODE_STATE_BUSY) {
- assert(pthread_cond_wait(&node->state_cv,
- &node->lock) == 0);
+ CV_WAIT(&node->state_cv, &node->lock);
}
return 0;
}
}
- code = pthread_mutex_trylock(&ml->nodes[1].node->lock);
- if (!code) {
+ code = MUTEX_TRYENTER(&ml->nodes[1].node->lock);
+ if (code) {
/* success */
goto done;
}
/* setup for main loop */
- assert(pthread_mutex_unlock(&ml->nodes[0].node->lock) == 0);
+ MUTEX_EXIT(&ml->nodes[0].node->lock);
}
/*
delay.tv_nsec = 500 + rand() % 500;
while (1) {
- assert(pthread_mutex_lock(&ml->nodes[first].node->lock) == 0);
+ MUTEX_ENTER(&ml->nodes[first].node->lock);
if ((first != 0) || !ml->nodes[0].busy_held) {
ret = _afs_wq_node_state_wait_busy(ml->nodes[first].node);
if (ret) {
/* cleanup */
if (!ml->nodes[0].lock_held || first) {
- assert(pthread_mutex_unlock(&ml->nodes[first].node->lock) == 0);
+ MUTEX_EXIT(&ml->nodes[first].node->lock);
if (ml->nodes[0].lock_held) {
/* on error, return with locks in same state as before call */
- assert(pthread_mutex_lock(&ml->nodes[0].node->lock) == 0);
+ MUTEX_ENTER(&ml->nodes[0].node->lock);
}
}
goto error;
* a non-blocking state check. if we meet any contention,
* we must drop back and start again.
*/
- code = pthread_mutex_trylock(&ml->nodes[second].node->lock);
- if (!code) {
+ code = MUTEX_TRYENTER(&ml->nodes[second].node->lock);
+ if (code) {
if (((second == 0) && (ml->nodes[0].busy_held)) ||
!_afs_wq_node_state_is_busy(ml->nodes[second].node)) {
/* success */
break;
} else {
- assert(pthread_mutex_unlock(&ml->nodes[second].node->lock) == 0);
+ MUTEX_EXIT(&ml->nodes[second].node->lock);
}
}
* drop locks, use exponential backoff,
* try acquiring in the opposite order
*/
- assert(pthread_mutex_unlock(&ml->nodes[first].node->lock) == 0);
+ MUTEX_EXIT(&ml->nodes[first].node->lock);
nanosleep(&delay, NULL);
if (delay.tv_nsec <= 65536000) { /* max backoff delay of ~131ms */
delay.tv_nsec <<= 1;
afs_wq_node_list_id_t id)
{
queue_Init(&list->list);
- assert(pthread_mutex_init(&list->lock, NULL) == 0);
- assert(pthread_cond_init(&list->cv, NULL) == 0);
+ MUTEX_INIT(&list->lock, "list", MUTEX_DEFAULT, 0);
+ CV_INIT(&list->cv, "list", CV_DEFAULT, 0);
list->qidx = id;
list->shutdown = 0;
goto error;
}
- assert(pthread_mutex_destroy(&list->lock) == 0);
- assert(pthread_cond_destroy(&list->cv) == 0);
+ MUTEX_DESTROY(&list->lock);
+ CV_DESTROY(&list->cv);
error:
return ret;
int ret = 0;
struct afs_work_queue_node *node, *nnode;
- assert(pthread_mutex_lock(&list->lock) == 0);
+ MUTEX_ENTER(&list->lock);
list->shutdown = 1;
for (queue_Scan(&list->list, node, nnode, afs_work_queue_node)) {
}
}
- assert(pthread_cond_broadcast(&list->cv) == 0);
- assert(pthread_mutex_unlock(&list->lock) == 0);
+ CV_BROADCAST(&list->cv);
+ MUTEX_EXIT(&list->lock);
return ret;
}
}
/* deal with lock inversion */
- code = pthread_mutex_trylock(&list->lock);
- if (code) {
+ code = MUTEX_TRYENTER(&list->lock);
+ if (!code) {
/* contended */
_afs_wq_node_state_change(node, AFS_WQ_NODE_STATE_BUSY);
- assert(pthread_mutex_unlock(&node->lock) == 0);
- assert(pthread_mutex_lock(&list->lock) == 0);
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
+ MUTEX_ENTER(&list->lock);
+ MUTEX_ENTER(&node->lock);
/* assert state of the world (we set busy, so this should never happen) */
- assert(queue_IsNotOnQueue(node));
+ osi_Assert(queue_IsNotOnQueue(node));
}
if (list->shutdown) {
goto error_unlock;
}
- assert(node->qidx == AFS_WQ_NODE_LIST_NONE);
+ osi_Assert(node->qidx == AFS_WQ_NODE_LIST_NONE);
if (queue_IsEmpty(&list->list)) {
/* wakeup a dequeue thread */
- assert(pthread_cond_signal(&list->cv) == 0);
+ CV_SIGNAL(&list->cv);
}
queue_Append(&list->list, node);
node->qidx = list->qidx;
_afs_wq_node_state_change(node, state);
error_unlock:
- assert(pthread_mutex_unlock(&node->lock) == 0);
- assert(pthread_mutex_unlock(&list->lock) == 0);
+ MUTEX_EXIT(&node->lock);
+ MUTEX_EXIT(&list->lock);
error:
return ret;
int ret = 0;
struct afs_work_queue_node * node;
- assert(pthread_mutex_lock(&list->lock) == 0);
+ MUTEX_ENTER(&list->lock);
if (list->shutdown) {
*node_out = NULL;
ret = EINTR;
goto done_sync;
}
- assert(pthread_cond_wait(&list->cv,
- &list->lock) == 0);
+ CV_WAIT(&list->cv, &list->lock);
}
*node_out = node = queue_First(&list->list, afs_work_queue_node);
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
queue_Remove(node);
node->qidx = AFS_WQ_NODE_LIST_NONE;
_afs_wq_node_state_change(node, state);
done_sync:
- assert(pthread_mutex_unlock(&list->lock) == 0);
+ MUTEX_EXIT(&list->lock);
return ret;
}
}
if (list) {
- code = pthread_mutex_trylock(&list->lock);
- if (code) {
+ code = MUTEX_TRYENTER(&list->lock);
+ if (!code) {
/* contended */
_afs_wq_node_state_change(node,
AFS_WQ_NODE_STATE_BUSY);
- assert(pthread_mutex_unlock(&node->lock) == 0);
- assert(pthread_mutex_lock(&list->lock) == 0);
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
+ MUTEX_ENTER(&list->lock);
+ MUTEX_ENTER(&node->lock);
if (node->qidx == AFS_WQ_NODE_LIST_NONE) {
/* raced */
_afs_wq_node_state_change(node, next_state);
done_sync:
- assert(pthread_mutex_unlock(&list->lock) == 0);
+ MUTEX_EXIT(&list->lock);
}
error:
nd,
afs_work_queue_dep_node)) {
- assert(pthread_mutex_lock(&dep->child->lock) == 0);
+ MUTEX_ENTER(&dep->child->lock);
node_unlock = dep->child;
/* We need to get a ref on child here, since _afs_wq_dep_unlink_r may
if (node_put) {
_afs_wq_node_put_r(node_put, 1);
} else if (node_unlock) {
- assert(pthread_mutex_unlock(&node_unlock->lock) == 0);
+ MUTEX_EXIT(&node_unlock->lock);
}
node_put = node_unlock = NULL;
/* skip unscheduled nodes */
if (dep->child->queue == NULL) {
- assert(pthread_mutex_unlock(&dep->child->lock) == 0);
+ MUTEX_EXIT(&dep->child->lock);
continue;
}
ret = _afs_wq_node_list_remove(dep->child,
AFS_WQ_NODE_STATE_BUSY);
if (ret) {
- assert(pthread_mutex_unlock(&dep->child->lock) == 0);
+ MUTEX_EXIT(&dep->child->lock);
goto error;
}
dep->child,
cns);
if (ret) {
- assert(pthread_mutex_unlock(&dep->child->lock) == 0);
+ MUTEX_EXIT(&dep->child->lock);
goto error;
}
}
- assert(pthread_mutex_unlock(&dep->child->lock) == 0);
+ MUTEX_EXIT(&dep->child->lock);
}
error:
static void
_afs_wq_dec_running_count(struct afs_work_queue *queue)
{
- assert(pthread_mutex_lock(&queue->lock) == 0);
+ MUTEX_ENTER(&queue->lock);
queue->running_count--;
if (queue->shutdown && queue->running_count == 0) {
/* if we've shut down, someone may be waiting for the running count
* to drop to 0 */
- assert(pthread_cond_broadcast(&queue->running_cv) == 0);
+ CV_BROADCAST(&queue->running_cv);
}
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
}
/**
* _afs_wq_node_list_dequeue should return immediately with EINTR,
* in which case we'll dec running_count, so it's as if we never inc'd it
* in the first place. */
- assert(pthread_mutex_lock(&queue->lock) == 0);
+ MUTEX_ENTER(&queue->lock);
if (queue->shutdown) {
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
return EINTR;
}
queue->running_count++;
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
ret = _afs_wq_node_list_dequeue(&queue->ready_list,
&node,
detached = node->detached;
if (cbf != NULL) {
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
code = (*cbf)(queue, node, queue->rock, node_rock, rock);
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
if (code == 0) {
next_state = AFS_WQ_NODE_STATE_DONE;
ql = &queue->done_list;
if ((next_state == AFS_WQ_NODE_STATE_DONE) ||
(next_state == AFS_WQ_NODE_STATE_ERROR)) {
- assert(pthread_mutex_lock(&queue->lock) == 0);
+ MUTEX_ENTER(&queue->lock);
if (queue->drain && queue->pend_count == queue->opts.pend_lothresh) {
/* signal other threads if we're about to below the low
* pending-tasks threshold */
queue->drain = 0;
- assert(pthread_cond_signal(&queue->pend_cv) == 0);
+ CV_SIGNAL(&queue->pend_cv);
}
if (queue->pend_count == 1) {
/* signal other threads if we're about to become 'empty' */
- assert(pthread_cond_broadcast(&queue->empty_cv) == 0);
+ CV_BROADCAST(&queue->empty_cv);
}
queue->pend_count--;
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
}
ret = _afs_wq_node_state_wait_busy(node);
queue->pend_count = 0;
queue->running_count = 0;
- assert(pthread_mutex_init(&queue->lock, NULL) == 0);
- assert(pthread_cond_init(&queue->pend_cv, NULL) == 0);
- assert(pthread_cond_init(&queue->empty_cv, NULL) == 0);
- assert(pthread_cond_init(&queue->running_cv, NULL) == 0);
+ MUTEX_INIT(&queue->lock, "queue", MUTEX_DEFAULT, 0);
+ CV_INIT(&queue->pend_cv, "queue pending", CV_DEFAULT, 0);
+ CV_INIT(&queue->empty_cv, "queue empty", CV_DEFAULT, 0);
+ CV_INIT(&queue->running_cv, "queue running", CV_DEFAULT, 0);
error:
return ret;
{
int ret = 0;
- assert(pthread_mutex_lock(&queue->lock) == 0);
+ MUTEX_ENTER(&queue->lock);
if (queue->shutdown) {
/* already shutdown, do nothing */
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
goto error;
}
queue->shutdown = 1;
/* signal everyone that could be waiting, since these conditions will
* generally fail to signal on their own if we're shutdown, since no
* progress is being made */
- assert(pthread_cond_broadcast(&queue->pend_cv) == 0);
- assert(pthread_cond_broadcast(&queue->empty_cv) == 0);
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ CV_BROADCAST(&queue->pend_cv);
+ CV_BROADCAST(&queue->empty_cv);
+ MUTEX_EXIT(&queue->lock);
error:
return ret;
node->refcount = 1;
node->block_count = 0;
node->error_count = 0;
- pthread_mutex_init(&node->lock, NULL);
- pthread_cond_init(&node->state_cv, NULL);
+ MUTEX_INIT(&node->lock, "node", MUTEX_DEFAULT, 0);
+ CV_INIT(&node->state_cv, "node state", CV_DEFAULT, 0);
node->state = AFS_WQ_NODE_STATE_INIT;
queue_Init(&node->dep_children);
goto error;
}
- pthread_mutex_destroy(&node->lock);
- pthread_cond_destroy(&node->state_cv);
+ MUTEX_DESTROY(&node->lock);
+ CV_DESTROY(&node->state_cv);
if (node->rock_dtor) {
(*node->rock_dtor) (node->rock);
int
afs_wq_node_get(struct afs_work_queue_node * node)
{
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
node->refcount++;
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
return 0;
}
{
afs_uint32 refc;
- assert(node->refcount > 0);
+ osi_Assert(node->refcount > 0);
refc = --node->refcount;
if (drop) {
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
}
if (!refc) {
- assert(node->qidx == AFS_WQ_NODE_LIST_NONE);
+ osi_Assert(node->qidx == AFS_WQ_NODE_LIST_NONE);
_afs_wq_node_free(node);
}
int
afs_wq_node_put(struct afs_work_queue_node * node)
{
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
return _afs_wq_node_put_r(node, 1);
}
afs_wq_callback_func_t * cbf,
void * rock, afs_wq_callback_dtor_t *dtor)
{
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
node->cbf = cbf;
node->rock = rock;
node->rock_dtor = dtor;
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
return 0;
}
int
afs_wq_node_set_detached(struct afs_work_queue_node * node)
{
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
node->detached = 1;
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
return 0;
}
done:
if (held) {
- assert(pthread_mutex_unlock(&child->lock) == 0);
- assert(pthread_mutex_unlock(&parent->lock) == 0);
+ MUTEX_EXIT(&child->lock);
+ MUTEX_EXIT(&parent->lock);
}
return ret;
error:
if (held) {
- assert(pthread_mutex_unlock(&child->lock) == 0);
- assert(pthread_mutex_unlock(&parent->lock) == 0);
+ MUTEX_EXIT(&child->lock);
+ MUTEX_EXIT(&parent->lock);
}
return ret;
}
int ret = 0;
int start;
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
ret = _afs_wq_node_state_wait_busy(node);
if (ret) {
goto error_sync;
}
error_sync:
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
return ret;
}
int ret = 0;
int end;
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
ret = _afs_wq_node_state_wait_busy(node);
if (ret) {
goto error_sync;
}
error_sync:
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
return ret;
}
force = opts->force;
retry:
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
ret = _afs_wq_node_state_wait_busy(node);
if (ret) {
ret = 0;
- assert(pthread_mutex_lock(&queue->lock) == 0);
+ MUTEX_ENTER(&queue->lock);
if (queue->shutdown) {
ret = EINTR;
- assert(pthread_mutex_unlock(&queue->lock) == 0);
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
+ MUTEX_EXIT(&node->lock);
goto error;
}
if (queue->drain) {
if (block) {
-
- assert(pthread_mutex_unlock(&node->lock) == 0);
-
- assert(pthread_cond_wait(&queue->pend_cv, &queue->lock) == 0);
+ MUTEX_EXIT(&node->lock);
+ CV_WAIT(&queue->pend_cv, &queue->lock);
if (queue->shutdown) {
ret = EINTR;
-
} else {
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
waited_for_drain = 1;
goto retry;
}
-
} else {
ret = EWOULDBLOCK;
}
}
-
}
if (ret == 0) {
}
if (waited_for_drain) {
/* signal another thread that may have been waiting for drain */
- assert(pthread_cond_signal(&queue->pend_cv) == 0);
+ CV_SIGNAL(&queue->pend_cv);
}
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
if (ret) {
goto error;
{
int ret = 0;
- assert(pthread_mutex_lock(&queue->lock) == 0);
+ MUTEX_ENTER(&queue->lock);
while (queue->pend_count > 0 && !queue->shutdown) {
- assert(pthread_cond_wait(&queue->empty_cv, &queue->lock) == 0);
+ CV_WAIT(&queue->empty_cv, &queue->lock);
}
if (queue->shutdown) {
* running e.g. in the middle of their callback. ensure they have
* stopped before we return. */
while (queue->running_count > 0) {
- assert(pthread_cond_wait(&queue->running_cv, &queue->lock) == 0);
+ CV_WAIT(&queue->running_cv, &queue->lock);
}
ret = EINTR;
goto done;
}
done:
- assert(pthread_mutex_unlock(&queue->lock) == 0);
+ MUTEX_EXIT(&queue->lock);
/* technically this doesn't really guarantee that the work queue is empty
* after we return, but we do guarantee that it was empty at some point */
{
int ret = 0;
- assert(pthread_mutex_lock(&node->lock) == 0);
+ MUTEX_ENTER(&node->lock);
if (node->state == AFS_WQ_NODE_STATE_INIT) {
/* not sure what to do in this case */
goto done_sync;
while ((node->state != AFS_WQ_NODE_STATE_DONE) &&
(node->state != AFS_WQ_NODE_STATE_ERROR)) {
- assert(pthread_cond_wait(&node->state_cv,
- &node->lock) == 0);
+ CV_WAIT(&node->state_cv, &node->lock);
}
if (retcode) {
*retcode = node->retcode;
AFS_WQ_NODE_STATE_INIT);
done_sync:
- assert(pthread_mutex_unlock(&node->lock) == 0);
+ MUTEX_EXIT(&node->lock);
return ret;
}
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);
errorCode = 0;
*volptr = VGetVolumeNoWait(&local_errorCode, &errorCode, (afs_int32) fid->Volume);
if (!errorCode) {
- assert(*volptr);
+ osi_Assert(*volptr);
break;
}
if ((errorCode == VOFFLINE) && (VInit < 2)) {
return (errorCode);
}
}
- assert(*volptr);
+ osi_Assert(*volptr);
/* get the vnode */
*vptr = VGetVnode(&errorCode, *volptr, fid->Vnode, 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 */
}
*ACLSize = VAclSize(*targetptr);
return (0);
} else {
- assert(Fid != 0);
+ osi_Assert(Fid != 0);
while (1) {
VnodeId parentvnode;
Error errorCode = 0;
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)
(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);
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);
}
IH_INIT(newH, V_device(volptr), V_id(volptr), ino);
newFdP = IH_OPEN(newH);
- assert(newFdP != NULL);
+ osi_Assert(newFdP != NULL);
done = off;
while (size > 0) {
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);
} 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
*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
*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 */
tmp = malloc(sendBufSize);
if (!tmp) {
ViceLog(0, ("Failed malloc in AllocSendBuffer\n"));
- assert(0);
+ osi_Panic("Failed malloc in AllocSendBuffer\n");
}
return tmp;
}
if (parentwhentargetnotdir != NULL) {
tparentwhentargetnotdir = *parentwhentargetnotdir;
VPutVnode(&fileCode, parentwhentargetnotdir);
- assert(!fileCode || (fileCode == VSALVAGE));
+ osi_Assert(!fileCode || (fileCode == VSALVAGE));
parentwhentargetnotdir = NULL;
}
#if FS_STATS_DETAILED
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");
}
/*
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;
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;
if (parentwhentargetnotdir != NULL) {
tparentwhentargetnotdir = *parentwhentargetnotdir;
VPutVnode(&fileCode, parentwhentargetnotdir);
- assert(!fileCode || (fileCode == VSALVAGE));
+ osi_Assert(!fileCode || (fileCode == VSALVAGE));
parentwhentargetnotdir = NULL;
}
#if FS_STATS_DETAILED
/* 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);
/* 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);
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);
}
/* 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);
}
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)) {
errorCode = EIO;
goto Bad_Rename;
}
- assert(errorCode == 0);
+ osi_Assert(errorCode == 0);
}
}
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--;
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
/* 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 */
/* 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 */
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);
/* 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);
/* 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);
#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 */
/* 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));
/* 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);
/* 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);
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);
}
{
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 */
}
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
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));
while (*p && *p != fei)
p = &itofe(*p)->fnext;
- assert(*p);
+ osi_Assert(*p);
*p = fe->fnext;
FreeFE(fe);
return 0;
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;
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;
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);
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
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);
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 */
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)));
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 */
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),
}
#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);
if (HTFree == NULL)
GetHTBlock();
- assert(HTFree != NULL);
+ osi_Assert(HTFree != NULL);
entry = HTFree;
HTFree = entry->next;
HTs++;
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;
}
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;
}
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;
}
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;
}
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));
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));
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) &&
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;
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;
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];
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",
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),
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];
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) {
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
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;
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),
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);
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;
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)
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;
("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);
}
}
}
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
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] = '@';
* 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
int
h_ReleaseClient_r(struct client *client)
{
- assert(client->refCount > 0);
+ osi_Assert(client->refCount > 0);
client->refCount--;
return 0;
}
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;
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;
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;
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++;
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++;
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;
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 */
(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 {
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;
interface->uuid = interf->uuid;
- assert(!host->interface);
+ osi_Assert(!host->interface);
host->interface = interface;
if (LogLevel >= 125) {
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),
* precedence is host_listlock_mutex, host->mutex, host_glock_mutex.
*/
#include <rx/rx_globals.h>
-#include <assert.h>
+#include <afs/afs_assert.h>
#include <pthread.h>
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
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;\
#undef SHARED
#include <rx/xdr.h>
#include <afs/nfs.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <lwp.h>
#include <lock.h>
#include <afs/ptclient.h>
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 */
#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
#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
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 */
#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 */
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;
}
#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
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;
}
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);
}
Die(char *msg)
{
ViceLog(0, ("%s\n", msg));
- assert(0);
+ osi_Panic("%s\n", msg);
} /*Die */
}
#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;
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
nice(-5); /* TODO: */
#endif
#endif
- assert(DInit(buffs) == 0);
+ osi_Assert(DInit(buffs) == 0);
#ifdef AFS_DEMAND_ATTACH_FS
FS_STATE_INIT;
#endif
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 */
/* 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)
/*
#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 */
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;
}
* HostCheck, Signal, min 2 for RXSTATS */
#ifdef AFS_PTHREAD_ENV
#include <pthread.h>
-#include <assert.h>
+#include <afs/afs_assert.h>
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
#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
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
MODULE_CFLAGS= -D${SYS_NAME} ${FSINCLUDES} \
-DFSSYNC_BUILD_SERVER -DFSSYNC_BUILD_CLIENT
$(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 \
#include <sys/types.h>
#include <stdio.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#ifdef AFS_NT40_ENV
#include <fcntl.h>
#include <windows.h>
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;
#include <unistd.h>
#endif
#include <errno.h>
-#include <assert.h>
+#include <afs/afs_assert.h>
#include <signal.h>
#include <string.h>
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;
}
#include <sys/time.h>
#endif
#include <errno.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <signal.h>
#include <string.h>
#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
#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
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);
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);
#include <unistd.h>
#endif
#include <errno.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <signal.h>
#include <string.h>
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 */
}
/* we must not be called before vol package initialization, since we use
* vol package mutexes and conds etc */
- assert(VInit);
+ osi_Assert(VInit);
SYNC_getAddr(&state->endpoint, &state->addr);
SYNC_cleanupSock(state);
state->fd = SYNC_getSock(&state->endpoint);
code = SYNC_bindSock(state);
- assert(!code);
+ osi_Assert(!code);
#ifdef AFS_DEMAND_ATTACH_FS
/*
}
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();
}
queue_Append(&fsync_salv.head, node);
- assert(pthread_cond_broadcast(&fsync_salv.cv) == 0);
+ CV_BROADCAST(&fsync_salv.cv);
}
#endif /* AFS_DEMAND_ATTACH_FS */
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));
}
}
#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 {
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 {
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) {
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);
}
}
AcceptOff(void)
{
if (AcceptHandler != -1) {
- assert(RemoveHandler(fssync_server_state.fd));
+ osi_Assert(RemoveHandler(fssync_server_state.fd));
AcceptHandler = -1;
}
}
return i;
}
ReleaseReadLock(&FSYNC_handler_lock); /* just in case */
- assert(1 == 2);
+ osi_Assert(1 == 2);
return -1; /* satisfy compiler */
}
if (HandlerFD[i] == afd) {
return i;
}
- assert(1 == 2);
+ osi_Assert(1 == 2);
return -1; /* satisfy compiler */
}
ObtainReadLock(&FSYNC_handler_lock);
for (i = 0; i < MAXHANDLERS; i++)
if (HandlerFD[i] != -1) {
- assert(fdi<maxfds);
+ osi_Assert(fdi<maxfds);
fds[fdi].fd = HandlerFD[i];
fds[fdi].events = events;
fds[fdi].revents = 0;
#include "nfs.h"
#include "ihandle.h"
#include "viceinode.h"
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include "afs/afs_assert.h"
-#endif /* AFS_PTHREAD_ENV */
#include <limits.h>
#ifndef AFS_NT40_ENV
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 */
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);
#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
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 */
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);
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;
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;
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_refcnt = 0;
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,
* we can't do so in a threadsafe way.
*/
if (fdP->fd_status != FD_HANDLE_INUSE) {
- assert(fdP->fd_status == FD_HANDLE_OPEN);
+ osi_Assert(fdP->fd_status == FD_HANDLE_OPEN);
#else /* HAVE_PIO */
if (fdP->fd_status != FD_HANDLE_AVAIL) {
#endif /* HAVE_PIO */
* 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);
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;
}
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;
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;
} 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) {
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;
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;
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_PWRITE(streamP->str_fd, streamP->str_buffer,
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);
*/
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,
* 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) {
}
IH_LOCK;
- assert(fdInUseCount >= closeCount);
+ osi_Assert(fdInUseCount >= closeCount);
fdInUseCount -= closeCount;
/*
IH_LOCK;
}
- assert(ihP->ih_refcnt > 0);
+ osi_Assert(ihP->ih_refcnt > 0);
ihP->ih_synced = 0;
ih_fdclose(ihP);
return 0;
IH_LOCK;
- assert(ihP->ih_refcnt > 0);
+ osi_Assert(ihP->ih_refcnt > 0);
if (ihP->ih_refcnt > 1) {
ihP->ih_refcnt--;
#define _IHANDLE_H_
#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
#include <pthread.h>
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
else \
(head) = (ptr)->next; \
(ptr)->next = (ptr)->prev = NULL; \
- assert(!(head) || !((head)->prev)); \
+ osi_Assert(!(head) || !((head)->prev)); \
} while(0)
/*
(ptr)->prev->next = (ptr); \
else \
(head) = (ptr); \
- assert((head) && ((head)->prev == NULL)); \
+ osi_Assert((head) && ((head)->prev == NULL)); \
} while(0)
#endif /* DLL_INIT_LIST */
#if defined (AFS_AIX_ENV) || defined (AFS_HPUX_ENV)
#include <sys/ino.h>
#endif
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#if defined(AFS_HPUX101_ENV)
#include <unistd.h>
#endif
* 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) {
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)
#ifdef AFS_PTHREAD_ENV
/* XXX do static initializers work for WINNT/pthread? */
pthread_mutex_t _namei_glc_lock = PTHREAD_MUTEX_INITIALIZER;
-#define NAMEI_GLC_LOCK assert(pthread_mutex_lock(&_namei_glc_lock) == 0)
-#define NAMEI_GLC_UNLOCK assert(pthread_mutex_unlock(&_namei_glc_lock) == 0)
+#define NAMEI_GLC_LOCK MUTEX_ENTER(&_namei_glc_lock)
+#define NAMEI_GLC_UNLOCK MUTEX_EXIT(&_namei_glc_lock)
#else /* !AFS_PTHREAD_ENV */
#define NAMEI_GLC_LOCK
#define NAMEI_GLC_UNLOCK
static void
_namei_wq_keycreate(void)
{
- assert(pthread_key_create(&wq_key, NULL) == 0);
+ osi_Assert(pthread_key_create(&wq_key, NULL) == 0);
}
/**
void
namei_SetWorkQueue(struct afs_work_queue *wq)
{
- assert(pthread_once(&wq_once, _namei_wq_keycreate) == 0);
+ osi_Assert(pthread_once(&wq_once, _namei_wq_keycreate) == 0);
- assert(pthread_setspecific(wq_key, wq) == 0);
+ osi_Assert(pthread_setspecific(wq_key, wq) == 0);
}
/**
linkHandle.fd_fd = -1;
#ifdef AFS_SALSRV_ENV
- assert(pthread_once(&wq_once, _namei_wq_keycreate) == 0);
+ osi_Assert(pthread_once(&wq_once, _namei_wq_keycreate) == 0);
wq = pthread_getspecific(wq_key);
if (!wq) {
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)
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)
#include <rx/xdr.h>
#include <afs/afsint.h>
#include <stdio.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include "vnode.h"
#include "volume.h"
#include "partition.h"
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#if defined(AFS_HPUX_ENV)
#include <sys/types.h>
#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;
{
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);
}
#endif /* AFS_DEMAND_ATTACH_FS */
if (abortp)
- assert(dp != NULL);
+ osi_Assert(dp != NULL);
return dp;
}
(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);
}
}
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,
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
}
}
if (abortp) {
- assert(dp != NULL);
+ osi_Assert(dp != NULL);
}
return dp;
}
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;
}
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
Die(char *msg)
{
printf("%s\n", msg);
- assert(1 == 2);
+ osi_Panic("%s\n", msg);
}
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 */
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);
/* 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);
if (!child_slot[slot])
break;
}
- assert (slot < Parallel);
+ osi_Assert (slot < Parallel);
do_fork:
pid = Fork();
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);
}
}
}
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));
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;
{
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;
}
prefix_len = strlen(prefix);
dp = opendir(AFSDIR_LOGS_DIR);
- assert(dp);
+ osi_Assert(dp);
while ((dirp = readdir(dp)) != NULL) {
pid_t pid;
{
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
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);
}
#include <sys/time.h>
#endif
#include <errno.h>
-#include <assert.h>
#include <signal.h>
#include <string.h>
#include <sys/time.h>
#endif
#include <errno.h>
-#include <assert.h>
+#include <afs/afs_assert.h>
#include <signal.h>
#include <string.h>
/* 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
/* 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);
state->fd = SYNC_getSock(&state->endpoint);
code = SYNC_bindSock(state);
- assert(!code);
+ osi_Assert(!code);
InitHandler();
AcceptOn();
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));
}
}
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);
}
}
AcceptOff(void)
{
if (AcceptHandler != -1) {
- assert(RemoveHandler(salvsync_server_state.fd));
+ osi_Assert(RemoveHandler(salvsync_server_state.fd));
AcceptHandler = -1;
}
}
return i;
}
ReleaseReadLock(&SALVSYNC_handler_lock); /* just in case */
- assert(1 == 2);
+ osi_Panic("Failed to find handler\n");
return -1; /* satisfy compiler */
}
if (HandlerFD[i] == afd) {
return i;
}
- assert(1 == 2);
+ osi_Panic("Failed to find handler\n");
return -1; /* satisfy compiler */
}
UpdateCommandPrio(node);
}
- assert(pthread_cond_broadcast(&salvageQueue.cv) == 0);
+ CV_BROADCAST(&salvageQueue.cv);
return 0;
}
salvageQueue.len[node->partition_id]--;
salvageQueue.total_len--;
node->state = SALVSYNC_STATE_UNKNOWN;
- assert(pthread_cond_broadcast(&salvageQueue.cv) == 0);
+ CV_BROADCAST(&salvageQueue.cv);
}
}
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
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);
}
}
afs_int32 id;
afs_uint32 prio;
- assert(queue_IsOnQueue(node));
+ osi_Assert(queue_IsOnQueue(node));
prio = node->command.sop.prio;
id = node->partition_id;
}
/* 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);
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;
}
/* 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;
{
int code = 0;
- assert(entry->refcnt == 0);
+ osi_Assert(entry->refcnt == 0);
free(entry);
return code;
{
int code = 0;
- assert(entry->refcnt > 0);
+ osi_Assert(entry->refcnt > 0);
if (--entry->refcnt == 0) {
VVGCache_entry_t *nentry;
}
}
- assert(!child_ent);
+ osi_Assert(!child_ent);
child_ent = parent_ent;
code = _VVGC_hash_entry_add(dp,
child,
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;
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:
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <rx/xdr.h>
#include "rx/rx_queue.h"
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;
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 */
VnChangeState_r(vnp, VN_STATE_ERROR);
VRequestSalvage_r(ec, vp, SALVSYNC_ERROR, 0);
#else
- assert(1 == 2);
+ osi_Assert(1 == 2);
#endif
}
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
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 */
#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 {
#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
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)
#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 {
#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);
#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);
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;
}
{
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));
}
/**
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));
}
/**
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));
}
/**
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);
}
/**
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);
}
}
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;
* 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);
}
DIR *dirp;
struct dirent *dp;
- assert((dirp = opendir(salvinfo->fileSysPath)) != NULL);
+ osi_Assert((dirp = opendir(salvinfo->fileSysPath)) != NULL);
while ((dp = readdir(dirp))) {
if (!strncmp(dp->d_name, "salvage.inodes.", 15)
|| !strncmp(dp->d_name, "salvage.temp.", 13)) {
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;
salvinfo->inodeSummary = (struct InodeSummary *)malloc(st_status);
- assert(salvinfo->inodeSummary != NULL);
+ osi_Assert(salvinfo->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), salvinfo->inodeSummary, st_status);
- assert(ret == st_status);
+ osi_Assert(ret == st_status);
}
salvinfo->nVolumesInInodeFile =(unsigned long)(status.st_size) / sizeof(struct InodeSummary);
for (i = 0; i < salvinfo->nVolumesInInodeFile; i++) {
}
salvinfo->volumeSummaryp = malloc(VOL_VG_MAX_VOLS * sizeof(struct VolumeSummary));
- assert(salvinfo->volumeSummaryp != NULL);
+ osi_Assert(salvinfo->volumeSummaryp != NULL);
salvinfo->nVolumes = 0;
vsp = salvinfo->volumeSummaryp;
}
salvinfo->volumeSummaryp = malloc(nvols * sizeof(struct VolumeSummary));
- assert(salvinfo->volumeSummaryp != NULL);
+ osi_Assert(salvinfo->volumeSummaryp != NULL);
params.singleVolumeNumber = singleVolumeNumber;
params.vsp = salvinfo->volumeSummaryp;
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
(salvinfo->inodeFd, isp->index * sizeof(struct ViceInodeInfo),
SEEK_SET) != -1);
- assert(read(salvinfo->inodeFd, inodes, size) == size);
+ osi_Assert(read(salvinfo->inodeFd, inodes, size) == size);
/* Don't try to salvage a read write volume if there isn't one on this
* partition */
IH_INIT(handle, salvinfo->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_ASEEK(file, vcp->diskSize) == 0);
+ osi_Assert((nVnodes + 1) * vcp->diskSize == size);
+ osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else {
nVnodes = 0;
}
}
} /* 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);
IH_IREAD(salvinfo->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
IH_CREATE(dir->ds_linkH, salvinfo->fileSysDevice, salvinfo->fileSysPath, 0, dir->rwVid,
dir->vnodeNumber, vnode.uniquifier, vnode.dataVersion +=
200);
- assert(VALID_INO(newinode));
- assert(CopyInode(salvinfo->fileSysDevice, oldinode, newinode, dir->rwVid) == 0);
+ osi_Assert(VALID_INO(newinode));
+ osi_Assert(CopyInode(salvinfo->fileSysDevice, oldinode, newinode, dir->rwVid) == 0);
vnode.cloned = 0;
VNDISK_SET_INO(&vnode, newinode);
code =
IH_IWRITE(salvinfo->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,
salvinfo->fileSysDevice, newinode,
IH_IREAD(salvinfo->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
IH_CREATE(dir->ds_linkH, salvinfo->fileSysDevice, salvinfo->fileSysPath, 0, dir->rwVid,
dir->vnodeNumber, vnode.uniquifier, vnode.dataVersion +=
200);
- assert(VALID_INO(newinode));
+ osi_Assert(VALID_INO(newinode));
SetSalvageDirHandle(&newdir, dir->rwVid, salvinfo->fileSysDevice, newinode,
&salvinfo->VolumeChanged);
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);
IH_IWRITE(salvinfo->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(salvinfo->fileSysDevice);
FDH_REALLYCLOSE(fdP);
code = IH_DEC(dir->ds_linkH, oldinode, dir->rwVid);
- assert(code == 0);
+ osi_Assert(code == 0);
dir->dirHandle = newdir;
}
}
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
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(salvinfo, dir);
- assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
if (!unique) {
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
fid.Vnode = vnodeNumber;
fid.Unique = vnodeEssence->unique;
CopyOnWrite(salvinfo, 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 */
Log("directory vnode %u.%u: bad '.' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique);
if (!Testing) {
CopyOnWrite(salvinfo, 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 */
struct VnodeEssence *dotdot;
pa.Vnode = dir->parent;
dotdot = CheckVnodeNumber(salvinfo, 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;
Log("directory vnode %u.%u: bad '..' entry (was %u.%u); fixed\n", dir->vnodeNumber, dir->unique, vnodeNumber, unique);
if (!Testing) {
CopyOnWrite(salvinfo, 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 */
}
if (!Testing) {
CopyOnWrite(salvinfo, 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 */
}
if (!Testing) {
CopyOnWrite(salvinfo, dir);
- assert(Delete(&dir->dirHandle, name) == 0);
+ osi_Assert(Delete(&dir->dirHandle, name) == 0);
}
return 0;
}
IH_INIT(vip->handle, salvinfo->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_ASEEK(file, vcp->diskSize) == 0);
- assert((vip->vnodes = (struct VnodeEssence *)
+ osi_Assert((vip->nVnodes + 1) * vcp->diskSize == size);
+ osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 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;
judge_params.salvinfo = salvinfo;
judge_params.dir = &dir;
- assert(EnumerateDir(&dirHandle, JudgeEntry, &judge_params) == 0);
+ osi_Assert(EnumerateDir(&dirHandle, JudgeEntry, &judge_params) == 0);
}
/* Delete the old directory if it was copied in order to salvage.
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;
}
salvinfo->vnodeInfo[vLarge].vnodes = calloc(1, sizeof(struct VnodeEssence));
salvinfo->vnodeInfo[vLarge].inodes = calloc(1, sizeof(Inode));
- assert(salvinfo->vnodeInfo[vLarge].vnodes);
- assert(salvinfo->vnodeInfo[vLarge].inodes);
+ osi_Assert(salvinfo->vnodeInfo[vLarge].vnodes);
+ osi_Assert(salvinfo->vnodeInfo[vLarge].inodes);
}
vep = &salvinfo->vnodeInfo[vLarge].vnodes[vnodeIdToBitNumber(1)];
vid = rwIsp->volSummary->header.id;
IH_INIT(h, salvinfo->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(salvinfo, vid, vLarge,
&salvinfo->VolumeChanged);
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.
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);
}
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 */
}
IH_IREAD(salvinfo->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;
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++;
}
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));
}
IH_IWRITE(salvinfo->vnodeInfo[class].handle,
vnodeIndexOffset(vcp, vnodeNumber),
(char *)&vnode, sizeof(vnode));
- assert(nBytes == sizeof(vnode));
+ osi_Assert(nBytes == sizeof(vnode));
}
salvinfo->VolumeChanged = 1;
}
salvinfo->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",
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));
}
}
* 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);
}
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_PREAD(srcFdP, buf, sizeof(buf), size)) > 0) {
- assert(FDH_PWRITE(destFdP, buf, nBytes, size) == nBytes);
+ osi_Assert(FDH_PWRITE(destFdP, buf, nBytes, size) == nBytes);
size += nBytes;
}
- assert(nBytes == 0);
+ osi_Assert(nBytes == 0);
FDH_REALLYCLOSE(srcFdP);
FDH_REALLYCLOSE(destFdP);
IH_RELEASE(srcH);
int nInodes;
afs_ino_str_t stmp;
- assert(afs_fstat(salvinfo->inodeFd, &status) == 0);
+ osi_Assert(afs_fstat(salvinfo->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(salvinfo->inodeFd, buf, status.st_size) == status.st_size);
+ osi_Assert(read(salvinfo->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(stmp, ip->inodeNumber), ip->linkCount,
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 */
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)
{
char *p;
p = (char *)malloc(strlen(s) + 1);
- assert(p != NULL);
+ osi_Assert(p != NULL);
strcpy(p, s);
return p;
}
#include "partition.h"
#include "volume_inline.h"
#include "common.h"
-
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include "afs/afs_assert.h"
-#endif /* AFS_PTHREAD_ENV */
#include "vutils.h"
#ifndef AFS_NT40_ENV
#include <afs/dir.h>
VSetVInit_r(int value)
{
VInit = value;
-#ifdef AFS_PTHREAD_ENV
- assert(pthread_cond_broadcast(&vol_vinit_cond) == 0);
-#endif
+ CV_BROADCAST(&vol_vinit_cond);
}
int
} 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);
- assert(pthread_cond_init(&vol_vinit_cond, NULL) == 0);
-#else /* AFS_PTHREAD_ENV */
+ 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);
+ CV_INIT(&vol_vinit_cond, "vol init", CV_DEFAULT, 0);
+#ifndef AFS_PTHREAD_ENV
IOMGR_Initialize();
#endif /* AFS_PTHREAD_ENV */
Lock_Init(&vol_listLock);
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
#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 */
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;
int
VInitAttachVolumes(ProgramType pt)
{
- assert(VInit==1);
+ osi_Assert(VInit==1);
if (pt == fileServer) {
struct DiskPartition64 *diskP;
struct vinitvolumepackage_thread_t params;
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);
}
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",
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();
}
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 */
VInitVolumePackageThread(¶ms);
}
- assert(pthread_cond_destroy(¶ms.thread_done_cv) == 0);
+ CV_DESTROY(¶ms.thread_done_cv);
}
VOL_LOCK;
VSetVInit_r(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;
}
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;
}
int
VInitAttachVolumes(ProgramType pt)
{
- assert(VInit==1);
+ osi_Assert(VInit==1);
if (pt == fileServer) {
struct DiskPartition64 *diskP;
/* 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);
}
/* 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",
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;
VSetVInit_r(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;
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;
}
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;
}
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);
}
/* 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);
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;
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
/* 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);
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");
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) {
void
VShutdown(void)
{
- assert(VInit>0);
+ osi_Assert(VInit>0);
VOL_LOCK;
VShutdown_r();
VOL_UNLOCK;
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;
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) {
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",
/* 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:
*ec = 0;
- assert(programType == fileServer);
+ osi_Assert(programType == fileServer);
if (!(partp = VGetPartition_r(partition, 0))) {
*ec = VNOVOL;
/* 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 */
}
if (VRequiresPartLock()) {
- assert(VInit == 3);
+ osi_Assert(VInit == 3);
VLockPartition_r(partition);
} else if (programType == fileServer) {
#ifdef AFS_DEMAND_ATTACH_FS
}
}
- assert(vp != NULL);
+ osi_Assert(vp != NULL);
/* handle pre-attach races
*
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 */
}
*ec = 0;
/* volume utility should never call AttachByVp */
- assert(programType == fileServer);
+ osi_Assert(programType == fileServer);
volumeId = vp->hashid;
partp = vp->partition;
}
}
- assert(vp != NULL);
+ osi_Assert(vp != NULL);
VChangeState_r(vp, VOL_STATE_ATTACHING);
/* restore monotonically increasing stats */
{
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) {
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);
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:
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;
void
VPutVolume_r(Volume * vp)
{
- assert(--vp->nUsers >= 0);
+ osi_Assert(--vp->nUsers >= 0);
if (vp->nUsers == 0) {
VCheckOffline(vp);
ReleaseVolumeHeader(vp->header);
*/
/* 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) {
#endif /* AFS_DEMAND_ATTACH_FS */
not_inited:
- assert(vp || *ec);
+ osi_Assert(vp || *ec);
return 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);
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;
#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 */
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;
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;
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;
VCheckSalvage(vp);
ReallyFreeVolume(vp);
if (programType == fileServer) {
- assert(pthread_cond_broadcast(&vol_put_volume_cond) == 0);
+ CV_BROADCAST(&vol_put_volume_cond);
}
}
return ret;
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 */
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) &&
if (vp->goingOffline && !vp->nUsers) {
Error error;
- assert(programType == fileServer);
+ osi_Assert(programType == fileServer);
ret = 1;
vp->goingOffline = 0;
}
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 */
void
VCancelReservation_r(Volume * vp)
{
- assert(--vp->nWaiters >= 0);
+ osi_Assert(--vp->nWaiters >= 0);
if (vp->nWaiters == 0) {
VCheckOffline(vp);
if (!VCheckDetach(vp)) {
/* 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;
VThreadOptions_t * thread_opts;
char partName[16];
- assert(VCanUseSALVSYNC() || VCanUseFSSYNC());
+ osi_Assert(VCanUseSALVSYNC() || VCanUseFSSYNC());
if (vp->nWaiters || vp->nUsers) {
return 1;
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;
VConnectFS_r(void)
{
int rc;
- assert((VInit == 2) &&
+ osi_Assert((VInit == 2) &&
(programType != fileServer) &&
(programType != salvager));
rc = FSYNC_clientInit();
void
VDisconnectFS_r(void)
{
- assert((programType != fileServer) &&
+ osi_Assert((programType != fileServer) &&
(programType != salvager));
FSYNC_clientFinis();
VSetVInit_r(2);
/* 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);
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
* 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_ASEEK(file, vcp->diskSize) != -1) {
sizeof(VolumeId) * updateSize);
}
}
- assert(UpdateList != NULL);
+ osi_Assert(UpdateList != NULL);
UpdateList[nUpdatedVolumes++] = V_id(vp);
#endif /* !AFS_DEMAND_ATTACH_FS */
}
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 */
/* 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);
}
}
if (!VLRU_enabled)
return;
- assert(queue_IsNotOnQueue(&vp->vlru));
+ osi_Assert(queue_IsNotOnQueue(&vp->vlru));
vp->vlru.idx = VLRU_QUEUE_INVALID;
}
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();
/* 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);
/* 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;
}
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]);
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]);
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 */
static void
VLRU_BeginExclusive_r(struct VLRU_q * q)
{
- assert(q->busy == 0);
+ osi_Assert(q->busy == 0);
q->busy = 1;
}
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 */
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)
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;
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
/* 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
* 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
/* 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;
#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) {
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 */
}
}
static void
VHashBeginExclusive_r(VolumeHashChainHead * head)
{
- assert(head->busy == 0);
+ osi_Assert(head->busy == 0);
head->busy = 1;
}
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);
}
/**
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;
}
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);
}
/**
#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 \
#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
#include <pthread.h>
extern pthread_mutex_t vol_glock_mutex;
extern pthread_mutex_t vol_trans_mutex;
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
return 0;
default:
- assert(0 /* unknown checkout mode */);
+ osi_Assert(0 /* unknown checkout mode */);
return 0;
}
}
{
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);
}
/**
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);
}
/**
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;
}
#endif
#include <dirent.h>
#include <sys/stat.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <rx/xdr.h>
#include <afs/afsint.h>
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.
*
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
void
VLockFileReinit(struct VLockFile *lf)
{
- AFS_LF_LOCK(lf);
+ MUTEX_ENTER(&lf->mutex);
if (lf->fd != INVALID_FD) {
_VCloseFd(lf->fd);
lf->refcount = 0;
- AFS_LF_UNLOCK(lf);
+ MUTEX_EXIT(&lf->mutex);
}
/**
{
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;
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);
_VUnlockFd(lf->fd, offset);
}
- AFS_LF_UNLOCK(lf);
+ MUTEX_EXIT(&lf->mutex);
}
#ifdef AFS_DEMAND_ATTACH_FS
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;
}
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) {
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,
code = EBUSY;
} else {
while ((dl->flags & VDISKLOCK_ACQUIRING)) {
- assert(pthread_cond_wait(&dl->cv, &dl->mutex) == 0);
+ CV_WAIT(&dl->cv, &dl->mutex);
}
}
}
/* 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;
dl->flags |= VDISKLOCK_ACQUIRED;
}
- assert(pthread_cond_broadcast(&dl->cv) == 0);
+ CV_BROADCAST(&dl->cv);
}
}
++dl->lockers;
}
- assert(pthread_mutex_unlock(&dl->mutex) == 0);
+ MUTEX_EXIT(&dl->mutex);
return code;
}
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
dl->flags &= ~VDISKLOCK_ACQUIRED;
}
- assert(pthread_mutex_unlock(&dl->mutex) == 0);
+ MUTEX_EXIT(&dl->mutex);
if (locktype == READ_LOCK) {
ReleaseReadLock(&dl->rwlock);
../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
#include <unistd.h>
#endif
#include <sys/stat.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <rx/xdr.h>
#include <rx/rx.h>
#include <afs/afsint.h>
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) {
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_ASEEK(file, vcp->diskSize) == 0);
+ osi_Assert((nVnodes + 1) * vcp->diskSize == size);
+ osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else
nVnodes = 0;
for (vnodeIndex = 0;
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;
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_ASEEK(file, vcp->diskSize) == 0);
+ osi_Assert((nVnodes + 1) * vcp->diskSize == size);
+ osi_Assert(STREAM_ASEEK(file, vcp->diskSize) == 0);
} else
nVnodes = 0;
for (vnodeIndex = 0;
Die(char *msg)
{
printf("%s\n", msg);
- assert(1 == 2);
+ osi_Panic("%s\n", msg);
}
#if defined(AFS_NAMEI_ENV) && !defined(AFS_NT40_ENV)
#include <sys/types.h>
#include <stdio.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#ifdef AFS_NT40_ENV
#include <fcntl.h>
#include <windows.h>
#include <afs/afsint.h>
#include <stdio.h>
#include <signal.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <afs/prs_fs.h>
#include <afs/nfs.h>
#include <lwp.h>
#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);
#include <rx/rxkad.h>
#include <afs/afsint.h>
#include <signal.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <afs/prs_fs.h>
#include <afs/nfs.h>
#include <lwp.h>
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 */
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);
nBytes = FDH_PWRITE(fdP, vnode, SIZEOF_LARGEDISKVNODE, vnodeIndexOffset(vcp, 1));
- assert(nBytes == SIZEOF_LARGEDISKVNODE);
+ osi_Assert(nBytes == SIZEOF_LARGEDISKVNODE);
FDH_REALLYCLOSE(fdP);
IH_RELEASE(h);
VNDISK_GET_LEN(length, vnode);
#ifndef _VOLSER_
#define _VOLSER_ 1
+#include <afs/afs_assert.h>
#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
#include <pthread.h>
#endif
#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)
#include <sys/stat.h>
#include <afs/afsint.h>
#include <signal.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
#include <afs/afs_assert.h>
-#endif /* AFS_PTHREAD_ENV */
#include <afs/prs_fs.h>
#include <afs/nfs.h>
#include <lwp.h>