From 88d13f1f58546460201aded9335acb411bc49d1a Mon Sep 17 00:00:00 2001 From: Derrick Brashear Date: Tue, 11 May 2010 11:40:09 -0400 Subject: [PATCH] vnode alloc bitnumber returns bitnumber fix function return types to match a bitnumber (int) and comment the function appropriately Change-Id: I9542c02b1aa7aacdd0596675992bb1e8a1708572 Reviewed-on: http://gerrit.openafs.org/1941 Reviewed-by: Derrick Brashear Tested-by: Derrick Brashear --- src/vol/volume.c | 41 +++++++++++++++++++++++++++-------------- src/vol/volume.h | 8 ++++---- 2 files changed, 31 insertions(+), 18 deletions(-) diff --git a/src/vol/volume.c b/src/vol/volume.c index 41f9ccee36..177c230f44 100644 --- a/src/vol/volume.c +++ b/src/vol/volume.c @@ -5405,19 +5405,33 @@ VChildProcReconnectFS(void) /* volume bitmap routines */ /***************************************************/ -/* - * 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. +/** + * 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 */ -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; @@ -5428,7 +5442,7 @@ VAllocBitmapEntry_r(Error * ec, Volume * vp, /* This test is probably redundant */ if (!VolumeWriteable(vp)) { *ec = (bit32) VREADONLY; - return 0; + return ret; } #ifdef AFS_DEMAND_ATTACH_FS @@ -5479,7 +5493,6 @@ VAllocBitmapEntry_r(Error * ec, Volume * vp, vp->shuttingDown = 1; /* Let who has it free it. */ vp->specialStatus = 0; #endif /* AFS_DEMAND_ATTACH_FS */ - ret = NULL; goto done; } } @@ -5504,7 +5517,7 @@ VAllocBitmapEntry_r(Error * ec, Volume * vp, 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 */ @@ -5537,10 +5550,10 @@ VAllocBitmapEntry_r(Error * ec, Volume * vp, 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; diff --git a/src/vol/volume.h b/src/vol/volume.h index 8a45135878..afc88bd5ca 100644 --- a/src/vol/volume.h +++ b/src/vol/volume.h @@ -774,10 +774,10 @@ extern Volume *VCreateVolume(Error * ec, char *partname, VolId volumeId, 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,