From fc23cd1b9cdd1d70067491614b16e616291e8ff2 Mon Sep 17 00:00:00 2001 From: Martin Schwenke Date: Wed, 26 Feb 2020 17:03:49 +1100 Subject: [PATCH] ctdb-daemon: Remove unused old client database functions BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294 Signed-off-by: Martin Schwenke Reviewed-by: Amitay Isaacs --- ctdb/include/ctdb_client.h | 22 ------ ctdb/include/ctdb_private.h | 2 + ctdb/server/ctdb_client.c | 146 ------------------------------------ 3 files changed, 2 insertions(+), 168 deletions(-) diff --git a/ctdb/include/ctdb_client.h b/ctdb/include/ctdb_client.h index ef4950ab533..d1dce1e68d8 100644 --- a/ctdb/include/ctdb_client.h +++ b/ctdb/include/ctdb_client.h @@ -176,9 +176,6 @@ int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb, struct timeval timeout, int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *runstate); -int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, - uint32_t destnode, uint32_t dbid, - TALLOC_CTX *mem_ctx, const char **path); int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, const char **name); @@ -190,25 +187,6 @@ int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32_t *level); -/* - attach to a ctdb database -*/ -int ctdb_ctrl_db_open_flags(struct ctdb_context *ctdb, uint32_t db_id, - int *tdb_flags); - -struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, - struct timeval timeout, - const char *name, - uint8_t db_flags); - -/* a ctdb call function */ -typedef int (*ctdb_fn_t)(struct ctdb_call_info *); - -/* - setup a ctdb call function -*/ -int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id); - int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode); diff --git a/ctdb/include/ctdb_private.h b/ctdb/include/ctdb_private.h index 405bf3b4186..e532323bb34 100644 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@ -36,6 +36,8 @@ struct ctdb_tcp_array { /* an installed ctdb remote call */ +typedef int (*ctdb_fn_t)(struct ctdb_call_info *); + struct ctdb_registered_call { struct ctdb_registered_call *next, *prev; uint32_t id; diff --git a/ctdb/server/ctdb_client.c b/ctdb/server/ctdb_client.c index 0da847c401b..f5366e874ee 100644 --- a/ctdb/server/ctdb_client.c +++ b/ctdb/server/ctdb_client.c @@ -1107,36 +1107,6 @@ int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, return 0; } -/* - find the real path to a ltdb - */ -int ctdb_ctrl_getdbpath(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t dbid, TALLOC_CTX *mem_ctx, - const char **path) -{ - int ret; - int32_t res; - TDB_DATA data; - - data.dptr = (uint8_t *)&dbid; - data.dsize = sizeof(dbid); - - ret = ctdb_control(ctdb, destnode, 0, - CTDB_CONTROL_GETDBPATH, 0, data, - mem_ctx, &data, &res, &timeout, NULL); - if (ret != 0 || res != 0) { - return -1; - } - - (*path) = talloc_strndup(mem_ctx, (const char *)data.dptr, data.dsize); - if ((*path) == NULL) { - return -1; - } - - talloc_free(data.dptr); - - return 0; -} - /* find the name of a db */ @@ -1233,122 +1203,6 @@ int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode, int32 return 0; } -/* - * Get db open flags - */ -int ctdb_ctrl_db_open_flags(struct ctdb_context *ctdb, uint32_t db_id, - int *tdb_flags) -{ - TDB_DATA indata, outdata; - int ret; - int32_t res; - - indata.dptr = (uint8_t *)&db_id; - indata.dsize = sizeof(db_id); - - ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, - CTDB_CONTROL_DB_OPEN_FLAGS, 0, indata, - ctdb, &outdata, &res, NULL, NULL); - if (ret != 0 || res != 0) { - D_ERR("ctdb control for db open flags failed\n"); - return -1; - } - - if (outdata.dsize != sizeof(int32_t)) { - D_ERR(__location__ " expected %zi bytes, received %zi bytes\n", - sizeof(int32_t), outdata.dsize); - talloc_free(outdata.dptr); - return -1; - } - - *tdb_flags = *(int32_t *)outdata.dptr; - talloc_free(outdata.dptr); - return 0; -} - -/* - attach to a specific database - client call -*/ -struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, - struct timeval timeout, - const char *name, - uint8_t db_flags) -{ - struct ctdb_db_context *ctdb_db; - int ret; - int tdb_flags; - - ctdb_db = ctdb_db_handle(ctdb, name); - if (ctdb_db) { - return ctdb_db; - } - - ctdb_db = talloc_zero(ctdb, struct ctdb_db_context); - CTDB_NO_MEMORY_NULL(ctdb, ctdb_db); - - ctdb_db->ctdb = ctdb; - ctdb_db->db_name = talloc_strdup(ctdb_db, name); - CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name); - - /* tell ctdb daemon to attach */ - ret = ctdb_ctrl_createdb(ctdb, timeout, CTDB_CURRENT_NODE, - ctdb_db, name, db_flags, &ctdb_db->db_id); - if (ret != 0) { - DEBUG(DEBUG_ERR,("Failed to attach to database '%s'\n", name)); - talloc_free(ctdb_db); - return NULL; - } - - ret = ctdb_ctrl_getdbpath(ctdb, timeout, CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path); - if (ret != 0) { - DEBUG(DEBUG_ERR,("Failed to get dbpath for database '%s'\n", name)); - talloc_free(ctdb_db); - return NULL; - } - - ret = ctdb_ctrl_db_open_flags(ctdb, ctdb_db->db_id, &tdb_flags); - if (ret != 0) { - D_ERR("Failed to get tdb_flags for database '%s'\n", name); - talloc_free(ctdb_db); - return NULL; - } - - ctdb_db->ltdb = tdb_wrap_open(ctdb_db, ctdb_db->db_path, 0, tdb_flags, - O_RDWR, 0); - if (ctdb_db->ltdb == NULL) { - ctdb_set_error(ctdb, "Failed to open tdb '%s'\n", ctdb_db->db_path); - talloc_free(ctdb_db); - return NULL; - } - - ctdb_db->db_flags = db_flags; - - DLIST_ADD(ctdb->db_list, ctdb_db); - - /* add well known functions */ - ctdb_set_call(ctdb_db, ctdb_null_func, CTDB_NULL_FUNC); - ctdb_set_call(ctdb_db, ctdb_fetch_func, CTDB_FETCH_FUNC); - ctdb_set_call(ctdb_db, ctdb_fetch_with_header_func, CTDB_FETCH_WITH_HEADER_FUNC); - - return ctdb_db; -} - -/* - setup a call for a database - */ -int ctdb_set_call(struct ctdb_db_context *ctdb_db, ctdb_fn_t fn, uint32_t id) -{ - struct ctdb_registered_call *call; - - /* register locally */ - call = talloc(ctdb_db, struct ctdb_registered_call); - call->fn = fn; - call->id = id; - - DLIST_ADD(ctdb_db->calls, call); - return 0; -} - /* Freeze all databases */ int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)