From: Jeffrey Altman Date: Tue, 22 Jan 2013 17:44:21 +0000 (-0500) Subject: Windows: AFSCleanupFile always flush on last handle X-Git-Tag: openafs-stable-1_8_0pre1~1592 X-Git-Url: https://git.openafs.org/?p=openafs.git;a=commitdiff_plain;h=8ae06c2ea48651ebd90635ffcc68bbccfeb908c8 Windows: AFSCleanupFile always flush on last handle 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 Reviewed-by: Jeffrey Altman Tested-by: Jeffrey Altman --- diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp index a92f4ce..a6c1ec5 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp @@ -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; }