All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: [PATCH 19/20] libceph: set the data pointers when encoding ops
Date: Fri, 05 Apr 2013 09:06:04 -0500	[thread overview]
Message-ID: <515EDA4C.4090305@inktank.com> (raw)
In-Reply-To: <515ED849.9060901@inktank.com>

Still using the osd request r_data_in and r_data_out pointer, but
we're basically only referring to it via the data pointers in the
osd ops.  And we're transferring that information to the request
or reply message only when the op indicates it's needed, in
osd_req_encode_op().

To avoid a forward reference, ceph_osdc_msg_data_set() was moved up
in the file.

Don't bother calling ceph_osd_data_init(), in ceph_osd_alloc(),
because the ops array will already be zeroed anyway.

Signed-off-by: Alex Elder <elder@inktank.com>
---
 include/linux/ceph/osd_client.h |    2 +-
 net/ceph/osd_client.c           |   63
+++++++++++++++++++--------------------
 2 files changed, 32 insertions(+), 33 deletions(-)

diff --git a/include/linux/ceph/osd_client.h
b/include/linux/ceph/osd_client.h
index f8a00b4..dd4ca4ba 100644
--- a/include/linux/ceph/osd_client.h
+++ b/include/linux/ceph/osd_client.h
@@ -51,7 +51,7 @@ struct ceph_osd {
 #define CEPH_OSD_MAX_OP	2

 enum ceph_osd_data_type {
-	CEPH_OSD_DATA_TYPE_NONE,
+	CEPH_OSD_DATA_TYPE_NONE = 0,
 	CEPH_OSD_DATA_TYPE_PAGES,
 	CEPH_OSD_DATA_TYPE_PAGELIST,
 #ifdef CONFIG_BLOCK
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 86cb524..cc4003f 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -339,9 +339,6 @@ struct ceph_osd_request
*ceph_osdc_alloc_request(struct ceph_osd_client *osdc,
 	}
 	req->r_reply = msg;

-	ceph_osd_data_init(&req->r_data_in);
-	ceph_osd_data_init(&req->r_data_out);
-
 	/* create request message; allow space for oid */
 	if (use_mempool)
 		msg = ceph_msgpool_get(&osdc->msgpool_op, 0);
@@ -549,6 +546,28 @@ void osd_req_op_watch_init(struct ceph_osd_request
*osd_req,
 }
 EXPORT_SYMBOL(osd_req_op_watch_init);

+static void ceph_osdc_msg_data_set(struct ceph_msg *msg,
+				struct ceph_osd_data *osd_data)
+{
+	u64 length = ceph_osd_data_length(osd_data);
+
+	if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) {
+		BUG_ON(length > (u64) SIZE_MAX);
+		if (length)
+			ceph_msg_data_set_pages(msg, osd_data->pages,
+					length, osd_data->alignment);
+	} else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) {
+		BUG_ON(!length);
+		ceph_msg_data_set_pagelist(msg, osd_data->pagelist);
+#ifdef CONFIG_BLOCK
+	} else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
+		ceph_msg_data_set_bio(msg, osd_data->bio, length);
+#endif
+	} else {
+		BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE);
+	}
+}
+
 static u64 osd_req_encode_op(struct ceph_osd_request *req,
 			      struct ceph_osd_op *dst, unsigned int which)
 {
@@ -576,17 +595,24 @@ static u64 osd_req_encode_op(struct
ceph_osd_request *req,
 			cpu_to_le64(src->extent.truncate_size);
 		dst->extent.truncate_seq =
 			cpu_to_le32(src->extent.truncate_seq);
-		if (src->op == CEPH_OSD_OP_WRITE)
+		if (src->op == CEPH_OSD_OP_WRITE) {
 			WARN_ON(src->extent.osd_data != &req->r_data_out);
-		else
+			ceph_osdc_msg_data_set(req->r_request,
+						src->extent.osd_data);
+		} else {
 			WARN_ON(src->extent.osd_data != &req->r_data_in);
+			ceph_osdc_msg_data_set(req->r_reply,
+						src->extent.osd_data);
+		}
 		break;
 	case CEPH_OSD_OP_CALL:
 		dst->cls.class_len = src->cls.class_len;
 		dst->cls.method_len = src->cls.method_len;
 		dst->cls.indata_len = cpu_to_le32(src->cls.request_data_len);
 		WARN_ON(src->cls.response_data != &req->r_data_in);
+		ceph_osdc_msg_data_set(req->r_reply, src->cls.response_data);
 		WARN_ON(src->cls.request_info != &req->r_data_out);
+		ceph_osdc_msg_data_set(req->r_request, src->cls.request_info);
 		BUG_ON(src->cls.request_info->type !=
 					CEPH_OSD_DATA_TYPE_PAGELIST);
 		request_data_len = src->cls.request_info->pagelist->length;
@@ -1930,28 +1956,6 @@ bad:
 	return;
 }

-static void ceph_osdc_msg_data_set(struct ceph_msg *msg,
-				struct ceph_osd_data *osd_data)
-{
-	u64 length = ceph_osd_data_length(osd_data);
-
-	if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGES) {
-		BUG_ON(length > (u64) SIZE_MAX);
-		if (length)
-			ceph_msg_data_set_pages(msg, osd_data->pages,
-					length, osd_data->alignment);
-	} else if (osd_data->type == CEPH_OSD_DATA_TYPE_PAGELIST) {
-		BUG_ON(!length);
-		ceph_msg_data_set_pagelist(msg, osd_data->pagelist);
-#ifdef CONFIG_BLOCK
-	} else if (osd_data->type == CEPH_OSD_DATA_TYPE_BIO) {
-		ceph_msg_data_set_bio(msg, osd_data->bio, length);
-#endif
-	} else {
-		BUG_ON(osd_data->type != CEPH_OSD_DATA_TYPE_NONE);
-	}
-}
-
 /*
  * build new request AND message
  *
@@ -1967,11 +1971,6 @@ void ceph_osdc_build_request(struct
ceph_osd_request *req, u64 off,
 	u64 data_len;
 	unsigned int i;

-	/* Set up response incoming data and request outgoing data fields */
-
-	ceph_osdc_msg_data_set(req->r_reply, &req->r_data_in);
-	ceph_osdc_msg_data_set(req->r_request, &req->r_data_out);
-
 	req->r_snapid = snap_id;
 	req->r_snapc = ceph_get_snap_context(snapc);

