Windows: change buf_Find*() signature to accept cm_fid_t

The buf_Find*() functions require a cm_fid_t to match with the
cm_buf_t objects not a cm_scache_t.  Change the signature so
that the cm_scache_t is not required.  It should be possible to
search for a buffer even if the cm_scache_t is not present in
the cache.

Change-Id: I38835ee86405c4f3f798ad6be8626e6da507109f
Reviewed-on: http://gerrit.openafs.org/5304
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@openafs.org>
Tested-by: Jeffrey Altman <jaltman@openafs.org>
This commit is contained in:
Jeffrey Altman 2011-08-23 16:02:28 -04:00 committed by Jeffrey Altman
parent b804e027f1
commit c23b27a693
5 changed files with 24 additions and 24 deletions

View File

@ -653,16 +653,16 @@ void buf_WaitIO(cm_scache_t * scp, cm_buf_t *bp)
/* find a buffer, if any, for a particular file ID and offset. Assumes
* that buf_globalLock is write locked when called.
*/
cm_buf_t *buf_FindLocked(struct cm_scache *scp, osi_hyper_t *offsetp)
cm_buf_t *buf_FindLocked(struct cm_fid *fidp, osi_hyper_t *offsetp)
{
afs_uint32 i;
cm_buf_t *bp;
lock_AssertAny(&buf_globalLock);
i = BUF_HASH(&scp->fid, offsetp);
i = BUF_HASH(fidp, offsetp);
for(bp = cm_data.buf_scacheHashTablepp[i]; bp; bp=bp->hashp) {
if (cm_FidCmp(&scp->fid, &bp->fid) == 0
if (cm_FidCmp(fidp, &bp->fid) == 0
&& offsetp->LowPart == bp->offset.LowPart
&& offsetp->HighPart == bp->offset.HighPart) {
buf_HoldLocked(bp);
@ -677,12 +677,12 @@ cm_buf_t *buf_FindLocked(struct cm_scache *scp, osi_hyper_t *offsetp)
/* find a buffer with offset *offsetp for vnode *scp. Called
* with no locks held.
*/
cm_buf_t *buf_Find(struct cm_scache *scp, osi_hyper_t *offsetp)
cm_buf_t *buf_Find(struct cm_fid *fidp, osi_hyper_t *offsetp)
{
cm_buf_t *bp;
lock_ObtainRead(&buf_globalLock);
bp = buf_FindLocked(scp, offsetp);
bp = buf_FindLocked(fidp, offsetp);
lock_ReleaseRead(&buf_globalLock);
return bp;
@ -692,13 +692,13 @@ cm_buf_t *buf_Find(struct cm_scache *scp, osi_hyper_t *offsetp)
* that buf_globalLock is write locked when called. Uses the all buffer
* list.
*/
cm_buf_t *buf_FindAllLocked(struct cm_scache *scp, osi_hyper_t *offsetp, afs_uint32 flags)
cm_buf_t *buf_FindAllLocked(struct cm_fid *fidp, osi_hyper_t *offsetp, afs_uint32 flags)
{
cm_buf_t *bp;
if (flags == 0) {
for(bp = cm_data.buf_allp; bp; bp=bp->allp) {
if (cm_FidCmp(&scp->fid, &bp->fid) == 0
if (cm_FidCmp(fidp, &bp->fid) == 0
&& offsetp->LowPart == bp->offset.LowPart
&& offsetp->HighPart == bp->offset.HighPart) {
buf_HoldLocked(bp);
@ -707,7 +707,7 @@ cm_buf_t *buf_FindAllLocked(struct cm_scache *scp, osi_hyper_t *offsetp, afs_uin
}
} else {
for(bp = cm_data.buf_allp; bp; bp=bp->allp) {
if (cm_FidCmp(&scp->fid, &bp->fid) == 0) {
if (cm_FidCmp(fidp, &bp->fid) == 0) {
char * fileOffset;
fileOffset = offsetp->QuadPart + cm_data.baseAddress;
@ -725,12 +725,12 @@ cm_buf_t *buf_FindAllLocked(struct cm_scache *scp, osi_hyper_t *offsetp, afs_uin
/* find a buffer with offset *offsetp for vnode *scp. Called
* with no locks held. Use the all buffer list.
*/
cm_buf_t *buf_FindAll(struct cm_scache *scp, osi_hyper_t *offsetp, afs_uint32 flags)
cm_buf_t *buf_FindAll(struct cm_fid *fidp, osi_hyper_t *offsetp, afs_uint32 flags)
{
cm_buf_t *bp;
lock_ObtainRead(&buf_globalLock);
bp = buf_FindAllLocked(scp, offsetp, flags);
bp = buf_FindAllLocked(fidp, offsetp, flags);
lock_ReleaseRead(&buf_globalLock);
return bp;
@ -958,7 +958,7 @@ long buf_GetNewLocked(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *req
lock_ObtainWrite(&buf_globalLock);
/* check to see if we lost the race */
if (scp) {
if (bp = buf_FindLocked(scp, offsetp)) {
if (bp = buf_FindLocked(&scp->fid, offsetp)) {
/* Do not call buf_ReleaseLocked() because we
* do not want to allow the buffer to be added
* to the free list.
@ -1164,7 +1164,7 @@ long buf_Get(struct cm_scache *scp, osi_hyper_t *offsetp, cm_req_t *reqp, cm_buf
buf_ValidateBufQueues();
#endif /* TESTING */
bp = buf_Find(scp, &pageOffset);
bp = buf_Find(&scp->fid, &pageOffset);
if (bp) {
/* lock it and break out */
lock_ObtainMutex(&bp->mx);

View File

@ -161,13 +161,13 @@ extern void buf_HoldLocked(cm_buf_t *);
extern void buf_WaitIO(cm_scache_t *, cm_buf_t *);
extern cm_buf_t *buf_FindLocked(struct cm_scache *, osi_hyper_t *);
extern cm_buf_t *buf_FindLocked(struct cm_fid *, osi_hyper_t *);
extern cm_buf_t *buf_Find(struct cm_scache *, osi_hyper_t *);
extern cm_buf_t *buf_Find(struct cm_fid *, osi_hyper_t *);
extern cm_buf_t *buf_FindAllLocked(struct cm_scache *, osi_hyper_t *, afs_uint32 flags);
extern cm_buf_t *buf_FindAllLocked(struct cm_fid *, osi_hyper_t *, afs_uint32 flags);
extern cm_buf_t *buf_FindAll(struct cm_scache *, osi_hyper_t *, afs_uint32 flags);
extern cm_buf_t *buf_FindAll(struct cm_fid *, osi_hyper_t *, afs_uint32 flags);
extern long buf_GetNewLocked(struct cm_scache *, osi_hyper_t *, cm_req_t *, cm_buf_t **);

View File

@ -687,7 +687,7 @@ cm_CheckFetchRange(cm_scache_t *scp, osi_hyper_t *startBasep, osi_hyper_t *lengt
break;
}
bp = buf_Find(scp, &tbase);
bp = buf_Find(&scp->fid, &tbase);
/* We cheat slightly by not locking the bp mutex. */
if (bp) {
if ((bp->cmFlags & (CM_BUF_CMFETCHING | CM_BUF_CMSTORING | CM_BUF_CMBKGFETCH)) == 0
@ -1023,7 +1023,7 @@ long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize,
thyper = ConvertLongToLargeInteger(temp);
tbase = LargeIntegerAdd(*inOffsetp, thyper);
bufp = buf_Find(scp, &tbase);
bufp = buf_Find(&scp->fid, &tbase);
if (bufp) {
/* get buffer mutex and scp mutex safely */
lock_ReleaseWrite(&scp->rw);
@ -1104,7 +1104,7 @@ long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize,
tbase = LargeIntegerSubtract(firstModOffset, thyper);
while(LargeIntegerGreaterThanOrEqualTo(tbase, scanStart)) {
/* see if we can find the buffer */
bufp = buf_Find(scp, &tbase);
bufp = buf_Find(&scp->fid, &tbase);
if (!bufp)
break;
@ -1164,7 +1164,7 @@ long cm_SetupStoreBIOD(cm_scache_t *scp, osi_hyper_t *inOffsetp, long inSize,
tbase = LargeIntegerAdd(firstModOffset, thyper);
while(LargeIntegerLessThan(tbase, scanEnd)) {
/* see if we can find the buffer */
bufp = buf_Find(scp, &tbase);
bufp = buf_Find(&scp->fid, &tbase);
if (!bufp)
break;
@ -1326,7 +1326,7 @@ long cm_SetupFetchBIOD(cm_scache_t *scp, osi_hyper_t *offsetp,
if (LargeIntegerGreaterThanOrEqualTo(pageBase, fileSize))
break;
tbp = buf_Find(scp, &pageBase);
tbp = buf_Find(&scp->fid, &pageBase);
if (!tbp)
break;

View File

@ -5611,7 +5611,7 @@ long smb_ReceiveCoreGetFileAttributes(smb_vc_t *vcp, smb_packet_t *inp, smb_pack
if (dscp->fileType == CM_SCACHETYPE_MOUNTPOINT && !dscp->mountRootFid.volume)
code = CM_ERROR_NOSUCHFILE;
else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) {
cm_buf_t *bp = buf_Find(dscp, &hzero);
cm_buf_t *bp = buf_Find(&dscp->fid, &hzero);
if (bp) {
buf_Release(bp);
bp = NULL;

View File

@ -3438,7 +3438,7 @@ long smb_ReceiveTran2QPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet_t
if (dscp->fileType == CM_SCACHETYPE_MOUNTPOINT && !dscp->mountRootFid.volume)
code = CM_ERROR_NOSUCHFILE;
else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) {
cm_buf_t *bp = buf_Find(dscp, &hzero);
cm_buf_t *bp = buf_Find(&dscp->fid, &hzero);
if (bp) {
buf_Release(bp);
bp = NULL;
@ -3768,7 +3768,7 @@ long smb_ReceiveTran2SetPathInfo(smb_vc_t *vcp, smb_tran2Packet_t *p, smb_packet
if (dscp->fileType == CM_SCACHETYPE_MOUNTPOINT && !dscp->mountRootFid.volume)
code = CM_ERROR_NOSUCHFILE;
else if (dscp->fileType == CM_SCACHETYPE_DIRECTORY) {
cm_buf_t *bp = buf_Find(dscp, &hzero);
cm_buf_t *bp = buf_Find(&dscp->fid, &hzero);
if (bp) {
buf_Release(bp);
bp = NULL;