segments-keep-chunkbytes-and-validpos-in-sync-20040914
authorChristof Hanke <hanke@rzg.mpg.de>
Wed, 15 Sep 2004 04:54:28 +0000 (04:54 +0000)
committerDerrick Brashear <shadow@dementia.org>
Wed, 15 Sep 2004 04:54:28 +0000 (04:54 +0000)
FIXES 15200

"Basically, the pointers (struct dcache *)->validPos and (struct dcache *)->f.chunkBytes are not kept in sync."

src/afs/afs_segments.c

index f9d5b80..1ebbceb 100644 (file)
@@ -1041,6 +1041,12 @@ afs_TruncateAllSegments(register struct vcache *avc, afs_size_t alen,
            afs_CFileTruncate(tfile, newSize);
            afs_CFileClose(tfile);
            afs_AdjustSize(tdc, newSize);
+           if (alen < tdc->validPos) {
+                if (alen < AFS_CHUNKTOBASE(tdc->f.chunk))
+                    tdc->validPos = 0;
+                else
+                    tdc->validPos = alen;
+            }
            ConvertWToSLock(&tdc->lock);
        }
        ReleaseSharedLock(&tdc->lock);