Windows: Do not defer Synchronous operations
authorRod Widdowson <rdw@your-file-system.com>
Mon, 14 Apr 2014 20:45:37 +0000 (16:45 -0400)
committerJeffrey Altman <jaltman@your-file-system.com>
Wed, 16 Apr 2014 13:05:20 +0000 (06:05 -0700)
There is nothing to be gained by posting a synchronous write.
Let it hang out in CcCopyWrite until there is enough memory
unless the write became synchronous after a deferral in which
case it can be deferred again.

Introduce bWait variable which is set to the result of
IoIsSynchronousWrite( Irp).

This change is being introduced after further analysis of the
FastFat example.

Change-Id: I0942975a142b0413e52076ee94977401c1d00dc9
Reviewed-on: http://gerrit.openafs.org/11067
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Rod Widdowson <rdw@steadingsoftware.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>

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

index d9809e0..df3c2e8 100644 (file)
@@ -1,6 +1,6 @@
 /*
  * Copyright (c) 2008, 2009, 2010, 2011 Kernel Drivers, LLC.
- * Copyright (c) 2009, 2010, 2011 Your File System, Inc.
+ * Copyright (c) 2009, 2010, 2011, 2012, 2013, 2014 Your File System, Inc.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -121,6 +121,7 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject,
     BOOLEAN            bReleasePaging = FALSE;
     BOOLEAN            bExtendingWrite = FALSE;
     BOOLEAN            bSynchronousFo = FALSE;
+    BOOLEAN           bWait = FALSE;
     BOOLEAN            bCompleteIrp = TRUE;
     BOOLEAN            bForceFlush = FALSE;
     BOOLEAN            bLockOK;
@@ -177,6 +178,7 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject,
         liStartingByte = pIrpSp->Parameters.Write.ByteOffset;
         bPagingIo      = BooleanFlagOn( Irp->Flags, IRP_PAGING_IO);
         bNonCachedIo   = BooleanFlagOn( Irp->Flags, IRP_NOCACHE);
+       bWait          = IoIsOperationSynchronous( Irp);
         ulByteCount    = pIrpSp->Parameters.Write.Length;
         bSynchronousFo = BooleanFlagOn( pFileObject->Flags, FO_SYNCHRONOUS_IO);
 
@@ -430,7 +432,7 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject,
 
                while (!CcCanIWrite( pFileObject,
                                     ulByteCount,
-                                    FALSE,
+                                    bWait && !bRetry,
                                     bRetry))
                {
                    static const LONGLONG llWriteDelay = (LONGLONG)-100000;
@@ -450,7 +452,7 @@ AFSCommonWrite( IN PDEVICE_OBJECT DeviceObject,
 
                if (!CcCanIWrite( pFileObject,
                                  ulByteCount,
-                                 FALSE,
+                                 bWait && !bRetry,
                                  bRetry))
                {