diff options
author | Greg Farnum <gregf@hq.newdream.net> | 2010-11-10 17:11:23 +0100 |
---|---|---|
committer | Greg Farnum <gregf@hq.newdream.net> | 2010-11-10 17:14:04 +0100 |
commit | ca3693d8ffcdffc3ae95eaba506a72889829bcb5 (patch) | |
tree | 3a1413a7811c5b477a5b4ac442fdf08b9c709fcc | |
parent | osdc: Fix bad assert in ~ObjectCacher. (diff) | |
download | ceph-ca3693d8ffcdffc3ae95eaba506a72889829bcb5.tar.xz ceph-ca3693d8ffcdffc3ae95eaba506a72889829bcb5.zip |
mds: Enable --journal_check mode.
This replaces the old --shadow option, which didn't work.
It starts up the MDS daemon, then replays the journal for
another MDS, and then shuts down.
Also minimally modifies the MDSMonitor to enable this
behavior; since it requires shared state.
-rw-r--r-- | src/cmds.cc | 22 | ||||
-rw-r--r-- | src/mds/MDS.cc | 13 | ||||
-rw-r--r-- | src/mds/MDS.h | 3 | ||||
-rw-r--r-- | src/mon/MDSMonitor.cc | 12 |
4 files changed, 32 insertions, 18 deletions
diff --git a/src/cmds.cc b/src/cmds.cc index fbb4bd83642..3fe9e28559c 100644 --- a/src/cmds.cc +++ b/src/cmds.cc @@ -38,7 +38,7 @@ using namespace std; void usage() { - cerr << "usage: cmds -i name [flags] [--mds rank] [--shadow rank]\n"; + cerr << "usage: cmds -i name [flags] [--mds rank] [--journal_check]\n"; cerr << " -m monitorip:port\n"; cerr << " connect to monitor at given address\n"; cerr << " --debug_mds n\n"; @@ -53,6 +53,7 @@ int main(int argc, const char **argv) env_to_vec(args); bool dump_journal = false; const char *dump_file = NULL; + bool shadow = false; common_set_defaults(true); #ifdef HAVE_LIBTCMALLOC @@ -67,16 +68,20 @@ int main(int argc, const char **argv) // mds specific args for (unsigned i=0; i<args.size(); i++) { if (!strcmp(args[i], "--dump-journal")) { - if (i + 2 < args.size()) // another argument? + if (i + 1 < args.size() && + (args[i+1][0] != '-')) { // another argument? dump_file = args[i+1]; - else + ++i; + } else dump_file = "mds.journal.dump"; dump_journal = true; dout(0) << "dumping journal" << dendl; - ++i; + } else if (!strcmp(args[i], "--journal_check")) { + dout(0) << "checking journal" << dendl; + shadow = true; } else { - cerr << "unrecognized arg " << args[i] << std::endl; - usage(); + cerr << "unrecognized arg " << args[i] << std::endl; + usage(); } } if (!g_conf.id) { @@ -130,7 +135,10 @@ int main(int argc, const char **argv) mds->orig_argc = argc; mds->orig_argv = argv; - mds->init(); + if (shadow) + mds->init(MDSMap::STATE_STANDBY); + else + mds->init(); messenger->wait(); diff --git a/src/mds/MDS.cc b/src/mds/MDS.cc index f155b7edf82..8a15be250d4 100644 --- a/src/mds/MDS.cc +++ b/src/mds/MDS.cc @@ -81,7 +81,6 @@ MDS::MDS(const char *n, Messenger *m, MonClient *mc) : name(n), whoami(-1), incarnation(0), standby_for_rank(-1), - standby_replay_for(-1), messenger(m), monc(mc), logclient(messenger, &mc->monmap, mc), @@ -418,7 +417,7 @@ void MDS::send_message_client(Message *m, Session *session) } } -int MDS::init() +int MDS::init(int wanted_state) { dout(10) << sizeof(MDSCacheObject) << "\tMDSCacheObject" << dendl; dout(10) << sizeof(CInode) << "\tCInode" << dendl; @@ -454,7 +453,9 @@ int MDS::init() mds_lock.Lock(); // starting beacon. this will induce an MDSMap from the monitor - want_state = MDSMap::STATE_BOOT; + want_state = wanted_state; + if (wanted_state == MDSMap::STATE_STANDBY && g_conf.id) + standby_for_rank = strtol(g_conf.id, NULL, 0); beacon_start(); whoami = -1; messenger->set_myname(entity_name_t::MDS(whoami)); @@ -837,7 +838,7 @@ void MDS::handle_mds_map(MMDSMap *m) want_state = state = MDSMap::STATE_STANDBY; dout(1) << "handle_mds_map standby" << dendl; - if (standby_replay_for >= 0) + if (standby_for_rank >= 0) request_state(MDSMap::STATE_STANDBY_REPLAY); goto out; @@ -860,7 +861,6 @@ void MDS::handle_mds_map(MMDSMap *m) } // ?? - assert(whoami >= 0); incarnation = mdsmap->get_inc(whoami); if (oldwhoami != whoami) @@ -984,7 +984,8 @@ void MDS::handle_mds_map(MMDSMap *m) mdcache->migrator->handle_mds_failure_or_stop(*p); } - balancer->try_rebalance(); + if (standby_for_rank < 0) //if we're not replaying + balancer->try_rebalance(); out: m->put(); diff --git a/src/mds/MDS.h b/src/mds/MDS.h index eb34c88752b..787211365b9 100644 --- a/src/mds/MDS.h +++ b/src/mds/MDS.h @@ -148,7 +148,6 @@ class MDS : public Dispatcher { int standby_for_rank; string standby_for_name; - int standby_replay_for; Messenger *messenger; MonClient *monc; @@ -339,7 +338,7 @@ class MDS : public Dispatcher { void send_message(Message *m, Connection *c); // start up, shutdown - int init(); + int init(int wanted_state=MDSMap::STATE_BOOT); void open_logger(); diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 70f945c098f..4c591da81df 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -206,7 +206,9 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m) goto out; } - if (mdsmap.get_epoch() != m->get_last_epoch_seen()) { + if (mdsmap.get_epoch() != m->get_last_epoch_seen() + && !((info.state == MDSMap::STATE_STANDBY) || + (info.state == MDSMap::STATE_STANDBY_REPLAY))){ dout(10) << "mds_beacon " << *m << " ignoring requested state, because mds hasn't seen latest map" << dendl; goto ignore; @@ -233,8 +235,10 @@ bool MDSMonitor::preprocess_beacon(MMDSBeacon *m) if (info.state == MDSMap::STATE_STANDBY && state == MDSMap::STATE_STANDBY_REPLAY && (pending_mdsmap.is_degraded() || - pending_mdsmap.get_state(info.rank) < MDSMap::STATE_ACTIVE)) { - dout(10) << "mds_beacon can't standby-replay mds" << info.rank << " at this time (cluster degraded, or mds not active)" << dendl; + pending_mdsmap.get_state(m->get_standby_for_rank()) < MDSMap::STATE_ACTIVE)) { + dout(10) << "mds_beacon can't standby-replay mds" << m->get_standby_for_rank() << " at this time (cluster degraded, or mds not active)" << dendl; + dout(10) << "pending_mdsmap.is_degraded()==" << pending_mdsmap.is_degraded() + << " rank state: " << ceph_mds_state_name(pending_mdsmap.get_state(m->get_standby_for_rank())) << dendl; goto ignore; } _note_beacon(m); @@ -363,6 +367,8 @@ bool MDSMonitor::prepare_beacon(MMDSBeacon *m) } else { info.state = state; info.state_seq = seq; + if (state == MDSMap::STATE_STANDBY_REPLAY) + info.rank = m->get_standby_for_rank(); } } |