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 08/15] rbd: use rbd_obj_bytes() more
Date: Tue, 14 Feb 2017 21:11:57 +0100	[thread overview]
Message-ID: <1487103124-2974-9-git-send-email-idryomov@gmail.com> (raw)
In-Reply-To: <1487103124-2974-1-git-send-email-idryomov@gmail.com>

Returning u64 doesn't make sense: max header->obj_order is 25 and
ceph_file_layout::object_size is u32.

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

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 68036c29c07c..f2f52b7db33d 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -971,6 +971,14 @@ static bool rbd_dev_ondisk_valid(struct rbd_image_header_ondisk *ondisk)
 }
 
 /*
+ * returns the size of an object in the image
+ */
+static u32 rbd_obj_bytes(struct rbd_image_header *header)
+{
+	return 1U << header->obj_order;
+}
+
+/*
  * Fill an rbd image header with information from the given format 1
  * on-disk header.
  */
@@ -1255,7 +1263,7 @@ static const char *rbd_segment_name(struct rbd_device *rbd_dev, u64 offset)
 
 static u64 rbd_segment_offset(struct rbd_device *rbd_dev, u64 offset)
 {
-	u64 segment_size = (u64) 1 << rbd_dev->header.obj_order;
+	u64 segment_size = rbd_obj_bytes(&rbd_dev->header);
 
 	return offset & (segment_size - 1);
 }
@@ -1263,7 +1271,7 @@ static u64 rbd_segment_offset(struct rbd_device *rbd_dev, u64 offset)
 static u64 rbd_segment_length(struct rbd_device *rbd_dev,
 				u64 offset, u64 length)
 {
-	u64 segment_size = (u64) 1 << rbd_dev->header.obj_order;
+	u64 segment_size = rbd_obj_bytes(&rbd_dev->header);
 
 	offset &= segment_size - 1;
 
@@ -1275,14 +1283,6 @@ static u64 rbd_segment_length(struct rbd_device *rbd_dev,
 }
 
 /*
- * returns the size of an object in the image
- */
-static u64 rbd_obj_bytes(struct rbd_image_header *header)
-{
-	return 1 << header->obj_order;
-}
-
-/*
  * bio helpers
  */
 
@@ -2721,7 +2721,7 @@ static int rbd_img_obj_parent_read_full(struct rbd_obj_request *obj_request)
 	 * child image to which the original request was to be sent.
 	 */
 	img_offset = obj_request->img_offset - obj_request->offset;
-	length = (u64)1 << rbd_dev->header.obj_order;
+	length = rbd_obj_bytes(&rbd_dev->header);
 
 	/*
 	 * There is no defined parent data beyond the parent
@@ -5130,7 +5130,7 @@ static int rbd_dev_v2_striping_info(struct rbd_device *rbd_dev)
 	 * out, and only fail if the image has non-default values.
 	 */
 	ret = -EINVAL;
-	obj_size = (u64)1 << rbd_dev->header.obj_order;
+	obj_size = rbd_obj_bytes(&rbd_dev->header);
 	p = &striping_info_buf;
 	stripe_unit = ceph_decode_64(&p);
 	if (stripe_unit != obj_size) {
-- 
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 ` Ilya Dryomov [this message]
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 ` [PATCH 11/15] rbd: set offset and length outside of rbd_obj_request_create() Ilya Dryomov
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-9-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.