From: Amitay Isaacs Date: Thu, 21 Apr 2016 05:22:47 +0000 (+1000) Subject: ctdb-client: Remove client functions related to server_id X-Git-Tag: talloc-2.1.7~201 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2e2dfae98c1c5b9c755407cd7b021e37bd13dbd8;p=thirdparty%2Fsamba.git ctdb-client: Remove client functions related to server_id These functions were used in the transaction code. These controls did not use server_id structure defined in samba, so samba would not use them. Instead check if the process exists for conflicting g_lock entry. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/client/client.h b/ctdb/client/client.h index 1060d2e175d..e8288dc3f07 100644 --- a/ctdb/client/client.h +++ b/ctdb/client/client.h @@ -397,29 +397,6 @@ int ctdb_ctrl_set_tcp_tickle_list(TALLOC_CTX *mem_ctx, int destnode, struct timeval timeout, struct ctdb_tickle_list *tickles); -int ctdb_ctrl_register_server_id(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id *cid); - -int ctdb_ctrl_unregister_server_id(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id *cid); - -int ctdb_ctrl_check_server_id(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id *cid); - -int ctdb_ctrl_get_server_id_list(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id_map **cid_map); - int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct ctdb_client_context *client, diff --git a/ctdb/client/client_control_sync.c b/ctdb/client/client_control_sync.c index 2c71b36458f..e14b02c6b2c 100644 --- a/ctdb/client/client_control_sync.c +++ b/ctdb/client/client_control_sync.c @@ -1145,125 +1145,6 @@ int ctdb_ctrl_set_tcp_tickle_list(TALLOC_CTX *mem_ctx, return 0; } -int ctdb_ctrl_register_server_id(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id *cid) -{ - struct ctdb_req_control request; - struct ctdb_reply_control *reply; - int ret; - - ctdb_req_control_register_server_id(&request, cid); - ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout, - &request, &reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control REGISTER_SERVER_ID failed to node %u, ret=%d\n", - destnode, ret)); - return ret; - } - - ret = ctdb_reply_control_register_server_id(reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control REGISTER_SERVER_ID failed, ret=%d\n", ret)); - return ret; - } - - return 0; -} - -int ctdb_ctrl_unregister_server_id(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id *cid) -{ - struct ctdb_req_control request; - struct ctdb_reply_control *reply; - int ret; - - ctdb_req_control_unregister_server_id(&request, cid); - ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout, - &request, &reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control UNREGISTER_SERVER_ID failed to node %u, ret=%d\n", - destnode, ret)); - return ret; - } - - ret = ctdb_reply_control_unregister_server_id(reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control UNREGISTER_SERVER_ID failed, ret=%d\n", ret)); - return ret; - } - - return 0; -} - -int ctdb_ctrl_check_server_id(TALLOC_CTX *mem_ctx, struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id *cid) -{ - struct ctdb_req_control request; - struct ctdb_reply_control *reply; - int ret; - - ctdb_req_control_check_server_id(&request, cid); - ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout, - &request, &reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control CHECK_SERVER_ID failed to node %u, ret=%d\n", - destnode, ret)); - return ret; - } - - ret = ctdb_reply_control_check_server_id(reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control CHECK_SERVER_ID failed, ret=%d\n", ret)); - return ret; - } - - return 0; -} - -int ctdb_ctrl_get_server_id_list(TALLOC_CTX *mem_ctx, - struct tevent_context *ev, - struct ctdb_client_context *client, - int destnode, struct timeval timeout, - struct ctdb_client_id_map **cid_map) -{ - struct ctdb_req_control request; - struct ctdb_reply_control *reply; - int ret; - - ctdb_req_control_get_server_id_list(&request); - ret = ctdb_client_control(mem_ctx, ev, client, destnode, timeout, - &request, &reply); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control GET_SERVER_ID_LIST failed to node %u, ret=%d\n", - destnode, ret)); - return ret; - } - - ret = ctdb_reply_control_get_server_id_list(reply, mem_ctx, cid_map); - if (ret != 0) { - DEBUG(DEBUG_ERR, - ("Control GET_SERVER_ID_LIST failed, ret=%d\n", ret)); - return ret; - } - - return 0; -} - int ctdb_ctrl_db_attach_persistent(TALLOC_CTX *mem_ctx, struct tevent_context *ev, struct ctdb_client_context *client, diff --git a/ctdb/client/ctdb_client.c b/ctdb/client/ctdb_client.c index aae3853ed48..19f126ce871 100644 --- a/ctdb/client/ctdb_client.c +++ b/ctdb/client/ctdb_client.c @@ -3171,117 +3171,6 @@ int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb, return status; } -/* - register a server id - */ -int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb, - struct timeval timeout, - struct ctdb_client_id *id) -{ - TDB_DATA data; - int32_t res; - int ret; - - data.dsize = sizeof(struct ctdb_client_id); - data.dptr = (unsigned char *)id; - - ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, - CTDB_CONTROL_REGISTER_SERVER_ID, - 0, data, NULL, - NULL, &res, &timeout, NULL); - if (ret != 0 || res != 0) { - DEBUG(DEBUG_ERR,(__location__ " ctdb_control for register server id failed\n")); - return -1; - } - - return 0; -} - -/* - unregister a server id - */ -int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb, - struct timeval timeout, - struct ctdb_client_id *id) -{ - TDB_DATA data; - int32_t res; - int ret; - - data.dsize = sizeof(struct ctdb_client_id); - data.dptr = (unsigned char *)id; - - ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, - CTDB_CONTROL_UNREGISTER_SERVER_ID, - 0, data, NULL, - NULL, &res, &timeout, NULL); - if (ret != 0 || res != 0) { - DEBUG(DEBUG_ERR,(__location__ " ctdb_control for unregister server id failed\n")); - return -1; - } - - return 0; -} - - -/* - check if a server id exists - - if a server id does exist, return *status == 1, otherwise *status == 0 - */ -int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - struct ctdb_client_id *id, uint32_t *status) -{ - TDB_DATA data; - int32_t res; - int ret; - - data.dsize = sizeof(struct ctdb_client_id); - data.dptr = (unsigned char *)id; - - ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_CHECK_SERVER_ID, - 0, data, NULL, - NULL, &res, &timeout, NULL); - if (ret != 0) { - DEBUG(DEBUG_ERR,(__location__ " ctdb_control for check server id failed\n")); - return -1; - } - - if (res) { - *status = 1; - } else { - *status = 0; - } - - return 0; -} - -/* - get the list of server ids that are registered on a node -*/ -int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb, - TALLOC_CTX *mem_ctx, - struct timeval timeout, uint32_t destnode, - struct ctdb_client_id_list_old **svid_list) -{ - int ret; - TDB_DATA outdata; - int32_t res; - - ret = ctdb_control(ctdb, destnode, 0, - CTDB_CONTROL_GET_SERVER_ID_LIST, 0, tdb_null, - mem_ctx, &outdata, &res, &timeout, NULL); - if (ret != 0 || res != 0) { - DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get_server_id_list failed\n")); - return -1; - } - - *svid_list = (struct ctdb_client_id_list_old *)talloc_steal(mem_ctx, outdata.dptr); - - return 0; -} - /* initialise the ctdb daemon for client applications @@ -3832,24 +3721,13 @@ static bool ctdb_server_id_equal(struct ctdb_server_id *id1, struct ctdb_server_ return true; } -static bool server_id_exists(struct ctdb_context *ctdb, struct ctdb_server_id *id) +static bool server_id_exists(struct ctdb_context *ctdb, + struct ctdb_server_id *id) { - struct ctdb_client_id sid; int ret; - uint32_t result = 0; - - sid.type = SERVER_TYPE_SAMBA; - sid.pnn = id->vnn; - sid.server_id = id->pid; - ret = ctdb_ctrl_check_server_id(ctdb, timeval_current_ofs(3,0), - id->vnn, &sid, &result); - if (ret != 0) { - /* If control times out, assume server_id exists. */ - return true; - } - - if (result) { + ret = ctdb_ctrl_process_exists(ctdb, id->vnn, id->pid); + if (ret == 0) { return true; } @@ -4079,7 +3957,6 @@ struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *c TALLOC_CTX *mem_ctx) { struct ctdb_transaction_handle *h; - struct ctdb_client_id id; h = talloc_zero(mem_ctx, struct ctdb_transaction_handle); if (h == NULL) { @@ -4104,17 +3981,6 @@ struct ctdb_transaction_handle *ctdb_transaction_start(struct ctdb_db_context *c return NULL; } - id.type = SERVER_TYPE_SAMBA; - id.pnn = ctdb_get_pnn(ctdb_db->ctdb); - id.server_id = getpid(); - - if (ctdb_ctrl_register_server_id(ctdb_db->ctdb, timeval_current_ofs(3,0), - &id) != 0) { - DEBUG(DEBUG_ERR, (__location__ " unable to register server id\n")); - talloc_free(h); - return NULL; - } - h->reqid = reqid_new(h->ctdb_db->ctdb->idr, h); if (!g_lock_lock(h, h->g_lock_db, h->lock_name, h->reqid)) { diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index 08ba9206c52..a39d09693bc 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -415,20 +415,6 @@ int ctdb_ctrl_get_tcp_tickles(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, ctdb_sock_addr *addr, struct ctdb_tickle_list_old **list); -int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb, - struct timeval timeout, - struct ctdb_client_id *id); -int ctdb_ctrl_unregister_server_id(struct ctdb_context *ctdb, - struct timeval timeout, - struct ctdb_client_id *id); -int ctdb_ctrl_check_server_id(struct ctdb_context *ctdb, - struct timeval timeout, uint32_t destnode, - struct ctdb_client_id *id, uint32_t *status); -int ctdb_ctrl_get_server_id_list(struct ctdb_context *ctdb, - TALLOC_CTX *mem_ctx, - struct timeval timeout, uint32_t destnode, - struct ctdb_client_id_list_old **svid_list); - /* initialise ctdb subsystem */