]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
client: fix mount timeout 3306/head
authorYan, Zheng <zyan@redhat.com>
Wed, 7 Jan 2015 08:22:29 +0000 (16:22 +0800)
committerYan, Zheng <zyan@redhat.com>
Wed, 7 Jan 2015 08:27:25 +0000 (16:27 +0800)
implement a simple timeout mechanism for make_request()

Fixes: #10041
Signed-off-by: Yan, Zheng <zyan@redhat.com>
src/client/Client.cc
src/client/MetaRequest.h

index fa47ac938b12744510a6bc172d80e163d3f62637..ac33425fe7fcfe7bb134bc759d1d770364341b3f 100644 (file)
@@ -1478,6 +1478,9 @@ int Client::make_request(MetaRequest *request,
     request->resend_mds = use_mds;
 
   while (1) {
+    if (request->aborted)
+      break;
+
     // set up wait cond
     Cond caller_cond;
     request->caller_cond = &caller_cond;
@@ -1536,6 +1539,16 @@ int Client::make_request(MetaRequest *request,
       break;
   }
 
+  if (!request->reply) {
+    assert(request->aborted);
+    assert(!request->got_unsafe);
+    request->item.remove_myself();
+    mds_requests.erase(tid);
+    put_request(request); // request map's
+    put_request(request); // ours
+    return -ETIMEDOUT;
+  }
+
   // got it!
   MClientReply *reply = request->reply;
   request->reply = NULL;
@@ -4763,6 +4776,22 @@ void Client::tick()
 
   utime_t now = ceph_clock_now(cct);
 
+  if (!mounted && !mds_requests.empty()) {
+    MetaRequest *req = mds_requests.begin()->second;
+    if (req->op_stamp + cct->_conf->client_mount_timeout < now) {
+      req->aborted = true;
+      if (req->caller_cond) {
+       req->kick = true;
+       req->caller_cond->Signal();
+      }
+      signal_cond_list(waiting_for_mdsmap);
+      for (map<mds_rank_t,MetaSession*>::iterator p = mds_sessions.begin();
+          p != mds_sessions.end();
+         ++p)
+       signal_context_list(p->second->waiting_for_open);
+    }
+  }
+
   if (mdsmap->get_epoch()) {
     // renew caps?
     utime_t el = now - last_cap_renew;
index 24b2f54cef4e68c6aae0ff6189f6bbe891a22023..e3b6bd167cc0a8c5015c04047b032646f84943c4 100644 (file)
@@ -53,6 +53,7 @@ public:
   
   MClientReply *reply;         // the reply
   bool kick;
+  bool aborted;
   
   // readdir result
   frag_t readdir_frag;
@@ -90,7 +91,7 @@ public:
     mds(-1), resend_mds(-1), send_to_auth(false), sent_on_mseq(0),
     num_fwd(0), retry_attempt(0),
     ref(1), reply(0), 
-    kick(false),
+    kick(false), aborted(false),
     readdir_offset(0), readdir_end(false), readdir_num(0),
     got_unsafe(false), item(this), unsafe_item(this),
     lock("MetaRequest lock"),