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.

165 lines
5.1 KiB

  1. /*++ BUILD Version: 0009 // Increment this if a change has global effects
  2. Copyright (c) 1987-1993 Microsoft Corporation
  3. Module Name:
  4. buffring.h
  5. Abstract:
  6. This module defines the change buffering state requests related data structures in RDBSS.
  7. Author:
  8. Balan Sethu Raman (SethuR) 11-Nov-95 Created
  9. Notes:
  10. The buffering manager implementation consists of two primary data structures
  11. (1) CHANGE_BUFFERING_STATE_REQUEST and (2) BUFFERING_MANAGER.
  12. The BUFFERING_MANAGER tracks and initiates actions on all change buffering state
  13. requests generated by the various mini redirectors as well as the RDBSS.
  14. There are three lists associated with the buffering manager, i.e., the registration
  15. list, the dispatcher list and the handler list.
  16. The registration list contains all the requests initiated for which no processing
  17. has been done. All DPC level indications merely register the indication in this
  18. list. The access to this list is protected by a spin lock(RxStrucsupSpinLock).
  19. The dispatcher list contains all the requests for which the lookup has not been
  20. completed. This list is organized as a two tier list. The top level is based on
  21. the NetRootKey. Each entry for a NetRootKey in this list has an associated cluster
  22. of requests corresponding to the various SrvOpenKey's. This is the reason for
  23. ghaving two LIST_ENTRY's in the request data structure as well. The
  24. NetRootListEntry field is used for inter cluster threading and the listEntry
  25. field is used for intra cluster threading.
  26. The handler list consists of all the requests for which the lookup has been completed
  27. and are awaiting processing.
  28. The dispatcher list and the handler list access is protected by the buffering manager
  29. mutex.
  30. The three routines of interest to mini rdr writers are ...
  31. 1) RxIndicateChangeOfBufferingState -- for registering the request.
  32. 2) RxAssociateSrvOpenKey -- for associating a SRV_OPEN instance with the key.
  33. Note that the key associations are irreverisble and will last the lifetime of the
  34. associated SRV_OPEN.
  35. Also note that 0 and 0xffffffff are not valid keys for SRV_OPEN. It has special
  36. significance for the buffering manager.
  37. --*/
  38. #ifndef __BUFFRING_H__
  39. #define __BUFFRING_H__
  40. #define RX_REQUEST_PREPARED_FOR_HANDLING (0x10000000)
  41. typedef struct _CHANGE_BUFFERING_STATE_REQUEST_ {
  42. LIST_ENTRY ListEntry;
  43. ULONG Flags;
  44. PSRV_CALL pSrvCall;
  45. PSRV_OPEN pSrvOpen;
  46. PVOID SrvOpenKey;
  47. PVOID pMRxContext;
  48. } CHANGE_BUFFERING_STATE_REQUEST, *PCHANGE_BUFFERING_STATE_REQUEST;
  49. typedef struct _RX_BUFFERING_MANAGER_ {
  50. BOOLEAN fDispatcherActive;
  51. BOOLEAN fNoWaitHandlerActive;
  52. BOOLEAN fLastChanceHandlerActive;
  53. UCHAR Pad;
  54. KSPIN_LOCK SpinLock;
  55. // This count is always incremented and never reset. This provides us with
  56. // a quick mechanism to establish if a buffering state change request has
  57. // been received for a given srvcall since a point in time.
  58. LONG CumulativeNumberOfBufferingChangeRequests;
  59. LONG NumberOfUnhandledRequests;
  60. LONG NumberOfUndispatchedRequests;
  61. LONG NumberOfOutstandingOpens;
  62. LIST_ENTRY DispatcherList;
  63. LIST_ENTRY HandlerList;
  64. LIST_ENTRY LastChanceHandlerList;
  65. RX_WORK_QUEUE_ITEM DispatcherWorkItem;
  66. RX_WORK_QUEUE_ITEM HandlerWorkItem;
  67. RX_WORK_QUEUE_ITEM LastChanceHandlerWorkItem;
  68. FAST_MUTEX Mutex;
  69. LIST_ENTRY SrvOpenLists[1];
  70. } RX_BUFFERING_MANAGER, *PRX_BUFFERING_MANAGER;
  71. #define RxAcquireBufferingManagerMutex(pBufferingManager) \
  72. { \
  73. if (!ExTryToAcquireFastMutex(&(pBufferingManager)->Mutex)) { \
  74. ExAcquireFastMutex(&(pBufferingManager)->Mutex); \
  75. } \
  76. }
  77. #define RxReleaseBufferingManagerMutex(pBufferingManager) \
  78. ExReleaseFastMutex(&(pBufferingManager)->Mutex)
  79. extern VOID
  80. RxpProcessChangeBufferingStateRequests(
  81. PSRV_CALL pSrvCall,
  82. BOOLEAN UpdateHandlerState);
  83. extern VOID
  84. RxProcessChangeBufferingStateRequests(
  85. PSRV_CALL pSrvCall);
  86. extern VOID
  87. RxProcessFcbChangeBufferingStateRequest(
  88. PFCB pFcb);
  89. extern VOID
  90. RxPurgeChangeBufferingStateRequestsForSrvOpen(
  91. PSRV_OPEN pSrvOpen);
  92. extern VOID
  93. RxCompleteSrvOpenKeyAssociation(
  94. IN OUT PSRV_OPEN pSrvOpen);
  95. extern VOID
  96. RxInitiateSrvOpenKeyAssociation(
  97. IN OUT PSRV_OPEN pSrvOpen);
  98. extern NTSTATUS
  99. RxInitializeBufferingManager(
  100. PSRV_CALL pSrvCall);
  101. extern NTSTATUS
  102. RxTearDownBufferingManager(
  103. PSRV_CALL pSrvCall);
  104. NTSTATUS
  105. RxFlushFcbInSystemCache(
  106. IN PFCB Fcb,
  107. IN BOOLEAN SynchronizeWithLazyWriter
  108. );
  109. NTSTATUS
  110. RxPurgeFcbInSystemCache(
  111. IN PFCB Fcb,
  112. IN PLARGE_INTEGER FileOffset OPTIONAL,
  113. IN ULONG Length,
  114. IN BOOLEAN UninitializeCacheMaps,
  115. IN BOOLEAN FlushFile );
  116. #endif __BUFFRING_H__