From: Sage Weil Date: Thu, 25 Apr 2013 22:18:42 +0000 (-0700) Subject: mon: get own entity_inst_t via messenger, not monmap X-Git-Tag: v0.61~95 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=3ce35a6743e050bf0de5abd5ad32f522c5664f3d;p=ceph.git mon: get own entity_inst_t via messenger, not monmap There are intervals during bootstrap(*) during which we are part of the monmap, but our name (mon->name) does not match the monmap's. This means that calling monmap->get_inst(mon->name) is not a safe way to get our own entity_inst_t. Instead, use messenger->get_myinst(). This includes our addr (obviously) and an up-to-date entity_name_t, too: in bootstrap we adjust the messenger name at the same time as mon->rank, based on the contents of the monmap. monmap->get_inst(mon->rank) would work too. * During mkfs, the monmap may have noname-foo instead of the name if it was generated from the mon_host lines or dns or whatever by MonMap::build_initial(). This was the case for #4811. Fixes: #4811 Signed-off-by: Sage Weil Reviewed-by: Greg Farnum --- diff --git a/src/mon/DataHealthService.cc b/src/mon/DataHealthService.cc index 949e1e2efe3f..a55e8c392e22 100644 --- a/src/mon/DataHealthService.cc +++ b/src/mon/DataHealthService.cc @@ -124,7 +124,7 @@ int DataHealthService::update_stats() return -errno; } - entity_inst_t our_inst = mon->monmap->get_inst(mon->name); + entity_inst_t our_inst = mon->messenger->get_myinst(); DataStats& ours = stats[our_inst]; ours.kb_total = stbuf.f_blocks * stbuf.f_bsize / 1024; @@ -145,7 +145,7 @@ void DataHealthService::share_stats() return; assert(!stats.empty()); - entity_inst_t our_inst = mon->monmap->get_inst(mon->rank); + entity_inst_t our_inst = mon->messenger->get_myinst(); assert(stats.count(our_inst) > 0); DataStats &ours = stats[our_inst]; const set& quorum = mon->get_quorum(); @@ -176,7 +176,7 @@ void DataHealthService::service_tick() if (in_quorum()) share_stats(); - DataStats &ours = stats[mon->monmap->get_inst(mon->name)]; + DataStats &ours = stats[mon->messenger->get_myinst()]; if (ours.latest_avail_percent <= g_conf->mon_data_avail_crit) { derr << "reached critical levels of available space on data store" diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index bd447a18701f..ab63ad80d1b7 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3429,8 +3429,8 @@ void Monitor::timecheck() << " round " << timecheck_round << dendl; // we are at the eye of the storm; the point of reference - timecheck_skews[monmap->get_inst(name)] = 0.0; - timecheck_latencies[monmap->get_inst(name)] = 0.0; + timecheck_skews[messenger->get_myinst()] = 0.0; + timecheck_latencies[messenger->get_myinst()] = 0.0; for (set::iterator it = quorum.begin(); it != quorum.end(); ++it) { if (monmap->get_name(*it) == name)