From c7e8b75353e2cd0bb58b05c9faab21df14c73c69 Mon Sep 17 00:00:00 2001 From: Jeffrey Altman Date: Fri, 23 Aug 2013 15:02:44 -0400 Subject: [PATCH 1/1] Windows: AFSWrite comments Add various comments regarding lock requirements Change-Id: I285eb416ef7d05ef29fcffbc5ce9afd5d3d27322 Reviewed-on: http://gerrit.openafs.org/10185 Tested-by: BuildBot Reviewed-by: Jeffrey Altman --- src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp b/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp index 0216d03..328ca84 100644 --- a/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp +++ b/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp @@ -522,6 +522,11 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject, // Check for lock inversion // + // + // For bExtendingWrite the PagingResource is needed to protect + // the CcSetFileSizes call in AFSExtendingWrite + // + ASSERT( !ExIsResourceAcquiredLite( &pNPFcb->PagingResource )); AFSDbgTrace(( AFS_SUBSYSTEM_LOCK_PROCESSING, @@ -641,6 +646,10 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject, ntStatus = AFSExtendingWrite( pFcb, pFileObject, (liStartingByte.QuadPart + ulByteCount)); + // + // Fcb->NPFcb->Resource is now held SHARED + // + if( !NT_SUCCESS(ntStatus)) { @@ -665,7 +674,8 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject, { // - // Main and SectionObject resources held Shared + // Main resource held Shared + // SectionObject resource held exclusive if extending write // AFSDbgTrace(( AFS_SUBSYSTEM_IO_PROCESSING, @@ -2008,6 +2018,10 @@ try_exit: return ntStatus; } +// +// Called with Fcb->NPFcb->SectionObjectResource and Fcb->NPFcb->Resource held +// + static NTSTATUS AFSExtendingWrite( IN AFSFcb *Fcb, @@ -2053,6 +2067,9 @@ AFSExtendingWrite( IN AFSFcb *Fcb, // // If the file is currently cached, then let the MM know about the extension // + // The CcSetFileSizes call should be made with only the PagingResource held + // which we are currently not holding. + // if( CcIsFileCached( FileObject)) { -- 1.9.4