-- 
1.7.9.5


  parent reply	other threads:[~2013-04-05 14:06 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-05 13:57 [PATCH 00/20] libceph: per-op osd request data Alex Elder
2013-04-05 14:01 ` [PATCH 01/20] rbd: define inbound data size for method ops Alex Elder
2013-04-05 18:13   ` Josh Durgin
2013-04-05 14:01 ` [PATCH 02/20] libceph: compute incoming bytes once Alex Elder
2013-04-05 18:14   ` Josh Durgin
2013-04-05 14:02 ` [PATCH 03/20] libceph: define osd data initialization helpers Alex Elder
2013-04-05 18:16   ` Josh Durgin
2013-04-05 14:02 ` [PATCH 04/20] libceph: define a few more helpers Alex Elder
2013-04-05 18:17   ` Josh Durgin
2013-04-05 14:02 ` [PATCH 05/20] libceph: define ceph_osd_data_length() Alex Elder
2013-04-05 18:17   ` Josh Durgin
2013-04-05 14:02 ` [PATCH 06/20] libceph: a few more osd data cleanups Alex Elder
2013-04-05 18:17   ` Josh Durgin
2013-04-05 14:03 ` [PATCH 07/20] rbd: define rbd_osd_req_format_op() Alex Elder
2013-04-05 18:18   ` Josh Durgin
2013-04-05 14:03 ` [PATCH 08/20] libceph: keep source rather than message osd op array Alex Elder
2013-04-08 18:12   ` Josh Durgin
2013-04-05 14:03 ` [PATCH 09/20] libceph: rename data out field in osd request op Alex Elder
2013-04-08 18:12   ` Josh Durgin
2013-04-05 14:03 ` [PATCH 10/20] libceph: add data pointers in osd op structures Alex Elder
2013-04-08 18:13   ` Josh Durgin
2013-04-05 14:04 ` [PATCH 11/20] libceph: specify osd op by index in request Alex Elder
2013-04-08 18:14   ` Josh Durgin
2013-04-05 14:04 ` [PATCH 12/20] rbd: don't set data in rbd_osd_req_format_op() Alex Elder
2013-04-08 18:14   ` Josh Durgin
2013-04-05 14:04 ` [PATCH 13/20] rbd: separate initialization of osd data Alex Elder
2013-04-08 18:14   ` Josh Durgin
2013-04-05 14:04 ` [PATCH 14/20] rbd: rearrange some code for consistency Alex Elder
2013-04-08 18:15   ` Josh Durgin
2013-04-05 14:05 ` [PATCH 15/20] libceph: format class info at init time Alex Elder
2013-04-08 18:16   ` Josh Durgin
2013-04-05 14:05 ` [PATCH 16/20] libceph: move ceph_osdc_build_request() Alex Elder
2013-04-08 18:17   ` Josh Durgin
2013-04-05 14:05 ` [PATCH 17/20] libceph: set message data when building osd request Alex Elder
2013-04-08 18:17   ` Josh Durgin
2013-04-05 14:05 ` [PATCH 18/20] libceph: combine initializing and setting osd data Alex Elder
2013-04-08 19:59   ` Josh Durgin
2013-04-05 14:06 ` Alex Elder [this message]
2013-04-08 20:03   ` [PATCH 19/20] libceph: set the data pointers when encoding ops Josh Durgin
2013-04-05 14:06 ` [PATCH 20/20] libceph: kill off osd request r_data_in and r_data_out Alex Elder
2013-04-08 20:07   ` Josh Durgin

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=515EDA4C.4090305@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.