From: Andrew Deason Date: Thu, 1 Nov 2012 20:43:09 +0000 (-0500) Subject: afs: Handle afs_AllocDCache errors X-Git-Tag: openafs-stable-1_8_0pre1~1812 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=e02185547e316667989a100f77e68b918481b597;hp=64ee7b32f134e6431eb2894ed4397f8b1fea25ad afs: Handle afs_AllocDCache errors Do not panic if afs_AllocDCache encounters an error and returns NULL. Instead, go into the normal retry loop that occurs if we couldn't free up any more free/discard dcache entries. Change-Id: Ia165e0b5f5ef37e05942c795955d75f26e4ea7d3 Reviewed-on: http://gerrit.openafs.org/8405 Tested-by: BuildBot Reviewed-by: Derrick Brashear --- diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index b48c05f..b398cf5 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -1892,35 +1892,36 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, goto done; } - /* Make sure there is a free dcache entry for us to use */ if (afs_discardDCList == NULLIDX && afs_freeDCList == NULLIDX) { - while (1) { - if (!setLocks) - avc->f.states |= CDCLock; - /* just need slots */ - afs_GetDownD(5, (int *)0, afs_DCGetBucket(avc)); - if (!setLocks) - avc->f.states &= ~CDCLock; - if (afs_discardDCList != NULLIDX - || afs_freeDCList != NULLIDX) - break; - /* If we can't get space for 5 mins we give up and panic */ - if (++downDCount > 300) { - osi_Panic("getdcache"); - } - ReleaseWriteLock(&afs_xdcache); - /* - * Locks held: - * avc->lock(R) if setLocks - * avc->lock(W) if !setLocks - */ - afs_osi_Wait(1000, 0, 0); - goto RetryLookup; - } + if (!setLocks) + avc->f.states |= CDCLock; + /* just need slots */ + afs_GetDownD(5, (int *)0, afs_DCGetBucket(avc)); + if (!setLocks) + avc->f.states &= ~CDCLock; } - tdc = afs_AllocDCache(avc, chunk, aflags, NULL); - osi_Assert(tdc); + if (!tdc) { + /* If we can't get space for 5 mins we give up and panic */ + if (++downDCount > 300) + osi_Panic("getdcache"); + ReleaseWriteLock(&afs_xdcache); + /* + * Locks held: + * avc->lock(R) if setLocks + * avc->lock(W) if !setLocks + */ + afs_osi_Wait(1000, 0, 0); + goto RetryLookup; + } + + /* + * Locks held: + * avc->lock(R) if setLocks + * avc->lock(W) if !setLocks + * tdc->lock(W) + * afs_xdcache(W) + */ /* * Now add to the two hash chains - note that i is still set