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.

228 lines
7.5 KiB

  1. /*++
  2. Copyright (c) 1994 Microsoft Corporation
  3. Module Name:
  4. scavengr.h
  5. Abstract:
  6. This module defines data structures related to scavenging in the RDBSS
  7. Author:
  8. Balan Sethu Raman [SethuR] 9-Sep-1995
  9. Revision History:
  10. Notes:
  11. The dormant file limit must be made configurable on a per server basis
  12. --*/
  13. #ifndef _SCAVENGR_H_
  14. #define _SCAVENGR_H_
  15. // currently, only a single scavengermutex is across all scavenging operations
  16. // for all underlying deviceobjects
  17. extern KMUTEX RxScavengerMutex;
  18. // An instance of this data structure is embedded as part of those data structures
  19. // that are scavenged, i.e., FCB, RX_CONTEXT, etc.
  20. #define RX_SCAVENGER_ENTRY_TYPE_MARKER (0x0001)
  21. #define RX_SCAVENGER_ENTRY_TYPE_FCB (0x0002)
  22. #define RX_SCAVENGER_OP_PURGE (0x0001)
  23. #define RX_SCAVENGER_OP_CLOSE (0x0002)
  24. #define RX_SCAVENGER_INITIATED_OPERATION (0x0001)
  25. typedef enum _RX_SCAVENGER_ENTRY_STATE {
  26. RX_SCAVENGING_INACTIVE,
  27. RX_SCAVENGING_PENDING,
  28. RX_SCAVENGING_IN_PROGRESS,
  29. RX_SCAVENGING_AWAITING_RESPONSE
  30. } RX_SCAVENGER_ENTRY_STATE, *PRX_SCAVENGER_ENTRY_STATE;
  31. typedef struct _RX_SCAVENGER_ENTRY {
  32. // List of related items to be scavenged
  33. LIST_ENTRY List;
  34. UCHAR Type;
  35. UCHAR Operation;
  36. UCHAR State;
  37. UCHAR Flags;
  38. struct _RX_SCAVENGER_ENTRY *pContinuationEntry;
  39. } RX_SCAVENGER_ENTRY, *PRX_SCAVENGER_ENTRY;
  40. #define RxInitializeScavengerEntry(pScavengerEntry) \
  41. (pScavengerEntry)->State = 0; \
  42. (pScavengerEntry)->Flags = 0; \
  43. (pScavengerEntry)->Type = 0; \
  44. (pScavengerEntry)->Operation = 0; \
  45. InitializeListHead(&(pScavengerEntry)->List); \
  46. (pScavengerEntry)->pContinuationEntry = NULL
  47. #define RX_SCAVENGER_MUTEX_ACQUIRED (1)
  48. typedef enum _RDBSS_SCAVENGER_STATE {
  49. RDBSS_SCAVENGER_INACTIVE,
  50. RDBSS_SCAVENGER_DORMANT,
  51. RDBSS_SCAVENGER_ACTIVE,
  52. RDBSS_SCAVENGER_SUSPENDED
  53. } RDBSS_SCAVENGER_STATE, *PRDBSS_SCAVENGER_STATE;
  54. typedef struct _RDBSS_SCAVENGER {
  55. RDBSS_SCAVENGER_STATE State;
  56. LONG MaximumNumberOfDormantFiles;
  57. LONG NumberOfDormantFiles;
  58. ULONG SrvCallsToBeFinalized;
  59. ULONG NetRootsToBeFinalized;
  60. ULONG VNetRootsToBeFinalized;
  61. ULONG FcbsToBeFinalized;
  62. ULONG SrvOpensToBeFinalized;
  63. ULONG FobxsToBeFinalized;
  64. LIST_ENTRY SrvCallFinalizationList;
  65. LIST_ENTRY NetRootFinalizationList;
  66. LIST_ENTRY VNetRootFinalizationList;
  67. LIST_ENTRY FcbFinalizationList;
  68. LIST_ENTRY SrvOpenFinalizationList;
  69. LIST_ENTRY FobxFinalizationList;
  70. LIST_ENTRY ClosePendingFobxsList;
  71. RX_WORK_ITEM WorkItem;
  72. KEVENT SyncEvent;
  73. PETHREAD CurrentScavengerThread;
  74. PNET_ROOT CurrentNetRootForClosePendingProcessing;
  75. PFCB CurrentFcbForClosePendingProcessing;
  76. KEVENT ClosePendingProcessingSyncEvent;
  77. } RDBSS_SCAVENGER, *PRDBSS_SCAVENGER;
  78. #if 0
  79. //this is not used anywhere
  80. typedef struct _RX_FCB_SCAVENGER_ {
  81. ULONG State;
  82. ULONG OperationsCompleted;
  83. PRX_SCAVENGER_ENTRY pLastActiveMarkerEntry;
  84. LIST_ENTRY OperationsPendingList;
  85. LIST_ENTRY OperationsInProgressList;
  86. LIST_ENTRY OperationsAwaitingResponseList;
  87. } RX_FCB_SCAVENGER, *PRX_FCB_SCAVENGER;
  88. #define RxInitializeFcbScavenger(pFcbScavenger) \
  89. (pFcbScavenger)->pLastActiveMarkerEntry = NULL; \
  90. (pFcbScavenger)->OperationsCompleted = 0; \
  91. (pFcbScavenger)->State = 0; \
  92. InitializeListHead(&(pFcbScavenger)->OperationsPendingList); \
  93. InitializeListHead(&(pFcbScavenger)->OperationsInProgressList); \
  94. InitializeListHead(&(pFcbScavenger)->OperationsAwaitingResponseList)
  95. #endif
  96. #define RxInitializeRdbssScavenger(pScavenger) \
  97. (pScavenger)->State = RDBSS_SCAVENGER_INACTIVE; \
  98. (pScavenger)->SrvCallsToBeFinalized = 0; \
  99. (pScavenger)->NetRootsToBeFinalized = 0; \
  100. (pScavenger)->VNetRootsToBeFinalized = 0; \
  101. (pScavenger)->FcbsToBeFinalized = 0; \
  102. (pScavenger)->SrvOpensToBeFinalized = 0; \
  103. (pScavenger)->FobxsToBeFinalized = 0; \
  104. (pScavenger)->NumberOfDormantFiles = 0; \
  105. (pScavenger)->MaximumNumberOfDormantFiles = 50; \
  106. (pScavenger)->CurrentFcbForClosePendingProcessing = NULL; \
  107. (pScavenger)->CurrentNetRootForClosePendingProcessing = NULL; \
  108. KeInitializeEvent(&((pScavenger)->SyncEvent),NotificationEvent,FALSE); \
  109. KeInitializeEvent(&((pScavenger)->ClosePendingProcessingSyncEvent),NotificationEvent,FALSE); \
  110. InitializeListHead(&(pScavenger)->SrvCallFinalizationList); \
  111. InitializeListHead(&(pScavenger)->NetRootFinalizationList); \
  112. InitializeListHead(&(pScavenger)->VNetRootFinalizationList); \
  113. InitializeListHead(&(pScavenger)->SrvOpenFinalizationList); \
  114. InitializeListHead(&(pScavenger)->FcbFinalizationList); \
  115. InitializeListHead(&(pScavenger)->FobxFinalizationList); \
  116. InitializeListHead(&(pScavenger)->ClosePendingFobxsList)
  117. #define RxAcquireScavengerMutex() \
  118. KeWaitForSingleObject(&RxScavengerMutex,Executive,KernelMode,FALSE,NULL)
  119. #define RxReleaseScavengerMutex() \
  120. KeReleaseMutex(&RxScavengerMutex,FALSE)
  121. extern NTSTATUS
  122. RxMarkFcbForScavengingAtCleanup(PFCB pFcb);
  123. extern NTSTATUS
  124. RxMarkFcbForScavengingAtClose(PFCB pFcb);
  125. extern VOID
  126. RxUpdateScavengerOnCloseCompletion(PFCB pFcb);
  127. extern VOID
  128. RxMarkFobxOnCleanup(PFOBX pFobx, BOOLEAN *pNeedPurge);
  129. extern VOID
  130. RxMarkFobxOnClose(PFOBX pFobx);
  131. extern NTSTATUS
  132. RxPurgeRelatedFobxs(PNET_ROOT pNetRoot,PRX_CONTEXT pRxContext,BOOLEAN AttemptFinalization,PFCB PurgingFcb);
  133. #define DONT_ATTEMPT_FINALIZE_ON_PURGE FALSE
  134. #define ATTEMPT_FINALIZE_ON_PURGE TRUE
  135. //
  136. // the purge_sync context is used to synchronize contexts that are attempting to purge...
  137. // notatbly creates and dirctrls. these are planted in various structures because various minirdrs
  138. // require different granularity of purge operations
  139. typedef struct _PURGE_SYNCHRONIZATION_CONTEXT {
  140. LIST_ENTRY ContextsAwaitingPurgeCompletion; // the list of purge requests active for this netroot.
  141. BOOLEAN PurgeInProgress;
  142. } PURGE_SYNCHRONIZATION_CONTEXT, *PPURGE_SYNCHRONIZATION_CONTEXT;
  143. VOID
  144. RxInitializePurgeSyncronizationContext (
  145. PPURGE_SYNCHRONIZATION_CONTEXT PurgeSyncronizationContext
  146. );
  147. extern NTSTATUS
  148. RxScavengeRelatedFcbs(PRX_CONTEXT pRxContext);
  149. extern BOOLEAN
  150. RxScavengeRelatedFobxs(PFCB pFcb);
  151. extern VOID
  152. RxScavengeFobxsForNetRoot(
  153. struct _NET_ROOT *pNetRoot,
  154. PFCB PurgingFcb);
  155. extern VOID
  156. RxpMarkInstanceForScavengedFinalization(
  157. PVOID pInstance);
  158. extern VOID
  159. RxpUndoScavengerFinalizationMarking(
  160. PVOID pInstance);
  161. extern VOID
  162. RxTerminateScavenging(
  163. PRX_CONTEXT pRxContext);
  164. extern BOOLEAN
  165. RxScavengeVNetRoots(
  166. PRDBSS_DEVICE_OBJECT RxDeviceObject);
  167. extern VOID
  168. RxSynchronizeWithScavenger(
  169. PRX_CONTEXT RxContext);
  170. #endif // _SCAVENGR_H_