win-pvdrivers

diff xencache/xencache.c @ 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 a127b9bea695
children
line diff
     1.1 --- a/xencache/xencache.c	Tue Jun 04 12:15:51 2013 +1000
     1.2 +++ b/xencache/xencache.c	Sat Jun 08 10:42:55 2013 +1000
     1.3 @@ -267,17 +267,24 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
     1.4    pagefile_context_t *context;
     1.5    int i;
     1.6    KIRQL old_irql;
     1.7 -  ULONG rc;
     1.8 +  LONG rc;
     1.9    struct tmem_op tmem_op;
    1.10  
    1.11    UNREFERENCED_PARAMETER(data);
    1.12    UNREFERENCED_PARAMETER(flt_objects);
    1.13    UNREFERENCED_PARAMETER(completion_context);
    1.14  
    1.15 +  if (global_context.error_count) {
    1.16 +    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.17 +  }
    1.18    if (!FsRtlIsPagingFile(flt_objects->FileObject)) {
    1.19      return FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.20    }
    1.21  
    1.22 +  if (!(data->Flags & FLTFL_CALLBACK_DATA_IRP_OPERATION)) {
    1.23 +    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.24 +  }
    1.25 +
    1.26    KeAcquireSpinLock(&global_context.lock, &old_irql);
    1.27    for (context = global_context.pagefile_head; context; context = context->next) {
    1.28      if (context->file_object == flt_objects->FileObject)
    1.29 @@ -300,12 +307,15 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
    1.30      tmem_op.u.new.flags = (TMEM_SPEC_VERSION << TMEM_VERSION_SHIFT); /* private, not shared */
    1.31      context->pool_id = XnTmemOp(&tmem_op);
    1.32      FUNCTION_MSG("pool_id = %d\n", context->pool_id);
    1.33 +    if (context->pool_id < 0) {
    1.34 +      ExFreePoolWithTag(context, XENCACHE_POOL_TAG);
    1.35 +      global_context.error_count++;
    1.36 +      KeReleaseSpinLock(&global_context.lock, old_irql);
    1.37 +      /* should actually unload here */
    1.38 +      return FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.39 +    }
    1.40      global_context.pagefile_head = context;
    1.41    }
    1.42 -  if (!(data->Flags & FLTFL_CALLBACK_DATA_IRP_OPERATION)) {
    1.43 -    KeReleaseSpinLock(&global_context.lock, old_irql);
    1.44 -    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.45 -  }
    1.46  
    1.47    for (i = 0; i < (int)data->Iopb->Parameters.Write.Length >> PAGE_SHIFT; i++) {
    1.48      ULONG page = (ULONG)(data->Iopb->Parameters.Write.ByteOffset.QuadPart >> PAGE_SHIFT) + i;
    1.49 @@ -327,6 +337,8 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
    1.50        context->put_fail_count++;
    1.51      } else {
    1.52        FUNCTION_MSG("TMEM_PUT_PAGE = %d\n", rc);
    1.53 +      context->put_fail_count++;
    1.54 +      context->error_count++;
    1.55      }
    1.56    }
    1.57    KeReleaseSpinLock(&global_context.lock, old_irql);
    1.58 @@ -335,6 +347,7 @@ XenCache_Pre_WRITE(PFLT_CALLBACK_DATA da
    1.59      FUNCTION_MSG("   put_fail_count    = %I64d\n", context->put_fail_count);
    1.60      FUNCTION_MSG("   get_success_count = %I64d\n", context->get_success_count);
    1.61      FUNCTION_MSG("   get_fail_count    = %I64d\n", context->get_fail_count);
    1.62 +    FUNCTION_MSG("   error_count    = %I64d\n", context->error_count);
    1.63    }
    1.64    return FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.65  }
    1.66 @@ -345,7 +358,7 @@ XenCache_Pre_READ(PFLT_CALLBACK_DATA dat
    1.67    pagefile_context_t *context;
    1.68    KIRQL old_irql;
    1.69    int i;
    1.70 -  ULONG rc;
    1.71 +  LONG rc;
    1.72    struct tmem_op tmem_op;
    1.73    
    1.74    UNREFERENCED_PARAMETER(data);
    1.75 @@ -395,6 +408,7 @@ XenCache_Pre_READ(PFLT_CALLBACK_DATA dat
    1.76        FUNCTION_MSG("TMEM_GET_PAGE = %d\n", rc);
    1.77        status = FLT_PREOP_SUCCESS_NO_CALLBACK;
    1.78        context->get_fail_count++;
    1.79 +      context->error_count++;
    1.80      }
    1.81    }
    1.82    
    1.83 @@ -403,6 +417,7 @@ XenCache_Pre_READ(PFLT_CALLBACK_DATA dat
    1.84      FUNCTION_MSG("   put_fail_count    = %I64d\n", context->put_fail_count);
    1.85      FUNCTION_MSG("   get_success_count = %I64d\n", context->get_success_count);
    1.86      FUNCTION_MSG("   get_fail_count    = %I64d\n", context->get_fail_count);
    1.87 +    FUNCTION_MSG("   error_count    = %I64d\n", context->error_count);
    1.88    }
    1.89    KeReleaseSpinLock(&global_context.lock, old_irql);
    1.90