From 4a39c2840f5894c2145d7bd0f2a62da61b49972f Mon Sep 17 00:00:00 2001 From: sageweil Date: Tue, 17 Jul 2007 23:47:04 +0000 Subject: [PATCH] query for new mdsmap if missing an inst git-svn-id: https://ceph.svn.sf.net/svnroot/ceph@1522 29311d96-e01e-0410-9327-a35deaab8ce9 --- trunk/ceph/client/Client.cc | 21 +++++++++++++++++++++ trunk/ceph/client/Client.h | 1 + 2 files changed, 22 insertions(+) diff --git a/trunk/ceph/client/Client.cc b/trunk/ceph/client/Client.cc index c07253ee6c763..290b0af500fa9 100644 --- a/trunk/ceph/client/Client.cc +++ b/trunk/ceph/client/Client.cc @@ -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 ls; + ls.swap(waiting_for_mdsmap); + for (list::iterator p = ls.begin(); p != ls.end(); ++p) + (*p)->Signal(); + delete m; } diff --git a/trunk/ceph/client/Client.h b/trunk/ceph/client/Client.h index c0a44fe473296..9492a3f451725 100644 --- a/trunk/ceph/client/Client.h +++ b/trunk/ceph/client/Client.h @@ -345,6 +345,7 @@ class Client : public Dispatcher { // mds sessions map mds_sessions; // mds -> push seq map > waiting_for_session; + list waiting_for_mdsmap; void handle_client_session(MClientSession *m); void send_reconnect(int mds); -- 2.39.5