mirror of
https://github.com/samba-team/samba.git
synced 2025-02-28 01:58:17 +03:00
server/banning: also release all ips if we're banning ourself
metze (This used to be ctdb commit c386f2c62f06f1c60047b7d4b1ec7a9eec11873c)
This commit is contained in:
parent
5e46150490
commit
0b5bd411ca
@ -1291,6 +1291,7 @@ int ctdb_vacuum_init(struct ctdb_db_context *ctdb_db);
|
|||||||
int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
|
int32_t ctdb_control_enable_script(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||||
int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
|
int32_t ctdb_control_disable_script(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||||
|
|
||||||
|
int32_t ctdb_local_node_got_banned(struct ctdb_context *ctdb);
|
||||||
int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
|
int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||||
int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
|
int32_t ctdb_control_get_ban_state(struct ctdb_context *ctdb, TDB_DATA *outdata);
|
||||||
int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
|
int32_t ctdb_control_set_db_priority(struct ctdb_context *ctdb, TDB_DATA indata);
|
||||||
|
@ -42,6 +42,31 @@ ctdb_ban_node_event(struct event_context *ev, struct timed_event *te,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t ctdb_local_node_got_banned(struct ctdb_context *ctdb)
|
||||||
|
{
|
||||||
|
uint32_t i;
|
||||||
|
|
||||||
|
/* make sure we are frozen */
|
||||||
|
DEBUG(DEBUG_NOTICE,("This node has been banned - forcing freeze and recovery\n"));
|
||||||
|
|
||||||
|
/* Reset the generation id to 1 to make us ignore any
|
||||||
|
REQ/REPLY CALL/DMASTER someone sends to us.
|
||||||
|
We are now banned so we shouldnt service database calls
|
||||||
|
anymore.
|
||||||
|
*/
|
||||||
|
ctdb->vnn_map->generation = INVALID_GENERATION;
|
||||||
|
|
||||||
|
for (i=1; i<=NUM_DB_PRIORITIES; i++) {
|
||||||
|
if (ctdb_start_freeze(ctdb, i) != 0) {
|
||||||
|
DEBUG(DEBUG_ERR,(__location__ " Failed to freeze db priority %u\n", i));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ctdb_release_all_ips(ctdb);
|
||||||
|
ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
|
int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
|
||||||
{
|
{
|
||||||
struct ctdb_ban_time *bantime = (struct ctdb_ban_time *)indata.dptr;
|
struct ctdb_ban_time *bantime = (struct ctdb_ban_time *)indata.dptr;
|
||||||
@ -96,6 +121,9 @@ int32_t ctdb_control_set_ban_state(struct ctdb_context *ctdb, TDB_DATA indata)
|
|||||||
ctdb->nodes[bantime->pnn]->flags |= NODE_FLAGS_BANNED;
|
ctdb->nodes[bantime->pnn]->flags |= NODE_FLAGS_BANNED;
|
||||||
|
|
||||||
event_add_timed(ctdb->ev, ctdb->banning_ctx, timeval_current_ofs(bantime->time,0), ctdb_ban_node_event, ctdb);
|
event_add_timed(ctdb->ev, ctdb->banning_ctx, timeval_current_ofs(bantime->time,0), ctdb_ban_node_event, ctdb);
|
||||||
|
if (bantime->pnn == ctdb->pnn) {
|
||||||
|
return ctdb_local_node_got_banned(ctdb);
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -431,7 +431,6 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata)
|
|||||||
struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)indata.dptr;
|
struct ctdb_node_flag_change *c = (struct ctdb_node_flag_change *)indata.dptr;
|
||||||
struct ctdb_node *node;
|
struct ctdb_node *node;
|
||||||
uint32_t old_flags;
|
uint32_t old_flags;
|
||||||
int i;
|
|
||||||
|
|
||||||
if (c->pnn >= ctdb->num_nodes) {
|
if (c->pnn >= ctdb->num_nodes) {
|
||||||
DEBUG(DEBUG_ERR,(__location__ " Node %d is invalid, num_nodes :%d\n", c->pnn, ctdb->num_nodes));
|
DEBUG(DEBUG_ERR,(__location__ " Node %d is invalid, num_nodes :%d\n", c->pnn, ctdb->num_nodes));
|
||||||
@ -481,22 +480,7 @@ int32_t ctdb_control_modflags(struct ctdb_context *ctdb, TDB_DATA indata)
|
|||||||
|
|
||||||
/* if we have become banned, we should go into recovery mode */
|
/* if we have become banned, we should go into recovery mode */
|
||||||
if ((node->flags & NODE_FLAGS_BANNED) && !(c->old_flags & NODE_FLAGS_BANNED) && (node->pnn == ctdb->pnn)) {
|
if ((node->flags & NODE_FLAGS_BANNED) && !(c->old_flags & NODE_FLAGS_BANNED) && (node->pnn == ctdb->pnn)) {
|
||||||
/* make sure we are frozen */
|
return ctdb_local_node_got_banned(ctdb);
|
||||||
DEBUG(DEBUG_NOTICE,("This node has been banned - forcing freeze and recovery\n"));
|
|
||||||
/* Reset the generation id to 1 to make us ignore any
|
|
||||||
REQ/REPLY CALL/DMASTER someone sends to us.
|
|
||||||
We are now banned so we shouldnt service database calls
|
|
||||||
anymore.
|
|
||||||
*/
|
|
||||||
ctdb->vnn_map->generation = INVALID_GENERATION;
|
|
||||||
|
|
||||||
for (i=1; i<=NUM_DB_PRIORITIES; i++) {
|
|
||||||
if (ctdb_start_freeze(ctdb, i) != 0) {
|
|
||||||
DEBUG(DEBUG_ERR,(__location__ " Failed to freeze db priority %u\n", i));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ctdb_release_all_ips(ctdb);
|
|
||||||
ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user