diff options
author | Kefu Chai <kchai@redhat.com> | 2020-11-28 12:08:26 +0100 |
---|---|---|
committer | Kefu Chai <kchai@redhat.com> | 2020-12-06 16:15:39 +0100 |
commit | e4bf716bfa077ba21e40ae5ddfba027d89f0827d (patch) | |
tree | 0a4b663997b6f16b2779eab37b3055e87ac2b3f5 | |
parent | mon: use unique_ptr<> to manage lifecycle of Monitor::paxos (diff) | |
download | ceph-e4bf716bfa077ba21e40ae5ddfba027d89f0827d.tar.xz ceph-e4bf716bfa077ba21e40ae5ddfba027d89f0827d.zip |
mon: store a reference as member variable
before this change, we always have a valid pointer as member variable.
so, a reference serve this purpose better.
Signed-off-by: Kefu Chai <kchai@redhat.com>
-rw-r--r-- | src/mon/AuthMonitor.cc | 180 | ||||
-rw-r--r-- | src/mon/AuthMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/ConfigMonitor.cc | 70 | ||||
-rw-r--r-- | src/mon/ConfigMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/HealthMonitor.cc | 90 | ||||
-rw-r--r-- | src/mon/HealthMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/LogMonitor.cc | 52 | ||||
-rw-r--r-- | src/mon/LogMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/MDSMonitor.cc | 176 | ||||
-rw-r--r-- | src/mon/MDSMonitor.h | 4 | ||||
-rw-r--r-- | src/mon/MgrMonitor.cc | 126 | ||||
-rw-r--r-- | src/mon/MgrMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/MgrStatMonitor.cc | 72 | ||||
-rw-r--r-- | src/mon/MgrStatMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/Monitor.cc | 26 | ||||
-rw-r--r-- | src/mon/Monitor.h | 12 | ||||
-rw-r--r-- | src/mon/MonmapMonitor.cc | 160 | ||||
-rw-r--r-- | src/mon/MonmapMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/OSDMonitor.cc | 412 | ||||
-rw-r--r-- | src/mon/OSDMonitor.h | 2 | ||||
-rw-r--r-- | src/mon/Paxos.cc | 200 | ||||
-rw-r--r-- | src/mon/Paxos.h | 4 | ||||
-rw-r--r-- | src/mon/PaxosService.cc | 64 | ||||
-rw-r--r-- | src/mon/PaxosService.h | 42 |
24 files changed, 852 insertions, 854 deletions
diff --git a/src/mon/AuthMonitor.cc b/src/mon/AuthMonitor.cc index bdc0c64738a..2b27dc6f530 100644 --- a/src/mon/AuthMonitor.cc +++ b/src/mon/AuthMonitor.cc @@ -69,9 +69,9 @@ using ceph::make_message; using ceph::mono_clock; using ceph::mono_time; using ceph::timespan_str; -static ostream& _prefix(std::ostream *_dout, Monitor *mon, version_t v) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() +static ostream& _prefix(std::ostream *_dout, Monitor &mon, version_t v) { + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").auth v" << v << " "; } @@ -84,7 +84,7 @@ bool AuthMonitor::check_rotate() { KeyServerData::Incremental rot_inc; rot_inc.op = KeyServerData::AUTH_INC_SET_ROTATING; - if (!mon->key_server.updated_rotating(rot_inc.rotating_bl, last_rotating_ver)) + if (!mon.key_server.updated_rotating(rot_inc.rotating_bl, last_rotating_ver)) return false; dout(10) << __func__ << " updated rotating" << dendl; push_cephx_inc(rot_inc); @@ -105,23 +105,23 @@ void AuthMonitor::tick() bool propose = false; bool increase; { - std::lock_guard l(mon->auth_lock); + std::lock_guard l(mon.auth_lock); increase = _should_increase_max_global_id(); } if (increase) { - if (mon->is_leader()) { + if (mon.is_leader()) { increase_max_global_id(); propose = true; } else { dout(10) << __func__ << "requesting more ids from leader" << dendl; - int leader = mon->get_leader(); + int leader = mon.get_leader(); MMonGlobalID *req = new MMonGlobalID(); req->old_max_id = max_global_id; - mon->send_mon_message(req, leader); + mon.send_mon_message(req, leader); } } - if (!mon->is_leader()) { + if (!mon.is_leader()) { return; } @@ -138,13 +138,13 @@ void AuthMonitor::on_active() { dout(10) << "AuthMonitor::on_active()" << dendl; - if (!mon->is_leader()) + if (!mon.is_leader()) return; - mon->key_server.start_server(); + mon.key_server.start_server(); bool increase; { - std::lock_guard l(mon->auth_lock); + std::lock_guard l(mon.auth_lock); increase = _should_increase_max_global_id(); } if (is_writeable() && increase) { @@ -166,7 +166,7 @@ void AuthMonitor::get_initial_keyring(KeyRing *keyring) ceph_assert(keyring != nullptr); bufferlist bl; - int ret = mon->store->get("mkfs", "keyring", bl); + int ret = mon.store->get("mkfs", "keyring", bl); if (ret == -ENOENT) { return; } @@ -241,12 +241,12 @@ void AuthMonitor::create_initial() dout(10) << "create_initial -- creating initial map" << dendl; // initialize rotating keys - mon->key_server.clear_secrets(); + mon.key_server.clear_secrets(); last_rotating_ver = 0; check_rotate(); ceph_assert(pending_auth.size() == 1); - if (mon->is_keyring_required()) { + if (mon.is_keyring_required()) { KeyRing keyring; // attempt to obtain an existing mkfs-time keyring get_initial_keyring(&keyring); @@ -272,7 +272,7 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) load_health(); version_t version = get_last_committed(); - version_t keys_ver = mon->key_server.get_ver(); + version_t keys_ver = mon.key_server.get_ver(); if (version == keys_ver) return; ceph_assert(version > keys_ver); @@ -293,12 +293,12 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) __u8 struct_v; decode(struct_v, p); decode(max_global_id, p); - decode(mon->key_server, p); - mon->key_server.set_ver(latest_full); + decode(mon.key_server, p); + mon.key_server.set_ver(latest_full); keys_ver = latest_full; } - dout(10) << __func__ << " key server version " << mon->key_server.get_ver() << dendl; + dout(10) << __func__ << " key server version " << mon.key_server.get_ver() << dendl; // walk through incrementals while (version > keys_ver) { @@ -311,7 +311,7 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) // keys in here temporarily for bootstrapping that we need to // clear out. if (keys_ver == 0) - mon->key_server.clear_secrets(); + mon.key_server.clear_secrets(); dout(20) << __func__ << " walking through version " << (keys_ver+1) << " len " << bl.length() << dendl; @@ -332,24 +332,24 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) KeyServerData::Incremental auth_inc; auto iter = inc.auth_data.cbegin(); decode(auth_inc, iter); - mon->key_server.apply_data_incremental(auth_inc); + mon.key_server.apply_data_incremental(auth_inc); break; } } } keys_ver++; - mon->key_server.set_ver(keys_ver); + mon.key_server.set_ver(keys_ver); - if (keys_ver == 1 && mon->is_keyring_required()) { + if (keys_ver == 1 && mon.is_keyring_required()) { auto t(std::make_shared<MonitorDBStore::Transaction>()); t->erase("mkfs", "keyring"); - mon->store->apply_transaction(t); + mon.store->apply_transaction(t); } } { - std::lock_guard l(mon->auth_lock); + std::lock_guard l(mon.auth_lock); if (last_allocated_id == 0) { last_allocated_id = max_global_id; dout(10) << __func__ << " last_allocated_id initialized to " @@ -364,7 +364,7 @@ void AuthMonitor::update_from_paxos(bool *need_bootstrap) bool AuthMonitor::_should_increase_max_global_id() { - ceph_assert(ceph_mutex_is_locked(mon->auth_lock)); + ceph_assert(ceph_mutex_is_locked(mon.auth_lock)); auto num_prealloc = g_conf()->mon_globalid_prealloc; if (max_global_id < num_prealloc || (last_allocated_id + 1) >= max_global_id - num_prealloc / 2) { @@ -375,7 +375,7 @@ bool AuthMonitor::_should_increase_max_global_id() void AuthMonitor::increase_max_global_id() { - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); Incremental inc; inc.inc_type = GLOBAL_ID; @@ -405,7 +405,7 @@ void AuthMonitor::encode_pending(MonitorDBStore::TransactionRef t) encode(v, bl); vector<Incremental>::iterator p; for (p = pending_auth.begin(); p != pending_auth.end(); ++p) - p->encode(bl, mon->get_quorum_con_features()); + p->encode(bl, mon.get_quorum_con_features()); version_t version = get_last_committed() + 1; put_version(t, version, bl); @@ -414,8 +414,8 @@ void AuthMonitor::encode_pending(MonitorDBStore::TransactionRef t) // health health_check_map_t next; map<string,list<string>> bad_detail; // entity -> details - for (auto i = mon->key_server.secrets_begin(); - i != mon->key_server.secrets_end(); + for (auto i = mon.key_server.secrets_begin(); + i != mon.key_server.secrets_end(); ++i) { for (auto& p : i->second.caps) { ostringstream ss; @@ -461,7 +461,7 @@ void AuthMonitor::encode_pending(MonitorDBStore::TransactionRef t) void AuthMonitor::encode_full(MonitorDBStore::TransactionRef t) { - version_t version = mon->key_server.get_ver(); + version_t version = mon.key_server.get_ver(); // do not stash full version 0 as it will never be removed nor read if (version == 0) return; @@ -470,14 +470,14 @@ void AuthMonitor::encode_full(MonitorDBStore::TransactionRef t) ceph_assert(get_last_committed() == version); bufferlist full_bl; - std::scoped_lock l{mon->key_server.get_lock()}; + std::scoped_lock l{mon.key_server.get_lock()}; dout(20) << __func__ << " key server has " - << (mon->key_server.has_secrets() ? "" : "no ") + << (mon.key_server.has_secrets() ? "" : "no ") << "secrets!" << dendl; __u8 v = 1; encode(v, full_bl); encode(max_global_id, full_bl); - encode(mon->key_server, full_bl); + encode(mon.key_server, full_bl); put_version_full(t, version, full_bl); put_version_latest_full(t, version); @@ -487,7 +487,7 @@ version_t AuthMonitor::get_trim_to() const { unsigned max = g_conf()->paxos_max_join_drift * 2; version_t version = get_last_committed(); - if (mon->is_leader() && (version > max)) + if (mon.is_leader() && (version > max)) return version - max; return 0; } @@ -502,7 +502,7 @@ bool AuthMonitor::preprocess_query(MonOpRequestRef op) return preprocess_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } @@ -528,7 +528,7 @@ bool AuthMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } case MSG_MON_GLOBAL_ID: @@ -544,14 +544,14 @@ bool AuthMonitor::prepare_update(MonOpRequestRef op) void AuthMonitor::_set_mon_num_rank(int num, int rank) { dout(10) << __func__ << " num " << num << " rank " << rank << dendl; - ceph_assert(ceph_mutex_is_locked(mon->auth_lock)); + ceph_assert(ceph_mutex_is_locked(mon.auth_lock)); mon_num = num; mon_rank = rank; } uint64_t AuthMonitor::_assign_global_id() { - ceph_assert(ceph_mutex_is_locked(mon->auth_lock)); + ceph_assert(ceph_mutex_is_locked(mon.auth_lock)); if (mon_num < 1 || mon_rank < 0) { dout(10) << __func__ << " inactive (num_mon " << mon_num << " rank " << mon_rank << ")" << dendl; @@ -584,13 +584,13 @@ uint64_t AuthMonitor::assign_global_id(bool should_increase_max) { uint64_t id; { - std::lock_guard l(mon->auth_lock); + std::lock_guard l(mon.auth_lock); id =_assign_global_id(); if (should_increase_max) { should_increase_max = _should_increase_max_global_id(); } } - if (mon->is_leader() && + if (mon.is_leader() && should_increase_max) { increase_max_global_id(); } @@ -688,11 +688,11 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) entity_name.get_type() == CEPH_ENTITY_TYPE_OSD || entity_name.get_type() == CEPH_ENTITY_TYPE_MDS || entity_name.get_type() == CEPH_ENTITY_TYPE_MGR) - type = mon->auth_cluster_required.pick(supported); + type = mon.auth_cluster_required.pick(supported); else - type = mon->auth_service_required.pick(supported); + type = mon.auth_service_required.pick(supported); - s->auth_handler = get_auth_service_handler(type, g_ceph_context, &mon->key_server); + s->auth_handler = get_auth_service_handler(type, g_ceph_context, &mon.key_server); if (!s->auth_handler) { dout(1) << "client did not provide supported auth type" << dendl; ret = -ENOTSUP; @@ -716,18 +716,18 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) delete s->auth_handler; s->auth_handler = NULL; - if (mon->is_leader() && paxos_writable) { + if (mon.is_leader() && paxos_writable) { dout(10) << "increasing global id, waitlisting message" << dendl; wait_for_active(op, new C_RetryMessage(this, op)); goto done; } - if (!mon->is_leader()) { + if (!mon.is_leader()) { dout(10) << "not the leader, requesting more ids from leader" << dendl; - int leader = mon->get_leader(); + int leader = mon.get_leader(); MMonGlobalID *req = new MMonGlobalID(); req->old_max_id = max_global_id; - mon->send_mon_message(req, leader); + mon.send_mon_message(req, leader); wait_for_finished_proposal(op, new C_RetryMessage(this, op)); return true; } @@ -761,7 +761,7 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) } if (ret > 0) { if (!s->authenticated && - mon->ms_handle_authentication(s->con.get()) > 0) { + mon.ms_handle_authentication(s->con.get()) > 0) { finished = true; } ret = 0; @@ -773,13 +773,13 @@ bool AuthMonitor::prep_auth(MonOpRequestRef op, bool paxos_writable) reply: reply = new MAuthReply(proto, &response_bl, ret, s->con->peer_global_id); - mon->send_reply(op, reply); + mon.send_reply(op, reply); if (finished) { // always send the latest monmap. - if (m->monmap_epoch < mon->monmap->get_epoch()) - mon->send_latest_monmap(m->get_connection().get()); + if (m->monmap_epoch < mon.monmap->get_epoch()) + mon.send_latest_monmap(m->get_connection().get()); - mon->configmon()->check_sub(s); + mon.configmon()->check_sub(s); } done: return true; @@ -796,7 +796,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -815,7 +815,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -825,7 +825,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) EntityName entity; if (!entity_name.empty() && !entity.from_str(entity_name)) { ss << "invalid entity_auth " << entity_name; - mon->reply_command(op, -EINVAL, ss.str(), get_last_committed()); + mon.reply_command(op, -EINVAL, ss.str(), get_last_committed()); return true; } @@ -863,7 +863,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) } else if (prefix == "auth get" && !entity_name.empty()) { KeyRing keyring; EntityAuth entity_auth; - if(!mon->key_server.get_auth(entity, entity_auth)) { + if(!mon.key_server.get_auth(entity, entity_auth)) { ss << "failed to find " << entity_name << " in keyring"; r = -ENOENT; } else { @@ -879,7 +879,7 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) prefix == "auth print_key" || prefix == "auth get-key") { EntityAuth auth; - if (!mon->key_server.get_auth(entity, auth)) { + if (!mon.key_server.get_auth(entity, auth)) { ss << "don't have " << entity; r = -ENOENT; goto done; @@ -893,9 +893,9 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) } else if (prefix == "auth list" || prefix == "auth ls") { if (f) { - mon->key_server.encode_formatted("auth", f.get(), rdata); + mon.key_server.encode_formatted("auth", f.get(), rdata); } else { - mon->key_server.encode_plaintext(rdata); + mon.key_server.encode_plaintext(rdata); if (rdata.length() > 0) ss << "installed auth entries:" << std::endl; else @@ -912,13 +912,13 @@ bool AuthMonitor::preprocess_command(MonOpRequestRef op) rdata.append(ds); string rs; getline(ss, rs, '\0'); - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return true; } void AuthMonitor::export_keyring(KeyRing& keyring) { - mon->key_server.export_keyring(keyring); + mon.key_server.export_keyring(keyring); } int AuthMonitor::import_keyring(KeyRing& keyring) @@ -941,7 +941,7 @@ int AuthMonitor::import_keyring(KeyRing& keyring) int AuthMonitor::remove_entity(const EntityName &entity) { dout(10) << __func__ << " " << entity << dendl; - if (!mon->key_server.contains(entity)) + if (!mon.key_server.contains(entity)) return -ENOENT; KeyServerData::Incremental auth_inc; @@ -991,7 +991,7 @@ int AuthMonitor::exists_and_matches_entity( EntityAuth existing_auth; // does entry already exist? - if (mon->key_server.get_auth(name, existing_auth)) { + if (mon.key_server.get_auth(name, existing_auth)) { // key match? if (has_secret) { if (existing_auth.key.get_secret().cmp(auth.key.get_secret())) { @@ -1044,7 +1044,7 @@ int AuthMonitor::validate_osd_destroy( EntityName& lockbox_entity, stringstream& ss) { - ceph_assert(paxos->is_plugged()); + ceph_assert(paxos.is_plugged()); dout(10) << __func__ << " id " << id << " uuid " << uuid << dendl; @@ -1065,8 +1065,8 @@ int AuthMonitor::validate_osd_destroy( return -EINVAL; } - if (!mon->key_server.contains(cephx_entity) && - !mon->key_server.contains(lockbox_entity)) { + if (!mon.key_server.contains(cephx_entity) && + !mon.key_server.contains(lockbox_entity)) { return -ENOENT; } @@ -1077,7 +1077,7 @@ int AuthMonitor::do_osd_destroy( const EntityName& cephx_entity, const EntityName& lockbox_entity) { - ceph_assert(paxos->is_plugged()); + ceph_assert(paxos.is_plugged()); dout(10) << __func__ << " cephx " << cephx_entity << " lockbox " << lockbox_entity << dendl; @@ -1232,7 +1232,7 @@ int AuthMonitor::do_osd_new( const auth_entity_t& lockbox_entity, bool has_lockbox) { - ceph_assert(paxos->is_plugged()); + ceph_assert(paxos.is_plugged()); dout(10) << __func__ << " cephx " << cephx_entity.name << " lockbox "; @@ -1246,7 +1246,7 @@ int AuthMonitor::do_osd_new( // we must have validated before reaching this point. // if keys exist, then this means they also match; otherwise we would // have failed before calling this function. - bool cephx_exists = mon->key_server.contains(cephx_entity.name); + bool cephx_exists = mon.key_server.contains(cephx_entity.name); if (!cephx_exists) { int err = add_entity(cephx_entity.name, cephx_entity.auth); @@ -1254,7 +1254,7 @@ int AuthMonitor::do_osd_new( } if (has_lockbox && - !mon->key_server.contains(lockbox_entity.name)) { + !mon.key_server.contains(lockbox_entity.name)) { int err = add_entity(lockbox_entity.name, lockbox_entity.auth); ceph_assert(0 == err); } @@ -1334,7 +1334,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -1351,7 +1351,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1375,7 +1375,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) if (bl.length() == 0) { ss << "auth import: no data supplied"; getline(ss, rs); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } auto iter = bl.cbegin(); @@ -1391,7 +1391,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) if (err < 0) { ss << "auth import: no caps supplied"; getline(ss, rs); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } ss << "imported keyring"; @@ -1519,7 +1519,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) // do we have it? EntityAuth entity_auth; - if (mon->key_server.get_auth(entity, entity_auth)) { + if (mon.key_server.get_auth(entity, entity_auth)) { for (const auto &sys_cap : wanted_caps) { if (entity_auth.caps.count(sys_cap.first) == 0 || !entity_auth.caps[sys_cap.first].contents_equal(sys_cap.second)) { @@ -1607,7 +1607,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) std::shared_ptr<const Filesystem> fs; if (filesystem != "*" && filesystem != "all") { - fs = mon->mdsmon()->get_fsmap().get_filesystem(filesystem); + fs = mon.mdsmon()->get_fsmap().get_filesystem(filesystem); if (fs == nullptr) { ss << "filesystem " << filesystem << " does not exist."; err = -EINVAL; @@ -1691,7 +1691,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) } EntityAuth entity_auth; - if (mon->key_server.get_auth(entity, entity_auth)) { + if (mon.key_server.get_auth(entity, entity_auth)) { for (const auto &sys_cap : wanted_caps) { if (entity_auth.caps.count(sys_cap.first) == 0 || !entity_auth.caps[sys_cap.first].contents_equal(sys_cap.second)) { @@ -1741,7 +1741,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) } else if (prefix == "auth caps" && !entity_name.empty()) { KeyServerData::Incremental auth_inc; auth_inc.name = entity; - if (!mon->key_server.get_auth(auth_inc.name, auth_inc.auth)) { + if (!mon.key_server.get_auth(auth_inc.name, auth_inc.auth)) { ss << "couldn't find entry " << auth_inc.name; err = -ENOENT; goto done; @@ -1770,7 +1770,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) !entity_name.empty()) { KeyServerData::Incremental auth_inc; auth_inc.name = entity; - if (!mon->key_server.contains(auth_inc.name)) { + if (!mon.key_server.contains(auth_inc.name)) { ss << "entity " << entity << " does not exist"; err = 0; goto done; @@ -1787,7 +1787,7 @@ bool AuthMonitor::prepare_command(MonOpRequestRef op) done: rdata.append(ds); getline(ss, rs, '\0'); - mon->reply_command(op, err, rs, rdata, get_last_committed()); + mon.reply_command(op, err, rs, rdata, get_last_committed()); return false; } @@ -1806,8 +1806,8 @@ bool AuthMonitor::_upgrade_format_to_dumpling() bool changed = false; map<EntityName, EntityAuth>::iterator p; - for (p = mon->key_server.secrets_begin(); - p != mon->key_server.secrets_end(); + for (p = mon.key_server.secrets_begin(); + p != mon.key_server.secrets_end(); ++p) { // grab mon caps, if any string mon_caps; @@ -1866,8 +1866,8 @@ bool AuthMonitor::_upgrade_format_to_luminous() bool changed = false; map<EntityName, EntityAuth>::iterator p; - for (p = mon->key_server.secrets_begin(); - p != mon->key_server.secrets_end(); + for (p = mon.key_server.secrets_begin(); + p != mon.key_server.secrets_end(); ++p) { string n = p->first.to_str(); @@ -1924,7 +1924,7 @@ bool AuthMonitor::_upgrade_format_to_luminous() EntityName bootstrap_mgr_name; int r = bootstrap_mgr_name.from_str("client.bootstrap-mgr"); ceph_assert(r); - if (!mon->key_server.contains(bootstrap_mgr_name)) { + if (!mon.key_server.contains(bootstrap_mgr_name)) { EntityName name = bootstrap_mgr_name; EntityAuth auth; @@ -1946,7 +1946,7 @@ bool AuthMonitor::_upgrade_format_to_mimic() bool changed = false; for (auto &p : auth_lst) { - if (mon->key_server.contains(p.first)) { + if (mon.key_server.contains(p.first)) { continue; } int err = add_entity(p.first, p.second); @@ -1971,11 +1971,11 @@ void AuthMonitor::upgrade_format() // by N+1. unsigned int current = FORMAT_MIMIC; - if (!mon->get_quorum_mon_features().contains_all( + if (!mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_LUMINOUS)) { // pre-luminous quorum current = FORMAT_DUMPLING; - } else if (!mon->get_quorum_mon_features().contains_all( + } else if (!mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_MIMIC)) { // pre-mimic quorum current = FORMAT_LUMINOUS; @@ -2016,6 +2016,6 @@ void AuthMonitor::dump_info(Formatter *f) f->open_object_section("auth"); f->dump_unsigned("first_committed", get_first_committed()); f->dump_unsigned("last_committed", get_last_committed()); - f->dump_unsigned("num_secrets", mon->key_server.get_num_secrets()); + f->dump_unsigned("num_secrets", mon.key_server.get_num_secrets()); f->close_section(); } diff --git a/src/mon/AuthMonitor.h b/src/mon/AuthMonitor.h index 96bf0cbc1ea..048fc0c08ef 100644 --- a/src/mon/AuthMonitor.h +++ b/src/mon/AuthMonitor.h @@ -184,7 +184,7 @@ private: const EntityAuth& auth); public: - AuthMonitor(Monitor *mn, Paxos *p, const std::string& service_name) + AuthMonitor(Monitor &mn, Paxos &p, const std::string& service_name) : PaxosService(mn, p, service_name), last_rotating_ver(0), max_global_id(0), diff --git a/src/mon/ConfigMonitor.cc b/src/mon/ConfigMonitor.cc index d7fe933c8b3..bc8c28133ec 100644 --- a/src/mon/ConfigMonitor.cc +++ b/src/mon/ConfigMonitor.cc @@ -48,16 +48,16 @@ using ceph::JSONFormatter; using ceph::mono_clock; using ceph::mono_time; using ceph::timespan_str; -static ostream& _prefix(std::ostream *_dout, const Monitor *mon, +static ostream& _prefix(std::ostream *_dout, const Monitor &mon, const ConfigMonitor *hmon) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() << ").config "; + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").config "; } const string KEY_PREFIX("config/"); const string HISTORY_PREFIX("config-history/"); -ConfigMonitor::ConfigMonitor(Monitor *m, Paxos *p, const string& service_name) +ConfigMonitor::ConfigMonitor(Monitor &m, Paxos &p, const string& service_name) : PaxosService(m, p, service_name) { } @@ -153,7 +153,7 @@ bool ConfigMonitor::preprocess_query(MonOpRequestRef op) return preprocess_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } } @@ -180,7 +180,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } string format; @@ -197,7 +197,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) cmd_getval(cmdmap, "key", name); const Option *opt = g_conf().find_option(name); if (!opt) { - opt = mon->mgrmon()->find_module_option(name); + opt = mon.mgrmon()->find_module_option(name); } if (opt) { if (f) { @@ -227,7 +227,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) ss << i.name << "\n"; } } - for (auto& i : mon->mgrmon()->get_mgr_module_options()) { + for (auto& i : mon.mgrmon()->get_mgr_module_options()) { if (f) { f->dump_string("option", i.first); } else { @@ -306,9 +306,9 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) map<string,string> crush_location; string device_class; if (entity.is_osd()) { - mon->osdmon()->osdmap.crush->get_full_location(who, &crush_location); + mon.osdmon()->osdmap.crush->get_full_location(who, &crush_location); int id = atoi(entity.get_id().c_str()); - const char *c = mon->osdmon()->osdmap.crush->get_item_class(id); + const char *c = mon.osdmon()->osdmap.crush->get_item_class(id); if (c) { device_class = c; } @@ -320,14 +320,14 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) auto config = config_map.generate_entity_map( entity, crush_location, - mon->osdmon()->osdmap.crush.get(), + mon.osdmon()->osdmap.crush.get(), device_class, &src); if (cmd_getval(cmdmap, "key", name)) { const Option *opt = g_conf().find_option(name); if (!opt) { - opt = mon->mgrmon()->find_module_option(name); + opt = mon.mgrmon()->find_module_option(name); } if (!opt) { err = -ENOENT; @@ -336,7 +336,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) if (opt->has_flag(Option::FLAG_NO_MON_UPDATE)) { // handle special options if (name == "fsid") { - odata.append(stringify(mon->monmap->get_fsid())); + odata.append(stringify(mon.monmap->get_fsid())); odata.append("\n"); goto reply; } @@ -426,16 +426,16 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) } } else if (prefix == "config generate-minimal-conf") { ostringstream conf; - conf << "# minimal ceph.conf for " << mon->monmap->get_fsid() << "\n"; + conf << "# minimal ceph.conf for " << mon.monmap->get_fsid() << "\n"; // the basics conf << "[global]\n"; - conf << "\tfsid = " << mon->monmap->get_fsid() << "\n"; + conf << "\tfsid = " << mon.monmap->get_fsid() << "\n"; conf << "\tmon_host = "; - for (auto i = mon->monmap->mon_info.begin(); - i != mon->monmap->mon_info.end(); + for (auto i = mon.monmap->mon_info.begin(); + i != mon.monmap->mon_info.end(); ++i) { - if (i != mon->monmap->mon_info.begin()) { + if (i != mon.monmap->mon_info.begin()) { conf << " "; } if (i->second.public_addrs.size() == 1 && @@ -467,7 +467,7 @@ bool ConfigMonitor::preprocess_command(MonOpRequestRef op) } reply: - mon->reply_command(op, err, ss.str(), odata, get_last_committed()); + mon.reply_command(op, err, ss.str(), odata, get_last_committed()); return true; } @@ -476,7 +476,7 @@ void ConfigMonitor::handle_get_config(MonOpRequestRef op) auto m = op->get_req<MGetConfig>(); dout(10) << __func__ << " " << m->name << " host " << m->host << dendl; - const OSDMap& osdmap = mon->osdmon()->osdmap; + const OSDMap& osdmap = mon.osdmon()->osdmap; map<string,string> crush_location; osdmap.crush->get_full_location(m->host, &crush_location); auto out = config_map.generate_entity_map( @@ -499,7 +499,7 @@ bool ConfigMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } } @@ -515,7 +515,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } @@ -536,7 +536,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) if (prefix == "config set" && !force) { const Option *opt = g_conf().find_option(name); if (!opt) { - opt = mon->mgrmon()->find_module_option(name); + opt = mon.mgrmon()->find_module_option(name); } if (!opt) { ss << "unrecognized config option '" << name << "'"; @@ -639,7 +639,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) // a known and worthy option? const Option *o = g_conf().find_option(key); if (!o) { - o = mon->mgrmon()->find_module_option(key); + o = mon.mgrmon()->find_module_option(key); } if (!o || (o->flags & Option::FLAG_NO_MON_UPDATE) || @@ -701,7 +701,7 @@ bool ConfigMonitor::prepare_command(MonOpRequestRef op) } reply: - mon->reply_command(op, err, ss.str(), odata, get_last_committed()); + mon.reply_command(op, err, ss.str(), odata, get_last_committed()); return false; update: @@ -734,7 +734,7 @@ update: void ConfigMonitor::tick() { - if (!is_active() || !mon->is_leader()) { + if (!is_active() || !mon.is_leader()) { return; } dout(10) << __func__ << dendl; @@ -764,7 +764,7 @@ void ConfigMonitor::load_config() }; unsigned num = 0; - KeyValueDB::Iterator it = mon->store->get_iterator(CONFIG_PREFIX); + KeyValueDB::Iterator it = mon.store->get_iterator(CONFIG_PREFIX); it->lower_bound(KEY_PREFIX); config_map.clear(); current.clear(); @@ -793,7 +793,7 @@ void ConfigMonitor::load_config() { auto p = renamed_pacific.find(name); if (p != renamed_pacific.end()) { - if (mon->monmap->min_mon_release >= ceph_release_t::pacific) { + if (mon.monmap->min_mon_release >= ceph_release_t::pacific) { // schedule a cleanup pending_cleanup[key] = boost::none; pending_cleanup[who + "/" + p->second] = it->value(); @@ -805,7 +805,7 @@ void ConfigMonitor::load_config() const Option *opt = g_conf().find_option(name); if (!opt) { - opt = mon->mgrmon()->find_module_option(name); + opt = mon.mgrmon()->find_module_option(name); } if (!opt) { dout(10) << __func__ << " unrecognized option '" << name << "'" << dendl; @@ -864,7 +864,7 @@ void ConfigMonitor::load_config() // refresh our own config { - const OSDMap& osdmap = mon->osdmon()->osdmap; + const OSDMap& osdmap = mon.osdmon()->osdmap; map<string,string> crush_location; osdmap.crush->get_full_location(g_conf()->host, &crush_location); auto out = config_map.generate_entity_map( @@ -880,7 +880,7 @@ void ConfigMonitor::load_changeset(version_t v, ConfigChangeSet *ch) { ch->version = v; string prefix = HISTORY_PREFIX + stringify(v) + "/"; - KeyValueDB::Iterator it = mon->store->get_iterator(CONFIG_PREFIX); + KeyValueDB::Iterator it = mon.store->get_iterator(CONFIG_PREFIX); it->lower_bound(prefix); while (it->valid() && it->key().find(prefix) == 0) { if (it->key() == prefix) { @@ -908,7 +908,7 @@ void ConfigMonitor::load_changeset(version_t v, ConfigChangeSet *ch) bool ConfigMonitor::refresh_config(MonSession *s) { - const OSDMap& osdmap = mon->osdmon()->osdmap; + const OSDMap& osdmap = mon.osdmon()->osdmap; map<string,string> crush_location; if (s->remote_host.size()) { osdmap.crush->get_full_location(s->remote_host, &crush_location); @@ -983,7 +983,7 @@ void ConfigMonitor::check_sub(Subscription *sub) if (sub->next <= version) { maybe_send_config(sub->session); if (sub->onetime) { - mon->with_session_map([sub](MonSessionMap& session_map) { + mon.with_session_map([sub](MonSessionMap& session_map) { session_map.remove_sub(sub); }); } else { @@ -995,8 +995,8 @@ void ConfigMonitor::check_sub(Subscription *sub) void ConfigMonitor::check_all_subs() { dout(10) << __func__ << dendl; - auto subs = mon->session_map.subs.find("config"); - if (subs == mon->session_map.subs.end()) { + auto subs = mon.session_map.subs.find("config"); + if (subs == mon.session_map.subs.end()) { return; } int updated = 0, total = 0; diff --git a/src/mon/ConfigMonitor.h b/src/mon/ConfigMonitor.h index 283cd04a022..8d05dc3b46b 100644 --- a/src/mon/ConfigMonitor.h +++ b/src/mon/ConfigMonitor.h @@ -21,7 +21,7 @@ class ConfigMonitor : public PaxosService std::map<std::string,ceph::buffer::list> current; public: - ConfigMonitor(Monitor *m, Paxos *p, const std::string& service_name); + ConfigMonitor(Monitor &m, Paxos &p, const std::string& service_name); void init() override; diff --git a/src/mon/HealthMonitor.cc b/src/mon/HealthMonitor.cc index 0e6bf5be2d4..ac36bb45fc6 100644 --- a/src/mon/HealthMonitor.cc +++ b/src/mon/HealthMonitor.cc @@ -63,13 +63,13 @@ using ceph::mono_clock; using ceph::mono_time; using ceph::parse_timespan; using ceph::timespan_str; -static ostream& _prefix(std::ostream *_dout, const Monitor *mon, +static ostream& _prefix(std::ostream *_dout, const Monitor &mon, const HealthMonitor *hmon) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() << ").health "; + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").health "; } -HealthMonitor::HealthMonitor(Monitor *m, Paxos *p, const string& service_name) +HealthMonitor::HealthMonitor(Monitor &m, Paxos &p, const string& service_name) : PaxosService(m, p, service_name) { } @@ -90,7 +90,7 @@ void HealthMonitor::update_from_paxos(bool *need_bootstrap) load_health(); bufferlist qbl; - mon->store->get(service_name, "quorum", qbl); + mon.store->get(service_name, "quorum", qbl); if (qbl.length()) { auto p = qbl.cbegin(); decode(quorum_checks, p); @@ -99,7 +99,7 @@ void HealthMonitor::update_from_paxos(bool *need_bootstrap) } bufferlist lbl; - mon->store->get(service_name, "leader", lbl); + mon.store->get(service_name, "leader", lbl); if (lbl.length()) { auto p = lbl.cbegin(); decode(leader_checks, p); @@ -109,7 +109,7 @@ void HealthMonitor::update_from_paxos(bool *need_bootstrap) { bufferlist bl; - mon->store->get(service_name, "mutes", bl); + mon.store->get(service_name, "mutes", bl); if (bl.length()) { auto p = bl.cbegin(); decode(mutes, p); @@ -163,7 +163,7 @@ void HealthMonitor::encode_pending(MonitorDBStore::TransactionRef t) map<string,set<string>> names; // code -> <mon names> for (auto p : quorum_checks) { for (auto q : p.second.checks) { - names[q.first].insert(mon->monmap->get_name(p.first)); + names[q.first].insert(mon.monmap->get_name(p.first)); } pending_health.merge(p.second); } @@ -207,7 +207,7 @@ bool HealthMonitor::preprocess_query(MonOpRequestRef op) case MSG_MON_HEALTH_CHECKS: return false; default: - mon->no_reply(op); + mon.no_reply(op); derr << "Unhandled message type " << m->get_type() << dendl; return true; } @@ -237,13 +237,13 @@ bool HealthMonitor::preprocess_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -254,7 +254,7 @@ bool HealthMonitor::preprocess_command(MonOpRequestRef op) string prefix; cmd_getval(cmdmap, "prefix", prefix); } catch (const bad_cmd_get& e) { - mon->reply_command(op, -EINVAL, e.what(), rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), rdata, get_last_committed()); return true; } return false; @@ -270,13 +270,13 @@ bool HealthMonitor::prepare_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -356,7 +356,7 @@ out: return true; } else { // reply immediately - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return false; } } @@ -379,7 +379,7 @@ void HealthMonitor::tick() if (check_member_health()) { changed = true; } - if (!mon->is_leader()) { + if (!mon.is_leader()) { return; } if (check_leader_health()) { @@ -403,7 +403,7 @@ bool HealthMonitor::check_mutes() while (p != pending_mutes.end()) { if (p->second.ttl != utime_t() && p->second.ttl <= now) { - mon->clog->info() << "Health alert mute " << p->first + mon.clog->info() << "Health alert mute " << p->first << " cleared (passed TTL " << p->second.ttl << ")"; p = pending_mutes.erase(p); changed = true; @@ -412,7 +412,7 @@ bool HealthMonitor::check_mutes() if (!p->second.sticky) { auto q = all.checks.find(p->first); if (q == all.checks.end()) { - mon->clog->info() << "Health alert mute " << p->first + mon.clog->info() << "Health alert mute " << p->first << " cleared (health alert cleared)"; p = pending_mutes.erase(p); changed = true; @@ -421,7 +421,7 @@ bool HealthMonitor::check_mutes() if (p->second.count) { // count-based mute if (q->second.count > p->second.count) { - mon->clog->info() << "Health alert mute " << p->first + mon.clog->info() << "Health alert mute " << p->first << " cleared (count increased from " << p->second.count << " to " << q->second.count << ")"; p = pending_mutes.erase(p); @@ -439,7 +439,7 @@ bool HealthMonitor::check_mutes() } else { // summary-based mute if (p->second.summary != q->second.summary) { - mon->clog->info() << "Health alert mute " << p->first + mon.clog->info() << "Health alert mute " << p->first << " cleared (summary changed)"; p = pending_mutes.erase(p); changed = true; @@ -454,7 +454,7 @@ bool HealthMonitor::check_mutes() void HealthMonitor::gather_all_health_checks(health_check_map_t *all) { - for (auto& svc : mon->paxos_service) { + for (auto& svc : mon.paxos_service) { all->merge(svc->get_health_checks()); } } @@ -576,7 +576,7 @@ bool HealthMonitor::check_member_health() DataStats stats; get_fs_stats(stats.fs_stats, g_conf()->mon_data.c_str()); map<string,uint64_t> extra; - uint64_t store_size = mon->store->get_estimated_size(extra); + uint64_t store_size = mon.store->get_estimated_size(extra); ceph_assert(store_size > 0); stats.store_stats.bytes_total = store_size; stats.store_stats.bytes_sst = extra["sst"]; @@ -594,14 +594,14 @@ bool HealthMonitor::check_member_health() stringstream ss, ss2; ss << "mon%plurals% %names% %isorare% very low on available space"; auto& d = next.add("MON_DISK_CRIT", HEALTH_ERR, ss.str(), 1); - ss2 << "mon." << mon->name << " has " << stats.fs_stats.avail_percent + ss2 << "mon." << mon.name << " has " << stats.fs_stats.avail_percent << "% avail"; d.detail.push_back(ss2.str()); } else if (stats.fs_stats.avail_percent <= g_conf()->mon_data_avail_warn) { stringstream ss, ss2; ss << "mon%plurals% %names% %isorare% low on available space"; auto& d = next.add("MON_DISK_LOW", HEALTH_WARN, ss.str(), 1); - ss2 << "mon." << mon->name << " has " << stats.fs_stats.avail_percent + ss2 << "mon." << mon.name << " has " << stats.fs_stats.avail_percent << "% avail"; d.detail.push_back(ss2.str()); } @@ -609,7 +609,7 @@ bool HealthMonitor::check_member_health() stringstream ss, ss2; ss << "mon%plurals% %names% %isorare% using a lot of disk space"; auto& d = next.add("MON_DISK_BIG", HEALTH_WARN, ss.str(), 1); - ss2 << "mon." << mon->name << " is " + ss2 << "mon." << mon.name << " is " << byte_u_t(stats.store_stats.bytes_total) << " >= mon_data_size_warn (" << byte_u_t(g_conf()->mon_data_size_warn) << ")"; @@ -635,12 +635,12 @@ bool HealthMonitor::check_member_health() ostringstream ss, ds; ss << "mon%plurals% %names% %hasorhave% mon_osd_down_out_interval set to 0"; auto& d = next.add("OSD_NO_DOWN_OUT_INTERVAL", HEALTH_WARN, ss.str(), 1); - ds << "mon." << mon->name << " has mon_osd_down_out_interval set to 0"; + ds << "mon." << mon.name << " has mon_osd_down_out_interval set to 0"; d.detail.push_back(ds.str()); } } - auto p = quorum_checks.find(mon->rank); + auto p = quorum_checks.find(mon.rank); if (p == quorum_checks.end()) { if (next.empty()) { return false; @@ -651,13 +651,13 @@ bool HealthMonitor::check_member_health() } } - if (mon->is_leader()) { + if (mon.is_leader()) { // prepare to propose - quorum_checks[mon->rank] = next; + quorum_checks[mon.rank] = next; changed = true; } else { // tell the leader - mon->send_mon_message(new MMonHealthChecks(next), mon->get_leader()); + mon.send_mon_message(new MMonHealthChecks(next), mon.get_leader()); } return changed; @@ -670,7 +670,7 @@ bool HealthMonitor::check_leader_health() // prune quorum_health { - auto& qset = mon->get_quorum(); + auto& qset = mon.get_quorum(); auto p = quorum_checks.begin(); while (p != quorum_checks.end()) { if (qset.count(p->first) == 0) { @@ -693,7 +693,7 @@ bool HealthMonitor::check_leader_health() old_version_first_time = now; if ((now - old_version_first_time) > g_conf().get_val<double>("mon_warn_older_version_delay")) { std::map<string, std::list<string> > all_versions; - mon->get_all_versions(all_versions); + mon.get_all_versions(all_versions); if (all_versions.size() > 1) { dout(20) << __func__ << " all_versions=" << all_versions << dendl; // The last entry has the largest version @@ -734,19 +734,19 @@ bool HealthMonitor::check_leader_health() // MON_DOWN { - int max = mon->monmap->size(); - int actual = mon->get_quorum().size(); + int max = mon.monmap->size(); + int actual = mon.get_quorum().size(); if (actual < max) { ostringstream ss; ss << (max-actual) << "/" << max << " mons down, quorum " - << mon->get_quorum_names(); + << mon.get_quorum_names(); auto& d = next.add("MON_DOWN", HEALTH_WARN, ss.str(), max - actual); - set<int> q = mon->get_quorum(); + set<int> q = mon.get_quorum(); for (int i=0; i<max; i++) { if (q.count(i) == 0) { ostringstream ss; - ss << "mon." << mon->monmap->get_name(i) << " (rank " << i - << ") addr " << mon->monmap->get_addrs(i) + ss << "mon." << mon.monmap->get_name(i) << " (rank " << i + << ") addr " << mon.monmap->get_addrs(i) << " is down (out of quorum)"; d.detail.push_back(ss.str()); } @@ -755,15 +755,15 @@ bool HealthMonitor::check_leader_health() } // MON_CLOCK_SKEW - if (!mon->timecheck_skews.empty()) { + if (!mon.timecheck_skews.empty()) { list<string> warns; list<string> details; - for (auto& i : mon->timecheck_skews) { + for (auto& i : mon.timecheck_skews) { double skew = i.second; - double latency = mon->timecheck_latencies[i.first]; - string name = mon->monmap->get_name(i.first); + double latency = mon.timecheck_latencies[i.first]; + string name = mon.monmap->get_name(i.first); ostringstream tcss; - health_status_t tcstatus = mon->timecheck_status(tcss, skew, latency); + health_status_t tcstatus = mon.timecheck_status(tcss, skew, latency); if (tcstatus != HEALTH_OK) { warns.push_back(name); ostringstream tmp_ss; @@ -789,10 +789,10 @@ bool HealthMonitor::check_leader_health() // MON_MSGR2_NOT_ENABLED if (g_conf().get_val<bool>("ms_bind_msgr2") && g_conf().get_val<bool>("mon_warn_on_msgr2_not_enabled") && - mon->monmap->get_required_features().contains_all( + mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_NAUTILUS)) { list<string> details; - for (auto& i : mon->monmap->mon_info) { + for (auto& i : mon.monmap->mon_info) { if (!i.second.public_addrs.has_msgr2()) { ostringstream ds; ds << "mon." << i.first << " is not bound to a msgr2 port, only " diff --git a/src/mon/HealthMonitor.h b/src/mon/HealthMonitor.h index e21ca72bc02..10debe51871 100644 --- a/src/mon/HealthMonitor.h +++ b/src/mon/HealthMonitor.h @@ -26,7 +26,7 @@ class HealthMonitor : public PaxosService std::map<std::string,health_mute_t> pending_mutes; public: - HealthMonitor(Monitor *m, Paxos *p, const std::string& service_name); + HealthMonitor(Monitor &m, Paxos &p, const std::string& service_name); /** * @defgroup HealthMonitor_Inherited_h Inherited abstract methods diff --git a/src/mon/LogMonitor.cc b/src/mon/LogMonitor.cc index 1ce36646c34..88327663a5b 100644 --- a/src/mon/LogMonitor.cc +++ b/src/mon/LogMonitor.cc @@ -166,9 +166,9 @@ ceph::logging::Graylog::Ref LogMonitor::log_channel_info::get_graylog( #undef dout_prefix #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() +static ostream& _prefix(std::ostream *_dout, Monitor &mon, version_t v) { + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").log v" << v << " "; } @@ -194,12 +194,12 @@ void LogMonitor::create_initial() dout(10) << "create_initial -- creating initial map" << dendl; LogEntry e; e.name = g_conf()->name; - e.rank = entity_name_t::MON(mon->rank); - e.addrs = mon->messenger->get_myaddrs(); + e.rank = entity_name_t::MON(mon.rank); + e.addrs = mon.messenger->get_myaddrs(); e.stamp = ceph_clock_now(); e.prio = CLOG_INFO; std::stringstream ss; - ss << "mkfs " << mon->monmap->get_fsid(); + ss << "mkfs " << mon.monmap->get_fsid(); e.msg = ss.str(); e.seq = 0; pending_log.insert(pair<utime_t,LogEntry>(e.stamp, e)); @@ -353,7 +353,7 @@ void LogMonitor::encode_pending(MonitorDBStore::TransactionRef t) __u8 v = 1; encode(v, bl); for (auto p = pending_log.begin(); p != pending_log.end(); ++p) - p->second.encode(bl, mon->get_quorum_con_features()); + p->second.encode(bl, mon.get_quorum_con_features()); put_version(t, version, bl); put_last_committed(t, version); @@ -365,7 +365,7 @@ void LogMonitor::encode_full(MonitorDBStore::TransactionRef t) ceph_assert(get_last_committed() == summary.version); bufferlist summary_bl; - encode(summary, summary_bl, mon->get_quorum_con_features()); + encode(summary, summary_bl, mon.get_quorum_con_features()); put_version_full(t, summary.version, summary_bl); put_version_latest_full(t, summary.version); @@ -373,7 +373,7 @@ void LogMonitor::encode_full(MonitorDBStore::TransactionRef t) version_t LogMonitor::get_trim_to() const { - if (!mon->is_leader()) + if (!mon.is_leader()) return 0; unsigned max = g_conf()->mon_max_log_epochs; @@ -394,7 +394,7 @@ bool LogMonitor::preprocess_query(MonOpRequestRef op) return preprocess_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } @@ -418,7 +418,7 @@ bool LogMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } case MSG_LOG: @@ -459,7 +459,7 @@ bool LogMonitor::preprocess_log(MonOpRequestRef op) return false; done: - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -481,8 +481,8 @@ bool LogMonitor::prepare_log(MonOpRequestRef op) auto m = op->get_req<MLog>(); dout(10) << "prepare_log " << *m << " from " << m->get_orig_source() << dendl; - if (m->fsid != mon->monmap->fsid) { - dout(0) << "handle_log on fsid " << m->fsid << " != " << mon->monmap->fsid + if (m->fsid != mon.monmap->fsid) { + dout(0) << "handle_log on fsid " << m->fsid << " != " << mon.monmap->fsid << dendl; return false; } @@ -505,7 +505,7 @@ void LogMonitor::_updated_log(MonOpRequestRef op) { auto m = op->get_req<MLog>(); dout(7) << "_updated_log for " << m->get_orig_source_inst() << dendl; - mon->send_reply(op, new MLogAck(m->fsid, m->entries.rbegin()->seq)); + mon.send_reply(op, new MLogAck(m->fsid, m->entries.rbegin()->seq)); } bool LogMonitor::should_propose(double& delay) @@ -531,12 +531,12 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -560,7 +560,7 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op) level = LogEntry::str_to_level(level_str); if (level == CLOG_UNKNOWN) { ss << "Invalid severity '" << level_str << "'"; - mon->reply_command(op, -EINVAL, ss.str(), get_last_committed()); + mon.reply_command(op, -EINVAL, ss.str(), get_last_committed()); return true; } } else { @@ -668,7 +668,7 @@ bool LogMonitor::preprocess_command(MonOpRequestRef op) string rs; getline(ss, rs); - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return true; } @@ -685,7 +685,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } @@ -694,7 +694,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op) MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -721,7 +721,7 @@ bool LogMonitor::prepare_command(MonOpRequestRef op) } getline(ss, rs); - mon->reply_command(op, err, rs, get_last_committed()); + mon.reply_command(op, err, rs, get_last_committed()); return false; } @@ -738,8 +738,8 @@ int LogMonitor::sub_name_to_id(const string& n) void LogMonitor::check_subs() { dout(10) << __func__ << dendl; - for (map<string, xlist<Subscription*>*>::iterator i = mon->session_map.subs.begin(); - i != mon->session_map.subs.end(); + for (map<string, xlist<Subscription*>*>::iterator i = mon.session_map.subs.begin(); + i != mon.session_map.subs.end(); ++i) { for (xlist<Subscription*>::iterator j = i->second->begin(); !j.end(); ++j) { if (sub_name_to_id((*j)->type) >= 0) @@ -764,7 +764,7 @@ void LogMonitor::check_sub(Subscription *s) return; } - MLog *mlog = new MLog(mon->monmap->fsid); + MLog *mlog = new MLog(mon.monmap->fsid); if (s->next == 0) { /* First timer, heh? */ @@ -784,7 +784,7 @@ void LogMonitor::check_sub(Subscription *s) mlog->put(); } if (s->onetime) - mon->session_map.remove_sub(s); + mon.session_map.remove_sub(s); else s->next = summary_version+1; } diff --git a/src/mon/LogMonitor.h b/src/mon/LogMonitor.h index 38018ddcc4c..6d6a0b71c68 100644 --- a/src/mon/LogMonitor.h +++ b/src/mon/LogMonitor.h @@ -143,7 +143,7 @@ private: void _create_sub_incremental(MLog *mlog, int level, version_t sv); public: - LogMonitor(Monitor *mn, Paxos *p, const std::string& service_name) + LogMonitor(Monitor &mn, Paxos &p, const std::string& service_name) : PaxosService(mn, p, service_name) { } void init() override { diff --git a/src/mon/MDSMonitor.cc b/src/mon/MDSMonitor.cc index 2e8d112ffe4..011b61fff9d 100644 --- a/src/mon/MDSMonitor.cc +++ b/src/mon/MDSMonitor.cc @@ -70,9 +70,9 @@ using ceph::mono_time; #define dout_subsys ceph_subsys_mon #undef dout_prefix #define dout_prefix _prefix(_dout, mon, get_fsmap()) -static ostream& _prefix(std::ostream *_dout, Monitor *mon, const FSMap& fsmap) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() +static ostream& _prefix(std::ostream *_dout, Monitor &mon, const FSMap& fsmap) { + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").mds e" << fsmap.get_epoch() << " "; } @@ -167,8 +167,8 @@ void MDSMonitor::create_pending() { auto &fsmap = PaxosFSMap::create_pending(); - if (mon->osdmon()->is_readable()) { - const auto &osdmap = mon->osdmon()->osdmap; + if (mon.osdmon()->is_readable()) { + const auto &osdmap = mon.osdmon()->osdmap; fsmap.sanitize([&osdmap](int64_t pool){return osdmap.have_pg_pool(pool);}); } @@ -198,7 +198,7 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) // apply to paxos ceph_assert(get_last_committed() + 1 == pending.epoch); bufferlist pending_bl; - pending.encode(pending_bl, mon->get_quorum_con_features()); + pending.encode(pending_bl, mon.get_quorum_con_features()); /* put everything in the transaction */ put_version(t, pending.epoch, pending_bl); @@ -234,7 +234,7 @@ void MDSMonitor::encode_pending(MonitorDBStore::TransactionRef t) health = p->second; } else { bufferlist bl; - mon->store->get(MDS_HEALTH_PREFIX, stringify(gid), bl); + mon.store->get(MDS_HEALTH_PREFIX, stringify(gid), bl); if (!bl.length()) { derr << "Missing health data for MDS " << gid << dendl; continue; @@ -321,7 +321,7 @@ bool MDSMonitor::preprocess_query(MonOpRequestRef op) return preprocess_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } @@ -367,8 +367,8 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) goto ignore; } - if (m->get_fsid() != mon->monmap->fsid) { - dout(0) << "preprocess_beacon on fsid " << m->get_fsid() << " != " << mon->monmap->fsid << dendl; + if (m->get_fsid() != mon.monmap->fsid) { + dout(0) << "preprocess_beacon on fsid " << m->get_fsid() << " != " << mon.monmap->fsid << dendl; goto ignore; } @@ -409,8 +409,8 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) MDSMap null_map; null_map.epoch = fsmap.epoch; null_map.compat = fsmap.compat; - auto m = make_message<MMDSMap>(mon->monmap->fsid, null_map); - mon->send_reply(op, m.detach()); + auto m = make_message<MMDSMap>(mon.monmap->fsid, null_map); + mon.send_reply(op, m.detach()); return true; } else { return false; // not booted yet. @@ -511,16 +511,16 @@ bool MDSMonitor::preprocess_beacon(MonOpRequestRef op) ceph_assert(effective_epoch > 0); _note_beacon(m); { - auto beacon = make_message<MMDSBeacon>(mon->monmap->fsid, + auto beacon = make_message<MMDSBeacon>(mon.monmap->fsid, m->get_global_id(), m->get_name(), effective_epoch, state, seq, CEPH_FEATURES_SUPPORTED_DEFAULT); - mon->send_reply(op, beacon.detach()); + mon.send_reply(op, beacon.detach()); } return true; ignore: // I won't reply this beacon, drop it. - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -549,7 +549,7 @@ bool MDSMonitor::preprocess_offload_targets(MonOpRequestRef op) return false; ignore: - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -570,7 +570,7 @@ bool MDSMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } @@ -626,7 +626,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) // Log the disappearance of health messages at INFO for (const auto &old_metric : old_health) { if (new_types.count(old_metric.type) == 0) { - mon->clog->info() << "MDS health message cleared (" + mon.clog->info() << "MDS health message cleared (" << m->get_orig_source() << "): " << old_metric.message; } } @@ -640,19 +640,19 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) if (g_conf()->mds_enforce_unique_name) { bool failed_mds = false; while (mds_gid_t existing = pending.find_mds_gid_by_name(m->get_name())) { - if (!mon->osdmon()->is_writeable()) { - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + if (!mon.osdmon()->is_writeable()) { + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } const MDSMap::mds_info_t &existing_info = pending.get_info_gid(existing); - mon->clog->info() << existing_info.human_name() << " restarted"; + mon.clog->info() << existing_info.human_name() << " restarted"; fail_mds_gid(pending, existing); failed_mds = true; } if (failed_mds) { - ceph_assert(mon->osdmon()->is_writeable()); - request_proposal(mon->osdmon()); + ceph_assert(mon.osdmon()->is_writeable()); + request_proposal(mon.osdmon()); } } @@ -709,8 +709,8 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) MDSMap null_map; null_map.epoch = fsmap.epoch; null_map.compat = fsmap.compat; - auto m = make_message<MMDSMap>(mon->monmap->fsid, null_map); - mon->send_reply(op, m.detach()); + auto m = make_message<MMDSMap>(mon.monmap->fsid, null_map); + mon.send_reply(op, m.detach()); } else { dispatch(op); // try again } @@ -758,7 +758,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) const auto fscid = pending.mds_roles.at(gid); const auto &fs = pending.get_filesystem(fscid); - mon->clog->info() << info.human_name() << " finished " + mon.clog->info() << info.human_name() << " finished " << "stopping rank " << info.rank << " in filesystem " << fs->mds_map.fs_name << " (now has " << fs->mds_map.get_num_in_mds() - 1 << " ranks)"; @@ -776,10 +776,10 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) } else if (state == MDSMap::STATE_DAMAGED) { - if (!mon->osdmon()->is_writeable()) { + if (!mon.osdmon()->is_writeable()) { dout(1) << __func__ << ": DAMAGED from rank " << info.rank << " waiting for osdmon writeable to blocklist it" << dendl; - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } @@ -790,34 +790,34 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) utime_t until = ceph_clock_now(); until += g_conf().get_val<double>("mon_mds_blocklist_interval"); - const auto blocklist_epoch = mon->osdmon()->blocklist(info.addrs, until); - request_proposal(mon->osdmon()); + const auto blocklist_epoch = mon.osdmon()->blocklist(info.addrs, until); + request_proposal(mon.osdmon()); pending.damaged(gid, blocklist_epoch); last_beacon.erase(gid); // Respond to MDS, so that it knows it can continue to shut down auto beacon = make_message<MMDSBeacon>( - mon->monmap->fsid, m->get_global_id(), + mon.monmap->fsid, m->get_global_id(), m->get_name(), pending.get_epoch(), state, seq, CEPH_FEATURES_SUPPORTED_DEFAULT); - mon->send_reply(op, beacon.detach()); + mon.send_reply(op, beacon.detach()); } else if (state == MDSMap::STATE_DNE) { - if (!mon->osdmon()->is_writeable()) { + if (!mon.osdmon()->is_writeable()) { dout(1) << __func__ << ": DNE from rank " << info.rank << " waiting for osdmon writeable to blocklist it" << dendl; - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } fail_mds_gid(pending, gid); - ceph_assert(mon->osdmon()->is_writeable()); - request_proposal(mon->osdmon()); + ceph_assert(mon.osdmon()->is_writeable()); + request_proposal(mon.osdmon()); // Respond to MDS, so that it knows it can continue to shut down - auto beacon = make_message<MMDSBeacon>(mon->monmap->fsid, + auto beacon = make_message<MMDSBeacon>(mon.monmap->fsid, m->get_global_id(), m->get_name(), pending.get_epoch(), state, seq, CEPH_FEATURES_SUPPORTED_DEFAULT); - mon->send_reply(op, beacon.detach()); + mon.send_reply(op, beacon.detach()); } else if (info.state == MDSMap::STATE_STANDBY && state != info.state) { // Standby daemons should never modify their own // state. Reject any attempts to do so. @@ -836,7 +836,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) if (info.state != MDSMap::STATE_ACTIVE && state == MDSMap::STATE_ACTIVE) { const auto &fscid = pending.mds_roles.at(gid); const auto &fs = pending.get_filesystem(fscid); - mon->clog->info() << info.human_name() << " is now active in " + mon.clog->info() << info.human_name() << " is now active in " << "filesystem " << fs->mds_map.fs_name << " as rank " << info.rank; } @@ -857,7 +857,7 @@ bool MDSMonitor::prepare_beacon(MonOpRequestRef op) if (r >= 0) _updated(op); // success else if (r == -ECANCELED) { - mon->no_reply(op); + mon.no_reply(op); } else { dispatch(op); // try again } @@ -879,7 +879,7 @@ bool MDSMonitor::prepare_offload_targets(MonOpRequestRef op) } else { dout(10) << "prepare_offload_targets " << gid << " not in map" << dendl; } - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -895,7 +895,7 @@ void MDSMonitor::_updated(MonOpRequestRef op) op->mark_mdsmon_event(__func__); auto m = op->get_req<MMDSBeacon>(); dout(10) << "_updated " << m->get_orig_source() << " " << *m << dendl; - mon->clog->debug() << m->get_orig_source() << " " + mon.clog->debug() << m->get_orig_source() << " " << m->get_orig_source_addrs() << " " << ceph_mds_state_name(m->get_state()); @@ -904,13 +904,13 @@ void MDSMonitor::_updated(MonOpRequestRef op) MDSMap null_map; null_map.epoch = fsmap.epoch; null_map.compat = fsmap.compat; - auto m = make_message<MMDSMap>(mon->monmap->fsid, null_map); - mon->send_reply(op, m.detach()); + auto m = make_message<MMDSMap>(mon.monmap->fsid, null_map); + mon.send_reply(op, m.detach()); } else { - auto beacon = make_message<MMDSBeacon>(mon->monmap->fsid, + auto beacon = make_message<MMDSBeacon>(mon.monmap->fsid, m->get_global_id(), m->get_name(), fsmap.get_epoch(), m->get_state(), m->get_seq(), CEPH_FEATURES_SUPPORTED_DEFAULT); - mon->send_reply(op, beacon.detach()); + mon.send_reply(op, beacon.detach()); } } @@ -919,7 +919,7 @@ void MDSMonitor::on_active() tick(); if (is_leader()) { - mon->clog->debug() << "fsmap " << get_fsmap(); + mon.clog->debug() << "fsmap " << get_fsmap(); } } @@ -945,7 +945,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { // ss has reason for failure string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -957,7 +957,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1157,7 +1157,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) f->dump_string("name", mds_map.fs_name); /* Output both the names and IDs of pools, for use by * humans and machines respectively */ - f->dump_string("metadata_pool", mon->osdmon()->osdmap.get_pool_name( + f->dump_string("metadata_pool", mon.osdmon()->osdmap.get_pool_name( mds_map.metadata_pool)); f->dump_int("metadata_pool_id", mds_map.metadata_pool); f->open_array_section("data_pool_ids"); @@ -1168,7 +1168,7 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) f->open_array_section("data_pools"); for (const auto &id : mds_map.data_pools) { - const auto &name = mon->osdmon()->osdmap.get_pool_name(id); + const auto &name = mon.osdmon()->osdmap.get_pool_name(id); f->dump_string("data_pool", name); } f->close_section(); @@ -1181,13 +1181,13 @@ bool MDSMonitor::preprocess_command(MonOpRequestRef op) for (const auto &p : fsmap.filesystems) { const auto &fs = p.second; const MDSMap &mds_map = fs->mds_map; - const string &md_pool_name = mon->osdmon()->osdmap.get_pool_name( + const string &md_pool_name = mon.osdmon()->osdmap.get_pool_name( mds_map.metadata_pool); ds << "name: " << mds_map.fs_name << ", metadata pool: " << md_pool_name << ", data pools: ["; for (const auto &id : mds_map.data_pools) { - const string &pool_name = mon->osdmon()->osdmap.get_pool_name(id); + const string &pool_name = mon.osdmon()->osdmap.get_pool_name(id); ds << pool_name << " "; } ds << "]" << std::endl; @@ -1222,7 +1222,7 @@ out: rdata.append(ds); string rs; getline(ss, rs); - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -1233,13 +1233,13 @@ bool MDSMonitor::fail_mds_gid(FSMap &fsmap, mds_gid_t gid) const auto& info = fsmap.get_info_gid(gid); dout(1) << "fail_mds_gid " << gid << " mds." << info.name << " role " << info.rank << dendl; - ceph_assert(mon->osdmon()->is_writeable()); + ceph_assert(mon.osdmon()->is_writeable()); epoch_t blocklist_epoch = 0; if (info.rank >= 0 && info.state != MDSMap::STATE_STANDBY_REPLAY) { utime_t until = ceph_clock_now(); until += g_conf().get_val<double>("mon_mds_blocklist_interval"); - blocklist_epoch = mon->osdmon()->blocklist(info.addrs, until); + blocklist_epoch = mon.osdmon()->blocklist(info.addrs, until); } fsmap.erase(gid, blocklist_epoch); @@ -1307,7 +1307,7 @@ int MDSMonitor::fail_mds(FSMap &fsmap, std::ostream &ss, if (gid == MDS_GID_NONE) { return 0; } - if (!mon->osdmon()->is_writeable()) { + if (!mon.osdmon()->is_writeable()) { return -EAGAIN; } @@ -1317,8 +1317,8 @@ int MDSMonitor::fail_mds(FSMap &fsmap, std::ostream &ss, fail_mds_gid(fsmap, gid); ss << "failed mds gid " << gid; - ceph_assert(mon->osdmon()->is_writeable()); - request_proposal(mon->osdmon()); + ceph_assert(mon.osdmon()->is_writeable()); + request_proposal(mon.osdmon()); return 0; } @@ -1333,7 +1333,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -1343,7 +1343,7 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op) /* Refuse access if message not associated with a valid session */ MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1362,11 +1362,11 @@ bool MDSMonitor::prepare_command(MonOpRequestRef op) batched_propose = h->batched_propose(); if (batched_propose) { - paxos->plug(); + paxos.plug(); } - r = h->handle(mon, pending, op, cmdmap, ss); + r = h->handle(&mon, pending, op, cmdmap, ss); if (batched_propose) { - paxos->unplug(); + paxos.unplug(); } if (r == -EAGAIN) { @@ -1414,7 +1414,7 @@ out: return true; } else { // reply immediately - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return false; } } @@ -1477,12 +1477,12 @@ int MDSMonitor::filesystem_command( r = fail_mds(fsmap, ss, who, &failed_info); if (r < 0 && r == -EAGAIN) { - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return -EAGAIN; // don't propose yet; wait for message to be retried } else if (r == 0) { // Only log if we really did something (not when was already gone) if (failed_info.global_id != MDS_GID_NONE) { - mon->clog->info() << failed_info.human_name() << " marked failed by " + mon.clog->info() << failed_info.human_name() << " marked failed by " << op->get_session()->entity_name; } } @@ -1663,7 +1663,7 @@ void MDSMonitor::check_subs() } for (const auto &type : types) { - auto& subs = mon->session_map.subs; + auto& subs = mon.session_map.subs; auto subs_it = subs.find(type); if (subs_it == subs.end()) continue; @@ -1690,9 +1690,9 @@ void MDSMonitor::check_sub(Subscription *sub) } if (sub->type == "fsmap") { - sub->session->con->send_message(new MFSMap(mon->monmap->fsid, fsmap)); + sub->session->con->send_message(new MFSMap(mon.monmap->fsid, fsmap)); if (sub->onetime) { - mon->session_map.remove_sub(sub); + mon.session_map.remove_sub(sub); } else { sub->next = fsmap.get_epoch() + 1; } @@ -1705,9 +1705,9 @@ void MDSMonitor::check_sub(Subscription *sub) fs_info.cid = p.second->fscid; fs_info.name = p.second->mds_map.fs_name; } - sub->session->con->send_message(new MFSMapUser(mon->monmap->fsid, fsmap_u)); + sub->session->con->send_message(new MFSMapUser(mon.monmap->fsid, fsmap_u)); if (sub->onetime) { - mon->session_map.remove_sub(sub); + mon.session_map.remove_sub(sub); } else { sub->next = fsmap.get_epoch() + 1; } @@ -1791,12 +1791,12 @@ void MDSMonitor::check_sub(Subscription *sub) if (sub->next > mds_map->epoch) { return; } - auto msg = make_message<MMDSMap>(mon->monmap->fsid, *mds_map, + auto msg = make_message<MMDSMap>(mon.monmap->fsid, *mds_map, mds_map->fs_name); sub->session->con->send_message(msg.detach()); if (sub->onetime) { - mon->session_map.remove_sub(sub); + mon.session_map.remove_sub(sub); } else { sub->next = mds_map->get_epoch() + 1; } @@ -1812,11 +1812,11 @@ void MDSMonitor::update_metadata(mds_gid_t gid, } pending_metadata[gid] = metadata; - MonitorDBStore::TransactionRef t = paxos->get_pending_transaction(); + MonitorDBStore::TransactionRef t = paxos.get_pending_transaction(); bufferlist bl; encode(pending_metadata, bl); t->put(MDS_METADATA_PREFIX, "last_metadata", bl); - paxos->trigger_propose(); + paxos.trigger_propose(); } void MDSMonitor::remove_from_metadata(const FSMap &fsmap, MonitorDBStore::TransactionRef t) @@ -1840,7 +1840,7 @@ void MDSMonitor::remove_from_metadata(const FSMap &fsmap, MonitorDBStore::Transa int MDSMonitor::load_metadata(map<mds_gid_t, Metadata>& m) { bufferlist bl; - int r = mon->store->get(MDS_METADATA_PREFIX, "last_metadata", bl); + int r = mon.store->get(MDS_METADATA_PREFIX, "last_metadata", bl); if (r) { dout(5) << "Unable to load 'last_metadata'" << dendl; return r; @@ -1986,7 +1986,7 @@ bool MDSMonitor::maybe_resize_cluster(FSMap &fsmap, fs_cluster_id_t fscid) dout(1) << "assigned standby " << info->addrs << " as mds." << mds << dendl; - mon->clog->info() << info->human_name() << " assigned to " + mon.clog->info() << info->human_name() << " assigned to " "filesystem " << mds_map.fs_name << " as rank " << mds << " (now has " << mds_map.get_num_in_mds() + 1 << " ranks)"; @@ -1997,7 +1997,7 @@ bool MDSMonitor::maybe_resize_cluster(FSMap &fsmap, fs_cluster_id_t fscid) const auto &info = mds_map.get_info(target); if (mds_map.is_active(target)) { dout(1) << "stopping " << target << dendl; - mon->clog->info() << "stopping " << info.human_name(); + mon.clog->info() << "stopping " << info.human_name(); auto f = [](auto& info) { info.state = MDSMap::STATE_STOPPING; }; @@ -2048,7 +2048,7 @@ bool MDSMonitor::drop_mds(FSMap &fsmap, mds_gid_t gid, const mds_info_t* rep_inf << " with " << rep_info->global_id << "/" << rep_info->name << " " << rep_info->addrs << dendl; - mon->clog->warn() << "Replacing " << info.human_name() + mon.clog->warn() << "Replacing " << info.human_name() << " as rank " << rank << " with standby " << rep_info->human_name(); @@ -2067,7 +2067,7 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap) { bool do_propose = false; const auto now = mono_clock::now(); - const bool osdmap_writeable = mon->osdmon()->is_writeable(); + const bool osdmap_writeable = mon.osdmon()->is_writeable(); const auto mds_beacon_grace = g_conf().get_val<double>("mds_beacon_grace"); const auto mds_beacon_interval = g_conf().get_val<double>("mds_beacon_interval"); @@ -2156,7 +2156,7 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap) } bool dropped = drop_mds(fsmap, gid, rep_info, propose_osdmap); if (dropped) { - mon->clog->info() << "MDS " << info.human_name() + mon.clog->info() << "MDS " << info.human_name() << " is removed because it is dead or otherwise unavailable."; do_propose = true; } @@ -2195,13 +2195,13 @@ bool MDSMonitor::check_health(FSMap& fsmap, bool* propose_osdmap) } if (better_affinity) { if (state == MDSMap::STATE_STANDBY_REPLAY) { - mon->clog->info() << "Dropping low affinity standby-replay " + mon.clog->info() << "Dropping low affinity standby-replay " << info.human_name() << " in favor of higher affinity standby."; *propose_osdmap |= fail_mds_gid(fsmap, gid); /* Now let maybe_promote_standby do the promotion. */ } else { - mon->clog->info() << "Dropping low affinity active " + mon.clog->info() << "Dropping low affinity active " << info.human_name() << " in favor of higher affinity standby."; do_propose |= drop_mds(fsmap, gid, rep_info, propose_osdmap); @@ -2231,7 +2231,7 @@ bool MDSMonitor::maybe_promote_standby(FSMap &fsmap, Filesystem& fs) if (info) { dout(1) << " taking over failed mds." << rank << " with " << info->global_id << "/" << info->name << " " << info->addrs << dendl; - mon->clog->info() << "Standby " << info->human_name() + mon.clog->info() << "Standby " << info->human_name() << " assigned to filesystem " << fs.mds_map.fs_name << " as rank " << rank; @@ -2292,7 +2292,7 @@ void MDSMonitor::tick() } if (propose_osdmap) { - request_proposal(mon->osdmon()); + request_proposal(mon.osdmon()); } if (do_propose) { @@ -2302,10 +2302,10 @@ void MDSMonitor::tick() last_tick = mono_clock::now(); } -MDSMonitor::MDSMonitor(Monitor *mn, Paxos *p, string service_name) +MDSMonitor::MDSMonitor(Monitor &mn, Paxos &p, string service_name) : PaxosService(mn, p, service_name) { - handlers = FileSystemCommandHandler::load(p); + handlers = FileSystemCommandHandler::load(&p); } void MDSMonitor::on_restart() diff --git a/src/mon/MDSMonitor.h b/src/mon/MDSMonitor.h index f84744e0c73..56723961b95 100644 --- a/src/mon/MDSMonitor.h +++ b/src/mon/MDSMonitor.h @@ -32,7 +32,7 @@ class FileSystemCommandHandler; class MDSMonitor : public PaxosService, public PaxosFSMap, protected CommandHandler { public: - MDSMonitor(Monitor *mn, Paxos *p, std::string service_name); + MDSMonitor(Monitor &mn, Paxos &p, std::string service_name); // service methods void create_initial() override; @@ -70,7 +70,7 @@ class MDSMonitor : public PaxosService, public PaxosFSMap, protected CommandHand */ bool fail_mds_gid(FSMap &fsmap, mds_gid_t gid); - bool is_leader() const override { return mon->is_leader(); } + bool is_leader() const override { return mon.is_leader(); } protected: using mds_info_t = MDSMap::mds_info_t; diff --git a/src/mon/MgrMonitor.cc b/src/mon/MgrMonitor.cc index cd5d6305e0e..97c36f2924d 100644 --- a/src/mon/MgrMonitor.cc +++ b/src/mon/MgrMonitor.cc @@ -58,10 +58,10 @@ using ceph::make_message; using ceph::mono_clock; using ceph::mono_time; -static ostream& _prefix(std::ostream *_dout, Monitor *mon, +static ostream& _prefix(std::ostream *_dout, Monitor &mon, const MgrMap& mgrmap) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").mgr e" << mgrmap.get_epoch() << " "; } @@ -210,7 +210,7 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) dout(4) << "mkfs or daemon transitioned to available, loading commands" << dendl; bufferlist loaded_commands; - int r = mon->store->get(command_descs_prefix, "", loaded_commands); + int r = mon.store->get(command_descs_prefix, "", loaded_commands); if (r < 0) { derr << "Failed to load mgr commands: " << cpp_strerror(r) << dendl; } else { @@ -269,9 +269,9 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) } // force ConfigMonitor to refresh, since it uses const Option * // pointers into our mgr_module_options (which we just rebuilt). - mon->configmon()->load_config(); + mon.configmon()->load_config(); - if (!mon->is_init()) { + if (!mon.is_init()) { // feed our pet MgrClient, unless we are in Monitor::[pre]init() prime_mgr_client(); } @@ -280,7 +280,7 @@ void MgrMonitor::update_from_paxos(bool *need_bootstrap) void MgrMonitor::prime_mgr_client() { dout(10) << __func__ << dendl; - mon->mgr_client.ms_dispatch2(make_message<MMgrMap>(map)); + mon.mgr_client.ms_dispatch2(make_message<MMgrMap>(map)); } void MgrMonitor::create_pending() @@ -295,8 +295,8 @@ health_status_t MgrMonitor::should_warn_about_mgr_down() // we warn if we have osds AND we've exceeded the grace period // which means a new mon cluster and be HEALTH_OK indefinitely as long as // no OSDs are ever created. - if (mon->osdmon()->osdmap.get_num_osds() > 0 && - now > mon->monmap->created + g_conf().get_val<int64_t>("mon_mgr_mkfs_grace")) { + if (mon.osdmon()->osdmap.get_num_osds() > 0 && + now > mon.monmap->created + g_conf().get_val<int64_t>("mon_mgr_mkfs_grace")) { health_status_t level = HEALTH_WARN; if (first_seen_inactive != utime_t() && now - first_seen_inactive > g_conf().get_val<int64_t>("mon_mgr_inactive_grace")) { @@ -313,12 +313,12 @@ void MgrMonitor::post_paxos_update() if (digest_event) { bool send = false; if (prev_health_checks.empty()) { - prev_health_checks.resize(mon->paxos_service.size()); + prev_health_checks.resize(mon.paxos_service.size()); send = true; } - ceph_assert(prev_health_checks.size() == mon->paxos_service.size()); + ceph_assert(prev_health_checks.size() == mon.paxos_service.size()); for (auto i = 0u; i < prev_health_checks.size(); i++) { - const auto& curr = mon->paxos_service[i]->get_health_checks(); + const auto& curr = mon.paxos_service[i]->get_health_checks(); if (!send && curr != prev_health_checks[i]) { send = true; } @@ -329,7 +329,7 @@ void MgrMonitor::post_paxos_update() send_digests(); } else { cancel_timer(); - wait_for_active_ctx(new C_MonContext{mon, [this](int) { + wait_for_active_ctx(new C_MonContext{&mon, [this](int) { send_digests(); }}); } @@ -341,7 +341,7 @@ void MgrMonitor::encode_pending(MonitorDBStore::TransactionRef t) { dout(10) << __func__ << " " << pending_map << dendl; bufferlist bl; - pending_map.encode(bl, mon->get_quorum_con_features()); + pending_map.encode(bl, mon.get_quorum_con_features()); put_version(t, pending_map.epoch, bl); put_last_committed(t, pending_map.epoch); @@ -393,9 +393,9 @@ bool MgrMonitor::check_caps(MonOpRequestRef op, const uuid_d& fsid) dout(1) << __func__ << " insufficient caps " << session->caps << dendl; return false; } - if (fsid != mon->monmap->fsid) { + if (fsid != mon.monmap->fsid) { dout(1) << __func__ << " op fsid " << fsid - << " != " << mon->monmap->fsid << dendl; + << " != " << mon.monmap->fsid << dendl; return false; } return true; @@ -412,12 +412,12 @@ bool MgrMonitor::preprocess_query(MonOpRequestRef op) return preprocess_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } default: - mon->no_reply(op); + mon.no_reply(op); derr << "Unhandled message type " << m->get_type() << dendl; return true; } @@ -435,12 +435,12 @@ bool MgrMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } default: - mon->no_reply(op); + mon.no_reply(op); derr << "Unhandled message type " << m->get_type() << dendl; return true; } @@ -458,7 +458,7 @@ public: if (r >= 0) { // Success } else if (r == -ECANCELED) { - mm->mon->no_reply(op); + mm->mon.no_reply(op); } else { mm->dispatch(op); // try again } @@ -468,7 +468,7 @@ public: bool MgrMonitor::preprocess_beacon(MonOpRequestRef op) { auto m = op->get_req<MMgrBeacon>(); - mon->no_reply(op); // we never reply to beacons + mon.no_reply(op); // we never reply to beacons dout(4) << "beacon from " << m->get_gid() << dendl; if (!check_caps(op, m->get_fsid())) { @@ -490,12 +490,12 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) && m->get_gid() != pending_map.active_gid) { dout(4) << "Active daemon restart (mgr." << m->get_name() << ")" << dendl; - mon->clog->info() << "Active manager daemon " << m->get_name() + mon.clog->info() << "Active manager daemon " << m->get_name() << " restarted"; - if (!mon->osdmon()->is_writeable()) { + if (!mon.osdmon()->is_writeable()) { dout(1) << __func__ << ": waiting for osdmon writeable to" " blocklist old instance." << dendl; - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } drop_active(); @@ -506,7 +506,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) const MgrMap::StandbyInfo &s = i.second; if (s.name == m->get_name() && s.gid != m->get_gid()) { dout(4) << "Standby daemon restart (mgr." << m->get_name() << ")" << dendl; - mon->clog->debug() << "Standby manager daemon " << m->get_name() + mon.clog->debug() << "Standby manager daemon " << m->get_name() << " restarted"; drop_standby(i.first); break; @@ -536,7 +536,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) if (pending_map.get_available() != m->get_available()) { dout(4) << "available " << m->get_gid() << dendl; - mon->clog->info() << "Manager daemon " << pending_map.active_name + mon.clog->info() << "Manager daemon " << pending_map.active_name << " is now available"; // This beacon should include command descriptions @@ -586,7 +586,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) encode(m->get_metadata(), pending_metadata[m->get_name()]); pending_metadata_rm.erase(m->get_name()); - mon->clog->info() << "Activating manager daemon " + mon.clog->info() << "Activating manager daemon " << pending_map.active_name; updated = true; @@ -605,7 +605,7 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) } } else { dout(10) << "new standby " << m->get_gid() << dendl; - mon->clog->debug() << "Standby manager daemon " << m->get_name() + mon.clog->debug() << "Standby manager daemon " << m->get_name() << " started"; pending_map.standbys[m->get_gid()] = {m->get_gid(), m->get_name(), m->get_available_modules(), @@ -629,9 +629,9 @@ bool MgrMonitor::prepare_beacon(MonOpRequestRef op) void MgrMonitor::check_subs() { const std::string type = "mgrmap"; - if (mon->session_map.subs.count(type) == 0) + if (mon.session_map.subs.count(type) == 0) return; - for (auto sub : *(mon->session_map.subs[type])) { + for (auto sub : *(mon.session_map.subs[type])) { check_sub(sub); } } @@ -644,7 +644,7 @@ void MgrMonitor::check_sub(Subscription *sub) << " " << sub->session->con->get_peer_addr() << dendl; sub->session->con->send_message2(make_message<MMgrMap>(map)); if (sub->onetime) { - mon->session_map.remove_sub(sub); + mon.session_map.remove_sub(sub); } else { sub->next = map.get_epoch() + 1; } @@ -670,7 +670,7 @@ void MgrMonitor::send_digests() cancel_timer(); const std::string type = "mgrdigest"; - if (mon->session_map.subs.count(type) == 0) { + if (mon.session_map.subs.count(type) == 0) { prev_health_checks.clear(); return; } @@ -681,17 +681,17 @@ void MgrMonitor::send_digests() } dout(10) << __func__ << dendl; - for (auto sub : *(mon->session_map.subs[type])) { + for (auto sub : *(mon.session_map.subs[type])) { dout(10) << __func__ << " sending digest to subscriber " << sub->session->con << " " << sub->session->con->get_peer_addr() << dendl; auto mdigest = make_message<MMgrDigest>(); JSONFormatter f; - mon->healthmon()->get_health_status(true, &f, nullptr, nullptr, nullptr); + mon.healthmon()->get_health_status(true, &f, nullptr, nullptr, nullptr); f.flush(mdigest->health_json); f.reset(); - mon->get_mon_status(&f); + mon.get_mon_status(&f); f.flush(mdigest->mon_status_json); f.reset(); @@ -699,9 +699,9 @@ void MgrMonitor::send_digests() } timer: - digest_event = mon->timer.add_event_after( + digest_event = mon.timer.add_event_after( g_conf().get_val<int64_t>("mon_mgr_digest_period"), - new C_MonContext{mon, [this](int) { + new C_MonContext{&mon, [this](int) { send_digests(); }}); } @@ -709,18 +709,18 @@ timer: void MgrMonitor::cancel_timer() { if (digest_event) { - mon->timer.cancel_event(digest_event); + mon.timer.cancel_event(digest_event); digest_event = nullptr; } } void MgrMonitor::on_active() { - if (!mon->is_leader()) { + if (!mon.is_leader()) { return; } - mon->clog->debug() << "mgrmap e" << map.epoch << ": " << map; - if (!HAVE_FEATURE(mon->get_quorum_con_features(), SERVER_NAUTILUS)) { + mon.clog->debug() << "mgrmap e" << map.epoch << ": " << map; + if (!HAVE_FEATURE(mon.get_quorum_con_features(), SERVER_NAUTILUS)) { return; } if (pending_map.always_on_modules == always_on_modules) { @@ -735,7 +735,7 @@ void MgrMonitor::on_active() void MgrMonitor::tick() { - if (!is_active() || !mon->is_leader()) + if (!is_active() || !mon.is_leader()) return; const auto now = ceph::coarse_mono_clock::now(); @@ -796,25 +796,25 @@ void MgrMonitor::tick() if (pending_map.active_gid != 0 && last_beacon.at(pending_map.active_gid) < cutoff - && mon->osdmon()->is_writeable()) { + && mon.osdmon()->is_writeable()) { const std::string old_active_name = pending_map.active_name; drop_active(); propose = true; dout(4) << "Dropping active" << pending_map.active_gid << dendl; if (promote_standby()) { dout(4) << "Promoted standby " << pending_map.active_gid << dendl; - mon->clog->info() << "Manager daemon " << old_active_name + mon.clog->info() << "Manager daemon " << old_active_name << " is unresponsive, replacing it with standby" << " daemon " << pending_map.active_name; } else { dout(4) << "Active is laggy but have no standbys to replace it" << dendl; - mon->clog->info() << "Manager daemon " << old_active_name + mon.clog->info() << "Manager daemon " << old_active_name << " is unresponsive. No standby daemons available."; } } else if (pending_map.active_gid == 0) { if (promote_standby()) { dout(4) << "Promoted standby " << pending_map.active_gid << dendl; - mon->clog->info() << "Activating manager daemon " + mon.clog->info() << "Activating manager daemon " << pending_map.active_name; propose = true; } @@ -830,7 +830,7 @@ void MgrMonitor::tick() } // obsolete modules? - if (mon->monmap->min_mon_release >= ceph_release_t::octopus && + if (mon.monmap->min_mon_release >= ceph_release_t::octopus && pending_map.module_enabled("orchestrator_cli")) { dout(10) << " disabling obsolete/renamed 'orchestrator_cli'" << dendl; // we don't need to enable 'orchestrator' because it's now always-on @@ -875,7 +875,7 @@ bool MgrMonitor::promote_standby() void MgrMonitor::drop_active() { - ceph_assert(mon->osdmon()->is_writeable()); + ceph_assert(mon.osdmon()->is_writeable()); if (last_beacon.count(pending_map.active_gid) > 0) { last_beacon.erase(pending_map.active_gid); @@ -887,13 +887,13 @@ void MgrMonitor::drop_active() dout(5) << "blocklisting previous mgr." << pending_map.active_name << "." << pending_map.active_gid << " (" << pending_map.active_addrs << ")" << dendl; - auto blocklist_epoch = mon->osdmon()->blocklist(pending_map.active_addrs, until); + auto blocklist_epoch = mon.osdmon()->blocklist(pending_map.active_addrs, until); /* blocklist RADOS clients in use by the mgr */ for (const auto& a : pending_map.clients) { - mon->osdmon()->blocklist(a, until); + mon.osdmon()->blocklist(a, until); } - request_proposal(mon->osdmon()); + request_proposal(mon.osdmon()); pending_metadata_rm.insert(pending_map.active_name); pending_metadata.erase(pending_map.active_name); @@ -933,13 +933,13 @@ bool MgrMonitor::preprocess_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1064,7 +1064,7 @@ bool MgrMonitor::preprocess_command(MonOpRequestRef op) reply: string rs; getline(ss, rs); - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return true; } @@ -1078,13 +1078,13 @@ bool MgrMonitor::prepare_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", rdata, get_last_committed()); return true; } @@ -1113,8 +1113,8 @@ bool MgrMonitor::prepare_command(MonOpRequestRef op) if (!err.empty()) { // Does not parse as a gid, treat it as a name if (pending_map.active_name == who) { - if (!mon->osdmon()->is_writeable()) { - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + if (!mon.osdmon()->is_writeable()) { + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } drop_active(); @@ -1136,8 +1136,8 @@ bool MgrMonitor::prepare_command(MonOpRequestRef op) } } else { if (pending_map.active_gid == gid) { - if (!mon->osdmon()->is_writeable()) { - mon->osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + if (!mon.osdmon()->is_writeable()) { + mon.osdmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } drop_active(); @@ -1228,7 +1228,7 @@ out: return true; } else { // reply immediately - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return false; } } @@ -1249,7 +1249,7 @@ int MgrMonitor::load_metadata(const string& name, std::map<string, string>& m, ostream *err) const { bufferlist bl; - int r = mon->store->get(MGR_METADATA_PREFIX, name, bl); + int r = mon.store->get(MGR_METADATA_PREFIX, name, bl); if (r < 0) return r; try { diff --git a/src/mon/MgrMonitor.h b/src/mon/MgrMonitor.h index dabd9386e25..5df70fc3634 100644 --- a/src/mon/MgrMonitor.h +++ b/src/mon/MgrMonitor.h @@ -71,7 +71,7 @@ class MgrMonitor: public PaxosService std::vector<MonCommand> pending_command_descs; public: - MgrMonitor(Monitor *mn, Paxos *p, const std::string& service_name) + MgrMonitor(Monitor &mn, Paxos &p, const std::string& service_name) : PaxosService(mn, p, service_name) {} ~MgrMonitor() override {} diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index b0172be2b69..40a322d7698 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -42,13 +42,13 @@ using ceph::make_message; using ceph::mono_clock; using ceph::mono_time; -static ostream& _prefix(std::ostream *_dout, Monitor *mon) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() +static ostream& _prefix(std::ostream *_dout, Monitor &mon) { + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").mgrstat "; } -MgrStatMonitor::MgrStatMonitor(Monitor *mn, Paxos *p, const string& service_name) +MgrStatMonitor::MgrStatMonitor(Monitor &mn, Paxos &p, const string& service_name) : PaxosService(mn, p, service_name) { } @@ -93,25 +93,25 @@ void MgrStatMonitor::update_from_paxos(bool *need_bootstrap) } check_subs(); update_logger(); - mon->osdmon()->notify_new_pg_digest(); + mon.osdmon()->notify_new_pg_digest(); } void MgrStatMonitor::update_logger() { dout(20) << __func__ << dendl; - mon->cluster_logger->set(l_cluster_osd_bytes, digest.osd_sum.statfs.total); - mon->cluster_logger->set(l_cluster_osd_bytes_used, + mon.cluster_logger->set(l_cluster_osd_bytes, digest.osd_sum.statfs.total); + mon.cluster_logger->set(l_cluster_osd_bytes_used, digest.osd_sum.statfs.get_used_raw()); - mon->cluster_logger->set(l_cluster_osd_bytes_avail, + mon.cluster_logger->set(l_cluster_osd_bytes_avail, digest.osd_sum.statfs.available); - mon->cluster_logger->set(l_cluster_num_pool, digest.pg_pool_sum.size()); + mon.cluster_logger->set(l_cluster_num_pool, digest.pg_pool_sum.size()); uint64_t num_pg = 0; for (auto i : digest.num_pg_by_pool) { num_pg += i.second; } - mon->cluster_logger->set(l_cluster_num_pg, num_pg); + mon.cluster_logger->set(l_cluster_num_pg, num_pg); unsigned active = 0, active_clean = 0, peering = 0; for (auto p = digest.num_pg_by_state.begin(); @@ -125,15 +125,15 @@ void MgrStatMonitor::update_logger() if (p->first & PG_STATE_PEERING) peering += p->second; } - mon->cluster_logger->set(l_cluster_num_pg_active_clean, active_clean); - mon->cluster_logger->set(l_cluster_num_pg_active, active); - mon->cluster_logger->set(l_cluster_num_pg_peering, peering); + mon.cluster_logger->set(l_cluster_num_pg_active_clean, active_clean); + mon.cluster_logger->set(l_cluster_num_pg_active, active); + mon.cluster_logger->set(l_cluster_num_pg_peering, peering); - mon->cluster_logger->set(l_cluster_num_object, digest.pg_sum.stats.sum.num_objects); - mon->cluster_logger->set(l_cluster_num_object_degraded, digest.pg_sum.stats.sum.num_objects_degraded); - mon->cluster_logger->set(l_cluster_num_object_misplaced, digest.pg_sum.stats.sum.num_objects_misplaced); - mon->cluster_logger->set(l_cluster_num_object_unfound, digest.pg_sum.stats.sum.num_objects_unfound); - mon->cluster_logger->set(l_cluster_num_bytes, digest.pg_sum.stats.sum.num_bytes); + mon.cluster_logger->set(l_cluster_num_object, digest.pg_sum.stats.sum.num_objects); + mon.cluster_logger->set(l_cluster_num_object_degraded, digest.pg_sum.stats.sum.num_objects_degraded); + mon.cluster_logger->set(l_cluster_num_object_misplaced, digest.pg_sum.stats.sum.num_objects_misplaced); + mon.cluster_logger->set(l_cluster_num_object_unfound, digest.pg_sum.stats.sum.num_objects_unfound); + mon.cluster_logger->set(l_cluster_num_bytes, digest.pg_sum.stats.sum.num_bytes); } @@ -143,7 +143,7 @@ void MgrStatMonitor::create_pending() pending_digest = digest; pending_health_checks = get_health_checks(); pending_service_map_bl.clear(); - encode(service_map, pending_service_map_bl, mon->get_quorum_con_features()); + encode(service_map, pending_service_map_bl, mon.get_quorum_con_features()); } void MgrStatMonitor::encode_pending(MonitorDBStore::TransactionRef t) @@ -151,7 +151,7 @@ void MgrStatMonitor::encode_pending(MonitorDBStore::TransactionRef t) ++version; dout(10) << " " << version << dendl; bufferlist bl; - encode(pending_digest, bl, mon->get_quorum_con_features()); + encode(pending_digest, bl, mon.get_quorum_con_features()); ceph_assert(pending_service_map_bl.length()); bl.append(pending_service_map_bl); encode(pending_progress_events, bl); @@ -190,7 +190,7 @@ bool MgrStatMonitor::preprocess_query(MonOpRequestRef op) case MSG_GETPOOLSTATS: return preprocess_getpoolstats(op); default: - mon->no_reply(op); + mon.no_reply(op); derr << "Unhandled message type " << m->get_type() << dendl; return true; } @@ -203,7 +203,7 @@ bool MgrStatMonitor::prepare_update(MonOpRequestRef op) case MSG_MON_MGR_REPORT: return prepare_report(op); default: - mon->no_reply(op); + mon.no_reply(op); derr << "Unhandled message type " << m->get_type() << dendl; return true; } @@ -211,7 +211,7 @@ bool MgrStatMonitor::prepare_update(MonOpRequestRef op) bool MgrStatMonitor::preprocess_report(MonOpRequestRef op) { - mon->no_reply(op); + mon.no_reply(op); return false; } @@ -267,16 +267,16 @@ bool MgrStatMonitor::preprocess_getpoolstats(MonOpRequestRef op) << session->caps << dendl; return true; } - if (m->fsid != mon->monmap->fsid) { + if (m->fsid != mon.monmap->fsid) { dout(0) << __func__ << " on fsid " - << m->fsid << " != " << mon->monmap->fsid << dendl; + << m->fsid << " != " << mon.monmap->fsid << dendl; return true; } epoch_t ver = get_last_committed(); auto reply = new MGetPoolStatsReply(m->fsid, m->get_tid(), ver); reply->per_pool = digest.use_per_pool_stats(); for (const auto& pool_name : m->pools) { - const auto pool_id = mon->osdmon()->osdmap.lookup_pg_pool_name(pool_name); + const auto pool_id = mon.osdmon()->osdmap.lookup_pg_pool_name(pool_name); if (pool_id == -ENOENT) continue; auto pool_stat = get_pool_stat(pool_id); @@ -284,7 +284,7 @@ bool MgrStatMonitor::preprocess_getpoolstats(MonOpRequestRef op) continue; reply->pool_stats[pool_name] = *pool_stat; } - mon->send_reply(op, reply); + mon.send_reply(op, reply); return true; } @@ -301,13 +301,13 @@ bool MgrStatMonitor::preprocess_statfs(MonOpRequestRef op) << session->caps << dendl; return true; } - if (statfs->fsid != mon->monmap->fsid) { + if (statfs->fsid != mon.monmap->fsid) { dout(0) << __func__ << " on fsid " << statfs->fsid - << " != " << mon->monmap->fsid << dendl; + << " != " << mon.monmap->fsid << dendl; return true; } const auto& pool = statfs->data_pool; - if (pool && !mon->osdmon()->osdmap.have_pg_pool(*pool)) { + if (pool && !mon.osdmon()->osdmap.have_pg_pool(*pool)) { // There's no error field for MStatfsReply so just ignore the request. // This is known to happen when a client is still accessing a removed fs. dout(1) << __func__ << " on removed pool " << *pool << dendl; @@ -317,14 +317,14 @@ bool MgrStatMonitor::preprocess_statfs(MonOpRequestRef op) << " from " << statfs->get_orig_source() << dendl; epoch_t ver = get_last_committed(); auto reply = new MStatfsReply(statfs->fsid, statfs->get_tid(), ver); - reply->h.st = get_statfs(mon->osdmon()->osdmap, pool); - mon->send_reply(op, reply); + reply->h.st = get_statfs(mon.osdmon()->osdmap, pool); + mon.send_reply(op, reply); return true; } void MgrStatMonitor::check_sub(Subscription *sub) { - const auto epoch = mon->monmap->get_epoch(); + const auto epoch = mon.monmap->get_epoch(); dout(10) << __func__ << " next " << sub->next << " have " << epoch << dendl; @@ -332,7 +332,7 @@ void MgrStatMonitor::check_sub(Subscription *sub) auto m = new MServiceMap(service_map); sub->session->con->send_message(m); if (sub->onetime) { - mon->with_session_map([sub](MonSessionMap& session_map) { + mon.with_session_map([sub](MonSessionMap& session_map) { session_map.remove_sub(sub); }); } else { @@ -347,8 +347,8 @@ void MgrStatMonitor::check_subs() if (!service_map.epoch) { return; } - auto subs = mon->session_map.subs.find("servicemap"); - if (subs == mon->session_map.subs.end()) { + auto subs = mon.session_map.subs.find("servicemap"); + if (subs == mon.session_map.subs.end()) { return; } auto p = subs->second->begin(); diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index 500399b3a52..7c31f2c13f6 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -22,7 +22,7 @@ class MgrStatMonitor : public PaxosService { ceph::buffer::list pending_service_map_bl; public: - MgrStatMonitor(Monitor *mn, Paxos *p, const std::string& service_name); + MgrStatMonitor(Monitor &mn, Paxos &p, const std::string& service_name); ~MgrStatMonitor() override; void init() override {} diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index ba6ab1ebe78..9b50d8e9859 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -238,17 +238,17 @@ Monitor::Monitor(CephContext* cct_, string nm, MonitorDBStore *s, g_conf().get_val<uint64_t>("mon_op_history_slow_op_size"), g_conf().get_val<std::chrono::seconds>("mon_op_history_slow_op_threshold").count()); - paxos = std::make_unique<Paxos>(this, "paxos"); - - paxos_service[PAXOS_MDSMAP].reset(new MDSMonitor(this, paxos.get(), "mdsmap")); - paxos_service[PAXOS_MONMAP].reset(new MonmapMonitor(this, paxos.get(), "monmap")); - paxos_service[PAXOS_OSDMAP].reset(new OSDMonitor(cct, this, paxos.get(), "osdmap")); - paxos_service[PAXOS_LOG].reset(new LogMonitor(this, paxos.get(), "logm")); - paxos_service[PAXOS_AUTH].reset(new AuthMonitor(this, paxos.get(), "auth")); - paxos_service[PAXOS_MGR].reset(new MgrMonitor(this, paxos.get(), "mgr")); - paxos_service[PAXOS_MGRSTAT].reset(new MgrStatMonitor(this, paxos.get(), "mgrstat")); - paxos_service[PAXOS_HEALTH].reset(new HealthMonitor(this, paxos.get(), "health")); - paxos_service[PAXOS_CONFIG].reset(new ConfigMonitor(this, paxos.get(), "config")); + paxos = std::make_unique<Paxos>(*this, "paxos"); + + paxos_service[PAXOS_MDSMAP].reset(new MDSMonitor(*this, *paxos, "mdsmap")); + paxos_service[PAXOS_MONMAP].reset(new MonmapMonitor(*this, *paxos, "monmap")); + paxos_service[PAXOS_OSDMAP].reset(new OSDMonitor(cct, *this, *paxos, "osdmap")); + paxos_service[PAXOS_LOG].reset(new LogMonitor(*this, *paxos, "logm")); + paxos_service[PAXOS_AUTH].reset(new AuthMonitor(*this, *paxos, "auth")); + paxos_service[PAXOS_MGR].reset(new MgrMonitor(*this, *paxos, "mgr")); + paxos_service[PAXOS_MGRSTAT].reset(new MgrStatMonitor(*this, *paxos, "mgrstat")); + paxos_service[PAXOS_HEALTH].reset(new HealthMonitor(*this, *paxos, "health")); + paxos_service[PAXOS_CONFIG].reset(new ConfigMonitor(*this, *paxos, "config")); config_key_service = std::make_unique<ConfigKeyService>(this, paxos.get()); @@ -1368,9 +1368,7 @@ set<string> Monitor::get_sync_targets_names() for (auto& svc : paxos_service) { svc->get_store_prefixes(targets); } - auto config_key_service_ptr = dynamic_cast<ConfigKeyService*>(config_key_service.get()); - ceph_assert(config_key_service_ptr); - config_key_service_ptr->get_store_prefixes(targets); + config_key_service->get_store_prefixes(targets); return targets; } diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index cf1f9867bde..233a4a7e44f 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -842,14 +842,14 @@ public: public: struct C_Command : public C_MonOp { - Monitor *mon; + Monitor &mon; int rc; std::string rs; ceph::buffer::list rdata; version_t version; - C_Command(Monitor *_mm, MonOpRequestRef _op, int r, std::string s, version_t v) : + C_Command(Monitor &_mm, MonOpRequestRef _op, int r, std::string s, version_t v) : C_MonOp(_op), mon(_mm), rc(r), rs(s), version(v){} - C_Command(Monitor *_mm, MonOpRequestRef _op, int r, std::string s, ceph::buffer::list rd, version_t v) : + C_Command(Monitor &_mm, MonOpRequestRef _op, int r, std::string s, ceph::buffer::list rd, version_t v) : C_MonOp(_op), mon(_mm), rc(r), rs(s), rdata(rd), version(v){} void _finish(int r) override { @@ -871,13 +871,13 @@ public: } ss << "cmd='" << m->cmd << "': finished"; - mon->audit_clog->info() << ss.str(); - mon->reply_command(op, rc, rs, rdata, version); + mon.audit_clog->info() << ss.str(); + mon.reply_command(op, rc, rs, rdata, version); } else if (r == -ECANCELED) return; else if (r == -EAGAIN) - mon->dispatch_op(op); + mon.dispatch_op(op); else ceph_abort_msg("bad C_Command return value"); } diff --git a/src/mon/MonmapMonitor.cc b/src/mon/MonmapMonitor.cc index 4669e5872f6..75652e00a2f 100644 --- a/src/mon/MonmapMonitor.cc +++ b/src/mon/MonmapMonitor.cc @@ -58,16 +58,16 @@ using ceph::make_message; using ceph::mono_clock; using ceph::mono_time; using ceph::timespan_str; -static ostream& _prefix(std::ostream *_dout, Monitor *mon) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() - << ").monmap v" << mon->monmap->epoch << " "; +static ostream& _prefix(std::ostream *_dout, Monitor &mon) { + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() + << ").monmap v" << mon.monmap->epoch << " "; } void MonmapMonitor::create_initial() { dout(10) << __func__ << " using current monmap" << dendl; - pending_map = *mon->monmap; + pending_map = *mon.monmap; pending_map.epoch = 1; if (g_conf()->mon_debug_no_initial_persistent_features) { @@ -83,13 +83,13 @@ void MonmapMonitor::create_initial() void MonmapMonitor::update_from_paxos(bool *need_bootstrap) { version_t version = get_last_committed(); - if (version <= mon->monmap->get_epoch()) + if (version <= mon.monmap->get_epoch()) return; dout(10) << __func__ << " version " << version - << ", my v " << mon->monmap->epoch << dendl; + << ", my v " << mon.monmap->epoch << dendl; - if (need_bootstrap && version != mon->monmap->get_epoch()) { + if (need_bootstrap && version != mon.monmap->get_epoch()) { dout(10) << " signaling that we need a bootstrap" << dendl; *need_bootstrap = true; } @@ -101,32 +101,32 @@ void MonmapMonitor::update_from_paxos(bool *need_bootstrap) ceph_assert(monmap_bl.length()); dout(10) << __func__ << " got " << version << dendl; - mon->monmap->decode(monmap_bl); + mon.monmap->decode(monmap_bl); - if (mon->store->exists("mkfs", "monmap")) { + if (mon.store->exists("mkfs", "monmap")) { auto t(std::make_shared<MonitorDBStore::Transaction>()); t->erase("mkfs", "monmap"); - mon->store->apply_transaction(t); + mon.store->apply_transaction(t); } check_subs(); // make sure we've recorded min_mon_release string val; - if (mon->store->read_meta("min_mon_release", &val) < 0 || + if (mon.store->read_meta("min_mon_release", &val) < 0 || val.size() == 0 || atoi(val.c_str()) != (int)ceph_release()) { dout(10) << __func__ << " updating min_mon_release meta" << dendl; - mon->store->write_meta("min_mon_release", + mon.store->write_meta("min_mon_release", stringify(ceph_release())); } - mon->notify_new_monmap(); + mon.notify_new_monmap(); } void MonmapMonitor::create_pending() { - pending_map = *mon->monmap; + pending_map = *mon.monmap; pending_map.epoch++; pending_map.last_changed = ceph_clock_now(); dout(10) << __func__ << " monmap epoch " << pending_map.epoch << dendl; @@ -136,17 +136,17 @@ void MonmapMonitor::encode_pending(MonitorDBStore::TransactionRef t) { dout(10) << __func__ << " epoch " << pending_map.epoch << dendl; - ceph_assert(mon->monmap->epoch + 1 == pending_map.epoch || + ceph_assert(mon.monmap->epoch + 1 == pending_map.epoch || pending_map.epoch == 1); // special case mkfs! bufferlist bl; - pending_map.encode(bl, mon->get_quorum_con_features()); + pending_map.encode(bl, mon.get_quorum_con_features()); put_version(t, pending_map.epoch, bl); put_last_committed(t, pending_map.epoch); // generate a cluster fingerprint, too? if (pending_map.epoch == 1) { - mon->prepare_new_fingerprint(t); + mon.prepare_new_fingerprint(t); } //health @@ -185,7 +185,7 @@ void MonmapMonitor::apply_mon_features(const mon_feature_t& features, } // do nothing here unless we have a full quorum - if (mon->get_quorum().size() < mon->monmap->size()) { + if (mon.get_quorum().size() < mon.monmap->size()) { return; } @@ -226,7 +226,7 @@ void MonmapMonitor::apply_mon_features(const mon_feature_t& features, void MonmapMonitor::on_active() { - if (get_last_committed() >= 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; @@ -238,16 +238,16 @@ void MonmapMonitor::on_active() */ auto t(std::make_shared<MonitorDBStore::Transaction>()); t->put(Monitor::MONITOR_NAME, "joined", 1); - mon->store->apply_transaction(t); - mon->has_ever_joined = true; + mon.store->apply_transaction(t); + mon.has_ever_joined = true; } - if (mon->is_leader()) { - mon->clog->debug() << "monmap " << *mon->monmap; + if (mon.is_leader()) { + mon.clog->debug() << "monmap " << *mon.monmap; } - apply_mon_features(mon->get_quorum_mon_features(), - mon->quorum_min_mon_release); + apply_mon_features(mon.get_quorum_mon_features(), + mon.quorum_min_mon_release); } bool MonmapMonitor::preprocess_query(MonOpRequestRef op) @@ -261,7 +261,7 @@ bool MonmapMonitor::preprocess_query(MonOpRequestRef op) } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } case MSG_MON_JOIN: @@ -277,10 +277,10 @@ void MonmapMonitor::dump_info(Formatter *f) f->dump_unsigned("monmap_first_committed", get_first_committed()); f->dump_unsigned("monmap_last_committed", get_last_committed()); f->open_object_section("monmap"); - mon->monmap->dump(f); + mon.monmap->dump(f); f->close_section(); f->open_array_section("quorum"); - for (set<int>::iterator q = mon->get_quorum().begin(); q != mon->get_quorum().end(); ++q) + for (set<int>::iterator q = mon.get_quorum().begin(); q != mon.get_quorum().end(); ++q) f->dump_int("mon", *q); f->close_section(); } @@ -295,7 +295,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, rdata, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, rdata, get_last_committed()); return true; } @@ -304,7 +304,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -315,11 +315,11 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) if (prefix == "mon stat") { if (f) { f->open_object_section("monmap"); - mon->monmap->dump_summary(f.get()); - f->dump_string("leader", mon->get_leader_name()); + mon.monmap->dump_summary(f.get()); + f->dump_string("leader", mon.get_leader_name()); f->open_array_section("quorum"); - for (auto rank: mon->get_quorum()) { - std::string name = mon->monmap->get_name(rank); + for (auto rank: mon.get_quorum()) { + std::string name = mon.monmap->get_name(rank); f->open_object_section("mon"); f->dump_int("rank", rank); f->dump_string("name", name); @@ -329,11 +329,11 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) f->close_section(); // monmap f->flush(ss); } else { - mon->monmap->print_summary(ss); - ss << ", election epoch " << mon->get_epoch() << ", leader " - << mon->get_leader() << " " << mon->get_leader_name() - << ", quorum " << mon->get_quorum() - << " " << mon->get_quorum_names(); + mon.monmap->print_summary(ss); + ss << ", election epoch " << mon.get_epoch() << ", leader " + << mon.get_leader() << " " << mon.get_leader_name() + << ", quorum " << mon.get_quorum() + << " " << mon.get_quorum_names(); } rdata.append(ss); @@ -348,7 +348,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) cmd_getval(cmdmap, "epoch", epochnum, (int64_t)0); epoch = epochnum; - MonMap *p = mon->monmap; + MonMap *p = mon.monmap; if (epoch) { bufferlist bl; r = get_version(epoch, bl); @@ -374,8 +374,8 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) f->open_object_section("monmap"); p->dump(f.get()); f->open_array_section("quorum"); - for (set<int>::iterator q = mon->get_quorum().begin(); - q != mon->get_quorum().end(); ++q) { + for (set<int>::iterator q = mon.get_quorum().begin(); + q != mon.get_quorum().end(); ++q) { f->dump_int("mon", *q); } f->close_section(); @@ -389,7 +389,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) rdata.append(ds); ss << "dumped monmap epoch " << p->get_epoch(); } - if (p != mon->monmap) { + if (p != mon.monmap) { delete p; p = nullptr; } @@ -403,7 +403,7 @@ bool MonmapMonitor::preprocess_command(MonOpRequestRef op) list_with_value = true; } - MonMap *p = mon->monmap; + MonMap *p = mon.monmap; // list features mon_feature_t supported = ceph::features::mon::get_supported(); @@ -472,7 +472,7 @@ reply: string rs; getline(ss, rs); - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return true; } else return false; @@ -490,7 +490,7 @@ bool MonmapMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } case MSG_MON_JOIN: @@ -512,7 +512,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } @@ -521,7 +521,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) MonSession *session = op->get_session(); if (!session) { - mon->reply_command(op, -EACCES, "access denied", get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -553,8 +553,8 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) * state, thus we are not bound by it. */ - ceph_assert(mon->monmap); - MonMap &monmap = *mon->monmap; + ceph_assert(mon.monmap); + MonMap &monmap = *mon.monmap; /* Please note: @@ -595,7 +595,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) cmd_getval(cmdmap, "location", locationvec); CrushWrapper::parse_loc_map(locationvec, &loc); if (locationvec.size() && - !mon->get_quorum_mon_features().contains_all( + !mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_PINGING)) { err = -ENOTSUP; ss << "Not all monitors support adding monitors with a location; please upgrade first!"; @@ -797,10 +797,10 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) goto reply; } - if (!mon->get_quorum_mon_features().contains_all(feature)) { + if (!mon.get_quorum_mon_features().contains_all(feature)) { ss << "current quorum does not support feature '" << feature << "'; supported features: " - << mon->get_quorum_mon_features(); + << mon.get_quorum_mon_features(); err = -EINVAL; goto reply; } @@ -916,7 +916,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) } err = 0; } else if (prefix == "mon set election_strategy") { - if (!mon->get_quorum_mon_features().contains_all( + if (!mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_PINGING)) { err = -ENOTSUP; ss << "Not all monitors support changing election strategies; please upgrade first!"; @@ -942,7 +942,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) pending_map.strategy = strategy; propose = true; } else if (prefix == "mon add disallowed_leader") { - if (!mon->get_quorum_mon_features().contains_all( + if (!mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_PINGING)) { err = -ENOTSUP; ss << "Not all monitors support changing election strategies; please upgrade first!"; @@ -978,7 +978,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) err = 0; propose = true; } else if (prefix == "mon rm disallowed_leader") { - if (!mon->get_quorum_mon_features().contains_all( + if (!mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_PINGING)) { err = -ENOTSUP; ss << "Not all monitors support changing election strategies; please upgrade first!"; @@ -1009,7 +1009,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) err = 0; propose = true; } else if (prefix == "mon set_location") { - if (!mon->get_quorum_mon_features().contains_all( + if (!mon.get_quorum_mon_features().contains_all( ceph::features::mon::FEATURE_PINGING)) { err = -ENOTSUP; ss << "Not all monitors support monitor locations; please upgrade first!"; @@ -1026,11 +1026,11 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) goto reply; } - if (!mon->osdmon()->is_readable()) { - mon->osdmon()->wait_for_readable(op, new Monitor::C_RetryMessage(mon, op)); + if (!mon.osdmon()->is_readable()) { + mon.osdmon()->wait_for_readable(op, new Monitor::C_RetryMessage(&mon, op)); } CrushWrapper crush; - mon->osdmon()->_get_pending_crush(crush); + mon.osdmon()->_get_pending_crush(crush); vector<string> argvec; map<string, string> loc; cmd_getval(cmdmap, "args", argvec); @@ -1050,10 +1050,10 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) err = 0; propose = true; } else if (prefix == "mon enable_stretch_mode") { - if (!mon->osdmon()->is_writeable()) { + if (!mon.osdmon()->is_writeable()) { dout(1) << __func__ << ": waiting for osdmon writeable for stretch mode" << dendl; - mon->osdmon()->wait_for_writeable(op, new Monitor::C_RetryMessage(mon, op)); + mon.osdmon()->wait_for_writeable(op, new Monitor::C_RetryMessage(&mon, op)); return false; } { @@ -1086,20 +1086,20 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) goto reply; } //okay, initial arguments make sense, check pools and cluster state - err = mon->osdmon()->check_cluster_features(CEPH_FEATUREMASK_STRETCH_MODE, ss); + err = mon.osdmon()->check_cluster_features(CEPH_FEATUREMASK_STRETCH_MODE, ss); if (err) goto reply; struct Plugger { - Paxos *p; - Plugger(Paxos *p) : p(p) { p->plug(); } - ~Plugger() { p->unplug(); } + Paxos &p; + Plugger(Paxos &p) : p(p) { p.plug(); } + ~Plugger() { p.unplug(); } } plugger(paxos); set<pg_pool_t*> pools; bool okay = false; int errcode = 0; - mon->osdmon()->try_enable_stretch_mode_pools(ss, &okay, &errcode, + mon.osdmon()->try_enable_stretch_mode_pools(ss, &okay, &errcode, &pools, new_crush_rule); if (!okay) { err = errcode; @@ -1111,7 +1111,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) err = errcode; goto reply; } - mon->osdmon()->try_enable_stretch_mode(ss, &okay, &errcode, false, + mon.osdmon()->try_enable_stretch_mode(ss, &okay, &errcode, false, dividing_bucket, 2, pools, new_crush_rule); if (!okay) { err = errcode; @@ -1120,13 +1120,13 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) // everything looks good, actually commit the changes! try_enable_stretch_mode(ss, &okay, &errcode, true, tiebreaker_mon, dividing_bucket); - mon->osdmon()->try_enable_stretch_mode(ss, &okay, &errcode, true, + mon.osdmon()->try_enable_stretch_mode(ss, &okay, &errcode, true, dividing_bucket, 2, // right now we only support 2 sites pools, new_crush_rule); ceph_assert(okay == true); } - request_proposal(mon->osdmon()); + request_proposal(mon.osdmon()); err = 0; propose = true; } else { @@ -1136,7 +1136,7 @@ bool MonmapMonitor::prepare_command(MonOpRequestRef op) reply: getline(ss, rs); - mon->reply_command(op, err, rs, get_last_committed()); + mon.reply_command(op, err, rs, get_last_committed()); // we are returning to the user; do not propose. return propose; } @@ -1161,7 +1161,7 @@ void MonmapMonitor::try_enable_stretch_mode(stringstream& ss, bool *okay, return; } map<string,string> buckets; - for (const auto&mii : mon->monmap->mon_info) { + for (const auto&mii : mon.monmap->mon_info) { const auto& mi = mii.second; const auto& bi = mi.crush_loc.find(dividing_bucket); if (bi == mi.crush_loc.end()) { @@ -1288,7 +1288,7 @@ int MonmapMonitor::get_monmap(bufferlist &bl) version_t latest_ver = get_last_committed(); dout(10) << __func__ << " ver " << latest_ver << dendl; - if (!mon->store->exists(get_service_name(), stringify(latest_ver))) + if (!mon.store->exists(get_service_name(), stringify(latest_ver))) return -ENOENT; int err = get_version(latest_ver, bl); @@ -1303,7 +1303,7 @@ int MonmapMonitor::get_monmap(bufferlist &bl) void MonmapMonitor::check_subs() { const string type = "monmap"; - mon->with_session_map([this, &type](const MonSessionMap& session_map) { + mon.with_session_map([this, &type](const MonSessionMap& session_map) { auto subs = session_map.subs.find(type); if (subs == session_map.subs.end()) return; @@ -1315,14 +1315,14 @@ void MonmapMonitor::check_subs() void MonmapMonitor::check_sub(Subscription *sub) { - const auto epoch = mon->monmap->get_epoch(); + const auto epoch = mon.monmap->get_epoch(); dout(10) << __func__ << " monmap next " << sub->next << " have " << epoch << dendl; if (sub->next <= epoch) { - mon->send_latest_monmap(sub->session->con.get()); + mon.send_latest_monmap(sub->session->con.get()); if (sub->onetime) { - mon->with_session_map([sub](MonSessionMap& session_map) { + mon.with_session_map([sub](MonSessionMap& session_map) { session_map.remove_sub(sub); }); } else { @@ -1334,11 +1334,11 @@ void MonmapMonitor::check_sub(Subscription *sub) void MonmapMonitor::tick() { if (!is_active() || - !mon->is_leader()) { + !mon.is_leader()) { return; } - if (mon->monmap->created.is_zero()) { + if (mon.monmap->created.is_zero()) { dout(10) << __func__ << " detected empty created stamp" << dendl; utime_t ctime; for (version_t v = 1; v <= get_last_committed(); v++) { diff --git a/src/mon/MonmapMonitor.h b/src/mon/MonmapMonitor.h index b4cadacfa81..cf22ae9f8e3 100644 --- a/src/mon/MonmapMonitor.h +++ b/src/mon/MonmapMonitor.h @@ -31,7 +31,7 @@ class MonmapMonitor : public PaxosService { public: - MonmapMonitor(Monitor *mn, Paxos *p, const std::string& service_name) + MonmapMonitor(Monitor &mn, Paxos &p, const std::string& service_name) : PaxosService(mn, p, service_name) { } diff --git a/src/mon/OSDMonitor.cc b/src/mon/OSDMonitor.cc index ebc82e669a9..9f7b3c611a8 100644 --- a/src/mon/OSDMonitor.cc +++ b/src/mon/OSDMonitor.cc @@ -435,23 +435,23 @@ public: #undef dout_prefix #define dout_prefix _prefix(_dout, mon, osdmap) -static ostream& _prefix(std::ostream *_dout, Monitor *mon, const OSDMap& osdmap) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() +static ostream& _prefix(std::ostream *_dout, Monitor &mon, const OSDMap& osdmap) { + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").osd e" << osdmap.get_epoch() << " "; } OSDMonitor::OSDMonitor( CephContext *cct, - Monitor *mn, - Paxos *p, + Monitor &mn, + Paxos &p, const string& service_name) : PaxosService(mn, p, service_name), cct(cct), inc_osd_cache(g_conf()->mon_osd_cache_size), full_osd_cache(g_conf()->mon_osd_cache_size), has_osdmap_manifest(false), - mapper(mn->cct, &mn->cpu_tp) + mapper(mn.cct, &mn.cpu_tp) { inc_cache = std::make_shared<IncCache>(this); full_cache = std::make_shared<FullCache>(this); @@ -629,18 +629,18 @@ void OSDMonitor::_get_pending_crush(CrushWrapper& newcrush) void OSDMonitor::create_initial() { - dout(10) << "create_initial for " << mon->monmap->fsid << dendl; + dout(10) << "create_initial for " << mon.monmap->fsid << dendl; OSDMap newmap; bufferlist bl; - mon->store->get("mkfs", "osdmap", bl); + mon.store->get("mkfs", "osdmap", bl); if (bl.length()) { newmap.decode(bl); - newmap.set_fsid(mon->monmap->fsid); + newmap.set_fsid(mon.monmap->fsid); } else { - newmap.build_simple(cct, 0, mon->monmap->fsid, 0); + newmap.build_simple(cct, 0, mon.monmap->fsid, 0); } newmap.set_epoch(1); newmap.created = newmap.modified = ceph_clock_now(); @@ -755,7 +755,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) latest_full = 0; for (version_t v = lc; v >= fc; v--) { string full_key = "full_" + stringify(v); - if (mon->store->exists(get_service_name(), full_key)) { + if (mon.store->exists(get_service_name(), full_key)) { dout(10) << __func__ << " found latest full map v " << v << dendl; latest_full = v; break; @@ -765,7 +765,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) ceph_assert(latest_full > 0); auto t(std::make_shared<MonitorDBStore::Transaction>()); put_version_latest_full(t, latest_full); - mon->store->apply_transaction(t); + mon.store->apply_transaction(t); dout(10) << __func__ << " updated the on-disk full map version to " << latest_full << dendl; } @@ -780,7 +780,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) } bufferlist bl; - if (!mon->store->get(OSD_PG_CREATING_PREFIX, "creating", bl)) { + if (!mon.store->get(OSD_PG_CREATING_PREFIX, "creating", bl)) { auto p = bl.cbegin(); std::lock_guard<std::mutex> l(creating_pgs_lock); creating_pgs.decode(p); @@ -827,7 +827,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) // encode with all features. uint64_t f = inc.encode_features; if (!f) - f = mon->get_quorum_con_features(); + f = mon.get_quorum_con_features(); if (!f) f = -1; bufferlist full_bl; @@ -882,7 +882,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) } if (tx_size > g_conf()->mon_sync_max_payload_size*2) { - mon->store->apply_transaction(t); + mon.store->apply_transaction(t); t = MonitorDBStore::TransactionRef(); tx_size = 0; } @@ -905,7 +905,7 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) } if (t) { - mon->store->apply_transaction(t); + mon.store->apply_transaction(t); } bool marked_osd_down = false; @@ -939,17 +939,17 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) // make sure our feature bits reflect the latest map update_msgr_features(); - if (!mon->is_leader()) { + if (!mon.is_leader()) { // will be called by on_active() on the leader, avoid doing so twice start_mapping(); } if (osdmap.stretch_mode_enabled) { dout(20) << "Stretch mode enabled in this map" << dendl; - mon->maybe_engage_stretch_mode(); + mon.maybe_engage_stretch_mode(); if (osdmap.degraded_stretch_mode) { dout(20) << "Degraded stretch mode set in this map" << dendl; if (!osdmap.recovering_stretch_mode) { - mon->set_degraded_stretch_mode(); + mon.set_degraded_stretch_mode(); if (prev_num_up_osd < osdmap.num_up_osd && (osdmap.num_up_osd / (double)osdmap.num_osd) > cct->_conf.get_val<double>("mon_stretch_cluster_recovery_ratio")) { @@ -957,14 +957,14 @@ void OSDMonitor::update_from_paxos(bool *need_bootstrap) // trimmed and everything is "normal" but not if you have a lot of out OSDs // you're ignoring or in some really degenerate failure cases dout(10) << "Enabling recovery stretch mode in this map" << dendl; - mon->go_recovery_stretch_mode(); + mon.go_recovery_stretch_mode(); } } } if (marked_osd_down && (!osdmap.degraded_stretch_mode || osdmap.recovering_stretch_mode)) { dout(20) << "Checking degraded stretch mode due to osd changes" << dendl; - mon->maybe_go_degraded_stretch_mode(); + mon.maybe_go_degraded_stretch_mode(); } if (osdmap.recovering_stretch_mode && stretch_recovery_triggered.is_zero()) { stretch_recovery_triggered = ceph_clock_now(); @@ -995,7 +995,7 @@ int OSDMonitor::register_cache_with_pcm() max = ltarget - base; } - rocksdb_binned_kv_cache = mon->store->get_priority_cache(); + rocksdb_binned_kv_cache = mon.store->get_priority_cache(); if (!rocksdb_binned_kv_cache) { derr << __func__ << " not using rocksdb" << dendl; return -EINVAL; @@ -1079,11 +1079,11 @@ void OSDMonitor::update_msgr_features() for (int type : types) { uint64_t mask; uint64_t features = osdmap.get_features(type, &mask); - if ((mon->messenger->get_policy(type).features_required & mask) != features) { + if ((mon.messenger->get_policy(type).features_required & mask) != features) { dout(0) << "crush map has features " << features << ", adjusting msgr requires" << dendl; - ceph::net::Policy p = mon->messenger->get_policy(type); + ceph::net::Policy p = mon.messenger->get_policy(type); p.features_required = (p.features_required & ~mask) | features; - mon->messenger->set_policy(type, p); + mon.messenger->set_policy(type, p); } } } @@ -1092,8 +1092,8 @@ void OSDMonitor::on_active() { update_logger(); - if (mon->is_leader()) { - mon->clog->debug() << "osdmap " << osdmap; + if (mon.is_leader()) { + mon.clog->debug() << "osdmap " << osdmap; if (!priority_convert) { // Only do this once at start-up convert_pool_priorities(); @@ -1136,16 +1136,16 @@ void OSDMonitor::update_logger() { dout(10) << "update_logger" << dendl; - mon->cluster_logger->set(l_cluster_num_osd, osdmap.get_num_osds()); - mon->cluster_logger->set(l_cluster_num_osd_up, osdmap.get_num_up_osds()); - mon->cluster_logger->set(l_cluster_num_osd_in, osdmap.get_num_in_osds()); - mon->cluster_logger->set(l_cluster_osd_epoch, osdmap.get_epoch()); + mon.cluster_logger->set(l_cluster_num_osd, osdmap.get_num_osds()); + mon.cluster_logger->set(l_cluster_num_osd_up, osdmap.get_num_up_osds()); + mon.cluster_logger->set(l_cluster_num_osd_in, osdmap.get_num_in_osds()); + mon.cluster_logger->set(l_cluster_osd_epoch, osdmap.get_epoch()); } void OSDMonitor::create_pending() { pending_inc = OSDMap::Incremental(osdmap.epoch+1); - pending_inc.fsid = mon->monmap->fsid; + pending_inc.fsid = mon.monmap->fsid; pending_metadata.clear(); pending_metadata_rm.clear(); pending_pseudo_purged_snaps.clear(); @@ -1208,7 +1208,7 @@ void OSDMonitor::create_pending() dout(1) << __func__ << " " << i.first << " -> " << i.second << dendl; } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } } @@ -1310,7 +1310,7 @@ OSDMonitor::update_pending_pgs(const OSDMap::Incremental& inc, dout(10) << __func__ << " queue remaining: " << pending_creatings.queue.size() << " pools" << dendl; - if (mon->monmap->min_mon_release >= ceph_release_t::octopus) { + if (mon.monmap->min_mon_release >= ceph_release_t::octopus) { // walk creating pgs' history and past_intervals forward for (auto& i : pending_creatings.pgs) { // this mirrors PG::start_peering_interval() @@ -1653,7 +1653,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) auto pending_creatings = update_pending_pgs(pending_inc, tmp); bufferlist creatings_bl; uint64_t features = CEPH_FEATURES_ALL; - if (mon->monmap->min_mon_release < ceph_release_t::octopus) { + if (mon.monmap->min_mon_release < ceph_release_t::octopus) { dout(20) << __func__ << " encoding pending pgs without octopus features" << dendl; features &= ~CEPH_FEATURE_SERVER_OCTOPUS; @@ -1862,7 +1862,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) auto mv = tmp.get_min_compat_client(); dout(1) << __func__ << " setting require_min_compat_client to currently " << "required " << mv << dendl; - mon->clog->info() << "setting require_min_compat_client to currently " + mon.clog->info() << "setting require_min_compat_client to currently " << "required " << mv; pending_inc.new_require_min_compat_client = mv; } @@ -1932,7 +1932,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) // prior to this epoch, and store it in the current epoch (i.e., // the last pre-octopus epoch, just prior to the one we're // encoding now). - auto it = mon->store->get_iterator(OSD_SNAP_PREFIX); + auto it = mon.store->get_iterator(OSD_SNAP_PREFIX); it->lower_bound("purged_snap_"); map<int64_t,snap_interval_set_t> combined; while (it->valid()) { @@ -2027,7 +2027,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) << " features " << features << dendl; // the features should be a subset of the mon quorum's features! - ceph_assert((features & ~mon->get_quorum_con_features()) == 0); + ceph_assert((features & ~mon.get_quorum_con_features()) == 0); bufferlist fullbl; encode(tmp, fullbl, features | CEPH_FEATURE_RESERVED); @@ -2098,7 +2098,7 @@ void OSDMonitor::encode_pending(MonitorDBStore::TransactionRef t) int OSDMonitor::load_metadata(int osd, map<string, string>& m, ostream *err) { bufferlist bl; - int r = mon->store->get(OSD_METADATA_PREFIX, stringify(osd), bl); + int r = mon.store->get(OSD_METADATA_PREFIX, stringify(osd), bl); if (r < 0) return r; try { @@ -2232,7 +2232,7 @@ void OSDMonitor::share_map_with_random_osd() return; } - MonSession *s = mon->session_map.get_random_osd_session(&osdmap); + MonSession *s = mon.session_map.get_random_osd_session(&osdmap); if (!s) { dout(10) << __func__ << " no up osd on our session map" << dendl; return; @@ -2244,7 +2244,7 @@ void OSDMonitor::share_map_with_random_osd() // get feature of the peer // use quorum_con_features, if it's an anonymous connection. uint64_t features = s->con_features ? s->con_features : - mon->get_quorum_con_features(); + mon.get_quorum_con_features(); // whatev, they'll request more if they need it MOSDMap *m = build_incremental(osdmap.get_epoch() - 1, osdmap.get_epoch(), features); s->con->send_message(m); @@ -2254,7 +2254,7 @@ void OSDMonitor::share_map_with_random_osd() version_t OSDMonitor::get_trim_to() const { - if (mon->get_quorum().empty()) { + if (mon.get_quorum().empty()) { dout(10) << __func__ << " quorum not formed, trim_to = 0" << dendl; return 0; } @@ -2336,7 +2336,7 @@ void OSDMonitor::encode_trim_extra(MonitorDBStore::TransactionRef tx, void OSDMonitor::load_osdmap_manifest() { bool store_has_manifest = - mon->store->exists(get_service_name(), "osdmap_manifest"); + mon.store->exists(get_service_name(), "osdmap_manifest"); if (!store_has_manifest) { if (!has_osdmap_manifest) { @@ -2478,7 +2478,7 @@ void OSDMonitor::prune_init(osdmap_manifest_t& manifest) // the trim that *must* have removed past the last pinned map in a // previous prune). ceph_assert(osdmap_manifest.pinned.empty()); - ceph_assert(!mon->store->exists(get_service_name(), "osdmap_manifest")); + ceph_assert(!mon.store->exists(get_service_name(), "osdmap_manifest")); pin_first = get_first_committed(); } else { @@ -2553,7 +2553,7 @@ bool OSDMonitor::is_prune_enabled() const { } bool OSDMonitor::is_prune_supported() const { - return mon->get_required_mon_features().contains_any( + return mon.get_required_mon_features().contains_any( ceph::features::mon::FEATURE_OSDMAP_PRUNE); } @@ -2617,8 +2617,8 @@ bool OSDMonitor::do_prune(MonitorDBStore::TransactionRef tx) // hundreds or thousands of maps. auto map_exists = [this](version_t v) { - string k = mon->store->combine_strings("full", v); - return mon->store->exists(get_service_name(), k); + string k = mon.store->combine_strings("full", v); + return mon.store->exists(get_service_name(), k); }; // 'interval' represents the number of maps from the last pinned @@ -2671,7 +2671,7 @@ bool OSDMonitor::do_prune(MonitorDBStore::TransactionRef tx) ceph_assert(!manifest.is_pinned(v)); dout(20) << __func__ << " pruning full osdmap e" << v << dendl; - string full_key = mon->store->combine_strings("full", v); + string full_key = mon.store->combine_strings("full", v); tx->erase(get_service_name(), full_key); ++num_pruned; } @@ -2702,7 +2702,7 @@ bool OSDMonitor::preprocess_query(MonOpRequestRef op) return preprocess_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } case CEPH_MSG_MON_GET_OSDMAP: @@ -2779,7 +2779,7 @@ bool OSDMonitor::prepare_update(MonOpRequestRef op) return prepare_command(op); } catch (const bad_cmd_get& e) { bufferlist bl; - mon->reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); + mon.reply_command(op, -EINVAL, e.what(), bl, get_last_committed()); return true; } @@ -2828,12 +2828,12 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op) op->mark_osdmon_event(__func__); auto m = op->get_req<MMonGetOSDMap>(); - uint64_t features = mon->get_quorum_con_features(); + uint64_t features = mon.get_quorum_con_features(); if (op->get_session() && op->get_session()->con_features) features = op->get_session()->con_features; dout(10) << __func__ << " " << *m << dendl; - MOSDMap *reply = new MOSDMap(mon->monmap->fsid, features); + MOSDMap *reply = new MOSDMap(mon.monmap->fsid, features); epoch_t first = get_first_committed(); epoch_t last = osdmap.get_epoch(); int max = g_conf()->osd_map_message_max; @@ -2856,7 +2856,7 @@ bool OSDMonitor::preprocess_get_osdmap(MonOpRequestRef op) } reply->oldest_map = first; reply->newest_map = last; - mon->send_reply(op, reply); + mon.send_reply(op, reply); return true; } @@ -2876,9 +2876,9 @@ bool OSDMonitor::check_source(MonOpRequestRef op, uuid_d fsid) { << session->caps << dendl; return true; } - if (fsid != mon->monmap->fsid) { + if (fsid != mon.monmap->fsid) { dout(0) << "check_source: on fsid " << fsid - << " != " << mon->monmap->fsid << dendl; + << " != " << mon.monmap->fsid << dendl; return true; } return false; @@ -2953,7 +2953,7 @@ bool OSDMonitor::preprocess_failure(MonOpRequestRef op) return false; didit: - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -2968,7 +2968,7 @@ public: void _finish(int r) override { if (r == 0) { auto m = op->get_req<MOSDMarkMeDown>(); - osdmon->mon->send_reply( + osdmon->mon.send_reply( op, new MOSDMarkMeDown( m->fsid, @@ -3034,7 +3034,7 @@ bool OSDMonitor::prepare_mark_me_down(MonOpRequestRef op) ceph_assert(osdmap.is_up(target_osd)); ceph_assert(osdmap.get_addrs(target_osd) == m->target_addrs); - mon->clog->info() << "osd." << target_osd << " marked itself down"; + mon.clog->info() << "osd." << target_osd << " marked itself down"; pending_inc.new_state[target_osd] = CEPH_OSD_UP; if (m->request_ack) wait_for_finished_proposal(op, new C_AckMarkedDown(this, op)); @@ -3049,13 +3049,13 @@ bool OSDMonitor::preprocess_mark_me_dead(MonOpRequestRef op) // check permissions if (check_source(op, m->fsid)) { - mon->no_reply(op); + mon.no_reply(op); return true; } // first, verify the reporting host is valid if (!m->get_orig_source().is_osd()) { - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -3064,7 +3064,7 @@ bool OSDMonitor::preprocess_mark_me_dead(MonOpRequestRef op) dout(5) << __func__ << " from nonexistent or up osd." << from << ", ignoring" << dendl; send_incremental(op, m->get_epoch()+1); - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -3079,7 +3079,7 @@ bool OSDMonitor::prepare_mark_me_dead(MonOpRequestRef op) ceph_assert(osdmap.is_down(target_osd)); - mon->clog->info() << "osd." << target_osd << " marked itself dead as of e" + mon.clog->info() << "osd." << target_osd << " marked itself dead as of e" << m->get_epoch(); if (!pending_inc.new_xinfo.count(target_osd)) { pending_inc.new_xinfo[target_osd] = osdmap.osd_xinfo[target_osd]; @@ -3090,7 +3090,7 @@ bool OSDMonitor::prepare_mark_me_dead(MonOpRequestRef op) new LambdaContext( [op, this] (int r) { if (r >= 0) { - mon->no_reply(op); // ignore on success + mon.no_reply(op); // ignore on success } } )); @@ -3269,7 +3269,7 @@ bool OSDMonitor::check_failure(utime_t now, int target_osd, failure_info_t& fi) << " down" << dendl; pending_inc.new_state[target_osd] = CEPH_OSD_UP; - mon->clog->info() << "osd." << target_osd << " failed (" + mon.clog->info() << "osd." << target_osd << " failed (" << osdmap.crush->get_full_location_ordered_string( target_osd) << ") (" @@ -3298,7 +3298,7 @@ void OSDMonitor::force_failure(int target_osd, int by) } pending_inc.new_xinfo[target_osd].dead_epoch = pending_inc.epoch; - mon->clog->info() << "osd." << target_osd << " failed (" + mon.clog->info() << "osd." << target_osd << " failed (" << osdmap.crush->get_full_location_ordered_string(target_osd) << ") (connection refused reported by osd." << by << ")"; return; @@ -3318,7 +3318,7 @@ bool OSDMonitor::prepare_failure(MonOpRequestRef op) ceph_assert(osdmap.is_up(target_osd)); ceph_assert(osdmap.get_addrs(target_osd) == m->get_target_addrs()); - mon->no_reply(op); + mon.no_reply(op); if (m->if_osd_failed()) { // calculate failure time @@ -3328,32 +3328,32 @@ bool OSDMonitor::prepare_failure(MonOpRequestRef op) // add a report if (m->is_immediate()) { - mon->clog->debug() << "osd." << m->get_target_osd() + mon.clog->debug() << "osd." << m->get_target_osd() << " reported immediately failed by " << m->get_orig_source(); force_failure(target_osd, reporter); return true; } - mon->clog->debug() << "osd." << m->get_target_osd() << " reported failed by " + mon.clog->debug() << "osd." << m->get_target_osd() << " reported failed by " << m->get_orig_source(); failure_info_t& fi = failure_info[target_osd]; MonOpRequestRef old_op = fi.add_report(reporter, failed_since, op); if (old_op) { - mon->no_reply(old_op); + mon.no_reply(old_op); } return check_failure(now, target_osd, fi); } else { // remove the report - mon->clog->debug() << "osd." << m->get_target_osd() + mon.clog->debug() << "osd." << m->get_target_osd() << " failure report canceled by " << m->get_orig_source(); if (failure_info.count(target_osd)) { failure_info_t& fi = failure_info[target_osd]; MonOpRequestRef report_op = fi.cancel_report(reporter); if (report_op) { - mon->no_reply(report_op); + mon.no_reply(report_op); } if (fi.reporters.empty()) { dout(10) << " removing last failure_info for osd." << target_osd @@ -3389,7 +3389,7 @@ void OSDMonitor::process_failures() o->mark_event(__func__); MOSDFailure *m = o->get_req<MOSDFailure>(); send_latest(o, m->get_epoch()); - mon->no_reply(o); + mon.no_reply(o); } ls.pop_front(); } @@ -3461,9 +3461,9 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op) goto ignore; } - if (m->sb.cluster_fsid != mon->monmap->fsid) { + if (m->sb.cluster_fsid != mon.monmap->fsid) { dout(0) << "preprocess_boot on fsid " << m->sb.cluster_fsid - << " != " << mon->monmap->fsid << dendl; + << " != " << mon.monmap->fsid << dendl; goto ignore; } @@ -3496,7 +3496,7 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op) stringstream ss; copy(begin(missing), end(missing), make_ostream_joiner(ss, ";")); - mon->clog->info() << "disallowing boot of OSD " + mon.clog->info() << "disallowing boot of OSD " << m->get_orig_source_inst() << " because the osd lacks " << ss.str(); goto ignore; @@ -3506,14 +3506,14 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op) // make sure osd versions do not span more than 3 releases if (HAVE_FEATURE(m->osd_features, SERVER_OCTOPUS) && osdmap.require_osd_release < ceph_release_t::mimic) { - mon->clog->info() << "disallowing boot of octopus+ OSD " + mon.clog->info() << "disallowing boot of octopus+ OSD " << m->get_orig_source_inst() << " because require_osd_release < mimic"; goto ignore; } if (HAVE_FEATURE(m->osd_features, SERVER_PACIFIC) && osdmap.require_osd_release < ceph_release_t::nautilus) { - mon->clog->info() << "disallowing boot of pacific+ OSD " + mon.clog->info() << "disallowing boot of pacific+ OSD " << m->get_orig_source_inst() << " because require_osd_release < nautilus"; goto ignore; @@ -3524,7 +3524,7 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op) if (osdmap.require_osd_release >= ceph_release_t::luminous && osdmap.test_flag(CEPH_OSDMAP_PGLOG_HARDLIMIT) && !(m->osd_features & CEPH_FEATURE_OSD_PGLOG_HARDLIMIT)) { - mon->clog->info() << "disallowing boot of OSD " + mon.clog->info() << "disallowing boot of OSD " << m->get_orig_source_inst() << " because 'pglog_hardlimit' osdmap flag is set and OSD lacks the OSD_PGLOG_HARDLIMIT feature"; goto ignore; @@ -3532,7 +3532,7 @@ bool OSDMonitor::preprocess_boot(MonOpRequestRef op) if (osdmap.stretch_mode_enabled && !(m->osd_features & CEPH_FEATUREMASK_STRETCH_MODE)) { - mon->clog->info() << "disallowing boot of OSD " + mon.clog->info() << "disallowing boot of OSD " << m->get_orig_source_inst() << " because stretch mode is on and OSD lacks support"; goto ignore; @@ -3746,7 +3746,7 @@ void OSDMonitor::_booted(MonOpRequestRef op, bool logit) << " w " << m->sb.weight << " from " << m->sb.current_epoch << dendl; if (logit) { - mon->clog->info() << m->get_source() << " " << m->get_orig_source_addrs() + mon.clog->info() << m->get_source() << " " << m->get_orig_source_addrs() << " boot"; } @@ -3895,7 +3895,7 @@ bool OSDMonitor::prepare_alive(MonOpRequestRef op) int from = m->get_orig_source().num(); if (0) { // we probably don't care much about these - mon->clog->debug() << m->get_orig_source_inst() << " alive"; + mon.clog->debug() << m->get_orig_source_inst() << " alive"; } dout(7) << "prepare_alive want up_thru " << m->want << " have " << m->version @@ -3922,7 +3922,7 @@ bool OSDMonitor::preprocess_pg_created(MonOpRequestRef op) auto m = op->get_req<MOSDPGCreated>(); dout(10) << __func__ << " " << *m << dendl; auto session = op->get_session(); - mon->no_reply(op); + mon.no_reply(op); if (!session) { dout(10) << __func__ << ": no monitor session!" << dendl; return true; @@ -3944,8 +3944,8 @@ bool OSDMonitor::prepare_pg_created(MonOpRequestRef op) auto src = m->get_orig_source(); auto from = src.num(); if (!src.is_osd() || - !mon->osdmon()->osdmap.is_up(from) || - !mon->osdmon()->osdmap.get_addrs(from).legacy_equals( + !mon.osdmon()->osdmap.is_up(from) || + !mon.osdmon()->osdmap.get_addrs(from).legacy_equals( m->get_orig_source_addrs())) { dout(1) << __func__ << " ignoring stats from non-active osd." << dendl; return false; @@ -3990,7 +3990,7 @@ bool OSDMonitor::preprocess_pg_ready_to_merge(MonOpRequestRef op) return false; ignore: - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -4037,13 +4037,13 @@ bool OSDMonitor::prepare_pg_ready_to_merge(MonOpRequestRef op) prob > 0 && prob > (double)(rand() % 1000)/1000.0) { derr << __func__ << " injecting pg merge pg_num bounce" << dendl; - auto n = new MMonCommand(mon->monmap->get_fsid()); + auto n = new MMonCommand(mon.monmap->get_fsid()); n->set_connection(m->get_connection()); n->cmd = { "{\"prefix\":\"osd pool set\", \"pool\": \"" + osdmap.get_pool_name(m->pgid.pool()) + "\", \"var\": \"pg_num_actual\", \"val\": \"" + stringify(m->pgid.ps() + 1) + "\"}" }; - MonOpRequestRef nop = mon->op_tracker.create_request<MonOpRequest>(n); + MonOpRequestRef nop = mon.op_tracker.create_request<MonOpRequest>(n); nop->set_type_service(); wait_for_finished_proposal(op, new C_RetryMessage(this, nop)); } else { @@ -4146,7 +4146,7 @@ bool OSDMonitor::preprocess_pgtemp(MonOpRequestRef op) return true; ignore: - mon->no_reply(op); + mon.no_reply(op); return true; } @@ -4210,7 +4210,7 @@ bool OSDMonitor::preprocess_remove_snaps(MonOpRequestRef op) // check privilege, ignore if failed MonSession *session = op->get_session(); - mon->no_reply(op); + mon.no_reply(op); if (!session) goto ignore; if (!session->caps.is_capable( @@ -4245,7 +4245,7 @@ bool OSDMonitor::preprocess_remove_snaps(MonOpRequestRef op) if (HAVE_FEATURE(m->get_connection()->get_features(), SERVER_OCTOPUS)) { auto reply = make_message<MRemoveSnaps>(); reply->snaps = m->snaps; - mon->send_reply(op, reply.detach()); + mon.send_reply(op, reply.detach()); } ignore: @@ -4310,7 +4310,7 @@ bool OSDMonitor::preprocess_get_purged_snaps(MonOpRequestRef op) map<epoch_t,mempool::osdmap::map<int64_t,snap_interval_set_t>> r; string k = make_purged_snap_epoch_key(m->start); - auto it = mon->store->get_iterator(OSD_SNAP_PREFIX); + auto it = mon.store->get_iterator(OSD_SNAP_PREFIX); it->upper_bound(k); unsigned long epoch = m->last; while (it->valid()) { @@ -4346,7 +4346,7 @@ bool OSDMonitor::preprocess_get_purged_snaps(MonOpRequestRef op) auto reply = make_message<MMonGetPurgedSnapsReply>(m->start, epoch); reply->purged_snaps.swap(r); - mon->send_reply(op, reply.detach()); + mon.send_reply(op, reply.detach()); return true; } @@ -4357,7 +4357,7 @@ bool OSDMonitor::preprocess_beacon(MonOpRequestRef op) op->mark_osdmon_event(__func__); // check caps auto session = op->get_session(); - mon->no_reply(op); + mon.no_reply(op); if (!session) { dout(10) << __func__ << " no monitor session!" << dendl; return true; @@ -4432,7 +4432,7 @@ void OSDMonitor::send_latest(MonOpRequestRef op, epoch_t start) MOSDMap *OSDMonitor::build_latest_full(uint64_t features) { - MOSDMap *r = new MOSDMap(mon->monmap->fsid, features); + MOSDMap *r = new MOSDMap(mon.monmap->fsid, features); get_version_full(osdmap.get_epoch(), features, r->maps[osdmap.get_epoch()]); r->oldest_map = get_first_committed(); r->newest_map = osdmap.get_epoch(); @@ -4443,7 +4443,7 @@ MOSDMap *OSDMonitor::build_incremental(epoch_t from, epoch_t to, uint64_t featur { dout(10) << "build_incremental [" << from << ".." << to << "] with features " << std::hex << features << std::dec << dendl; - MOSDMap *m = new MOSDMap(mon->monmap->fsid, features); + MOSDMap *m = new MOSDMap(mon.monmap->fsid, features); m->oldest_map = get_first_committed(); m->newest_map = osdmap.get_epoch(); @@ -4477,7 +4477,7 @@ void OSDMonitor::send_full(MonOpRequestRef op) { op->mark_osdmon_event(__func__); dout(5) << "send_full to " << op->get_req()->get_orig_source_inst() << dendl; - mon->send_reply(op, build_latest_full(op->get_session()->con_features)); + mon.send_reply(op, build_latest_full(op->get_session()->con_features)); } void OSDMonitor::send_incremental(MonOpRequestRef op, epoch_t first) @@ -4512,7 +4512,7 @@ void OSDMonitor::send_incremental(epoch_t first, // get feature of the peer // use quorum_con_features, if it's an anonymous connection. uint64_t features = session->con_features ? session->con_features : - mon->get_quorum_con_features(); + mon.get_quorum_con_features(); if (first <= session->osd_epoch) { dout(10) << __func__ << " " << session->name << " should already have epoch " @@ -4535,7 +4535,7 @@ void OSDMonitor::send_incremental(epoch_t first, m->maps[first] = bl; if (req) { - mon->send_reply(req, m); + mon.send_reply(req, m); session->osd_epoch = first; return; } else { @@ -4553,7 +4553,7 @@ void OSDMonitor::send_incremental(epoch_t first, if (req) { // send some maps. it may not be all of them, but it will get them // started. - mon->send_reply(req, m); + mon.send_reply(req, m); } else { session->con->send_message(m); first = last + 1; @@ -4566,7 +4566,7 @@ void OSDMonitor::send_incremental(epoch_t first, int OSDMonitor::get_version(version_t ver, bufferlist& bl) { - return get_version(ver, mon->get_quorum_con_features(), bl); + return get_version(ver, mon.get_quorum_con_features(), bl); } void OSDMonitor::reencode_incremental_map(bufferlist& bl, uint64_t features) @@ -4625,7 +4625,7 @@ int OSDMonitor::get_version(version_t ver, uint64_t features, bufferlist& bl) // reencode once and then cache the (identical) result under both // feature masks. if (significant_features != - OSDMap::get_significant_features(mon->get_quorum_con_features())) { + OSDMap::get_significant_features(mon.get_quorum_con_features())) { reencode_incremental_map(bl, features); } inc_osd_cache.add_bytes({ver, significant_features}, bl); @@ -4668,7 +4668,7 @@ int OSDMonitor::get_full_from_pinned_map(version_t ver, bufferlist& bl) bufferlist osdm_bl; bool has_cached_osdmap = false; for (version_t v = ver-1; v >= closest_pinned; --v) { - if (full_osd_cache.lookup({v, mon->get_quorum_con_features()}, + if (full_osd_cache.lookup({v, mon.get_quorum_con_features()}, &osdm_bl)) { dout(10) << __func__ << " found map in cache ver " << v << dendl; closest_pinned = v; @@ -4715,7 +4715,7 @@ int OSDMonitor::get_full_from_pinned_map(version_t ver, bufferlist& bl) uint64_t f = encode_features; if (!f) { - f = (mon->quorum_con_features ? mon->quorum_con_features : -1); + f = (mon.quorum_con_features ? mon.quorum_con_features : -1); } // encode osdmap to force calculating crcs @@ -4742,7 +4742,7 @@ int OSDMonitor::get_full_from_pinned_map(version_t ver, bufferlist& bl) << " last incremental map didn't have features;" << " defaulting to quorum's or all" << dendl; encode_features = - (mon->quorum_con_features ? mon->quorum_con_features : -1); + (mon.quorum_con_features ? mon.quorum_con_features : -1); } osdm.encode(bl, encode_features | CEPH_FEATURE_RESERVED); @@ -4751,7 +4751,7 @@ int OSDMonitor::get_full_from_pinned_map(version_t ver, bufferlist& bl) int OSDMonitor::get_version_full(version_t ver, bufferlist& bl) { - return get_version_full(ver, mon->get_quorum_con_features(), bl); + return get_version_full(ver, mon.get_quorum_con_features(), bl); } int OSDMonitor::get_version_full(version_t ver, uint64_t features, @@ -4774,7 +4774,7 @@ int OSDMonitor::get_version_full(version_t ver, uint64_t features, // reencode once and then cache the (identical) result under both // feature masks. if (significant_features != - OSDMap::get_significant_features(mon->get_quorum_con_features())) { + OSDMap::get_significant_features(mon.get_quorum_con_features())) { reencode_full_map(bl, features); } full_osd_cache.add_bytes({ver, significant_features}, bl); @@ -4814,8 +4814,8 @@ void OSDMonitor::check_osdmap_subs() if (!osdmap.get_epoch()) { return; } - auto osdmap_subs = mon->session_map.subs.find("osdmap"); - if (osdmap_subs == mon->session_map.subs.end()) { + auto osdmap_subs = mon.session_map.subs.find("osdmap"); + if (osdmap_subs == mon.session_map.subs.end()) { return; } auto p = osdmap_subs->second->begin(); @@ -4836,7 +4836,7 @@ void OSDMonitor::check_osdmap_sub(Subscription *sub) else sub->session->con->send_message(build_latest_full(sub->session->con_features)); if (sub->onetime) - mon->session_map.remove_sub(sub); + mon.session_map.remove_sub(sub); else sub->next = osdmap.get_epoch() + 1; } @@ -4848,7 +4848,7 @@ void OSDMonitor::check_pg_creates_subs() return; } ceph_assert(osdmap.get_up_osd_features() & CEPH_FEATURE_MON_STATEFUL_SUB); - mon->with_session_map([this](const MonSessionMap& session_map) { + mon.with_session_map([this](const MonSessionMap& session_map) { auto pg_creates_subs = session_map.subs.find("osd_pg_creates"); if (pg_creates_subs == session_map.subs.end()) { return; @@ -4866,7 +4866,7 @@ void OSDMonitor::check_pg_creates_sub(Subscription *sub) // only send these if the OSD is up. we will check_subs() when they do // come up so they will get the creates then. if (sub->session->name.is_osd() && - mon->osdmon()->osdmap.is_up(sub->session->name.num())) { + mon.osdmon()->osdmap.is_up(sub->session->name.num())) { sub->next = send_pg_creates(sub->session->name.num(), sub->session->con.get(), sub->next); @@ -4879,7 +4879,7 @@ void OSDMonitor::do_application_enable(int64_t pool_id, const std::string &app_value, bool force) { - ceph_assert(paxos->is_plugged() && is_writeable()); + ceph_assert(paxos.is_plugged() && is_writeable()); dout(20) << __func__ << ": pool_id=" << pool_id << ", app_name=" << app_name << dendl; @@ -5110,7 +5110,7 @@ void OSDMonitor::tick() } } - if (!mon->is_leader()) return; + if (!mon.is_leader()) return; bool do_propose = false; utime_t now = ceph_clock_now(); @@ -5209,7 +5209,7 @@ void OSDMonitor::tick() do_propose = true; - mon->clog->info() << "Marking osd." << o << " out (has been down for " + mon.clog->info() << "Marking osd." << o << " out (has been down for " << int(down.sec()) << " seconds)"; } else continue; @@ -5272,7 +5272,7 @@ bool OSDMonitor::handle_osd_timeouts(const utime_t &now, std::map<int, std::pair<utime_t, int>> &last_osd_report) { utime_t timeo(g_conf()->mon_osd_report_timeout, 0); - if (now - mon->get_leader_since() < timeo) { + if (now - mon.get_leader_since() < timeo) { // We haven't been the leader for long enough to consider OSD timeouts return false; } @@ -5300,7 +5300,7 @@ bool OSDMonitor::handle_osd_timeouts(const utime_t &now, int mon_osd_report_timeout = g_conf()->mon_osd_report_timeout; utime_t max_timeout(std::max(mon_osd_report_timeout, 2 * t->second.second), 0); if (diff > max_timeout) { - mon->clog->info() << "osd." << i << " marked down after no beacon for " + mon.clog->info() << "osd." << i << " marked down after no beacon for " << diff << " seconds"; derr << "no beacon from osd." << i << " since " << t->second.first << ", " << diff << " seconds ago. marking down" << dendl; @@ -5424,14 +5424,14 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { derr << __func__ << " no session" << dendl; - mon->reply_command(op, -EACCES, "access denied", get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -5620,7 +5620,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) rdata.append(osdmap_bl); ss << "got osdmap epoch " << p->get_epoch(); } else if (prefix == "osd getcrushmap") { - p->crush->encode(rdata, mon->get_quorum_con_features()); + p->crush->encode(rdata, mon.get_quorum_con_features()); ss << p->get_crush_version(); } else if (prefix == "osd ls-tree") { string bucket_name; @@ -6551,7 +6551,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) goto reply; } const pg_pool_t *p = osdmap.get_pg_pool(poolid); - const pool_stat_t* pstat = mon->mgrstatmon()->get_pool_stat(poolid); + const pool_stat_t* pstat = mon.mgrstatmon()->get_pool_stat(poolid); const object_stat_sum_t& sum = pstat->stats.sum; if (f) { f->open_object_section("pool_quotas"); @@ -6984,7 +6984,7 @@ bool OSDMonitor::preprocess_command(MonOpRequestRef op) reply: string rs; getline(ss, rs); - mon->reply_command(op, r, rs, rdata, get_last_committed()); + mon.reply_command(op, r, rs, rdata, get_last_committed()); return true; } @@ -7037,7 +7037,7 @@ int OSDMonitor::lookup_purged_snap( snapid_t *begin, snapid_t *end) { string k = make_purged_snap_key(pool, snap); - auto it = mon->store->get_iterator(OSD_SNAP_PREFIX); + auto it = mon.store->get_iterator(OSD_SNAP_PREFIX); it->lower_bound(k); if (!it->valid()) { dout(20) << __func__ @@ -7140,7 +7140,7 @@ void OSDMonitor::insert_purged_snap_update( bool OSDMonitor::try_prune_purged_snaps() { - if (!mon->mgrstatmon()->is_readable()) { + if (!mon.mgrstatmon()->is_readable()) { return false; } if (!pending_inc.new_purged_snaps.empty()) { @@ -7155,7 +7155,7 @@ bool OSDMonitor::try_prune_purged_snaps() dout(10) << __func__ << " max_prune " << max_prune << dendl; unsigned actually_pruned = 0; - auto& purged_snaps = mon->mgrstatmon()->get_digest().purged_snaps; + auto& purged_snaps = mon.mgrstatmon()->get_digest().purged_snaps; for (auto& p : osdmap.get_pools()) { auto q = purged_snaps.find(p.first); if (q == purged_snaps.end()) { @@ -7219,14 +7219,14 @@ bool OSDMonitor::try_prune_purged_snaps() bool OSDMonitor::update_pools_status() { - if (!mon->mgrstatmon()->is_readable()) + if (!mon.mgrstatmon()->is_readable()) return false; bool ret = false; auto& pools = osdmap.get_pools(); for (auto it = pools.begin(); it != pools.end(); ++it) { - const pool_stat_t *pstat = mon->mgrstatmon()->get_pool_stat(it->first); + const pool_stat_t *pstat = mon.mgrstatmon()->get_pool_stat(it->first); if (!pstat) continue; const object_stat_sum_t& sum = pstat->stats.sum; @@ -7241,7 +7241,7 @@ bool OSDMonitor::update_pools_status() if (pool_is_full) continue; - mon->clog->info() << "pool '" << pool_name + mon.clog->info() << "pool '" << pool_name << "' no longer out of quota; removing NO_QUOTA flag"; // below we cancel FLAG_FULL too, we'll set it again in // OSDMonitor::encode_pending if it still fails the osd-full checking. @@ -7254,13 +7254,13 @@ bool OSDMonitor::update_pools_status() if (pool.quota_max_bytes > 0 && (uint64_t)sum.num_bytes >= pool.quota_max_bytes) { - mon->clog->warn() << "pool '" << pool_name << "' is full" + mon.clog->warn() << "pool '" << pool_name << "' is full" << " (reached quota's max_bytes: " << byte_u_t(pool.quota_max_bytes) << ")"; } if (pool.quota_max_objects > 0 && (uint64_t)sum.num_objects >= pool.quota_max_objects) { - mon->clog->warn() << "pool '" << pool_name << "' is full" + mon.clog->warn() << "pool '" << pool_name << "' is full" << " (reached quota's max_objects: " << pool.quota_max_objects << ")"; } @@ -7329,7 +7329,7 @@ int OSDMonitor::crush_rename_bucket(const string& srcname, return ret; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); *ss << "renamed bucket " << srcname << " into " << dstname; return 0; } @@ -7436,7 +7436,7 @@ int OSDMonitor::crush_rule_create_erasure(const string &name, return err; *rule = err; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); return 0; } } @@ -7469,7 +7469,7 @@ int OSDMonitor::check_cluster_features(uint64_t features, { stringstream unsupported_ss; int unsupported_count = 0; - if ((mon->get_quorum_con_features() & features) != features) { + if ((mon.get_quorum_con_features() & features) != features) { unsupported_ss << "the monitor cluster"; ++unsupported_count; } @@ -7512,7 +7512,7 @@ bool OSDMonitor::validate_crush_against_features(const CrushWrapper *newcrush, stringstream& ss) { OSDMap::Incremental new_pending = pending_inc; - encode(*newcrush, new_pending.crush, mon->get_quorum_con_features()); + encode(*newcrush, new_pending.crush, mon.get_quorum_con_features()); OSDMap newmap; newmap.deepish_copy_from(osdmap); newmap.apply_incremental(new_pending); @@ -8988,7 +8988,7 @@ int OSDMonitor::_prepare_command_osd_crush_remove( void OSDMonitor::do_osd_crush_remove(CrushWrapper& newcrush) { pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } int OSDMonitor::prepare_command_osd_crush_remove( @@ -9119,7 +9119,7 @@ out: dout(20) << __func__ << " set " << name << " device_class " << device_class << dendl; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } } else { dout(20) << __func__ << " no device_class" << dendl; @@ -9238,7 +9238,7 @@ int OSDMonitor::prepare_command_osd_new( string uuidstr; int64_t id = -1; - ceph_assert(paxos->is_plugged()); + ceph_assert(paxos.is_plugged()); dout(10) << __func__ << " " << op << dendl; @@ -9392,7 +9392,7 @@ int OSDMonitor::prepare_command_osd_new( dout(10) << __func__ << " validate secrets using osd id " << id << dendl; - err = mon->authmon()->validate_osd_new(id, uuid, + err = mon.authmon()->validate_osd_new(id, uuid, cephx_secret, lockbox_secret, cephx_entity, @@ -9409,7 +9409,7 @@ int OSDMonitor::prepare_command_osd_new( } if (has_lockbox) { - svc = (ConfigKeyService*)(mon->config_key_service.get()); + svc = (ConfigKeyService*)(mon.config_key_service.get()); err = svc->validate_osd_new(uuid, dmcrypt_key, ss); if (err < 0) { return err; @@ -9447,7 +9447,7 @@ int OSDMonitor::prepare_command_osd_new( ceph_assert((lockbox_secret.empty() && dmcrypt_key.empty()) || (!lockbox_secret.empty() && !dmcrypt_key.empty())); - err = mon->authmon()->do_osd_new(cephx_entity, + err = mon.authmon()->do_osd_new(cephx_entity, lockbox_entity, has_lockbox); ceph_assert(0 == err); @@ -9500,14 +9500,14 @@ bool OSDMonitor::prepare_command(MonOpRequestRef op) cmdmap_t cmdmap; if (!cmdmap_from_json(m->cmd, &cmdmap, ss)) { string rs = ss.str(); - mon->reply_command(op, -EINVAL, rs, get_last_committed()); + mon.reply_command(op, -EINVAL, rs, get_last_committed()); return true; } MonSession *session = op->get_session(); if (!session) { derr << __func__ << " no session" << dendl; - mon->reply_command(op, -EACCES, "access denied", get_last_committed()); + mon.reply_command(op, -EACCES, "access denied", get_last_committed()); return true; } @@ -9554,7 +9554,7 @@ int OSDMonitor::prepare_command_osd_destroy( int32_t id, stringstream& ss) { - ceph_assert(paxos->is_plugged()); + ceph_assert(paxos.is_plugged()); // we check if the osd exists for the benefit of `osd purge`, which may // have previously removed the osd. If the osd does not exist, return @@ -9582,7 +9582,7 @@ int OSDMonitor::prepare_command_osd_destroy( EntityName cephx_entity, lockbox_entity; bool idempotent_auth = false, idempotent_cks = false; - int err = mon->authmon()->validate_osd_destroy(id, uuid, + int err = mon.authmon()->validate_osd_destroy(id, uuid, cephx_entity, lockbox_entity, ss); @@ -9594,7 +9594,7 @@ int OSDMonitor::prepare_command_osd_destroy( } } - auto svc = (ConfigKeyService*)(mon->config_key_service.get()); + auto svc = (ConfigKeyService*)(mon.config_key_service.get()); err = svc->validate_osd_destroy(id, uuid); if (err < 0) { ceph_assert(err == -ENOENT); @@ -9603,7 +9603,7 @@ int OSDMonitor::prepare_command_osd_destroy( } if (!idempotent_auth) { - err = mon->authmon()->do_osd_destroy(cephx_entity, lockbox_entity); + err = mon.authmon()->do_osd_destroy(cephx_entity, lockbox_entity); ceph_assert(0 == err); } @@ -9626,7 +9626,7 @@ int OSDMonitor::prepare_command_osd_purge( int32_t id, stringstream& ss) { - ceph_assert(paxos->is_plugged()); + ceph_assert(paxos.is_plugged()); dout(10) << __func__ << " purging osd." << id << dendl; ceph_assert(!osdmap.is_up(id)); @@ -9780,8 +9780,8 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // (multiple racing updaters may not both get reliable success) // but we expect crush updaters (via this interface) to be rare-ish. bufferlist current, proposed; - osdmap.crush->encode(current, mon->get_quorum_con_features()); - crush.encode(proposed, mon->get_quorum_con_features()); + osdmap.crush->encode(current, mon.get_quorum_con_features()); + crush.encode(proposed, mon.get_quorum_con_features()); if (current.contents_equal(proposed)) { dout(10) << __func__ << " proposed matches current and version equals previous" @@ -9856,7 +9856,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, get_last_committed() + 1)); return true; @@ -9934,7 +9934,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!updated.empty()) { pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "set osd(s) " << updated << " to class '" << device_class << "'"; getline(ss, rs); wait_for_finished_proposal(op, @@ -9996,7 +9996,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (!updated.empty()) { pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "done removing class of osd(s): " << updated; getline(ss, rs); wait_for_finished_proposal(op, @@ -10028,7 +10028,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } int class_id = newcrush.get_or_create_class_id(device_class); pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "created class " << device_class << " with id " << class_id << " to crush map"; goto update; @@ -10110,7 +10110,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "removed class " << device_class << " with id " << class_id << " from crush map"; goto update; @@ -10143,7 +10143,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "rename class '" << srcname << "' to '" << dstname << "'"; goto update; } else if (prefix == "osd crush add-bucket") { @@ -10213,7 +10213,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); if (loc.empty()) { ss << "added bucket " << name << " type " << typestr << " to crush map"; @@ -10285,7 +10285,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); goto update; } else if (prefix == "osd crush weight-set rm" || @@ -10307,7 +10307,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } newcrush.rm_choose_args(pool); pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); goto update; } else if (prefix == "osd crush weight-set reweight" || @@ -10363,7 +10363,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } err = 0; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); goto update; } else if (osdid_present && (prefix == "osd crush set" || prefix == "osd crush add")) { @@ -10429,7 +10429,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << action << " item id " << osdid << " name '" << osd_name << "' weight " << weight << " at location " << loc << " to crush map"; getline(ss, rs); @@ -10478,7 +10478,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } if (err > 0) { pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "create-or-move updating item name '" << osd_name << "' weight " << weight << " at location " << loc << " to crush map"; @@ -10521,7 +10521,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err >= 0) { ss << "moved item id " << id << " name '" << name << "' to location " << loc << " in crush map"; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, get_last_committed() + 1)); @@ -10576,7 +10576,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } ss << "swapped bucket of " << source << " to " << dest; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, err, ss.str(), get_last_committed() + 1)); @@ -10623,7 +10623,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, ss << "linked item id " << id << " name '" << name << "' to location " << loc << " in crush map"; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } else { ss << "cannot link item id " << id << " name '" << name << "' to location " << loc; @@ -10704,7 +10704,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, newcrush.reweight(cct); pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "reweighted crush hierarchy"; getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -10742,7 +10742,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err < 0) goto reply; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "reweighted item id " << id << " name '" << name << "' to " << w << " in crush map"; getline(ss, rs); @@ -10781,7 +10781,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, if (err < 0) goto reply; pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "reweighted subtree id " << id << " name '" << name << "' to " << w << " in crush map"; getline(ss, rs); @@ -10821,7 +10821,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "adjusted tunables profile to " << profile; getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -10862,7 +10862,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); ss << "adjusted tunable " << tunable << " to " << value; getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -10903,7 +10903,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -10943,7 +10943,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -11151,7 +11151,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, @@ -11191,7 +11191,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); getline(ss, rs); wait_for_finished_proposal(op, new Monitor::C_Command(mon, op, 0, rs, get_last_committed() + 1)); @@ -11282,7 +11282,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, cmd_getval(cmdmap, "yes_i_really_mean_it", sure); if (!sure) { FeatureMap m; - mon->get_combined_feature_map(&m); + mon.get_combined_feature_map(&m); uint64_t features = ceph_release_features(to_integer<int>(vno)); bool first = true; bool ok = true; @@ -11438,7 +11438,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } if (rel == ceph_release_t::mimic) { - if (!mon->monmap->get_required_features().contains_all( + if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_MIMIC)) { ss << "not all mons are mimic"; err = -EPERM; @@ -11451,7 +11451,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } } else if (rel == ceph_release_t::nautilus) { - if (!mon->monmap->get_required_features().contains_all( + if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_NAUTILUS)) { ss << "not all mons are nautilus"; err = -EPERM; @@ -11464,7 +11464,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } } else if (rel == ceph_release_t::octopus) { - if (!mon->monmap->get_required_features().contains_all( + if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_OCTOPUS)) { ss << "not all mons are octopus"; err = -EPERM; @@ -11477,7 +11477,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto reply; } } else if (rel == ceph_release_t::pacific) { - if (!mon->monmap->get_required_features().contains_all( + if (!mon.monmap->get_required_features().contains_all( ceph::features::mon::FEATURE_PACIFIC)) { ss << "not all mons are pacific"; err = -EPERM; @@ -11587,7 +11587,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, << " seconds"; } - mon->clog->info() << msg.str(); + mon.clog->info() << msg.str(); any = true; } } else if (prefix == "osd in") { @@ -12329,10 +12329,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, */ // make sure authmon is writeable. - if (!mon->authmon()->is_writeable()) { + if (!mon.authmon()->is_writeable()) { dout(10) << __func__ << " waiting for auth mon to be writeable for " << "osd destroy" << dendl; - mon->authmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + mon.authmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } @@ -12387,7 +12387,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, bool goto_reply = false; - paxos->plug(); + paxos.plug(); if (is_destroy) { err = prepare_command_osd_destroy(id, ss); // we checked above that it should exist. @@ -12400,7 +12400,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, goto_reply = true; } } - paxos->unplug(); + paxos.unplug(); if (err < 0 || goto_reply) { goto reply; @@ -12421,10 +12421,10 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } else if (prefix == "osd new") { // make sure authmon is writeable. - if (!mon->authmon()->is_writeable()) { + if (!mon.authmon()->is_writeable()) { dout(10) << __func__ << " waiting for auth mon to be writeable for " << "osd new" << dendl; - mon->authmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); + mon.authmon()->wait_for_writeable(op, new C_RetryMessage(this, op)); return false; } @@ -12440,9 +12440,9 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, dout(20) << __func__ << " osd new params " << param_map << dendl; - paxos->plug(); + paxos.plug(); err = prepare_command_osd_new(op, cmdmap, param_map, ss, f.get()); - paxos->unplug(); + paxos.unplug(); if (err < 0) { goto reply; @@ -13015,7 +13015,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, // make sure new tier is empty string force_nonempty; cmd_getval(cmdmap, "force_nonempty", force_nonempty); - const pool_stat_t *pstats = mon->mgrstatmon()->get_pool_stat(tierpool_id); + const pool_stat_t *pstats = mon.mgrstatmon()->get_pool_stat(tierpool_id); if (pstats && pstats->stats.sum.num_objects != 0 && force_nonempty != "--force-nonempty") { ss << "tier pool '" << tierpoolstr << "' is not empty; --force-nonempty to force"; @@ -13322,7 +13322,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, mode != pg_pool_t::CACHEMODE_READPROXY))) { const pool_stat_t* pstats = - mon->mgrstatmon()->get_pool_stat(pool_id); + mon.mgrstatmon()->get_pool_stat(pool_id); if (pstats && pstats->stats.sum.num_objects_dirty > 0) { ss << "unable to set cache-mode '" @@ -13390,7 +13390,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, } // make sure new tier is empty const pool_stat_t *pstats = - mon->mgrstatmon()->get_pool_stat(tierpool_id); + mon.mgrstatmon()->get_pool_stat(tierpool_id); if (pstats && pstats->stats.sum.num_objects != 0) { ss << "tier pool '" << tierpoolstr << "' is not empty"; err = -ENOTEMPTY; @@ -13582,7 +13582,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, err = -EPERM; goto reply; } - mon->go_recovery_stretch_mode(); + mon.go_recovery_stretch_mode(); ss << "Triggering recovery stretch mode"; err = 0; goto reply; @@ -13594,7 +13594,7 @@ bool OSDMonitor::prepare_command_impl(MonOpRequestRef op, getline(ss, rs); if (err < 0 && rs.length() == 0) rs = cpp_strerror(err); - mon->reply_command(op, err, rs, rdata, get_last_committed()); + mon.reply_command(op, err, rs, rdata, get_last_committed()); return ret; update: @@ -13629,7 +13629,7 @@ bool OSDMonitor::enforce_pool_op_caps(MonOpRequestRef op) pool_name = &osdmap.get_pool_name(m->pool); } - if (!is_unmanaged_snap_op_permitted(cct, mon->key_server, + if (!is_unmanaged_snap_op_permitted(cct, mon.key_server, session->entity_name, session->caps, session->get_peer_socket_addr(), pool_name)) { @@ -13664,9 +13664,9 @@ bool OSDMonitor::preprocess_pool_op(MonOpRequestRef op) return true; } - if (m->fsid != mon->monmap->fsid) { + if (m->fsid != mon.monmap->fsid) { dout(0) << __func__ << " drop message on fsid " << m->fsid - << " != " << mon->monmap->fsid << " for " << *m << dendl; + << " != " << mon.monmap->fsid << " for " << *m << dendl; _pool_op_reply(op, -EINVAL, osdmap.get_epoch()); return true; } @@ -13962,7 +13962,7 @@ int OSDMonitor::_check_remove_pool(int64_t pool_id, const pg_pool_t& pool, const string& poolstr = osdmap.get_pool_name(pool_id); // If the Pool is in use by CephFS, refuse to delete it - FSMap const &pending_fsmap = mon->mdsmon()->get_pending_fsmap(); + FSMap const &pending_fsmap = mon.mdsmon()->get_pending_fsmap(); if (pending_fsmap.pool_in_use(pool_id)) { *ss << "pool '" << poolstr << "' is in use by CephFS"; return -EBUSY; @@ -14011,7 +14011,7 @@ bool OSDMonitor::_check_become_tier( const std::string &tier_pool_name = osdmap.get_pool_name(tier_pool_id); const std::string &base_pool_name = osdmap.get_pool_name(base_pool_id); - const FSMap &pending_fsmap = mon->mdsmon()->get_pending_fsmap(); + const FSMap &pending_fsmap = mon.mdsmon()->get_pending_fsmap(); if (pending_fsmap.pool_in_use(tier_pool_id)) { *ss << "pool '" << tier_pool_name << "' is in use by CephFS"; *err = -EBUSY; @@ -14071,7 +14071,7 @@ bool OSDMonitor::_check_remove_tier( const std::string &base_pool_name = osdmap.get_pool_name(base_pool_id); // Apply CephFS-specific checks - const FSMap &pending_fsmap = mon->mdsmon()->get_pending_fsmap(); + const FSMap &pending_fsmap = mon.mdsmon()->get_pending_fsmap(); if (pending_fsmap.pool_in_use(base_pool_id)) { if (base_pool->is_erasure() && !base_pool->allows_ecoverwrites()) { // If the underlying pool is erasure coded and does not allow EC @@ -14208,7 +14208,7 @@ int OSDMonitor::_prepare_remove_pool( dout(10) << __func__ << " removing choose_args for pool " << pool << dendl; newcrush.rm_choose_args(pool); pending_inc.crush.clear(); - newcrush.encode(pending_inc.crush, mon->get_quorum_con_features()); + newcrush.encode(pending_inc.crush, mon.get_quorum_con_features()); } return 0; } @@ -14257,7 +14257,7 @@ void OSDMonitor::_pool_op_reply(MonOpRequestRef op, dout(20) << "_pool_op_reply " << ret << dendl; MPoolOpReply *reply = new MPoolOpReply(m->fsid, m->get_tid(), ret, epoch, get_last_committed(), blp); - mon->send_reply(op, reply); + mon.send_reply(op, reply); } void OSDMonitor::convert_pool_priorities(void) @@ -14530,9 +14530,9 @@ struct CMonExitRecovery : public Context { void OSDMonitor::try_end_recovery_stretch_mode(bool force) { dout(20) << __func__ << dendl; - if (!mon->is_leader()) return; - if (!mon->is_degraded_stretch_mode()) return; - if (!mon->is_recovering_stretch_mode()) return; + if (!mon.is_leader()) return; + if (!mon.is_degraded_stretch_mode()) return; + if (!mon.is_recovering_stretch_mode()) return; if (!is_readable()) { wait_for_readable_ctx(new CMonExitRecovery(this, force)); return; @@ -14543,16 +14543,16 @@ void OSDMonitor::try_end_recovery_stretch_mode(bool force) ceph_clock_now() - g_conf().get_val<double>("mon_stretch_recovery_min_wait") > stretch_recovery_triggered) || force)) { - if (!mon->mgrstatmon()->is_readable()) { - mon->mgrstatmon()->wait_for_readable_ctx(new CMonExitRecovery(this, force)); + if (!mon.mgrstatmon()->is_readable()) { + mon.mgrstatmon()->wait_for_readable_ctx(new CMonExitRecovery(this, force)); return; } - const PGMapDigest& pgd = mon->mgrstatmon()->get_digest(); + const PGMapDigest& pgd = mon.mgrstatmon()->get_digest(); double misplaced, degraded, inactive, unknown; pgd.get_recovery_stats(&misplaced, °raded, &inactive, &unknown); if (force || (degraded == 0.0 && inactive == 0.0 && unknown == 0.0)) { // we can exit degraded stretch mode! - mon->trigger_healthy_stretch_mode(); + mon.trigger_healthy_stretch_mode(); } } } diff --git a/src/mon/OSDMonitor.h b/src/mon/OSDMonitor.h index 02f0fa36cce..ea04eb83350 100644 --- a/src/mon/OSDMonitor.h +++ b/src/mon/OSDMonitor.h @@ -677,7 +677,7 @@ protected: void set_default_laggy_params(int target_osd); public: - OSDMonitor(CephContext *cct, Monitor *mn, Paxos *p, const std::string& service_name); + OSDMonitor(CephContext *cct, Monitor &mn, Paxos &p, const std::string& service_name); void tick() override; // check state, take actions diff --git a/src/mon/Paxos.cc b/src/mon/Paxos.cc index 39f9045839a..21f244239c5 100644 --- a/src/mon/Paxos.cc +++ b/src/mon/Paxos.cc @@ -34,13 +34,13 @@ using ceph::to_timespan; #define dout_subsys ceph_subsys_paxos #undef dout_prefix -#define dout_prefix _prefix(_dout, mon, mon->name, mon->rank, paxos_name, state, first_committed, last_committed) -static std::ostream& _prefix(std::ostream *_dout, Monitor *mon, const string& name, +#define dout_prefix _prefix(_dout, mon, mon.name, mon.rank, paxos_name, state, first_committed, last_committed) +static std::ostream& _prefix(std::ostream *_dout, Monitor &mon, const string& name, int rank, const string& paxos_name, int state, version_t first_committed, version_t last_committed) { return *_dout << "mon." << name << "@" << rank - << "(" << mon->get_state_name() << ")" + << "(" << mon.get_state_name() << ")" << ".paxos(" << paxos_name << " " << Paxos::get_statename(state) << " c " << first_committed << ".." << last_committed << ") "; @@ -57,7 +57,7 @@ public: MonitorDBStore *Paxos::get_store() { - return mon->store; + return mon.store; } void Paxos::read_and_prepare_transactions(MonitorDBStore::TransactionRef tx, @@ -155,7 +155,7 @@ void Paxos::collect(version_t oldpn) { // we're recoverying, it seems! state = STATE_RECOVERING; - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); // reset the number of lasts received uncommitted_v = 0; @@ -194,24 +194,24 @@ void Paxos::collect(version_t oldpn) dout(10) << "collect with pn " << accepted_pn << dendl; // send collect - for (auto p = mon->get_quorum().begin(); - p != mon->get_quorum().end(); + for (auto p = mon.get_quorum().begin(); + p != mon.get_quorum().end(); ++p) { - if (*p == mon->rank) continue; + if (*p == mon.rank) continue; - MMonPaxos *collect = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_COLLECT, + MMonPaxos *collect = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_COLLECT, ceph_clock_now()); collect->last_committed = last_committed; collect->first_committed = first_committed; collect->pn = accepted_pn; - mon->send_mon_message(collect, *p); + mon.send_mon_message(collect, *p); } // set timeout event - collect_timeout_event = mon->timer.add_event_after( + collect_timeout_event = mon.timer.add_event_after( g_conf()->mon_accept_timeout_factor * g_conf()->mon_lease, - new C_MonContext{mon, [this](int r) { + new C_MonContext{&mon, [this](int r) { if (r == -ECANCELED) return; collect_timeout(); @@ -228,7 +228,7 @@ void Paxos::handle_collect(MonOpRequestRef op) auto collect = op->get_req<MMonPaxos>(); dout(10) << "handle_collect " << *collect << dendl; - ceph_assert(mon->is_peon()); // mon epoch filter should catch strays + ceph_assert(mon.is_peon()); // mon epoch filter should catch strays // we're recoverying, it seems! state = STATE_RECOVERING; @@ -242,12 +242,12 @@ void Paxos::handle_collect(MonOpRequestRef op) << " (theirs: " << collect->first_committed << "; ours: " << last_committed << ") -- bootstrap!" << dendl; op->mark_paxos_event("need to bootstrap"); - mon->bootstrap(); + mon.bootstrap(); return; } // reply - MMonPaxos *last = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_LAST, + MMonPaxos *last = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_LAST, ceph_clock_now()); last->last_committed = last_committed; last->first_committed = first_committed; @@ -474,7 +474,7 @@ void Paxos::handle_last(MonOpRequestRef op) dout(10) << "handle_last " << *last << dendl; - if (!mon->is_leader()) { + if (!mon.is_leader()) { dout(10) << "not leader, dropping" << dendl; return; } @@ -491,7 +491,7 @@ void Paxos::handle_last(MonOpRequestRef op) << " (theirs: " << last->first_committed << "; ours: " << last_committed << ") -- bootstrap!" << dendl; op->mark_paxos_event("need to bootstrap"); - mon->bootstrap(); + mon.bootstrap(); return; } @@ -513,17 +513,17 @@ void Paxos::handle_last(MonOpRequestRef op) << ") is too low for our first_committed (" << first_committed << ") -- bootstrap!" << dendl; op->mark_paxos_event("need to bootstrap"); - mon->bootstrap(); + mon.bootstrap(); return; } if (p->second < last_committed) { // share committed values dout(10) << " sending commit to mon." << p->first << dendl; - MMonPaxos *commit = new MMonPaxos(mon->get_epoch(), + MMonPaxos *commit = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_COMMIT, ceph_clock_now()); share_state(commit, peer_first_committed[p->first], p->second); - mon->send_mon_message(commit, p->first); + mon.send_mon_message(commit, p->first); } } @@ -533,7 +533,7 @@ void Paxos::handle_last(MonOpRequestRef op) dout(10) << " they had a higher pn than us, picking a new one." << dendl; // cancel timeout event - mon->timer.cancel_event(collect_timeout_event); + mon.timer.cancel_event(collect_timeout_event); collect_timeout_event = 0; collect(last->pn); @@ -564,9 +564,9 @@ void Paxos::handle_last(MonOpRequestRef op) } // is that everyone? - if (num_last == mon->get_quorum().size()) { + if (num_last == mon.get_quorum().size()) { // cancel timeout event - mon->timer.cancel_event(collect_timeout_event); + mon.timer.cancel_event(collect_timeout_event); collect_timeout_event = 0; peer_first_committed.clear(); peer_last_committed.clear(); @@ -604,8 +604,8 @@ void Paxos::collect_timeout() dout(1) << "collect timeout, calling fresh election" << dendl; collect_timeout_event = 0; logger->inc(l_paxos_collect_timeout); - ceph_assert(mon->is_leader()); - mon->bootstrap(); + ceph_assert(mon.is_leader()); + mon.bootstrap(); } @@ -616,19 +616,19 @@ void Paxos::begin(bufferlist& v) << v.length() << " bytes" << dendl; - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); ceph_assert(is_updating() || is_updating_previous()); // we must already have a majority for this to work. - ceph_assert(mon->get_quorum().size() == 1 || - num_last > (unsigned)mon->monmap->size()/2); + ceph_assert(mon.get_quorum().size() == 1 || + num_last > (unsigned)mon.monmap->size()/2); // and no value, yet. ceph_assert(new_value.length() == 0); // accept it ourselves accepted.clear(); - accepted.insert(mon->rank); + accepted.insert(mon.rank); new_value = v; if (last_committed == 0) { @@ -676,32 +676,32 @@ void Paxos::begin(bufferlist& v) ceph_assert(g_conf()->paxos_kill_at != 3); - if (mon->get_quorum().size() == 1) { + if (mon.get_quorum().size() == 1) { // we're alone, take it easy commit_start(); return; } // ask others to accept it too! - for (auto p = mon->get_quorum().begin(); - p != mon->get_quorum().end(); + for (auto p = mon.get_quorum().begin(); + p != mon.get_quorum().end(); ++p) { - if (*p == mon->rank) continue; + if (*p == mon.rank) continue; dout(10) << " sending begin to mon." << *p << dendl; - MMonPaxos *begin = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_BEGIN, + MMonPaxos *begin = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_BEGIN, ceph_clock_now()); begin->values[last_committed+1] = new_value; begin->last_committed = last_committed; begin->pn = accepted_pn; - mon->send_mon_message(begin, *p); + mon.send_mon_message(begin, *p); } // set timeout event - accept_timeout_event = mon->timer.add_event_after( + accept_timeout_event = mon.timer.add_event_after( g_conf()->mon_accept_timeout_factor * g_conf()->mon_lease, - new C_MonContext{mon, [this](int r) { + new C_MonContext{&mon, [this](int r) { if (r == -ECANCELED) return; accept_timeout(); @@ -761,7 +761,7 @@ void Paxos::handle_begin(MonOpRequestRef op) ceph_assert(g_conf()->paxos_kill_at != 5); // reply - MMonPaxos *accept = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_ACCEPT, + MMonPaxos *accept = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_ACCEPT, ceph_clock_now()); accept->pn = accepted_pn; accept->last_committed = last_committed; @@ -803,7 +803,7 @@ void Paxos::handle_accept(MonOpRequestRef op) // stale state. // FIXME: we can improve this with an additional lease revocation message // that doesn't block for the persist. - if (accepted == mon->get_quorum()) { + if (accepted == mon.get_quorum()) { // yay, commit! dout(10) << " got majority, committing, done with update" << dendl; op->mark_paxos_event("commit_start"); @@ -815,11 +815,11 @@ void Paxos::accept_timeout() { dout(1) << "accept timeout, calling fresh election" << dendl; accept_timeout_event = 0; - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); ceph_assert(is_updating() || is_updating_previous() || is_writing() || is_writing_previous()); logger->inc(l_paxos_accept_timeout); - mon->bootstrap(); + mon.bootstrap(); } struct C_Committed : public Context { @@ -827,7 +827,7 @@ struct C_Committed : public Context { explicit C_Committed(Paxos *p) : paxos(p) {} void finish(int r) override { ceph_assert(r >= 0); - std::lock_guard l(paxos->mon->lock); + std::lock_guard l(paxos->mon.lock); if (paxos->is_shutdown()) { paxos->abort_commit(); return; @@ -880,9 +880,9 @@ void Paxos::commit_start() ceph_abort(); ++commits_started; - if (mon->get_quorum().size() > 1) { + if (mon.get_quorum().size() > 1) { // cancel timeout event - mon->timer.cancel_event(accept_timeout_event); + mon.timer.cancel_event(accept_timeout_event); accept_timeout_event = 0; } } @@ -909,19 +909,19 @@ void Paxos::commit_finish() _sanity_check_store(); // tell everyone - for (auto p = mon->get_quorum().begin(); - p != mon->get_quorum().end(); + for (auto p = mon.get_quorum().begin(); + p != mon.get_quorum().end(); ++p) { - if (*p == mon->rank) continue; + if (*p == mon.rank) continue; dout(10) << " sending commit to mon." << *p << dendl; - MMonPaxos *commit = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_COMMIT, + MMonPaxos *commit = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_COMMIT, ceph_clock_now()); commit->values[last_committed] = new_value; commit->pn = accepted_pn; commit->last_committed = last_committed; - mon->send_mon_message(commit, *p); + mon.send_mon_message(commit, *p); } ceph_assert(g_conf()->paxos_kill_at != 9); @@ -930,7 +930,7 @@ void Paxos::commit_finish() new_value.clear(); // WRITING -> REFRESH - // among other things, this lets do_refresh() -> mon->bootstrap() -> + // among other things, this lets do_refresh() -> mon.bootstrap() -> // wait_for_paxos_write() know that it doesn't need to flush the store // queue. and it should not, as we are in the async completion thread now! ceph_assert(is_writing() || is_writing_previous()); @@ -940,7 +940,7 @@ void Paxos::commit_finish() if (do_refresh()) { commit_proposal(); - if (mon->get_quorum().size() > 1) { + if (mon.get_quorum().size() > 1) { extend_lease(); } @@ -959,7 +959,7 @@ void Paxos::handle_commit(MonOpRequestRef op) logger->inc(l_paxos_commit); - if (!mon->is_peon()) { + if (!mon.is_peon()) { dout(10) << "not a peon, dropping" << dendl; ceph_abort(); return; @@ -973,36 +973,36 @@ void Paxos::handle_commit(MonOpRequestRef op) void Paxos::extend_lease() { - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); //assert(is_active()); lease_expire = ceph::real_clock::now(); lease_expire += ceph::make_timespan(g_conf()->mon_lease); acked_lease.clear(); - acked_lease.insert(mon->rank); + acked_lease.insert(mon.rank); dout(7) << "extend_lease now+" << g_conf()->mon_lease << " (" << lease_expire << ")" << dendl; // bcast - for (auto p = mon->get_quorum().begin(); - p != mon->get_quorum().end(); ++p) { + for (auto p = mon.get_quorum().begin(); + p != mon.get_quorum().end(); ++p) { - if (*p == mon->rank) continue; - MMonPaxos *lease = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_LEASE, + if (*p == mon.rank) continue; + MMonPaxos *lease = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_LEASE, ceph_clock_now()); lease->last_committed = last_committed; lease->lease_timestamp = utime_t{lease_expire}; lease->first_committed = first_committed; - mon->send_mon_message(lease, *p); + mon.send_mon_message(lease, *p); } // set timeout event. // if old timeout is still in place, leave it. if (!lease_ack_timeout_event) { - lease_ack_timeout_event = mon->timer.add_event_after( + lease_ack_timeout_event = mon.timer.add_event_after( g_conf()->mon_lease_ack_timeout_factor * g_conf()->mon_lease, - new C_MonContext{mon, [this](int r) { + new C_MonContext{&mon, [this](int r) { if (r == -ECANCELED) return; lease_ack_timeout(); @@ -1014,8 +1014,8 @@ void Paxos::extend_lease() at -= ceph::make_timespan(g_conf()->mon_lease); at += ceph::make_timespan(g_conf()->mon_lease_renew_interval_factor * g_conf()->mon_lease); - lease_renew_event = mon->timer.add_event_at( - at, new C_MonContext{mon, [this](int r) { + lease_renew_event = mon.timer.add_event_at( + at, new C_MonContext{&mon, [this](int r) { if (r == -ECANCELED) return; lease_renew_timeout(); @@ -1031,7 +1031,7 @@ void Paxos::warn_on_future_time(utime_t t, entity_name_t from) utime_t warn_diff = now - last_clock_drift_warn; if (warn_diff > pow(g_conf()->mon_clock_drift_warn_backoff, clock_drift_warned)) { - mon->clog->warn() << "message from " << from << " was stamped " << diff + mon.clog->warn() << "message from " << from << " was stamped " << diff << "s in the future, clocks not synchronized"; last_clock_drift_warn = ceph_clock_now(); ++clock_drift_warned; @@ -1047,7 +1047,7 @@ bool Paxos::do_refresh() // make sure we have the latest state loaded up auto start = ceph::coarse_mono_clock::now(); - mon->refresh_from_paxos(&need_bootstrap); + mon.refresh_from_paxos(&need_bootstrap); auto end = ceph::coarse_mono_clock::now(); logger->inc(l_paxos_refresh); @@ -1055,7 +1055,7 @@ bool Paxos::do_refresh() if (need_bootstrap) { dout(10) << " doing requested bootstrap" << dendl; - mon->bootstrap(); + mon.bootstrap(); return false; } @@ -1065,7 +1065,7 @@ bool Paxos::do_refresh() void Paxos::commit_proposal() { dout(10) << __func__ << dendl; - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); ceph_assert(is_refresh()); finish_contexts(g_ceph_context, committing_finishers); @@ -1074,7 +1074,7 @@ void Paxos::commit_proposal() void Paxos::finish_round() { dout(10) << __func__ << dendl; - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); // ok, now go active! state = STATE_ACTIVE; @@ -1104,7 +1104,7 @@ void Paxos::handle_lease(MonOpRequestRef op) op->mark_paxos_event("handle_lease"); auto lease = op->get_req<MMonPaxos>(); // sanity - if (!mon->is_peon() || + if (!mon.is_peon() || last_committed != lease->last_committed) { dout(10) << "handle_lease i'm not a peon, or they're not the leader," << " or the last_committed doesn't match, dropping" << dendl; @@ -1132,12 +1132,12 @@ void Paxos::handle_lease(MonOpRequestRef op) << " now " << lease_expire << dendl; // ack - MMonPaxos *ack = new MMonPaxos(mon->get_epoch(), MMonPaxos::OP_LEASE_ACK, + MMonPaxos *ack = new MMonPaxos(mon.get_epoch(), MMonPaxos::OP_LEASE_ACK, ceph_clock_now()); ack->last_committed = last_committed; ack->first_committed = first_committed; ack->lease_timestamp = ceph_clock_now(); - encode(mon->session_map.feature_map, ack->feature_map); + encode(mon.session_map.feature_map, ack->feature_map); lease->get_connection()->send_message(ack); // (re)set timeout event. @@ -1163,21 +1163,21 @@ void Paxos::handle_lease_ack(MonOpRequestRef op) acked_lease.insert(from); if (ack->feature_map.length()) { auto p = ack->feature_map.cbegin(); - FeatureMap& t = mon->quorum_feature_map[from]; + FeatureMap& t = mon.quorum_feature_map[from]; decode(t, p); } - if (acked_lease == mon->get_quorum()) { + if (acked_lease == mon.get_quorum()) { // yay! dout(10) << "handle_lease_ack from " << ack->get_source() << " -- got everyone" << dendl; - mon->timer.cancel_event(lease_ack_timeout_event); + mon.timer.cancel_event(lease_ack_timeout_event); lease_ack_timeout_event = 0; } else { dout(10) << "handle_lease_ack from " << ack->get_source() << " -- still need " - << mon->get_quorum().size() - acked_lease.size() + << mon.get_quorum().size() - acked_lease.size() << " more" << dendl; } } else { @@ -1191,21 +1191,21 @@ void Paxos::handle_lease_ack(MonOpRequestRef op) void Paxos::lease_ack_timeout() { dout(1) << "lease_ack_timeout -- calling new election" << dendl; - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); ceph_assert(is_active()); logger->inc(l_paxos_lease_ack_timeout); lease_ack_timeout_event = 0; - mon->bootstrap(); + mon.bootstrap(); } void Paxos::reset_lease_timeout() { dout(20) << "reset_lease_timeout - setting timeout event" << dendl; if (lease_timeout_event) - mon->timer.cancel_event(lease_timeout_event); - lease_timeout_event = mon->timer.add_event_after( + mon.timer.cancel_event(lease_timeout_event); + lease_timeout_event = mon.timer.add_event_after( g_conf()->mon_lease_ack_timeout_factor * g_conf()->mon_lease, - new C_MonContext{mon, [this](int r) { + new C_MonContext{&mon, [this](int r) { if (r == -ECANCELED) return; lease_timeout(); @@ -1215,10 +1215,10 @@ void Paxos::reset_lease_timeout() void Paxos::lease_timeout() { dout(1) << "lease_timeout -- calling new election" << dendl; - ceph_assert(mon->is_peon()); + ceph_assert(mon.is_peon()); logger->inc(l_paxos_lease_timeout); lease_timeout_event = 0; - mon->bootstrap(); + mon.bootstrap(); } void Paxos::lease_renew_timeout() @@ -1270,7 +1270,7 @@ version_t Paxos::get_new_proposal_number(version_t gt) last_pn /= 100; last_pn++; last_pn *= 100; - last_pn += (version_t)mon->rank; + last_pn += (version_t)mon.rank; // write auto t(std::make_shared<MonitorDBStore::Transaction>()); @@ -1298,23 +1298,23 @@ version_t Paxos::get_new_proposal_number(version_t gt) void Paxos::cancel_events() { if (collect_timeout_event) { - mon->timer.cancel_event(collect_timeout_event); + mon.timer.cancel_event(collect_timeout_event); collect_timeout_event = 0; } if (accept_timeout_event) { - mon->timer.cancel_event(accept_timeout_event); + mon.timer.cancel_event(accept_timeout_event); accept_timeout_event = 0; } if (lease_renew_event) { - mon->timer.cancel_event(lease_renew_event); + mon.timer.cancel_event(lease_renew_event); lease_renew_event = 0; } if (lease_ack_timeout_event) { - mon->timer.cancel_event(lease_ack_timeout_event); + mon.timer.cancel_event(lease_ack_timeout_event); lease_ack_timeout_event = 0; } if (lease_timeout_event) { - mon->timer.cancel_event(lease_timeout_event); + mon.timer.cancel_event(lease_timeout_event); lease_timeout_event = 0; } } @@ -1331,7 +1331,7 @@ void Paxos::shutdown() // Let store finish commits in progress // XXX: I assume I can't use finish_contexts() because the store // is going to trigger - unique_lock l{mon->lock, std::adopt_lock}; + unique_lock l{mon.lock, std::adopt_lock}; shutdown_cond.wait(l, [this] { return commits_started <= 0; }); // Monitor::shutdown() will unlock it l.release(); @@ -1357,7 +1357,7 @@ void Paxos::leader_init() logger->inc(l_paxos_start_leader); - if (mon->get_quorum().size() == 1) { + if (mon.get_quorum().size() == 1) { state = STATE_ACTIVE; return; } @@ -1398,9 +1398,9 @@ void Paxos::restart() if (is_writing() || is_writing_previous()) { dout(10) << __func__ << " flushing" << dendl; - mon->lock.unlock(); - mon->store->flush(); - mon->lock.lock(); + mon.lock.unlock(); + mon.store->flush(); + mon.lock.lock(); dout(10) << __func__ << " flushed" << dendl; } state = STATE_RECOVERING; @@ -1434,14 +1434,14 @@ void Paxos::dispatch(MonOpRequestRef op) auto *req = op->get_req<MMonPaxos>(); // election in progress? - if (!mon->is_leader() && !mon->is_peon()) { + if (!mon.is_leader() && !mon.is_peon()) { dout(5) << "election in progress, dropping " << *req << dendl; return; } // check sanity - ceph_assert(mon->is_leader() || - (mon->is_peon() && req->get_source().num() == mon->get_leader())); + ceph_assert(mon.is_leader() || + (mon.is_peon() && req->get_source().num() == mon.get_leader())); // NOTE: these ops are defined in messages/MMonPaxos.h switch (req->op) { @@ -1485,7 +1485,7 @@ bool Paxos::is_readable(version_t v) ret = false; else ret = - (mon->is_peon() || mon->is_leader()) && + (mon.is_peon() || mon.is_leader()) && (is_active() || is_updating() || is_writing()) && last_committed > 0 && is_lease_valid(); // must have a value alone, or have lease dout(5) << __func__ << " = " << (int)ret @@ -1513,7 +1513,7 @@ version_t Paxos::read_current(bufferlist &bl) bool Paxos::is_lease_valid() { - return ((mon->get_quorum().size() == 1) + return ((mon.get_quorum().size() == 1) || (ceph::real_clock::now() < lease_expire)); } @@ -1522,7 +1522,7 @@ bool Paxos::is_lease_valid() bool Paxos::is_writeable() { return - mon->is_leader() && + mon.is_leader() && is_active() && is_lease_valid(); } @@ -1561,7 +1561,7 @@ void Paxos::queue_pending_finisher(Context *onfinished) MonitorDBStore::TransactionRef Paxos::get_pending_transaction() { - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); if (!pending_proposal) { pending_proposal.reset(new MonitorDBStore::Transaction); ceph_assert(pending_finishers.empty()); diff --git a/src/mon/Paxos.h b/src/mon/Paxos.h index 657b646e2c3..c197f26f7f0 100644 --- a/src/mon/Paxos.h +++ b/src/mon/Paxos.h @@ -179,7 +179,7 @@ class Paxos { /** * The Monitor to which this Paxos class is associated with. */ - Monitor *mon; + Monitor &mon; /// perf counter for internal instrumentations PerfCounters *logger; @@ -1045,7 +1045,7 @@ public: * @param name A name for the paxos service. It serves as the naming space * of the underlying persistent storage for this service. */ - Paxos(Monitor *m, const std::string &name) + Paxos(Monitor &m, const std::string &name) : mon(m), logger(NULL), paxos_name(name), diff --git a/src/mon/PaxosService.cc b/src/mon/PaxosService.cc index 47222ee6734..8dff901c067 100644 --- a/src/mon/PaxosService.cc +++ b/src/mon/PaxosService.cc @@ -27,10 +27,10 @@ using ceph::bufferlist; #define dout_subsys ceph_subsys_paxos #undef dout_prefix #define dout_prefix _prefix(_dout, mon, paxos, service_name, get_first_committed(), get_last_committed()) -static ostream& _prefix(std::ostream *_dout, Monitor *mon, Paxos *paxos, string service_name, +static ostream& _prefix(std::ostream *_dout, Monitor &mon, Paxos &paxos, string service_name, version_t fc, version_t lc) { - return *_dout << "mon." << mon->name << "@" << mon->rank - << "(" << mon->get_state_name() + return *_dout << "mon." << mon.name << "@" << mon.rank + << "(" << mon.get_state_name() << ").paxosservice(" << service_name << " " << fc << ".." << lc << ") "; } @@ -44,15 +44,15 @@ bool PaxosService::dispatch(MonOpRequestRef op) << " from " << m->get_orig_source_inst() << " con " << m->get_connection() << dendl; - if (mon->is_shutdown()) { + if (mon.is_shutdown()) { return true; } // make sure this message isn't forwarded from a previous election epoch if (m->rx_election_epoch && - m->rx_election_epoch < mon->get_epoch()) { + m->rx_election_epoch < mon.get_epoch()) { dout(10) << " discarding forwarded message from previous election epoch " - << m->rx_election_epoch << " < " << mon->get_epoch() << dendl; + << m->rx_election_epoch << " < " << mon.get_epoch() << dendl; return true; } @@ -61,7 +61,7 @@ bool PaxosService::dispatch(MonOpRequestRef op) // those. also ignore loopback (e.g., log) messages. if (m->get_connection() && !m->get_connection()->is_connected() && - m->get_connection() != mon->con_self && + m->get_connection() != mon.con_self && m->get_connection()->get_messenger() != NULL) { dout(10) << " discarding message from disconnected client " << m->get_source_inst() << " " << *m << dendl; @@ -80,8 +80,8 @@ bool PaxosService::dispatch(MonOpRequestRef op) return true; // easy! // leader? - if (!mon->is_leader()) { - mon->forward_request_leader(op); + if (!mon.is_leader()) { + mon.forward_request_leader(op); return true; } @@ -122,7 +122,7 @@ bool PaxosService::dispatch(MonOpRequestRef op) * Callback class used to propose the pending value once the proposal_timer * fires up. */ - auto do_propose = new C_MonContext{mon, [this](int r) { + auto do_propose = new C_MonContext{&mon, [this](int r) { proposal_timer = 0; if (r >= 0) { propose_pending(); @@ -134,7 +134,7 @@ bool PaxosService::dispatch(MonOpRequestRef op) }}; dout(10) << " setting proposal_timer " << do_propose << " with delay of " << delay << dendl; - proposal_timer = mon->timer.add_event_after(delay, do_propose); + proposal_timer = mon.timer.add_event_after(delay, do_propose); } else { dout(10) << " proposal_timer already set" << dendl; } @@ -144,8 +144,8 @@ bool PaxosService::dispatch(MonOpRequestRef op) void PaxosService::refresh(bool *need_bootstrap) { // update cached versions - cached_first_committed = mon->store->get(get_service_name(), first_committed_name); - cached_last_committed = mon->store->get(get_service_name(), last_committed_name); + cached_first_committed = mon.store->get(get_service_name(), first_committed_name); + cached_last_committed = mon.store->get(get_service_name(), last_committed_name); version_t new_format = get_value("format_version"); if (new_format != format_version) { @@ -165,7 +165,7 @@ void PaxosService::post_refresh() post_paxos_update(); - if (mon->is_peon() && !waiting_for_finished_proposal.empty()) { + if (mon.is_peon() && !waiting_for_finished_proposal.empty()) { finish_contexts(g_ceph_context, waiting_for_finished_proposal, -EAGAIN); } } @@ -177,10 +177,10 @@ bool PaxosService::should_propose(double& delay) delay = 0.0; } else { utime_t now = ceph_clock_now(); - if ((now - paxos->last_commit_time) > g_conf()->paxos_propose_interval) + if ((now - paxos.last_commit_time) > g_conf()->paxos_propose_interval) delay = (double)g_conf()->paxos_min_wait; else - delay = (double)(g_conf()->paxos_propose_interval + paxos->last_commit_time + delay = (double)(g_conf()->paxos_propose_interval + paxos.last_commit_time - now); } return true; @@ -192,12 +192,12 @@ void PaxosService::propose_pending() dout(10) << __func__ << dendl; ceph_assert(have_pending); ceph_assert(!proposing); - ceph_assert(mon->is_leader()); + ceph_assert(mon.is_leader()); ceph_assert(is_active()); if (proposal_timer) { dout(10) << " canceling proposal_timer " << proposal_timer << dendl; - mon->timer.cancel_event(proposal_timer); + mon.timer.cancel_event(proposal_timer); proposal_timer = NULL; } @@ -210,7 +210,7 @@ void PaxosService::propose_pending() * bufferlist, so we can then propose that as a value through * Paxos. */ - MonitorDBStore::TransactionRef t = paxos->get_pending_transaction(); + MonitorDBStore::TransactionRef t = paxos.get_pending_transaction(); if (should_stash_full()) encode_full(t); @@ -248,8 +248,8 @@ void PaxosService::propose_pending() ceph_abort_msg("bad return value for C_Committed"); } }; - paxos->queue_pending_finisher(new C_Committed(this)); - paxos->trigger_propose(); + paxos.queue_pending_finisher(new C_Committed(this)); + paxos.trigger_propose(); } bool PaxosService::should_stash_full() @@ -270,7 +270,7 @@ void PaxosService::restart() dout(10) << __func__ << dendl; if (proposal_timer) { dout(10) << " canceling proposal_timer " << proposal_timer << dendl; - mon->timer.cancel_event(proposal_timer); + mon.timer.cancel_event(proposal_timer); proposal_timer = 0; } @@ -326,7 +326,7 @@ void PaxosService::_active() dout(10) << __func__ << dendl; // create pending state? - if (mon->is_leader()) { + if (mon.is_leader()) { dout(7) << __func__ << " creating new pending" << dendl; if (!have_pending) { create_pending(); @@ -348,7 +348,7 @@ void PaxosService::_active() // on this list; it is on Paxos's. finish_contexts(g_ceph_context, waiting_for_finished_proposal, 0); - if (mon->is_leader()) + if (mon.is_leader()) upgrade_format(); // NOTE: it's possible that this will get called twice if we commit @@ -363,7 +363,7 @@ void PaxosService::shutdown() if (proposal_timer) { dout(10) << " canceling proposal_timer " << proposal_timer << dendl; - mon->timer.cancel_event(proposal_timer); + mon.timer.cancel_event(proposal_timer); proposal_timer = 0; } @@ -402,7 +402,7 @@ void PaxosService::maybe_trim() } dout(10) << __func__ << " trimming to " << trim_to << ", " << to_remove << " states" << dendl; - MonitorDBStore::TransactionRef t = paxos->get_pending_transaction(); + MonitorDBStore::TransactionRef t = paxos.get_pending_transaction(); trim(t, get_first_committed(), trim_to); put_first_committed(t, trim_to); cached_first_committed = trim_to; @@ -410,7 +410,7 @@ void PaxosService::maybe_trim() // let the service add any extra stuff encode_trim_extra(t, trim_to); - paxos->trigger_propose(); + paxos.trigger_propose(); } void PaxosService::trim(MonitorDBStore::TransactionRef t, @@ -423,8 +423,8 @@ void PaxosService::trim(MonitorDBStore::TransactionRef t, dout(20) << __func__ << " " << v << dendl; t->erase(get_service_name(), v); - string full_key = mon->store->combine_strings("full", v); - if (mon->store->exists(get_service_name(), full_key)) { + string full_key = mon.store->combine_strings("full", v); + if (mon.store->exists(get_service_name(), full_key)) { dout(20) << __func__ << " " << full_key << dendl; t->erase(get_service_name(), full_key); } @@ -433,15 +433,15 @@ void PaxosService::trim(MonitorDBStore::TransactionRef t, dout(20) << " compacting prefix " << get_service_name() << dendl; t->compact_range(get_service_name(), stringify(from - 1), stringify(to)); t->compact_range(get_service_name(), - mon->store->combine_strings(full_prefix_name, from - 1), - mon->store->combine_strings(full_prefix_name, to)); + mon.store->combine_strings(full_prefix_name, from - 1), + mon.store->combine_strings(full_prefix_name, to)); } } void PaxosService::load_health() { bufferlist bl; - mon->store->get("health", service_name, bl); + mon.store->get("health", service_name, bl); if (bl.length()) { auto p = bl.cbegin(); using ceph::decode; diff --git a/src/mon/PaxosService.h b/src/mon/PaxosService.h index 0134f6a7054..93c5e7c81f9 100644 --- a/src/mon/PaxosService.h +++ b/src/mon/PaxosService.h @@ -34,11 +34,11 @@ class PaxosService { /** * The Monitor to which this class is associated with */ - Monitor *mon; + Monitor &mon; /** * The Paxos instance to which this class is associated with */ - Paxos *paxos; + Paxos &paxos; /** * Our name. This will be associated with the class implementing us, and will * be used mainly for store-related operations. @@ -122,7 +122,7 @@ public: }; class C_ReplyOp : public C_MonOp { - Monitor *mon; + Monitor &mon; MonOpRequestRef op; MessageRef reply; public: @@ -130,7 +130,7 @@ public: C_MonOp(o), mon(s->mon), op(o), reply(r) { } void _finish(int r) override { if (r >= 0) { - mon->send_reply(op, reply.detach()); + mon.send_reply(op, reply.detach()); } } }; @@ -144,7 +144,7 @@ public: * @param p A Paxos instance * @param name Our service's name. */ - PaxosService(Monitor *mn, Paxos *p, std::string name) + PaxosService(Monitor &mn, Paxos &p, std::string name) : mon(mn), paxos(p), service_name(name), proposing(false), service_version(0), proposal_timer(0), have_pending(false), @@ -442,7 +442,7 @@ public: ceph::buffer::list bl; encode(next, bl); t->put("health", service_name, bl); - mon->log_health(next, health_checks, t); + mon.log_health(next, health_checks, t); } void load_health(); @@ -507,7 +507,7 @@ public: bool is_active() const { return !is_proposing() && - (paxos->is_active() || paxos->is_updating() || paxos->is_writing()); + (paxos.is_active() || paxos.is_updating() || paxos.is_writing()); } /** @@ -524,7 +524,7 @@ public: */ bool is_readable(version_t ver = 0) const { if (ver > get_last_committed() || - !paxos->is_readable(0) || + !paxos.is_readable(0) || get_last_committed() == 0) return false; return true; @@ -573,7 +573,7 @@ public: op->mark_event(service_name + ":wait_for_active"); if (!is_proposing()) { - paxos->wait_for_active(op, c); + paxos.wait_for_active(op, c); return; } wait_for_finished_proposal(op, c); @@ -607,7 +607,7 @@ public: if (op) op->mark_event(service_name + ":wait_for_readable/paxos"); - paxos->wait_for_readable(op, c); + paxos.wait_for_readable(op, c); } } @@ -630,7 +630,7 @@ public: else if (!is_writeable()) wait_for_active(op, c); else - paxos->wait_for_writeable(op, c); + paxos.wait_for_writeable(op, c); } void wait_for_writeable_ctx(Context *c) { MonOpRequestRef o; @@ -712,7 +712,7 @@ public: * @note This function is a wrapper for Paxos::cancel_events */ void cancel_events() { - paxos->cancel_events(); + paxos.cancel_events(); } /** @@ -767,7 +767,7 @@ public: */ void put_version_full(MonitorDBStore::TransactionRef t, version_t ver, ceph::buffer::list& bl) { - std::string key = mon->store->combine_strings(full_prefix_name, ver); + std::string key = mon.store->combine_strings(full_prefix_name, ver); t->put(get_service_name(), key, bl); } /** @@ -778,7 +778,7 @@ public: * @param ver A version number */ void put_version_latest_full(MonitorDBStore::TransactionRef t, version_t ver) { - std::string key = mon->store->combine_strings(full_prefix_name, full_latest_name); + std::string key = mon.store->combine_strings(full_prefix_name, full_latest_name); t->put(get_service_name(), key, ver); } /** @@ -849,7 +849,7 @@ public: * @return 0 on success; <0 otherwise */ virtual int get_version(version_t ver, ceph::buffer::list& bl) { - return mon->store->get(get_service_name(), ver, bl); + return mon.store->get(get_service_name(), ver, bl); } /** * Get the contents of a given full version of this service. @@ -859,8 +859,8 @@ public: * @returns 0 on success; <0 otherwise */ virtual int get_version_full(version_t ver, ceph::buffer::list& bl) { - std::string key = mon->store->combine_strings(full_prefix_name, ver); - return mon->store->get(get_service_name(), key, bl); + std::string key = mon.store->combine_strings(full_prefix_name, ver); + return mon.store->get(get_service_name(), key, bl); } /** * Get the latest full version number @@ -868,8 +868,8 @@ public: * @returns A version number */ version_t get_version_latest_full() { - std::string key = mon->store->combine_strings(full_prefix_name, full_latest_name); - return mon->store->get(get_service_name(), key); + std::string key = mon.store->combine_strings(full_prefix_name, full_latest_name); + return mon.store->get(get_service_name(), key); } /** @@ -879,7 +879,7 @@ public: * @param[out] bl The ceph::buffer::list to be populated with the value */ int get_value(const std::string& key, ceph::buffer::list& bl) { - return mon->store->get(get_service_name(), key, bl); + return mon.store->get(get_service_name(), key, bl); } /** * Get an integer value from a given key. @@ -887,7 +887,7 @@ public: * @param[in] key The key */ version_t get_value(const std::string& key) { - return mon->store->get(get_service_name(), key); + return mon.store->get(get_service_name(), key); } /** |