CEPH filesystem development
 help / color / mirror / Atom feed
* OSDMap / osd_state questions
@ 2017-04-04 11:42 Jesse Williamson
  2017-04-04 12:18 ` Jesse Williamson
  2017-04-04 14:12 ` Sage Weil
  0 siblings, 2 replies; 5+ messages in thread
From: Jesse Williamson @ 2017-04-04 11:42 UTC (permalink / raw)
  To: Squid Cybernetic


Hello,

I have a couple of questions about OSDMap.

OSDMap has:
   int num_osd;         // not saved; see calc_num_osds
   int num_up_osd;      // not saved; see calc_num_osds
   int num_in_osd;      // not saved; see calc_num_osds

   int32_t max_osd;
   vector<uint8_t> osd_state;

   int calc_num_osds();

calc_num_osds() does this:
int OSDMap::calc_num_osds()
{
   num_osd = 0;
   num_up_osd = 0;
   num_in_osd = 0;
   for (int i=0; i<max_osd; i++) {
     if (osd_state[i] & CEPH_OSD_EXISTS) {
       ++num_osd;
       if (osd_state[i] & CEPH_OSD_UP) {
     ++num_up_osd;
       }
       if (get_weight(i) != CEPH_OSD_OUT) {
     ++num_in_osd;
       }
     }
   }
   return num_osd;
}

...is there some condition where an osd id will appear in osd_state and 
yet CEPH_OSD_EXISTS be false? It looks like the other two conditions, UP 
and OUT[1] depend on that being true.

First question: Can we get away with returning osd_state.size()?

Second, should the cached/memoized member variables set as a side-effect 
of calc_num_osds() /ever/ be trusted if we don't call the method first?

Finally, if we have to go through this loop anyway, perhaps in addition to 
the size we'll want to know the OSD ids as well? I see several places 
where we wind up looping through osd_state /again/ to get extra 
information (for example, OSDMonitor::get_health()).

Perhaps a method basically doing this would be useful, along these lines?

partition_copy(begin(osd_state), end(osd_state),
                begin(up_osds), begin(down_osds),
                [&osdmap](const int32_t osd_id) { return osdmap.is_up(osd_id); });

Thanks for reading,

-Jesse

1. It would be amusing to check for DOWN and OUT.;-)


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-04-04 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-04-04 11:42 OSDMap / osd_state questions Jesse Williamson
2017-04-04 12:18 ` Jesse Williamson
2017-04-04 14:16   ` Sage Weil
2017-04-04 14:12 ` Sage Weil
2017-04-04 14:55   ` Jesse Williamson

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox