]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
kclient: break out __prepare_send_request helper
authorSage Weil <sage@newdream.net>
Fri, 9 Jan 2009 20:49:17 +0000 (12:49 -0800)
committerSage Weil <sage@newdream.net>
Fri, 9 Jan 2009 22:16:17 +0000 (14:16 -0800)
This will be used for preparing the request when sent during reconnect
(instead of do_request, which exited after the first unsafe reply).

src/kernel/mds_client.c

index 3a8ec32cf1bed9065ae79287d60e2f6b42de45d0..66c45f59252a2dbe4fbeec629143879d8c558333 100644 (file)
@@ -1107,6 +1107,30 @@ static u64 __get_oldest_tid(struct ceph_mds_client *mdsc)
        return first->r_tid;
 }
 
+/*
+ * called under mdsc->mutex
+ */
+static void __prepare_send_request(struct ceph_mds_client *mdsc,
+                                  struct ceph_mds_request *req)
+{
+       struct ceph_mds_request_head *rhead;
+
+       /* if there are other references on this message, e.g., if we are
+        * told to forward it and the previous copy is still in flight, dup
+        * it. */
+       req->r_request = ceph_msg_maybe_dup(req->r_request);
+
+       rhead = req->r_request->front.iov_base;
+       rhead->retry_attempt = cpu_to_le32(req->r_attempts - 1);
+       rhead->oldest_client_tid = cpu_to_le64(__get_oldest_tid(mdsc));
+       rhead->num_fwd = cpu_to_le32(req->r_num_fwd);
+
+       if (req->r_last_inode)
+               rhead->ino = cpu_to_le64(ceph_ino(req->r_last_inode));
+       else
+               rhead->ino = 0;
+}
+
 /*
  * Synchrously perform an mds request.  Take care of all of the
  * session setup, forwarding, retry details.
@@ -1116,7 +1140,6 @@ int ceph_mdsc_do_request(struct ceph_mds_client *mdsc,
                         struct ceph_mds_request *req)
 {
        struct ceph_mds_session *session = NULL;
-       struct ceph_mds_request_head *rhead;
        int err;
        int mds = -1;
        int safe = 0;
@@ -1173,25 +1196,8 @@ retry:
        if (req->r_request_started == 0)   /* note request start time */
                req->r_request_started = jiffies;
 
-       /* if there are other references on this message, e.g., if we are
-        * told to forward it and the previous copy is still in flight, dup
-        * it. */
-       req->r_request = ceph_msg_maybe_dup(req->r_request);
-
-       rhead = req->r_request->front.iov_base;
-       rhead->retry_attempt = cpu_to_le32(req->r_attempts - 1);
-       rhead->oldest_client_tid = cpu_to_le64(__get_oldest_tid(mdsc));
-       rhead->num_fwd = cpu_to_le32(req->r_num_fwd);
-
-       if (req->r_last_inode)
-               rhead->ino = cpu_to_le64(ceph_ino(req->r_last_inode));
-       else
-               rhead->ino = 0;
-
-       /* send and wait */
+       __prepare_send_request(mdsc, req);
        mutex_unlock(&mdsc->mutex);
-       dout(10, "do_request %p %lld r_expected_cap=%p\n", req, req->r_tid,
-            req->r_expected_cap);
 
        ceph_msg_get(req->r_request);
        ceph_send_msg_mds(mdsc, req->r_request, mds);