Windows: AFSWriteCommon collapse redundant condition
authorRod Widdowson <rdw@steadingsoftware.com>
Fri, 15 Feb 2013 11:48:08 +0000 (06:48 -0500)
committerJeffrey Altman <jaltman@your-file-system.com>
Fri, 22 Feb 2013 21:11:18 +0000 (13:11 -0800)
We never get non cached and yet paging IO.  Even if we did it would
be inappropriate to call CcCanIWrite.  Therefore, collapse two if
statements into one.

Change-Id: I95c9030836e4f7dc4f7867a8b8b09b97bf57b429
Reviewed-on: http://gerrit.openafs.org/9125
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Peter Scott <pscott@kerneldrivers.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

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

index a868630..39fe479 100644 (file)
@@ -335,74 +335,70 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject,
             bNonCachedIo = FALSE;
         }
 
-        if ( !bNonCachedIo) {
+        if ( !bNonCachedIo && !bPagingIo)
+        {
 
-            if( !bPagingIo)
+            if( pFileObject->PrivateCacheMap == NULL)
             {
 
-                if( pFileObject->PrivateCacheMap == NULL)
-                {
-
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSCommonWrite Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
-                                  &pNPFcb->SectionObjectResource,
-                                  PsGetCurrentThread());
-
-                    AFSAcquireExcl( &pNPFcb->SectionObjectResource,
-                                    TRUE);
+                AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSCommonWrite Acquiring Fcb SectionObject lock %p EXCL %08lX\n",
+                              &pNPFcb->SectionObjectResource,
+                              PsGetCurrentThread());
 
-                    bReleaseSectionObject = TRUE;
+                AFSAcquireExcl( &pNPFcb->SectionObjectResource,
+                                TRUE);
 
-                    __try
-                    {
+                bReleaseSectionObject = TRUE;
 
-                        AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
-                                      AFS_TRACE_LEVEL_VERBOSE,
-                                      "AFSCommonWrite Initialize caching on Fcb %p FileObject %p\n",
-                                      pFcb,
-                                      pFileObject);
+                __try
+                {
 
-                        CcInitializeCacheMap( pFileObject,
-                                              (PCC_FILE_SIZES)&pFcb->Header.AllocationSize,
-                                              FALSE,
-                                              AFSLibCacheManagerCallbacks,
-                                              pFcb);
+                    AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
+                                  AFS_TRACE_LEVEL_VERBOSE,
+                                  "AFSCommonWrite Initialize caching on Fcb %p FileObject %p\n",
+                                  pFcb,
+                                  pFileObject);
 
-                        CcSetReadAheadGranularity( pFileObject,
-                                                   pDeviceExt->Specific.RDR.MaximumRPCLength);
+                    CcInitializeCacheMap( pFileObject,
+                                          (PCC_FILE_SIZES)&pFcb->Header.AllocationSize,
+                                          FALSE,
+                                          AFSLibCacheManagerCallbacks,
+                                          pFcb);
 
-                        CcSetDirtyPageThreshold( pFileObject,
-                                                 AFS_DIRTY_CHUNK_THRESHOLD * pDeviceExt->Specific.RDR.MaximumRPCLength / 4096);
-                    }
-                    __except( EXCEPTION_EXECUTE_HANDLER)
-                    {
+                    CcSetReadAheadGranularity( pFileObject,
+                                               pDeviceExt->Specific.RDR.MaximumRPCLength);
 
-                        ntStatus = GetExceptionCode();
+                    CcSetDirtyPageThreshold( pFileObject,
+                                             AFS_DIRTY_CHUNK_THRESHOLD * pDeviceExt->Specific.RDR.MaximumRPCLength / 4096);
+                }
+                __except( EXCEPTION_EXECUTE_HANDLER)
+                {
 
-                        AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
-                                      AFS_TRACE_LEVEL_ERROR,
-                                      "AFSCommonWrite (%p) Exception thrown while initializing cache map Status %08lX\n",
-                                      Irp,
-                                      ntStatus);
-                    }
+                    ntStatus = GetExceptionCode();
 
-                    AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
-                                  AFS_TRACE_LEVEL_VERBOSE,
-                                  "AFSCommonWrite Releasing Fcb SectionObject lock %p EXCL %08lX\n",
-                                  &pNPFcb->SectionObjectResource,
-                                  PsGetCurrentThread());
+                    AFSDbgLogMsg( AFS_SUBSYSTEM_IO_PROCESSING,
+                                  AFS_TRACE_LEVEL_ERROR,
+                                  "AFSCommonWrite (%p) Exception thrown while initializing cache map Status %08lX\n",
+                                  Irp,
+                                  ntStatus);
+                }
 
-                    AFSReleaseResource( &pNPFcb->SectionObjectResource);
+                AFSDbgLogMsg( AFS_SUBSYSTEM_LOCK_PROCESSING,
+                              AFS_TRACE_LEVEL_VERBOSE,
+                              "AFSCommonWrite Releasing Fcb SectionObject lock %p EXCL %08lX\n",
+                              &pNPFcb->SectionObjectResource,
+                              PsGetCurrentThread());
 
-                    bReleaseSectionObject = FALSE;
+                AFSReleaseResource( &pNPFcb->SectionObjectResource);
 
+                bReleaseSectionObject = FALSE;
 
-                    if( !NT_SUCCESS( ntStatus))
-                    {
+                if( !NT_SUCCESS( ntStatus))
+                {
 
-                        try_return( ntStatus);
-                    }
+                    try_return( ntStatus);
                 }
             }