From ceda1788c03f65513413021100958756206fd810 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Fri, 9 Jan 2009 12:49:17 -0800 Subject: [PATCH] kclient: break out __prepare_send_request helper 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 | 44 +++++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/src/kernel/mds_client.c b/src/kernel/mds_client.c index 3a8ec32cf1bed..66c45f59252a2 100644 --- a/src/kernel/mds_client.c +++ b/src/kernel/mds_client.c @@ -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); -- 2.39.5