1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

ctdb-protocol: Add controls for parallel DB recovery

Signed-off-by: Amitay Isaacs <amitay@gmail.com>
Reviewed-by: Martin Schwenke <martin@meltin.net>
This commit is contained in:
Amitay Isaacs 2015-08-01 01:47:22 +10:00 committed by Amitay Isaacs
parent c6a50b97d4
commit 81ac247c10
6 changed files with 249 additions and 2 deletions

View File

@ -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

View File

@ -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,

View File

@ -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);
}

View File

@ -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;

View File

@ -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

View File

@ -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)
{