#include <afsconfig.h>
#include <afs/param.h>
-#ifdef AFS_DEMAND_ATTACH_FS
+#include <roken.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <afs/assert.h>
-#include <string.h>
-#ifdef AFS_NT40_ENV
-#include <io.h>
-#else
+#ifdef HAVE_SYS_FILE_H
#include <sys/file.h>
-#include <sys/param.h>
-#if defined(AFS_SUN5_ENV) || defined(AFS_HPUX_ENV)
-#include <unistd.h>
#endif
-#endif /* AFS_NT40_ENV */
+
+#ifdef AFS_DEMAND_ATTACH_FS
+
+#include <afs/opr.h>
+#include <rx/rx_queue.h>
+#include <opr/lock.h>
#include <lock.h>
#include <afs/afsutil.h>
-#include <lwp.h>
#include "nfs.h"
#include <afs/afsint.h>
#include "ihandle.h"
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;
static int
_VVGC_entry_alloc(VVGCache_entry_t ** entry_out)
{
- int code = 0;
- VVGCache_entry_t * ent;
+ *entry_out = calloc(1, sizeof(VVGCache_entry_t));
- *entry_out = ent = malloc(sizeof(VVGCache_entry_t));
- if (ent == NULL) {
- code = ENOMEM;
- goto error;
- }
+ if (*entry_out == NULL)
+ return ENOMEM;
- memset(ent, 0, sizeof(*ent));
-
- error:
- return code;
+ return 0;
}
/**
{
int code = 0;
- assert(entry->refcnt == 0);
+ opr_Assert(entry->refcnt == 0);
free(entry);
return code;
{
int code = 0;
- assert(entry->refcnt > 0);
+ opr_Assert(entry->refcnt > 0);
if (--entry->refcnt == 0) {
VVGCache_entry_t *nentry;
}
}
- assert(!child_ent);
+ opr_Assert(!child_ent);
child_ent = parent_ent;
code = _VVGC_hash_entry_add(dp,
child,
VolumeId parent, VolumeId child)
{
int code = 0, res;
- VVGCache_entry_t * parent_ent, * child_ent;
+ VVGCache_entry_t * child_ent;
VVGCache_hash_entry_t * child_hent;
- /* check mappings for each volid */
- res = _VVGC_lookup(dp, parent, &parent_ent, NULL);
- if (res) {
- code = res;
- goto done;
- }
res = _VVGC_lookup(dp, child, &child_ent, &child_hent);
if (res) {
code = res;
goto done;
}
- /* if the mappings don't match, we have a serious error */
- if (parent_ent != child_ent) {
- ViceLog(0, ("VVGCache_entry_del: trying to delete vol %lu from VG %lu, "
- "but vol %lu points to VGC entry %"AFS_PTR_FMT" and VG %lu "
- "points to VGC entry %"AFS_PTR_FMT"\n",
- afs_printable_uint32_lu(child),
- afs_printable_uint32_lu(parent),
- afs_printable_uint32_lu(child),
- child_ent, afs_printable_uint32_lu(parent), parent_ent));
- code = -1;
- goto done;
+ if (parent != 0) {
+ VVGCache_entry_t * parent_ent;
+
+ res = _VVGC_lookup(dp, parent, &parent_ent, NULL);
+ if (res) {
+ code = res;
+ goto done;
+ }
+
+ /* if the mappings don't match, we have a serious error */
+ if (parent_ent != child_ent) {
+ ViceLog(0,
+ ("VVGCache_entry_del: trying to delete vol %lu from VG %lu, "
+ "but vol %lu points to VGC entry %" AFS_PTR_FMT
+ " and VG %lu " "points to VGC entry %" AFS_PTR_FMT "\n",
+ afs_printable_uint32_lu(child),
+ afs_printable_uint32_lu(parent),
+ afs_printable_uint32_lu(child), child_ent,
+ afs_printable_uint32_lu(parent), parent_ent));
+ code = -1;
+ goto done;
+ }
}
code = _VVGC_hash_entry_del(child_hent);
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;