48#include <qb/qbipc_common.h>
64#define MAX_REQ_EXEC_CMAP_MCAST_ITEMS 32
65#define ICMAP_VALUETYPE_NOT_EXIST 0
153static int cmap_exec_exit_fn(
void);
155static int cmap_lib_init_fn (
void *conn);
156static int cmap_lib_exit_fn (
void *conn);
158static void message_handler_req_lib_cmap_set(
void *conn,
const void *
message);
159static void message_handler_req_lib_cmap_delete(
void *conn,
const void *
message);
160static void message_handler_req_lib_cmap_get(
void *conn,
const void *
message);
161static void message_handler_req_lib_cmap_adjust_int(
void *conn,
const void *
message);
162static void message_handler_req_lib_cmap_iter_init(
void *conn,
const void *
message);
163static void message_handler_req_lib_cmap_iter_next(
void *conn,
const void *
message);
164static void message_handler_req_lib_cmap_iter_finalize(
void *conn,
const void *
message);
165static void message_handler_req_lib_cmap_track_add(
void *conn,
const void *
message);
166static void message_handler_req_lib_cmap_track_delete(
void *conn,
const void *
message);
167static void message_handler_req_lib_cmap_set_current_map(
void *conn,
const void *
message);
169static void cmap_notify_fn(
int32_t event,
170 const char *key_name,
175static void message_handler_req_exec_cmap_mcast(
179static void exec_cmap_mcast_endian_convert(
void *
message);
190static void cmap_sync_init (
193 const unsigned int *member_list,
194 size_t member_list_entries,
197static int cmap_sync_process (
void);
198static void cmap_sync_activate (
void);
199static void cmap_sync_abort (
void);
201static void cmap_config_version_track_cb(
203 const char *key_name,
218 .lib_handler_fn = message_handler_req_lib_cmap_delete,
222 .lib_handler_fn = message_handler_req_lib_cmap_get,
226 .lib_handler_fn = message_handler_req_lib_cmap_adjust_int,
230 .lib_handler_fn = message_handler_req_lib_cmap_iter_init,
234 .lib_handler_fn = message_handler_req_lib_cmap_iter_next,
238 .lib_handler_fn = message_handler_req_lib_cmap_iter_finalize,
242 .lib_handler_fn = message_handler_req_lib_cmap_track_add,
246 .lib_handler_fn = message_handler_req_lib_cmap_track_delete,
250 .lib_handler_fn = message_handler_req_lib_cmap_set_current_map,
259 .exec_endian_convert_fn = exec_cmap_mcast_endian_convert
264 .
name =
"corosync configuration map access",
270 .lib_init_fn = cmap_lib_init_fn,
271 .lib_exit_fn = cmap_lib_exit_fn,
272 .lib_engine = cmap_lib_engine,
274 .exec_init_fn = cmap_exec_init_fn,
275 .exec_exit_fn = cmap_exec_exit_fn,
276 .exec_engine = cmap_exec_engine,
278 .sync_init = cmap_sync_init,
279 .sync_process = cmap_sync_process,
280 .sync_activate = cmap_sync_activate,
281 .sync_abort = cmap_sync_abort
307static size_t cmap_sync_trans_list_entries = 0;
308static size_t cmap_sync_member_list_entries = 0;
309static uint64_t cmap_highest_config_version_received = 0;
310static uint64_t cmap_my_config_version = 0;
311static int cmap_first_sync = 1;
314static void cmap_config_version_track_cb(
316 const char *key_name,
321 const char *key =
"totem.config_version";
327 cmap_my_config_version = 0;
339static int cmap_exec_exit_fn(
void)
349static char *cmap_exec_init_fn (
358 cmap_config_version_track_cb,
360 &cmap_config_version_track);
363 return ((
char *)
"Can't add config_version icmap tracker");
369static int cmap_lib_init_fn (
void *conn)
385static int cmap_lib_exit_fn (
void *conn)
396 while (hdb_iterator_next(&
conn_info->iter_db,
406 hdb_iterator_reset(&
conn_info->track_db);
407 while (hdb_iterator_next(&
conn_info->track_db,
408 (
void*)&
track, &track_handle) == 0) {
423static void cmap_sync_init (
426 const unsigned int *member_list,
427 size_t member_list_entries,
432 cmap_sync_member_list_entries = member_list_entries;
435 cmap_my_config_version = 0;
438 cmap_highest_config_version_received = cmap_my_config_version;
441static int cmap_sync_process (
void)
443 const char *key =
"totem.config_version";
451static void cmap_sync_activate (
void)
454 if (cmap_sync_trans_list_entries == 0) {
460 if (cmap_first_sync == 1) {
468 if (cmap_my_config_version == 0) {
474 if (cmap_highest_config_version_received != cmap_my_config_version) {
476 "Received config version (%"PRIu64") is different than my config version (%"PRIu64")! Exiting",
477 cmap_highest_config_version_received, cmap_my_config_version);
483static void cmap_sync_abort (
void)
489static void message_handler_req_lib_cmap_set(
void *conn,
const void *
message)
511static void message_handler_req_lib_cmap_delete(
void *conn,
const void *
message)
532static void message_handler_req_lib_cmap_get(
void *conn,
const void *
message)
591static void message_handler_req_lib_cmap_adjust_int(
void *conn,
const void *
message)
614static void message_handler_req_lib_cmap_iter_init(
void *conn,
const void *
message)
661static void message_handler_req_lib_cmap_iter_next(
void *conn,
const void *
message)
667 size_t value_len = 0;
704static void message_handler_req_lib_cmap_iter_finalize(
void *conn,
const void *
message)
733static void cmap_notify_fn(
int32_t event,
734 const char *key_name,
771static void message_handler_req_lib_cmap_track_add(
void *conn,
const void *
message)
780 const char *key_name;
840static void message_handler_req_lib_cmap_track_delete(
void *conn,
const void *
message)
876static void message_handler_req_lib_cmap_set_current_map(
void *
conn,
const void *
message)
890 while (hdb_iterator_next(&
conn_info->iter_db,
895 hdb_iterator_reset(&
conn_info->track_db);
896 while (hdb_iterator_next(&
conn_info->track_db,
897 (
void*)&
track, &track_handle) == 0) {
964 item->value_type = value_type;
965 item->value_len = value_len;
1035static void message_handler_req_exec_cmap_mcast_reason_sync_nv(
1047 item = cmap_mcast_item_find(
message, (
char *)
"totem.config_version");
1049 value_len =
item->value_len;
1068 "runtime.members.%u.config_version",
nodeid);
1074static void message_handler_req_exec_cmap_mcast(
1100static void exec_cmap_mcast_endian_convert(
void *
message)
1119 swab_mar_uint16_t(&
item->key_name.length);
1120 swab_mar_size_t(&
item->value_len);
1122 switch (
item->value_type) {
@ CS_LIB_FLOW_CONTROL_NOT_REQUIRED
cs_error_t
The cs_error_t enum.
uint64_t cmap_iter_handle_t
struct cmap_map stats_map
#define ICMAP_VALUETYPE_NOT_EXIST
#define MAX_REQ_EXEC_CMAP_MCAST_ITEMS
struct corosync_service_engine * cmap_get_service_engine_ver0(void)
@ MESSAGE_REQ_EXEC_CMAP_MCAST
uint64_t cmap_track_handle_t
struct cmap_map icmap_map
@ CMAP_MCAST_REASON_NEW_CONFIG_VERSION
struct corosync_service_engine cmap_service_engine
uint64_t cmap_iter_handle_t
uint64_t cmap_track_handle_t
#define hdb_handle_database
#define ICMAP_TRACK_MODIFY
cs_error_t icmap_set(const char *key_name, const void *value, size_t value_len, icmap_value_types_t type)
Store value with value_len length and type as key_name name in global icmap.
cs_error_t icmap_adjust_int(const char *key_name, int32_t step)
icmap_adjust_int
cs_error_t icmap_delete(const char *key_name)
Delete key from map.
icmap_value_types_t
Possible types of value.
#define ICMAP_TRACK_DELETE
cs_error_t icmap_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
Add tracking function for given key_name.
icmap_iter_t icmap_iter_init(const char *prefix)
Initialize iterator with given prefix.
void(* icmap_notify_fn_t)(int32_t event, const char *key_name, struct icmap_notify_value new_value, struct icmap_notify_value old_value, void *user_data)
Prototype for notify callback function.
const char * icmap_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
Return next item in iterator iter.
cs_error_t icmap_get(const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
Retrieve value of key key_name and store it in user preallocated value pointer.
qb_map_iter_t * icmap_iter_t
Itterator type.
void icmap_iter_finalize(icmap_iter_t iter)
Finalize iterator.
cs_error_t icmap_track_delete(icmap_track_t icmap_track)
Remove previously added track.
cs_error_t icmap_set_uint64(const char *key_name, uint64_t value)
#define ICMAP_KEYNAME_MAXLEN
Maximum length of key in icmap.
void * icmap_track_get_user_data(icmap_track_t icmap_track)
Return user data associated with given track.
cs_error_t icmap_get_uint64(const char *key_name, uint64_t *u64)
int icmap_is_key_ro(const char *key_name)
Check in given key is read only.
@ MESSAGE_RES_CMAP_ITER_FINALIZE
@ MESSAGE_RES_CMAP_SET_CURRENT_MAP
@ MESSAGE_RES_CMAP_ITER_INIT
@ MESSAGE_RES_CMAP_ITER_NEXT
@ MESSAGE_RES_CMAP_DELETE
@ MESSAGE_RES_CMAP_NOTIFY_CALLBACK
@ MESSAGE_RES_CMAP_TRACK_ADD
@ MESSAGE_RES_CMAP_TRACK_DELETE
@ MESSAGE_RES_CMAP_ADJUST_INT
cs_error_t hdb_error_to_cs(int res)
#define LOGSYS_LEVEL_ERROR
#define log_printf(level, format, args...)
#define LOGSYS_DECLARE_SUBSYS(subsys)
The LOGSYS_DECLARE_SUBSYS macro.
#define LOGSYS_LEVEL_DEBUG
#define MAR_ALIGN_UP(addr, size)
mar_uint64_t mar_size_t
mar_size_t
const char * stats_map_iter_next(icmap_iter_t iter, size_t *value_len, icmap_value_types_t *type)
void * stats_map_track_get_user_data(icmap_track_t icmap_track)
cs_error_t stats_map_delete(const char *key_name)
cs_error_t stats_map_track_delete(icmap_track_t icmap_track)
icmap_iter_t stats_map_iter_init(const char *prefix)
int stats_map_is_key_ro(const char *key_name)
cs_error_t stats_map_set(const char *key_name, const void *value, size_t value_len, icmap_value_types_t type)
void stats_map_iter_finalize(icmap_iter_t iter)
cs_error_t stats_map_get(const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
cs_error_t stats_map_adjust_int(const char *key_name, int32_t step)
cs_error_t stats_map_track_add(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
struct hdb_handle_database iter_db
struct hdb_handle_database track_db
cs_error_t(* map_track_add)(const char *key_name, int32_t track_type, icmap_notify_fn_t notify_fn, void *user_data, icmap_track_t *icmap_track)
cs_error_t(* map_track_delete)(icmap_track_t icmap_track)
void(* map_iter_finalize)(icmap_iter_t iter)
cs_error_t(* map_get)(const char *key_name, void *value, size_t *value_len, icmap_value_types_t *type)
int(* map_is_key_ro)(const char *key_name)
cs_error_t(* map_delete)(const char *key_name)
cs_error_t(* map_set)(const char *key_name, const void *value, size_t value_len, icmap_value_types_t type)
cs_error_t(* map_adjust_int)(const char *key_name, int32_t step)
icmap_iter_t(* map_iter_init)(const char *prefix)
cmap_track_handle_t track_handle
uint64_t track_inst_handle
The corosync_api_v1 struct.
int(* totem_mcast)(const struct iovec *iovec, unsigned int iov_len, unsigned int guarantee)
void *(* ipc_private_data_get)(void *conn)
unsigned int(* totem_nodeid_get)(void)
void(* ipc_refcnt_dec)(void *conn)
void(* shutdown_request)(void)
void(* ipc_refcnt_inc)(void *conn)
int(* ipc_response_send)(void *conn, const void *msg, size_t mlen)
int(* ipc_dispatch_iov_send)(void *conn, const struct iovec *iov, unsigned int iov_len)
The corosync_exec_handler struct.
void(* exec_handler_fn)(const void *msg, unsigned int nodeid)
The corosync_lib_handler struct.
void(* lib_handler_fn)(void *conn, const void *msg)
The corosync_service_engine struct.
Structure passed as new_value and old_value in change callback.
mar_size_t value_len __attribute__((aligned(8)))
mar_name_t key_name __attribute__((aligned(8)))
mar_uint8_t value_type __attribute__((aligned(8)))
uint8_t value[] __attribute__((aligned(8)))
mar_uint8_t reason __attribute__((aligned(8)))
mar_uint8_t no_items __attribute__((aligned(8)))
mar_uint8_t reserver2 __attribute__((aligned(8)))
mar_uint8_t reserved1 __attribute__((aligned(8)))
The req_lib_cmap_adjust_int struct.
The req_lib_cmap_get struct.
The req_lib_cmap_iter_finalize struct.
The req_lib_cmap_iter_init struct.
The req_lib_cmap_iter_next struct.
The req_lib_cmap_set_current_map struct used by cmap_initialize_map()
The req_lib_cmap_set struct.
The req_lib_cmap_track_add struct.
The req_lib_cmap_track_delete struct.
The res_lib_cmap_adjust_int struct.
The res_lib_cmap_delete struct.
The res_lib_cmap_get struct.
The res_lib_cmap_iter_finalize struct.
The res_lib_cmap_iter_init struct.
The res_lib_cmap_iter_next struct.
The res_lib_cmap_notify_callback struct.
The res_lib_cmap_set struct.
The res_lib_cmap_track_add struct.
The res_lib_cmap_track_delete struct.
#define swab64(x)
The swab64 macro.
#define swab16(x)
The swab16 macro.
#define swab32(x)
The swab32 macro.
struct memb_ring_id ring_id
struct totem_message_header header