#include "system/locale.h"
#include <talloc.h>
-/* Allow use of deprecated function tevent_loop_allow_nesting() */
-#define TEVENT_DEPRECATED
#include <tevent.h>
#include <tdb.h>
#include "lib/util/debug.h"
#include "lib/util/samba_util.h"
-#include "ctdb_logging.h"
#include "ctdb_private.h"
#include "ctdb_client.h"
#include "common/reqid.h"
#include "common/system.h"
#include "common/common.h"
+#include "common/logging.h"
/*
allocate a packet for use in client<->daemon communication
struct ctdb_registered_call *fn;
struct ctdb_context *ctdb = ctdb_db->ctdb;
- c = talloc(ctdb, struct ctdb_call_info);
+ c = talloc_zero(mem_ctx, struct ctdb_call_info);
CTDB_NO_MEMORY(ctdb, c);
c->key = call->key;
c->record_data.dptr = talloc_memdup(c, data->dptr, data->dsize);
c->record_data.dsize = data->dsize;
CTDB_NO_MEMORY(ctdb, c->record_data.dptr);
- c->new_data = NULL;
- c->reply_data = NULL;
- c->status = 0;
c->header = header;
for (fn=ctdb_db->calls;fn;fn=fn->next) {
void ctdb_request_message(struct ctdb_context *ctdb,
struct ctdb_req_header *hdr)
{
- struct ctdb_req_message *c = (struct ctdb_req_message *)hdr;
+ struct ctdb_req_message_old *c = (struct ctdb_req_message_old *)hdr;
TDB_DATA data;
data.dsize = c->datalen;
int ctdb_socket_connect(struct ctdb_context *ctdb)
{
struct sockaddr_un addr;
+ int ret;
memset(&addr, 0, sizeof(addr));
addr.sun_family = AF_UNIX;
}
if (connect(ctdb->daemon.sd, (struct sockaddr *)&addr, sizeof(addr)) == -1) {
+ DEBUG(DEBUG_ERR,
+ (__location__
+ "Failed to connect client socket to daemon (%s)\n",
+ strerror(errno)));
+ close(ctdb->daemon.sd);
+ ctdb->daemon.sd = -1;
+ return -1;
+ }
+
+ ret = set_blocking(ctdb->daemon.sd, false);
+ if (ret != 0) {
+ DEBUG(DEBUG_ERR,
+ (__location__
+ " failed to set socket non-blocking (%s)\n",
+ strerror(errno)));
close(ctdb->daemon.sd);
ctdb->daemon.sd = -1;
- DEBUG(DEBUG_ERR,(__location__ " Failed to connect client socket to daemon. Errno:%s(%d)\n", strerror(errno), errno));
return -1;
}
- set_nonblocking(ctdb->daemon.sd);
set_close_on_exec(ctdb->daemon.sd);
-
+
ctdb->daemon.queue = ctdb_queue_setup(ctdb, ctdb, ctdb->daemon.sd,
CTDB_DS_ALIGNMENT,
ctdb_client_read_cb, ctdb, "to-ctdbd");
return 0;
}
-/*
- * check server ids
- */
-int ctdb_client_check_message_handlers(struct ctdb_context *ctdb, uint64_t *ids, uint32_t num,
- uint8_t *result)
-{
- TDB_DATA indata, outdata;
- int res;
- int32_t status;
- int i;
-
- indata.dptr = (uint8_t *)ids;
- indata.dsize = num * sizeof(*ids);
-
- res = ctdb_control(ctdb, CTDB_CURRENT_NODE, 0, CTDB_CONTROL_CHECK_SRVIDS, 0,
- indata, ctdb, &outdata, &status, NULL, NULL);
- if (res != 0 || status != 0) {
- DEBUG(DEBUG_ERR, (__location__ " failed to check srvids\n"));
- return -1;
- }
-
- if (outdata.dsize != num*sizeof(uint8_t)) {
- DEBUG(DEBUG_ERR, (__location__ " expected %lu bytes, received %zi bytes\n",
- (long unsigned int)num*sizeof(uint8_t),
- outdata.dsize));
- talloc_free(outdata.dptr);
- return -1;
- }
-
- for (i=0; i<num; i++) {
- result[i] = outdata.dptr[i];
- }
-
- talloc_free(outdata.dptr);
- return 0;
-}
-
/*
send a message - from client context
*/
int ctdb_client_send_message(struct ctdb_context *ctdb, uint32_t pnn,
uint64_t srvid, TDB_DATA data)
{
- struct ctdb_req_message *r;
+ struct ctdb_req_message_old *r;
int len, res;
- len = offsetof(struct ctdb_req_message, data) + data.dsize;
+ len = offsetof(struct ctdb_req_message_old, data) + data.dsize;
r = ctdbd_allocate_pkt(ctdb, ctdb, CTDB_REQ_MESSAGE,
- len, struct ctdb_req_message);
+ len, struct ctdb_req_message_old);
CTDB_NO_MEMORY(ctdb, r);
r->hdr.destnode = pnn;
*/
int ctdb_record_store(struct ctdb_record_handle *h, TDB_DATA data)
{
- if (h->ctdb_db->persistent) {
- DEBUG(DEBUG_ERR, (__location__ " ctdb_record_store prohibited for persistent dbs\n"));
+ if (! ctdb_db_volatile(h->ctdb_db)) {
+ DEBUG(DEBUG_ERR,
+ ("ctdb_record_store prohibited for non-volatile dbs\n"));
return -1;
}
static void ctdb_client_reply_control(struct ctdb_context *ctdb,
struct ctdb_req_header *hdr)
{
- struct ctdb_reply_control *c = (struct ctdb_reply_control *)hdr;
+ struct ctdb_reply_control_old *c = (struct ctdb_reply_control_old *)hdr;
struct ctdb_client_control_state *state;
state = reqid_find(ctdb->idr, hdr->reqid, struct ctdb_client_control_state);
c->errorlen);
}
- /* state->outdata now uses resources from c so we dont want c
+ /* state->outdata now uses resources from c so we don't want c
to just dissappear from under us while state is still alive
*/
talloc_steal(state, c);
{
struct ctdb_client_control_state *state;
size_t len;
- struct ctdb_req_control *c;
+ struct ctdb_req_control_old *c;
int ret;
if (errormsg) {
talloc_set_destructor(state, ctdb_client_control_destructor);
- len = offsetof(struct ctdb_req_control, data) + data.dsize;
+ len = offsetof(struct ctdb_req_control_old, data) + data.dsize;
c = ctdbd_allocate_pkt(ctdb, state, CTDB_REQ_CONTROL,
- len, struct ctdb_req_control);
+ len, struct ctdb_req_control_old);
state->c = c;
CTDB_NO_MEMORY_NULL(ctdb, c);
c->hdr.reqid = state->reqid;
}
if (state->errormsg) {
+ int s = (state->status == 0 ? -1 : state->status);
DEBUG(DEBUG_ERR,("ctdb_control error: '%s'\n", state->errormsg));
if (errormsg) {
(*errormsg) = talloc_move(mem_ctx, &state->errormsg);
state->async.fn(state);
}
talloc_free(tmp_ctx);
- return (status == 0 ? -1 : state->status);
+ return s;
}
if (outdata) {
* get db statistics
*/
int ctdb_ctrl_dbstatistics(struct ctdb_context *ctdb, uint32_t destnode, uint32_t dbid,
- TALLOC_CTX *mem_ctx, struct ctdb_db_statistics **dbstat)
+ TALLOC_CTX *mem_ctx, struct ctdb_db_statistics_old **dbstat)
{
int ret;
TDB_DATA indata, outdata;
int32_t res;
- struct ctdb_db_statistics *wire, *s;
+ struct ctdb_db_statistics_old *wire, *s;
char *ptr;
int i;
return -1;
}
- if (outdata.dsize < offsetof(struct ctdb_db_statistics, hot_keys_wire)) {
+ if (outdata.dsize < offsetof(struct ctdb_db_statistics_old, hot_keys_wire)) {
DEBUG(DEBUG_ERR,(__location__ " Wrong dbstatistics size %zi - expected >= %lu\n",
outdata.dsize,
(long unsigned int)sizeof(struct ctdb_statistics)));
return -1;
}
- s = talloc_zero(mem_ctx, struct ctdb_db_statistics);
+ s = talloc_zero(mem_ctx, struct ctdb_db_statistics_old);
if (s == NULL) {
talloc_free(outdata.dptr);
CTDB_NO_MEMORY(ctdb, s);
}
- wire = (struct ctdb_db_statistics *)outdata.dptr;
- memcpy(s, wire, offsetof(struct ctdb_db_statistics, hot_keys_wire));
+ wire = (struct ctdb_db_statistics_old *)outdata.dptr;
+ memcpy(s, wire, offsetof(struct ctdb_db_statistics_old, hot_keys_wire));
ptr = &wire->hot_keys_wire[0];
for (i=0; i<wire->num_hot_keys; i++) {
s->hot_keys[i].key.dptr = talloc_size(mem_ctx, s->hot_keys[i].key.dsize);
get a list of databases off a remote node
*/
int ctdb_ctrl_getdbmap(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, struct ctdb_dbid_map **dbmap)
+ TALLOC_CTX *mem_ctx, struct ctdb_dbid_map_old **dbmap)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *dbmap = (struct ctdb_dbid_map *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+ *dbmap = (struct ctdb_dbid_map_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
talloc_free(outdata.dptr);
return 0;
*/
int ctdb_ctrl_getnodemap(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap)
+ TALLOC_CTX *mem_ctx, struct ctdb_node_map_old **nodemap)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *nodemap = (struct ctdb_node_map *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+ *nodemap = (struct ctdb_node_map_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
talloc_free(outdata.dptr);
return 0;
}
*/
int ctdb_ctrl_getnodesfile(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, struct ctdb_node_map **nodemap)
+ TALLOC_CTX *mem_ctx, struct ctdb_node_map_old **nodemap)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *nodemap = (struct ctdb_node_map *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+ *nodemap = (struct ctdb_node_map_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
talloc_free(outdata.dptr);
return 0;
uint32_t lmaster, TALLOC_CTX *mem_ctx, struct timeval timeout)
{
TDB_DATA indata;
- struct ctdb_control_pulldb *pull;
+ struct ctdb_pulldb *pull;
struct ctdb_client_control_state *state;
- pull = talloc(mem_ctx, struct ctdb_control_pulldb);
+ pull = talloc(mem_ctx, struct ctdb_pulldb);
CTDB_NO_MEMORY_NULL(ctdb, pull);
pull->db_id = dbid;
pull->lmaster = lmaster;
- indata.dsize = sizeof(struct ctdb_control_pulldb);
+ indata.dsize = sizeof(struct ctdb_pulldb);
indata.dptr = (unsigned char *)pull;
state = ctdb_control_send(ctdb, destnode, 0,
int ret;
int32_t res;
TDB_DATA data, outdata;
+ uint8_t buf[sizeof(uint64_t)] = { 0 };
- data.dptr = (uint8_t *)&dbid;
- data.dsize = sizeof(uint64_t); /* This is just wrong */
+ *(uint32_t *)buf = dbid;
+ data.dptr = buf;
+ data.dsize = sizeof(uint64_t);
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_GET_DB_SEQNUM,
0, data, ctdb, &outdata, &res, &timeout, NULL);
/*
create a database
*/
-int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx, const char *name, bool persistent)
+int ctdb_ctrl_createdb(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, TALLOC_CTX *mem_ctx,
+ const char *name, uint8_t db_flags, uint32_t *db_id)
{
int ret;
int32_t res;
TDB_DATA data;
- uint64_t tdb_flags = 0;
+ uint32_t opcode;
data.dptr = discard_const(name);
data.dsize = strlen(name)+1;
- /* Make sure that volatile databases use jenkins hash */
- if (!persistent) {
- tdb_flags = TDB_INCOMPATIBLE_HASH;
- }
-
-#ifdef TDB_MUTEX_LOCKING
- if (!persistent && ctdb->tunable.mutex_enabled == 1) {
- tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
+ if (db_flags & CTDB_DB_FLAGS_PERSISTENT) {
+ opcode = CTDB_CONTROL_DB_ATTACH_PERSISTENT;
+ } else if (db_flags & CTDB_DB_FLAGS_REPLICATED) {
+ opcode = CTDB_CONTROL_DB_ATTACH_REPLICATED;
+ } else {
+ opcode = CTDB_CONTROL_DB_ATTACH;
}
-#endif
- ret = ctdb_control(ctdb, destnode, tdb_flags,
- persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH,
- 0, data,
+ ret = ctdb_control(ctdb, destnode, 0, opcode, 0, data,
mem_ctx, &data, &res, &timeout, NULL);
if (ret != 0 || res != 0) {
return -1;
}
+ if (data.dsize != sizeof(uint32_t)) {
+ TALLOC_FREE(data.dptr);
+ return -1;
+ }
+ if (db_id != NULL) {
+ *db_id = *(uint32_t *)data.dptr;
+ }
+ talloc_free(data.dptr);
+
return 0;
}
TALLOC_CTX *mem_ctx,
uint32_t *num_nodes)
{
- struct ctdb_node_map *map=NULL;
+ struct ctdb_node_map_old *map=NULL;
int ret, i;
uint32_t *nodes;
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,
- bool persistent,
- uint32_t tdb_flags)
+ uint8_t db_flags)
{
struct ctdb_db_context *ctdb_db;
- TDB_DATA data;
int ret;
- int32_t res;
-#ifdef TDB_MUTEX_LOCKING
- uint32_t mutex_enabled = 0;
-#endif
+ int tdb_flags;
ctdb_db = ctdb_db_handle(ctdb, name);
if (ctdb_db) {
ctdb_db->db_name = talloc_strdup(ctdb_db, name);
CTDB_NO_MEMORY_NULL(ctdb, ctdb_db->db_name);
- data.dptr = discard_const(name);
- data.dsize = strlen(name)+1;
-
- /* CTDB has switched to using jenkins hash for volatile databases.
- * Even if tdb_flags do not explicitly mention TDB_INCOMPATIBLE_HASH,
- * always set it.
- */
- if (!persistent) {
- tdb_flags |= TDB_INCOMPATIBLE_HASH;
- }
-
-#ifdef TDB_MUTEX_LOCKING
- if (!persistent) {
- ret = ctdb_ctrl_get_tunable(ctdb, timeval_current_ofs(3,0),
- CTDB_CURRENT_NODE,
- "TDBMutexEnabled",
- &mutex_enabled);
- if (ret != 0) {
- DEBUG(DEBUG_WARNING, ("Assuming no mutex support.\n"));
- }
-
- if (mutex_enabled == 1) {
- tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
- }
- }
-#endif
-
/* tell ctdb daemon to attach */
- ret = ctdb_control(ctdb, CTDB_CURRENT_NODE, tdb_flags,
- persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:CTDB_CONTROL_DB_ATTACH,
- 0, data, ctdb_db, &data, &res, NULL, NULL);
- if (ret != 0 || res != 0 || data.dsize != sizeof(uint32_t)) {
+ 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;
}
-
- ctdb_db->db_id = *(uint32_t *)data.dptr;
- talloc_free(data.dptr);
ret = ctdb_ctrl_getdbpath(ctdb, timeout, CTDB_CURRENT_NODE, ctdb_db->db_id, ctdb_db, &ctdb_db->db_path);
if (ret != 0) {
return NULL;
}
- if (persistent) {
- tdb_flags = TDB_DEFAULT;
- } else {
- tdb_flags = TDB_NOSYNC;
-#ifdef TDB_MUTEX_LOCKING
- if (mutex_enabled) {
- tdb_flags |= (TDB_MUTEX_LOCKING | TDB_CLEAR_IF_FIRST);
- }
-#endif
- }
- if (ctdb->valgrinding) {
- tdb_flags |= TDB_NOMMAP;
+ 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;
}
- tdb_flags |= TDB_DISALLOW_NESTING;
ctdb_db->ltdb = tdb_wrap_open(ctdb_db, ctdb_db->db_path, 0, tdb_flags,
O_RDWR, 0);
return NULL;
}
- ctdb_db->persistent = persistent;
+ ctdb_db->db_flags = db_flags;
DLIST_ADD(ctdb->db_list, ctdb_db);
static void traverse_handler(uint64_t srvid, TDB_DATA data, void *p)
{
struct traverse_state *state = (struct traverse_state *)p;
- struct ctdb_rec_data *d = (struct ctdb_rec_data *)data.dptr;
+ struct ctdb_rec_data_old *d = (struct ctdb_rec_data_old *)data.dptr;
TDB_DATA key;
if (data.dsize < sizeof(uint32_t) || d->length != data.dsize) {
return 0;
}
-
-/*
- async freeze send control
- */
-struct ctdb_client_control_state *
-ctdb_ctrl_freeze_send(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct timeval timeout, uint32_t destnode, uint32_t priority)
-{
- return ctdb_control_send(ctdb, destnode, priority,
- CTDB_CONTROL_FREEZE, 0, tdb_null,
- mem_ctx, &timeout, NULL);
-}
-
-/*
- async freeze recv control
-*/
-int ctdb_ctrl_freeze_recv(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, struct ctdb_client_control_state *state)
-{
- int ret;
- int32_t res;
-
- ret = ctdb_control_recv(ctdb, state, mem_ctx, NULL, &res, NULL);
- if ( (ret != 0) || (res != 0) ){
- DEBUG(DEBUG_ERR,(__location__ " ctdb_ctrl_freeze_recv failed\n"));
- return -1;
- }
-
- return 0;
-}
-
-/*
- freeze databases of a certain priority
- */
-int ctdb_ctrl_freeze_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority)
-{
- TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
- struct ctdb_client_control_state *state;
- int ret;
-
- state = ctdb_ctrl_freeze_send(ctdb, tmp_ctx, timeout, destnode, priority);
- ret = ctdb_ctrl_freeze_recv(ctdb, tmp_ctx, state);
- talloc_free(tmp_ctx);
-
- return ret;
-}
-
/* Freeze all databases */
-int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
- int i;
-
- for (i=1; i<=NUM_DB_PRIORITIES; i++) {
- if (ctdb_ctrl_freeze_priority(ctdb, timeout, destnode, i) != 0) {
- return -1;
- }
- }
- return 0;
-}
-
-/*
- thaw databases of a certain priority
- */
-int ctdb_ctrl_thaw_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t priority)
+int ctdb_ctrl_freeze(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode)
{
int ret;
int32_t res;
- ret = ctdb_control(ctdb, destnode, priority,
- CTDB_CONTROL_THAW, 0, tdb_null,
+ ret = ctdb_control(ctdb, destnode, 0,
+ CTDB_CONTROL_FREEZE, 0, tdb_null,
NULL, NULL, &res, &timeout, NULL);
if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control thaw failed\n"));
+ DEBUG(DEBUG_ERR, ("ctdb_ctrl_freeze_priority failed\n"));
return -1;
}
return 0;
}
-/* thaw all databases */
-int ctdb_ctrl_thaw(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
- return ctdb_ctrl_thaw_priority(ctdb, timeout, destnode, 0);
-}
-
/*
get pnn of a node, or -1
*/
return res;
}
-/*
- get the monitoring mode of a remote node
- */
-int ctdb_ctrl_getmonmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t *monmode)
-{
- int ret;
- int32_t res;
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_GET_MONMODE, 0, tdb_null,
- NULL, NULL, &res, &timeout, NULL);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getmonmode failed\n"));
- return -1;
- }
-
- *monmode = res;
-
- return 0;
-}
-
-
-/*
- set the monitoring mode of a remote node to active
- */
-int ctdb_ctrl_enable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
- int ret;
-
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_ENABLE_MONITOR, 0, tdb_null,
- NULL, NULL,NULL, &timeout, NULL);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for enable_monitor failed\n"));
- return -1;
- }
-
-
-
- return 0;
-}
-
-/*
- set the monitoring mode of a remote node to disable
- */
-int ctdb_ctrl_disable_monmode(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode)
-{
- int ret;
-
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_DISABLE_MONITOR, 0, tdb_null,
- NULL, NULL, NULL, &timeout, NULL);
- if (ret != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for disable_monitor failed\n"));
- return -1;
- }
-
-
-
- return 0;
-}
-
-
/*
sent to a node to make it take over an ip address
uint32_t destnode,
const char *name, uint32_t value)
{
- struct ctdb_control_set_tunable *t;
+ struct ctdb_tunable_old *t;
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = offsetof(struct ctdb_control_set_tunable, name) + strlen(name) + 1;
+ data.dsize = offsetof(struct ctdb_tunable_old, name) + strlen(name) + 1;
data.dptr = talloc_size(ctdb, data.dsize);
CTDB_NO_MEMORY(ctdb, data.dptr);
- t = (struct ctdb_control_set_tunable *)data.dptr;
+ t = (struct ctdb_tunable_old *)data.dptr;
t->length = strlen(name)+1;
memcpy(t->name, name, t->length);
t->value = value;
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
uint32_t flags,
- struct ctdb_all_public_ips **ips)
+ struct ctdb_public_ip_list_old **ips)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *ips = (struct ctdb_all_public_ips *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+ *ips = (struct ctdb_public_ip_list_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
talloc_free(outdata.dptr);
return 0;
int ctdb_ctrl_get_public_ips(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
- struct ctdb_all_public_ips **ips)
+ struct ctdb_public_ip_list_old **ips)
{
return ctdb_ctrl_get_public_ips_flags(ctdb, timeout,
destnode, mem_ctx,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
const ctdb_sock_addr *addr,
- struct ctdb_control_public_ip_info **_info)
+ struct ctdb_public_ip_info_old **_info)
{
int ret;
TDB_DATA indata;
TDB_DATA outdata;
int32_t res;
- struct ctdb_control_public_ip_info *info;
+ struct ctdb_public_ip_info_old *info;
uint32_t len;
uint32_t i;
return -1;
}
- len = offsetof(struct ctdb_control_public_ip_info, ifaces);
+ len = offsetof(struct ctdb_public_ip_info_old, ifaces);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get public ip info "
"returned invalid data with size %u > %u\n",
return -1;
}
- info = (struct ctdb_control_public_ip_info *)outdata.dptr;
- len += info->num*sizeof(struct ctdb_control_iface_info);
+ info = (struct ctdb_public_ip_info_old *)outdata.dptr;
+ len += info->num*sizeof(struct ctdb_iface);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get public ip info "
info->ifaces[i].name[CTDB_IFACE_SIZE] = '\0';
}
- *_info = (struct ctdb_control_public_ip_info *)talloc_memdup(mem_ctx,
+ *_info = (struct ctdb_public_ip_info_old *)talloc_memdup(mem_ctx,
outdata.dptr,
outdata.dsize);
talloc_free(outdata.dptr);
int ctdb_ctrl_get_ifaces(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
- struct ctdb_control_get_ifaces **_ifaces)
+ struct ctdb_iface_list_old **_ifaces)
{
int ret;
TDB_DATA outdata;
int32_t res;
- struct ctdb_control_get_ifaces *ifaces;
+ struct ctdb_iface_list_old *ifaces;
uint32_t len;
uint32_t i;
return -1;
}
- len = offsetof(struct ctdb_control_get_ifaces, ifaces);
+ len = offsetof(struct ctdb_iface_list_old, ifaces);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get ifaces "
"returned invalid data with size %u > %u\n",
return -1;
}
- ifaces = (struct ctdb_control_get_ifaces *)outdata.dptr;
- len += ifaces->num*sizeof(struct ctdb_control_iface_info);
+ ifaces = (struct ctdb_iface_list_old *)outdata.dptr;
+ len += ifaces->num*sizeof(struct ctdb_iface);
if (len > outdata.dsize) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get ifaces "
ifaces->ifaces[i].name[CTDB_IFACE_SIZE] = '\0';
}
- *_ifaces = (struct ctdb_control_get_ifaces *)talloc_memdup(mem_ctx,
+ *_ifaces = (struct ctdb_iface_list_old *)talloc_memdup(mem_ctx,
outdata.dptr,
outdata.dsize);
talloc_free(outdata.dptr);
int ctdb_ctrl_set_iface_link(struct ctdb_context *ctdb,
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
- const struct ctdb_control_iface_info *info)
+ const struct ctdb_iface *info)
{
int ret;
TDB_DATA indata;
{
int ret;
TDB_DATA data;
- struct ctdb_node_map *nodemap=NULL;
+ struct ctdb_node_map_old *nodemap=NULL;
struct ctdb_node_flag_change c;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
uint32_t recmaster;
/*
get all tunables
*/
-int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
- struct timeval timeout,
+int ctdb_ctrl_get_all_tunables(struct ctdb_context *ctdb,
+ struct timeval timeout,
uint32_t destnode,
- struct ctdb_tunable *tunables)
+ struct ctdb_tunable_list *tunables)
{
TDB_DATA outdata;
int ret;
if (outdata.dsize != sizeof(*tunables)) {
DEBUG(DEBUG_ERR,(__location__ " bad data size %u in ctdb_ctrl_get_all_tunables should be %u\n",
(unsigned)outdata.dsize, (unsigned)sizeof(*tunables)));
- return -1;
+ return -1;
}
- *tunables = *(struct ctdb_tunable *)outdata.dptr;
+ *tunables = *(struct ctdb_tunable_list *)outdata.dptr;
talloc_free(outdata.dptr);
return 0;
}
/*
add a public address to a node
*/
-int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- struct ctdb_control_ip_iface *pub)
+int ctdb_ctrl_add_public_ip(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_addr_info_old *pub)
{
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = offsetof(struct ctdb_control_ip_iface, iface) + pub->len;
+ data.dsize = offsetof(struct ctdb_addr_info_old, iface) + pub->len;
data.dptr = (unsigned char *)pub;
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_ADD_PUBLIC_IP, 0, data, NULL,
/*
delete a public address from a node
*/
-int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- struct ctdb_control_ip_iface *pub)
+int ctdb_ctrl_del_public_ip(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ struct ctdb_addr_info_old *pub)
{
TDB_DATA data;
int32_t res;
int ret;
- data.dsize = offsetof(struct ctdb_control_ip_iface, iface) + pub->len;
+ data.dsize = offsetof(struct ctdb_addr_info_old, iface) + pub->len;
data.dptr = (unsigned char *)pub;
ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_DEL_PUBLIC_IP, 0, data, NULL,
return 0;
}
-/*
- kill a tcp connection
- */
-int ctdb_ctrl_killtcp(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- struct ctdb_tcp_connection *killtcp)
-{
- TDB_DATA data;
- int32_t res;
- int ret;
-
- data.dsize = sizeof(struct ctdb_tcp_connection);
- data.dptr = (unsigned char *)killtcp;
-
- ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_KILL_TCP, 0, data, NULL,
- NULL, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for killtcp failed\n"));
- return -1;
- }
-
- return 0;
-}
-
/*
send a gratious arp
*/
-int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
- struct timeval timeout,
- uint32_t destnode,
- ctdb_sock_addr *addr,
- const char *ifname)
+int ctdb_ctrl_gratious_arp(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ ctdb_sock_addr *addr, const char *ifname)
{
TDB_DATA data;
int32_t res;
int ret, len;
- struct ctdb_control_gratious_arp *gratious_arp;
+ struct ctdb_addr_info_old *gratious_arp;
TALLOC_CTX *tmp_ctx = talloc_new(ctdb);
len = strlen(ifname)+1;
- gratious_arp = talloc_size(tmp_ctx,
- offsetof(struct ctdb_control_gratious_arp, iface) + len);
+ gratious_arp = talloc_size(tmp_ctx,
+ offsetof(struct ctdb_addr_info_old, iface) + len);
CTDB_NO_MEMORY(ctdb, gratious_arp);
gratious_arp->addr = *addr;
memcpy(&gratious_arp->iface[0], ifname, len);
- data.dsize = offsetof(struct ctdb_control_gratious_arp, iface) + len;
+ data.dsize = offsetof(struct ctdb_addr_info_old, iface) + len;
data.dptr = (unsigned char *)gratious_arp;
- ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_SEND_GRATIOUS_ARP, 0, data, NULL,
+ ret = ctdb_control(ctdb, destnode, 0, CTDB_CONTROL_SEND_GRATUITOUS_ARP, 0, data, NULL,
NULL, &res, &timeout, NULL);
if (ret != 0 || res != 0) {
DEBUG(DEBUG_ERR,(__location__ " ctdb_control for gratious_arp failed\n"));
struct timeval timeout, uint32_t destnode,
TALLOC_CTX *mem_ctx,
ctdb_sock_addr *addr,
- struct ctdb_control_tcp_tickle_list **list)
+ struct ctdb_tickle_list_old **list)
{
int ret;
TDB_DATA data, outdata;
return -1;
}
- *list = (struct ctdb_control_tcp_tickle_list *)outdata.dptr;
+ *list = (struct ctdb_tickle_list_old *)outdata.dptr;
return status;
}
-/*
- register a server id
- */
-int ctdb_ctrl_register_server_id(struct ctdb_context *ctdb,
- struct timeval timeout,
- struct ctdb_server_id *id)
-{
- TDB_DATA data;
- int32_t res;
- int ret;
-
- data.dsize = sizeof(struct ctdb_server_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_server_id *id)
-{
- TDB_DATA data;
- int32_t res;
- int ret;
-
- data.dsize = sizeof(struct ctdb_server_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_server_id *id,
- uint32_t *status)
-{
- TDB_DATA data;
- int32_t res;
- int ret;
-
- data.dsize = sizeof(struct ctdb_server_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_server_id_list **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_server_id_list *)talloc_steal(mem_ctx, outdata.dptr);
-
- return 0;
-}
-
/*
initialise the ctdb daemon for client applications
* If exclude_pnn is not -1 then exclude that pnn from the list.
*/
uint32_t *list_of_nodes(struct ctdb_context *ctdb,
- struct ctdb_node_map *node_map,
+ struct ctdb_node_map_old *node_map,
TALLOC_CTX *mem_ctx,
uint32_t mask,
int exclude_pnn)
}
uint32_t *list_of_active_nodes(struct ctdb_context *ctdb,
- struct ctdb_node_map *node_map,
+ struct ctdb_node_map_old *node_map,
TALLOC_CTX *mem_ctx,
bool include_self)
{
}
uint32_t *list_of_connected_nodes(struct ctdb_context *ctdb,
- struct ctdb_node_map *node_map,
+ struct ctdb_node_map_old *node_map,
TALLOC_CTX *mem_ctx,
bool include_self)
{
ctdb_get_capabilities(struct ctdb_context *ctdb,
TALLOC_CTX *mem_ctx,
struct timeval timeout,
- struct ctdb_node_map *nodemap)
+ struct ctdb_node_map_old *nodemap)
{
uint32_t *nodes;
uint32_t i, res;
struct ctdb_node_capabilities *ret;
- nodes = list_of_connected_nodes(ctdb, nodemap, mem_ctx, true);
+ nodes = list_of_active_nodes(ctdb, nodemap, mem_ctx, true);
ret = talloc_array(mem_ctx, struct ctdb_node_capabilities,
nodemap->num);
}
-struct server_id {
- uint64_t pid;
- uint32_t task_id;
- uint32_t vnn;
- uint64_t unique_id;
-};
-
-static struct server_id server_id_fetch(struct ctdb_context *ctdb, uint32_t reqid)
+static struct ctdb_server_id server_id_fetch(struct ctdb_context *ctdb, uint32_t reqid)
{
- struct server_id id;
+ struct ctdb_server_id id;
id.pid = getpid();
id.task_id = reqid;
/* This is basically a copy from Samba's server_id.*. However, a
* dependency chain stops us from using Samba's version, so use a
* renamed copy until a better solution is found. */
-static bool ctdb_server_id_equal(struct server_id *id1, struct server_id *id2)
+static bool ctdb_server_id_equal(struct ctdb_server_id *id1, struct ctdb_server_id *id2)
{
if (id1->pid != id2->pid) {
return false;
return true;
}
-static bool server_id_exists(struct ctdb_context *ctdb, struct server_id *id)
+static bool server_id_exists(struct ctdb_context *ctdb,
+ struct ctdb_server_id *id)
{
- struct ctdb_server_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;
}
return false;
}
-
-enum g_lock_type {
- G_LOCK_READ = 0,
- G_LOCK_WRITE = 1,
-};
-
-struct g_lock_rec {
- enum g_lock_type type;
- struct server_id id;
-};
-
-struct g_lock_recs {
- unsigned int num;
- struct g_lock_rec *lock;
-};
-
static bool g_lock_parse(TALLOC_CTX *mem_ctx, TDB_DATA data,
- struct g_lock_recs **locks)
+ struct ctdb_g_lock_list **locks)
{
- struct g_lock_recs *recs;
+ struct ctdb_g_lock_list *recs;
- recs = talloc_zero(mem_ctx, struct g_lock_recs);
+ recs = talloc_zero(mem_ctx, struct ctdb_g_lock_list);
if (recs == NULL) {
return false;
}
goto done;
}
- if (data.dsize % sizeof(struct g_lock_rec) != 0) {
+ if (data.dsize % sizeof(struct ctdb_g_lock) != 0) {
DEBUG(DEBUG_ERR, (__location__ "invalid data size %lu in g_lock record\n",
(unsigned long)data.dsize));
talloc_free(recs);
return false;
}
- recs->num = data.dsize / sizeof(struct g_lock_rec);
+ recs->num = data.dsize / sizeof(struct ctdb_g_lock);
recs->lock = talloc_memdup(mem_ctx, data.dptr, data.dsize);
if (recs->lock == NULL) {
talloc_free(recs);
{
TDB_DATA key, data;
struct ctdb_record_handle *h;
- struct g_lock_recs *locks;
- struct server_id id;
+ struct ctdb_g_lock_list *locks;
+ struct ctdb_server_id id;
struct timeval t_start;
int i;
i = 0;
while (i < locks->num) {
- if (ctdb_server_id_equal(&locks->lock[i].id, &id)) {
+ if (ctdb_server_id_equal(&locks->lock[i].sid, &id)) {
/* Internal error */
talloc_free(h);
return false;
}
- if (!server_id_exists(ctdb_db->ctdb, &locks->lock[i].id)) {
+ if (!server_id_exists(ctdb_db->ctdb, &locks->lock[i].sid)) {
if (i < locks->num-1) {
locks->lock[i] = locks->lock[locks->num-1];
}
goto again;
}
- locks->lock = talloc_realloc(locks, locks->lock, struct g_lock_rec,
+ locks->lock = talloc_realloc(locks, locks->lock, struct ctdb_g_lock,
locks->num+1);
if (locks->lock == NULL) {
talloc_free(h);
return false;
}
- locks->lock[locks->num].type = G_LOCK_WRITE;
- locks->lock[locks->num].id = id;
+ locks->lock[locks->num].type = CTDB_G_LOCK_WRITE;
+ locks->lock[locks->num].sid = id;
locks->num++;
data.dptr = (uint8_t *)locks->lock;
- data.dsize = locks->num * sizeof(struct g_lock_rec);
+ data.dsize = locks->num * sizeof(struct ctdb_g_lock);
if (ctdb_record_store(h, data) != 0) {
DEBUG(DEBUG_ERR, ("g_lock: failed to write transaction lock for "
{
TDB_DATA key, data;
struct ctdb_record_handle *h;
- struct g_lock_recs *locks;
- struct server_id id;
+ struct ctdb_g_lock_list *locks;
+ struct ctdb_server_id id;
int i;
bool found = false;
id = server_id_fetch(ctdb_db->ctdb, reqid);
for (i=0; i<locks->num; i++) {
- if (ctdb_server_id_equal(&locks->lock[i].id, &id)) {
+ if (ctdb_server_id_equal(&locks->lock[i].sid, &id)) {
if (i < locks->num-1) {
locks->lock[i] = locks->lock[locks->num-1];
}
}
data.dptr = (uint8_t *)locks->lock;
- data.dsize = locks->num * sizeof(struct g_lock_rec);
+ data.dsize = locks->num * sizeof(struct ctdb_g_lock);
if (ctdb_record_store(h, data) != 0) {
talloc_free(h);
TALLOC_CTX *mem_ctx)
{
struct ctdb_transaction_handle *h;
- struct ctdb_server_id id;
h = talloc_zero(mem_ctx, struct ctdb_transaction_handle);
if (h == NULL) {
}
h->g_lock_db = ctdb_attach(h->ctdb_db->ctdb, timeval_current_ofs(3,0),
- "g_lock.tdb", false, 0);
+ "g_lock.tdb", 0);
if (!h->g_lock_db) {
DEBUG(DEBUG_ERR, (__location__ " unable to attach to g_lock.tdb\n"));
talloc_free(h);
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)) {
}
if (data.dsize != sizeof(*seqnum)) {
- DEBUG(DEBUG_ERR, (__location__ " Invalid data recived len=%zi\n",
+ DEBUG(DEBUG_ERR, (__location__ " Invalid data received len=%zi\n",
data.dsize));
talloc_free(data.dptr);
return -1;
}
again:
- timeout = timeval_current_ofs(3,0);
+ timeout = timeval_current_ofs(30,0);
ret = ctdb_control(h->ctdb_db->ctdb, CTDB_CURRENT_NODE,
h->ctdb_db->db_id,
CTDB_CONTROL_TRANS3_COMMIT, 0,
return 0;
}
-/* When forking the main daemon and the child process needs to connect
- * back to the daemon as a client process, this function can be used
- * to change the ctdb context from daemon into client mode. The child
- * process must be created using ctdb_fork() and not fork() -
- * ctdb_fork() does some necessary housekeeping.
- */
-int switch_from_server_to_client(struct ctdb_context *ctdb, const char *fmt, ...)
-{
- int ret;
- va_list ap;
-
- /* Add extra information so we can identify this in the logs */
- va_start(ap, fmt);
- debug_extra = talloc_strdup_append(talloc_vasprintf(NULL, fmt, ap), ":");
- va_end(ap);
-
- /* get a new event context */
- ctdb->ev = tevent_context_init(ctdb);
- tevent_loop_allow_nesting(ctdb->ev);
-
- /* Connect to main CTDB daemon */
- ret = ctdb_socket_connect(ctdb);
- if (ret != 0) {
- DEBUG(DEBUG_ALERT, (__location__ " Failed to init ctdb client\n"));
- return -1;
- }
-
- ctdb->can_send_controls = true;
-
- return 0;
-}
-
-/*
- get the status of running the monitor eventscripts: NULL means never run.
- */
-int ctdb_ctrl_getscriptstatus(struct ctdb_context *ctdb,
- struct timeval timeout, uint32_t destnode,
- TALLOC_CTX *mem_ctx,
- enum ctdb_event type,
- struct ctdb_script_list_old **scripts)
-{
- int ret;
- TDB_DATA outdata, indata;
- int32_t res;
- uint32_t uinttype = type;
-
- indata.dptr = (uint8_t *)&uinttype;
- indata.dsize = sizeof(uinttype);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_GET_EVENT_SCRIPT_STATUS, 0, indata,
- mem_ctx, &outdata, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for getscriptstatus failed ret:%d res:%d\n", ret, res));
- return -1;
- }
-
- if (outdata.dsize == 0) {
- *scripts = NULL;
- } else {
- *scripts = (struct ctdb_script_list_old *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
- talloc_free(outdata.dptr);
- }
-
- return 0;
-}
-
/*
tell the main daemon how long it took to lock the reclock file
*/
return 0;
}
-/*
- set the reclock filename for a node
- */
-int ctdb_ctrl_setreclock(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *reclock)
-{
- int ret;
- TDB_DATA data;
- int32_t res;
-
- if (reclock == NULL) {
- data.dsize = 0;
- data.dptr = NULL;
- } else {
- data.dsize = strlen(reclock) + 1;
- data.dptr = discard_const(reclock);
- }
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_SET_RECLOCK_FILE, 0, data,
- NULL, NULL, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for setreclock failed\n"));
- return -1;
- }
-
- return 0;
-}
-
/*
stop a node
*/
return 0;
}
-/*
- set the natgw state for a node
- */
-int ctdb_ctrl_setnatgwstate(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t natgwstate)
-{
- int ret;
- TDB_DATA data;
- int32_t res;
-
- data.dsize = sizeof(natgwstate);
- data.dptr = (uint8_t *)&natgwstate;
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_SET_NATGWSTATE, 0, data,
- NULL, NULL, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for setnatgwstate failed\n"));
- return -1;
- }
-
- return 0;
-}
-
/*
set the lmaster role for a node
*/
return 0;
}
-/* enable an eventscript
- */
-int ctdb_ctrl_enablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script)
-{
- int ret;
- TDB_DATA data;
- int32_t res;
-
- data.dsize = strlen(script) + 1;
- data.dptr = discard_const(script);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_ENABLE_SCRIPT, 0, data,
- NULL, NULL, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for enablescript failed\n"));
- return -1;
- }
-
- return 0;
-}
-
-/* disable an eventscript
- */
-int ctdb_ctrl_disablescript(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, const char *script)
-{
- int ret;
- TDB_DATA data;
- int32_t res;
-
- data.dsize = strlen(script) + 1;
- data.dptr = discard_const(script);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_DISABLE_SCRIPT, 0, data,
- NULL, NULL, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for disablescript failed\n"));
- return -1;
- }
-
- return 0;
-}
-
-
-int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_ban_time *bantime)
+int ctdb_ctrl_set_ban(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, struct ctdb_ban_state *bantime)
{
int ret;
TDB_DATA data;
}
-int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_ban_time **bantime)
+int ctdb_ctrl_get_ban(struct ctdb_context *ctdb, struct timeval timeout,
+ uint32_t destnode, TALLOC_CTX *mem_ctx,
+ struct ctdb_ban_state **bantime)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *bantime = (struct ctdb_ban_time *)talloc_steal(mem_ctx, outdata.dptr);
+ *bantime = (struct ctdb_ban_state *)talloc_steal(mem_ctx, outdata.dptr);
talloc_free(tmp_ctx);
return 0;
}
-
-int ctdb_ctrl_set_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, struct ctdb_db_priority *db_prio)
-{
- int ret;
- int32_t res;
- TDB_DATA data;
- TALLOC_CTX *tmp_ctx = talloc_new(NULL);
-
- data.dptr = (uint8_t*)db_prio;
- data.dsize = sizeof(*db_prio);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_SET_DB_PRIORITY, 0, data,
- tmp_ctx, NULL, &res, &timeout, NULL);
- if (ret != 0 || res != 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for set_db_priority failed\n"));
- talloc_free(tmp_ctx);
- return -1;
- }
-
- talloc_free(tmp_ctx);
-
- return 0;
-}
-
-int ctdb_ctrl_get_db_priority(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, uint32_t db_id, uint32_t *priority)
-{
- int ret;
- int32_t res;
- TDB_DATA data;
- TALLOC_CTX *tmp_ctx = talloc_new(NULL);
-
- data.dptr = (uint8_t*)&db_id;
- data.dsize = sizeof(db_id);
-
- ret = ctdb_control(ctdb, destnode, 0,
- CTDB_CONTROL_GET_DB_PRIORITY, 0, data,
- tmp_ctx, NULL, &res, &timeout, NULL);
- if (ret != 0 || res < 0) {
- DEBUG(DEBUG_ERR,(__location__ " ctdb_control for get_db_priority failed\n"));
- talloc_free(tmp_ctx);
- return -1;
- }
-
- if (priority) {
- *priority = res;
- }
-
- talloc_free(tmp_ctx);
-
- return 0;
-}
-
-int ctdb_ctrl_getstathistory(struct ctdb_context *ctdb, struct timeval timeout, uint32_t destnode, TALLOC_CTX *mem_ctx, struct ctdb_statistics_wire **stats)
+int ctdb_ctrl_getstathistory(struct ctdb_context *ctdb,
+ struct timeval timeout, uint32_t destnode,
+ TALLOC_CTX *mem_ctx,
+ struct ctdb_statistics_list_old **stats)
{
int ret;
TDB_DATA outdata;
return -1;
}
- *stats = (struct ctdb_statistics_wire *)talloc_memdup(mem_ctx, outdata.dptr, outdata.dsize);
+ *stats = (struct ctdb_statistics_list_old *)talloc_memdup(mem_ctx,
+ outdata.dptr,
+ outdata.dsize);
talloc_free(outdata.dptr);
-
+
return 0;
}
{
struct ctdb_client_control_state *handle;
struct ctdb_marshall_buffer *m;
- struct ctdb_rec_data *rec;
+ struct ctdb_rec_data_old *rec;
TDB_DATA outdata;
m = talloc_zero(mem_ctx, struct ctdb_marshall_buffer);