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.

750 lines
15 KiB

  1. #ifndef _FM_H
  2. #define _FM_H
  3. /*++
  4. Copyright (c) 1996 Microsoft Corporation
  5. Module Name:
  6. fm.h
  7. Abstract:
  8. Public data structures and procedure prototypes for
  9. the Failover Manager subcomponent of the NT Cluster Service
  10. Author:
  11. John Vert (jvert) 7-Feb-1996
  12. Revision History:
  13. --*/
  14. //
  15. // Public structure definitions
  16. //
  17. //
  18. // FM notifications
  19. // The FM supports the following notifications to allow other
  20. // cluster components to prepare and cleanup state.
  21. //
  22. //SS: for now add it here..but if this is needed externally
  23. //move it to appropriate place
  24. // these notifications are generated only on the node where the
  25. // resource resides
  26. #define NOTIFY_RESOURCE_PREONLINE 0x00000001
  27. #define NOTIFY_RESOURCE_POSTONLINE 0x00000002
  28. #define NOTIFY_RESOURCE_PREOFFLINE 0x00000004
  29. #define NOTIFY_RESOURCE_POSTOFFLINE 0x00000008 //this is the same as offline
  30. #define NOTIFY_RESOURCE_FAILED 0x00000010
  31. #define NOTIFY_RESOURCE_OFFLINEPENDING 0x00000020
  32. #define NOTIFY_RESOURCE_ONLINEPENDING 0x00000040
  33. //
  34. // Resource type structure definition
  35. //
  36. // Define Flags
  37. #define RESTYPE_DEBUG_CONTROL_FUNC 1
  38. #define RESTYPE_STATE_LOADS 0x00000001
  39. typedef struct FM_RESTYPE {
  40. LPWSTR DllName;
  41. DWORD LooksAlivePollInterval;
  42. DWORD IsAlivePollInterval;
  43. LPWSTR DebugPrefix;
  44. DWORD Flags;
  45. DWORD State;
  46. DWORD Class;
  47. LIST_ENTRY PossibleNodeList;
  48. } FM_RESTYPE, *PFM_RESTYPE;
  49. //
  50. // Resource Possible Owners structure
  51. //
  52. typedef struct RESTYPE_POSSIBLE_ENTRY {
  53. LIST_ENTRY PossibleLinkage;
  54. PNM_NODE PossibleNode;
  55. } RESTYPE_POSSIBLE_ENTRY, *PRESTYPE_POSSIBLE_ENTRY;
  56. #if CLUSTER_BETA
  57. #define FM_MAX_LOCK_ENTRIES 8
  58. #else
  59. #define FM_MAX_LOCK_ENTRIES 4
  60. #endif
  61. //
  62. // Group structure
  63. //
  64. typedef struct _LOCK_INFO {
  65. DWORD Module: 5;
  66. DWORD ThreadId: 11;
  67. DWORD LineNumber: 16;
  68. } LOCK_INFO, *PLOCK_INFO;
  69. typedef struct FM_GROUP {
  70. DWORD dwStructState;
  71. LIST_ENTRY Contains; // List of root resources in this Group
  72. LIST_ENTRY PreferredOwners; // Ordered list of preferred owners
  73. LIST_ENTRY DmRundownList; // DM rundown list
  74. DWORD OrderedOwners; // # of ordered owners in above list
  75. CRITICAL_SECTION Lock; // Critical section for this Group
  76. DWORD LockIndex;
  77. DWORD UnlockIndex;
  78. LOCK_INFO LockTable[FM_MAX_LOCK_ENTRIES];
  79. LOCK_INFO UnlockTable[FM_MAX_LOCK_ENTRIES];
  80. CLUSTER_GROUP_STATE State; // State of the Group
  81. PRESOURCE_ENUM MovingList; // Ptr to List of moving resources
  82. BOOL Initialized; // TRUE if registry parameters read
  83. BOOL InitFailed; // TRUE if a resource fails to init
  84. PNM_NODE OwnerNode; // Ptr to owner node. NULL if not known
  85. UCHAR FailbackType; // See AutoFailbackTypes
  86. UCHAR FailbackWindowStart; // 0-24 hours
  87. UCHAR FailbackWindowEnd; // 0-24 hours (0 is immediate)
  88. UCHAR FailoverPeriod; // 1-24 hours (0 is infinite)
  89. DWORD FailoverThreshold; // 1-N failovers (0 is infinite)
  90. CLUSTER_GROUP_STATE PersistentState; // Preferred state of this group
  91. DWORD FailureTime; // Time of first failure
  92. DWORD NumberOfFailures; // Number of failures.
  93. HDMKEY RegistryKey;
  94. LIST_ENTRY WaitQueue; // chained FM_WAIT_BLOCK structures
  95. DWORD StateSequence;
  96. HANDLE hPendingEvent;
  97. PNM_NODE pIntendedOwner;
  98. LPWSTR lpszAntiAffinityClassName; // Anti-affinity property
  99. } FM_GROUP, *PFM_GROUP;
  100. #define FM_GROUP_STRUCT_CREATED 0x00000001
  101. #define FM_GROUP_STRUCT_INITIALIZED 0x00000002
  102. #define FM_GROUP_STRUCT_MARKED_FOR_DELETE 0x00000004
  103. #define FM_GROUP_STRUCT_MARKED_FOR_MOVE_ON_FAIL 0x00000008
  104. #define FM_GROUP_STRUCT_MARKED_FOR_REGULAR_MOVE 0x00000010
  105. #define FM_GROUP_STRUCT_MARKED_FOR_PENDING_ACTION 0x00000020
  106. #define IS_VALID_FM_GROUP(pFmGroup) \
  107. (!(pFmGroup->dwStructState & FM_GROUP_STRUCT_MARKED_FOR_DELETE))
  108. //
  109. #define IS_PENDING_FM_GROUP(pFmGroup) \
  110. (pFmGroup->dwStructState & FM_GROUP_STRUCT_MARKED_FOR_PENDING_ACTION)
  111. // Resource structure and types
  112. //
  113. //
  114. // Resource structure
  115. //
  116. // Define Flags
  117. #define RESOURCE_SEPARATE_MONITOR 1
  118. #define RESOURCE_CREATED 2
  119. #define RESOURCE_WAITING 4
  120. typedef struct FM_RESOURCE {
  121. DWORD dwStructState;
  122. LIST_ENTRY DependsOn;
  123. LIST_ENTRY ProvidesFor;
  124. LIST_ENTRY PossibleOwners; // List of possible owners
  125. LIST_ENTRY ContainsLinkage; // Linkage onto FM_GROUP.Contains
  126. LIST_ENTRY DmRundownList; // DM rundown list
  127. //SS: for now we dont use resource locks, so dont create it and leak it !
  128. //CRITICAL_SECTION Lock;
  129. RESID Id;
  130. CLUSTER_RESOURCE_STATE State;
  131. BOOL QuorumResource;
  132. LPWSTR Dependencies;
  133. LPWSTR DebugPrefix;
  134. DWORD DependenciesSize;
  135. struct RESMON *Monitor;
  136. PFM_RESTYPE Type;
  137. PFM_GROUP Group;
  138. ULONG Flags;
  139. DWORD LooksAlivePollInterval;
  140. DWORD IsAlivePollInterval;
  141. CLUSTER_RESOURCE_STATE PersistentState;
  142. DWORD RestartAction;
  143. DWORD RestartThreshold;
  144. DWORD RestartPeriod;
  145. DWORD NumberOfFailures;
  146. DWORD PendingTimeout;
  147. HANDLE PendingEvent;
  148. HDMKEY RegistryKey;
  149. DWORD FailureTime;
  150. PVOID CheckpointState; // for use by checkpoint manager
  151. DWORD ExFlags; // Extrinsic flags
  152. DWORD Characteristic;
  153. DWORD StateSequence;
  154. BOOL PossibleList; // TRUE if possible list entries specified
  155. DWORD BlockingQuorum; // 1 if shared lock held, blocking quorum
  156. HANDLE hTimer; // handle to timer used for delayed restart
  157. DWORD RetryPeriodOnFailure; //Time,in milliseconds, after which a restart will be attempted
  158. } FM_RESOURCE, *PFM_RESOURCE;
  159. #define FM_RESOURCE_STRUCT_CREATED 0x00000001
  160. #define FM_RESOURCE_STRUCT_INITIALIZED 0x00000002
  161. #define FM_RESOURCE_STRUCT_MARKED_FOR_DELETE 0x00000004
  162. #define IS_VALID_FM_RESOURCE(pFmResource) \
  163. (!(pFmResource->dwStructState & FM_RESOURCE_STRUCT_MARKED_FOR_DELETE))
  164. //
  165. // Dependency structure
  166. //
  167. typedef struct dependency {
  168. LIST_ENTRY DependentLinkage;
  169. PFM_RESOURCE DependentResource;
  170. LIST_ENTRY ProviderLinkage;
  171. PFM_RESOURCE ProviderResource;
  172. } DEPENDENCY, *PDEPENDENCY;
  173. //
  174. // AutoFailbackType
  175. //
  176. typedef enum {
  177. GroupNoFailback,
  178. GroupFailback
  179. } GROUP_FAILBACK_TYPE;
  180. //
  181. // Group Preferred Owners structure
  182. //
  183. typedef struct PREFERRED_ENTRY {
  184. LIST_ENTRY PreferredLinkage;
  185. PNM_NODE PreferredNode;
  186. } PREFERRED_ENTRY, *PPREFERRED_ENTRY;
  187. //
  188. // Resource Possible Owners structure
  189. //
  190. typedef struct POSSIBLE_ENTRY {
  191. LIST_ENTRY PossibleLinkage;
  192. PNM_NODE PossibleNode;
  193. } POSSIBLE_ENTRY, *PPOSSIBLE_ENTRY;
  194. //
  195. // Public function interfaces
  196. //
  197. //
  198. // Startup, online and shutdown
  199. //
  200. DWORD
  201. WINAPI
  202. FmInitialize(
  203. VOID
  204. );
  205. BOOL
  206. FmArbitrateQuorumResource(
  207. VOID
  208. );
  209. VOID
  210. FmHoldIO(
  211. VOID
  212. );
  213. VOID
  214. FmResumeIO(
  215. VOID
  216. );
  217. DWORD
  218. WINAPI
  219. FmFindQuorumResource(
  220. OUT PFM_RESOURCE *ppResource
  221. );
  222. DWORD FmBringQuorumOnline();
  223. DWORD
  224. WINAPI
  225. FmFindQuorumOwnerNodeId(
  226. IN PFM_RESOURCE pResource
  227. );
  228. DWORD
  229. WINAPI
  230. FmGetQuorumResource(
  231. OUT PFM_GROUP *ppQuoGroup,
  232. OUT LPDWORD lpdwSignature OPTIONAL
  233. );
  234. DWORD
  235. WINAPI
  236. FmSetQuorumResource(
  237. IN PFM_RESOURCE Resource,
  238. IN LPCWSTR lpszLogPathName,
  239. IN DWORD dwMaxQuorumLogSize
  240. );
  241. DWORD
  242. WINAPI
  243. FmBackupClusterDatabase(
  244. IN LPCWSTR lpszPathName
  245. );
  246. DWORD
  247. WINAPI
  248. FmFormNewClusterPhase1(
  249. IN PFM_GROUP pQuoGroup
  250. );
  251. DWORD
  252. WINAPI
  253. FmFormNewClusterPhase2(
  254. VOID
  255. );
  256. DWORD
  257. WINAPI
  258. FmJoinPhase1(
  259. VOID
  260. );
  261. DWORD
  262. WINAPI
  263. FmJoinPhase2(
  264. VOID
  265. );
  266. VOID
  267. FmJoinPhase3(
  268. VOID
  269. );
  270. VOID
  271. FmShutdownGroups(
  272. VOID
  273. );
  274. VOID
  275. FmShutdown(
  276. VOID
  277. );
  278. //
  279. // Management APIs for groups
  280. //
  281. DWORD
  282. WINAPI
  283. FmOnlineGroup(
  284. IN PFM_GROUP Group
  285. );
  286. DWORD
  287. WINAPI
  288. FmOfflineGroup(
  289. IN PFM_GROUP Group
  290. );
  291. DWORD
  292. WINAPI
  293. FmMoveGroup(
  294. IN PFM_GROUP Group,
  295. IN PNM_NODE DestinationNode OPTIONAL
  296. );
  297. PFM_GROUP
  298. WINAPI
  299. FmCreateGroup(
  300. IN LPWSTR GroupId,
  301. IN LPCWSTR GroupName
  302. );
  303. DWORD
  304. WINAPI
  305. FmDeleteGroup(
  306. IN PFM_GROUP Group
  307. );
  308. DWORD
  309. WINAPI
  310. FmSetGroupName(
  311. IN PFM_GROUP Group,
  312. IN LPCWSTR FriendlyName
  313. );
  314. CLUSTER_GROUP_STATE
  315. WINAPI
  316. FmGetGroupState(
  317. IN PFM_GROUP Group,
  318. OUT LPWSTR NodeName,
  319. IN OUT PDWORD NameLength
  320. );
  321. //
  322. // Check if a cluster partition exists
  323. //
  324. BOOL
  325. WINAPI
  326. FmVerifyNodeDown(
  327. IN PNM_NODE Node,
  328. OUT LPBOOL IsDown
  329. );
  330. DWORD
  331. WINAPI
  332. FmEvictNode(
  333. IN PNM_NODE Node
  334. );
  335. //
  336. // enumeration callback routine definitions
  337. //
  338. typedef BOOL (*FM_ENUM_GROUP_RESOURCE_ROUTINE)(
  339. IN PVOID Context1,
  340. IN PVOID Context2,
  341. IN PVOID Resource,
  342. IN LPCWSTR Name
  343. );
  344. DWORD
  345. WINAPI
  346. FmEnumerateGroupResources(
  347. IN PFM_GROUP Group,
  348. IN FM_ENUM_GROUP_RESOURCE_ROUTINE EnumerationRoutine,
  349. IN PVOID Context1,
  350. IN PVOID Context2
  351. );
  352. //
  353. // Management APIs for resources
  354. //
  355. PFM_RESOURCE
  356. WINAPI
  357. FmCreateResource(
  358. IN PFM_GROUP Group,
  359. IN LPWSTR ResourceId,
  360. IN LPCWSTR ResourceName,
  361. IN LPCWSTR ResourceType,
  362. IN DWORD dwFlags
  363. );
  364. DWORD
  365. WINAPI
  366. FmOnlineResource(
  367. IN PFM_RESOURCE Resource
  368. );
  369. DWORD
  370. WINAPI
  371. FmOfflineResource(
  372. IN PFM_RESOURCE Resource
  373. );
  374. CLUSTER_RESOURCE_STATE
  375. WINAPI
  376. FmGetResourceState(
  377. IN PFM_RESOURCE Resource,
  378. OUT LPWSTR NodeName,
  379. IN OUT PDWORD NameLength
  380. );
  381. DWORD
  382. WINAPI
  383. FmFailResource(
  384. IN PFM_RESOURCE Resource
  385. );
  386. DWORD
  387. WINAPI
  388. FmDeleteResource(
  389. IN PFM_RESOURCE Resource
  390. );
  391. DWORD
  392. WINAPI
  393. FmSetResourceName(
  394. IN PFM_RESOURCE Resource,
  395. IN LPCWSTR FriendlyName
  396. );
  397. DWORD
  398. WINAPI
  399. FmAddResourceDependency(
  400. IN PFM_RESOURCE Resource,
  401. IN PFM_RESOURCE DependentResource
  402. );
  403. DWORD
  404. WINAPI
  405. FmRemoveResourceDependency(
  406. IN PFM_RESOURCE Resource,
  407. IN PFM_RESOURCE DependentResource
  408. );
  409. BOOL
  410. FmDependentResource(
  411. IN PFM_RESOURCE Resource,
  412. IN PFM_RESOURCE DependentResource,
  413. IN BOOL ImmediateOnly
  414. );
  415. DWORD
  416. WINAPI
  417. FmEnumResourceDependent(
  418. IN PFM_RESOURCE Resource,
  419. IN DWORD Index,
  420. OUT PFM_RESOURCE *DependentResource
  421. );
  422. DWORD
  423. WINAPI
  424. FmEnumResourceProvider(
  425. IN PFM_RESOURCE Resource,
  426. IN DWORD Index,
  427. OUT PFM_RESOURCE *ProviderResource
  428. );
  429. DWORD
  430. WINAPI
  431. FmEnumResourceNode(
  432. IN PFM_RESOURCE Resource,
  433. IN DWORD Index,
  434. OUT PNM_NODE *ProviderResource
  435. );
  436. DWORD
  437. WINAPI
  438. FmChangeResourceNode(
  439. IN PFM_RESOURCE Resource,
  440. IN PNM_NODE Node,
  441. IN BOOL Add
  442. );
  443. DWORD
  444. FmCreateResourceType(
  445. IN LPCWSTR lpszTypeName,
  446. IN LPCWSTR lpszDisplayName,
  447. IN LPCWSTR lpszDllName,
  448. IN DWORD dwLooksAlive,
  449. IN DWORD dwIsAlive
  450. );
  451. DWORD
  452. WINAPI
  453. FmDeleteResourceType(
  454. IN LPCWSTR TypeName
  455. );
  456. DWORD
  457. FmEnumResourceTypeNode(
  458. IN PFM_RESTYPE pResType,
  459. IN DWORD dwIndex,
  460. OUT PNM_NODE *pPossibleNode
  461. );
  462. DWORD
  463. FmChangeResourceGroup(
  464. IN PFM_RESOURCE Resource,
  465. IN PFM_GROUP Group
  466. );
  467. DWORD
  468. FmChangeClusterName(
  469. IN LPCWSTR NewName
  470. );
  471. DWORD
  472. FmNetNameParseProperties(
  473. IN PUCHAR InBuffer,
  474. IN DWORD InBufferSize,
  475. OUT LPWSTR *ppszClusterName
  476. );
  477. DWORD
  478. WINAPI
  479. FmResourceControl(
  480. IN PFM_RESOURCE Resource,
  481. IN PNM_NODE Node OPTIONAL,
  482. IN DWORD ControlCode,
  483. IN PUCHAR InBuffer,
  484. IN DWORD InBufferSize,
  485. OUT PUCHAR OutBuffer,
  486. IN DWORD OutBufferSize,
  487. OUT LPDWORD BytesReturned,
  488. OUT LPDWORD Required
  489. );
  490. DWORD
  491. WINAPI
  492. FmResourceTypeControl(
  493. IN LPCWSTR ResourceTypeName,
  494. IN PNM_NODE Node OPTIONAL,
  495. IN DWORD ControlCode,
  496. IN PUCHAR InBuffer,
  497. IN DWORD InBufferSize,
  498. OUT PUCHAR OutBuffer,
  499. IN DWORD OutBufferSize,
  500. OUT LPDWORD BytesReturned,
  501. OUT LPDWORD Required
  502. );
  503. DWORD
  504. WINAPI
  505. FmGroupControl(
  506. IN PFM_GROUP Group,
  507. IN PNM_NODE Node OPTIONAL,
  508. IN DWORD ControlCode,
  509. IN PUCHAR InBuffer,
  510. IN DWORD InBufferSize,
  511. OUT PUCHAR OutBuffer,
  512. IN DWORD OutBufferSize,
  513. OUT LPDWORD BytesReturned,
  514. OUT LPDWORD Required
  515. );
  516. //
  517. // Routines for manipulating dependency trees
  518. //
  519. typedef struct FM_DEPENDENCY_TREE {
  520. LIST_ENTRY ListHead;
  521. } FM_DEPENDENCY_TREE, *PFM_DEPENDENCY_TREE;
  522. typedef struct FM_DEPENDTREE_ENTRY {
  523. LIST_ENTRY ListEntry;
  524. PFM_RESOURCE Resource;
  525. } FM_DEPENDTREE_ENTRY, *PFM_DEPENDTREE_ENTRY;
  526. PFM_DEPENDENCY_TREE
  527. FmCreateFullDependencyTree(
  528. IN PFM_RESOURCE Resource
  529. );
  530. VOID
  531. FmDestroyFullDependencyTree(
  532. IN PFM_DEPENDENCY_TREE Tree
  533. );
  534. BOOL
  535. FmCheckNetworkDependency(
  536. IN LPCWSTR DependentNetwork
  537. );
  538. DWORD
  539. FmBuildWINS(
  540. IN DWORD dwFixUpType,
  541. OUT PVOID *ppPropertyList,
  542. OUT LPDWORD pdwPropertyListSize,
  543. OUT LPWSTR *pszKeyName
  544. );
  545. DWORD
  546. FmBuildDHCP(
  547. IN DWORD dwFixUpType,
  548. OUT PVOID *ppPropertyList,
  549. OUT LPDWORD pdwPropertyListSize,
  550. OUT LPWSTR * pszKeyName
  551. );
  552. DWORD
  553. FmBuildIIS(
  554. IN DWORD dwFixUpType,
  555. OUT PVOID *ppPropertyList,
  556. OUT LPDWORD pdwPropertyListSize,
  557. OUT LPWSTR * pszKeyName
  558. );
  559. DWORD
  560. FmBuildSMTP(
  561. IN DWORD dwFixUpType,
  562. OUT PVOID *ppPropertyList,
  563. OUT LPDWORD pdwPropertyListSize,
  564. OUT LPWSTR * pszKeyName
  565. );
  566. DWORD
  567. FmBuildNNTP(
  568. IN DWORD dwFixUpType,
  569. OUT PVOID *ppPropertyList,
  570. OUT LPDWORD pdwPropertyListSize,
  571. OUT LPWSTR * pszKeyName
  572. );
  573. DWORD
  574. FmBuildMSDTC(
  575. IN DWORD dwFixUpType,
  576. OUT PVOID * ppPropertyList,
  577. OUT LPDWORD pdwPropertyListSize,
  578. OUT LPWSTR * pszKeyName
  579. );
  580. DWORD
  581. FmBuildNewMSMQ(
  582. IN DWORD dwFixUpType,
  583. OUT PVOID * ppPropertyList,
  584. OUT LPDWORD pdwPropertyListSize,
  585. OUT LPWSTR * pszKeyName
  586. );
  587. DWORD
  588. FmBuildClusterProp(
  589. IN DWORD dwFixUpType,
  590. OUT PVOID * ppPropertyList,
  591. OUT LPDWORD pdwPropertyListSize,
  592. OUT LPWSTR * pszKeyName
  593. );
  594. DWORD
  595. FmCreateRpcBindings(
  596. PNM_NODE Node
  597. );
  598. //callback for registry fixups (resource type addition)
  599. DWORD
  600. FmFixupNotifyCb(VOID);
  601. //the callback registered for object notifications
  602. typedef void (WINAPI *FM_ONLINE_ONTHISNODE_CB)(
  603. );
  604. void FmCheckQuorumState(
  605. IN FM_ONLINE_ONTHISNODE_CB OnLineOnThisNodeCb,
  606. OUT PBOOL pbQuorumOfflineOnThisNode
  607. );
  608. DWORD FmDoesQuorumAllowJoin();
  609. DWORD FmDoesQuorumAllowLogging();
  610. //Fixup function for AdminExt value
  611. DWORD
  612. FmFixupAdminExt(VOID);
  613. #endif //_FM_H