Windows: AFSWrite comments
authorJeffrey Altman <jaltman@your-file-system.com>
Fri, 23 Aug 2013 19:02:44 +0000 (15:02 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 30 Aug 2013 19:10:51 +0000 (12:10 -0700)
Add various comments regarding lock requirements

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

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

index 0216d03..328ca84 100644 (file)
@@ -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))
         {