Windows: SetDispositionInfo !MmFlush SectionObjectResource
authorJeffrey Altman <jaltman@your-file-system.com>
Thu, 6 Dec 2012 19:59:22 +0000 (14:59 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 7 Dec 2012 14:48:51 +0000 (06:48 -0800)
In AFSSetDispositionInfo() if MmFlushImageSection() fails,
be sure to release the SectionObjectResource.

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

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

index 0d9d896..c3547a7 100644 (file)
@@ -2107,6 +2107,7 @@ AFSSetDispositionInfo( IN PIRP Irp,
             }
             else if( pFcb->Header.NodeTypeCode == AFS_FILE_FCB)
             {
+                BOOLEAN bMmFlushed;
 
                 AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
                               AFS_TRACE_LEVEL_VERBOSE,
@@ -2121,46 +2122,41 @@ AFSSetDispositionInfo( IN PIRP Irp,
                 // Attempt to flush any outstanding data
                 //
 
-                if( !MmFlushImageSection( &pFcb->NPFcb->SectionObjectPointers,
-                                          MmFlushForDelete))
+                bMmFlushed = MmFlushImageSection( &pFcb->NPFcb->SectionObjectPointers,
+                                                  MmFlushForDelete);
+
+                if ( bMmFlushed)
                 {
 
+                    //
+                    // Set PENDING_DELETE before CcPurgeCacheSection to avoid a
+                    // deadlock with Trend Micro's Enterprise anti-virus product
+                    // which attempts to open the file which is being deleted.
+                    //
+
                     AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
-                                  AFS_TRACE_LEVEL_ERROR,
-                                  "AFSSetDispositionInfo Failed to flush image section for delete Entry %wZ\n",
+                                  AFS_TRACE_LEVEL_VERBOSE,
+                                  "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n",
+                                  DirectoryCB,
                                   &DirectoryCB->NameInformation.FileName);
 
-                    try_return( ntStatus = STATUS_CANNOT_DELETE);
-                }
+                    SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
 
-                //
-                // Set PENDING_DELETE before CcPurgeCacheSection to avoid a
-                // deadlock with Trend Micro's Enterprise anti-virus product
-                // which attempts to open the file which is being deleted.
-                //
-
-                AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
-                              AFS_TRACE_LEVEL_VERBOSE,
-                              "AFSSetDispositionInfo Setting PENDING_DELETE on DirEntry %p Name %wZ\n",
-                              DirectoryCB,
-                              &DirectoryCB->NameInformation.FileName);
-
-                SetFlag( pCcb->DirectoryCB->Flags, AFS_DIR_ENTRY_PENDING_DELETE);
-
-                //
-                // Purge the cache as well
-                //
-
-                if( pFcb->NPFcb->SectionObjectPointers.DataSectionObject != NULL)
-                {
+                    //
+                    // Purge the cache as well
+                    //
 
-                    if ( !CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers,
-                                               NULL,
-                                               0,
-                                               TRUE))
+                    if( pFcb->NPFcb->SectionObjectPointers.DataSectionObject != NULL)
                     {
 
-                        SetFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+                        if ( !CcPurgeCacheSection( &pFcb->NPFcb->SectionObjectPointers,
+                                                   NULL,
+                                                   0,
+                                                   TRUE))
+                        {
+
+                            SetFlag( pFcb->Flags, AFS_FCB_FLAG_PURGE_ON_CLOSE);
+                        }
                     }
                 }
 
@@ -2171,6 +2167,17 @@ AFSSetDispositionInfo( IN PIRP Irp,
                               PsGetCurrentThread());
 
                 AFSReleaseResource( &pFcb->NPFcb->SectionObjectResource);
+
+                if ( !bMmFlushed)
+                {
+
+                    AFSDbgLogMsg( AFS_SUBSYSTEM_FILE_PROCESSING,
+                                  AFS_TRACE_LEVEL_ERROR,
+                                  "AFSSetDispositionInfo Failed to flush image section for delete Entry %wZ\n",
+                                  &DirectoryCB->NameInformation.FileName);
+
+                    try_return( ntStatus = STATUS_CANNOT_DELETE);
+                }
             }
         }
         else