win-pvdrivers

changeset 1057:2d5fbe07e866

More XenCache updates
author James Harper <james.harper@bendigoit.com.au>
date Sat Jun 08 10:42:55 2013 +1000 (2013-06-08)
parents b29ed182391f
children 8b6500e0ebfc
files quicksign.bat xencache/xencache.c xencache/xencache.h xencache/xencache.inx
line diff
     1.1 --- a/quicksign.bat	Tue Jun 04 12:15:51 2013 +1000
     1.2 +++ b/quicksign.bat	Sat Jun 08 10:42:55 2013 +1000
     1.3 @@ -35,3 +35,4 @@ IF DEFINED CERT_PASSWORD SET CERT_PASSWO
     1.4  %SIGNTOOL% sign /v %CERT_CROSS_CERT_FLAG% /f %CERT_FILENAME% %CERT_PASSWORD_FLAG% /t http://timestamp.verisign.com/scripts/timstamp.dll xennet\%BUILDDIR%\xennet.sys
     1.5  %SIGNTOOL% sign /v %CERT_CROSS_CERT_FLAG% /f %CERT_FILENAME% %CERT_PASSWORD_FLAG% /t http://timestamp.verisign.com/scripts/timstamp.dll xenscsi\%BUILDDIR%\xenscsi.sys
     1.6  %SIGNTOOL% sign /v %CERT_CROSS_CERT_FLAG% /f %CERT_FILENAME% %CERT_PASSWORD_FLAG% /t http://timestamp.verisign.com/scripts/timstamp.dll xenusb\%BUILDDIR%\xenusb.sys
     1.7 +%SIGNTOOL% sign /v %CERT_CROSS_CERT_FLAG% /f %CERT_FILENAME% %CERT_PASSWORD_FLAG% /t http://timestamp.verisign.com/scripts/timstamp.dll xencache\%BUILDDIR%\xencache.sys
     2.1 --- a/xencache/xencache.c	Tue Jun 04 12:15:51 2013 +1000
     2.2 +++ b/xencache/xencache.c	Sat Jun 08 10:42:55 2013 +1000
     2.3 @@ -267,17 +267,24 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
     2.4    pagefile_context_t *context;
     2.5    int i;
     2.6    KIRQL old_irql;
     2.7 -  ULONG rc;
     2.8 +  LONG rc;
     2.9    struct tmem_op tmem_op;
    2.10  
    2.11    UNREFERENCED_PARAMETER(data);
    2.12    UNREFERENCED_PARAMETER(flt_objects);
    2.13    UNREFERENCED_PARAMETER(completion_context);
    2.14  
    2.15 +  if (global_context.error_count) {
    2.16 +    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.17 +  }
    2.18    if (!FsRtlIsPagingFile(flt_objects->FileObject)) {
    2.19      return FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.20    }
    2.21  
    2.22 +  if (!(data->Flags & FLTFL_CALLBACK_DATA_IRP_OPERATION)) {
    2.23 +    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.24 +  }
    2.25 +
    2.26    KeAcquireSpinLock(&global_context.lock, &old_irql);
    2.27    for (context = global_context.pagefile_head; context; context = context->next) {
    2.28      if (context->file_object == flt_objects->FileObject)
    2.29 @@ -300,12 +307,15 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
    2.30      tmem_op.u.new.flags = (TMEM_SPEC_VERSION << TMEM_VERSION_SHIFT); /* private, not shared */
    2.31      context->pool_id = XnTmemOp(&tmem_op);
    2.32      FUNCTION_MSG("pool_id = %d\n", context->pool_id);
    2.33 +    if (context->pool_id < 0) {
    2.34 +      ExFreePoolWithTag(context, XENCACHE_POOL_TAG);
    2.35 +      global_context.error_count++;
    2.36 +      KeReleaseSpinLock(&global_context.lock, old_irql);
    2.37 +      /* should actually unload here */
    2.38 +      return FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.39 +    }
    2.40      global_context.pagefile_head = context;
    2.41    }
    2.42 -  if (!(data->Flags & FLTFL_CALLBACK_DATA_IRP_OPERATION)) {
    2.43 -    KeReleaseSpinLock(&global_context.lock, old_irql);
    2.44 -    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.45 -  }
    2.46  
    2.47    for (i = 0; i < (int)data->Iopb->Parameters.Write.Length >> PAGE_SHIFT; i++) {
    2.48      ULONG page = (ULONG)(data->Iopb->Parameters.Write.ByteOffset.QuadPart >> PAGE_SHIFT) + i;
    2.49 @@ -327,6 +337,8 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
    2.50        context->put_fail_count++;
    2.51      } else {
    2.52        FUNCTION_MSG("TMEM_PUT_PAGE = %d\n", rc);
    2.53 +      context->put_fail_count++;
    2.54 +      context->error_count++;
    2.55      }
    2.56    }
    2.57    KeReleaseSpinLock(&global_context.lock, old_irql);
    2.58 @@ -335,6 +347,7 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
    2.59      FUNCTION_MSG("   put_fail_count    = %I64d\n", context->put_fail_count);
    2.60      FUNCTION_MSG("   get_success_count = %I64d\n", context->get_success_count);
    2.61      FUNCTION_MSG("   get_fail_count    = %I64d\n", context->get_fail_count);
    2.62 +    FUNCTION_MSG("   error_count    = %I64d\n", context->error_count);
    2.63    }
    2.64    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.65  }
    2.66 @@ -345,7 +358,7 @@ XenCache_Pre_READ(PFLT_CALLBACK_DATA dat
    2.67    pagefile_context_t *context;
    2.68    KIRQL old_irql;
    2.69    int i;
    2.70 -  ULONG rc;
    2.71 +  LONG rc;
    2.72    struct tmem_op tmem_op;
    2.73    
    2.74    UNREFERENCED_PARAMETER(data);
    2.75 @@ -395,6 +408,7 @@ XenCache_Pre_READ(PFLT_CALLBACK_DATA dat
    2.76        FUNCTION_MSG("TMEM_GET_PAGE = %d\n", rc);
    2.77        status = FLT_PREOP_SUCCESS_NO_CALLBACK;
    2.78        context->get_fail_count++;
    2.79 +      context->error_count++;
    2.80      }
    2.81    }
    2.82    
    2.83 @@ -403,6 +417,7 @@ XenCache_Pre_READ(PFLT_CALLBACK_DATA dat
    2.84      FUNCTION_MSG("   put_fail_count    = %I64d\n", context->put_fail_count);
    2.85      FUNCTION_MSG("   get_success_count = %I64d\n", context->get_success_count);
    2.86      FUNCTION_MSG("   get_fail_count    = %I64d\n", context->get_fail_count);
    2.87 +    FUNCTION_MSG("   error_count    = %I64d\n", context->error_count);
    2.88    }
    2.89    KeReleaseSpinLock(&global_context.lock, old_irql);
    2.90  
     3.1 --- a/xencache/xencache.h	Tue Jun 04 12:15:51 2013 +1000
     3.2 +++ b/xencache/xencache.h	Sat Jun 08 10:42:55 2013 +1000
     3.3 @@ -39,18 +39,20 @@ typedef struct _global_context_t global_
     3.4  struct _global_context_t {
     3.5    KSPIN_LOCK lock;
     3.6    pagefile_context_t *pagefile_head;
     3.7 +  ULONGLONG error_count;
     3.8  };
     3.9    
    3.10  struct _pagefile_context_t {
    3.11    pagefile_context_t *next;
    3.12    global_context_t *global;
    3.13    PFILE_OBJECT file_object;
    3.14 -  ULONG pool_id;
    3.15 +  LONG pool_id;
    3.16  
    3.17    ULONGLONG put_success_count;
    3.18    ULONGLONG put_fail_count;
    3.19    ULONGLONG get_success_count;
    3.20    ULONGLONG get_fail_count;
    3.21 +  ULONGLONG error_count;
    3.22  };
    3.23  
    3.24  #endif
     4.1 --- a/xencache/xencache.inx	Tue Jun 04 12:15:51 2013 +1000
     4.2 +++ b/xencache/xencache.inx	Sat Jun 08 10:42:55 2013 +1000
     4.3 @@ -26,7 +26,7 @@ DisplayName    = %XenCache.SVCDESC%
     4.4  ServiceBinary  = %12%\xencache.sys
     4.5  Dependencies   = FltMgr
     4.6  ServiceType    = 2
     4.7 -StartType      = 3
     4.8 +StartType      = 0
     4.9  ErrorControl   = 1
    4.10  LoadOrderGroup = "FSFilter Top"
    4.11  AddReg = XenCache_Service.AddReg
    4.12 @@ -34,7 +34,7 @@ AddReg = XenCache_Service.AddReg
    4.13  [XenCache_Service.AddReg]
    4.14  HKR,,"DebugFlags",0x00010001 ,0x0
    4.15  HKR,"Instances","DefaultInstance",0x00000000,XenCache
    4.16 -HKR,"Instances\XenCache","Altitude",0x00000000,123456
    4.17 +HKR,"Instances\XenCache","Altitude",0x00000000,400000
    4.18  HKR,"Instances\XenCache","Flags",0x00010001,0
    4.19  
    4.20  [XenCache.CopyFiles]