All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: ceph-devel@vger.kernel.org
Subject: [PATCH 4/5] libceph: set response data fields earlier
Date: Tue, 05 Mar 2013 07:53:33 -0600	[thread overview]
Message-ID: <5135F8DD.3030602@inktank.com> (raw)
In-Reply-To: <5135F859.1090606@inktank.com>

When an incoming message is destined for the osd client, the
messenger calls the osd client's alloc_msg method.  That function
looks up which request has the tid matching the incoming message,
and returns the request message that was preallocated to receive the
response.  The response message is therefore known before the
request is even started.

Between the start of the request and the receipt of the response,
the request and its data fields will not change, so there's no
reason we need to hold off setting them.  In fact it's preferable
to set them just once because it's more obvious that they're
unchanging.

So set up the fields describing where incoming data is to land in a
response message at the beginning of ceph_osdc_start_request().
Define a helper function that sets these fields, and use it to
set the fields for both outgoing data in the request message and
incoming data in the response.

This resolves:
    http://tracker.ceph.com/issues/4284

Signed-off-by: Alex Elder <elder@inktank.com>
---
 net/ceph/osd_client.c |   38 ++++++++++++++++++--------------------
 1 file changed, 18 insertions(+), 20 deletions(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index c19188a..1bb2be9 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -1739,6 +1739,21 @@ bad:
 	return;
 }

+static void ceph_osdc_msg_data_set(struct ceph_msg *msg,
+				struct ceph_osd_data *osd_data)
+{
+	if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) {
+		ceph_msg_data_set_pages(msg, osd_data->pages,
+			osd_data->num_pages, osd_data->alignment);
+#ifdef CONFIG_BLOCK
+	} else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
+		ceph_msg_data_set_bio(msg, osd_data->bio);
+#endif
+	} else {
+		BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE);
+	}
+}
+
 /*
  * Register request, send initial attempt.
  */
@@ -1747,22 +1762,12 @@ int ceph_osdc_start_request(struct
ceph_osd_client *osdc,
 			    bool nofail)
 {
 	int rc = 0;
-	struct ceph_osd_data *osd_data;

-	/* Set up outgoing data */
+	/* Set up request outgoing data and response incoming data fields */

-	osd_data = &req->r_data_out;
-	if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) {
-		ceph_msg_data_set_pages(req->r_request, osd_data->pages,
-			osd_data->num_pages, osd_data->alignment);
-#ifdef CONFIG_BLOCK
-	} else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
-		ceph_msg_data_set_bio(req->r_request, osd_data->bio);
-#endif
-	} else {
-		BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE);
-	}
+	ceph_osdc_msg_data_set(req->r_request, &req->r_data_out);
 	ceph_msg_data_set_trail(req->r_request, &req->r_trail);
+	ceph_osdc_msg_data_set(req->r_reply, &req->r_data_in);

 	register_request(osdc, req);

@@ -2126,13 +2131,6 @@ static struct ceph_msg *get_reply(struct
ceph_connection *con,
 				m = NULL;
 				goto out;
 			}
-
-			ceph_msg_data_set_pages(m, osd_data->pages,
-				osd_data->num_pages, osd_data->alignment);
-#ifdef CONFIG_BLOCK
-		} else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
-			ceph_msg_data_set_bio(m, osd_data->bio);
-#endif
 		}
 	}
 	*skip = 0;
-- 
1.7.9.5


  parent reply	other threads:[~2013-03-05 13:53 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-03-05 13:51 [PATCH 0/5] ceph: abstract message data information setting Alex Elder
2013-03-05 13:52 ` [PATCH 1/5] libceph: isolate message page field manipulation Alex Elder
2013-03-05 16:03   ` Alex Elder
2013-03-05 13:52 ` [PATCH 2/5] libceph: isolate other message data fields Alex Elder
2013-03-05 13:53 ` [PATCH 3/5] ceph: only set message data pointers if non-empty Alex Elder
2013-03-05 21:20   ` Greg Farnum
2013-03-05 13:53 ` Alex Elder [this message]
2013-03-05 13:53 ` [PATCH 5/5] libceph: activate message data assignment checks Alex Elder
2013-03-05 21:21   ` Greg Farnum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5135F8DD.3030602@inktank.com \
    --to=elder@inktank.com \
    --cc=ceph-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.