Windows: AFSProcessOpen !MmFlush release SectionObjectResource
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 6 Dec 2012 19:24:12 +0000 (14:24 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 7 Dec 2012 14:54:39 +0000 (06:54 -0800)
Restructure the code around the MmFlushImageSection() call in
AFSProcessOpen() to ensure that the SectionObjectResource is
released even when the flush fails.

Change-Id: Ifd6b25640df796f64fba46b920fdababa5224637
Reviewed-on: http://gerrit.openafs.org/8713
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>

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

index 34ee237..82e3658 100644 (file)
@@ -2679,6 +2679,8 @@ AFSProcessOpen( IN PIRP Irp,
                 BooleanFlagOn(ulOptions, FILE_DELETE_ON_CLOSE))
             {
 
+                BOOLEAN bMmFlushed;
+
                 AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
                               AFS_TRACE_LEVEL_VERBOSE,
                               "AFSProcessOpen Acquiring Fcb SectionObject lock %08lX EXCL %08lX\n",
@@ -2688,8 +2690,18 @@ AFSProcessOpen( IN PIRP Irp,
                 AFSAcquireExcl( &pObjectInfo->Fcb->NPFcb->SectionObjectResource,
                                 TRUE);
 
-                if( !MmFlushImageSection( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
-                                          MmFlushForWrite))
+                bMmFlushed = MmFlushImageSection( &pObjectInfo->Fcb->NPFcb->SectionObjectPointers,
+                                                  MmFlushForWrite);
+
+                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 ( !bMmFlushed)
                 {
 
                     ntStatus = BooleanFlagOn(ulOptions, FILE_DELETE_ON_CLOSE) ? STATUS_CANNOT_DELETE :
@@ -2704,14 +2716,6 @@ 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))