Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

193 lines
4.4 KiB

  1. /*++
  2. Copyright (c) 1993 Microsoft Corporation
  3. Module Name:
  4. FaultTol.c
  5. Abstract:
  6. The routines in this module help the file systems perform fault
  7. tolerance operation to the FT device drivers.
  8. Author:
  9. David Goebel [DavidGoe] 30-Mar-1993
  10. Revision History:
  11. --*/
  12. #include "FsRtlP.h"
  13. #ifdef ALLOC_PRAGMA
  14. #pragma alloc_text(PAGE, FsRtlBalanceReads)
  15. #pragma alloc_text(PAGE, FsRtlSyncVolumes)
  16. #endif
  17. NTSTATUS
  18. FsRtlBalanceReads (
  19. IN PDEVICE_OBJECT TargetDevice
  20. )
  21. /*++
  22. Routine Description:
  23. This routine signals a device driver that it is now OK to start
  24. balancing reads from a mirrored drive. This is typically called
  25. after the file system determines that a volume is clean.
  26. Arguments:
  27. TargetDevice - Supplies the device to start balanced read from.
  28. Return Value:
  29. NTSTATUS - The result of the operation. This will be
  30. STATUS_INVALID_DEVICE_REQUEST is the volume is not a mirror.
  31. --*/
  32. {
  33. PIRP Irp;
  34. KEVENT Event;
  35. IO_STATUS_BLOCK Iosb;
  36. NTSTATUS Status;
  37. KeInitializeEvent( &Event, NotificationEvent, FALSE );
  38. Irp = IoBuildDeviceIoControlRequest( FT_BALANCED_READ_MODE,
  39. TargetDevice,
  40. NULL,
  41. 0,
  42. NULL,
  43. 0,
  44. FALSE,
  45. &Event,
  46. &Iosb );
  47. if ( Irp == NULL ) {
  48. return STATUS_INSUFFICIENT_RESOURCES;
  49. }
  50. Status = IoCallDriver( TargetDevice, Irp );
  51. if (Status == STATUS_PENDING) {
  52. Status = KeWaitForSingleObject( &Event,
  53. Executive,
  54. KernelMode,
  55. FALSE,
  56. NULL );
  57. ASSERT( Status == STATUS_SUCCESS );
  58. Status = Iosb.Status;
  59. }
  60. return Status;
  61. }
  62. NTSTATUS
  63. FsRtlSyncVolumes (
  64. IN PDEVICE_OBJECT TargetDevice,
  65. IN PLARGE_INTEGER ByteOffset OPTIONAL,
  66. IN PLARGE_INTEGER ByteCount
  67. )
  68. /*++
  69. Routine Description:
  70. This routine signals a device driver that it must sync redundant
  71. members of a mirror from the primary member. This is typically
  72. called after the file system determines that a volume is dirty.
  73. Arguments:
  74. TargetDevice - Supplies the device to sync.
  75. ByteOffset - If specified, gives the location to start syncing
  76. ByteCount - Gives the byte count to sync. Ignored if StartingOffset
  77. not specified.
  78. Return Value:
  79. NTSTATUS - The result of the operation. This will be
  80. STATUS_INVALID_DEVICE_REQUEST is the volume is not a mirror.
  81. --*/
  82. {
  83. #if 0 // Mike Glass says we no longer need to do this. 3/3/94
  84. PIRP Irp;
  85. KEVENT Event;
  86. IO_STATUS_BLOCK Iosb;
  87. NTSTATUS Status;
  88. BOOLEAN RangeSpecified;
  89. FT_SYNC_INFORMATION SyncInfo;
  90. KeInitializeEvent( &Event, NotificationEvent, FALSE );
  91. //
  92. // If the user specified a range, capture it.
  93. //
  94. if (ARGUMENT_PRESENT(ByteOffset)) {
  95. SyncInfo.ByteOffset = *ByteOffset;
  96. SyncInfo.ByteCount = *ByteCount;
  97. RangeSpecified = TRUE;
  98. } else {
  99. RangeSpecified = FALSE;
  100. }
  101. Irp = IoBuildDeviceIoControlRequest( FT_SYNC_REDUNDANT_COPY,
  102. TargetDevice,
  103. RangeSpecified ? &SyncInfo : NULL,
  104. RangeSpecified ?
  105. sizeof(FT_SYNC_INFORMATION) : 0,
  106. NULL,
  107. 0,
  108. FALSE,
  109. &Event,
  110. &Iosb );
  111. if ( Irp == NULL ) {
  112. return STATUS_INSUFFICIENT_RESOURCES;
  113. }
  114. Status = IoCallDriver( TargetDevice, Irp );
  115. if (Status == STATUS_PENDING) {
  116. Status = KeWaitForSingleObject( &Event,
  117. Executive,
  118. KernelMode,
  119. FALSE,
  120. NULL );
  121. ASSERT( Status == STATUS_SUCCESS );
  122. Status = Iosb.Status;
  123. }
  124. return Status;
  125. #else
  126. return STATUS_SUCCESS;
  127. #endif //0
  128. }