]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mds: clean up startup, state transitions
authorSage Weil <sage@newdream.net>
Fri, 9 May 2008 16:11:00 +0000 (09:11 -0700)
committerSage Weil <sage@newdream.net>
Fri, 9 May 2008 16:11:00 +0000 (09:11 -0700)
src/mds/MDS.cc
src/mds/MDS.h
src/mds/journal.cc

index cc4b14fe828a662c97588770a5ed5c6db1a28bac..4a5b7c3af5769c967d7a3eef27353bb71e79edc5 100644 (file)
@@ -447,7 +447,6 @@ void MDS::beacon_kill(utime_t lab)
 
 void MDS::handle_mds_map(MMDSMap *m)
 {
-  version_t hadepoch = mdsmap->get_epoch();
   version_t epoch = m->get_epoch();
   dout(5) << "handle_mds_map epoch " << epoch << " from " << m->get_source() << dendl;
 
@@ -535,14 +534,10 @@ void MDS::handle_mds_map(MMDSMap *m)
   
   // did it change?
   if (oldstate != state) {
-    if (state == want_state) {
-      dout(1) << "handle_mds_map new state " << mdsmap->get_state_name(state) << dendl;
-    } else {
-      dout(1) << "handle_mds_map new state " << mdsmap->get_state_name(state)
-       //            << ", although i wanted " << mdsmap->get_state_name(want_state)
-             << dendl;
-      want_state = state;
-    }    
+    dout(1) << "handle_mds_map state change "
+           << mdsmap->get_state_name(oldstate) << " --> "
+           << mdsmap->get_state_name(state) << dendl;
+    want_state = state;
 
     // now active?
     if (is_active()) {
@@ -557,6 +552,10 @@ void MDS::handle_mds_map(MMDSMap *m)
       resolve_start();
     } else if (is_reconnect()) {
       reconnect_start();
+    } else if (is_creating()) {
+      boot_create();
+    } else if (is_starting()) {
+      boot_start();
     } else if (is_stopping()) {
       assert(oldstate == MDSMap::STATE_ACTIVE);
       stopping_start();
@@ -637,16 +636,6 @@ void MDS::handle_mds_map(MMDSMap *m)
        mdcache->migrator->handle_mds_failure_or_stop(*p);
   }
 
-  // just got mdsmap+osdmap?
-  if (hadepoch == 0 && 
-      mdsmap->get_epoch() > 0 &&
-      osdmap->get_epoch() > 0) {
-    boot();
-  } else if (want_state != state) {
-    // resend beacon.
-    beacon_send();
-  }
-
  out:
   delete m;
   delete oldmap;
@@ -667,39 +656,13 @@ void MDS::bcast_mds_map()
 }
 
 
-void MDS::handle_osd_map(MOSDMap *m)
-{
-  version_t hadepoch = osdmap->get_epoch();
-  dout(10) << "handle_osd_map had " << hadepoch << dendl;
-  
-  // process
-  objecter->handle_osd_map(m);
-
-  // just got mdsmap+osdmap?
-  if (hadepoch == 0 && 
-      osdmap->get_epoch() > 0 &&
-      mdsmap->get_epoch() > 0) 
-    boot();
-}
-
-
-void MDS::set_want_state(int s)
+void MDS::request_state(int s)
 {
-  dout(3) << "set_want_state " << MDSMap::get_state_name(s) << dendl;
+  dout(3) << "request_state " << MDSMap::get_state_name(s) << dendl;
   want_state = s;
   beacon_send();
 }
 
-void MDS::boot()
-{   
-  if (is_creating()) 
-    boot_create();    // new tables, journal
-  else if (is_starting() || is_replay())
-    boot_start();    // start|replay, join
-  else 
-    assert(is_standby());
-}
-
 
 class C_MDS_CreateFinish : public Context {
   MDS *mds;
@@ -772,7 +735,7 @@ void MDS::boot_create()
 void MDS::creating_done()
 {
   dout(1)<< "creating_done" << dendl;
-  set_want_state(MDSMap::STATE_ACTIVE);
+  request_state(MDSMap::STATE_ACTIVE);
 }
 
 
@@ -854,7 +817,7 @@ void MDS::starting_done()
 {
   dout(3) << "starting_done" << dendl;
   assert(is_starting());
-  set_want_state(MDSMap::STATE_ACTIVE);
+  request_state(MDSMap::STATE_ACTIVE);
 
   // start new segment
   mdlog->start_new_segment(0);
@@ -873,9 +836,9 @@ void MDS::replay_start()
   mdcache->set_recovery_set(rs);
 
   // start?
-  if (osdmap->get_epoch() > 0 &&
-      mdsmap->get_epoch() > 0)
-    boot_start();
+  //if (osdmap->get_epoch() > 0 &&
+  //mdsmap->get_epoch() > 0)
+  boot_start();
 }
 
 void MDS::replay_done()
@@ -885,10 +848,10 @@ void MDS::replay_done()
   if (mdsmap->get_num_in_mds() == 1 &&
       mdsmap->get_num_mds(MDSMap::STATE_FAILED) == 0) { // just me!
     dout(2) << "i am alone, moving to state reconnect" << dendl;      
-    set_want_state(MDSMap::STATE_RECONNECT);
+    request_state(MDSMap::STATE_RECONNECT);
   } else {
     dout(2) << "i am not alone, moving to state resolve" << dendl;
-    set_want_state(MDSMap::STATE_RESOLVE);
+    request_state(MDSMap::STATE_RESOLVE);
   }
 
   // start new segment
@@ -913,7 +876,7 @@ void MDS::resolve_start()
 void MDS::resolve_done()
 {
   dout(1) << "resolve_done" << dendl;
-  set_want_state(MDSMap::STATE_RECONNECT);
+  request_state(MDSMap::STATE_RECONNECT);
 }
 
 void MDS::reconnect_start()
@@ -924,7 +887,7 @@ void MDS::reconnect_start()
 void MDS::reconnect_done()
 {
   dout(1) << "reconnect_done" << dendl;
-  set_want_state(MDSMap::STATE_REJOIN);    // move to rejoin state
+  request_state(MDSMap::STATE_REJOIN);    // move to rejoin state
 
   /*
   if (mdsmap->get_num_in_mds() == 1 &&
@@ -933,9 +896,9 @@ void MDS::reconnect_done()
     // finish processing caps (normally, this happens during rejoin, but we're skipping that...)
     mdcache->rejoin_gather_finish();
 
-    set_want_state(MDSMap::STATE_ACTIVE);    // go active
+    request_state(MDSMap::STATE_ACTIVE);    // go active
   } else {
-    set_want_state(MDSMap::STATE_REJOIN);    // move to rejoin state
+    request_state(MDSMap::STATE_REJOIN);    // move to rejoin state
   }
   */
 }
@@ -950,7 +913,7 @@ void MDS::rejoin_done()
   dout(1) << "rejoin_done" << dendl;
   mdcache->show_subtrees();
   mdcache->show_cache();
-  set_want_state(MDSMap::STATE_ACTIVE);
+  request_state(MDSMap::STATE_ACTIVE);
 }
 
 
@@ -1004,7 +967,7 @@ void MDS::stopping_done()
   dout(2) << "stopping_done" << dendl;
 
   // tell monitor we shut down cleanly.
-  set_want_state(MDSMap::STATE_STOPPED);
+  request_state(MDSMap::STATE_STOPPED);
 }
 
   
