#endif
#include <afs/opr.h>
+#include <opr/lock.h>
#include <afs/nfs.h> /* yuck. This is an abomination. */
-#include <lwp.h>
#include <rx/rx.h>
#include <rx/rx_queue.h>
#include <afs/afscbint.h>
#include <afs/afsutil.h>
-#include <lock.h>
#include <afs/ihandle.h>
+#include <afs/partition.h>
#include <afs/vnode.h>
#include <afs/volume.h>
#include "viced_prototypes.h"
int
InitCallBack(int nblks)
{
+ opr_Assert(nblks > 0);
+
H_LOCK;
tfirst = CBtime(time(NULL));
/* N.B. The "-1", below, is because
* FE[0] and CB[0] are not used--and not allocated */
- FE = ((struct FileEntry *)(calloc(nblks, sizeof(struct FileEntry))));
+ FE = calloc(nblks, sizeof(struct FileEntry));
if (!FE) {
ViceLogThenPanic(0, ("Failed malloc in InitCallBack\n"));
}
cbstuff.nFEs = nblks;
while (cbstuff.nFEs)
FreeFE(&FE[cbstuff.nFEs]); /* This is correct */
- CB = ((struct CallBack *)(calloc(nblks, sizeof(struct CallBack))));
+ CB = calloc(nblks, sizeof(struct CallBack));
if (!CB) {
ViceLogThenPanic(0, ("Failed malloc in InitCallBack\n"));
}
extern pthread_cond_t fsync_cond;
int
-BreakVolumeCallBacksLater(afs_uint32 volume)
+BreakVolumeCallBacksLater(VolumeId volume)
{
int hash;
afs_uint32 *feip;
struct host *host;
int found = 0;
- ViceLog(25, ("Setting later on volume %u\n", volume));
+ ViceLog(25, ("Setting later on volume %" AFS_VOLID_FMT "\n",
+ afs_printable_VolumeId_lu(volume)));
H_LOCK;
for (hash = 0; hash < FEHASH_SIZE; hash++) {
for (feip = &HashTable[hash]; (fe = itofe(*feip)) != NULL; ) {
ViceLog(25, ("Fsync thread wakeup\n"));
FSYNC_LOCK;
- CV_BROADCAST(&fsync_cond);
+ opr_cv_broadcast(&fsync_cond);
FSYNC_UNLOCK;
return 0;
}
/* Ugly, but used to avoid left side casting */
struct object *tmpfe;
ViceLog(125,
- ("Unchaining for %u:%u:%u\n", fe->vnode, fe->unique,
- fe->volid));
+ ("Unchaining for %u:%u:%" AFS_VOLID_FMT "\n", fe->vnode,
+ fe->unique, afs_printable_VolumeId_lu(fe->volid)));
fid.Volume = fe->volid;
*feip = fe->fnext;
fe->status &= ~FE_LATER; /* not strictly needed */
/* leave flag for MultiBreakVolumeCallBack to clear */
} else {
ViceLog(125,
- ("Found host %p (%s:%d) non-DELAYED cb for %u:%u:%u\n",
+ ("Found host %p (%s:%d) non-DELAYED cb for %u:%u:%" AFS_VOLID_FMT "\n",
host, afs_inet_ntoa_r(host->host, hoststr),
- ntohs(host->port), fe->vnode, fe->unique, fe->volid));
+ ntohs(host->port), fe->vnode, fe->unique,
+ afs_printable_VolumeId_lu(fe->volid)));
}
}
myfe = fe;
cb = itocb(cbi);
cbi = cb->tnext;
ViceLog(8,
- ("CCB: deleting timed out call back %x (%s:%d), (%u,%u,%u)\n",
+ ("CCB: deleting timed out call back %x (%s:%d), (%" AFS_VOLID_FMT ",%u,%u)\n",
h_itoh(cb->hhead)->host,
afs_inet_ntoa_r(h_itoh(cb->hhead)->host, hoststr),
- h_itoh(cb->hhead)->port, itofe(cb->fhead)->volid,
+ h_itoh(cb->hhead)->port,
+ afs_printable_VolumeId_lu(itofe(cb->fhead)->volid),
itofe(cb->fhead)->vnode, itofe(cb->fhead)->unique));
HDel(cb);
CDel(cb, 1);
}
#endif /* AFS_DEMAND_ATTACH_FS */
+#define DumpBytes(fd,buf,req) if (write(fd, buf, req) < 0) ; /* don't care */
+
static int
DumpCallBackState_r(void)
{
AFSDIR_SERVER_CBKDUMP_FILEPATH));
return 0;
}
- (void)write(fd, &magic, sizeof(magic));
- (void)write(fd, &now, sizeof(now));
- (void)write(fd, &cbstuff, sizeof(cbstuff));
- (void)write(fd, TimeOuts, sizeof(TimeOuts));
- (void)write(fd, timeout, sizeof(timeout));
- (void)write(fd, &tfirst, sizeof(tfirst));
+ /*
+ * Collect but ignoring the return value of write(2) here,
+ * to avoid compiler warnings on some platforms.
+ */
+ DumpBytes(fd, &magic, sizeof(magic));
+ DumpBytes(fd, &now, sizeof(now));
+ DumpBytes(fd, &cbstuff, sizeof(cbstuff));
+ DumpBytes(fd, TimeOuts, sizeof(TimeOuts));
+ DumpBytes(fd, timeout, sizeof(timeout));
+ DumpBytes(fd, &tfirst, sizeof(tfirst));
freelisthead = cbtoi((struct CallBack *)CBfree);
- (void)write(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */
+ DumpBytes(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */
freelisthead = fetoi((struct FileEntry *)FEfree);
- (void)write(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */
- (void)write(fd, HashTable, sizeof(HashTable));
- (void)write(fd, &CB[1], sizeof(CB[1]) * cbstuff.nblks); /* CB stuff */
- (void)write(fd, &FE[1], sizeof(FE[1]) * cbstuff.nblks); /* FE stuff */
+ DumpBytes(fd, &freelisthead, sizeof(freelisthead)); /* This is a pointer */
+ DumpBytes(fd, HashTable, sizeof(HashTable));
+ DumpBytes(fd, &CB[1], sizeof(CB[1]) * cbstuff.nblks); /* CB stuff */
+ DumpBytes(fd, &FE[1], sizeof(FE[1]) * cbstuff.nblks); /* FE stuff */
close(fd);
return 0;
if (fe == NULL)
return;
- printf("vol=%u vn=%u cbs=%d hi=%d st=%d fest=%d, exp in %lu secs at %s",
- fe->volid, fe->vnode, fe->ncbs, cb->hhead, cb->status, fe->status,
- expires - now, ctime(&expires));
+ printf("vol=%" AFS_VOLID_FMT " vn=%u cbs=%d hi=%d st=%d fest=%d, exp in %lu secs at %s",
+ afs_printable_VolumeId_lu(fe->volid), fe->vnode, fe->ncbs,
+ cb->hhead, cb->status, fe->status, expires - now, ctime(&expires));
}
#endif