]> git.michaelhowe.org Git - packages/o/openafs.git/commitdiff
newvcache-can-fail-now-20051014
authorPeter Somogyi <psomogyi@gamax.hu>
Sat, 15 Oct 2005 03:32:06 +0000 (03:32 +0000)
committerDerrick Brashear <shadow@dementia.org>
Sat, 15 Oct 2005 03:32:06 +0000 (03:32 +0000)
FIXES 22260

allow newvcache to fail without ooping

sort of nasty, if you want more vcaches, say so.

src/afs/VNOPS/afs_vnop_lookup.c
src/afs/VNOPS/afs_vnop_symlink.c
src/afs/afs_vcache.c

index 057dc4373df9055af3ce7fb8a1400104c7ade951..df5f09e43a0e43365ccc88913a1a0cc13477b866 100644 (file)
@@ -709,15 +709,24 @@ afs_DoBulkStat(struct vcache *adp, long dirCookie, struct vrequest *areqp)
            } while (tvcp && retry);
            if (!tvcp) {        /* otherwise, create manually */
                tvcp = afs_NewVCache(&tfid, hostp);
-               ObtainWriteLock(&tvcp->lock, 505);
-               ReleaseWriteLock(&afs_xvcache);
-               afs_RemoveVCB(&tfid);
-               ReleaseWriteLock(&tvcp->lock);
+               if (tvcp)
+               {
+                       ObtainWriteLock(&tvcp->lock, 505);
+                       ReleaseWriteLock(&afs_xvcache);
+                       afs_RemoveVCB(&tfid);
+                       ReleaseWriteLock(&tvcp->lock);
+               } else {
+                       ReleaseWriteLock(&afs_xvcache);
+               }
            } else {
                ReleaseWriteLock(&afs_xvcache);
            }
            if (!tvcp)
-               goto done;      /* can't happen at present, more's the pity */
+           {
+               ReleaseReadLock(&dcp->lock);
+               ReleaseReadLock(&adp->lock);
+               goto done;      /* can happen if afs_NewVCache fails */
+           }
 
 #ifdef AFS_DARWIN80_ENV
             if (tvcp->states & CVInit) {
index b273a2dd6336a4a4c488276672fe2d574b430238..205e40743c0146d89c3233ff5cea13bb6fc2a6b8 100644 (file)
@@ -191,6 +191,12 @@ int afs_symlink
      * no one can get a pointer to the new cache entry until we release 
      * the xvcache lock. */
     tvc = afs_NewVCache(&newFid, hostp);
+    if (!tvc)
+    {
+       code = -2;
+       ReleaseWriteLock(&afs_xvcache);
+       goto done;
+    }
     ObtainWriteLock(&tvc->lock, 157);
     ObtainWriteLock(&afs_xcbhash, 500);
     tvc->states |= CStatd;     /* have valid info */
index 6c0bc8267eb8fbfcfa79b858b2392933e5afeed9..31cf9177ee0b5776f1c0795da084972aa28d0156 100644 (file)
@@ -695,12 +695,11 @@ restart:
                break;
        }
        if (anumber == VCACHE_FREE) {
-           printf("NewVCache: warning none freed, using %d of %d\n",
+           printf("afs_NewVCache: warning none freed, using %d of %d\n",
                   afs_vcount, afs_maxvcount);
            if (afs_vcount >= afs_maxvcount) {
-               osi_Panic("NewVCache - none freed");
-               /* XXX instead of panicing, should do afs_maxvcount++
-                * and magic up another one */
+               printf("afs_NewVCache - none freed\n");
+               return NULL;
            }
        }
     }
@@ -1697,6 +1696,12 @@ afs_GetVCache(register struct VenusFid *afid, struct vrequest *areq,
        newvcache = 1;
 
        ConvertWToSLock(&afs_xvcache);
+       if (!tvc)
+       {
+               ReleaseSharedLock(&afs_xvcache);
+               return NULL;
+       }
+
        afs_stats_cmperf.vcacheMisses++;
     }
 
@@ -1921,6 +1926,11 @@ afs_LookupVCache(struct VenusFid *afid, struct vrequest *areq,
        tvc = afs_NewVCache(&nfid, serverp);
        newvcache = 1;
        ConvertWToSLock(&afs_xvcache);
+       if (!tvc)
+       {
+               ReleaseSharedLock(&afs_xvcache);
+               return NULL;
+       }
     }
 
     ReleaseSharedLock(&afs_xvcache);
@@ -2104,6 +2114,11 @@ afs_GetRootVCache(struct VenusFid *afid, struct vrequest *areq,
        UpgradeSToWLock(&afs_xvcache, 23);
        /* no cache entry, better grab one */
        tvc = afs_NewVCache(afid, NULL);
+       if (!tvc)
+       {
+               ReleaseWriteLock(&afs_xvcache);
+               return NULL;
+       }
        newvcache = 1;
        afs_stats_cmperf.vcacheMisses++;
     } else {
@@ -2374,6 +2389,11 @@ afs_StuffVcache(register struct VenusFid *afid,
        tvc = afs_NewVCache(afid, NULL);
        newvcache = 1;
        ConvertWToSLock(&afs_xvcache);
+       if (!tvc)
+       {
+               ReleaseSharedLock(&afs_xvcache);
+               return NULL;
+       }
     }
 
     ReleaseSharedLock(&afs_xvcache);