Просмотр исходного кода

Add support for selecting IPC type

Signed-off-by: Jan Friesse <jfriesse@redhat.com>
Reviewed-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Jan Friesse 13 лет назад
Родитель
Сommit
3cd4f9a1f5
4 измененных файлов с 75 добавлено и 3 удалено
  1. 20 2
      exec/coroparse.c
  2. 38 1
      exec/ipc_glue.c
  3. 1 0
      exec/main.c
  4. 16 0
      man/corosync.conf.5

+ 20 - 2
exec/coroparse.c

@@ -90,7 +90,8 @@ enum main_cp_cb_data_state {
 	MAIN_CP_CB_DATA_STATE_QDEVICE,
 	MAIN_CP_CB_DATA_STATE_NODELIST,
 	MAIN_CP_CB_DATA_STATE_NODELIST_NODE,
-	MAIN_CP_CB_DATA_STATE_PLOAD
+	MAIN_CP_CB_DATA_STATE_PLOAD,
+	MAIN_CP_CB_DATA_STATE_QB
 };
 
 struct key_value_list_item {
@@ -536,6 +537,18 @@ static int main_config_parser_cb(const char *path,
 			}
 			break;
 
+		case MAIN_CP_CB_DATA_STATE_QB:
+			if (strcmp(path, "qb.ipc_type") == 0) {
+				if ((strcmp(value, "native") != 0) &&
+				    (strcmp(value, "shm") != 0) &&
+				    (strcmp(value, "socket") != 0)) {
+					*error_string = "Invalid qb ipc_type";
+
+					return (0);
+				}
+			}
+			break;
+
 		case MAIN_CP_CB_DATA_STATE_INTERFACE:
 			if (strcmp(path, "totem.interface.ringnumber") == 0) {
 				if (safe_atoi(value, &i) != 0) {
@@ -742,7 +755,9 @@ static int main_config_parser_cb(const char *path,
 		if (strcmp(path, "totem") == 0) {
 			data->state = MAIN_CP_CB_DATA_STATE_TOTEM;
 		};
-
+		if (strcmp(path, "qb") == 0) {
+			data->state = MAIN_CP_CB_DATA_STATE_QB;
+		}
 		if (strcmp(path, "logging.logger_subsys") == 0) {
 			data->state = MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS;
 			list_init(&data->logger_subsys_items_head);
@@ -847,6 +862,9 @@ static int main_config_parser_cb(const char *path,
 		case MAIN_CP_CB_DATA_STATE_TOTEM:
 			data->state = MAIN_CP_CB_DATA_STATE_NORMAL;
 			break;
+		case MAIN_CP_CB_DATA_STATE_QB:
+			data->state = MAIN_CP_CB_DATA_STATE_NORMAL;
+			break;
 		case MAIN_CP_CB_DATA_STATE_LOGGER_SUBSYS:
 			if (data->subsys == NULL) {
 				*error_string = "No subsys key in logger_subsys directive";

+ 38 - 1
exec/ipc_glue.c

@@ -801,6 +801,43 @@ void cs_ipcs_stats_update(void)
 	}
 }
 
+static enum qb_ipc_type cs_get_ipc_type (void)
+{
+	char *str;
+	int found = 0;
+	enum qb_ipc_type ret = QB_IPC_NATIVE;
+
+	if (icmap_get_string("qb.ipc_type", &str) != CS_OK) {
+		log_printf(LOGSYS_LEVEL_DEBUG, "No configured qb.ipc_type. Using native ipc");
+		return QB_IPC_NATIVE;
+	}
+
+	if (strcmp(str, "native") == 0) {
+		ret = QB_IPC_NATIVE;
+		found = 1;
+	}
+
+	if (strcmp(str, "shm") == 0) {
+		ret = QB_IPC_SHM;
+		found = 1;
+	}
+
+	if (strcmp(str, "socket") == 0) {
+		ret = QB_IPC_SOCKET;
+		found = 1;
+	}
+
+	if (found) {
+		log_printf(LOGSYS_LEVEL_DEBUG, "Using %s ipc", str);
+	} else {
+		log_printf(LOGSYS_LEVEL_DEBUG, "Unknown ipc type %s", str);
+	}
+
+	free(str);
+
+	return ret;
+}
+
 const char *cs_ipcs_service_init(struct corosync_service_engine *service)
 {
 	if (service->lib_engine_count == 0) {
@@ -818,7 +855,7 @@ const char *cs_ipcs_service_init(struct corosync_service_engine *service)
 		ipcs_mapper[service->id].id);
 	ipcs_mapper[service->id].inst = qb_ipcs_create(ipcs_mapper[service->id].name,
 		ipcs_mapper[service->id].id,
-		QB_IPC_NATIVE,
+		cs_get_ipc_type(),
 		&corosync_service_funcs);
 	assert(ipcs_mapper[service->id].inst);
 	qb_ipcs_poll_handlers_set(ipcs_mapper[service->id].inst,

+ 1 - 0
exec/main.c

@@ -910,6 +910,7 @@ static void set_icmap_ro_keys_flag (void)
 	icmap_set_ro_access("totem.secauth", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.rrp_mode", CS_FALSE, CS_TRUE);
 	icmap_set_ro_access("totem.netmtu", CS_FALSE, CS_TRUE);
+	icmap_set_ro_access("qb.ipc_type", CS_FALSE, CS_TRUE);
 }
 
 static void main_service_ready (void)

+ 16 - 0
man/corosync.conf.5

@@ -57,6 +57,9 @@ This top level directive contains configuration options for quorum.
 .TP
 nodelist { }
 This top level directive contains configuration options for nodes in cluster.
+.TP
+qb { }
+This top level directive contains configuration options related to libqb.
 
 .PP
 .PP
@@ -649,6 +652,19 @@ will be determined from the 32 bit IP address the system to which the system
 is bound with ring identifier of 0.  The node identifier value of zero is
 reserved and should not be used.
 
+.PP
+Within the
+.B qb
+directive it is possible to specify options for libqb.
+
+Possible option is:
+.TP
+ipc_type
+This specifies type of IPC to use. Can be one of native (default), shm and socket.
+Native means one of shm or socket, depending on what is supported by OS. On systems
+with support for both, SHM is selected. SHM is generally faster, but need to allocate
+ring buffer file in /dev/shm.
+
 .SH "FILES"
 .TP
 /etc/corosync/corosync.conf