CEPH filesystem development
 help / color / mirror / Atom feed
From: Alex Elder <elder@inktank.com>
To: "ceph-devel@vger.kernel.org" <ceph-devel@vger.kernel.org>
Subject: [PATCH 3/6] rbd: initialize off and len in rbd_create_rw_op()
Date: Tue, 20 Nov 2012 13:57:22 -0600	[thread overview]
Message-ID: <50ABE0A2.8080205@inktank.com> (raw)
In-Reply-To: <50ABDF8A.4080206@inktank.com>

Move the initialization of a read or write operation's offset,
length, and payload length fields into rbd_create_rw_op().

This will actually get removed in the next patch, but it finishes
the consolidation of setting these fields at osd op creation time.

Signed-off-by: Alex Elder <elder@inktank.com>
---
 drivers/block/rbd.c |   36 ++++++++++++++++--------------------
 1 file changed, 16 insertions(+), 20 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index b2e819c..54d11c9 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1025,19 +1025,23 @@ out_err:
 	return NULL;
 }

-static struct ceph_osd_req_op *rbd_create_rw_op(int opcode, u32
payload_len)
+static struct ceph_osd_req_op *rbd_create_rw_op(int opcode, u64 ofs,
u64 len)
 {
 	struct ceph_osd_req_op *op;

 	op = kzalloc(sizeof (*op), GFP_NOIO);
 	if (!op)
 		return NULL;
-	/*
-	 * op extent offset and length will be set later on
-	 * after ceph_calc_file_object_mapping().
-	 */
+
 	op->op = opcode;
-	op->payload_len = payload_len;
+	if (opcode == CEPH_OSD_OP_READ || opcode == CEPH_OSD_OP_WRITE) {
+		op->extent.offset = ofs;
+		op->extent.length = len;
+		if (opcode == CEPH_OSD_OP_WRITE) {
+			rbd_assert(len <= (u64) U32_MAX);
+			op->payload_len = len;
+		}
+	}

 	return op;
 }
@@ -1297,7 +1301,6 @@ static int rbd_do_op(struct request *rq,
 	u64 seg_len;
 	int ret;
 	struct ceph_osd_req_op *op;
-	u32 payload_len;
 	int opcode;
 	int flags;
 	u64 snapid;
@@ -1312,22 +1315,17 @@ static int rbd_do_op(struct request *rq,
 		opcode = CEPH_OSD_OP_WRITE;
 		flags = CEPH_OSD_FLAG_WRITE|CEPH_OSD_FLAG_ONDISK;
 		snapid = CEPH_NOSNAP;
-		payload_len = seg_len;
 	} else {
 		opcode = CEPH_OSD_OP_READ;
 		flags = CEPH_OSD_FLAG_READ;
 		rbd_assert(!snapc);
 		snapid = rbd_dev->spec->snap_id;
-		payload_len = 0;
 	}

 	ret = -ENOMEM;
-	op = rbd_create_rw_op(opcode, payload_len);
+	op = rbd_create_rw_op(opcode, seg_ofs, seg_len);
 	if (!op)
 		goto done;
-	op->extent.offset = seg_ofs;
-	op->extent.length = seg_len;
-	op->payload_len = payload_len;

 	/* we've taken care of segment sizes earlier when we
 	   cloned the bios. We should never have a segment
@@ -1363,12 +1361,9 @@ static int rbd_req_sync_read(struct rbd_device
*rbd_dev,
 	struct ceph_osd_req_op *op;
 	int ret;

-	op = rbd_create_rw_op(CEPH_OSD_OP_READ, 0);
+	op = rbd_create_rw_op(CEPH_OSD_OP_READ, ofs, len);
 	if (!op)
 		return -ENOMEM;
-	op->extent.offset = ofs;
-	op->extent.length = len;
-	op->payload_len = 0;

 	ret = rbd_req_sync_op(rbd_dev, CEPH_OSD_FLAG_READ,
 			       op, object_name, ofs, len, buf, NULL, ver);
@@ -1387,7 +1382,7 @@ static int rbd_req_sync_notify_ack(struct
rbd_device *rbd_dev,
 	struct ceph_osd_req_op *op;
 	int ret;

-	op = rbd_create_rw_op(CEPH_OSD_OP_NOTIFY_ACK, 0);
+	op = rbd_create_rw_op(CEPH_OSD_OP_NOTIFY_ACK, 0, 0);
 	if (!op)
 		return -ENOMEM;

@@ -1438,7 +1433,7 @@ static int rbd_req_sync_watch(struct rbd_device
*rbd_dev, int start)
 	__le64 version = 0;
 	int ret;

-	op = rbd_create_rw_op(CEPH_OSD_OP_WATCH, 0);
+	op = rbd_create_rw_op(CEPH_OSD_OP_WATCH, 0, 0);
 	if (!op)
 		return -ENOMEM;

@@ -1501,9 +1496,10 @@ static int rbd_req_sync_exec(struct rbd_device
*rbd_dev,
 	 * operation.
 	 */
 	payload_size = class_name_len + method_name_len + outbound_size;
-	op = rbd_create_rw_op(CEPH_OSD_OP_CALL, payload_size);
+	op = rbd_create_rw_op(CEPH_OSD_OP_CALL, 0, 0);
 	if (!op)
 		return -ENOMEM;
+	op->payload_len = payload_size;

 	op->cls.class_name = class_name;
 	op->cls.class_len = (__u8) class_name_len;
-- 
1.7.9.5


  parent reply	other threads:[~2012-11-20 19:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-11-20 19:52 [PATCH 0/6] rbd: consolidate request operation creation Alex Elder
2012-11-20 19:54 ` [PATCH 1/6] rbd: don't assign extent info in rbd_do_request() Alex Elder
2012-11-20 19:56 ` [PATCH 2/6] rbd: don't assign extent info in rbd_req_sync_op() Alex Elder
2012-11-20 19:57 ` Alex Elder [this message]
2012-11-20 19:58 ` [PATCH 4/6] rbd: define generalized osd request op routines Alex Elder
2012-11-20 19:58 ` [PATCH 5/6] rbd: move call osd op setup into rbd_osd_req_op_create() Alex Elder
2012-11-20 19:59 ` [PATCH 6/6] rbd: move remaining " Alex Elder

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=50ABE0A2.8080205@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox