mirror of
https://github.com/samba-team/samba.git
synced 2024-12-22 13:34:15 +03:00
ctdb-daemon: Remove unused old client database functions
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14294 Signed-off-by: Martin Schwenke <martin@meltin.net> Reviewed-by: Amitay Isaacs <amitay@gmail.com>
This commit is contained in:
parent
c6c89495fb
commit
fc23cd1b9c
@ -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,
|
int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb, struct timeval timeout,
|
||||||
uint32_t destnode, uint32_t *runstate);
|
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,
|
int ctdb_ctrl_getdbname(struct ctdb_context *ctdb, struct timeval timeout,
|
||||||
uint32_t destnode, uint32_t dbid,
|
uint32_t destnode, uint32_t dbid,
|
||||||
TALLOC_CTX *mem_ctx, const char **name);
|
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,
|
int ctdb_ctrl_get_debuglevel(struct ctdb_context *ctdb, uint32_t destnode,
|
||||||
int32_t *level);
|
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,
|
int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
|
||||||
uint32_t destnode);
|
uint32_t destnode);
|
||||||
|
|
||||||
|
@ -36,6 +36,8 @@ struct ctdb_tcp_array {
|
|||||||
/*
|
/*
|
||||||
an installed ctdb remote call
|
an installed ctdb remote call
|
||||||
*/
|
*/
|
||||||
|
typedef int (*ctdb_fn_t)(struct ctdb_call_info *);
|
||||||
|
|
||||||
struct ctdb_registered_call {
|
struct ctdb_registered_call {
|
||||||
struct ctdb_registered_call *next, *prev;
|
struct ctdb_registered_call *next, *prev;
|
||||||
uint32_t id;
|
uint32_t id;
|
||||||
|
@ -1107,36 +1107,6 @@ int ctdb_ctrl_get_runstate(struct ctdb_context *ctdb,
|
|||||||
return 0;
|
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
|
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;
|
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 */
|
/* Freeze all databases */
|
||||||
int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
|
int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
|
||||||
uint32_t destnode)
|
uint32_t destnode)
|
||||||
|
Loading…
Reference in New Issue
Block a user