From: Sage Weil Date: Tue, 18 Jun 2013 16:20:44 +0000 (-0700) Subject: mon/PaxosService: s/get_version()/get_last_committed()/ X-Git-Tag: v0.67-rc1~175^2~19 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=29e14bafa46aeb3a245ce783463543d74ecf320e;p=ceph.git mon/PaxosService: s/get_version()/get_last_committed()/ Avoid aliasing simple accessors; use a single name instead. Also, function name overloading will throw a wrench in the class inheritance later. Signed-off-by: Sage Weil --- diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index 9901dab7def0..9adadf183788 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -38,7 +38,7 @@ #define dout_subsys ceph_subsys_mon #undef dout_prefix -#define dout_prefix _prefix(_dout, mon, get_version()) +#define dout_prefix _prefix(_dout, mon, get_last_committed()) static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) { return *_dout << "mon." << mon->name << "@" << mon->rank << "(" << mon->get_state_name() @@ -120,7 +120,7 @@ void AuthMonitor::create_initial() void AuthMonitor::update_from_paxos(bool *need_bootstrap) { dout(10) << __func__ << dendl; - version_t version = get_version(); + version_t version = get_last_committed(); version_t keys_ver = mon->key_server.get_ver(); if (version == keys_ver) return; @@ -238,12 +238,12 @@ bool AuthMonitor::should_propose(double& delay) void AuthMonitor::create_pending() { pending_auth.clear(); - dout(10) << "create_pending v " << (get_version() + 1) << dendl; + dout(10) << "create_pending v " << (get_last_committed() + 1) << dendl; } void AuthMonitor::encode_pending(MonitorDBStore::Transaction *t) { - dout(10) << __func__ << " v " << (get_version() + 1) << dendl; + dout(10) << __func__ << " v " << (get_last_committed() + 1) << dendl; bufferlist bl; @@ -257,7 +257,7 @@ void AuthMonitor::encode_pending(MonitorDBStore::Transaction *t) t->put(get_service_name(), "format_version", format_version); } - version_t version = get_version() + 1; + version_t version = get_last_committed() + 1; put_version(t, version, bl); put_last_committed(t, version); } @@ -266,7 +266,7 @@ void AuthMonitor::encode_full(MonitorDBStore::Transaction *t) { version_t version = mon->key_server.get_ver(); dout(10) << __func__ << " auth v " << version << dendl; - assert(get_version() == version); + assert(get_last_committed() == version); bufferlist full_bl; Mutex::Locker l(mon->key_server.get_lock()); @@ -288,7 +288,7 @@ void AuthMonitor::encode_full(MonitorDBStore::Transaction *t) void AuthMonitor::update_trim() { unsigned max = g_conf->paxos_max_join_drift * 2; - version_t version = get_version(); + version_t version = get_last_committed(); if (mon->is_leader() && (version > max)) set_trim_to(version - max); } @@ -543,7 +543,7 @@ bool AuthMonitor::preprocess_command(MMonCommand *m) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_version()); + mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -561,7 +561,7 @@ bool AuthMonitor::preprocess_command(MMonCommand *m) MonSession *session = m->get_session(); if (!session || (!mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_version()); + mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -630,7 +630,7 @@ bool AuthMonitor::preprocess_command(MMonCommand *m) rdata.append(ds); string rs; getline(ss, rs, '\0'); - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return true; } @@ -665,7 +665,7 @@ bool AuthMonitor::prepare_command(MMonCommand *m) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_version()); + mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -679,7 +679,7 @@ bool AuthMonitor::prepare_command(MMonCommand *m) MonSession *session = m->get_session(); if (!session || (!mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_version()); + mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -712,8 +712,8 @@ bool AuthMonitor::prepare_command(MMonCommand *m) ss << "imported keyring"; getline(ss, rs); err = 0; - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); - //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); + //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "auth add") { KeyServerData::Incremental auth_inc; @@ -753,8 +753,8 @@ bool AuthMonitor::prepare_command(MMonCommand *m) ss << "added key for " << auth_inc.name; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); - //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); + //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if ((prefix == "auth get-or-create-key" || prefix == "auth get-or-create") && @@ -798,7 +798,7 @@ bool AuthMonitor::prepare_command(MMonCommand *m) ::decode(auth_inc, q); if (auth_inc.op == KeyServerData::AUTH_INC_ADD && auth_inc.name == entity) { - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); //paxos->wait_for_commit(new C_RetryMessage(this, m)); return true; } @@ -826,8 +826,8 @@ bool AuthMonitor::prepare_command(MMonCommand *m) rdata.append(ds); getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, rdata, get_version())); - //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, rdata, get_last_committed())); + //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "auth caps" && !entity_name.empty()) { KeyServerData::Incremental auth_inc; @@ -849,8 +849,8 @@ bool AuthMonitor::prepare_command(MMonCommand *m) ss << "updated caps for " << auth_inc.name; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); - //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); + //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "auth del" && !entity_name.empty()) { KeyServerData::Incremental auth_inc; @@ -865,15 +865,15 @@ bool AuthMonitor::prepare_command(MMonCommand *m) ss << "updated"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); - //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); + //paxos->wait_for_commit(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } done: rdata.append(ds); getline(ss, rs, '\0'); - mon->reply_command(m, err, rs, rdata, get_version()); + mon->reply_command(m, err, rs, rdata, get_last_committed()); return false; } diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 19ad622bb401..065a9bccc752 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -32,7 +32,7 @@ #define dout_subsys ceph_subsys_mon #undef dout_prefix -#define dout_prefix _prefix(_dout, mon, get_version()) +#define dout_prefix _prefix(_dout, mon, get_last_committed()) static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) { return *_dout << "mon." << mon->name << "@" << mon->rank << "(" << mon->get_state_name() @@ -93,7 +93,7 @@ void LogMonitor::create_initial() void LogMonitor::update_from_paxos(bool *need_bootstrap) { dout(10) << __func__ << dendl; - version_t version = get_version(); + version_t version = get_last_committed(); dout(10) << __func__ << " version " << version << " summary v " << summary.version << dendl; if (version == summary.version) @@ -181,12 +181,12 @@ void LogMonitor::create_pending() { pending_log.clear(); pending_summary = summary; - dout(10) << "create_pending v " << (get_version() + 1) << dendl; + dout(10) << "create_pending v " << (get_last_committed() + 1) << dendl; } void LogMonitor::encode_pending(MonitorDBStore::Transaction *t) { - version_t version = get_version() + 1; + version_t version = get_last_committed() + 1; bufferlist bl; dout(10) << __func__ << " v" << version << dendl; __u8 v = 1; @@ -202,7 +202,7 @@ void LogMonitor::encode_pending(MonitorDBStore::Transaction *t) void LogMonitor::encode_full(MonitorDBStore::Transaction *t) { dout(10) << __func__ << " log v " << summary.version << dendl; - assert(get_version() == summary.version); + assert(get_last_committed() == summary.version); bufferlist summary_bl; ::encode(summary, summary_bl); @@ -214,7 +214,7 @@ void LogMonitor::encode_full(MonitorDBStore::Transaction *t) void LogMonitor::update_trim() { unsigned max = g_conf->mon_max_log_epochs; - version_t version = get_version(); + version_t version = get_last_committed(); if (mon->is_leader() && version > max) set_trim_to(version - max); } @@ -336,7 +336,7 @@ bool LogMonitor::preprocess_command(MMonCommand *m) if (r != -1) { string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -353,7 +353,7 @@ bool LogMonitor::prepare_command(MMonCommand *m) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_version()); + mon->reply_command(m, -EINVAL, rs, get_last_committed()); return true; } @@ -364,7 +364,7 @@ bool LogMonitor::prepare_command(MMonCommand *m) if (!session || (!session->is_capable("log", MON_CAP_W) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", get_version()); + mon->reply_command(m, -EACCES, "access denied", get_last_committed()); return true; } @@ -382,12 +382,12 @@ bool LogMonitor::prepare_command(MMonCommand *m) le.msg = ds.str(); pending_summary.add(le); pending_log.insert(pair(le.stamp, le)); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, string(), get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, string(), get_last_committed())); return true; } getline(ss, rs); - mon->reply_command(m, err, rs, get_version()); + mon->reply_command(m, err, rs, get_last_committed()); return false; } diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 757014257d64..35ef66af43d3 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -86,7 +86,7 @@ void MDSMonitor::create_initial() void MDSMonitor::update_from_paxos(bool *need_bootstrap) { - version_t version = get_version(); + version_t version = get_last_committed(); if (version == mdsmap.epoch) return; assert(version >= mdsmap.epoch); @@ -127,7 +127,7 @@ void MDSMonitor::encode_pending(MonitorDBStore::Transaction *t) //print_map(pending_mdsmap); // apply to paxos - assert(get_version() + 1 == pending_mdsmap.epoch); + assert(get_last_committed() + 1 == pending_mdsmap.epoch); bufferlist mdsmap_bl; pending_mdsmap.encode(mdsmap_bl, mon->get_quorum_features()); @@ -541,7 +541,7 @@ bool MDSMonitor::preprocess_command(MMonCommand *m) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_version()); + mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -552,7 +552,7 @@ bool MDSMonitor::preprocess_command(MMonCommand *m) if (!session || (!session->is_capable("mds", MON_CAP_R) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_version()); + mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -638,7 +638,7 @@ bool MDSMonitor::preprocess_command(MMonCommand *m) i != mds_info.end(); ++i) { m->cmd = args_vec; - mon->send_command(i->second.get_inst(), m->cmd, get_version()); + mon->send_command(i->second.get_inst(), m->cmd, get_last_committed()); r = 0; } if (r == -ENOENT) { @@ -652,7 +652,7 @@ bool MDSMonitor::preprocess_command(MMonCommand *m) if (!errno && who >= 0) { if (mdsmap.is_up(who)) { m->cmd = args_vec; - mon->send_command(mdsmap.get_inst(who), m->cmd, get_version()); + mon->send_command(mdsmap.get_inst(who), m->cmd, get_last_committed()); r = 0; ss << "ok"; } else { @@ -670,7 +670,7 @@ bool MDSMonitor::preprocess_command(MMonCommand *m) rdata.append(ds); string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -780,7 +780,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_version()); + mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -792,7 +792,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) if (!session || (!session->is_capable("mds", MON_CAP_W) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_version()); + mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -844,7 +844,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) map.epoch = pending_mdsmap.epoch; // make sure epoch is correct pending_mdsmap = map; string rs = "set mds map"; - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else { ss << "next mdsmap epoch " << pending_mdsmap.epoch << " != " << e; @@ -863,7 +863,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) ss << "set mds gid " << gid << " to state " << state << " " << ceph_mds_state_name(state); string rs; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } @@ -893,7 +893,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) ss << "removed mds gid " << gid; string rs; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } else if (prefix == "mds rmfailed") { @@ -904,7 +904,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) ss << "removed failed mds." << w; string rs; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "mds cluster_fail") { r = cluster_fail(ss); @@ -987,7 +987,7 @@ bool MDSMonitor::prepare_command(MMonCommand *m) ss << "new fs with metadata pool " << metadata << " and data pool " << data; string rs; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } @@ -999,11 +999,11 @@ bool MDSMonitor::prepare_command(MMonCommand *m) if (r >= 0) { // success.. delay reply - wait_for_finished_proposal(new Monitor::C_Command(mon, m, r, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, r, rs, get_last_committed())); return true; } else { // reply immediately - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return false; } } diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3691fd0b5cdd..46f05a2942b9 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -442,7 +442,7 @@ int Monitor::preinit() // we need to bootstrap authentication keys so we can form an // initial quorum. - if (authmon()->get_version() == 0) { + if (authmon()->get_last_committed() == 0) { dout(10) << "loading initial keyring to bootstrap authentication for mkfs" << dendl; bufferlist bl; store->get("mkfs", "keyring", bl); diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 20b01bd9ccb0..d04418b6391a 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -49,7 +49,7 @@ void MonmapMonitor::create_initial() void MonmapMonitor::update_from_paxos(bool *need_bootstrap) { - version_t version = get_version(); + version_t version = get_last_committed(); if (version <= mon->monmap->get_epoch()) return; @@ -100,7 +100,7 @@ void MonmapMonitor::encode_pending(MonitorDBStore::Transaction *t) void MonmapMonitor::on_active() { - if (get_version() >= 1 && !mon->has_ever_joined) { + if (get_last_committed() >= 1 && !mon->has_ever_joined) { // make note of the fact that i was, once, part of the quorum. dout(10) << "noting that i was, once, part of an active quorum." << dendl; @@ -155,7 +155,7 @@ bool MonmapMonitor::preprocess_command(MMonCommand *m) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_version()); + mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -166,7 +166,7 @@ bool MonmapMonitor::preprocess_command(MMonCommand *m) if (!session || (!session->is_capable("mon", MON_CAP_R) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", get_version()); + mon->reply_command(m, -EACCES, "access denied", get_last_committed()); return true; } @@ -234,7 +234,7 @@ bool MonmapMonitor::preprocess_command(MMonCommand *m) string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -267,7 +267,7 @@ bool MonmapMonitor::prepare_command(MMonCommand *m) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_version()); + mon->reply_command(m, -EINVAL, rs, get_last_committed()); return true; } @@ -278,7 +278,7 @@ bool MonmapMonitor::prepare_command(MMonCommand *m) if (!session || (!session->is_capable("mon", MON_CAP_R) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", get_version()); + mon->reply_command(m, -EACCES, "access denied", get_last_committed()); return true; } @@ -314,7 +314,7 @@ bool MonmapMonitor::prepare_command(MMonCommand *m) pending_map.last_changed = ceph_clock_now(g_ceph_context); ss << "added mon." << name << " at " << addr; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "mon remove") { @@ -337,7 +337,7 @@ bool MonmapMonitor::prepare_command(MMonCommand *m) ss << "removed mon." << name << " at " << addr << ", there are now " << pending_map.size() << " monitors" ; getline(ss, rs); // send reply immediately in case we get removed - mon->reply_command(m, 0, rs, get_version()); + mon->reply_command(m, 0, rs, get_last_committed()); return true; } else @@ -345,7 +345,7 @@ bool MonmapMonitor::prepare_command(MMonCommand *m) out: getline(ss, rs); - mon->reply_command(m, err, rs, get_version()); + mon->reply_command(m, err, rs, get_last_committed()); return false; } diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index 900f0d6ac199..c4b6ac03044c 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -107,7 +107,7 @@ void OSDMonitor::create_initial() void OSDMonitor::update_from_paxos(bool *need_bootstrap) { - version_t version = get_version(); + version_t version = get_last_committed(); if (version == osdmap.epoch) return; assert(version >= osdmap.epoch); @@ -499,7 +499,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::Transaction *t) } // encode - assert(get_version() + 1 == pending_inc.epoch); + assert(get_last_committed() + 1 == pending_inc.epoch); ::encode(pending_inc, bl, CEPH_FEATURES_ALL); /* put everything in the transaction */ @@ -510,7 +510,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::Transaction *t) void OSDMonitor::encode_full(MonitorDBStore::Transaction *t) { dout(10) << __func__ << " osdmap e " << osdmap.epoch << dendl; - assert(get_version() == osdmap.epoch); + assert(get_last_committed() == osdmap.epoch); bufferlist osdmap_bl; osdmap.encode(osdmap_bl); @@ -544,9 +544,9 @@ void OSDMonitor::update_trim() epoch_t floor = mon->pgmon()->pg_map.calc_min_last_epoch_clean(); dout(10) << " min_last_epoch_clean " << floor << dendl; unsigned min = g_conf->mon_min_osdmap_epochs; - if (floor + min > get_version()) { - if (min < get_version()) - floor = get_version() - min; + if (floor + min > get_last_committed()) { + if (min < get_last_committed()) + floor = get_last_committed() - min; else floor = 0; } @@ -1925,7 +1925,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_version()); + mon->reply_command(m, -EINVAL, rs, get_last_committed()); return true; } @@ -1933,7 +1933,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) if (!session || (!session->is_capable("osd", MON_CAP_R) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_version()); + mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -2038,7 +2038,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) if (whostr == "*") { for (int i = 0; i < osdmap.get_max_osd(); ++i) if (osdmap.is_up(i)) - mon->send_command(osdmap.get_inst(i), argvec, get_version()); + mon->send_command(osdmap.get_inst(i), argvec, get_last_committed()); ss << "ok"; } else { errno = 0; @@ -2047,7 +2047,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) r = -EINVAL; } else { if (osdmap.is_up(who)) { - mon->send_command(osdmap.get_inst(who), argvec, get_version()); + mon->send_command(osdmap.get_inst(who), argvec, get_last_committed()); ss << "ok"; } else { ss << "osd." << who << " not up"; @@ -2201,7 +2201,7 @@ bool OSDMonitor::preprocess_command(MMonCommand *m) reply: string rs; getline(ss, rs); - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return true; } @@ -2414,7 +2414,7 @@ bool OSDMonitor::prepare_set_flag(MMonCommand *m, int flag) pending_inc.new_flags = osdmap.get_flags(); pending_inc.new_flags |= flag; ss << "set " << OSDMap::get_flag_string(flag); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, ss.str(), get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, ss.str(), get_last_committed())); return true; } @@ -2425,7 +2425,7 @@ bool OSDMonitor::prepare_unset_flag(MMonCommand *m, int flag) pending_inc.new_flags = osdmap.get_flags(); pending_inc.new_flags &= ~flag; ss << "unset " << OSDMap::get_flag_string(flag); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, ss.str(), get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, ss.str(), get_last_committed())); return true; } @@ -2477,7 +2477,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) map cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_version()); + mon->reply_command(m, -EINVAL, rs, get_last_committed()); return true; } @@ -2485,7 +2485,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) if (!session || (!session->is_capable("osd", MON_CAP_W) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", get_version()); + mon->reply_command(m, -EACCES, "access denied", get_last_committed()); return true; } @@ -2611,7 +2611,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) ss << action << " item id " << id << " name '" << name << "' weight " << weight << " at location " << loc << " to crush map"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } while (false); @@ -2652,7 +2652,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) ss << "create-or-move updating item name '" << name << "' weight " << weight << " at location " << loc << " to crush map"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } while (false); @@ -2685,7 +2685,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) pending_inc.crush.clear(); newcrush.encode(pending_inc.crush); getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } else { @@ -2722,7 +2722,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) pending_inc.crush.clear(); newcrush.encode(pending_inc.crush); getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } else { @@ -2772,7 +2772,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) newcrush.encode(pending_inc.crush); ss << "removed item id " << id << " name '" << name << "' from crush map"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } while (false); @@ -2806,7 +2806,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) ss << "reweighted item id " << id << " name '" << name << "' to " << w << " in crush map"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } while (false); @@ -2831,7 +2831,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) newcrush.encode(pending_inc.crush); ss << "adjusted tunables profile to " << profile; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "osd crush rule create-simple") { @@ -2863,7 +2863,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) newcrush.encode(pending_inc.crush); } getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "osd crush rule rm") { @@ -2905,7 +2905,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) newcrush.encode(pending_inc.crush); } getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "osd setmaxosd") { @@ -2922,7 +2922,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) pending_inc.new_max_osd = newmax; ss << "set new max_osd = " << pending_inc.new_max_osd; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "osd pause") { @@ -3034,7 +3034,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) } if (any) { getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } else if (prefix == "osd reweight") { @@ -3052,7 +3052,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) pending_inc.new_weight[id] = ww; ss << "reweighted osd." << id << " to " << w << " (" << ios::hex << ww << ios::dec << ")"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } @@ -3070,7 +3070,7 @@ bool OSDMonitor::prepare_command(MMonCommand *m) pending_inc.new_lost[id] = e; ss << "marked osd lost in epoch " << e; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } @@ -3125,7 +3125,7 @@ done: pending_inc.new_uuid[i] = uuid; ss << i; rdata.append(ss); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, rdata, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, rdata, get_last_committed())); return true; } else if (prefix == "osd blacklist") { @@ -3147,7 +3147,7 @@ done: pending_inc.new_blacklist[addr] = expires; ss << "blacklisting " << addr << " until " << expires << " (" << d << " sec)"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (blacklistop == "rm") { if (osdmap.is_blacklisted(addr) || @@ -3158,7 +3158,7 @@ done: pending_inc.new_blacklist.erase(addr); ss << "un-blacklisting " << addr; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } ss << addr << " isn't blacklisted"; @@ -3193,7 +3193,7 @@ done: pp->set_snap_epoch(pending_inc.epoch); ss << "created pool " << poolstr << " snap " << snapname; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } @@ -3225,7 +3225,7 @@ done: pp->set_snap_epoch(pending_inc.epoch); ss << "removed pool " << poolstr << " snap " << snapname; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } @@ -3270,7 +3270,7 @@ done: ss << "pool '" << poolstr << "' created"; } getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "osd pool delete") { @@ -3297,7 +3297,7 @@ done: if (ret == 0) ss << "pool '" << poolstr << "' deleted"; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, ret, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, ret, rs, get_last_committed())); return true; } else if (prefix == "osd pool rename") { string srcpoolstr, destpoolstr; @@ -3319,7 +3319,7 @@ done: << cpp_strerror(ret); } getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, ret, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, ret, rs, get_last_committed())); return true; } } else if (prefix == "osd pool set") { @@ -3385,7 +3385,7 @@ done: } pending_inc.new_pools[pool].last_change = pending_inc.epoch; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } } else if (prefix == "osd pool set-quota") { @@ -3429,7 +3429,7 @@ done: } ss << "set-quota " << field << " = " << value << " for pool " << poolstr; rs = ss.str(); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } else if (prefix == "osd pool get") { @@ -3481,7 +3481,7 @@ done: } else { ss << "SUCCESSFUL reweight-by-utilization: " << out_str; getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } @@ -3501,12 +3501,12 @@ reply: getline(ss, rs); if (err < 0 && rs.length() == 0) rs = cpp_strerror(err); - mon->reply_command(m, err, rs, rdata, get_version()); + mon->reply_command(m, err, rs, rdata, get_last_committed()); return ret; update: getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, 0, rs, get_last_committed())); return true; } @@ -3760,7 +3760,7 @@ void OSDMonitor::_pool_op_reply(MPoolOp *m, int ret, epoch_t epoch, bufferlist * { dout(20) << "_pool_op_reply " << ret << dendl; MPoolOpReply *reply = new MPoolOpReply(m->fsid, m->get_tid(), - ret, epoch, get_version(), blp); + ret, epoch, get_last_committed(), blp); mon->send_reply(m, reply); m->put(); } diff --git a/src/mon/PGMonitor.cc b/src/mon/PGMonitor.cc index a9f3c1b6c5db..2540a7245da2 100644 --- a/src/mon/PGMonitor.cc +++ b/src/mon/PGMonitor.cc @@ -151,7 +151,7 @@ void PGMonitor::create_initial() void PGMonitor::update_from_paxos(bool *need_bootstrap) { - version_t version = get_version(); + version_t version = get_last_committed(); if (version == pg_map.version) return; assert(version >= pg_map.version); @@ -278,7 +278,7 @@ void PGMonitor::encode_pending(MonitorDBStore::Transaction *t) { version_t version = pending_inc.version; dout(10) << __func__ << " v " << version << dendl; - assert(get_version() + 1 == version); + assert(get_last_committed() + 1 == version); pending_inc.stamp = ceph_clock_now(g_ceph_context); bufferlist bl; @@ -291,7 +291,7 @@ void PGMonitor::encode_pending(MonitorDBStore::Transaction *t) void PGMonitor::encode_full(MonitorDBStore::Transaction *t) { dout(10) << __func__ << " pgmap v " << pg_map.version << dendl; - assert(get_version() == pg_map.version); + assert(get_last_committed() == pg_map.version); bufferlist full_bl; pg_map.encode(full_bl, mon->get_quorum_features()); @@ -303,7 +303,7 @@ void PGMonitor::encode_full(MonitorDBStore::Transaction *t) void PGMonitor::update_trim() { unsigned max = g_conf->mon_max_pgmap_epochs; - version_t version = get_version(); + version_t version = get_last_committed(); if (mon->is_leader() && (version > max)) set_trim_to(version - max); } @@ -371,7 +371,7 @@ void PGMonitor::handle_statfs(MStatfs *statfs) } // fill out stfs - reply = new MStatfsReply(mon->monmap->fsid, statfs->get_tid(), get_version()); + reply = new MStatfsReply(mon->monmap->fsid, statfs->get_tid(), get_last_committed()); // these are in KB. reply->h.st.kb = pg_map.osd_sum.kb; @@ -403,7 +403,7 @@ bool PGMonitor::preprocess_getpoolstats(MGetPoolStats *m) goto out; } - reply = new MGetPoolStatsReply(m->fsid, m->get_tid(), get_version()); + reply = new MGetPoolStatsReply(m->fsid, m->get_tid(), get_last_committed()); for (list::iterator p = m->pools.begin(); p != m->pools.end(); @@ -1101,7 +1101,7 @@ bool PGMonitor::preprocess_command(MMonCommand *m) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, rdata, get_version()); + mon->reply_command(m, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -1112,7 +1112,7 @@ bool PGMonitor::preprocess_command(MMonCommand *m) if (!session || (!session->is_capable("pg", MON_CAP_R) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", rdata, get_version()); + mon->reply_command(m, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1302,7 +1302,7 @@ bool PGMonitor::preprocess_command(MMonCommand *m) string rs; getline(ss, rs); rdata.append(ds); - mon->reply_command(m, r, rs, rdata, get_version()); + mon->reply_command(m, r, rs, rdata, get_last_committed()); return true; } @@ -1318,7 +1318,7 @@ bool PGMonitor::prepare_command(MMonCommand *m) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(m, -EINVAL, rs, get_version()); + mon->reply_command(m, -EINVAL, rs, get_last_committed()); return true; } @@ -1329,7 +1329,7 @@ bool PGMonitor::prepare_command(MMonCommand *m) if (!session || (!session->is_capable("pg", MON_CAP_W) && !mon->_allowed_command(session, cmdmap))) { - mon->reply_command(m, -EACCES, "access denied", get_version()); + mon->reply_command(m, -EACCES, "access denied", get_last_committed()); return true; } @@ -1378,12 +1378,12 @@ bool PGMonitor::prepare_command(MMonCommand *m) getline(ss, rs); if (r < 0 && rs.length() == 0) rs = cpp_strerror(r); - mon->reply_command(m, r, rs, get_version()); + mon->reply_command(m, r, rs, get_last_committed()); return false; update: getline(ss, rs); - wait_for_finished_proposal(new Monitor::C_Command(mon, m, r, rs, get_version())); + wait_for_finished_proposal(new Monitor::C_Command(mon, m, r, rs, get_last_committed())); return true; } diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 19d47fc316d9..d3912e87b63a 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -218,7 +218,7 @@ bool PaxosService::should_stash_full() */ return (!latest_full || (latest_full <= get_trim_to()) || - (get_version() - latest_full > (unsigned)g_conf->paxos_stash_full_interval)); + (get_last_committed() - latest_full > (unsigned)g_conf->paxos_stash_full_interval)); } void PaxosService::restart() @@ -279,7 +279,7 @@ void PaxosService::_active() have_pending = true; } - if (get_version() == 0) { + if (get_last_committed() == 0) { // create initial state create_initial(); propose_pending(); diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index deda0d0bfd84..14854e137ad2 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -851,14 +851,6 @@ public: version_t get_last_committed() { return cached_last_committed; } - /** - * Get our current version - * - * @returns Our current version - */ - version_t get_version() { - return get_last_committed(); - } /** * @}