]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: get own entity_inst_t via messenger, not monmap
authorSage Weil <sage@inktank.com>
Thu, 25 Apr 2013 22:18:42 +0000 (15:18 -0700)
committerSage Weil <sage@inktank.com>
Thu, 25 Apr 2013 22:18:55 +0000 (15:18 -0700)
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 <sage@inktank.com>
Reviewed-by: Greg Farnum <greg@inktank.com>
src/mon/DataHealthService.cc
src/mon/Monitor.cc

index 949e1e2efe3f2c0fbd543dce790dfb033e0d74c0..a55e8c392e22e42c6c12a36c188dfcb1f96faca7 100644 (file)
@@ -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<int>& 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"
index bd447a18701f01cd85094101c7d4e525c64358be..ab63ad80d1b72b40ee582d25528979b3c3caf433 100644 (file)
@@ -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<int>::iterator it = quorum.begin(); it != quorum.end(); ++it) {
     if (monmap->get_name(*it) == name)