mirror of
https://github.com/samba-team/samba.git
synced 2025-03-07 00:58:40 +03:00
clean out some more cruft
(This used to be ctdb commit ad16c5fe2748b48a6f6c79976359d56d9bed33f4)
This commit is contained in:
parent
ac55bc4166
commit
be3a00bd73
@ -78,14 +78,6 @@ void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags)
|
||||
ctdb->flags |= flags;
|
||||
}
|
||||
|
||||
/*
|
||||
clear some ctdb flags
|
||||
*/
|
||||
void ctdb_clear_flags(struct ctdb_context *ctdb, unsigned flags)
|
||||
{
|
||||
ctdb->flags &= ~flags;
|
||||
}
|
||||
|
||||
/*
|
||||
set the directory for the local databases
|
||||
*/
|
||||
@ -489,7 +481,7 @@ void ctdb_queue_packet(struct ctdb_context *ctdb, struct ctdb_req_header *hdr)
|
||||
|
||||
node = ctdb->nodes[hdr->destnode];
|
||||
|
||||
if (hdr->destnode == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (hdr->destnode == ctdb->vnn) {
|
||||
ctdb_defer_packet(ctdb, hdr);
|
||||
} else {
|
||||
node->tx_cnt++;
|
||||
|
@ -47,7 +47,7 @@
|
||||
/*
|
||||
a varient of input packet that can be used in lock requeue
|
||||
*/
|
||||
void ctdb_call_input_pkt(void *p, struct ctdb_req_header *hdr)
|
||||
static void ctdb_call_input_pkt(void *p, struct ctdb_req_header *hdr)
|
||||
{
|
||||
struct ctdb_context *ctdb = talloc_get_type(p, struct ctdb_context);
|
||||
ctdb_input_pkt(ctdb, hdr);
|
||||
|
@ -287,8 +287,7 @@ struct ctdb_client_call_state *ctdb_call_send(struct ctdb_db_context *ctdb_db,
|
||||
|
||||
ret = ctdb_ltdb_fetch(ctdb_db, call->key, &header, ctdb_db, &data);
|
||||
|
||||
if (ret == 0 &&
|
||||
header.dmaster == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (ret == 0 && header.dmaster == ctdb->vnn) {
|
||||
state = ctdb_client_call_local_send(ctdb_db, call, &header, &data);
|
||||
talloc_free(data.dptr);
|
||||
ctdb_ltdb_unlock(ctdb_db, call->key);
|
||||
@ -1109,31 +1108,6 @@ int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb, struct timeval timeout, uint
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
delete all records from a tdb
|
||||
*/
|
||||
int ctdb_ctrl_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid)
|
||||
{
|
||||
int ret;
|
||||
TDB_DATA indata;
|
||||
int32_t res;
|
||||
|
||||
indata.dsize = sizeof(uint32_t);
|
||||
indata.dptr = (unsigned char *)talloc_array(mem_ctx, uint32_t, 1);
|
||||
|
||||
((uint32_t *)(&indata.dptr[0]))[0] = dbid;
|
||||
|
||||
ret = ctdb_control(ctdb, destnode, 0,
|
||||
CTDB_CONTROL_CLEAR_DB, 0, indata,
|
||||
NULL, NULL, &res, NULL, NULL);
|
||||
if (ret != 0 || res != 0) {
|
||||
DEBUG(0,(__location__ " ctdb_control for cleardb failed\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
ping a node, return number of clients connected
|
||||
*/
|
||||
|
@ -112,10 +112,6 @@ static int32_t ctdb_control_dispatch(struct ctdb_context *ctdb,
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(struct ctdb_control_set_dmaster));
|
||||
return ctdb_control_set_dmaster(ctdb, indata);
|
||||
|
||||
case CTDB_CONTROL_CLEAR_DB:
|
||||
CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t));
|
||||
return ctdb_control_clear_db(ctdb, indata);
|
||||
|
||||
case CTDB_CONTROL_PUSH_DB:
|
||||
return ctdb_control_push_db(ctdb, indata);
|
||||
|
||||
|
@ -359,7 +359,7 @@ static void daemon_request_call_from_client(struct ctdb_client *client,
|
||||
call->call_data.dsize = c->calldatalen;
|
||||
call->flags = c->flags;
|
||||
|
||||
if (header.dmaster == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (header.dmaster == ctdb->vnn) {
|
||||
state = ctdb_call_local_send(ctdb_db, call, &header, &data);
|
||||
} else {
|
||||
state = ctdb_daemon_call_send_remote(ctdb_db, call, &header);
|
||||
|
@ -115,7 +115,7 @@ int ctdb_daemon_send_message(struct ctdb_context *ctdb, uint32_t vnn,
|
||||
int len;
|
||||
|
||||
/* see if this is a message to ourselves */
|
||||
if (vnn == ctdb->vnn && !(ctdb->flags & CTDB_FLAG_SELF_CONNECT)) {
|
||||
if (vnn == ctdb->vnn) {
|
||||
return ctdb_local_message(ctdb, srvid, data);
|
||||
}
|
||||
|
||||
|
@ -392,48 +392,6 @@ int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int traverse_cleardb(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data, void *p)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = tdb_delete(tdb, key);
|
||||
if (ret) {
|
||||
DEBUG(0,(__location__ " failed to delete tdb record\n"));
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int32_t ctdb_control_clear_db(struct ctdb_context *ctdb, TDB_DATA indata)
|
||||
{
|
||||
uint32_t dbid = *(uint32_t *)indata.dptr;
|
||||
struct ctdb_db_context *ctdb_db;
|
||||
|
||||
if (ctdb->freeze_mode != CTDB_FREEZE_FROZEN) {
|
||||
DEBUG(0,("rejecting ctdb_control_clear_db when not frozen\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
ctdb_db = find_ctdb_db(ctdb, dbid);
|
||||
if (!ctdb_db) {
|
||||
DEBUG(0,(__location__ " Unknown db 0x%08x\n",dbid));
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (ctdb_lock_all_databases_mark(ctdb) != 0) {
|
||||
DEBUG(0,(__location__ " Failed to get lock on entired db - failing\n"));
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdb_traverse(ctdb_db->ltdb->tdb, traverse_cleardb, NULL);
|
||||
|
||||
ctdb_lock_all_databases_unmark(ctdb);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct ctdb_set_recmode_state {
|
||||
struct ctdb_req_control *c;
|
||||
uint32_t recmode;
|
||||
|
@ -662,7 +662,7 @@ static void force_election(struct ctdb_context *ctdb, TALLOC_CTX *mem_ctx, uint3
|
||||
/*
|
||||
the main monitoring loop
|
||||
*/
|
||||
void monitor_cluster(struct ctdb_context *ctdb)
|
||||
static void monitor_cluster(struct ctdb_context *ctdb)
|
||||
{
|
||||
uint32_t vnn, num_active, recmode, recmaster;
|
||||
TALLOC_CTX *mem_ctx=NULL;
|
||||
|
@ -116,9 +116,9 @@ static int ctdb_traverse_local_fn(struct tdb_context *tdb, TDB_DATA key, TDB_DAT
|
||||
|
||||
The traverse is finished when the callback is called with tdb_null for key and data
|
||||
*/
|
||||
struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
static struct ctdb_traverse_local_handle *ctdb_traverse_local(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
{
|
||||
struct ctdb_traverse_local_handle *h;
|
||||
int ret;
|
||||
@ -217,9 +217,9 @@ static void ctdb_traverse_all_timeout(struct event_context *ev, struct timed_eve
|
||||
The traverse is finished when the callback is called with tdb_null
|
||||
for key and data
|
||||
*/
|
||||
struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
static struct ctdb_traverse_all_handle *ctdb_daemon_traverse_all(struct ctdb_db_context *ctdb_db,
|
||||
ctdb_traverse_fn_t callback,
|
||||
void *private_data)
|
||||
{
|
||||
struct ctdb_traverse_all_handle *state;
|
||||
struct ctdb_context *ctdb = ctdb_db->ctdb;
|
||||
|
@ -105,17 +105,6 @@ uint32_t ctdb_hash(const TDB_DATA *key)
|
||||
return (1103515243 * value + 12345);
|
||||
}
|
||||
|
||||
/*
|
||||
hash function for a string
|
||||
*/
|
||||
uint32_t ctdb_hash_string(const char *str)
|
||||
{
|
||||
TDB_DATA data;
|
||||
data.dptr = (uint8_t *)discard_const(str);
|
||||
data.dsize = strlen(str)+1;
|
||||
return ctdb_hash(&data);
|
||||
}
|
||||
|
||||
/*
|
||||
a type checking varient of idr_find
|
||||
*/
|
||||
|
@ -47,7 +47,7 @@ double timeval_elapsed(struct timeval *tv)
|
||||
/**
|
||||
return a timeval struct with the given elements
|
||||
*/
|
||||
struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
_PUBLIC_ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
{
|
||||
struct timeval tv;
|
||||
tv.tv_sec = secs;
|
||||
@ -55,7 +55,7 @@ struct timeval timeval_set(uint32_t secs, uint32_t usecs)
|
||||
return tv;
|
||||
}
|
||||
|
||||
int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
|
||||
_PUBLIC_ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
|
||||
{
|
||||
if (tv1->tv_sec > tv2->tv_sec) return 1;
|
||||
if (tv1->tv_sec < tv2->tv_sec) return -1;
|
||||
@ -64,8 +64,8 @@ int timeval_compare(const struct timeval *tv1, const struct timeval *tv2)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct timeval timeval_until(const struct timeval *tv1,
|
||||
const struct timeval *tv2)
|
||||
_PUBLIC_ struct timeval timeval_until(const struct timeval *tv1,
|
||||
const struct timeval *tv2)
|
||||
{
|
||||
struct timeval t;
|
||||
if (timeval_compare(tv1, tv2) >= 0) {
|
||||
@ -81,7 +81,7 @@ struct timeval timeval_until(const struct timeval *tv1,
|
||||
return t;
|
||||
}
|
||||
|
||||
_PUBLIC_ struct timeval timeval_add(const struct timeval *tv,
|
||||
static struct timeval timeval_add(const struct timeval *tv,
|
||||
uint32_t secs, uint32_t usecs)
|
||||
{
|
||||
struct timeval tv2 = *tv;
|
||||
@ -100,7 +100,7 @@ _PUBLIC_ struct timeval timeval_current_ofs(uint32_t secs, uint32_t usecs)
|
||||
return timeval_add(&tv, secs, usecs);
|
||||
}
|
||||
|
||||
_PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
static char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
struct stat sbuf;
|
||||
char *p;
|
||||
@ -122,7 +122,7 @@ _PUBLIC_ char *fd_load(int fd, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
}
|
||||
|
||||
|
||||
_PUBLIC_ char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
static char *file_load(const char *fname, size_t *size, TALLOC_CTX *mem_ctx)
|
||||
{
|
||||
int fd;
|
||||
char *p;
|
||||
|
@ -48,14 +48,12 @@ static struct {
|
||||
const char *logfile;
|
||||
const char *recovery_lock_file;
|
||||
const char *db_dir;
|
||||
int self_connect;
|
||||
} options = {
|
||||
.nlist = ETCDIR "/ctdb/nodes",
|
||||
.transport = "tcp",
|
||||
.event_script = ETCDIR "/ctdb/events",
|
||||
.logfile = VARDIR "/log/log.ctdb",
|
||||
.db_dir = VARDIR "/ctdb",
|
||||
.self_connect = 0,
|
||||
};
|
||||
|
||||
|
||||
@ -79,7 +77,6 @@ int main(int argc, const char *argv[])
|
||||
{ "nlist", 0, POPT_ARG_STRING, &options.nlist, 0, "node list file", "filename" },
|
||||
{ "listen", 0, POPT_ARG_STRING, &options.myaddress, 0, "address to listen on", "address" },
|
||||
{ "transport", 0, POPT_ARG_STRING, &options.transport, 0, "protocol transport", NULL },
|
||||
{ "self-connect", 0, POPT_ARG_NONE, &options.self_connect, 0, "enable self connect", "boolean" },
|
||||
{ "dbdir", 0, POPT_ARG_STRING, &options.db_dir, 0, "directory for the tdb files", NULL },
|
||||
{ "reclock", 0, POPT_ARG_STRING, &options.recovery_lock_file, 0, "location of recovery lock file", "filename" },
|
||||
POPT_TABLEEND
|
||||
@ -125,10 +122,6 @@ int main(int argc, const char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (options.self_connect) {
|
||||
ctdb_set_flags(ctdb, CTDB_FLAG_SELF_CONNECT);
|
||||
}
|
||||
|
||||
ret = ctdb_set_transport(ctdb, options.transport);
|
||||
if (ret == -1) {
|
||||
printf("ctdb_set_transport failed - %s\n", ctdb_errstr(ctdb));
|
||||
|
@ -106,10 +106,9 @@ static int ctdb_ibw_start(struct ctdb_context *ctdb)
|
||||
/* everything async here */
|
||||
for (i=0;i<ctdb->num_nodes;i++) {
|
||||
struct ctdb_node *node = ctdb->nodes[i];
|
||||
if (!(ctdb->flags & CTDB_FLAG_SELF_CONNECT) &&
|
||||
ctdb_same_address(&ctdb->address, &node->address))
|
||||
continue;
|
||||
ctdb_ibw_node_connect(node);
|
||||
if (!ctdb_same_address(&ctdb->address, &node->address)) {
|
||||
ctdb_ibw_node_connect(node);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -49,7 +49,6 @@ struct ctdb_call_info {
|
||||
/*
|
||||
ctdb flags
|
||||
*/
|
||||
#define CTDB_FLAG_SELF_CONNECT (1<<0)
|
||||
#define CTDB_FLAG_TORTURE (1<<1)
|
||||
|
||||
/*
|
||||
@ -102,11 +101,6 @@ int ctdb_set_tdb_dir(struct ctdb_context *ctdb, const char *dir);
|
||||
*/
|
||||
void ctdb_set_flags(struct ctdb_context *ctdb, unsigned flags);
|
||||
|
||||
/*
|
||||
clear some flags
|
||||
*/
|
||||
void ctdb_clear_flags(struct ctdb_context *ctdb, unsigned flags);
|
||||
|
||||
/*
|
||||
set max acess count before a dmaster migration
|
||||
*/
|
||||
@ -277,11 +271,6 @@ int ctdb_ctrl_setdmaster(struct ctdb_context *ctdb,
|
||||
struct timeval timeout, uint32_t destnode,
|
||||
TALLOC_CTX *mem_ctx, uint32_t dbid, uint32_t dmaster);
|
||||
|
||||
/*
|
||||
delete all records from a tdb
|
||||
*/
|
||||
int ctdb_ctrl_cleardb(struct ctdb_context *ctdb, uint32_t destnode, TALLOC_CTX *mem_ctx, uint32_t dbid);
|
||||
|
||||
/*
|
||||
write a record on a specific db (this implicitely updates dmaster of the record to locally be the vnn of the node where the control is executed on)
|
||||
*/
|
||||
|
@ -369,7 +369,7 @@ enum ctdb_controls {CTDB_CONTROL_PROCESS_EXISTS = 0,
|
||||
CTDB_CONTROL_GET_DBMAP = 9,
|
||||
CTDB_CONTROL_GET_NODEMAP = 10,
|
||||
CTDB_CONTROL_SET_DMASTER = 11,
|
||||
CTDB_CONTROL_CLEAR_DB = 12,
|
||||
/* #12 removed */
|
||||
CTDB_CONTROL_PULL_DB = 13,
|
||||
CTDB_CONTROL_PUSH_DB = 14,
|
||||
CTDB_CONTROL_GET_RECMODE = 15,
|
||||
@ -893,7 +893,6 @@ struct ctdb_rec_data *ctdb_marshall_record(TALLOC_CTX *mem_ctx, uint32_t reqid,
|
||||
int32_t ctdb_control_pull_db(struct ctdb_context *ctdb, TDB_DATA indata, TDB_DATA *outdata);
|
||||
int32_t ctdb_control_push_db(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
int32_t ctdb_control_set_dmaster(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
int32_t ctdb_control_clear_db(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||
|
||||
int32_t ctdb_control_set_recmode(struct ctdb_context *ctdb,
|
||||
struct ctdb_req_control *c,
|
||||
|
@ -80,10 +80,10 @@ static int ctdb_tcp_start(struct ctdb_context *ctdb)
|
||||
struct ctdb_node *node = *(ctdb->nodes + i);
|
||||
struct ctdb_tcp_node *tnode = talloc_get_type(
|
||||
node->private_data, struct ctdb_tcp_node);
|
||||
if (!(ctdb->flags & CTDB_FLAG_SELF_CONNECT) &&
|
||||
ctdb_same_address(&ctdb->address, &node->address)) continue;
|
||||
event_add_timed(ctdb->ev, tnode, timeval_zero(),
|
||||
ctdb_tcp_node_connect, node);
|
||||
if (!ctdb_same_address(&ctdb->address, &node->address)) {
|
||||
event_add_timed(ctdb->ev, tnode, timeval_zero(),
|
||||
ctdb_tcp_node_connect, node);
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user