afs: Ensure CDirty is set during afs_write loop
[openafs.git] / src / afs / VNOPS / afs_vnop_write.c
index 1c203ce..c720f6a 100644 (file)
@@ -302,9 +302,16 @@ afs_write(struct vcache *avc, struct uio *auio, int aio,
 #else
     afs_FakeOpen(avc);
 #endif
-    avc->f.states |= CDirty;
 
     while (totalLength > 0) {
+       /*
+        * Note that we must set CDirty for every iteration of this loop.
+        * CDirty may get cleared below (such as during afs_DoPartialStore),
+        * but we're still writing to the file, so make sure CDirty is set
+        * here.
+        */
+       avc->f.states |= CDirty;
+
        tdc = afs_ObtainDCacheForWriting(avc, filePos, totalLength, treq,
                                         noLock);
        if (!tdc) {