linux-truncate-race-20090109
[openafs.git] / src / afs / VNOPS / afs_vnop_attrs.c
index 36606aa..58b9a00 100644 (file)
@@ -546,6 +546,13 @@ afs_setattr(OSI_VC_DECL(avc), register struct vattr *attrs,
        avc->states |= CDirty;
 
        code = afs_TruncateAllSegments(avc, tsize, &treq, acred);
+#ifdef AFS_LINUX_26_ENV
+       /* We must update the Linux kernel's idea of file size as soon as
+        * possible, to avoid racing with delayed writepages delivered by
+        * pdflush */
+       if (code == 0) 
+           i_size_write(AFSTOV(avc), tsize);
+#endif
        /* if date not explicitly set by this call, set it ourselves, since we
         * changed the data */
        if (!(astat.Mask & AFS_SETMODTIME)) {