diff -r 6f7a28bd7e3b crmd/control.c --- a/crmd/control.c Tue Jul 06 11:27:00 2010 +0900 +++ b/crmd/control.c Tue Jul 06 17:15:42 2010 +0900 @@ -50,6 +50,7 @@ GHashTable *ipc_clients = NULL; crm_trigger_t *fsa_source = NULL; crm_trigger_t *config_read = NULL; +int our_expected_votes = 2; /* A_HA_CONNECT */ #if SUPPORT_AIS @@ -86,7 +87,7 @@ int rc = update_attr( fsa_cib_conn, cib_quorum_override|cib_scope_local|cib_inhibit_notify, XML_CIB_TAG_CRMCONFIG, NULL, NULL, NULL, XML_ATTR_EXPECTED_VOTES, votes, FALSE); - + our_expected_votes = crm_int_helper(votes, NULL); crm_info("Setting expected votes to %s", votes); if(cib_ok > rc) { crm_err("Quorum update failed: %s", cib_error2string(rc)); diff -r 6f7a28bd7e3b crmd/crmd_fsa.h --- a/crmd/crmd_fsa.h Tue Jul 06 11:27:00 2010 +0900 +++ b/crmd/crmd_fsa.h Tue Jul 06 17:15:42 2010 +0900 @@ -110,6 +110,8 @@ extern crm_trigger_t *fsa_source; extern crm_trigger_t *config_read; +extern int our_expected_votes; + extern struct crm_subsystem_s *cib_subsystem; extern struct crm_subsystem_s *te_subsystem; extern struct crm_subsystem_s *pe_subsystem; diff -r 6f7a28bd7e3b crmd/te_actions.c --- a/crmd/te_actions.c Tue Jul 06 11:27:00 2010 +0900 +++ b/crmd/te_actions.c Tue Jul 06 17:15:42 2010 +0900 @@ -136,8 +136,8 @@ return FALSE); te_log_action(LOG_INFO, - "Executing %s fencing operation (%s) on %s (timeout=%d)", - type, id, target, transition_graph->stonith_timeout); + "Executing %s fencing operation (%s) on %s (timeout=%d expected_votes=%d)", + type, id, target, transition_graph->stonith_timeout, our_expected_votes); /* Passing NULL means block until we can connect... */ te_connect_stonith(NULL); @@ -150,6 +150,7 @@ } st_op->timeout = transition_graph->stonith_timeout; + st_op->expected_votes = our_expected_votes; st_op->node_name = crm_strdup(target); st_op->node_uuid = crm_strdup(uuid); diff -r 6f7a28bd7e3b fencing/stonithd/stonithd.c --- a/fencing/stonithd/stonithd.c Tue Jul 06 11:27:00 2010 +0900 +++ b/fencing/stonithd/stonithd.c Tue Jul 06 17:15:42 2010 +0900 @@ -1015,6 +1015,17 @@ } stonithd_log(LOG_DEBUG, "failed to STONITH node %s " "locally", op->op_union.st_op->node_name); + + if (op->op_union.st_op->expected_votes < ST_BROADCAST_MIN) { + stonithd_log(LOG_INFO, "failed to STONITH node %s with " + "local device %s (exitcode %d), not necessary to ask other nodes." + "(expected_votes=%d)" + ,op->op_union.st_op->node_name, op->rsc_id, exitcode, op->op_union.st_op->expected_votes); + op->op_union.st_op->op_result = STONITH_GENERIC; + send_stonithop_final_result(op); + g_hash_table_remove(executing_queue, &pid); + return; + } /* The next statement is just for debugging */ if (op->scenario == STONITH_INIT) { stonithd_log(LOG_DEBUG, "Will ask other nodes " @@ -2262,12 +2273,16 @@ (call_id=initiate_local_stonithop(st_op, srsc, client->cbch)) > 0 ) { api_reply = ST_APIOK; } else { - /* including query operation */ - /* call_id < 0 is the correct value when require others to do */ - if ((call_id = initiate_remote_stonithop(st_op,client->cbch)) < 0 ) { - api_reply = ST_APIOK; - } else { + if ( srsc != NULL && st_op->expected_votes < ST_BROADCAST_MIN ) { api_reply = ST_APIFAIL; + } else { + /* including query operation */ + /* call_id < 0 is the correct value when require others to do */ + if ((call_id = initiate_remote_stonithop(st_op,client->cbch)) < 0 ) { + api_reply = ST_APIOK; + } else { + api_reply = ST_APIFAIL; + } } } @@ -2588,6 +2603,7 @@ ||(ha_msg_add_int(reply, F_STONITHD_TIMEOUT, st_op->timeout)!=HA_OK) ||(ha_msg_add_int(reply, F_STONITHD_CALLID, st_op->call_id) !=HA_OK) ||(ha_msg_add(reply, F_STONITHD_NODE_UUID, st_op->node_uuid) != HA_OK) + ||(ha_msg_add_int(reply, F_STONITHD_EXPECTED_VOTES, st_op->expected_votes)!=HA_OK) ||(ha_msg_add_int(reply, F_STONITHD_FRC, st_op->op_result) != HA_OK) ||(st_op->private_data && ha_msg_add(reply, F_STONITHD_PDATA, st_op->private_data) != HA_OK) @@ -2739,6 +2755,7 @@ stonithd_log2(LOG_DEBUG, "require_others_to_stonith: begin."); if ((ha_msg_add(msg, F_STONITHD_NODE, st_op->node_name) != HA_OK) ||(ha_msg_add_int(msg, F_STONITHD_OPTYPE, st_op->optype) != HA_OK) + ||(ha_msg_add_int(msg, F_STONITHD_EXPECTED_VOTES, st_op->expected_votes) != HA_OK) ||(ha_msg_add_int(msg, F_STONITHD_TIMEOUT, st_op->timeout) != HA_OK) ||(ha_msg_add_int(msg, F_STONITHD_CALLID, st_op->call_id) != HA_OK)) { stonithd_log(LOG_ERR, "require_others_to_stonith: " @@ -3788,6 +3805,7 @@ ret->optype = st_op->optype; ret->node_name = g_strdup(st_op->node_name); ret->node_uuid = g_strdup(st_op->node_uuid); + ret->expected_votes = st_op->expected_votes; ret->timeout = st_op->timeout; ret->call_id = st_op->call_id; ret->rs_callid = st_op->rs_callid; @@ -3810,6 +3828,7 @@ st_op = g_new0(stonith_ops_t, 1); st_save_string(msg, F_STONITHD_NODE, st_op->node_name); st_get_int_value(msg, F_STONITHD_OPTYPE, (int *)&st_op->optype); + st_get_int_value(msg, F_STONITHD_EXPECTED_VOTES, &st_op->expected_votes); st_get_int_value(msg, F_STONITHD_TIMEOUT, &st_op->timeout); if( rc != ST_OK ) { free_stonith_ops_t(st_op); diff -r 6f7a28bd7e3b include/fencing/stonithd_api.h --- a/include/fencing/stonithd_api.h Tue Jul 06 11:27:00 2010 +0900 +++ b/include/fencing/stonithd_api.h Tue Jul 06 17:15:42 2010 +0900 @@ -27,6 +27,7 @@ #define ST_OK 0 #define ST_FAIL -1 +#define ST_BROADCAST_MIN 3 typedef enum stonith_type { @@ -56,6 +57,7 @@ /* Temporarily only use node_name until having a good idea about it */ char * node_name; char * node_uuid; + int expected_votes; int timeout; /* its unit is millisecond */ ProcTrackKillInfo killseq[3]; diff -r 6f7a28bd7e3b include/fencing/stonithd_msg.h --- a/include/fencing/stonithd_msg.h Tue Jul 06 11:27:00 2010 +0900 +++ b/include/fencing/stonithd_msg.h Tue Jul 06 17:15:42 2010 +0900 @@ -40,6 +40,7 @@ to stonith */ #define F_STONITHD_NODE_UUID "node_uuid"/* the uuid of the node which is rquired to be stonith'd */ +#define F_STONITHD_EXPECTED_VOTES "expected_votes" /* The number of the expected_votes when execute stonith */ #define F_STONITHD_TIMEOUT "timeout" /* the timeout of a stonith operation */ #define F_STONITHD_RSCID "rscid" /* stonith resource id */ #define F_STONITHD_RANAME "raname" /* stonith RA name */ diff -r 6f7a28bd7e3b lib/fencing/stonithd_lib.c --- a/lib/fencing/stonithd_lib.c Tue Jul 06 11:27:00 2010 +0900 +++ b/lib/fencing/stonithd_lib.c Tue Jul 06 17:15:42 2010 +0900 @@ -537,6 +537,11 @@ "cannot add node_uuid field to ha_msg."); goto out; } + if (ha_msg_add_int(request, F_STONITHD_EXPECTED_VOTES, op->expected_votes) != HA_OK) { + stdlib_log(LOG_ERR, "stonithd_node_fence: " + "cannot add expected_votes field to ha_msg."); + goto out; + } if (ha_msg_add_int(request, F_STONITHD_TIMEOUT, op->timeout) != HA_OK) { stdlib_log(LOG_ERR, "stonithd_node_fence: " "cannot add timeout field to ha_msg.");