Leaked source code of windows server 2003
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.

334 lines
5.2 KiB

  1. /*++
  2. Copyright (C) 1991-5 Microsoft Corporation
  3. Module Name:
  4. ftvol.cxx
  5. Abstract:
  6. This module contains the code specific to all volume objects.
  7. Author:
  8. Norbert Kusters 2-Feb-1995
  9. Environment:
  10. kernel mode only
  11. Notes:
  12. Revision History:
  13. --*/
  14. extern "C" {
  15. #include <ntddk.h>
  16. }
  17. #include <ftdisk.h>
  18. #ifdef ALLOC_PRAGMA
  19. #pragma code_seg("PAGE")
  20. #endif
  21. VOID
  22. FT_VOLUME::Initialize(
  23. IN OUT PROOT_EXTENSION RootExtension,
  24. IN FT_LOGICAL_DISK_ID LogicalDiskId
  25. )
  26. /*++
  27. Routine Description:
  28. This is the init routine for an FT_VOLUME. It must be called before
  29. the FT_VOLUME is used.
  30. Arguments:
  31. RootExtension - Supplies the root device extension.
  32. LogicalDiskId - Supplies the logical disk id for this volume.
  33. Return Value:
  34. None.
  35. --*/
  36. {
  37. KeInitializeSpinLock(&_spinLock);
  38. _diskInfoSet = RootExtension->DiskInfoSet;
  39. _rootExtension = RootExtension;
  40. _logicalDiskId = LogicalDiskId;
  41. }
  42. BOOLEAN
  43. FT_VOLUME::IsVolumeSuitableForRegenerate(
  44. IN USHORT MemberNumber,
  45. IN PFT_VOLUME Volume
  46. )
  47. /*++
  48. Routine Description:
  49. This routine computes whether or not the given volume is suitable
  50. for a regenerate operation.
  51. Arguments:
  52. MemberNumber - Supplies the member number.
  53. Volume - Supplies the volume.
  54. Return Value:
  55. FALSE - The volume is not suitable.
  56. TRUE - The volume is suitable.
  57. --*/
  58. {
  59. return FALSE;
  60. }
  61. VOID
  62. FT_VOLUME::ModifyStateForUser(
  63. IN OUT PVOID State
  64. )
  65. /*++
  66. Routine Description:
  67. This routine modifies the state for the user to see, possibly adding
  68. non-persistant state different than what is stored on disk.
  69. Arguments:
  70. State - Supplies and returns the state for the logical disk.
  71. Return Value:
  72. None.
  73. --*/
  74. {
  75. }
  76. #ifdef ALLOC_PRAGMA
  77. #pragma code_seg("PAGELK")
  78. #endif
  79. PVOID
  80. FT_BASE_CLASS::operator new(
  81. IN size_t Size
  82. )
  83. /*++
  84. Routine Description:
  85. This routine is the memory allocator for all classes derived from
  86. FT_VOLUME.
  87. Arguments:
  88. Size - Supplies the number of bytes to allocate.
  89. Return Value:
  90. A pointer to Size bytes of non-paged pool.
  91. --*/
  92. {
  93. return ExAllocatePool(NonPagedPool, Size);
  94. }
  95. VOID
  96. FT_BASE_CLASS::operator delete(
  97. IN PVOID MemPtr
  98. )
  99. /*++
  100. Routine Description:
  101. This routine frees memory allocated for all classes derived from
  102. FT_VOLUME.
  103. Arguments:
  104. MemPtr - Supplies a pointer to the memory to free.
  105. Return Value:
  106. None.
  107. --*/
  108. {
  109. if (MemPtr) {
  110. ExFreePool(MemPtr);
  111. }
  112. }
  113. FT_LOGICAL_DISK_ID
  114. FT_VOLUME::QueryLogicalDiskId(
  115. )
  116. {
  117. KIRQL irql;
  118. FT_LOGICAL_DISK_ID r;
  119. KeAcquireSpinLock(&_spinLock, &irql);
  120. r = _logicalDiskId;
  121. KeReleaseSpinLock(&_spinLock, irql);
  122. return r;
  123. }
  124. VOID
  125. FT_VOLUME::SetLogicalDiskId(
  126. IN FT_LOGICAL_DISK_ID NewLogicalDiskId
  127. )
  128. {
  129. KIRQL irql;
  130. KeAcquireSpinLock(&_spinLock, &irql);
  131. _logicalDiskId = NewLogicalDiskId;
  132. KeReleaseSpinLock(&_spinLock, irql);
  133. }
  134. VOID
  135. FtVolumeNotifyWorker(
  136. IN PVOID FtVolume
  137. )
  138. /*++
  139. Routine Description:
  140. This is the worker routine to signal a notify on the given volume
  141. object.
  142. Arguments:
  143. FtVolume - Supplies the FT volume.
  144. Return Value:
  145. None.
  146. --*/
  147. {
  148. PFT_VOLUME vol = (PFT_VOLUME) FtVolume;
  149. PVOLUME_EXTENSION extension;
  150. FtpAcquire(vol->_rootExtension);
  151. extension = FtpFindExtensionCoveringDiskId(vol->_rootExtension,
  152. vol->QueryLogicalDiskId());
  153. FtpRelease(vol->_rootExtension);
  154. if (extension) {
  155. FtpNotify(extension->Root, extension);
  156. }
  157. if (!InterlockedDecrement(&vol->_refCount)) {
  158. delete vol;
  159. }
  160. }
  161. VOID
  162. FT_VOLUME::Notify(
  163. )
  164. /*++
  165. Routine Description:
  166. This routine is called when a sub class would like to post notification
  167. about a state change.
  168. Arguments:
  169. None.
  170. Return Value:
  171. None.
  172. --*/
  173. {
  174. PWORK_QUEUE_ITEM workItem;
  175. workItem = (PWORK_QUEUE_ITEM)
  176. ExAllocatePool(NonPagedPool, sizeof(WORK_QUEUE_ITEM));
  177. if (!workItem) {
  178. return;
  179. }
  180. ExInitializeWorkItem(workItem, FtVolumeNotifyWorker, this);
  181. InterlockedIncrement(&_refCount);
  182. FtpQueueWorkItem(_rootExtension, workItem);
  183. }
  184. VOID
  185. FT_VOLUME::NewStateArrival(
  186. IN PVOID NewStateInstance
  187. )
  188. /*++
  189. Routine Description:
  190. This routine takes the new state instance arrival combined with its
  191. current state to come up with the new current state for the volume.
  192. If the two states cannot be reconciled then this routine returns FALSE
  193. indicating that the volume is invalid and should be broken into its
  194. constituant parts.
  195. Arguments:
  196. NewStateInstance - Supplies the new state instance.
  197. Return Value:
  198. None.
  199. --*/
  200. {
  201. }
  202. FT_VOLUME::~FT_VOLUME(
  203. )
  204. /*++
  205. Routine Description:
  206. Desctructor for FT_VOLUME.
  207. Arguments:
  208. None.
  209. Return Value:
  210. None.
  211. --*/
  212. {
  213. }