From 7dacbcd0ec79a3a2198aebc43040d2693375adcf Mon Sep 17 00:00:00 2001 From: Vinit Agnihotri Date: Tue, 27 Feb 2024 00:13:57 -0800 Subject: [PATCH] ctdb: send a CTDB_SRVID_START_IPREALLOCATE message after CTDB_EVENT_START_IPREALLOCATE Event scripts run the "start_ipreallocate" hook in order to notice that some ip addresses in the cluster potentially changed. CTDB_SRVID_START_IPREALLOCATE gives C code a chance to get notified as well once the event scripts are finished. Signed-off-by: Vinit Agnihotri Reviewed-by: Martin Schwenke Reviewed-by: Volker Lendecke --- ctdb/protocol/protocol.h | 3 +++ ctdb/protocol/protocol_debug.c | 2 ++ ctdb/protocol/protocol_message.c | 9 +++++++++ ctdb/server/ctdb_takeover.c | 7 +++++++ 4 files changed, 21 insertions(+) diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index f39eb4acafe..99440b39125 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -143,6 +143,9 @@ struct ctdb_call { /* SRVID to inform clients that CTDB_EVENT_IPREALLOCATED finished */ #define CTDB_SRVID_IPREALLOCATED 0xF302000000000000LL +/* SRVID to inform clients that CTDB_EVENT_START_IPREALLOCATE finished */ +#define CTDB_SRVID_START_IPREALLOCATE 0xF303000000000000LL + /* SRVID to inform recovery daemon of the node flags - OBSOLETE */ #define CTDB_SRVID_SET_NODE_FLAGS 0xF400000000000000LL diff --git a/ctdb/protocol/protocol_debug.c b/ctdb/protocol/protocol_debug.c index 3a4b09f6bb4..cfa8b47672d 100644 --- a/ctdb/protocol/protocol_debug.c +++ b/ctdb/protocol/protocol_debug.c @@ -304,6 +304,8 @@ static void ctdb_srvid_print(uint64_t srvid, FILE *fp) fprintf(fp, "TAKE_IP"); } else if (srvid == CTDB_SRVID_IPREALLOCATED) { fprintf(fp, "IPREALLOCATED"); + } else if (srvid == CTDB_SRVID_START_IPREALLOCATE) { + fprintf(fp, "START_IPREALLOCATE"); } else if (srvid == CTDB_SRVID_SET_NODE_FLAGS) { fprintf(fp, "SET_NODE_FLAGS"); } else if (srvid == CTDB_SRVID_RECD_UPDATE_IP) { diff --git a/ctdb/protocol/protocol_message.c b/ctdb/protocol/protocol_message.c index 8d323227914..627d4f8317d 100644 --- a/ctdb/protocol/protocol_message.c +++ b/ctdb/protocol/protocol_message.c @@ -60,6 +60,9 @@ static size_t ctdb_message_data_len(union ctdb_message_data *mdata, case CTDB_SRVID_IPREALLOCATED: break; + case CTDB_SRVID_START_IPREALLOCATE: + break; + case CTDB_SRVID_SET_NODE_FLAGS: len = ctdb_node_flag_change_len(mdata->flag_change); break; @@ -154,6 +157,9 @@ static void ctdb_message_data_push(union ctdb_message_data *mdata, case CTDB_SRVID_IPREALLOCATED: break; + case CTDB_SRVID_START_IPREALLOCATE: + break; + case CTDB_SRVID_SET_NODE_FLAGS: ctdb_node_flag_change_push(mdata->flag_change, buf, &np); break; @@ -253,6 +259,9 @@ static int ctdb_message_data_pull(uint8_t *buf, size_t buflen, case CTDB_SRVID_IPREALLOCATED: break; + case CTDB_SRVID_START_IPREALLOCATE: + break; + case CTDB_SRVID_SET_NODE_FLAGS: ret = ctdb_node_flag_change_pull(buf, buflen, mem_ctx, &mdata->flag_change, &np); diff --git a/ctdb/server/ctdb_takeover.c b/ctdb/server/ctdb_takeover.c index 70d9b85b746..79445ec4899 100644 --- a/ctdb/server/ctdb_takeover.c +++ b/ctdb/server/ctdb_takeover.c @@ -2458,6 +2458,7 @@ static void ctdb_start_ipreallocate_callback(struct ctdb_context *ctdb, { struct start_ipreallocate_callback_state *state = talloc_get_type_abort( p, struct start_ipreallocate_callback_state); + TDB_DATA data = { .dsize = 0, }; if (status != 0) { D_ERR("\"startipreallocate\" event failed (status %d)\n", @@ -2467,6 +2468,12 @@ static void ctdb_start_ipreallocate_callback(struct ctdb_context *ctdb, } } + D_INFO("Sending START_IPREALLOCATE message\n"); + ctdb_daemon_send_message(ctdb, + ctdb->pnn, + CTDB_SRVID_START_IPREALLOCATE, + data); + ctdb_request_control_reply(ctdb, state->c, NULL, status, NULL); talloc_free(state); }