All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ilya Dryomov <idryomov@gmail.com>
To: ceph-devel@vger.kernel.org
Cc: Alex Elder <elder@ieee.org>
Subject: [PATCH 11/15] rbd: set offset and length outside of rbd_obj_request_create()
Date: Tue, 14 Feb 2017 21:12:00 +0100	[thread overview]
Message-ID: <1487103124-2974-12-git-send-email-idryomov@gmail.com> (raw)
In-Reply-To: <1487103124-2974-1-git-send-email-idryomov@gmail.com>

The allocation doesn't depend on offset and length.  Both offset and
length can be changed after obj_request is allocated, too.

Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
---
 drivers/block/rbd.c | 26 +++++++++++---------------
 1 file changed, 11 insertions(+), 15 deletions(-)

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index f01dfdfa5645..ea60d238ca55 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1631,7 +1631,9 @@ static void rbd_obj_request_submit(struct rbd_obj_request *obj_request)
 {
 	struct ceph_osd_request *osd_req = obj_request->osd_req;
 
-	dout("%s %p osd_req %p\n", __func__, obj_request, osd_req);
+	dout("%s %p \"%s\" %llu~%llu osd_req %p\n", __func__,
+	     obj_request, obj_request->object_name, obj_request->offset,
+	     obj_request->length, osd_req);
 	if (obj_request_img_data_test(obj_request)) {
 		WARN_ON(obj_request->callback != rbd_img_obj_callback);
 		rbd_img_request_get(obj_request->img_request);
@@ -2073,7 +2075,6 @@ static void rbd_osd_req_destroy(struct ceph_osd_request *osd_req)
 /* object_name is assumed to be a non-null pointer and NUL-terminated */
 
 static struct rbd_obj_request *rbd_obj_request_create(const char *object_name,
-						u64 offset, u64 length,
 						enum obj_request_type type)
 {
 	struct rbd_obj_request *obj_request;
@@ -2094,18 +2095,13 @@ static struct rbd_obj_request *rbd_obj_request_create(const char *object_name,
 	}
 
 	obj_request->object_name = memcpy(name, object_name, size);
-	obj_request->offset = offset;
-	obj_request->length = length;
-	obj_request->flags = 0;
 	obj_request->which = BAD_WHICH;
 	obj_request->type = type;
 	INIT_LIST_HEAD(&obj_request->links);
 	init_completion(&obj_request->completion);
 	kref_init(&obj_request->kref);
 
-	dout("%s: \"%s\" %llu/%llu %d -> obj %p\n", __func__, object_name,
-		offset, length, (int)type, obj_request);
-
+	dout("%s %p\n", __func__, obj_request);
 	return obj_request;
 }
 
@@ -2517,21 +2513,21 @@ static int rbd_img_request_fill(struct rbd_img_request *img_request,
 	while (resid) {
 		struct ceph_osd_request *osd_req;
 		const char *object_name;
-		u64 offset;
-		u64 length;
+		u64 offset = rbd_segment_offset(rbd_dev, img_offset);
+		u64 length = rbd_segment_length(rbd_dev, img_offset, resid);
 
 		object_name = rbd_segment_name(rbd_dev, img_offset);
 		if (!object_name)
 			goto out_unwind;
-		offset = rbd_segment_offset(rbd_dev, img_offset);
-		length = rbd_segment_length(rbd_dev, img_offset, resid);
-		obj_request = rbd_obj_request_create(object_name,
-						offset, length, type);
+		obj_request = rbd_obj_request_create(object_name, type);
 		/* object request has its own copy of the object name */
 		rbd_segment_name_free(object_name);
 		if (!obj_request)
 			goto out_unwind;
 
+		obj_request->offset = offset;
+		obj_request->length = length;
+
 		/*
 		 * set obj_request->img_request before creating the
 		 * osd_request so that it gets the right snapc
@@ -2870,7 +2866,7 @@ static int rbd_img_obj_exists_submit(struct rbd_obj_request *obj_request)
 	size_t size;
 	int ret;
 
-	stat_request = rbd_obj_request_create(obj_request->object_name, 0, 0,
+	stat_request = rbd_obj_request_create(obj_request->object_name,
 					      OBJ_REQUEST_PAGES);
 	if (!stat_request)
 		return -ENOMEM;
-- 
2.4.3


  parent reply	other threads:[~2017-02-14 20:12 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-02-14 20:11 [PATCH 00/15] rbd: support for data-pool + obj_request->object_no Ilya Dryomov
2017-02-14 20:11 ` [PATCH 01/15] rbd: use kstrndup() in rbd_header_from_disk() Ilya Dryomov
2017-02-15 15:52   ` Alex Elder
2017-02-15 15:52   ` Alex Elder
2017-02-14 20:11 ` [PATCH 02/15] rbd: kill rbd_image_header::{crypt_type,comp_type} Ilya Dryomov
2017-02-14 20:11 ` [PATCH 03/15] rbd: initialize rbd_dev->header_oloc early Ilya Dryomov
2017-02-14 20:11 ` [PATCH 04/15] rbd: do away with obj_request in rbd_obj_read_sync() Ilya Dryomov
2017-02-14 20:11 ` [PATCH 05/15] libceph: pass reply buffer length through ceph_osdc_call() Ilya Dryomov
2017-02-14 20:11 ` [PATCH 06/15] rbd: switch rbd_obj_method_sync() to ceph_osdc_call() Ilya Dryomov
2017-02-14 20:11 ` [PATCH 07/15] rbd: remove now unused rbd_obj_request_wait() and helpers Ilya Dryomov
2017-02-14 20:11 ` [PATCH 08/15] rbd: use rbd_obj_bytes() more Ilya Dryomov
2017-02-14 20:11 ` [PATCH 09/15] rbd: introduce rbd_init_layout() Ilya Dryomov
2017-02-14 20:11 ` [PATCH 10/15] rbd: support for data-pool feature Ilya Dryomov
2017-02-14 20:12 ` Ilya Dryomov [this message]
2017-02-14 20:12 ` [PATCH 12/15] rbd: factor out __rbd_osd_req_create() Ilya Dryomov
2017-02-14 20:12 ` [PATCH 13/15] rbd: RBD_V{1,2}_DATA_FORMAT macros Ilya Dryomov
2017-02-15 14:47   ` Jason Dillaman
2017-02-14 20:12 ` [PATCH 14/15] rbd: store and use obj_request->object_no Ilya Dryomov
2017-02-14 20:12 ` [PATCH 15/15] rbd: kill obj_request->object_name and rbd_segment_name_cache Ilya Dryomov
2017-02-15 14:53 ` [PATCH 00/15] rbd: support for data-pool + obj_request->object_no Jason Dillaman

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=1487103124-2974-12-git-send-email-idryomov@gmail.com \
    --to=idryomov@gmail.com \
    --cc=ceph-devel@vger.kernel.org \
    --cc=elder@ieee.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.