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.

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