mirror of
https://github.com/samba-team/samba.git
synced 2025-01-10 01:18:15 +03:00
fix a conflict in the merge from rusty
Merge commit 'rusty/ctdb-no-setsched' Conflicts: server/ctdb_vacuum.c (This used to be ctdb commit b4365045797f520a7914afdb69ebd1a8dacfa0d9)
This commit is contained in:
commit
4c722fe34c
@ -1721,7 +1721,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name,
|
||||
}
|
||||
|
||||
tdb_flags = persistent?TDB_DEFAULT:TDB_NOSYNC;
|
||||
if (!ctdb->do_setsched) {
|
||||
if (ctdb->valgrinding) {
|
||||
tdb_flags |= TDB_NOMMAP;
|
||||
}
|
||||
tdb_flags |= TDB_DISALLOW_NESTING;
|
||||
@ -3666,11 +3666,6 @@ int switch_from_server_to_client(struct ctdb_context *ctdb)
|
||||
close(ctdb->daemon.sd);
|
||||
ctdb->daemon.sd = -1;
|
||||
|
||||
/* the client does not need to be realtime */
|
||||
if (ctdb->do_setsched) {
|
||||
ctdb_restore_scheduler(ctdb);
|
||||
}
|
||||
|
||||
/* initialise ctdb */
|
||||
ret = ctdb_socket_connect(ctdb);
|
||||
if (ret != 0) {
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "system/network.h"
|
||||
#include "system/filesys.h"
|
||||
#include "system/wait.h"
|
||||
#include "system/shmem.h"
|
||||
#include "../include/ctdb_private.h"
|
||||
|
||||
int LogLevel = DEBUG_NOTICE;
|
||||
@ -323,52 +324,19 @@ struct ctdb_rec_data *ctdb_marshall_loop_next(struct ctdb_marshall_buffer *m, st
|
||||
return r;
|
||||
}
|
||||
|
||||
|
||||
#if HAVE_SCHED_H
|
||||
#include <sched.h>
|
||||
#endif
|
||||
|
||||
/*
|
||||
if possible, make this task real time
|
||||
if possible, make this task very high priority
|
||||
*/
|
||||
void ctdb_set_scheduler(struct ctdb_context *ctdb)
|
||||
void ctdb_high_priority(struct ctdb_context *ctdb)
|
||||
{
|
||||
#if HAVE_SCHED_SETSCHEDULER
|
||||
struct sched_param p;
|
||||
if (ctdb->saved_scheduler_param == NULL) {
|
||||
ctdb->saved_scheduler_param = talloc_size(ctdb, sizeof(p));
|
||||
}
|
||||
|
||||
if (sched_getparam(0, (struct sched_param *)ctdb->saved_scheduler_param) == -1) {
|
||||
DEBUG(DEBUG_ERR,("Unable to get old scheduler params\n"));
|
||||
return;
|
||||
}
|
||||
|
||||
p = *(struct sched_param *)ctdb->saved_scheduler_param;
|
||||
p.sched_priority = 1;
|
||||
|
||||
if (sched_setscheduler(0, SCHED_FIFO, &p) == -1) {
|
||||
DEBUG(DEBUG_CRIT,("Unable to set scheduler to SCHED_FIFO (%s)\n",
|
||||
strerror(errno)));
|
||||
errno = 0;
|
||||
if (nice(-20) == -1 && errno != 0) {
|
||||
DEBUG(DEBUG_WARNING,("Unable to renice self: %s\n",
|
||||
strerror(errno)));
|
||||
} else {
|
||||
DEBUG(DEBUG_NOTICE,("Set scheduler to SCHED_FIFO\n"));
|
||||
DEBUG(DEBUG_NOTICE,("Scheduler says I'm nice: %i\n",
|
||||
getpriority(PRIO_PROCESS, getpid())));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
restore previous scheduler parameters
|
||||
*/
|
||||
void ctdb_restore_scheduler(struct ctdb_context *ctdb)
|
||||
{
|
||||
#if HAVE_SCHED_SETSCHEDULER
|
||||
if (ctdb->saved_scheduler_param == NULL) {
|
||||
ctdb_fatal(ctdb, "No saved scheduler parameters\n");
|
||||
}
|
||||
if (sched_setscheduler(0, SCHED_OTHER, (struct sched_param *)ctdb->saved_scheduler_param) == -1) {
|
||||
ctdb_fatal(ctdb, "Unable to restore old scheduler parameters\n");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void set_nonblocking(int fd)
|
||||
@ -662,6 +630,28 @@ int32_t get_debug_by_desc(const char *desc)
|
||||
return DEBUG_ERR;
|
||||
}
|
||||
|
||||
/* we don't lock future pages here; it would increase the chance that
|
||||
* we'd fail to mmap later on. */
|
||||
void ctdb_lockdown_memory(struct ctdb_context *ctdb)
|
||||
{
|
||||
#ifdef HAVE_MLOCKALL
|
||||
/* Extra stack, please! */
|
||||
char dummy[10000];
|
||||
memset(dummy, 0, sizeof(dummy));
|
||||
|
||||
if (ctdb->valgrinding) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* Avoid compiler optimizing out dummy. */
|
||||
mlock(dummy, sizeof(dummy));
|
||||
if (mlockall(MCL_CURRENT) != 0) {
|
||||
DEBUG(DEBUG_WARNING,("Failed to lock memory: %s'\n",
|
||||
strerror(errno)));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *ctdb_eventscript_call_names[] = {
|
||||
"startup",
|
||||
"startrecovery",
|
||||
|
@ -186,7 +186,7 @@ start() {
|
||||
case $init_style in
|
||||
valgrind)
|
||||
valgrind -q --log-file=/var/log/ctdb_valgrind \
|
||||
$ctdbd --nosetsched $CTDB_OPTIONS
|
||||
$ctdbd --valgrinding $CTDB_OPTIONS
|
||||
RETVAL=$?
|
||||
echo
|
||||
;;
|
||||
|
@ -71,6 +71,7 @@ m4_include(ib/config.m4)
|
||||
|
||||
AC_CHECK_HEADERS(sched.h)
|
||||
AC_CHECK_FUNCS(sched_setscheduler)
|
||||
AC_CHECK_FUNCS(mlockall)
|
||||
|
||||
AC_CACHE_CHECK([for sin_len in sock],ctdb_cv_HAVE_SOCK_SIN_LEN,[
|
||||
AC_TRY_COMPILE([#include <sys/types.h>
|
||||
|
@ -437,9 +437,7 @@ struct ctdb_context {
|
||||
uint32_t recovery_master;
|
||||
struct ctdb_call_state *pending_calls;
|
||||
struct ctdb_client_ip *client_ip_list;
|
||||
bool do_setsched;
|
||||
bool do_checkpublicip;
|
||||
void *saved_scheduler_param;
|
||||
struct _trbt_tree_t *server_ids;
|
||||
const char *event_script_dir;
|
||||
const char *notification_script;
|
||||
@ -453,6 +451,7 @@ struct ctdb_context {
|
||||
struct ctdb_log_state *log;
|
||||
int start_as_disabled;
|
||||
int start_as_stopped;
|
||||
bool valgrinding;
|
||||
uint32_t event_script_timeouts; /* counting how many consecutive times an eventscript has timedout */
|
||||
uint32_t *recd_ping_count;
|
||||
TALLOC_CTX *release_ips_ctx; /* a context used to automatically drop all IPs if we fail to recover the node */
|
||||
@ -1252,8 +1251,7 @@ void ctdb_call_resend_all(struct ctdb_context *ctdb);
|
||||
void ctdb_node_dead(struct ctdb_node *node);
|
||||
void ctdb_node_connected(struct ctdb_node *node);
|
||||
bool ctdb_blocking_freeze(struct ctdb_context *ctdb);
|
||||
void ctdb_set_scheduler(struct ctdb_context *ctdb);
|
||||
void ctdb_restore_scheduler(struct ctdb_context *ctdb);
|
||||
void ctdb_high_priority(struct ctdb_context *ctdb);
|
||||
int32_t ctdb_control_takeover_ip(struct ctdb_context *ctdb,
|
||||
struct ctdb_req_control *c,
|
||||
TDB_DATA indata,
|
||||
@ -1457,7 +1455,7 @@ void ctdb_block_signal(int signum);
|
||||
void ctdb_unblock_signal(int signum);
|
||||
int32_t ctdb_monitoring_mode(struct ctdb_context *ctdb);
|
||||
int ctdb_set_child_logging(struct ctdb_context *ctdb);
|
||||
|
||||
void ctdb_lockdown_memory(struct ctdb_context *ctdb);
|
||||
|
||||
typedef void (*client_async_callback)(struct ctdb_context *ctdb, uint32_t node_pnn, int32_t res, TDB_DATA outdata, void *callback_data);
|
||||
|
||||
|
@ -730,10 +730,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
|
||||
|
||||
DEBUG(DEBUG_ERR, ("Starting CTDBD as pid : %u\n", ctdbd_pid));
|
||||
|
||||
if (ctdb->do_setsched) {
|
||||
/* try to set us up as realtime */
|
||||
ctdb_set_scheduler(ctdb);
|
||||
}
|
||||
ctdb_high_priority(ctdb);
|
||||
|
||||
/* ensure the socket is deleted on exit of the daemon */
|
||||
domain_socket_name = talloc_strdup(talloc_autofree_context(), ctdb->daemon.name);
|
||||
@ -818,6 +815,7 @@ int ctdb_start_daemon(struct ctdb_context *ctdb, bool do_fork, bool use_syslog)
|
||||
}
|
||||
}
|
||||
|
||||
ctdb_lockdown_memory(ctdb);
|
||||
|
||||
/* go into a wait loop to allow other nodes to complete */
|
||||
event_loop_wait(ctdb->ev);
|
||||
|
@ -589,7 +589,7 @@ static int ctdb_local_attach(struct ctdb_context *ctdb, const char *db_name,
|
||||
db_name, ctdb->pnn);
|
||||
|
||||
tdb_flags = persistent? TDB_DEFAULT : TDB_CLEAR_IF_FIRST | TDB_NOSYNC;
|
||||
if (!ctdb->do_setsched) {
|
||||
if (ctdb->valgrinding) {
|
||||
tdb_flags |= TDB_NOMMAP;
|
||||
}
|
||||
tdb_flags |= TDB_DISALLOW_NESTING;
|
||||
@ -790,6 +790,9 @@ int32_t ctdb_control_db_attach(struct ctdb_context *ctdb, TDB_DATA indata,
|
||||
outdata->dptr = (uint8_t *)&db->db_id;
|
||||
outdata->dsize = sizeof(db->db_id);
|
||||
|
||||
/* Try to ensure it's locked in mem */
|
||||
ctdb_lockdown_memory(ctdb);
|
||||
|
||||
/* tell all the other nodes about this database */
|
||||
ctdb_daemon_send_control(ctdb, CTDB_BROADCAST_ALL, 0,
|
||||
persistent?CTDB_CONTROL_DB_ATTACH_PERSISTENT:
|
||||
|
@ -1019,7 +1019,7 @@ static struct tdb_wrap *create_recdb(struct ctdb_context *ctdb, TALLOC_CTX *mem_
|
||||
unlink(name);
|
||||
|
||||
tdb_flags = TDB_NOLOCK;
|
||||
if (!ctdb->do_setsched) {
|
||||
if (ctdb->valgrinding) {
|
||||
tdb_flags |= TDB_NOMMAP;
|
||||
}
|
||||
tdb_flags |= TDB_DISALLOW_NESTING;
|
||||
|
@ -516,6 +516,7 @@ static int update_tuning_db(struct ctdb_db_context *ctdb_db, struct vacuum_data
|
||||
struct vacuum_tuning_data tdata;
|
||||
struct vacuum_tuning_data *tptr;
|
||||
char *vac_dbname;
|
||||
int flags;
|
||||
|
||||
vac_dbname = talloc_asprintf(tmp_ctx, "%s/%s.%u",
|
||||
ctdb_db->ctdb->db_directory_state,
|
||||
@ -526,8 +527,10 @@ static int update_tuning_db(struct ctdb_db_context *ctdb_db, struct vacuum_data
|
||||
return -1;
|
||||
}
|
||||
|
||||
flags = ctdb_db->ctdb->valgrinding ? TDB_NOMMAP : 0;
|
||||
flags |= TDB_DISALLOW_NESTING;
|
||||
tune_tdb = tdb_open(vac_dbname, 0,
|
||||
TDB_DISALLOW_NESTING,
|
||||
flags,
|
||||
O_RDWR|O_CREAT, 0600);
|
||||
if (tune_tdb == NULL) {
|
||||
DEBUG(DEBUG_ERR,(__location__ " Failed to create/open %s\n", TUNINGDBNAME));
|
||||
@ -681,6 +684,7 @@ static int get_vacuum_interval(struct ctdb_db_context *ctdb_db)
|
||||
char *vac_dbname;
|
||||
uint interval = ctdb_db->ctdb->tunable.vacuum_default_interval;
|
||||
struct ctdb_context *ctdb = ctdb_db->ctdb;
|
||||
int flags;
|
||||
|
||||
vac_dbname = talloc_asprintf(tmp_ctx, "%s/%s.%u", ctdb->db_directory, TUNINGDBNAME, ctdb->pnn);
|
||||
if (vac_dbname == NULL) {
|
||||
@ -689,9 +693,11 @@ static int get_vacuum_interval(struct ctdb_db_context *ctdb_db)
|
||||
return interval;
|
||||
}
|
||||
|
||||
flags = ctdb_db->ctdb->valgrinding ? TDB_NOMMAP : 0;
|
||||
flags |= TDB_DISALLOW_NESTING;
|
||||
tdb = tdb_open(vac_dbname, 0,
|
||||
TDB_DISALLOW_NESTING,
|
||||
O_RDWR|O_CREAT, 0644);
|
||||
flags,
|
||||
O_RDWR|O_CREAT, 0600);
|
||||
if (!tdb) {
|
||||
DEBUG(DEBUG_ERR,("Unable to open/create database %s using default interval\n", vac_dbname));
|
||||
talloc_free(tmp_ctx);
|
||||
|
@ -42,7 +42,7 @@ static struct {
|
||||
const char *public_interface;
|
||||
const char *single_public_ip;
|
||||
const char *node_ip;
|
||||
int no_setsched;
|
||||
int valgrinding;
|
||||
int use_syslog;
|
||||
int start_as_disabled;
|
||||
int start_as_stopped;
|
||||
@ -131,7 +131,7 @@ int main(int argc, const char *argv[])
|
||||
{ "dbdir-persistent", 0, POPT_ARG_STRING, &options.db_dir_persistent, 0, "directory for persistent tdb files", NULL },
|
||||
{ "dbdir-state", 0, POPT_ARG_STRING, &options.db_dir_state, 0, "directory for internal state tdb files", NULL },
|
||||
{ "reclock", 0, POPT_ARG_STRING, &options.recovery_lock_file, 0, "location of recovery lock file", "filename" },
|
||||
{ "nosetsched", 0, POPT_ARG_NONE, &options.no_setsched, 0, "disable setscheduler SCHED_FIFO call", NULL },
|
||||
{ "valgrinding", 0, POPT_ARG_NONE, &options.valgrinding, 0, "make valgrind more effective", NULL },
|
||||
{ "syslog", 0, POPT_ARG_NONE, &options.use_syslog, 0, "log messages to syslog", NULL },
|
||||
{ "start-as-disabled", 0, POPT_ARG_NONE, &options.start_as_disabled, 0, "Node starts in disabled state", NULL },
|
||||
{ "start-as-stopped", 0, POPT_ARG_NONE, &options.start_as_stopped, 0, "Node starts in stopped state", NULL },
|
||||
@ -325,7 +325,7 @@ int main(int argc, const char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
ctdb->do_setsched = !options.no_setsched;
|
||||
ctdb->valgrinding = options.valgrinding;
|
||||
|
||||
ctdb->do_checkpublicip = !options.no_publicipcheck;
|
||||
|
||||
|
@ -452,7 +452,10 @@ static void ctdb_event_script_handler(struct event_context *ev, struct fd_event
|
||||
|
||||
/* valgrind gets overloaded if we run next script as it's still doing
|
||||
* post-execution analysis, so kill finished child here. */
|
||||
kill(state->child, SIGKILL);
|
||||
if (ctdb->valgrinding) {
|
||||
kill(state->child, SIGKILL);
|
||||
}
|
||||
|
||||
state->child = 0;
|
||||
|
||||
/* Aborted or finished all scripts? We're done. */
|
||||
|
Loading…
Reference in New Issue
Block a user