From: Andrew Deason Date: Mon, 30 Apr 2018 22:33:14 +0000 (-0500) Subject: afs: Avoid afs_GetDCache panic on cache open error X-Git-Tag: upstream/1.8.1_pre2^2~73 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=e05a095455294feff4e1b28a432896222a3ffd94;p=packages%2Fo%2Fopenafs.git afs: Avoid afs_GetDCache panic on cache open error When we need to populate a dcache entry, afs_GetDCache calls afs_CFileOpen to get a handle for our file backing that dcache. Currently, if we cannot open the file, we panic. To handle this a little more gracefully, just return an error from afs_GetDCache instead. The relevant userspace request will probably fail with EIO, but this is better than possibly crashing the whole system. Reviewed-on: https://gerrit.openafs.org/13046 Reviewed-by: Benjamin Kaduk Tested-by: Benjamin Kaduk (cherry picked from commit 22e64df8e043fa7bd78bff263866ee2bd6a6e13d) Change-Id: Iddc7b0ebc56a64d792251f1f42c576603f2a86cf Reviewed-on: https://gerrit.openafs.org/13072 Reviewed-by: Mark Vitale Reviewed-by: Michael Meffie Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- diff --git a/src/afs/afs_dcache.c b/src/afs/afs_dcache.c index 321e37f5a..6ca9c1fa1 100644 --- a/src/afs/afs_dcache.c +++ b/src/afs/afs_dcache.c @@ -2298,7 +2298,14 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte, */ DZap(tdc); /* pages in cache may be old */ file = afs_CFileOpen(&tdc->f.inode); - osi_Assert(file); + if (!file) { + /* We can't access the file in the disk cache backing this dcache; + * bail out. */ + ReleaseWriteLock(&tdc->lock); + afs_PutDCache(tdc); + tdc = NULL; + goto done; + } afs_RemoveVCB(&avc->f.fid); tdc->f.states |= DWriting; tdc->dflags |= DFFetching;