along with this program; if not, see <http://www.gnu.org/licenses/>.
*/
#include "includes.h"
-#include "lib/tdb/include/tdb.h"
+#include "tdb.h"
#include "system/time.h"
#include "system/network.h"
#include "system/filesys.h"
{
struct ctdb_context *ctdb = talloc_get_type(private_data, struct ctdb_context);
+ /* Make sure we were able to freeze databases during banning */
+ if (!ctdb_db_all_frozen(ctdb)) {
+ DEBUG(DEBUG_ERR, ("Banning timedout, but still unable to freeze databases\n"));
+ ctdb_ban_self(ctdb);
+ return;
+ }
+
DEBUG(DEBUG_ERR,("Banning timedout\n"));
ctdb->nodes[ctdb->pnn]->flags &= ~NODE_FLAGS_BANNED;
}
}
-int32_t ctdb_local_node_got_banned(struct ctdb_context *ctdb)
+void ctdb_local_node_got_banned(struct ctdb_context *ctdb)
{
uint32_t i;
*/
ctdb->vnn_map->generation = INVALID_GENERATION;
+ ctdb->recovery_mode = CTDB_RECOVERY_ACTIVE;
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_start_freeze(ctdb, 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)
{
struct ctdb_ban_time *bantime = (struct ctdb_ban_time *)indata.dptr;
+ bool already_banned;
DEBUG(DEBUG_INFO,("SET BAN STATE\n"));
if (bantime->pnn != ctdb->pnn) {
- if (bantime->pnn < 0 || bantime->pnn >= ctdb->num_nodes) {
+ if (bantime->pnn >= ctdb->num_nodes) {
DEBUG(DEBUG_ERR,(__location__ " ERROR: Invalid ban request. PNN:%d is invalid. Max nodes %d\n", bantime->pnn, ctdb->num_nodes));
return -1;
}
if (bantime->time == 0) {
- DEBUG(DEBUG_INFO,("unbanning node %d\n", bantime->pnn));
+ DEBUG(DEBUG_NOTICE,("unbanning node %d\n", bantime->pnn));
ctdb->nodes[bantime->pnn]->flags &= ~NODE_FLAGS_BANNED;
} else {
- DEBUG(DEBUG_INFO,("banning node %d\n", bantime->pnn));
+ DEBUG(DEBUG_NOTICE,("banning node %d\n", bantime->pnn));
if (ctdb->tunable.enable_bans == 0) {
- DEBUG(DEBUG_INFO,("Bans are disabled - ignoring ban of node %u\n", bantime->pnn));
+ /* FIXME: This is bogus. We really should be
+ * taking decision based on the tunables on
+ * the banned node and not local node.
+ */
+ DEBUG(DEBUG_WARNING,("Bans are disabled - ignoring ban of node %u\n", bantime->pnn));
return 0;
}
return 0;
}
+ already_banned = false;
if (ctdb->banning_ctx != NULL) {
talloc_free(ctdb->banning_ctx);
ctdb->banning_ctx = NULL;
+ already_banned = true;
}
if (bantime->time == 0) {
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);
- if (bantime->pnn == ctdb->pnn) {
- return ctdb_local_node_got_banned(ctdb);
- }
+ if (!already_banned) {
+ ctdb_local_node_got_banned(ctdb);
+ }
return 0;
}