From e05a095455294feff4e1b28a432896222a3ffd94 Mon Sep 17 00:00:00 2001 From: Andrew Deason Date: Mon, 30 Apr 2018 17:33:14 -0500 Subject: [PATCH] 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 --- src/afs/afs_dcache.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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; -- 2.39.5