afs: Remove second argument to afs_GetDSlot
authorAndrew Deason <adeason@sinenomine.net>
Wed, 21 Dec 2011 22:25:29 +0000 (17:25 -0500)
committerDerrick Brashear <shadow@dementix.org>
Tue, 27 Dec 2011 04:29:27 +0000 (20:29 -0800)
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.

Change-Id: I138fe917d739c3020c35c20da48ffdf38f682fd6
Reviewed-on: http://gerrit.openafs.org/6416
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>

src/afs/afs_chunkops.h
src/afs/afs_dcache.c
src/afs/afs_disconnected.c
src/afs/afs_pioctl.c
src/afs/afs_prototypes.h
src/afs/afs_segments.c

index f20bd05..df6b4e6 100644 (file)
@@ -60,8 +60,7 @@ struct afs_cacheOps {
     int (*close) (struct osi_file * fp);
     int (*vreadUIO) (afs_dcache_id_t *, struct uio *);
     int (*vwriteUIO) (struct vcache *, afs_dcache_id_t *, struct uio *);
-    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);
 };
@@ -72,7 +71,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)
 
index 3c2d96d..6dac860 100644 (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);
 
index 795412c..223b838 100644 (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)) {
index 2589b79..200a00e 100644 (file)
@@ -3546,7 +3546,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) {
index 46f2c76..eb2e080 100644 (file)
@@ -250,8 +250,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,
@@ -273,8 +272,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);
index 0d827dc..515c363 100644 (file)
@@ -252,7 +252,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;
@@ -356,7 +356,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)
@@ -520,7 +520,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++;
@@ -534,7 +534,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 */
@@ -712,7 +712,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++;
@@ -730,7 +730,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 */