Windows: Fcb sectionObjectResource
[openafs.git] / src / WINNT / afsrdr / kernel / lib / AFSCreate.cpp
index 0fbf686..34ee237 100644 (file)
@@ -2679,6 +2679,15 @@ AFSProcessOpen( IN PIRP Irp,
                 BooleanFlagOn(ulOptions, FILE_DELETE_ON_CLOSE))
             {
 
+                AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSProcessOpen Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+                              &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+                              PsGetCurrentThread());
+
+                AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+                                TRUE);
+
                 if( !MmFlushImageSection( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
                                           MmFlushForWrite))
                 {
@@ -2695,6 +2704,14 @@ AFSProcessOpen( IN PIRP Irp,
 
                     try_return( ntStatus);
                 }
+
+                AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSProcessOpen Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+                              &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+                              PsGetCurrentThread());
+
+                AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->SectionObjectResource);
             }
 
             if( BooleanFlagOn( ulOptions, FILE_DIRECTORY_FILE))
@@ -3011,6 +3028,7 @@ AFSProcessOverwriteSupersede( IN PDEVICE_OBJECT DeviceObject,
     LARGE_INTEGER liTime;
     ULONG ulCreateDisposition = 0;
     BOOLEAN bAllocatedCcb = FALSE;
+    BOOLEAN bUserMapped = FALSE;
     PACCESS_MASK pDesiredAccess = NULL;
     USHORT usShareAccess;
     AFSObjectInfoCB *pParentObjectInfo = NULL;
@@ -3135,13 +3153,32 @@ AFSProcessOverwriteSupersede( IN PDEVICE_OBJECT DeviceObject,
             }
         }
 
+        AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                      AFS_TRACE_LEVEL_VERBOSE,
+                      "AFSProcessOverwriteSupercede Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
+                      &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+                      PsGetCurrentThread());
+
+        AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+                        TRUE);
+
         //
         //  Before we actually truncate, check to see if the purge
         //  is going to fail.
         //
 
-        if( !MmCanFileBeTruncated( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
-                                   &liZero))
+        bUserMapped = !MmCanFileBeTruncated( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+                                             &liZero);
+
+        AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                      AFS_TRACE_LEVEL_VERBOSE,
+                      "AFSProcessOverwriteSupercede Releasing Fcb SectionObject lock %08lX EXCL %08lX\n",
+                      &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
+                      PsGetCurrentThread());
+
+        AFSReleaseResource( &pObjectInfo->Fcb->NPFcb->SectionObjectResource);
+
+        if( bUserMapped)
         {
 
             ntStatus = STATUS_USER_MAPPED_FILE;