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.

449 lines
8.7 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. //
  47. // Definitions for GUM update types
  48. //
  49. // The first entries in this list are auto-marshalled through Gum...Ex.
  50. // Any updates that are not auto-marshalled must come after DmUpdateMaxAuto
  51. //
  52. typedef enum {
  53. DmUpdateCreateKey = 0,
  54. DmUpdateSetSecurity,
  55. DmUpdateMaxAuto = 0x1000,
  56. DmUpdateDeleteKey,
  57. DmUpdateSetValue,
  58. DmUpdateDeleteValue,
  59. DmUpdateJoin
  60. } DM_UPDATE_TYPE;
  61. //
  62. // Key creation update structure.
  63. //
  64. typedef struct _DM_CREATE_KEY_UPDATE {
  65. LPDWORD lpDisposition; // only valid on issuing node
  66. HKEY *phKey; // only valid on issuing node
  67. DWORD samDesired;
  68. DWORD dwOptions;
  69. BOOL SecurityPresent;
  70. } DM_CREATE_KEY_UPDATE, *PDM_CREATE_KEY_UPDATE;
  71. //
  72. // Key deletion update structure.
  73. //
  74. typedef struct _DM_DELETE_KEY_UPDATE {
  75. LPDWORD lpStatus; // only valid on issuing node
  76. WCHAR Name[0];
  77. } DM_DELETE_KEY_UPDATE, *PDM_DELETE_KEY_UPDATE;
  78. //
  79. // Value set update structure.
  80. //
  81. typedef struct _DM_SET_VALUE_UPDATE {
  82. LPDWORD lpStatus; // only valid on issuing node
  83. DWORD NameOffset;
  84. DWORD DataOffset;
  85. DWORD DataLength;
  86. DWORD Type;
  87. WCHAR KeyName[0];
  88. } DM_SET_VALUE_UPDATE, *PDM_SET_VALUE_UPDATE;
  89. //
  90. // Value delete update structure.
  91. //
  92. typedef struct _DM_DELETE_VALUE_UPDATE {
  93. LPDWORD lpStatus; // only valid on issuing node
  94. DWORD NameOffset;
  95. WCHAR KeyName[0];
  96. } DM_DELETE_VALUE_UPDATE, *PDM_DELETE_VALUE_UPDATE;
  97. // the record structure for quorum logging
  98. typedef struct _DM_LOGSCAN_CONTEXT{
  99. DWORD dwSequence;
  100. LSN StartLsn;
  101. DWORD dwLastSequence;
  102. }DM_LOGSCAN_CONTEXT, *PDM_LOGSCAN_CONTEXT;
  103. //
  104. // Data local to the DM module.
  105. //
  106. extern HKEY DmpRoot;
  107. extern LIST_ENTRY KeyList;
  108. extern CRITICAL_SECTION KeyLock;
  109. extern BOOL gbDmpShutdownUpdates;
  110. //disk space requirements
  111. //1M, is lower than this, gracefully shutdown
  112. #define DISKSPACE_LOW_WATERMARK (1 * 1024 * 1000)
  113. //2M, if lower then send alert
  114. #define DISKSPACE_HIGH_WATERMARK (5 * 1024 * 1000)
  115. //minimum required to start the cluster service
  116. #define DISKSPACE_INIT_MINREQUIRED DISKSPACE_HIGH_WATERMARK
  117. #define DISKSPACE_MANAGE_INTERVAL (5 * 60 * 1000) //5 minute..log management functions are performed
  118. #define DEFAULT_CHECKPOINT_INTERVAL (4 ) // in hours
  119. typedef struct _LOCALXSACTION{
  120. DWORD dwSig;
  121. DWORD dwSequence;
  122. HXSACTION hLogXsaction; //the log transaction
  123. LIST_ENTRY PendingNotifyListHead; //the pending notifications to be issued on commit
  124. }LOCALXSACTION, *PLOCALXSACTION;
  125. typedef struct _DM_PENDING_NOTIFY{
  126. LIST_ENTRY ListEntry;
  127. LPWSTR pszKeyName;
  128. DWORD dwFilter;
  129. }DM_PENDING_NOTIFY, *PDM_PENDING_NOTIFY;
  130. #define LOCALXSAC_SIG 'CAXL'
  131. #define GETLOCALXSACTION(pLocalXsaction, hLocalXsaction) \
  132. (pLocalXsaction) = (PLOCALXSACTION)(hLocalXsaction); \
  133. CL_ASSERT((pLocalXsaction)->dwSig == LOCALXSAC_SIG)
  134. //quorum log tombstone
  135. #define MAXSIZE_RESOURCEID 128
  136. typedef struct _QUO_TOMBSTONE{
  137. WCHAR szOldQuoResId[MAXSIZE_RESOURCEID];
  138. WCHAR szOldQuoLogPath[MAX_PATH];
  139. }QUO_TOMBSTONE, *PQUO_TOMBSTONE;
  140. //
  141. // Function prototypes local to the DM
  142. //
  143. DWORD
  144. DmpOpenKeys(
  145. IN REGSAM samDesired
  146. );
  147. DWORD
  148. DmpGetRegistrySequence(
  149. VOID
  150. );
  151. DWORD
  152. DmpSyncDatabase(
  153. IN RPC_BINDING_HANDLE RpcBinding,
  154. IN OPTIONAL LPCWSTR Directory
  155. );
  156. VOID
  157. DmpUpdateSequence(
  158. VOID
  159. );
  160. VOID
  161. DmpInvalidateKeys(
  162. VOID
  163. );
  164. VOID
  165. DmpReopenKeys(
  166. VOID
  167. );
  168. //
  169. // Notification interface
  170. //
  171. BOOL
  172. DmpInitNotify(
  173. VOID
  174. );
  175. VOID
  176. DmpRundownNotify(
  177. IN PDMKEY Key
  178. );
  179. VOID
  180. DmpReportNotify(
  181. IN LPCWSTR KeyName,
  182. IN DWORD Filter
  183. );
  184. //for delivering notifications when a transaction is committed
  185. VOID
  186. DmpReportPendingNotifications(
  187. IN PLOCALXSACTION pLocalXsaction,
  188. IN BOOL bCommit
  189. );
  190. DWORD
  191. DmpAddToPendingNotifications(
  192. IN PLOCALXSACTION pLocalXsaction,
  193. IN LPCWSTR pszName,
  194. IN DWORD dwFilter
  195. );
  196. //
  197. // Update handlers
  198. //
  199. DWORD
  200. DmpUpdateCreateKey(
  201. IN BOOL SourceNode,
  202. IN PDM_CREATE_KEY_UPDATE CreateUpdate,
  203. IN LPCWSTR KeyName,
  204. IN OPTIONAL LPVOID lpSecurityDescriptor
  205. );
  206. DWORD
  207. DmpUpdateDeleteKey(
  208. IN BOOL SourceNode,
  209. IN PDM_DELETE_KEY_UPDATE Update
  210. );
  211. DWORD
  212. DmpUpdateSetValue(
  213. IN BOOL SourceNode,
  214. IN PDM_SET_VALUE_UPDATE Update
  215. );
  216. DWORD
  217. DmpUpdateDeleteValue(
  218. IN BOOL SourceNode,
  219. IN PDM_DELETE_VALUE_UPDATE Update
  220. );
  221. DWORD
  222. DmpUpdateSetSecurity(
  223. IN BOOL SourceNode,
  224. IN PSECURITY_INFORMATION pSecurityInformation,
  225. IN LPCWSTR KeyName,
  226. IN PSECURITY_DESCRIPTOR lpSecurityDescriptor,
  227. IN LPDWORD pGrantedAccess
  228. );
  229. //
  230. // For Quorum Logging
  231. //
  232. DWORD DmpChkQuoTombStone(void);
  233. DWORD DmpApplyChanges(void);
  234. DWORD DmpCheckDiskSpace(void);
  235. //diskmanage functions
  236. void
  237. WINAPI DmpDiskManage(
  238. IN HANDLE hTimer,
  239. IN PVOID pContext
  240. );
  241. void WINAPI DmpCheckpointTimerCb(
  242. IN HANDLE hTimer,
  243. IN PVOID pContext
  244. );
  245. DWORD DmWriteToQuorumLog(
  246. IN DWORD dwGumDispatch,
  247. IN DWORD dwSequence,
  248. IN DWORD dwType,
  249. IN PVOID pData,
  250. IN DWORD dwSize
  251. );
  252. BOOL DmpLogApplyChangesCb(
  253. IN PVOID pContext,
  254. IN LSN Lsn,
  255. IN RMID Resource,
  256. IN RMTYPE ResourceType,
  257. IN TRID Transaction,
  258. IN TRTYPE TransactionType,
  259. IN const PVOID pLogData,
  260. IN DWORD DataLength
  261. );
  262. BOOL WINAPI DmpApplyTransactionCb(
  263. IN PVOID pContext,
  264. IN LSN Lsn,
  265. IN RMID Resource,
  266. IN RMTYPE ResourceType,
  267. IN TRID TransactionId,
  268. IN const PVOID pLogData,
  269. IN DWORD dwDataLength
  270. );
  271. DWORD DmpLogFindStartLsn(
  272. IN HLOG hQuoLog,
  273. OUT LSN *pStartScanLsn,
  274. IN OUT LPDWORD pdwSequence);
  275. BOOL WINAPI DmpLogFindStartLsnCb(
  276. IN PVOID pContext,
  277. IN LSN Lsn,
  278. IN RMID Resource,
  279. IN RMTYPE ResourceType,
  280. IN TRID Transaction,
  281. IN TRTYPE TransactionType,
  282. IN const PVOID pLogData,
  283. IN DWORD DataLength);
  284. DWORD WINAPI DmpGetSnapShotCb(
  285. IN LPCWSTR lpszPathName,
  286. IN PVOID pContext,
  287. OUT LPWSTR szChkPtFile,
  288. OUT LPDWORD pdwChkPtSequence);
  289. DWORD
  290. DmpHookQuorumNotify(void);
  291. DWORD
  292. DmpUnhookQuorumNotify(void);
  293. void DmpQuoObjNotifyCb(
  294. IN PVOID pContext,
  295. IN PVOID pObject,
  296. IN DWORD dwNotification);
  297. DWORD
  298. DmpHookEventHandler();
  299. BOOL DmpNodeObjEnumCb(
  300. IN BOOL *pbAreAllNodesUp,
  301. IN PVOID pContext2,
  302. IN PVOID pNode,
  303. IN LPCWSTR szName);
  304. DWORD WINAPI
  305. DmpEventHandler(
  306. IN CLUSTER_EVENT Event,
  307. IN PVOID pContext
  308. );
  309. DWORD
  310. DmpLoadHive(
  311. IN LPCWSTR Path
  312. );
  313. DWORD
  314. DmpUnloadHive(
  315. );
  316. DWORD DmpRestoreClusterDatabase(
  317. IN LPCWSTR lpszQuoLogPathName
  318. );
  319. DWORD DmpLogCheckpointAndBackup(
  320. IN HLOG hLogFile,
  321. IN LPWSTR lpszPathName);
  322. DWORD DmpGetCheckpointInterval(
  323. OUT LPDWORD pdwCheckpointInterval);
  324. DWORD DmpHandleNodeDownEvent(
  325. IN LPVOID NotUsed );
  326. //
  327. // registry flusher thread interface.
  328. //
  329. DWORD
  330. DmpStartFlusher(
  331. VOID
  332. );
  333. VOID
  334. DmpShutdownFlusher(
  335. VOID
  336. );
  337. VOID
  338. DmpRestartFlusher(
  339. VOID
  340. );
  341. DWORD
  342. DmpSetDwordInClusterServer(
  343. LPCWSTR lpszValueName,
  344. DWORD dwValue
  345. );
  346. DWORD DmpGetDwordFromClusterServer(
  347. IN LPCWSTR lpszValueName,
  348. OUT LPDWORD pdwValue,
  349. IN DWORD dwDefaultValue
  350. );
  351. DWORD
  352. DmpSafeDatabaseCopy(
  353. IN LPCWSTR FileName,
  354. IN LPCWSTR Path,
  355. IN LPCWSTR BkpPath,
  356. IN BOOL bDeleteSrcFile
  357. );
  358. #endif //ifndef _DMP_H