Whamcloud - gitweb
LU-694 ptlrpc: Job Stats
[fs/lustre-release.git] / lustre / ptlrpc / client.c
index 0f159e5..2995e6a 100644 (file)
@@ -606,7 +606,30 @@ EXPORT_SYMBOL(ptlrpc_request_bufs_pack);
 int ptlrpc_request_pack(struct ptlrpc_request *request,
                         __u32 version, int opcode)
 {
-        return ptlrpc_request_bufs_pack(request, version, opcode, NULL, NULL);
+       int rc;
+       rc = ptlrpc_request_bufs_pack(request, version, opcode, NULL, NULL);
+       if (rc)
+               return rc;
+
+       /* For some old 1.8 clients (< 1.8.7), they will LASSERT the size of
+        * ptlrpc_body sent from server equal to local ptlrpc_body size, so we
+        * have to send old ptlrpc_body to keep interoprability with these
+        * clients.
+        *
+        * Only three kinds of server->client RPCs so far:
+        *  - LDLM_BL_CALLBACK
+        *  - LDLM_CP_CALLBACK
+        *  - LDLM_GL_CALLBACK
+        *
+        * XXX This should be removed whenever we drop the interoprability with
+        *     the these old clients.
+        */
+       if (opcode == LDLM_BL_CALLBACK || opcode == LDLM_CP_CALLBACK ||
+           opcode == LDLM_GL_CALLBACK)
+               req_capsule_shrink(&request->rq_pill, &RMF_PTLRPC_BODY,
+                                  sizeof(struct ptlrpc_body_v2), RCL_CLIENT);
+
+       return rc;
 }
 
 /**
@@ -951,6 +974,7 @@ int ptlrpc_set_add_cb(struct ptlrpc_request_set *set,
 void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
                         struct ptlrpc_request *req)
 {
+       char jobid[JOBSTATS_JOBID_SIZE];
         LASSERT(cfs_list_empty(&req->rq_set_chain));
 
         /* The set takes over the caller's request reference */
@@ -958,6 +982,11 @@ void ptlrpc_set_add_req(struct ptlrpc_request_set *set,
         req->rq_set = set;
         cfs_atomic_inc(&set->set_remaining);
         req->rq_queued_time = cfs_time_current();
+
+       if (req->rq_reqmsg) {
+               lustre_get_jobid(jobid);
+               lustre_msg_set_jobid(req->rq_reqmsg, jobid);
+       }
 }
 
 /**