/* volume bitmap routines */
/***************************************************/
+/**
+ * allocate a vnode bitmap number for the vnode
+ *
+ * @param[out] ec error code
+ * @param[in] vp volume object pointer
+ * @param[in] index vnode index number for the vnode
+ * @param[in] flags flag values described in note
+ *
+ * @note for DAFS, flags parameter controls locking behavior.
+ * If (flags & VOL_ALLOC_BITMAP_WAIT) is set, then this function
+ * will create a reservation and block on any other exclusive
+ * operations. Otherwise, this function assumes the caller
+ * already has exclusive access to vp, and we just change the
+ * volume state.
+ *
+ * @pre VOL_LOCK held
+ *
+ * @return bit number allocated
+ */
/*
- * For demand attach fs, flags parameter controls
- * locking behavior. If (flags & VOL_ALLOC_BITMAP_WAIT)
- * is set, then this function will create a reservation
- * and block on any other exclusive operations. Otherwise,
- * this function assumes the caller already has exclusive
- * access to vp, and we just change the volume state.
+
*/
-VnodeId
+int
VAllocBitmapEntry_r(Error * ec, Volume * vp,
struct vnodeIndex *index, int flags)
{
- VnodeId ret;
+ int ret = 0;
register byte *bp, *ep;
#ifdef AFS_DEMAND_ATTACH_FS
VolState state_save;
/* This test is probably redundant */
if (!VolumeWriteable(vp)) {
*ec = (bit32) VREADONLY;
- return 0;
+ return ret;
}
#ifdef AFS_DEMAND_ATTACH_FS
vp->shuttingDown = 1; /* Let who has it free it. */
vp->specialStatus = 0;
#endif /* AFS_DEMAND_ATTACH_FS */
- ret = NULL;
goto done;
}
}
bp++;
o = ffs(~*bp) - 1; /* ffs is documented in BSTRING(3) */
*bp |= (1 << o);
- ret = (VnodeId) ((bp - index->bitmap) * 8 + o);
+ ret = ((bp - index->bitmap) * 8 + o);
#ifdef AFS_DEMAND_ATTACH_FS
VOL_LOCK;
#endif /* AFS_DEMAND_ATTACH_FS */
return ret;
}
-VnodeId
+int
VAllocBitmapEntry(Error * ec, Volume * vp, register struct vnodeIndex * index)
{
- VnodeId retVal;
+ int retVal;
VOL_LOCK;
retVal = VAllocBitmapEntry_r(ec, vp, index, VOL_ALLOC_BITMAP_WAIT);
VOL_UNLOCK;
VolId parentId);
extern Volume *VCreateVolume_r(Error * ec, char *partname, VolId volumeId,
VolId parentId);
-extern VnodeId VAllocBitmapEntry(Error * ec, Volume * vp,
- struct vnodeIndex *index);
-extern VnodeId VAllocBitmapEntry_r(Error * ec, Volume * vp,
- struct vnodeIndex *index, int flags);
+extern int VAllocBitmapEntry(Error * ec, Volume * vp,
+ struct vnodeIndex *index);
+extern int VAllocBitmapEntry_r(Error * ec, Volume * vp,
+ struct vnodeIndex *index, int flags);
extern void VFreeBitMapEntry(Error * ec, register struct vnodeIndex *index,
unsigned bitNumber);
extern void VFreeBitMapEntry_r(Error * ec, register struct vnodeIndex *index,