@@ -1118,7 +1081,7 @@ void MDS::_dispatch(Message *m)
       objecter->handle_osd_op_reply((class MOSDOpReply*)m);
       break;
     case CEPH_MSG_OSD_MAP:
-      handle_osd_map((MOSDMap*)m);
+      objecter->handle_osd_map((MOSDMap*)m);
       break;
       
       // MDS
@@ -1244,7 +1207,7 @@ void MDS::proc_message(Message *m)
     objecter->handle_osd_op_reply((class MOSDOpReply*)m);
     return;
   case CEPH_MSG_OSD_MAP:
-    handle_osd_map((MOSDMap*)m);
+    objecter->handle_osd_map((MOSDMap*)m);
     return;
 
 
index 442bcacad6c994341145a2cd6811d10950403a88..1afe25dfb2b10610c9aac1f3bf19f80b956734dc 100644 (file)
@@ -143,7 +143,7 @@ class MDS : public Dispatcher {
   bool is_stopping() { return state == MDSMap::STATE_STOPPING; }
   bool is_stopped()  { return state == MDSMap::STATE_STOPPED; }
 
-  void set_want_state(int s);
+  void request_state(int s);
 
   tid_t issue_tid() { return ++last_tid; }
     
@@ -235,7 +235,6 @@ class MDS : public Dispatcher {
 
   void bcast_mds_map();  // to mounted clients
 
-  void boot();
   void boot_create();             // i am new mds.
   void boot_start(int step=0, int r=0);    // starting|replay
 
@@ -276,9 +275,6 @@ class MDS : public Dispatcher {
 
   // special message types
   void handle_mds_map(class MMDSMap *m);
-
-  // osds
-  void handle_osd_map(class MOSDMap *m);
 };
 
 
index c92f51289f626a432cd665e5c6d7a4b632005bf5..a11a4f556bbdcaab92d2e1fb218a4fd430daf8a9 100644 (file)
@@ -680,7 +680,7 @@ void ESubtreeMap::replay(MDS *mds)
   dout(10) << "ESubtreeMap.replay -- reconstructing (auth) subtree spanning tree" << dendl;
   
   // first, stick the spanning tree in my cache
-  //metablob.print(cout);
+  //metablob.print(*_dout);
   metablob.replay(mds, _segment);
   
   // restore import/export maps