2 * Copyright (c) 2015-2017 Red Hat, Inc.
6 * Author: Jan Friesse (jfriesse@redhat.com)
8 * This software licensed under BSD license, the text of which follows:
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions are met:
13 * - Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * - Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * - Neither the name of the Red Hat, Inc. nor the names of its
19 * contributors may be used to endorse or promote products derived from this
20 * software without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
32 * THE POSSIBILITY OF SUCH DAMAGE.
35 #ifndef _QDEVICE_INSTANCE_H_
36 #define _QDEVICE_INSTANCE_H_
38 #include <sys/types.h>
43 #include <corosync/cmap.h>
44 #include <corosync/votequorum.h>
46 #include "qdevice-advanced-settings.h"
47 #include "qdevice-heuristics.h"
48 #include "qdevice-model-type.h"
49 #include "node-list.h"
50 #include "unix-socket-ipc.h"
56 struct qdevice_instance
{
57 cmap_handle_t cmap_handle
;
59 int cmap_reload_in_progress
;
60 cmap_track_handle_t cmap_reload_track_handle
;
61 cmap_track_handle_t cmap_nodelist_track_handle
;
62 cmap_track_handle_t cmap_logging_track_handle
;
63 cmap_track_handle_t cmap_heuristics_track_handle
;
65 votequorum_handle_t votequorum_handle
;
66 int votequorum_poll_fd
;
68 struct unix_socket_ipc local_ipc
;
70 enum qdevice_model_type model_type
;
73 uint32_t heartbeat_interval
; /* Heartbeat interval during normal operation */
74 uint32_t sync_heartbeat_interval
; /* Heartbeat interval during corosync sync */
76 struct node_list config_node_list
;
77 int config_node_list_version_set
;
78 uint64_t config_node_list_version
;
81 * Copy of votequorum_quorum_notify_fn callback paramters.
82 * Set after model callback is called.
84 uint32_t vq_quorum_quorate
;
85 uint32_t vq_quorum_node_list_entries
;
86 votequorum_node_t
*vq_quorum_node_list
;
89 * Copy of current votequorum_nodelist_notify_fn callback parameters.
90 * Set after model callback qdevice_votequorum_node_list_notify_callback is called.
92 uint8_t vq_node_list_initial_ring_id_set
;
93 votequorum_ring_id_t vq_node_list_ring_id
;
94 uint32_t vq_node_list_entries
;
95 uint32_t *vq_node_list
;
96 uint8_t vq_node_list_initial_heuristics_finished
;
97 enum qdevice_heuristics_exec_result vq_node_list_heuristics_result
;
100 * Copy of current votequorum_nodelist_notify_fn callback ring id
101 * It's set before any callback is called and used for qdevice_votequorum_poll
103 votequorum_ring_id_t vq_poll_ring_id
;
106 * Copy of votequorum_expectedvotes_notify_fn callback parameters.
107 * Set after model callback is called.
109 uint32_t vq_expected_votes
;
112 int vq_last_poll_cast_vote
;
116 const struct qdevice_advanced_settings
*advanced_settings
;
118 int sync_in_progress
;
120 struct qdevice_heuristics_instance heuristics_instance
;
123 extern int qdevice_instance_init(struct qdevice_instance
*instance
,
124 const struct qdevice_advanced_settings
*advanced_settings
);
126 extern int qdevice_instance_destroy(struct qdevice_instance
*instance
);
128 extern int qdevice_instance_configure_from_cmap(struct qdevice_instance
*instance
);
130 extern int qdevice_instance_configure_from_cmap_heuristics(struct qdevice_instance
*instance
);
132 extern int qdevice_instance_wait_for_initial_heuristics_exec_result(struct qdevice_instance
*instance
);
138 #endif /* _QDEVICE_INSTANCE_H_ */