Windows: AFSCleanupFile always flush on last handle
authorJeffrey Altman <jaltman@your-file-system.com>
Tue, 22 Jan 2013 17:44:21 +0000 (12:44 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Sat, 2 Feb 2013 17:19:10 +0000 (09:19 -0800)
Do not rely on a count of dirty extents to determine if the
service should flush a file during a cleanup operation.  Simply
because there are no dirty extents held by the redirector does
not imply that the service has no dirty buffers for the file.

Change-Id: Ifc7c139a587413626eae145f343c4295dd94f28a
Reviewed-on: http://gerrit.openafs.org/8971
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp

index a92f4ce..a6c1ec5 100644 (file)
@@ -596,18 +596,23 @@ AFSCleanup( IN PDEVICE_OBJECT LibDeviceObject,
                                                         (ULONG)FILE_ACTION_MODIFIED);
                     }
 
+
                     //
-                    // Attempt to flush any dirty extents to the server. This may be a little
-                    // aggressive, to flush whenever the handle is closed, but it ensures
-                    // coherency.
+                    // Whenever a handle with write access or the last handle is closed
+                    // notify the service to FSync the file.  If the redirector is holding
+                    // dirty extents, flush them to the service.  This is a bit aggressive
+                    // but it ensures cache coherency.
                     //
 
-                    if( (pCcb->GrantedAccess & FILE_WRITE_DATA) &&
-                        pFcb->Specific.File.ExtentsDirtyCount != 0)
+                    if( (pCcb->GrantedAccess & FILE_WRITE_DATA) || (pFcb->OpenHandleCount == 1))
                     {
 
-                        AFSFlushExtents( pFcb,
-                                         &pCcb->AuthGroup);
+                        if ( pFcb->Specific.File.ExtentsDirtyCount != 0)
+                        {
+
+                            AFSFlushExtents( pFcb,
+                                             &pCcb->AuthGroup);
+                        }
 
                         ulNotificationFlags |= AFS_REQUEST_FLAG_FLUSH_FILE;
                     }