*/
#include <afsconfig.h>
#include <afs/param.h>
+
+#include <roken.h>
+
#define MAXINT (~(1<<((sizeof(int)*8)-1)))
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
-#ifdef AFS_PTHREAD_ENV
-#include <assert.h>
-#else /* AFS_PTHREAD_ENV */
-#include <afs/assert.h>
-#endif /* AFS_PTHREAD_ENV */
+#include <afs/afs_assert.h>
#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 */
*ec = EIO;
goto error_encountered;
}
- if (FDH_SEEK(fdP, off, SEEK_SET) < 0) {
- Log("VAllocVnode: can't seek on index file!\n");
- *ec = EIO;
- goto error_encountered;
- }
if (off + vcp->diskSize <= size) {
- if (FDH_READ(fdP, &vnp->disk, vcp->diskSize) != vcp->diskSize) {
+ if (FDH_PREAD(fdP, &vnp->disk, vcp->diskSize, off) != vcp->diskSize) {
Log("VAllocVnode: can't read index file!\n");
*ec = EIO;
goto error_encountered;
goto error_encountered;
}
memset(buf, 0, 16 * 1024);
- if ((FDH_WRITE(fdP, buf, 16 * 1024)) != 16 * 1024) {
+ if ((FDH_PWRITE(fdP, buf, 16 * 1024, off)) != 16 * 1024) {
Log("VAllocVnode: can't grow vnode index: write failed\n");
*ec = EIO;
free(buf);
if (fdP)
FDH_CLOSE(fdP);
VOL_LOCK;
- VFreeBitMapEntry_r(&tmp, &vp->vnodeIndex[class], bitNumber);
+ VFreeBitMapEntry_r(&tmp, vp, &vp->vnodeIndex[class], bitNumber, 0 /*flags*/);
VInvalidateVnode_r(vnp);
VnUnlock(vnp, WRITE_LOCK);
VnCancelReservation_r(vnp);
PrintInode(stmp, vp->vnodeIndex[class].handle->ih_ino));
*ec = VIO;
goto error_encountered_nolock;
- } else if (FDH_SEEK(fdP, vnodeIndexOffset(vcp, Vn_id(vnp)), SEEK_SET)
- < 0) {
- Log("VnLoad: can't seek on index file vn=%u\n", Vn_id(vnp));
- *ec = VIO;
- goto error_encountered_nolock;
- } else if ((nBytes = FDH_READ(fdP, (char *)&vnp->disk, vcp->diskSize))
+ } else if ((nBytes = FDH_PREAD(fdP, (char *)&vnp->disk, vcp->diskSize, vnodeIndexOffset(vcp, Vn_id(vnp))))
!= vcp->diskSize) {
/* Don't take volume off line if the inumber is out of range
* or the inode table is full. */
unsigned int bitNumber = vnodeIdToBitNumber(Vn_id(vnp));
unsigned int offset = bitNumber >> 3;
+#ifdef AFS_DEMAND_ATTACH_FS
+ /* Make sure the volume bitmap isn't getting updated while we are
+ * checking it */
+ VWaitExclusiveState_r(vp);
+#endif
+
/* Test to see if vnode number is valid. */
if ((offset >= index->bitmapSize)
|| ((*(index->bitmap + offset) & (1 << (bitNumber & 0x7)))
Log("VnStore: can't open index file!\n");
goto error_encountered;
}
- if (FDH_SEEK(fdP, offset, SEEK_SET) < 0) {
- Log("VnStore: can't seek on index file! fdp=%"AFS_PTR_FMT
- " offset=%d, errno=%d\n",
- fdP, (int) offset, errno);
- goto error_encountered;
- }
-
- nBytes = FDH_WRITE(fdP, &vnp->disk, vcp->diskSize);
+ nBytes = FDH_PWRITE(fdP, &vnp->disk, vcp->diskSize, offset);
if (nBytes != vcp->diskSize) {
/* Don't force volume offline if the inumber is out of
* range or the inode table is full.
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 {
if (vnp->delete && !*ec) {
if (Vn_volume(vnp)->header->diskstuff.filecount-- < 1)
Vn_volume(vnp)->header->diskstuff.filecount = 0;
- VFreeBitMapEntry_r(ec, &vp->vnodeIndex[class],
- vnodeIdToBitNumber(Vn_id(vnp)));
+ VFreeBitMapEntry_r(ec, vp, &vp->vnodeIndex[class],
+ vnodeIdToBitNumber(Vn_id(vnp)),
+ VOL_FREE_BITMAP_WAIT);
}
}
vcp->writes++;
#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);