diff options
author | Martin Schwenke <martin@meltin.net> | 2014-01-22 17:12:09 +1100 |
---|---|---|
committer | Stefan Metzmacher <metze@samba.org> | 2016-07-28 05:00:17 +0200 |
commit | 87b49c913f8e0a334221706976254d852dbb9bfe (patch) | |
tree | 264c6d8c2dde425739c2d38b4c1e5f49dc991943 /ctdb/server | |
parent | 0a759bc3ff3887671981e03e1898acf5da692bc2 (diff) | |
download | samba-87b49c913f8e0a334221706976254d852dbb9bfe.tar.gz |
ctdb-daemon: Deletion of IPs is deferred until the next takeover run
This drastically simplifies the code. "ctdb reloadips" behaves the
same, since it causes a takeover run immediately after IPs are
deleted. "ctdb delip" now needs to be followed with an explicit "ctdb
ipreallocate".
Signed-off-by: Martin Schwenke <martin@meltin.net>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Amitay Isaacs <amitay@gmail.com>
Diffstat (limited to 'ctdb/server')
-rw-r--r-- | ctdb/server/ctdb_control.c | 3 | ||||
-rw-r--r-- | ctdb/server/ctdb_takeover.c | 72 |
2 files changed, 8 insertions, 67 deletions
diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index 5b3e7c2190b..92022cabfc9 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -467,8 +467,7 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, return ctdb_control_add_public_address(ctdb, indata); case CTDB_CONTROL_DEL_PUBLIC_IP: - return ctdb_control_del_public_address(ctdb, c, indata, - async_reply); + return ctdb_control_del_public_address(ctdb, indata); case CTDB_CONTROL_GET_CAPABILITIES: return ctdb_control_get_capabilities(ctdb, outdata); diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 84dcd98ccbf..6d182ded7be 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2718,29 +2718,7 @@ int32_t ctdb_control_add_public_address(struct ctdb_context *ctdb, TDB_DATA inda return 0; } -struct delete_ip_callback_state { - struct ctdb_req_control_old *c; -}; - -/* - called when releaseip event finishes for del_public_address - */ -static void delete_ip_callback(struct ctdb_context *ctdb, - int32_t status, TDB_DATA data, - const char *errormsg, - void *private_data) -{ - struct delete_ip_callback_state *state = - talloc_get_type(private_data, struct delete_ip_callback_state); - - /* If release failed then fail. */ - ctdb_request_control_reply(ctdb, state->c, NULL, status, errormsg); - talloc_free(private_data); -} - -int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, - struct ctdb_req_control_old *c, - TDB_DATA indata, bool *async_reply) +int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, TDB_DATA indata) { struct ctdb_addr_info_old *pub = (struct ctdb_addr_info_old *)indata.dptr; struct ctdb_vnn *vnn; @@ -2767,49 +2745,13 @@ int32_t ctdb_control_del_public_address(struct ctdb_context *ctdb, for (vnn=ctdb->vnn;vnn;vnn=vnn->next) { if (ctdb_same_ip(&vnn->public_address, &pub->addr)) { if (vnn->pnn == ctdb->pnn) { - struct delete_ip_callback_state *state; - struct ctdb_public_ip *ip; - TDB_DATA data; - int ret; - + /* This IP is currently being hosted. + * Defer the deletion until the next + * takeover run. "ctdb reloadips" will + * always cause a takeover run. "ctdb + * delip" will now need an explicit + * "ctdb ipreallocated" afterwards. */ vnn->delete_pending = true; - - state = talloc(ctdb, - struct delete_ip_callback_state); - CTDB_NO_MEMORY(ctdb, state); - state->c = c; - - ip = talloc(state, struct ctdb_public_ip); - if (ip == NULL) { - DEBUG(DEBUG_ERR, - (__location__ " Out of memory\n")); - talloc_free(state); - return -1; - } - ip->pnn = -1; - ip->addr = pub->addr; - - data.dsize = sizeof(struct ctdb_public_ip); - data.dptr = (unsigned char *)ip; - - ret = ctdb_daemon_send_control(ctdb, - ctdb_get_pnn(ctdb), - 0, - CTDB_CONTROL_RELEASE_IP, - 0, 0, - data, - delete_ip_callback, - state); - if (ret == -1) { - DEBUG(DEBUG_ERR, - (__location__ "Unable to send " - "CTDB_CONTROL_RELEASE_IP\n")); - talloc_free(state); - return -1; - } - - state->c = talloc_steal(state, c); - *async_reply = true; } else { /* This IP is not hosted on the * current node so just delete it |