From: Andrew Tridgell Date: Thu, 7 Jun 2007 01:15:22 +0000 (+1000) Subject: merged admin enable/disable change from ronnie X-Git-Tag: tevent-0.9.20~348^2~2544 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=9754d16d4806463c53cc3233640c828982aa0b2c;p=thirdparty%2Fsamba.git merged admin enable/disable change from ronnie (This used to be ctdb commit df17b69dfd83a98f9c711994c7dd51ad2cc0ab8a) --- 9754d16d4806463c53cc3233640c828982aa0b2c diff --cc ctdb/common/ctdb_control.c index ac2522131f6,83a4ee33a64..e22cc7f0732 --- a/ctdb/common/ctdb_control.c +++ b/ctdb/common/ctdb_control.c @@@ -288,6 -288,15 +288,10 @@@ static int32_t ctdb_control_dispatch(st case CTDB_CONTROL_LIST_TUNABLES: return ctdb_control_list_tunables(ctdb, outdata); + case CTDB_CONTROL_PERMANENTLY_DISABLE: + CHECK_CONTROL_DATA_SIZE(sizeof(uint32_t)); - if ( *(uint32_t *)indata.dptr ){ - ctdb->nodes[ctdb->vnn]->flags |= NODE_FLAGS_PERMANENTLY_DISABLED; - } else { - ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED; - } - return 0; ++ return ctdb_control_permdisable(ctdb, indata); + default: DEBUG(0,(__location__ " Unknown CTDB control opcode %u\n", opcode)); return -1; diff --cc ctdb/common/ctdb_monitor.c index 166ee65df96,8461dca242c..3b838e6e047 --- a/ctdb/common/ctdb_monitor.c +++ b/ctdb/common/ctdb_monitor.c @@@ -104,12 -104,17 +104,12 @@@ static void ctdb_health_callback(struc timeval_current_ofs(ctdb->tunable.monitor_interval, 0), ctdb_check_health, ctdb); - if (status != 0 && !(node->flags & NODE_FLAGS_DISABLED)) { - if (node->flags & NODE_FLAGS_PERMANENTLY_DISABLED) { - if ( !(node->flags & NODE_FLAGS_DISABLED) ) { - DEBUG(0,("monitoring - node is permanently disabled\n")); - node->flags |= NODE_FLAGS_DISABLED; - } - } else if (status != 0 && !(node->flags & NODE_FLAGS_DISABLED)) { ++ if (status != 0 && !(node->flags & NODE_FLAGS_UNHEALTHY)) { DEBUG(0,("monitor event failed - disabling node\n")); -- node->flags |= NODE_FLAGS_DISABLED; -- } else if (status == 0 && (node->flags & NODE_FLAGS_DISABLED)) { ++ node->flags |= NODE_FLAGS_UNHEALTHY; ++ } else if (status == 0 && (node->flags & NODE_FLAGS_UNHEALTHY)) { DEBUG(0,("monitor event OK - node re-enabled\n")); -- ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_DISABLED; ++ ctdb->nodes[ctdb->vnn]->flags &= ~NODE_FLAGS_UNHEALTHY; } else { /* no change */ return; @@@ -124,6 -129,6 +124,7 @@@ /* tell the other nodes that something has changed */ ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP, CTDB_SRVID_NODE_FLAGS_CHANGED, data); ++ } @@@ -181,3 -186,3 +182,33 @@@ void ctdb_start_monitoring(struct ctdb_ ctdb_check_health, ctdb); CTDB_NO_MEMORY_FATAL(ctdb, te); } ++ ++ ++/* ++ administratively disable/enable a node ++ */ ++int32_t ctdb_control_permdisable(struct ctdb_context *ctdb, TDB_DATA indata) ++{ ++ uint32_t set = *(uint32_t *)indata.dptr; ++ TDB_DATA data; ++ struct ctdb_node_flag_change c; ++ struct ctdb_node *node = ctdb->nodes[ctdb->vnn]; ++ ++ if (set) { ++ node->flags |= NODE_FLAGS_PERMANENTLY_DISABLED; ++ } else { ++ node->flags &= ~NODE_FLAGS_PERMANENTLY_DISABLED; ++ } ++ ++ c.vnn = ctdb->vnn; ++ c.flags = node->flags; ++ ++ data.dptr = (uint8_t *)&c; ++ data.dsize = sizeof(c); ++ ++ /* tell the other nodes that something has changed */ ++ ctdb_daemon_send_message(ctdb, CTDB_BROADCAST_VNNMAP, ++ CTDB_SRVID_NODE_FLAGS_CHANGED, data); ++ ++ return 0; ++} diff --cc ctdb/include/ctdb_private.h index 0e5e361d70c,c22c8a6d996..2ec30817620 --- a/ctdb/include/ctdb_private.h +++ b/ctdb/include/ctdb_private.h @@@ -111,8 -111,9 +111,10 @@@ struct ctdb_node const char *name; /* for debug messages */ void *private_data; /* private to transport */ uint32_t vnn; - #define NODE_FLAGS_CONNECTED 0x00000001 - #define NODE_FLAGS_DISABLED 0x00000002 + #define NODE_FLAGS_CONNECTED 0x00000001 -#define NODE_FLAGS_DISABLED 0x00000002 ++#define NODE_FLAGS_UNHEALTHY 0x00000002 + #define NODE_FLAGS_PERMANENTLY_DISABLED 0x00000004 ++#define NODE_FLAGS_DISABLED (NODE_FLAGS_UNHEALTHY|NODE_FLAGS_PERMANENTLY_DISABLED) uint32_t flags; /* used by the dead node monitoring */ @@@ -1007,4 -1009,4 +1010,6 @@@ int32_t ctdb_control_list_tunables(stru void ctdb_tunables_set_defaults(struct ctdb_context *ctdb); ++int32_t ctdb_control_permdisable(struct ctdb_context *ctdb, TDB_DATA indata); ++ #endif diff --cc ctdb/tools/ctdb_control.c index d5ffbd96be1,94c5be3b41d..3525fd672c5 --- a/ctdb/tools/ctdb_control.c +++ b/ctdb/tools/ctdb_control.c @@@ -285,11 -285,13 +285,13 @@@ static int control_status(struct ctdb_c } if(options.machinereadable){ - printf(":Node:IP:Status:\n"); + printf(":Node:IP:Connected:Disabled:Permanently Disabled:\n"); for(i=0;inum;i++){ - printf(":%d:%s:%d:\n", nodemap->nodes[i].vnn, + printf(":%d:%s:%d:%d:%d:\n", nodemap->nodes[i].vnn, inet_ntoa(nodemap->nodes[i].sin.sin_addr), - !!nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED); + !!(nodemap->nodes[i].flags&NODE_FLAGS_CONNECTED), - !!(nodemap->nodes[i].flags&NODE_FLAGS_DISABLED), ++ !!(nodemap->nodes[i].flags&NODE_FLAGS_UNHEALTHY), + !!(nodemap->nodes[i].flags&NODE_FLAGS_PERMANENTLY_DISABLED)); } return 0; } @@@ -297,8 -299,10 +299,10 @@@ printf("Number of nodes:%d\n", nodemap->num); for(i=0;inum;i++){ const char *flags_str; - if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) { + if (nodemap->nodes[i].flags & NODE_FLAGS_PERMANENTLY_DISABLED) { - flags_str = "PERM DISABLED"; - } else if (nodemap->nodes[i].flags & NODE_FLAGS_DISABLED) { flags_str = "DISABLED"; ++ } else if (nodemap->nodes[i].flags & NODE_FLAGS_UNHEALTHY) { ++ flags_str = "UNHEALTHY"; } else if (nodemap->nodes[i].flags & NODE_FLAGS_CONNECTED) { flags_str = "CONNECTED"; } else {