diff --git a/ctdb/protocol/protocol.h b/ctdb/protocol/protocol.h index 805fdd161b2..f7405872aa9 100644 --- a/ctdb/protocol/protocol.h +++ b/ctdb/protocol/protocol.h @@ -348,6 +348,11 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0, CTDB_CONTROL_GET_RUNSTATE = 138, CTDB_CONTROL_DB_DETACH = 139, CTDB_CONTROL_GET_NODES_FILE = 140, + CTDB_CONTROL_DB_FREEZE = 141, + CTDB_CONTROL_DB_THAW = 142, + CTDB_CONTROL_DB_TRANSACTION_START = 143, + CTDB_CONTROL_DB_TRANSACTION_COMMIT = 144, + CTDB_CONTROL_DB_TRANSACTION_CANCEL = 145, }; #define CTDB_MONITORING_ACTIVE 0 diff --git a/ctdb/protocol/protocol_api.h b/ctdb/protocol/protocol_api.h index 3628c3e73f4..cc00b44574b 100644 --- a/ctdb/protocol/protocol_api.h +++ b/ctdb/protocol/protocol_api.h @@ -610,6 +610,26 @@ int ctdb_reply_control_get_nodes_file(struct ctdb_reply_control *reply, TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap); +void ctdb_req_control_db_freeze(struct ctdb_req_control *request, + uint32_t db_id); +int ctdb_reply_control_db_freeze(struct ctdb_reply_control *reply); + +void ctdb_req_control_db_thaw(struct ctdb_req_control *request, + uint32_t db_id); +int ctdb_reply_control_db_thaw(struct ctdb_reply_control *reply); + +void ctdb_req_control_db_transaction_start(struct ctdb_req_control *request, + struct ctdb_transdb *transdb); +int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control *reply); + +void ctdb_req_control_db_transaction_commit(struct ctdb_req_control *request, + struct ctdb_transdb *transdb); +int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control *reply); + +void ctdb_req_control_db_transaction_cancel(struct ctdb_req_control *request, + uint32_t db_id); +int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control *reply); + /* From protocol/protocol_message.c */ int ctdb_req_message_push(struct ctdb_req_header *h, diff --git a/ctdb/protocol/protocol_client.c b/ctdb/protocol/protocol_client.c index f4bfe193990..3bfcef8e9cf 100644 --- a/ctdb/protocol/protocol_client.c +++ b/ctdb/protocol/protocol_client.c @@ -2368,3 +2368,103 @@ int ctdb_reply_control_get_nodes_file(struct ctdb_reply_control *reply, } return reply->status; } + +/* CTDB_CONTROL_DB_FREEZE */ + +void ctdb_req_control_db_freeze(struct ctdb_req_control *request, + uint32_t db_id) +{ + request->opcode = CTDB_CONTROL_DB_FREEZE; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_DB_FREEZE; + request->rdata.data.db_id = db_id; +} + +int ctdb_reply_control_db_freeze(struct ctdb_reply_control *reply) +{ + return ctdb_reply_control_generic(reply); +} + +/* CTDB_CONTROL_DB_THAW */ + +void ctdb_req_control_db_thaw(struct ctdb_req_control *request, + uint32_t db_id) +{ + request->opcode = CTDB_CONTROL_DB_THAW; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_DB_THAW; + request->rdata.data.db_id = db_id; +} + +int ctdb_reply_control_db_thaw(struct ctdb_reply_control *reply) +{ + return ctdb_reply_control_generic(reply); +} + +/* CTDB_CONTROL_DB_TRANSACTION_START */ + +void ctdb_req_control_db_transaction_start(struct ctdb_req_control *request, + struct ctdb_transdb *transdb) +{ + request->opcode = CTDB_CONTROL_DB_TRANSACTION_START; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_START; + request->rdata.data.transdb = transdb; +} + +int ctdb_reply_control_db_transaction_start(struct ctdb_reply_control *reply) +{ + return ctdb_reply_control_generic(reply); +} + +/* CTDB_CONTROL_DB_TRANSACTION_COMMIT */ + +void ctdb_req_control_db_transaction_commit(struct ctdb_req_control *request, + struct ctdb_transdb *transdb) +{ + request->opcode = CTDB_CONTROL_DB_TRANSACTION_COMMIT; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_COMMIT; + request->rdata.data.transdb = transdb; +} + +int ctdb_reply_control_db_transaction_commit(struct ctdb_reply_control *reply) +{ + return ctdb_reply_control_generic(reply); +} + +/* CTDB_CONTROL_DB_TRANSACTION_CANCEL */ + +void ctdb_req_control_db_transaction_cancel(struct ctdb_req_control *request, + uint32_t db_id) +{ + request->opcode = CTDB_CONTROL_DB_TRANSACTION_CANCEL; + request->pad = 0; + request->srvid = 0; + request->client_id = 0; + request->flags = 0; + + request->rdata.opcode = CTDB_CONTROL_DB_TRANSACTION_CANCEL; + request->rdata.data.db_id = db_id; +} + +int ctdb_reply_control_db_transaction_cancel(struct ctdb_reply_control *reply) +{ + return ctdb_reply_control_generic(reply); +} diff --git a/ctdb/protocol/protocol_control.c b/ctdb/protocol/protocol_control.c index da873510887..486a1f2cea0 100644 --- a/ctdb/protocol/protocol_control.c +++ b/ctdb/protocol/protocol_control.c @@ -461,6 +461,26 @@ static size_t ctdb_req_control_data_len(struct ctdb_req_control_data *cd) case CTDB_CONTROL_GET_NODES_FILE: break; + + case CTDB_CONTROL_DB_FREEZE: + len = ctdb_uint32_len(cd->data.db_id); + break; + + case CTDB_CONTROL_DB_THAW: + len = ctdb_uint32_len(cd->data.db_id); + break; + + case CTDB_CONTROL_DB_TRANSACTION_START: + len = ctdb_transdb_len(cd->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_COMMIT: + len = ctdb_transdb_len(cd->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_CANCEL: + len = ctdb_uint32_len(cd->data.db_id); + break; } return len; @@ -751,6 +771,26 @@ static void ctdb_req_control_data_push(struct ctdb_req_control_data *cd, case CTDB_CONTROL_DB_DETACH: ctdb_uint32_push(cd->data.db_id, buf); break; + + case CTDB_CONTROL_DB_FREEZE: + ctdb_uint32_push(cd->data.db_id, buf); + break; + + case CTDB_CONTROL_DB_THAW: + ctdb_uint32_push(cd->data.db_id, buf); + break; + + case CTDB_CONTROL_DB_TRANSACTION_START: + ctdb_transdb_push(cd->data.transdb, buf); + break; + + case CTDB_CONTROL_DB_TRANSACTION_COMMIT: + ctdb_transdb_push(cd->data.transdb, buf); + break; + + case CTDB_CONTROL_DB_TRANSACTION_CANCEL: + ctdb_uint32_push(cd->data.db_id, buf); + break; } } @@ -1112,6 +1152,31 @@ static int ctdb_req_control_data_pull(uint8_t *buf, size_t buflen, ret = ctdb_uint32_pull(buf, buflen, mem_ctx, &cd->data.db_id); break; + + case CTDB_CONTROL_DB_FREEZE: + ret = ctdb_uint32_pull(buf, buflen, mem_ctx, + &cd->data.db_id); + break; + + case CTDB_CONTROL_DB_THAW: + ret = ctdb_uint32_pull(buf, buflen, mem_ctx, + &cd->data.db_id); + break; + + case CTDB_CONTROL_DB_TRANSACTION_START: + ret = ctdb_transdb_pull(buf, buflen, mem_ctx, + &cd->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_COMMIT: + ret = ctdb_transdb_pull(buf, buflen, mem_ctx, + &cd->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_CANCEL: + ret = ctdb_uint32_pull(buf, buflen, mem_ctx, + &cd->data.db_id); + break; } return ret; @@ -1494,6 +1559,21 @@ static size_t ctdb_reply_control_data_len(struct ctdb_reply_control_data *cd) case CTDB_CONTROL_GET_NODES_FILE: len = ctdb_node_map_len(cd->data.nodemap); break; + + case CTDB_CONTROL_DB_FREEZE: + break; + + case CTDB_CONTROL_DB_THAW: + break; + + case CTDB_CONTROL_DB_TRANSACTION_START: + break; + + case CTDB_CONTROL_DB_TRANSACTION_COMMIT: + break; + + case CTDB_CONTROL_DB_TRANSACTION_CANCEL: + break; } return len; diff --git a/ctdb/tests/cunit/protocol_test_002.sh b/ctdb/tests/cunit/protocol_test_002.sh index 47410be464c..a654f740af7 100755 --- a/ctdb/tests/cunit/protocol_test_002.sh +++ b/ctdb/tests/cunit/protocol_test_002.sh @@ -2,7 +2,7 @@ . "${TEST_SCRIPTS_DIR}/unit.sh" -last_control=140 +last_control=145 control_output=$( for i in $(seq 0 $last_control) ; do diff --git a/ctdb/tests/src/protocol_client_test.c b/ctdb/tests/src/protocol_client_test.c index a17fac05cdc..f5a3c35c664 100644 --- a/ctdb/tests/src/protocol_client_test.c +++ b/ctdb/tests/src/protocol_client_test.c @@ -633,6 +633,29 @@ static void fill_ctdb_req_control_data(TALLOC_CTX *mem_ctx, case CTDB_CONTROL_GET_NODES_FILE: break; + case CTDB_CONTROL_DB_FREEZE: + cd->data.db_id = rand32(); + break; + + case CTDB_CONTROL_DB_THAW: + cd->data.db_id = rand32(); + break; + + case CTDB_CONTROL_DB_TRANSACTION_START: + cd->data.transdb = talloc(mem_ctx, struct ctdb_transdb); + assert(cd->data.transdb != NULL); + fill_ctdb_transdb(mem_ctx, cd->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_COMMIT: + cd->data.transdb = talloc(mem_ctx, struct ctdb_transdb); + assert(cd->data.transdb != NULL); + fill_ctdb_transdb(mem_ctx, cd->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_CANCEL: + cd->data.db_id = rand32(); + break; } } @@ -1061,6 +1084,25 @@ static void verify_ctdb_req_control_data(struct ctdb_req_control_data *cd, case CTDB_CONTROL_GET_NODES_FILE: break; + case CTDB_CONTROL_DB_FREEZE: + assert(cd->data.db_id == cd2->data.db_id); + break; + + case CTDB_CONTROL_DB_THAW: + assert(cd->data.db_id == cd2->data.db_id); + break; + + case CTDB_CONTROL_DB_TRANSACTION_START: + verify_ctdb_transdb(cd->data.transdb, cd2->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_COMMIT: + verify_ctdb_transdb(cd->data.transdb, cd2->data.transdb); + break; + + case CTDB_CONTROL_DB_TRANSACTION_CANCEL: + assert(cd->data.db_id == cd2->data.db_id); + break; } } @@ -2119,7 +2161,7 @@ static void test_reply_dmaster_test(void) talloc_free(mem_ctx); } -#define NUM_CONTROLS 141 +#define NUM_CONTROLS 146 static void test_req_control_data_test(void) {