From: Jeffrey Altman Date: Fri, 23 Aug 2013 19:02:44 +0000 (-0400) Subject: Windows: AFSWrite comments X-Git-Tag: upstream/1.8.0_pre1^2~1029 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=c7e8b75353e2cd0bb58b05c9faab21df14c73c69;p=packages%2Fo%2Fopenafs.git 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 --- diff --git a/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp b/src/WINNT/afsrdr/kernel/lib/AFSWrite.cpp index 0216d03a9..328ca8428 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)) {