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.

375 lines
8.9 KiB

  1. /*++
  2. Copyright (c) 1989 Microsoft Corporation
  3. Module Name:
  4. RxStruc.h
  5. Abstract:
  6. This module defines the data structures that make up the major internal
  7. part of the Rx file system.
  8. Author:
  9. Gary Kimura [GaryKi] 28-Dec-1989
  10. Revision History:
  11. Joe Linn [joelinn] aug-1994 moved over to rdbss
  12. --*/
  13. #ifndef _RDBSSSTRUC_
  14. #define _RDBSSSTRUC_
  15. #include "prefix.h"
  16. #include "lowio.h"
  17. #include "scavengr.h" // scavenger related definitions.
  18. #include "RxContx.h"
  19. #include "mrx.h"
  20. #include "Fcb.h"
  21. //
  22. // define our byte offsets to be the full 64 bits
  23. //
  24. typedef LONGLONG RXVBO;
  25. #if 0
  26. //
  27. // Define who many freed structures we are willing to keep around
  28. //
  29. #define FREE_FOBX_SIZE (8)
  30. #define FREE_FCB_SIZE (8)
  31. #define FREE_NON_PAGED_FCB_SIZE (8)
  32. #define FREE_128_BYTE_SIZE (16)
  33. #define FREE_256_BYTE_SIZE (16)
  34. #define FREE_512_BYTE_SIZE (16)
  35. #endif // 0
  36. //
  37. // We will use both a common and private dispatch tables on a per FCB basis to (a) get
  38. // some encapsulation and (b) [less important] go a little faster. The driver table then gets
  39. // optimized for the most common case. Right now we just use the common dispatch...later and
  40. // Eventually, all the FCBs will have pointers to optimized dispatch tables.
  41. //
  42. //
  43. // used to synchronize access to rxcontxs and structures
  44. //
  45. extern RX_SPIN_LOCK RxStrucSupSpinLock;
  46. typedef struct _RDBSS_EXPORTS {
  47. PRX_SPIN_LOCK pRxStrucSupSpinLock;
  48. PLONG pRxDebugTraceIndent;
  49. } RDBSS_EXPORTS, *PRDBSS_EXPORTS;
  50. extern RDBSS_EXPORTS RxExports;
  51. //
  52. // this type is used with table locks to track whether or not the lock
  53. // should be released
  54. //
  55. typedef enum _LOCK_HOLDING_STATE {
  56. LHS_LockNotHeld,
  57. LHS_SharedLockHeld,
  58. LHS_ExclusiveLockHeld
  59. } LOCK_HOLDING_STATE, *PLOCK_HOLDING_STATE;
  60. //
  61. // The RDBSS_DATA record is the top record in the Rx file system in-memory
  62. // data structure. This structure must be allocated from non-paged pool.
  63. //
  64. typedef struct _RDBSS_DATA {
  65. //
  66. // The type and size of this record (must be RDBSS_NTC_DATA_HEADER)
  67. //
  68. NODE_TYPE_CODE NodeTypeCode;
  69. NODE_BYTE_SIZE NodeByteSize;
  70. //
  71. // The Driver object we were initialized with
  72. //
  73. PDRIVER_OBJECT DriverObject;
  74. //
  75. // Mini Rdr registration related fields
  76. //
  77. LONG NumberOfMinirdrsStarted;
  78. FAST_MUTEX MinirdrRegistrationMutex;
  79. LIST_ENTRY RegisteredMiniRdrs; //protected by the mutex
  80. LONG NumberOfMinirdrsRegistered; //protected by the mutex
  81. //
  82. // A pointer to our EPROCESS struct, which is a required input to the
  83. // Cache Management subsystem.
  84. //
  85. PEPROCESS OurProcess;
  86. //
  87. // Cache manager call back structures, which must be passed on each call
  88. // to CcInitializeCacheMap.
  89. //
  90. CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
  91. //
  92. // To control access to the global Rx data record
  93. //
  94. ERESOURCE Resource;
  95. } RDBSS_DATA;
  96. typedef RDBSS_DATA *PRDBSS_DATA;
  97. extern RDBSS_DATA RxData;
  98. PEPROCESS
  99. RxGetRDBSSProcess (
  100. VOID
  101. );
  102. //
  103. // Note: A Strategy needs to be in place to deal with requests for stopping the
  104. // RDBSS when requests are active.
  105. //
  106. typedef enum _RX_RDBSS_STATE_ {
  107. RDBSS_STARTABLE = 0,
  108. RDBSS_STARTED,
  109. RDBSS_STOP_IN_PROGRESS
  110. //
  111. // this state deleted with cause! RDBSS_STOPPED
  112. //
  113. } RX_RDBSS_STATE, *PRX_RDBSS_STATE;
  114. typedef struct _RDBSS_STARTSTOP_CONTEXT_ {
  115. RX_RDBSS_STATE State;
  116. ULONG Version;
  117. PRX_CONTEXT pStopContext;
  118. } RDBSS_STARTSTOP_CONTEXT, *PRDBSS_STARTSTOP_CONTEXT;
  119. typedef struct _MRX_CALLDOWN_COMPLETION_CONTEXT_ {
  120. LONG WaitCount;
  121. KEVENT Event;
  122. } MRX_CALLDOWN_COMPLETION_CONTEXT, *PMRX_CALLDOWN_COMPLETION_CONTEXT;
  123. typedef
  124. NTSTATUS
  125. (NTAPI *PMRX_CALLDOWN_ROUTINE) (
  126. IN OUT PVOID CalldownParameter
  127. );
  128. typedef struct _MRX_CALLDOWN_CONTEXT_ {
  129. RX_WORK_QUEUE_ITEM WorkQueueItem;
  130. PRDBSS_DEVICE_OBJECT pMRxDeviceObject;
  131. PMRX_CALLDOWN_COMPLETION_CONTEXT pCompletionContext;
  132. PMRX_CALLDOWN_ROUTINE pRoutine;
  133. NTSTATUS CompletionStatus;
  134. PVOID pParameter;
  135. } MRX_CALLDOWN_CONTEXT, *PMRX_CALLDOWN_CONTEXT;
  136. typedef struct _RX_DISPATCHER_CONTEXT_ {
  137. LONG NumberOfWorkerThreads;
  138. PKEVENT pTearDownEvent;
  139. } RX_DISPATCHER_CONTEXT, *PRX_DISPATCHER_CONTEXT;
  140. #define RxSetRdbssState(RxDeviceObject,NewState) \
  141. { \
  142. KIRQL SavedIrql; \
  143. KeAcquireSpinLock( &RxStrucSupSpinLock,&SavedIrql ); \
  144. RxDeviceObject->StartStopContext.State = (NewState); \
  145. KeReleaseSpinLock( &RxStrucSupSpinLock, SavedIrql ); \
  146. }
  147. #define RxGetRdbssState(RxDeviceObject) \
  148. (RxDeviceObject)->StartStopContext.State
  149. BOOLEAN
  150. RxIsOperationCompatibleWithRdbssState (
  151. PIRP Irp
  152. );
  153. //
  154. // The RDBSS Device Object is an I/O system device object with additions for
  155. // the various structures needed by each minirdr: the dispatch, export-to-minirdr
  156. // structure, MUP call characteristics, list of active operations, etc.
  157. //
  158. typedef struct _RDBSS_DEVICE_OBJECT {
  159. union {
  160. DEVICE_OBJECT DeviceObject;
  161. #ifndef __cplusplus
  162. DEVICE_OBJECT;
  163. #endif // __cplusplus
  164. };
  165. ULONG RegistrationControls;
  166. //
  167. // stuff that the minirdr needs to know
  168. //
  169. PRDBSS_EXPORTS RdbssExports;
  170. //
  171. // set to NULL if monolithic
  172. //
  173. PDEVICE_OBJECT RDBSSDeviceObject;
  174. //
  175. // the mini rdr dispatch vector
  176. //
  177. PMINIRDR_DISPATCH Dispatch;
  178. UNICODE_STRING DeviceName;
  179. ULONG NetworkProviderPriority;
  180. HANDLE MupHandle;
  181. BOOLEAN RegisterUncProvider;
  182. BOOLEAN RegisterMailSlotProvider;
  183. BOOLEAN RegisteredAsFileSystem;
  184. BOOLEAN Unused;
  185. LIST_ENTRY MiniRdrListLinks;
  186. ULONG NumberOfActiveFcbs;
  187. ULONG NumberOfActiveContexts;
  188. struct {
  189. LARGE_INTEGER PagingReadBytesRequested;
  190. LARGE_INTEGER NonPagingReadBytesRequested;
  191. LARGE_INTEGER CacheReadBytesRequested;
  192. LARGE_INTEGER FastReadBytesRequested;
  193. LARGE_INTEGER NetworkReadBytesRequested;
  194. ULONG ReadOperations;
  195. ULONG FastReadOperations;
  196. ULONG RandomReadOperations;
  197. LARGE_INTEGER PagingWriteBytesRequested;
  198. LARGE_INTEGER NonPagingWriteBytesRequested;
  199. LARGE_INTEGER CacheWriteBytesRequested;
  200. LARGE_INTEGER FastWriteBytesRequested;
  201. LARGE_INTEGER NetworkWriteBytesRequested;
  202. ULONG WriteOperations;
  203. ULONG FastWriteOperations;
  204. ULONG RandomWriteOperations;
  205. };
  206. //
  207. // The following field tells how many requests for this volume have
  208. // either been enqueued to ExWorker threads or are currently being
  209. // serviced by ExWorker threads. If the number goes above
  210. // a certain threshold, put the request on the overflow queue to be
  211. // executed later.
  212. //
  213. LONG PostedRequestCount[MaximumWorkQueue];
  214. //
  215. // The following field indicates the number of IRP's waiting
  216. // to be serviced in the overflow queue.
  217. //
  218. LONG OverflowQueueCount[MaximumWorkQueue];
  219. //
  220. // The following field contains the queue header of the overflow queue.
  221. // The Overflow queue is a list of IRP's linked via the IRP's ListEntry
  222. // field.
  223. //
  224. LIST_ENTRY OverflowQueue[MaximumWorkQueue];
  225. //
  226. // The following spinlock protects access to all the above fields.
  227. //
  228. RX_SPIN_LOCK OverflowQueueSpinLock;
  229. //
  230. // The following fields are required for synchronization with async.
  231. // requests issued by the RDBSS on behalf of this mini redirector on
  232. // on shutdown.
  233. //
  234. LONG AsynchronousRequestsPending;
  235. PKEVENT pAsynchronousRequestsCompletionEvent;
  236. RDBSS_STARTSTOP_CONTEXT StartStopContext;
  237. RX_DISPATCHER_CONTEXT DispatcherContext;
  238. //
  239. // some guys may want to share
  240. //
  241. PRX_PREFIX_TABLE pRxNetNameTable;
  242. RX_PREFIX_TABLE RxNetNameTableInDeviceObject;
  243. //
  244. // for sharing
  245. //
  246. PRDBSS_SCAVENGER pRdbssScavenger;
  247. RDBSS_SCAVENGER RdbssScavengerInDeviceObject;
  248. } RDBSS_DEVICE_OBJECT, *PRDBSS_DEVICE_OBJECT;
  249. INLINE
  250. VOID
  251. NTAPI
  252. RxUnregisterMinirdr (
  253. IN PRDBSS_DEVICE_OBJECT RxDeviceObject
  254. )
  255. {
  256. PDEVICE_OBJECT RDBSSDeviceObject;
  257. RDBSSDeviceObject = RxDeviceObject->RDBSSDeviceObject;
  258. RxpUnregisterMinirdr( RxDeviceObject );
  259. if (RDBSSDeviceObject != NULL) {
  260. ObDereferenceObject( RDBSSDeviceObject );
  261. }
  262. }
  263. extern FAST_MUTEX RxMinirdrRegistrationMutex;
  264. extern LIST_ENTRY RxRegisteredMiniRdrs;
  265. extern ULONG RxNumberOfMinirdrs;
  266. #endif // _RDBSSSTRUC_
  267.