From: Amitay Isaacs Date: Thu, 21 Apr 2016 05:18:33 +0000 (+1000) Subject: ctdb-daemon: Remove unused controls related to server_id X-Git-Tag: talloc-2.1.7~203 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d2f86ea8c308a39ad6db1bd212e6ae6f5d63b140;p=thirdparty%2Fsamba.git ctdb-daemon: Remove unused controls related to server_id These controls have never been used and also they do not use the server_id structure defined in samba. In future, similar controls can be added to register/unregister using proper server_id structure. Signed-off-by: Amitay Isaacs Reviewed-by: Martin Schwenke --- diff --git a/ctdb/common/cmdline.c b/ctdb/common/cmdline.c index 02083e88838..3a4557eab17 100644 --- a/ctdb/common/cmdline.c +++ b/ctdb/common/cmdline.c @@ -113,9 +113,6 @@ struct ctdb_context *ctdb_cmdline_init(struct tevent_context *ev) DEBUGLEVEL = debug_level_to_int(DEBUG_NOTICE); } - /* set up the tree to store server ids */ - ctdb->server_ids = trbt_create(ctdb, 0); - return ctdb; } diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index b17af53e744..41b9f4f6ce9 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -335,7 +335,6 @@ struct ctdb_context { uint32_t recovery_master; struct ctdb_client_ip *client_ip_list; bool do_checkpublicip; - struct trbt_tree *server_ids; bool do_setsched; const char *event_script_dir; const char *notification_script; diff --git a/ctdb/server/ctdb_control.c b/ctdb/server/ctdb_control.c index c795a3f9b84..9819176c970 100644 --- a/ctdb/server/ctdb_control.c +++ b/ctdb/server/ctdb_control.c @@ -418,21 +418,17 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb, /* data size is verified in the called function */ return ctdb_control_set_tcp_tickle_list(ctdb, indata); - case CTDB_CONTROL_REGISTER_SERVER_ID: - CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_id)); - return ctdb_control_register_server_id(ctdb, client_id, indata); + case CTDB_CONTROL_REGISTER_SERVER_ID: + return control_not_implemented("REGISTER_SERVER_ID", NULL); - case CTDB_CONTROL_UNREGISTER_SERVER_ID: - CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_id)); - return ctdb_control_unregister_server_id(ctdb, indata); + case CTDB_CONTROL_UNREGISTER_SERVER_ID: + return control_not_implemented("UNREGISTER_SERVER_ID", NULL); - case CTDB_CONTROL_CHECK_SERVER_ID: - CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_client_id)); - return ctdb_control_check_server_id(ctdb, indata); + case CTDB_CONTROL_CHECK_SERVER_ID: + return control_not_implemented("CHECK_SERVER_ID", NULL); case CTDB_CONTROL_GET_SERVER_ID_LIST: - CHECK_CONTROL_DATA_SIZE(0); - return ctdb_control_get_server_id_list(ctdb, outdata); + return control_not_implemented("SERVER_ID_LIST", NULL); case CTDB_CONTROL_PERSISTENT_STORE: return control_not_implemented("PERSISTENT_STORE", NULL); diff --git a/ctdb/server/ctdb_serverids.c b/ctdb/server/ctdb_serverids.c deleted file mode 100644 index 11ee99b5aad..00000000000 --- a/ctdb/server/ctdb_serverids.c +++ /dev/null @@ -1,200 +0,0 @@ -/* - ctdb_control protocol code to manage server ids - - Copyright (C) Ronnie Sahlberg 2007 - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, see . -*/ -#include "replace.h" -#include "system/network.h" - -#include - -#include "lib/util/debug.h" - -#include "ctdb_private.h" - -#include "common/rb_tree.h" -#include "common/reqid.h" -#include "common/common.h" -#include "common/logging.h" - - -#define SERVER_ID_KEY_SIZE 3 -static uint32_t *get_server_id_key(struct ctdb_client_id *server_id) -{ - static uint32_t key[SERVER_ID_KEY_SIZE]; - - key[0] = server_id->type; - key[1] = server_id->pnn; - key[2] = server_id->server_id; - - return &key[0]; -} - -/* add a server_id to the tree. - if we had already 'data' in the tree then this is a duplicate and we can - just talloc_free the structure in parm and leave data in the tree. - othervise if this is a new node we return parm and that is inserted - into the tree. -*/ -static void *add_server_id_callback(void *parm, void *data) -{ - if (data) { - talloc_free(parm); - return data; - } - return parm; -} - -/* - register a server id - a serverid that is registered with ctdb will be automatically unregistered - once the client domain socket dissappears. - */ -int32_t ctdb_control_register_server_id(struct ctdb_context *ctdb, - uint32_t client_id, - TDB_DATA indata) -{ - struct ctdb_client_id *server_id; - struct ctdb_client *client = reqid_find(ctdb->idr, client_id, struct ctdb_client); - - - if (client == NULL) { - DEBUG(DEBUG_ERR,(__location__ " Could not find client parent structure. You can not send this control to a remote node\n")); - return 1; - } - - /* hang the server_id structure off client before storing it in the - tree so that is will be automatically destroyed when client - is destroyed. - when the structure is free'd it will be automatically - removed from the tree - */ - server_id = talloc_zero(client, struct ctdb_client_id); - CTDB_NO_MEMORY(ctdb, server_id); - memcpy(server_id, indata.dptr, sizeof(struct ctdb_client_id)); - - trbt_insertarray32_callback(ctdb->server_ids, SERVER_ID_KEY_SIZE, - get_server_id_key(server_id), - add_server_id_callback, server_id); - - return 0; -} - - -/* - check whether a server id exists - */ -int32_t ctdb_control_check_server_id(struct ctdb_context *ctdb, - TDB_DATA indata) -{ - struct ctdb_client_id *server_id = (struct ctdb_client_id *)indata.dptr; - - return trbt_lookuparray32(ctdb->server_ids, - SERVER_ID_KEY_SIZE, - get_server_id_key(server_id)) == NULL? 0 : 1; -} - -/* - unregisters a server id - */ -int32_t ctdb_control_unregister_server_id(struct ctdb_context *ctdb, - TDB_DATA indata) -{ - struct ctdb_client_id *server_id = (struct ctdb_client_id *)indata.dptr; - - talloc_free(trbt_lookuparray32(ctdb->server_ids, - SERVER_ID_KEY_SIZE, - get_server_id_key(server_id))); - return 0; -} - - - - -struct count_server_ids { - int count; - struct ctdb_client_id_list_old *list; -}; - -static int server_id_count(void *param, void *data) -{ - struct count_server_ids *svid = talloc_get_type(param, - struct count_server_ids); - - if (svid == NULL) { - DEBUG(DEBUG_ERR, (__location__ " Got null pointer for svid\n")); - return -1; - } - - svid->count++; - return 0; -} - -static int server_id_store(void *param, void *data) -{ - struct count_server_ids *svid = talloc_get_type(param, - struct count_server_ids); - struct ctdb_client_id *server_id = talloc_get_type(data, - struct ctdb_client_id); - - if (svid == NULL) { - DEBUG(DEBUG_ERR, (__location__ " Got null pointer for svid\n")); - return -1; - } - - if (svid->count >= svid->list->num) { - DEBUG(DEBUG_ERR, (__location__ " size of server id tree changed during traverse\n")); - return -1; - } - - memcpy(&svid->list->server_ids[svid->count], server_id, sizeof(struct ctdb_client_id)); - svid->count++; - return 0; -} - -/* - returns a list of all registered server ids for a node -*/ -int32_t ctdb_control_get_server_id_list(struct ctdb_context *ctdb, TDB_DATA *outdata) -{ - struct count_server_ids *svid; - - - svid = talloc_zero(outdata, struct count_server_ids); - CTDB_NO_MEMORY(ctdb, svid); - - - /* first we must count how many entries we have */ - trbt_traversearray32(ctdb->server_ids, SERVER_ID_KEY_SIZE, - server_id_count, svid); - - - outdata->dsize = offsetof(struct ctdb_client_id_list_old, server_ids) - + sizeof(struct ctdb_client_id) * svid->count; - outdata->dptr = talloc_size(outdata, outdata->dsize); - CTDB_NO_MEMORY(ctdb, outdata->dptr); - - - /* now fill the structure in */ - svid->list = (struct ctdb_client_id_list_old *)(outdata->dptr); - svid->list->num = svid->count; - svid->count=0; - trbt_traversearray32(ctdb->server_ids, SERVER_ID_KEY_SIZE, - server_id_store, svid); - - - return 0; -} diff --git a/ctdb/tests/src/ctdbd_test.c b/ctdb/tests/src/ctdbd_test.c index 5fa70144ed4..77fac08a6ad 100644 --- a/ctdb/tests/src/ctdbd_test.c +++ b/ctdb/tests/src/ctdbd_test.c @@ -62,7 +62,6 @@ bool fast_start; #include "server/ipalloc_lcp2.c" #include "server/ipalloc.c" #include "server/ctdb_takeover.c" -#include "server/ctdb_serverids.c" #include "server/ctdb_persistent.c" #include "server/ctdb_keepalive.c" #include "server/ctdb_logging.c" diff --git a/ctdb/wscript b/ctdb/wscript index 55b50eda819..d88fcfc9a13 100755 --- a/ctdb/wscript +++ b/ctdb/wscript @@ -392,7 +392,7 @@ def build(bld): ctdb_server.c ctdb_control.c ctdb_call.c ctdb_ltdb_server.c ctdb_traverse.c eventscript.c - ctdb_takeover.c ctdb_serverids.c + ctdb_takeover.c ctdb_persistent.c ctdb_keepalive.c ctdb_logging.c ctdb_logging_syslog.c