From 8ae06c2ea48651ebd90635ffcc68bbccfeb908c8 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Tue, 22 Jan 2013 12:44:21 -0500 Subject: [PATCH] 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 --- src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp b/src/WINNT/afsrdr/kernel/lib/AFSCleanup.cpp index a92f4ce1b..a6c1ec50a 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; } -- 2.39.5