LINUX: Return NULL for afs_linux_raw_open error
[openafs.git] / src / afs / afs_dcache.c
index dc14762..321e37f 100644 (file)
@@ -1188,6 +1188,7 @@ afs_FreeDiscardedDCache(void)
      * Truncate the element to reclaim its space
      */
     tfile = afs_CFileOpen(&tdc->f.inode);
+    osi_Assert(tfile);
     afs_CFileTruncate(tfile, 0);
     afs_CFileClose(tfile);
     afs_AdjustSize(tdc, 0);
@@ -1619,6 +1620,7 @@ afs_AllocDiscardDSlot(afs_int32 lock)
     if ((lock & 2)) {
        /* Truncate the chunk so zeroes get filled properly */
        file = afs_CFileOpen(&tdc->f.inode);
+        osi_Assert(file);
        afs_CFileTruncate(file, 0);
        afs_CFileClose(file);
        afs_AdjustSize(tdc, 0);
@@ -2076,6 +2078,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
            /* no data in file to read at this position */
            UpgradeSToWLock(&tdc->lock, 607);
            file = afs_CFileOpen(&tdc->f.inode);
+            osi_Assert(file);
            afs_CFileTruncate(file, 0);
            afs_CFileClose(file);
            afs_AdjustSize(tdc, 0);
@@ -2295,6 +2298,7 @@ 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);
        afs_RemoveVCB(&avc->f.fid);
        tdc->f.states |= DWriting;
        tdc->dflags |= DFFetching;
@@ -2423,13 +2427,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
                    afs_CFileTruncate(file, size);      /* prune it */
                } else {
                    if (!setLocks || slowPass) {
-                       ObtainWriteLock(&afs_xcbhash, 453);
-                       afs_DequeueCallback(avc);
-                       avc->f.states &= ~(CStatd | CUnique);
-                       avc->callback = NULL;
-                       ReleaseWriteLock(&afs_xcbhash);
-                       if (avc->f.fid.Fid.Vnode & 1 || (vType(avc) == VDIR))
-                           osi_dnlc_purgedp(avc);
+                       afs_StaleVCacheFlags(avc, AFS_STALEVC_CLEARCB, CUnique);
                    } else {
                        /* Something lost.  Forget about performance, and go
                         * back with a vcache write lock.
@@ -2504,12 +2502,7 @@ afs_GetDCache(struct vcache *avc, afs_size_t abyte,
            ReleaseWriteLock(&tdc->lock);
            afs_PutDCache(tdc);
            if (!afs_IsDynroot(avc)) {
-               ObtainWriteLock(&afs_xcbhash, 454);
-               afs_DequeueCallback(avc);
-               avc->f.states &= ~(CStatd | CUnique);
-               ReleaseWriteLock(&afs_xcbhash);
-               if (avc->f.fid.Fid.Vnode & 1 || (vType(avc) == VDIR))
-                   osi_dnlc_purgedp(avc);
+               afs_StaleVCacheFlags(avc, 0, CUnique);
                /*
                 * Locks held:
                 * avc->lock(W); assert(!setLocks || slowPass)
@@ -3627,6 +3620,8 @@ afs_MakeShadowDir(struct vcache *avc, struct dcache *adc)
     /* Open the files. */
     tfile_src = afs_CFileOpen(&adc->f.inode);
     tfile_dst = afs_CFileOpen(&new_dc->f.inode);
+    osi_Assert(tfile_src);
+    osi_Assert(tfile_dst);
 
     /* And now copy dir dcache data into this dcache,
      * 4k at a time.