From: Sage Weil Date: Thu, 28 Apr 2011 21:09:52 +0000 (-0700) Subject: client: do not send request to mds -1 X-Git-Tag: v0.28~132^2~8 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=2614583882ba4a285ae00066417b3015582ccbbe;p=ceph.git client: do not send request to mds -1 If we can't find a target, or the chosen target isn't active, wait. Signed-off-by: Sage Weil --- diff --git a/src/client/Client.cc b/src/client/Client.cc index 1fb7283bfb0d0..13c39b9928a23 100644 --- a/src/client/Client.cc +++ b/src/client/Client.cc @@ -847,7 +847,8 @@ int Client::choose_target_mds(MetaRequest *req) goto out; } - if (g_conf.client_use_random_mds) goto random_mds; + if (g_conf.client_use_random_mds) + goto random_mds; if (req->inode) { in = req->inode; @@ -919,7 +920,6 @@ int Client::choose_target_mds(MetaRequest *req) random_mds: if (mds < 0) { mds = mdsmap->get_random_up_mds(); - if (mds < 0) mds = 0; //why is this necessary? dout(10) << "did not get mds through better means, so chose random mds " << mds << dendl; } @@ -991,10 +991,15 @@ int Client::make_request(MetaRequest *request, while (1) { // choose mds - int mds; - // force use of a particular mds? - mds = choose_target_mds(request); - + int mds = choose_target_mds(request); + if (mds < 0 || !mdsmap->is_active(mds)) { + Cond cond; + dout(10) << " target mds" << mds << " not active, waiting for new mdsmap" << dendl; + waiting_for_mdsmap.push_back(&cond); + cond.Wait(client_lock); + continue; + } + // open a session? if (mds_sessions.count(mds) == 0) { Cond cond; @@ -1346,7 +1351,8 @@ void Client::handle_client_reply(MClientReply *reply) dout(20) << "got ESTALE on req" << request->tid << "from mds" << request->mds << dendl; request->resend_mds = choose_target_mds(request); - if (request->resend_mds != request->mds) { //wasn't sent to auth, resend + if (request->resend_mds >= 0 && + request->resend_mds != request->mds) { //wasn't sent to auth, resend dout(20) << "but it wasn't sent to auth, resending" << dendl; send_request(request, request->resend_mds); return;