]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
query for new mdsmap if missing an inst
authorsageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 17 Jul 2007 23:47:04 +0000 (23:47 +0000)
committersageweil <sageweil@29311d96-e01e-0410-9327-a35deaab8ce9>
Tue, 17 Jul 2007 23:47:04 +0000 (23:47 +0000)
git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1522 29311d96-e01e-0410-9327-a35deaab8ce9

trunk/ceph/client/Client.cc
trunk/ceph/client/Client.h

index c07253ee6c763c898be9f8be2160e10cc3201373..290b0af500fa93a69b0441ec444fe78e570cf226 100644 (file)
@@ -607,6 +607,21 @@ MClientReply *Client::make_request(MClientRequest *req,
     // open a session?
     if (mds_sessions.count(mds) == 0) {
       Cond cond;
+
+      if (!mdsmap->have_inst(mds)) {
+       dout(10) << "no address for mds" << mds << ", requesting new mdsmap" << endl;
+       int mon = monmap->pick_mon();
+       messenger->send_message(new MMDSGetMap(),
+                               monmap->get_inst(mon));
+       waiting_for_mdsmap.push_back(&cond);
+       cond.Wait(client_lock);
+
+       if (!mdsmap->have_inst(mds)) {
+         dout(10) << "hmm, still have no address for mds" << mds << ", trying a random mds" << endl;
+         request.resend_mds = mdsmap->get_random_in_mds();
+         continue;
+       }
+      }        
       
       if (waiting_for_session.count(mds) == 0) {
        dout(10) << "opening session to mds" << mds << endl;
@@ -916,6 +931,12 @@ void Client::handle_mds_map(MMDSMap* m)
     //failed_mds.erase(from);
   }
 
+  // kick any waiting threads
+  list<Cond*> ls;
+  ls.swap(waiting_for_mdsmap);
+  for (list<Cond*>::iterator p = ls.begin(); p != ls.end(); ++p)
+    (*p)->Signal();
+
   delete m;
 }
 
index c0a44fe47329637c2a7aeb31640873d654064162..9492a3f4517257b03b94749dffad81409555325a 100644 (file)
@@ -345,6 +345,7 @@ class Client : public Dispatcher {
   // mds sessions
   map<int, version_t> mds_sessions;  // mds -> push seq
   map<int, list<Cond*> > waiting_for_session;
+  list<Cond*> waiting_for_mdsmap;
 
   void handle_client_session(MClientSession *m);
   void send_reconnect(int mds);