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.

437 lines
8.9 KiB

  1. #ifndef _DMP_H
  2. #define _DMP_H
  3. /*++
  4. Copyright (c) 1996 Microsoft Corporation
  5. Module Name:
  6. dmp.h
  7. Abstract:
  8. Private header file for the Config Database Manager (DM) component
  9. of the NT Cluster Service
  10. Author:
  11. John Vert (jvert) 24-Apr-1996
  12. Revision History:
  13. --*/
  14. #define UNICODE 1
  15. #include "nt.h"
  16. #include "ntrtl.h"
  17. #include "nturtl.h"
  18. #include "service.h"
  19. #define LOG_CURRENT_MODULE LOG_MODULE_DM
  20. #define DM_SEPARATE_HIVE 1
  21. // For now is hKey is NULL, we assume that it was deleted while this handle was open
  22. #define ISKEYDELETED(pDmKey) \
  23. (!((pDmKey != NULL) && (pDmKey->hKey)))
  24. #define AMIOWNEROFQUORES(pQuoResource) \
  25. (NmGetNodeId(NmLocalNode) == NmGetNodeId(pQuoResource->Group->OwnerNode))
  26. //
  27. // DMKEY Structure.
  28. //
  29. typedef struct _DMKEY {
  30. LIST_ENTRY ListEntry;
  31. LIST_ENTRY NotifyList;
  32. HKEY hKey;
  33. DWORD GrantedAccess;
  34. WCHAR Name[0];
  35. } DMKEY, *PDMKEY;
  36. //
  37. // Update handler definition
  38. //
  39. DWORD
  40. DmpUpdateHandler(
  41. IN DWORD Context,
  42. IN BOOL SourceNode,
  43. IN DWORD BufferLength,
  44. IN PVOID Buffer
  45. );
  46. // JAF: Moved DM_UPDATE_TYPE into dm.h because receive.c needs access to it and doesn't
  47. // have service\dm in its include path.
  48. //
  49. // Key creation update structure.
  50. //
  51. typedef struct _DM_CREATE_KEY_UPDATE {
  52. LPDWORD lpDisposition; // only valid on issuing node
  53. HKEY *phKey; // only valid on issuing node
  54. DWORD samDesired;
  55. DWORD dwOptions;
  56. BOOL SecurityPresent;
  57. } DM_CREATE_KEY_UPDATE, *PDM_CREATE_KEY_UPDATE;
  58. //
  59. // Key deletion update structure.
  60. //
  61. typedef struct _DM_DELETE_KEY_UPDATE {
  62. LPDWORD lpStatus; // only valid on issuing node
  63. WCHAR Name[0];
  64. } DM_DELETE_KEY_UPDATE, *PDM_DELETE_KEY_UPDATE;
  65. //
  66. // Value set update structure.
  67. //
  68. typedef struct _DM_SET_VALUE_UPDATE {
  69. LPDWORD lpStatus; // only valid on issuing node
  70. DWORD NameOffset;
  71. DWORD DataOffset;
  72. DWORD DataLength;
  73. DWORD Type;
  74. WCHAR KeyName[0];
  75. } DM_SET_VALUE_UPDATE, *PDM_SET_VALUE_UPDATE;
  76. //
  77. // Value delete update structure.
  78. //
  79. typedef struct _DM_DELETE_VALUE_UPDATE {
  80. LPDWORD lpStatus; // only valid on issuing node
  81. DWORD NameOffset;
  82. WCHAR KeyName[0];
  83. } DM_DELETE_VALUE_UPDATE, *PDM_DELETE_VALUE_UPDATE;
  84. // the record structure for quorum logging
  85. typedef struct _DM_LOGSCAN_CONTEXT{
  86. DWORD dwSequence;
  87. LSN StartLsn;
  88. DWORD dwLastSequence;
  89. }DM_LOGSCAN_CONTEXT, *PDM_LOGSCAN_CONTEXT;
  90. //
  91. // Data local to the DM module.
  92. //
  93. extern HKEY DmpRoot;
  94. extern HKEY DmpRootCopy;
  95. extern LIST_ENTRY KeyList;
  96. extern CRITICAL_SECTION KeyLock;
  97. extern BOOL gbDmpShutdownUpdates;
  98. //disk space requirements
  99. //1M, is lower than this, gracefully shutdown
  100. #define DISKSPACE_LOW_WATERMARK (1 * 1024 * 1000)
  101. //2M, if lower then send alert
  102. #define DISKSPACE_HIGH_WATERMARK (5 * 1024 * 1000)
  103. //minimum required to start the cluster service
  104. #define DISKSPACE_INIT_MINREQUIRED DISKSPACE_HIGH_WATERMARK
  105. #define DISKSPACE_MANAGE_INTERVAL (5 * 60 * 1000) //5 minute..log management functions are performed
  106. #define DEFAULT_CHECKPOINT_INTERVAL (4 ) // in hours
  107. typedef struct _LOCALXSACTION{
  108. DWORD dwSig;
  109. DWORD dwSequence;
  110. HXSACTION hLogXsaction; //the log transaction
  111. LIST_ENTRY PendingNotifyListHead; //the pending notifications to be issued on commit
  112. }LOCALXSACTION, *PLOCALXSACTION;
  113. typedef struct _DM_PENDING_NOTIFY{
  114. LIST_ENTRY ListEntry;
  115. LPWSTR pszKeyName;
  116. DWORD dwFilter;
  117. }DM_PENDING_NOTIFY, *PDM_PENDING_NOTIFY;
  118. #define LOCALXSAC_SIG 'CAXL'
  119. #define GETLOCALXSACTION(pLocalXsaction, hLocalXsaction) \
  120. (pLocalXsaction) = (PLOCALXSACTION)(hLocalXsaction); \
  121. CL_ASSERT((pLocalXsaction)->dwSig == LOCALXSAC_SIG)
  122. //quorum log tombstone
  123. #define MAXSIZE_RESOURCEID 128
  124. typedef struct _QUO_TOMBSTONE{
  125. WCHAR szOldQuoResId[MAXSIZE_RESOURCEID];
  126. WCHAR szOldQuoLogPath[MAX_PATH];
  127. }QUO_TOMBSTONE, *PQUO_TOMBSTONE;
  128. //
  129. // Function prototypes local to the DM
  130. //
  131. DWORD
  132. DmpOpenKeys(
  133. IN REGSAM samDesired
  134. );
  135. DWORD
  136. DmpGetRegistrySequence(
  137. VOID
  138. );
  139. DWORD
  140. DmpSyncDatabase(
  141. IN RPC_BINDING_HANDLE RpcBinding,
  142. IN OPTIONAL LPCWSTR Directory
  143. );
  144. VOID
  145. DmpUpdateSequence(
  146. VOID
  147. );
  148. VOID
  149. DmpInvalidateKeys(
  150. VOID
  151. );
  152. VOID
  153. DmpReopenKeys(
  154. VOID
  155. );
  156. //
  157. // Notification interface
  158. //
  159. BOOL
  160. DmpInitNotify(
  161. VOID
  162. );
  163. VOID
  164. DmpRundownNotify(
  165. IN PDMKEY Key
  166. );
  167. VOID
  168. DmpReportNotify(
  169. IN LPCWSTR KeyName,
  170. IN DWORD Filter
  171. );
  172. //for delivering notifications when a transaction is committed
  173. VOID
  174. DmpReportPendingNotifications(
  175. IN PLOCALXSACTION pLocalXsaction,
  176. IN BOOL bCommit
  177. );
  178. DWORD
  179. DmpAddToPendingNotifications(
  180. IN PLOCALXSACTION pLocalXsaction,
  181. IN LPCWSTR pszName,
  182. IN DWORD dwFilter
  183. );
  184. //
  185. // Update handlers
  186. //
  187. DWORD
  188. DmpUpdateCreateKey(
  189. IN BOOL SourceNode,
  190. IN PDM_CREATE_KEY_UPDATE CreateUpdate,
  191. IN LPCWSTR KeyName,
  192. IN OPTIONAL LPVOID lpSecurityDescriptor
  193. );
  194. DWORD
  195. DmpUpdateDeleteKey(
  196. IN BOOL SourceNode,
  197. IN PDM_DELETE_KEY_UPDATE Update
  198. );
  199. DWORD
  200. DmpUpdateSetValue(
  201. IN BOOL SourceNode,
  202. IN PDM_SET_VALUE_UPDATE Update
  203. );
  204. DWORD
  205. DmpUpdateDeleteValue(
  206. IN BOOL SourceNode,
  207. IN PDM_DELETE_VALUE_UPDATE Update
  208. );
  209. DWORD
  210. DmpUpdateSetSecurity(
  211. IN BOOL SourceNode,
  212. IN PSECURITY_INFORMATION pSecurityInformation,
  213. IN LPCWSTR KeyName,
  214. IN PSECURITY_DESCRIPTOR lpSecurityDescriptor,
  215. IN LPDWORD pGrantedAccess
  216. );
  217. //
  218. // For Quorum Logging
  219. //
  220. DWORD DmpChkQuoTombStone(void);
  221. DWORD DmpApplyChanges(void);
  222. DWORD DmpCheckDiskSpace(void);
  223. //diskmanage functions
  224. void
  225. WINAPI DmpDiskManage(
  226. IN HANDLE hTimer,
  227. IN PVOID pContext
  228. );
  229. void WINAPI DmpCheckpointTimerCb(
  230. IN HANDLE hTimer,
  231. IN PVOID pContext
  232. );
  233. DWORD DmWriteToQuorumLog(
  234. IN DWORD dwGumDispatch,
  235. IN DWORD dwSequence,
  236. IN DWORD dwType,
  237. IN PVOID pData,
  238. IN DWORD dwSize
  239. );
  240. BOOL DmpLogApplyChangesCb(
  241. IN PVOID pContext,
  242. IN LSN Lsn,
  243. IN RMID Resource,
  244. IN RMTYPE ResourceType,
  245. IN TRID Transaction,
  246. IN TRTYPE TransactionType,
  247. IN const PVOID pLogData,
  248. IN DWORD DataLength
  249. );
  250. BOOL WINAPI DmpApplyTransactionCb(
  251. IN PVOID pContext,
  252. IN LSN Lsn,
  253. IN RMID Resource,
  254. IN RMTYPE ResourceType,
  255. IN TRID TransactionId,
  256. IN const PVOID pLogData,
  257. IN DWORD dwDataLength
  258. );
  259. DWORD DmpLogFindStartLsn(
  260. IN HLOG hQuoLog,
  261. OUT LSN *pStartScanLsn,
  262. IN OUT LPDWORD pdwSequence);
  263. BOOL WINAPI DmpLogFindStartLsnCb(
  264. IN PVOID pContext,
  265. IN LSN Lsn,
  266. IN RMID Resource,
  267. IN RMTYPE ResourceType,
  268. IN TRID Transaction,
  269. IN TRTYPE TransactionType,
  270. IN const PVOID pLogData,
  271. IN DWORD DataLength);
  272. DWORD WINAPI DmpGetSnapShotCb(
  273. IN LPCWSTR lpszPathName,
  274. IN PVOID pContext,
  275. OUT LPWSTR szChkPtFile,
  276. OUT LPDWORD pdwChkPtSequence);
  277. DWORD
  278. DmpHookQuorumNotify(void);
  279. DWORD
  280. DmpUnhookQuorumNotify(void);
  281. void DmpQuoObjNotifyCb(
  282. IN PVOID pContext,
  283. IN PVOID pObject,
  284. IN DWORD dwNotification);
  285. DWORD
  286. DmpHookEventHandler();
  287. BOOL DmpNodeObjEnumCb(
  288. IN BOOL *pbAreAllNodesUp,
  289. IN PVOID pContext2,
  290. IN PVOID pNode,
  291. IN LPCWSTR szName);
  292. DWORD WINAPI
  293. DmpEventHandler(
  294. IN CLUSTER_EVENT Event,
  295. IN PVOID pContext
  296. );
  297. DWORD
  298. DmpLoadHive(
  299. IN LPCWSTR Path
  300. );
  301. DWORD
  302. DmpUnloadHive(
  303. );
  304. DWORD DmpRestoreClusterDatabase(
  305. IN LPCWSTR lpszQuoLogPathName
  306. );
  307. DWORD DmpLogCheckpointAndBackup(
  308. IN HLOG hLogFile,
  309. IN LPWSTR lpszPathName);
  310. DWORD DmpGetCheckpointInterval(
  311. OUT LPDWORD pdwCheckpointInterval);
  312. DWORD DmpHandleNodeDownEvent(
  313. IN LPVOID NotUsed );
  314. //
  315. // registry flusher thread interface.
  316. //
  317. DWORD
  318. DmpStartFlusher(
  319. VOID
  320. );
  321. VOID
  322. DmpShutdownFlusher(
  323. VOID
  324. );
  325. VOID
  326. DmpRestartFlusher(
  327. VOID
  328. );
  329. DWORD
  330. DmpSetDwordInClusterServer(
  331. LPCWSTR lpszValueName,
  332. DWORD dwValue
  333. );
  334. DWORD DmpGetDwordFromClusterServer(
  335. IN LPCWSTR lpszValueName,
  336. OUT LPDWORD pdwValue,
  337. IN DWORD dwDefaultValue
  338. );
  339. DWORD
  340. DmpSafeDatabaseCopy(
  341. IN LPCWSTR FileName,
  342. IN LPCWSTR Path,
  343. IN LPCWSTR BkpPath,
  344. IN BOOL bDeleteSrcFile
  345. );
  346. #endif //ifndef _DMP_H