afs: Remove second argument to afs_GetDSlot

All callers of afs_GetDSlot were passing NULL as the second argument
to afs_GetDSlot. So, remove the argument, and behave as if tmpdc was
NULL unconditionally.

Reviewed-on: http://gerrit.openafs.org/6416
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
(cherry picked from commit 12177ba6fffaf8a693dd8c8e9445d5e7725ae743)

Change-Id: Ic1ad6d35a7051e83a811692156b0da7207cb57f4
Reviewed-on: http://gerrit.openafs.org/7939
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
This commit is contained in:
Andrew Deason 2011-12-21 17:25:29 -05:00 committed by Derrick Brashear
parent 67a1e4069d
commit 524a97a2be
6 changed files with 59 additions and 79 deletions

View File

@ -63,8 +63,7 @@ struct afs_cacheOps {
int noLock);
int (*vwrite) (struct vcache * avc, struct uio * auio, int aio,
afs_ucred_t * acred, int noLock);
struct dcache *(*GetDSlot) (afs_int32 aslot,
struct dcache * tmpdc);
struct dcache *(*GetDSlot) (afs_int32 aslot);
struct volume *(*GetVolSlot) (void);
int (*HandleLink) (struct vcache * avc, struct vrequest * areq);
};
@ -75,7 +74,7 @@ struct afs_cacheOps {
#define afs_CFileRead(file, offset, data, size) (*(afs_cacheType->fread))(file, offset, data, size)
#define afs_CFileWrite(file, offset, data, size) (*(afs_cacheType->fwrite))(file, offset, data, size)
#define afs_CFileClose(handle) (*(afs_cacheType->close))(handle)
#define afs_GetDSlot(slot, adc) (*(afs_cacheType->GetDSlot))(slot, adc)
#define afs_GetDSlot(slot) (*(afs_cacheType->GetDSlot))(slot)
#define afs_GetVolSlot() (*(afs_cacheType->GetVolSlot))()
#define afs_HandleLink(avc, areq) (*(afs_cacheType->HandleLink))(avc, areq)

View File

@ -672,7 +672,7 @@ afs_GetDownD(int anumber, int *aneedSpace, afs_int32 buckethint)
* during the truncate operation.
*/
for (i = 0; i < victimPtr; i++) {
tdc = afs_GetDSlot(victims[i], 0);
tdc = afs_GetDSlot(victims[i]);
/* We got tdc->tlock(R) here */
if (tdc->refCount == 1)
victimDCs[i] = tdc;
@ -1085,7 +1085,7 @@ afs_FreeDiscardedDCache(void)
/*
* Get an entry from the list of discarded cache elements
*/
tdc = afs_GetDSlot(afs_discardDCList, 0);
tdc = afs_GetDSlot(afs_discardDCList);
osi_Assert(tdc->refCount == 1);
ReleaseReadLock(&tdc->tlock);
@ -1311,7 +1311,7 @@ afs_TryToSmush(struct vcache *avc, afs_ucred_t *acred, int sync)
i = afs_dvnextTbl[index]; /* next pointer this hash table */
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
int releaseTlock = 1;
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
if (sync) {
if ((afs_indexFlags[index] & IFDataMod) == 0
@ -1400,7 +1400,7 @@ afs_DCacheMissingChunks(struct vcache *avc)
for (index = afs_dvhashTbl[i]; index != NULLIDX; index = i) {
i = afs_dvnextTbl[index];
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
totalChunks--;
}
@ -1453,7 +1453,7 @@ afs_FindDCache(struct vcache *avc, afs_size_t abyte)
ObtainWriteLock(&afs_xdcache, 278);
for (index = afs_dchashTbl[i]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid) && chunk == tdc->f.chunk) {
break; /* leaving refCount high for caller */
@ -1501,7 +1501,7 @@ afs_AllocDCache(struct vcache *avc, afs_int32 chunk, afs_int32 lock,
|| ((lock & 2) && afs_freeDCList != NULLIDX)) {
afs_indexFlags[afs_freeDCList] &= ~IFFree;
tdc = afs_GetDSlot(afs_freeDCList, 0);
tdc = afs_GetDSlot(afs_freeDCList);
osi_Assert(tdc->refCount == 1);
ReleaseReadLock(&tdc->tlock);
ObtainWriteLock(&tdc->lock, 604);
@ -1509,7 +1509,7 @@ afs_AllocDCache(struct vcache *avc, afs_int32 chunk, afs_int32 lock,
afs_freeDCCount--;
} else {
afs_indexFlags[afs_discardDCList] &= ~IFDiscarded;
tdc = afs_GetDSlot(afs_discardDCList, 0);
tdc = afs_GetDSlot(afs_discardDCList);
osi_Assert(tdc->refCount == 1);
ReleaseReadLock(&tdc->tlock);
ObtainWriteLock(&tdc->lock, 605);
@ -1769,7 +1769,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
us = NULLIDX;
for (index = afs_dchashTbl[i]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
/*
* Locks held:
@ -2561,14 +2561,13 @@ afs_WriteThroughDSlots(void)
*
* Parameters:
* aslot : Dcache slot to look at.
* tmpdc : Ptr to dcache entry.
*
* Environment:
* Must be called with afs_xdcache write-locked.
*/
struct dcache *
afs_MemGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
afs_MemGetDSlot(afs_int32 aslot)
{
struct dcache *tdc;
int existing = 0;
@ -2588,31 +2587,26 @@ afs_MemGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
ConvertWToRLock(&tdc->tlock);
return tdc;
}
if (tmpdc == NULL) {
if (!afs_freeDSList)
afs_GetDownDSlot(4);
if (!afs_freeDSList) {
/* none free, making one is better than a panic */
afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */
tdc = afs_osi_Alloc(sizeof(struct dcache));
osi_Assert(tdc != NULL);
if (!afs_freeDSList)
afs_GetDownDSlot(4);
if (!afs_freeDSList) {
/* none free, making one is better than a panic */
afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */
tdc = afs_osi_Alloc(sizeof(struct dcache));
osi_Assert(tdc != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)tdc, sizeof(struct dcache)); /* XXX */
pin((char *)tdc, sizeof(struct dcache)); /* XXX */
#endif
} else {
tdc = afs_freeDSList;
afs_freeDSList = (struct dcache *)tdc->lruq.next;
existing = 1;
}
tdc->dflags = 0; /* up-to-date, not in free q */
tdc->mflags = 0;
QAdd(&afs_DLRU, &tdc->lruq);
if (tdc->lruq.prev == &tdc->lruq)
osi_Panic("lruq 3");
} else {
tdc = tmpdc;
tdc->f.states = 0;
tdc = afs_freeDSList;
afs_freeDSList = (struct dcache *)tdc->lruq.next;
existing = 1;
}
tdc->dflags = 0; /* up-to-date, not in free q */
tdc->mflags = 0;
QAdd(&afs_DLRU, &tdc->lruq);
if (tdc->lruq.prev == &tdc->lruq)
osi_Panic("lruq 3");
/* initialize entry */
tdc->f.fid.Cell = 0;
@ -2636,8 +2630,7 @@ afs_MemGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
AFS_RWLOCK_INIT(&tdc->mflock, "dcache flock");
ObtainReadLock(&tdc->tlock);
if (tmpdc == NULL)
afs_indexTable[aslot] = tdc;
afs_indexTable[aslot] = tdc;
return tdc;
} /*afs_MemGetDSlot */
@ -2653,13 +2646,12 @@ unsigned int last_error = 0, lasterrtime = 0;
*
* Parameters:
* aslot : Dcache slot to look at.
* tmpdc : Ptr to dcache entry.
*
* Environment:
* afs_xdcache lock write-locked.
*/
struct dcache *
afs_UFSGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
afs_UFSGetDSlot(afs_int32 aslot)
{
afs_int32 code;
struct dcache *tdc;
@ -2681,36 +2673,28 @@ afs_UFSGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
ConvertWToRLock(&tdc->tlock);
return tdc;
}
/* otherwise we should read it in from the cache file */
/*
* If we weren't passed an in-memory region to place the file info,
* we have to allocate one.
*/
if (tmpdc == NULL) {
if (!afs_freeDSList)
afs_GetDownDSlot(4);
if (!afs_freeDSList) {
/* none free, making one is better than a panic */
afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */
tdc = afs_osi_Alloc(sizeof(struct dcache));
osi_Assert(tdc != NULL);
if (!afs_freeDSList)
afs_GetDownDSlot(4);
if (!afs_freeDSList) {
/* none free, making one is better than a panic */
afs_stats_cmperf.dcacheXAllocs++; /* count in case we have a leak */
tdc = afs_osi_Alloc(sizeof(struct dcache));
osi_Assert(tdc != NULL);
#ifdef KERNEL_HAVE_PIN
pin((char *)tdc, sizeof(struct dcache)); /* XXX */
pin((char *)tdc, sizeof(struct dcache)); /* XXX */
#endif
} else {
tdc = afs_freeDSList;
afs_freeDSList = (struct dcache *)tdc->lruq.next;
existing = 1;
}
tdc->dflags = 0; /* up-to-date, not in free q */
tdc->mflags = 0;
QAdd(&afs_DLRU, &tdc->lruq);
if (tdc->lruq.prev == &tdc->lruq)
osi_Panic("lruq 3");
} else {
tdc = tmpdc;
tdc->f.states = 0;
tdc = afs_freeDSList;
afs_freeDSList = (struct dcache *)tdc->lruq.next;
existing = 1;
}
tdc->dflags = 0; /* up-to-date, not in free q */
tdc->mflags = 0;
QAdd(&afs_DLRU, &tdc->lruq);
if (tdc->lruq.prev == &tdc->lruq)
osi_Panic("lruq 3");
/*
* Seek to the aslot'th entry and read it in.
@ -2772,8 +2756,7 @@ afs_UFSGetDSlot(afs_int32 aslot, struct dcache *tmpdc)
* If we didn't read into a temporary dcache region, update the
* slot pointer table.
*/
if (tmpdc == NULL)
afs_indexTable[aslot] = tdc;
afs_indexTable[aslot] = tdc;
return tdc;
} /*afs_UFSGetDSlot */
@ -2891,7 +2874,7 @@ afs_InitCacheFile(char *afile, ino_t ainode)
return EINVAL;
ObtainWriteLock(&afs_xdcache, 282);
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
ReleaseWriteLock(&afs_xdcache);

View File

@ -71,7 +71,7 @@ afs_FindDCacheByFid(struct VenusFid *afid)
ObtainWriteLock(&afs_xdcache, 758);
for (index = afs_dvhashTbl[i]; index != NULLIDX;) {
if (afs_indexUnique[index] == afid->Fid.Unique) {
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, afid)) {
break; /* leaving refCount high for caller */
@ -853,7 +853,7 @@ afs_ProcessOpCreate(struct vcache *avc, struct vrequest *areq,
ObtainWriteLock(&afs_xdcache, 743);
for (index = afs_dvhashTbl[hash]; index != NULLIDX; index = hash) {
hash = afs_dvnextTbl[index];
tdc = afs_GetDSlot(index, NULL);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {

View File

@ -3483,7 +3483,7 @@ DECL_PIOCTL(PFlushVolumeData)
for (i = 0; i < afs_cacheFiles; i++) {
if (!(afs_indexFlags[i] & IFEverUsed))
continue; /* never had any data */
tdc = afs_GetDSlot(i, NULL);
tdc = afs_GetDSlot(i);
if (tdc->refCount <= 1) { /* too high, in use by running sys call */
ReleaseReadLock(&tdc->tlock);
if (tdc->f.fid.Fid.Volume == volume && tdc->f.fid.Cell == cell) {

View File

@ -258,8 +258,7 @@ extern void afs_FlushDCache(struct dcache *adc);
extern void shutdown_dcache(void);
extern void afs_CacheTruncateDaemon(void);
extern afs_int32 afs_fsfragsize;
extern struct dcache *afs_MemGetDSlot(afs_int32 aslot,
struct dcache *tmpdc);
extern struct dcache *afs_MemGetDSlot(afs_int32 aslot);
extern struct dcache *afs_GetDCache(struct vcache *avc,
afs_size_t abyte,
struct vrequest *areq,
@ -281,8 +280,7 @@ extern void afs_TryToSmush(struct vcache *avc,
extern void updateV2DC(int lockVc, struct vcache *v, struct dcache *d,
int src);
extern void afs_WriteThroughDSlots(void);
extern struct dcache *afs_UFSGetDSlot(afs_int32 aslot,
struct dcache *tmpdc);
extern struct dcache *afs_UFSGetDSlot(afs_int32 aslot);
extern int afs_WriteDCache(struct dcache *adc, int atime);
extern int afs_wakeup(struct vcache *avc);
extern int afs_InitCacheFile(char *afile, ino_t ainode);

View File

@ -254,7 +254,7 @@ afs_StoreAllSegments(struct vcache *avc, struct vrequest *areq,
for (j = 0; index != NULLIDX;) {
if ((afs_indexFlags[index] & IFDataMod)
&& (afs_indexUnique[index] == avc->f.fid.Fid.Unique)) {
tdc = afs_GetDSlot(index, 0); /* refcount+1. */
tdc = afs_GetDSlot(index); /* refcount+1. */
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid) && tdc->f.chunk >= minj) {
off = tdc->f.chunk - minj;
@ -358,7 +358,7 @@ afs_StoreAllSegments(struct vcache *avc, struct vrequest *areq,
index != NULLIDX && safety < afs_cacheFiles + 2;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, 0);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)
@ -522,7 +522,7 @@ afs_InvalidateAllSegments(struct vcache *avc)
for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, 0);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid))
dcListMax++;
@ -536,7 +536,7 @@ afs_InvalidateAllSegments(struct vcache *avc)
for (index = afs_dvhashTbl[hash]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, 0);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
/* same file? we'll zap it */
@ -714,7 +714,7 @@ afs_TruncateAllSegments(struct vcache *avc, afs_size_t alen,
dcCount = 0;
for (index = afs_dvhashTbl[code]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, 0);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid))
dcCount++;
@ -732,7 +732,7 @@ afs_TruncateAllSegments(struct vcache *avc, afs_size_t alen,
for (index = afs_dvhashTbl[code]; index != NULLIDX;) {
if (afs_indexUnique[index] == avc->f.fid.Fid.Unique) {
tdc = afs_GetDSlot(index, 0);
tdc = afs_GetDSlot(index);
ReleaseReadLock(&tdc->tlock);
if (!FidCmp(&tdc->f.fid, &avc->f.fid)) {
/* same file, and modified, we'll store it back */