1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-08 21:18:16 +03:00

ctdbd: New control CTDB_CONTROL_IPREALLOCATED

This is an alternative to using ctdb_run_eventscripts() that can be
used when in recovery.

Signed-off-by: Martin Schwenke <martin@meltin.net>

(This used to be ctdb commit 27a44685f0d7a88804b61a1542bb42adc8f88cb1)
This commit is contained in:
Martin Schwenke 2013-04-19 13:05:02 +10:00 committed by Amitay Isaacs
parent f6e48639cd
commit 2e59cd5428
5 changed files with 65 additions and 0 deletions

View File

@ -1102,6 +1102,9 @@ int32_t ctdb_control_release_ipv4(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
TDB_DATA indata,
bool *async_reply);
int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
bool *async_reply);
int32_t ctdb_control_start_recovery(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
bool *async_reply);

View File

@ -404,6 +404,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
CTDB_CONTROL_RELOAD_PUBLIC_IPS = 134,
CTDB_CONTROL_TRAVERSE_ALL_EXT = 135,
CTDB_CONTROL_RECEIVE_RECORDS = 136,
CTDB_CONTROL_IPREALLOCATED = 137,
};
/*

View File

@ -351,6 +351,10 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_public_ip));
return ctdb_control_release_ip(ctdb, c, indata, async_reply);
case CTDB_CONTROL_IPREALLOCATED:
CHECK_CONTROL_DATA_SIZE(0);
return ctdb_control_ipreallocated(ctdb, c, async_reply);
case CTDB_CONTROL_GET_PUBLIC_IPSv4:
CHECK_CONTROL_DATA_SIZE(0);
return ctdb_control_get_public_ipsv4(ctdb, c, outdata);

View File

@ -3810,6 +3810,62 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA inda
return -1;
}
struct ipreallocated_callback_state {
struct ctdb_req_control *c;
};
static void ctdb_ipreallocated_callback(struct ctdb_context *ctdb,
int status, void *p)
{
struct ipreallocated_callback_state *state =
talloc_get_type(p, struct ipreallocated_callback_state);
if (status != 0) {
DEBUG(DEBUG_ERR,
(" \"ipreallocated\" event script failed (status %d)\n",
status));
if (status == -ETIME) {
ctdb_ban_self(ctdb);
}
}
ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL);
talloc_free(state);
}
/* A control to run the ipreallocated event */
int32_t ctdb_control_ipreallocated(struct ctdb_context *ctdb,
struct ctdb_req_control *c,
bool *async_reply)
{
int ret;
struct ipreallocated_callback_state *state;
state = talloc(ctdb, struct ipreallocated_callback_state);
CTDB_NO_MEMORY(ctdb, state);
DEBUG(DEBUG_INFO,(__location__ " Running \"ipreallocated\" event\n"));
ret = ctdb_event_script_callback(ctdb, state,
ctdb_ipreallocated_callback, state,
false, CTDB_EVENT_IPREALLOCATED,
"%s", "");
if (ret != 0) {
DEBUG(DEBUG_ERR,("Failed to run \"ipreallocated\" event \n"));
talloc_free(state);
return -1;
}
/* tell the control that we will be reply asynchronously */
state->c = talloc_steal(state, c);
*async_reply = true;
return 0;
}
/* This function is called from the recovery daemon to verify that a remote
node has the expected ip allocation.
This is verified against ctdb->ip_tree

View File

@ -716,6 +716,7 @@ static int ctdb_event_script_callback_v(struct ctdb_context *ctdb,
CTDB_EVENT_START_RECOVERY,
CTDB_EVENT_SHUTDOWN,
CTDB_EVENT_RELEASE_IP,
CTDB_EVENT_IPREALLOCATED,
CTDB_EVENT_STOPPED
};
int i;