peering_wq.drain();
dout(0) << "done with init, starting boot process" << dendl;
- set_state(STATE_BOOTING);
-
- // we don't need to ask for an osdmap here; objecter will
-
start_boot();
return 0;
if (is_waiting_for_healthy()) {
if (_is_healthy()) {
dout(1) << "healthy again, booting" << dendl;
- set_state(STATE_BOOTING);
start_boot();
}
}
return;
dout(10) << "ms_handle_connect on mon" << dendl;
- if (is_booting()) {
+ if (is_preboot() || is_booting()) {
start_boot();
} else {
utime_t now = ceph_clock_now(NULL);
C_OSD_GetVersion(OSD *o) : osd(o), oldest(0), newest(0) {}
void finish(int r) {
if (r >= 0)
- osd->maybe_boot(oldest, newest);
+ osd->_got_mon_epochs(oldest, newest);
}
};
void OSD::start_boot()
{
+ set_state(STATE_PREBOOT);
dout(10) << "start_boot - have maps " << superblock.oldest_map
<< ".." << superblock.newest_map << dendl;
C_OSD_GetVersion *c = new C_OSD_GetVersion(this);
monc->get_version("osdmap", &c->newest, &c->oldest, c);
}
-void OSD::maybe_boot(epoch_t oldest, epoch_t newest)
+void OSD::_got_mon_epochs(epoch_t oldest, epoch_t newest)
{
- Mutex::Locker l(osd_lock);
- _maybe_boot(oldest, newest);
+ if (is_preboot()) {
+ Mutex::Locker l(osd_lock);
+ _preboot(oldest, newest);
+ }
}
-void OSD::_maybe_boot(epoch_t oldest, epoch_t newest)
+void OSD::_preboot(epoch_t oldest, epoch_t newest)
{
- if (!is_booting())
- return;
- dout(10) << "_maybe_boot mon has osdmaps " << oldest << ".." << newest << dendl;
-
- if (is_initializing()) {
- dout(10) << "still initializing" << dendl;
- return;
- }
+ assert(is_preboot());
+ dout(10) << __func__ << " _preboot mon has osdmaps "
+ << oldest << ".." << newest << dendl;
// if our map within recent history, try to add ourselves to the osdmap.
if (osdmap->test_flag(CEPH_OSDMAP_NOUP)) {
<< dendl;
_collect_metadata(&mboot->metadata);
monc->send_mon_message(mboot);
+ set_state(STATE_BOOTING);
}
void OSD::_collect_metadata(map<string,string> *pm)
dout(10) << " msg say newest map is " << m->newest_map << ", requesting more" << dendl;
osdmap_subscribe(osdmap->get_epoch()+1, true);
}
- else if (is_booting()) {
+ else if (is_preboot()) {
if (m->get_source().is_mon())
- _maybe_boot(m->oldest_map, m->newest_map);
+ _preboot(m->oldest_map, m->newest_map);
else
start_boot();
}
// -- state --
public:
- static const int STATE_INITIALIZING = 1;
- static const int STATE_BOOTING = 2;
- static const int STATE_ACTIVE = 3;
- static const int STATE_STOPPING = 4;
- static const int STATE_WAITING_FOR_HEALTHY = 5;
+ typedef enum {
+ STATE_INITIALIZING = 1,
+ STATE_PREBOOT,
+ STATE_BOOTING,
+ STATE_ACTIVE,
+ STATE_STOPPING,
+ STATE_WAITING_FOR_HEALTHY
+ } osd_state_t;
static const char *get_state_name(int s) {
switch (s) {
case STATE_INITIALIZING: return "initializing";
+ case STATE_PREBOOT: return "preboot";
case STATE_BOOTING: return "booting";
case STATE_ACTIVE: return "active";
case STATE_STOPPING: return "stopping";
bool is_initializing() {
return get_state() == STATE_INITIALIZING;
}
+ bool is_preboot() {
+ return get_state() == STATE_PREBOOT;
+ }
bool is_booting() {
return get_state() == STATE_BOOTING;
}
// -- boot --
void start_boot();
- void maybe_boot(epoch_t oldest, epoch_t newest);
- void _maybe_boot(epoch_t oldest, epoch_t newest);
+ void _got_mon_epochs(epoch_t oldest, epoch_t newest);
+ void _preboot(epoch_t oldest, epoch_t newest);
void _send_boot();
void _collect_metadata(map<string,string> *pmeta);
bool _lsb_release_set(char *buf, const char *str, map<string,string> *pm, const char *key);