summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSage Weil <sage@inktank.com>2013-07-22 14:47:18 -0700
committerSage Weil <sage@inktank.com>2013-07-22 14:47:18 -0700
commit3f95f9a45e34af78449427db315321185e87cbcc (patch)
tree582df3dd7486f4fb32659018a12755527205195e /src
parentc7edf03691a5cc86726e687d9a140a4fefb07a97 (diff)
parentc3acc256088a3da36c964d149263058ec647b6b2 (diff)
downloadceph-3f95f9a45e34af78449427db315321185e87cbcc.tar.gz
Merge remote-tracking branch 'gh/wip-5624-b' into next
Reviewed-by: David Zafman <david.zafman@inktank.com>
Diffstat (limited to 'src')
-rw-r--r--src/ceph_mds.cc27
-rw-r--r--src/ceph_mon.cc9
-rw-r--r--src/ceph_osd.cc15
-rw-r--r--src/common/config_opts.h2
-rw-r--r--src/mds/MDS.cc7
-rw-r--r--src/mon/Monitor.cc4
-rw-r--r--src/osd/OSD.cc7
7 files changed, 42 insertions, 29 deletions
diff --git a/src/ceph_mds.cc b/src/ceph_mds.cc
index edb48bd96d8..88b807b1b24 100644
--- a/src/ceph_mds.cc
+++ b/src/ceph_mds.cc
@@ -274,12 +274,6 @@ int main(int argc, const char **argv)
messenger->start();
- // set up signal handlers, now that we've daemonized/forked.
- init_async_signal_handler();
- register_async_signal_handler(SIGHUP, sighup_handler);
- register_async_signal_handler_oneshot(SIGINT, handle_mds_signal);
- register_async_signal_handler_oneshot(SIGTERM, handle_mds_signal);
-
// start mds
mds = new MDS(g_conf->name.get_id().c_str(), messenger, &mc);
@@ -291,16 +285,26 @@ int main(int argc, const char **argv)
r = mds->init(shadow);
else
r = mds->init();
+ if (r < 0)
+ goto shutdown;
- if (r >= 0) {
- messenger->wait();
- }
+ // set up signal handlers, now that we've daemonized/forked.
+ init_async_signal_handler();
+ register_async_signal_handler(SIGHUP, sighup_handler);
+ register_async_signal_handler_oneshot(SIGINT, handle_mds_signal);
+ register_async_signal_handler_oneshot(SIGTERM, handle_mds_signal);
+
+ if (g_conf->inject_early_sigterm)
+ kill(getpid(), SIGTERM);
+
+ messenger->wait();
unregister_async_signal_handler(SIGHUP, sighup_handler);
unregister_async_signal_handler(SIGINT, handle_mds_signal);
unregister_async_signal_handler(SIGTERM, handle_mds_signal);
shutdown_async_signal_handler();
+ shutdown:
// yuck: grab the mds lock, so we can be sure that whoever in *mds
// called shutdown finishes what they were doing.
mds->mds_lock.Lock();
@@ -313,14 +317,15 @@ int main(int argc, const char **argv)
if (mds->is_stopped())
delete mds;
+ g_ceph_context->put();
+
// cd on exit, so that gmon.out (if any) goes into a separate directory for each node.
char s[20];
snprintf(s, sizeof(s), "gmon/%d", getpid());
if ((mkdir(s, 0755) == 0) && (chdir(s) == 0)) {
- dout(0) << "ceph-mds: gmon.out should be in " << s << dendl;
+ cerr << "ceph-mds: gmon.out should be in " << s << std::endl;
}
- generic_dout(0) << "stopped." << dendl;
return 0;
}
diff --git a/src/ceph_mon.cc b/src/ceph_mon.cc
index 6ac22ba20e5..35ed56a7985 100644
--- a/src/ceph_mon.cc
+++ b/src/ceph_mon.cc
@@ -542,15 +542,18 @@ int main(int argc, const char **argv)
if (g_conf->daemonize)
prefork.daemonize();
+ messenger->start();
+
+ mon->init();
+
// set up signal handlers, now that we've daemonized/forked.
init_async_signal_handler();
register_async_signal_handler(SIGHUP, sighup_handler);
register_async_signal_handler_oneshot(SIGINT, handle_mon_signal);
register_async_signal_handler_oneshot(SIGTERM, handle_mon_signal);
- messenger->start();
-
- mon->init();
+ if (g_conf->inject_early_sigterm)
+ kill(getpid(), SIGTERM);
messenger->wait();
diff --git a/src/ceph_osd.cc b/src/ceph_osd.cc
index b485133514e..d8590bff817 100644
--- a/src/ceph_osd.cc
+++ b/src/ceph_osd.cc
@@ -451,12 +451,6 @@ int main(int argc, const char **argv)
messenger_hb_back_server->start();
cluster_messenger->start();
- // install signal handlers
- init_async_signal_handler();
- register_async_signal_handler(SIGHUP, sighup_handler);
- register_async_signal_handler_oneshot(SIGINT, handle_osd_signal);
- register_async_signal_handler_oneshot(SIGTERM, handle_osd_signal);
-
// start osd
err = osd->init();
if (err < 0) {
@@ -465,6 +459,15 @@ int main(int argc, const char **argv)
return 1;
}
+ // install signal handlers
+ init_async_signal_handler();
+ register_async_signal_handler(SIGHUP, sighup_handler);
+ register_async_signal_handler_oneshot(SIGINT, handle_osd_signal);
+ register_async_signal_handler_oneshot(SIGTERM, handle_osd_signal);
+
+ if (g_conf->inject_early_sigterm)
+ kill(getpid(), SIGTERM);
+
client_messenger->wait();
messenger_hbclient->wait();
messenger_hb_front_server->wait();
diff --git a/src/common/config_opts.h b/src/common/config_opts.h
index ff23ba56232..d16dfe0061a 100644
--- a/src/common/config_opts.h
+++ b/src/common/config_opts.h
@@ -123,6 +123,8 @@ OPTION(ms_inject_delay_max, OPT_DOUBLE, 1) // seconds
OPTION(ms_inject_delay_probability, OPT_DOUBLE, 0) // range [0, 1]
OPTION(ms_inject_internal_delays, OPT_DOUBLE, 0) // seconds
+OPTION(inject_early_sigterm, OPT_BOOL, false)
+
OPTION(mon_data, OPT_STR, "/var/lib/ceph/mon/$cluster-$id")
OPTION(mon_initial_members, OPT_STR, "") // list of initial cluster mon ids; if specified, need majority to form initial quorum and create new cluster
OPTION(mon_sync_fs_threshold, OPT_INT, 5) // sync() when writing this many objects; 0 to disable.
diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc
index a867961ccf3..e70d6fd4dff 100644
--- a/src/mds/MDS.cc
+++ b/src/mds/MDS.cc
@@ -1628,19 +1628,18 @@ void MDS::suicide()
}
timer.cancel_all_events();
//timer.join();
+ timer.shutdown();
// shut down cache
mdcache->shutdown();
if (objecter->initialized)
objecter->shutdown_locked();
-
- // shut down messenger
- messenger->shutdown();
monc->shutdown();
- timer.shutdown();
+ // shut down messenger
+ messenger->shutdown();
}
void MDS::respawn()
diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc
index 7e484e8db6b..f537c915945 100644
--- a/src/mon/Monitor.cc
+++ b/src/mon/Monitor.cc
@@ -605,13 +605,13 @@ void Monitor::shutdown()
finish_contexts(g_ceph_context, waitfor_quorum, -ECANCELED);
finish_contexts(g_ceph_context, maybe_wait_for_quorum, -ECANCELED);
-
timer.shutdown();
+ remove_all_sessions();
+
// unlock before msgr shutdown...
lock.Unlock();
- remove_all_sessions();
messenger->shutdown(); // last thing! ceph_mon.cc will delete mon.
}
diff --git a/src/osd/OSD.cc b/src/osd/OSD.cc
index 464ed770df2..3f226cec95d 100644
--- a/src/osd/OSD.cc
+++ b/src/osd/OSD.cc
@@ -4739,11 +4739,12 @@ bool OSDService::prepare_to_stop()
if (state != NOT_STOPPING)
return false;
- if (get_osdmap()->is_up(whoami)) {
+ OSDMapRef osdmap = get_osdmap();
+ if (osdmap && osdmap->is_up(whoami)) {
state = PREPARING_TO_STOP;
monc->send_mon_message(new MOSDMarkMeDown(monc->get_fsid(),
- get_osdmap()->get_inst(whoami),
- get_osdmap()->get_epoch(),
+ osdmap->get_inst(whoami),
+ osdmap->get_epoch(),
false
));
utime_t now = ceph_clock_now(g_ceph_context);