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>
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 << " ";
}
{
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);
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;
}
{
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) {
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;
}
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);
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);
__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) {
// 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;
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 "
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) {
void AuthMonitor::increase_max_global_id()
{
- ceph_assert(mon->is_leader());
+ ceph_assert(mon.is_leader());
Incremental inc;
inc.inc_type = GLOBAL_ID;
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);
// 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;
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;
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);
{
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;
}
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;
}
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:
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;
{
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();
}
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;
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;
}
}
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;
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;
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;
}
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;
}
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;
}
} 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 {
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;
} 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
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)
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;
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())) {
EntityName& lockbox_entity,
stringstream& ss)
{
- ceph_assert(paxos->is_plugged());
+ ceph_assert(paxos.is_plugged());
dout(10) << __func__ << " id " << id << " uuid " << uuid << dendl;
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;
}
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;
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 ";
// 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);
}
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);
}
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;
}
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;
}
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();
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";
// 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)) {
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;
}
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)) {
} 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;
!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;
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;
}
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;
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();
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;
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);
// 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;
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();
}
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),
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) {
}
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;
}
}
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;
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) {
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 {
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;
}
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;
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;
}
}
} 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 &&
}
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;
}
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(
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;
}
}
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;
}
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 << "'";
// 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) ||
}
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:
void ConfigMonitor::tick()
{
- if (!is_active() || !mon->is_leader()) {
+ if (!is_active() || !mon.is_leader()) {
return;
}
dout(10) << __func__ << dendl;
};
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();
{
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();
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;
// 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(
{
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) {
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);
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 {
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;
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;
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) {
}
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);
}
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);
{
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);
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);
}
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;
}
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;
}
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;
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;
}
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;
}
}
if (check_member_health()) {
changed = true;
}
- if (!mon->is_leader()) {
+ if (!mon.is_leader()) {
return;
}
if (check_leader_health()) {
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;
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;
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);
} 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;
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());
}
}
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"];
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());
}
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) << ")";
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;
}
}
- 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;
// 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) {
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
// 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());
}
}
// 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;
// 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 "
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
#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 << " ";
}
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));
__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);
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);
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;
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;
}
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:
return false;
done:
- mon->no_reply(op);
+ mon.no_reply(op);
return true;
}
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;
}
{
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)
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;
}
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 {
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;
}
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;
}
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;
}
}
getline(ss, rs);
- mon->reply_command(op, err, rs, get_last_committed());
+ mon.reply_command(op, err, rs, get_last_committed());
return false;
}
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)
return;
}
- MLog *mlog = new MLog(mon->monmap->fsid);
+ MLog *mlog = new MLog(mon.monmap->fsid);
if (s->next == 0) {
/* First timer, heh? */
mlog->put();
}
if (s->onetime)
- mon->session_map.remove_sub(s);
+ mon.session_map.remove_sub(s);
else
s->next = summary_version+1;
}
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 {
#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() << " ";
}
{
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);});
}
// 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);
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;
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;
}
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;
}
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.
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;
}
return false;
ignore:
- mon->no_reply(op);
+ mon.no_reply(op);
return true;
}
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;
}
// 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;
}
}
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());
}
}
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
}
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)";
} 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;
}
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.
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;
}
if (r >= 0)
_updated(op); // success
else if (r == -ECANCELED) {
- mon->no_reply(op);
+ mon.no_reply(op);
} else {
dispatch(op); // try again
}
} else {
dout(10) << "prepare_offload_targets " << gid << " not in map" << dendl;
}
- mon->no_reply(op);
+ mon.no_reply(op);
return true;
}
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());
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());
}
}
tick();
if (is_leader()) {
- mon->clog->debug() << "fsmap " << get_fsmap();
+ mon.clog->debug() << "fsmap " << get_fsmap();
}
}
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;
}
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;
}
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");
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();
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;
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;
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);
if (gid == MDS_GID_NONE) {
return 0;
}
- if (!mon->osdmon()->is_writeable()) {
+ if (!mon.osdmon()->is_writeable()) {
return -EAGAIN;
}
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;
}
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;
}
/* 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;
}
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) {
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;
}
}
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;
}
}
}
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;
}
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;
}
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;
}
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;
}
}
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)
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;
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)";
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;
};
<< " 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();
{
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");
}
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;
}
}
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);
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;
}
if (propose_osdmap) {
- request_proposal(mon->osdmon());
+ request_proposal(mon.osdmon());
}
if (do_propose) {
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()
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;
*/
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;
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() << " ";
}
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 {
}
// 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();
}
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()
// 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")) {
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;
}
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();
}});
}
{
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);
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;
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;
}
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;
}
if (r >= 0) {
// Success
} else if (r == -ECANCELED) {
- mm->mon->no_reply(op);
+ mm->mon.no_reply(op);
} else {
mm->dispatch(op); // try again
}
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())) {
&& 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();
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;
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
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;
}
} 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(),
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);
}
}
<< " " << 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;
}
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;
}
}
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();
}
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();
}});
}
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) {
void MgrMonitor::tick()
{
- if (!is_active() || !mon->is_leader())
+ if (!is_active() || !mon.is_leader())
return;
const auto now = ceph::coarse_mono_clock::now();
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;
}
}
// 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
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);
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);
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;
}
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;
}
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;
}
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();
}
} 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();
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;
}
}
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 {
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 {}
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)
{
}
}
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();
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);
}
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)
++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);
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;
}
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;
}
bool MgrStatMonitor::preprocess_report(MonOpRequestRef op)
{
- mon->no_reply(op);
+ mon.no_reply(op);
return false;
}
<< 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);
continue;
reply->pool_stats[pool_name] = *pool_stat;
}
- mon->send_reply(op, reply);
+ mon.send_reply(op, reply);
return true;
}
<< 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;
<< " 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;
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 {
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();
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 {}
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());
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;
}
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 {
}
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");
}
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) {
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;
}
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;
{
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
}
// 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;
}
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;
*/
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)
}
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:
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();
}
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", get_last_committed());
+ mon.reply_command(op, -EACCES, "access denied", get_last_committed());
return true;
}
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);
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);
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);
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();
rdata.append(ds);
ss << "dumped monmap epoch " << p->get_epoch();
}
- if (p != mon->monmap) {
+ if (p != mon.monmap) {
delete p;
p = nullptr;
}
list_with_value = true;
}
- MonMap *p = mon->monmap;
+ MonMap *p = mon.monmap;
// list features
mon_feature_t supported = ceph::features::mon::get_supported();
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;
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:
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;
}
* 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:
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!";
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;
}
}
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!";
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!";
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!";
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!";
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);
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;
}
{
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;
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;
// 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 {
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;
}
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()) {
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);
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;
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 {
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++) {
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)
{
}
#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);
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();
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;
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;
}
}
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);
// 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;
}
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;
}
}
if (t) {
- mon->store->apply_transaction(t);
+ mon.store->apply_transaction(t);
}
bool marked_osd_down = false;
// 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")) {
// 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();
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;
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);
}
}
}
{
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();
{
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();
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());
}
}
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()
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;
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;
}
// 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()) {
<< " 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);
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 {
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;
// 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);
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;
}
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) {
// 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 {
}
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);
}
// 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
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;
}
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:
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;
}
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;
}
reply->oldest_map = first;
reply->newest_map = last;
- mon->send_reply(op, reply);
+ mon.send_reply(op, reply);
return true;
}
<< 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;
return false;
didit:
- mon->no_reply(op);
+ mon.no_reply(op);
return true;
}
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,
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));
// 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;
}
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;
}
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];
new LambdaContext(
[op, this] (int r) {
if (r >= 0) {
- mon->no_reply(op); // ignore on success
+ mon.no_reply(op); // ignore on success
}
}
));
<< " 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)
<< ") ("
}
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;
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
// 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
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();
}
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;
}
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;
// 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;
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;
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;
<< " 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";
}
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
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;
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;
return false;
ignore:
- mon->no_reply(op);
+ mon.no_reply(op);
return true;
}
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 {
return true;
ignore:
- mon->no_reply(op);
+ mon.no_reply(op);
return true;
}
// 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(
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:
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()) {
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;
}
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;
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();
{
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();
{
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)
// 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 "
m->maps[first] = bl;
if (req) {
- mon->send_reply(req, m);
+ mon.send_reply(req, m);
session->osd_epoch = first;
return;
} else {
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;
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)
// 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);
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;
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
<< " 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);
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,
// 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);
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();
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;
}
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;
// 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);
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;
}
}
- if (!mon->is_leader()) return;
+ if (!mon.is_leader()) return;
bool do_propose = false;
utime_t now = ceph_clock_now();
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;
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;
}
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;
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;
}
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;
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");
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;
}
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__
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()) {
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()) {
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;
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.
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 << ")";
}
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;
}
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;
}
}
{
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;
}
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);
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(
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;
string uuidstr;
int64_t id = -1;
- ceph_assert(paxos->is_plugged());
+ ceph_assert(paxos.is_plugged());
dout(10) << __func__ << " " << op << dendl;
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,
}
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;
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);
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;
}
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
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);
}
}
- 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);
}
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);
}
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));
// (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"
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;
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,
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,
}
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;
}
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;
}
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") {
}
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";
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" ||
}
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" ||
}
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")) {
}
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);
}
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";
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));
}
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));
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;
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,
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);
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);
}
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,
}
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,
}
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,
}
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,
}
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,
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));
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;
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;
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;
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;
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;
<< " seconds";
}
- mon->clog->info() << msg.str();
+ mon.clog->info() << msg.str();
any = true;
}
} else if (prefix == "osd in") {
*/
// 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;
}
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.
goto_reply = true;
}
}
- paxos->unplug();
+ paxos.unplug();
if (err < 0 || goto_reply) {
goto reply;
} 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;
}
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;
// 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";
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 '"
}
// 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;
err = -EPERM;
goto reply;
}
- mon->go_recovery_stretch_mode();
+ mon.go_recovery_stretch_mode();
ss << "Triggering recovery stretch mode";
err = 0;
goto reply;
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:
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)) {
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;
}
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;
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;
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
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;
}
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)
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;
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();
}
}
}
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
#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
<< ") ";
MonitorDBStore *Paxos::get_store()
{
- return mon->store;
+ return mon.store;
}
void Paxos::read_and_prepare_transactions(MonitorDBStore::TransactionRef tx,
{
// 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;
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();
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;
<< " (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;
dout(10) << "handle_last " << *last << dendl;
- if (!mon->is_leader()) {
+ if (!mon.is_leader()) {
dout(10) << "not leader, dropping" << dendl;
return;
}
<< " (theirs: " << last->first_committed
<< "; ours: " << last_committed << ") -- bootstrap!" << dendl;
op->mark_paxos_event("need to bootstrap");
- mon->bootstrap();
+ mon.bootstrap();
return;
}
<< ") 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);
}
}
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);
}
// 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();
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();
}
<< 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) {
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();
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;
// 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");
{
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 {
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;
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;
}
}
_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);
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());
if (do_refresh()) {
commit_proposal();
- if (mon->get_quorum().size() > 1) {
+ if (mon.get_quorum().size() > 1) {
extend_lease();
}
logger->inc(l_paxos_commit);
- if (!mon->is_peon()) {
+ if (!mon.is_peon()) {
dout(10) << "not a peon, dropping" << dendl;
ceph_abort();
return;
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();
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();
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;
// 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);
if (need_bootstrap) {
dout(10) << " doing requested bootstrap" << dendl;
- mon->bootstrap();
+ mon.bootstrap();
return false;
}
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);
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;
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;
<< " 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.
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 {
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();
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()
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>());
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;
}
}
// 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();
logger->inc(l_paxos_start_leader);
- if (mon->get_quorum().size() == 1) {
+ if (mon.get_quorum().size() == 1) {
state = STATE_ACTIVE;
return;
}
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;
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) {
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
bool Paxos::is_lease_valid()
{
- return ((mon->get_quorum().size() == 1)
+ return ((mon.get_quorum().size() == 1)
|| (ceph::real_clock::now() < lease_expire));
}
bool Paxos::is_writeable()
{
return
- mon->is_leader() &&
+ mon.is_leader() &&
is_active() &&
is_lease_valid();
}
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());
/**
* The Monitor to which this Paxos class is associated with.
*/
- Monitor *mon;
+ Monitor &mon;
/// perf counter for internal instrumentations
PerfCounters *logger;
* @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),
#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 << ") ";
}
<< " 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;
}
// 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;
return true; // easy!
// leader?
- if (!mon->is_leader()) {
- mon->forward_request_leader(op);
+ if (!mon.is_leader()) {
+ mon.forward_request_leader(op);
return true;
}
* 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();
}};
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;
}
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) {
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);
}
}
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;
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;
}
* 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);
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()
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;
}
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();
// 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
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;
}
}
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;
// 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,
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);
}
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;
/**
* 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.
};
class C_ReplyOp : public C_MonOp {
- Monitor *mon;
+ Monitor &mon;
MonOpRequestRef op;
MessageRef reply;
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());
}
}
};
* @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),
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();
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());
}
/**
*/
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;
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);
if (op)
op->mark_event(service_name + ":wait_for_readable/paxos");
- paxos->wait_for_readable(op, c);
+ paxos.wait_for_readable(op, c);
}
}
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;
* @note This function is a wrapper for Paxos::cancel_events
*/
void cancel_events() {
- paxos->cancel_events();
+ paxos.cancel_events();
}
/**
*/
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);
}
/**
* @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);
}
/**
* @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.
* @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
* @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);
}
/**
* @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.
* @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);
}
/**