]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
uclient: insert_trace in reply handler
authorSage Weil <sage@newdream.net>
Thu, 2 Jul 2009 21:53:14 +0000 (14:53 -0700)
committerSage Weil <sage@newdream.net>
Thu, 2 Jul 2009 21:53:14 +0000 (14:53 -0700)
This will avoid the ugly kickback crap.

Also, after mds reconnect, we may get a safe reply (after we already
got an unsafe from the previous mds) that includes the new cap.

src/client/Client.cc
src/client/Client.h

index d73152e2e54ffa23ebaa8391f8c78bf33c8e81b1..82dd961965abe047520e0303e92f18d85d5527f8 100644 (file)
@@ -653,6 +653,7 @@ Inode* Client::insert_trace(MetaRequest *request, utime_t from, int mds)
       close_dir(dir);
   }
   
+  request->target = in;
   return in;
 }
 
@@ -845,7 +846,9 @@ MClientReply *Client::make_request(MClientRequest *req,
 
   // got it!
   MClientReply *reply = request->reply;
-  int mds = reply->get_source().num();
+  request->reply = 0;
+  if (ptarget)
+    *ptarget = request->target;
 
   // kick dispatcher (we've got it!)
   assert(request->dispatch_cond);
@@ -853,16 +856,10 @@ MClientReply *Client::make_request(MClientRequest *req,
   dout(20) << "sendrecv kickback on tid " << tid << " " << request->dispatch_cond << dendl;
   request->dispatch_cond = 0;
   
-  // insert trace
-  utime_t from = request->sent_stamp;
-  Inode *target = insert_trace(request, from, mds);
-  if (ptarget)
-    *ptarget = target;
-
   // -- log times --
   if (client_logger) {
     utime_t lat = g_clock.real_now();
-    lat -= start;
+    lat -= request->sent_stamp;
     dout(20) << "lat " << lat << dendl;
     client_logger->favg(l_c_lat,(double)lat);
     client_logger->favg(l_c_reply,(double)lat);
@@ -1035,13 +1032,14 @@ void Client::handle_client_reply(MClientReply *reply)
     return;
   }
   
+  int mds = reply->get_source().num();
+  request->reply = reply;
+  insert_trace(request, request->sent_stamp, mds);
+
   if (!request->got_unsafe) {
     request->got_unsafe = true;
     mds_sessions[mds_num].unsafe_requests.push_back(&request->unsafe_item);
 
-    // store reply
-    request->reply = reply;
-    
     Cond cond;
     request->dispatch_cond = &cond;
     
index 94617b2011ad220ea0674405bad0228a9b8edca8..d76dfd46df86a8b2ef794209b6c2add77c7872c9 100644 (file)
@@ -89,6 +89,7 @@ extern class Logger  *client_logger;
  
 */
 struct InodeCap;
+struct Inode;
 
 struct MetaRequest {
   tid_t tid;
@@ -116,13 +117,15 @@ struct MetaRequest {
   Cond  *caller_cond;          // who to take up
   Cond  *dispatch_cond;        // who to kick back
 
+  Inode *target;
+
   MetaRequest(MClientRequest *req, tid_t t) : 
     tid(t), request(req), 
     resend_mds(-1), num_fwd(0), retry_attempt(0),
     ref(1), reply(0), 
     got_safe(false), got_unsafe(false), unsafe_item(this),
     lock("MetaRequest lock"),
-    caller_cond(0), dispatch_cond(0) { }
+    caller_cond(0), dispatch_cond(0), target(0) { }
 
   MetaRequest* get() {++ref; return this; }