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.

775 lines
16 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 FM_GROUP_STRUCT_MARKED_FOR_COMPLETION_EVENT 0x00000040
  107. #define IS_VALID_FM_GROUP(pFmGroup) \
  108. (!(pFmGroup->dwStructState & FM_GROUP_STRUCT_MARKED_FOR_DELETE))
  109. //
  110. #define IS_PENDING_FM_GROUP(pFmGroup) \
  111. (pFmGroup->dwStructState & FM_GROUP_STRUCT_MARKED_FOR_PENDING_ACTION)
  112. // Resource structure and types
  113. //
  114. //
  115. // Resource structure
  116. //
  117. // Define Flags
  118. #define RESOURCE_SEPARATE_MONITOR 1
  119. #define RESOURCE_CREATED 2
  120. #define RESOURCE_WAITING 4
  121. typedef struct FM_RESOURCE {
  122. DWORD dwStructState;
  123. LIST_ENTRY DependsOn;
  124. LIST_ENTRY ProvidesFor;
  125. LIST_ENTRY PossibleOwners; // List of possible owners
  126. LIST_ENTRY ContainsLinkage; // Linkage onto FM_GROUP.Contains
  127. LIST_ENTRY DmRundownList; // DM rundown list
  128. //SS: for now we dont use resource locks, so dont create it and leak it !
  129. //CRITICAL_SECTION Lock;
  130. RESID Id;
  131. CLUSTER_RESOURCE_STATE State;
  132. BOOL QuorumResource;
  133. LPWSTR Dependencies;
  134. LPWSTR DebugPrefix;
  135. DWORD DependenciesSize;
  136. struct RESMON *Monitor;
  137. PFM_RESTYPE Type;
  138. PFM_GROUP Group;
  139. ULONG Flags;
  140. DWORD LooksAlivePollInterval;
  141. DWORD IsAlivePollInterval;
  142. CLUSTER_RESOURCE_STATE PersistentState;
  143. DWORD RestartAction;
  144. DWORD RestartThreshold;
  145. DWORD RestartPeriod;
  146. DWORD NumberOfFailures;
  147. DWORD PendingTimeout;
  148. HANDLE PendingEvent;
  149. HDMKEY RegistryKey;
  150. DWORD FailureTime;
  151. PVOID CheckpointState; // for use by checkpoint manager
  152. DWORD ExFlags; // Extrinsic flags
  153. DWORD Characteristic;
  154. DWORD StateSequence;
  155. BOOL PossibleList; // TRUE if possible list entries specified
  156. DWORD BlockingQuorum; // 1 if shared lock held, blocking quorum
  157. HANDLE hTimer; // handle to timer used for delayed restart
  158. DWORD RetryPeriodOnFailure; //Time,in milliseconds, after which a restart will be attempted
  159. } FM_RESOURCE, *PFM_RESOURCE;
  160. #define FM_RESOURCE_STRUCT_CREATED 0x00000001
  161. #define FM_RESOURCE_STRUCT_INITIALIZED 0x00000002
  162. #define FM_RESOURCE_STRUCT_MARKED_FOR_DELETE 0x00000004
  163. #define IS_VALID_FM_RESOURCE(pFmResource) \
  164. (!(pFmResource->dwStructState & FM_RESOURCE_STRUCT_MARKED_FOR_DELETE))
  165. //
  166. // Dependency structure
  167. //
  168. typedef struct dependency {
  169. LIST_ENTRY DependentLinkage;
  170. PFM_RESOURCE DependentResource;
  171. LIST_ENTRY ProviderLinkage;
  172. PFM_RESOURCE ProviderResource;
  173. } DEPENDENCY, *PDEPENDENCY;
  174. //
  175. // AutoFailbackType
  176. //
  177. typedef enum {
  178. GroupNoFailback,
  179. GroupFailback
  180. } GROUP_FAILBACK_TYPE;
  181. //
  182. // Group Preferred Owners structure
  183. //
  184. typedef struct PREFERRED_ENTRY {
  185. LIST_ENTRY PreferredLinkage;
  186. PNM_NODE PreferredNode;
  187. } PREFERRED_ENTRY, *PPREFERRED_ENTRY;
  188. //
  189. // Resource Possible Owners structure
  190. //
  191. typedef struct POSSIBLE_ENTRY {
  192. LIST_ENTRY PossibleLinkage;
  193. PNM_NODE PossibleNode;
  194. } POSSIBLE_ENTRY, *PPOSSIBLE_ENTRY;
  195. //
  196. // Public function interfaces
  197. //
  198. //
  199. // Startup, online and shutdown
  200. //
  201. DWORD
  202. WINAPI
  203. FmInitialize(
  204. VOID
  205. );
  206. BOOL
  207. FmArbitrateQuorumResource(
  208. VOID
  209. );
  210. VOID
  211. FmHoldIO(
  212. VOID
  213. );
  214. VOID
  215. FmResumeIO(
  216. VOID
  217. );
  218. DWORD
  219. WINAPI
  220. FmFindQuorumResource(
  221. OUT PFM_RESOURCE *ppResource
  222. );
  223. DWORD FmBringQuorumOnline();
  224. DWORD
  225. WINAPI
  226. FmFindQuorumOwnerNodeId(
  227. IN PFM_RESOURCE pResource
  228. );
  229. DWORD
  230. WINAPI
  231. FmGetQuorumResource(
  232. OUT PFM_GROUP *ppQuoGroup,
  233. OUT LPDWORD lpdwSignature OPTIONAL
  234. );
  235. DWORD
  236. WINAPI
  237. FmpSendForceQuorumControlToResource(
  238. IN PFM_RESOURCE resource
  239. );
  240. BOOL
  241. WINAPI
  242. FmpIsNodeInForceQuorumNodes(
  243. IN LPCWSTR lpszNodeId
  244. );
  245. DWORD
  246. WINAPI
  247. FmSetQuorumResource(
  248. IN PFM_RESOURCE Resource,
  249. IN LPCWSTR lpszLogPathName,
  250. IN DWORD dwMaxQuorumLogSize
  251. );
  252. DWORD
  253. WINAPI
  254. FmBackupClusterDatabase(
  255. IN LPCWSTR lpszPathName
  256. );
  257. DWORD
  258. WINAPI
  259. FmFormNewClusterPhase1(
  260. IN PFM_GROUP pQuoGroup
  261. );
  262. DWORD
  263. WINAPI
  264. FmFormNewClusterPhase2(
  265. VOID
  266. );
  267. DWORD
  268. WINAPI
  269. FmJoinPhase1(
  270. OUT DWORD *EndSeq
  271. );
  272. DWORD
  273. WINAPI
  274. FmJoinPhase2(
  275. VOID
  276. );
  277. VOID
  278. FmJoinPhase3(
  279. VOID
  280. );
  281. VOID
  282. FmShutdownGroups(
  283. VOID
  284. );
  285. VOID
  286. FmShutdown(
  287. VOID
  288. );
  289. //
  290. // Management APIs for groups
  291. //
  292. DWORD
  293. WINAPI
  294. FmOnlineGroup(
  295. IN PFM_GROUP Group
  296. );
  297. DWORD
  298. WINAPI
  299. FmOfflineGroup(
  300. IN PFM_GROUP Group
  301. );
  302. DWORD
  303. WINAPI
  304. FmMoveGroup(
  305. IN PFM_GROUP Group,
  306. IN PNM_NODE DestinationNode OPTIONAL
  307. );
  308. PFM_GROUP
  309. WINAPI
  310. FmCreateGroup(
  311. IN LPWSTR GroupId,
  312. IN LPCWSTR GroupName
  313. );
  314. DWORD
  315. WINAPI
  316. FmDeleteGroup(
  317. IN PFM_GROUP Group
  318. );
  319. DWORD
  320. WINAPI
  321. FmSetGroupName(
  322. IN PFM_GROUP Group,
  323. IN LPCWSTR FriendlyName
  324. );
  325. CLUSTER_GROUP_STATE
  326. WINAPI
  327. FmGetGroupState(
  328. IN PFM_GROUP Group,
  329. OUT LPWSTR NodeName,
  330. IN OUT PDWORD NameLength
  331. );
  332. //
  333. // Check if a cluster partition exists
  334. //
  335. BOOL
  336. WINAPI
  337. FmVerifyNodeDown(
  338. IN PNM_NODE Node,
  339. OUT LPBOOL IsDown
  340. );
  341. DWORD
  342. WINAPI
  343. FmEvictNode(
  344. IN PNM_NODE Node
  345. );
  346. //
  347. // enumeration callback routine definitions
  348. //
  349. typedef BOOL (*FM_ENUM_GROUP_RESOURCE_ROUTINE)(
  350. IN PVOID Context1,
  351. IN PVOID Context2,
  352. IN PVOID Resource,
  353. IN LPCWSTR Name
  354. );
  355. DWORD
  356. WINAPI
  357. FmEnumerateGroupResources(
  358. IN PFM_GROUP Group,
  359. IN FM_ENUM_GROUP_RESOURCE_ROUTINE EnumerationRoutine,
  360. IN PVOID Context1,
  361. IN PVOID Context2
  362. );
  363. //
  364. // Management APIs for resources
  365. //
  366. PFM_RESOURCE
  367. WINAPI
  368. FmCreateResource(
  369. IN PFM_GROUP Group,
  370. IN LPWSTR ResourceId,
  371. IN LPCWSTR ResourceName,
  372. IN LPCWSTR ResourceType,
  373. IN DWORD dwFlags
  374. );
  375. DWORD
  376. WINAPI
  377. FmOnlineResource(
  378. IN PFM_RESOURCE Resource
  379. );
  380. DWORD
  381. WINAPI
  382. FmOfflineResource(
  383. IN PFM_RESOURCE Resource
  384. );
  385. CLUSTER_RESOURCE_STATE
  386. WINAPI
  387. FmGetResourceState(
  388. IN PFM_RESOURCE Resource,
  389. OUT LPWSTR NodeName,
  390. IN OUT PDWORD NameLength
  391. );
  392. DWORD
  393. WINAPI
  394. FmFailResource(
  395. IN PFM_RESOURCE Resource
  396. );
  397. DWORD
  398. WINAPI
  399. FmDeleteResource(
  400. IN PFM_RESOURCE Resource
  401. );
  402. DWORD
  403. WINAPI
  404. FmSetResourceName(
  405. IN PFM_RESOURCE Resource,
  406. IN LPCWSTR FriendlyName
  407. );
  408. DWORD
  409. WINAPI
  410. FmAddResourceDependency(
  411. IN PFM_RESOURCE Resource,
  412. IN PFM_RESOURCE DependentResource
  413. );
  414. DWORD
  415. WINAPI
  416. FmRemoveResourceDependency(
  417. IN PFM_RESOURCE Resource,
  418. IN PFM_RESOURCE DependentResource
  419. );
  420. BOOL
  421. FmDependentResource(
  422. IN PFM_RESOURCE Resource,
  423. IN PFM_RESOURCE DependentResource,
  424. IN BOOL ImmediateOnly
  425. );
  426. DWORD
  427. WINAPI
  428. FmEnumResourceDependent(
  429. IN PFM_RESOURCE Resource,
  430. IN DWORD Index,
  431. OUT PFM_RESOURCE *DependentResource
  432. );
  433. DWORD
  434. WINAPI
  435. FmEnumResourceProvider(
  436. IN PFM_RESOURCE Resource,
  437. IN DWORD Index,
  438. OUT PFM_RESOURCE *ProviderResource
  439. );
  440. DWORD
  441. WINAPI
  442. FmEnumResourceNode(
  443. IN PFM_RESOURCE Resource,
  444. IN DWORD Index,
  445. OUT PNM_NODE *ProviderResource
  446. );
  447. DWORD
  448. WINAPI
  449. FmChangeResourceNode(
  450. IN PFM_RESOURCE Resource,
  451. IN PNM_NODE Node,
  452. IN BOOL Add
  453. );
  454. DWORD
  455. FmCreateResourceType(
  456. IN LPCWSTR lpszTypeName,
  457. IN LPCWSTR lpszDisplayName,
  458. IN LPCWSTR lpszDllName,
  459. IN DWORD dwLooksAlive,
  460. IN DWORD dwIsAlive
  461. );
  462. DWORD
  463. WINAPI
  464. FmDeleteResourceType(
  465. IN LPCWSTR TypeName
  466. );
  467. DWORD
  468. FmEnumResourceTypeNode(
  469. IN PFM_RESTYPE pResType,
  470. IN DWORD dwIndex,
  471. OUT PNM_NODE *pPossibleNode
  472. );
  473. DWORD
  474. FmChangeResourceGroup(
  475. IN PFM_RESOURCE Resource,
  476. IN PFM_GROUP Group
  477. );
  478. DWORD
  479. FmChangeClusterName(
  480. IN LPCWSTR pszNewName,
  481. IN LPCWSTR pszOldName
  482. );
  483. DWORD
  484. FmNetNameParseProperties(
  485. IN PUCHAR InBuffer,
  486. IN DWORD InBufferSize,
  487. OUT LPWSTR *ppszClusterName
  488. );
  489. DWORD
  490. WINAPI
  491. FmResourceControl(
  492. IN PFM_RESOURCE Resource,
  493. IN PNM_NODE Node OPTIONAL,
  494. IN DWORD ControlCode,
  495. IN PUCHAR InBuffer,
  496. IN DWORD InBufferSize,
  497. OUT PUCHAR OutBuffer,
  498. IN DWORD OutBufferSize,
  499. OUT LPDWORD BytesReturned,
  500. OUT LPDWORD Required
  501. );
  502. DWORD
  503. WINAPI
  504. FmResourceTypeControl(
  505. IN LPCWSTR ResourceTypeName,
  506. IN PNM_NODE Node OPTIONAL,
  507. IN DWORD ControlCode,
  508. IN PUCHAR InBuffer,
  509. IN DWORD InBufferSize,
  510. OUT PUCHAR OutBuffer,
  511. IN DWORD OutBufferSize,
  512. OUT LPDWORD BytesReturned,
  513. OUT LPDWORD Required
  514. );
  515. DWORD
  516. WINAPI
  517. FmGroupControl(
  518. IN PFM_GROUP Group,
  519. IN PNM_NODE Node OPTIONAL,
  520. IN DWORD ControlCode,
  521. IN PUCHAR InBuffer,
  522. IN DWORD InBufferSize,
  523. OUT PUCHAR OutBuffer,
  524. IN DWORD OutBufferSize,
  525. OUT LPDWORD BytesReturned,
  526. OUT LPDWORD Required
  527. );
  528. //
  529. // Routines for manipulating dependency trees
  530. //
  531. typedef struct FM_DEPENDENCY_TREE {
  532. LIST_ENTRY ListHead;
  533. } FM_DEPENDENCY_TREE, *PFM_DEPENDENCY_TREE;
  534. typedef struct FM_DEPENDTREE_ENTRY {
  535. LIST_ENTRY ListEntry;
  536. PFM_RESOURCE Resource;
  537. } FM_DEPENDTREE_ENTRY, *PFM_DEPENDTREE_ENTRY;
  538. PFM_DEPENDENCY_TREE
  539. FmCreateFullDependencyTree(
  540. IN PFM_RESOURCE Resource
  541. );
  542. VOID
  543. FmDestroyFullDependencyTree(
  544. IN PFM_DEPENDENCY_TREE Tree
  545. );
  546. BOOL
  547. FmCheckNetworkDependency(
  548. IN LPCWSTR DependentNetwork
  549. );
  550. DWORD
  551. FmBuildWINS(
  552. IN DWORD dwFixUpType,
  553. OUT PVOID *ppPropertyList,
  554. OUT LPDWORD pdwPropertyListSize,
  555. OUT LPWSTR *pszKeyName
  556. );
  557. DWORD
  558. FmBuildDHCP(
  559. IN DWORD dwFixUpType,
  560. OUT PVOID *ppPropertyList,
  561. OUT LPDWORD pdwPropertyListSize,
  562. OUT LPWSTR * pszKeyName
  563. );
  564. DWORD
  565. FmBuildIIS(
  566. IN DWORD dwFixUpType,
  567. OUT PVOID *ppPropertyList,
  568. OUT LPDWORD pdwPropertyListSize,
  569. OUT LPWSTR * pszKeyName
  570. );
  571. DWORD
  572. FmBuildSMTP(
  573. IN DWORD dwFixUpType,
  574. OUT PVOID *ppPropertyList,
  575. OUT LPDWORD pdwPropertyListSize,
  576. OUT LPWSTR * pszKeyName
  577. );
  578. DWORD
  579. FmBuildNNTP(
  580. IN DWORD dwFixUpType,
  581. OUT PVOID *ppPropertyList,
  582. OUT LPDWORD pdwPropertyListSize,
  583. OUT LPWSTR * pszKeyName
  584. );
  585. DWORD
  586. FmBuildMSDTC(
  587. IN DWORD dwFixUpType,
  588. OUT PVOID * ppPropertyList,
  589. OUT LPDWORD pdwPropertyListSize,
  590. OUT LPWSTR * pszKeyName
  591. );
  592. DWORD
  593. FmBuildNewMSMQ(
  594. IN DWORD dwFixUpType,
  595. OUT PVOID * ppPropertyList,
  596. OUT LPDWORD pdwPropertyListSize,
  597. OUT LPWSTR * pszKeyName
  598. );
  599. DWORD
  600. FmBuildClusterProp(
  601. IN DWORD dwFixUpType,
  602. OUT PVOID * ppPropertyList,
  603. OUT LPDWORD pdwPropertyListSize,
  604. OUT LPWSTR * pszKeyName
  605. );
  606. DWORD
  607. FmCreateRpcBindings(
  608. PNM_NODE Node
  609. );
  610. //callback for registry fixups (resource type addition)
  611. DWORD
  612. FmFixupNotifyCb(VOID);
  613. //the callback registered for object notifications
  614. typedef void (WINAPI *FM_ONLINE_ONTHISNODE_CB)(
  615. );
  616. void FmCheckQuorumState(
  617. IN FM_ONLINE_ONTHISNODE_CB OnLineOnThisNodeCb,
  618. OUT PBOOL pbQuorumOfflineOnThisNode
  619. );
  620. DWORD FmDoesQuorumAllowJoin(
  621. IN PCWSTR pszJoinerNodeId );
  622. DWORD FmDoesQuorumAllowLogging(
  623. IN DWORD dwQuorumResourceCharacteristics OPTIONAL
  624. );
  625. //Fixup function for AdminExt value
  626. DWORD
  627. FmFixupAdminExt(VOID);
  628. //
  629. // Check if resource dll deadlock detection is enabled
  630. //
  631. VOID
  632. FmCheckIsDeadlockDetectionEnabled(
  633. VOID
  634. );
  635. #endif //_FM_H