From patchwork Tue Feb 14 20:11:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ilya Dryomov X-Patchwork-Id: 9572777 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5E37E60578 for ; Tue, 14 Feb 2017 20:12:51 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5B06C271BC for ; Tue, 14 Feb 2017 20:12:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4FF272840E; Tue, 14 Feb 2017 20:12:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.3 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E96EA271BC for ; Tue, 14 Feb 2017 20:12:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754982AbdBNUMs (ORCPT ); Tue, 14 Feb 2017 15:12:48 -0500 Received: from mail-qt0-f193.google.com ([209.85.216.193]:33318 "EHLO mail-qt0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754961AbdBNUMn (ORCPT ); Tue, 14 Feb 2017 15:12:43 -0500 Received: by mail-qt0-f193.google.com with SMTP id n13so18833367qtc.0 for ; Tue, 14 Feb 2017 12:12:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=ExqVKxhkcemAHeVBCUIsLQ17RNrAqTnmmCZEu6FEJWg=; b=oAE7jdRQpsftYrSi2DlQZ8OUKSH9ByxNesQ9nupHxVLgetIZA511TkKf8Wex1MQytk SBmeEp7q/S/P6G/IZg+18G15FnCpSoaEkqcC1iCPDr09I0iowXsfzSVy4qQKH6bXdT8W Yb2gxB7Lc1U2htwQgtmG3zbAbZcZJ13P41shdsyDBrPMx8mkQgGV82N3Qp+UXSu7i0HC +MteNpLDO4+rZPtlVh5RY6WG+m1Y52HYn5zluwDwRA48mrqUIOBnCVb9Jjk3bNEvSfdm Kp782GfZJEb65IqUwHGqG23URdqUy6E5xOTzL76Jp1PgybT2pcr3B91ITN2yTu1BvAUM nO5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=ExqVKxhkcemAHeVBCUIsLQ17RNrAqTnmmCZEu6FEJWg=; b=k+mcxKYMYuMm3HtJ+sWFucGDc5dqKoFhOrRlr8lOzPunRm9VmFW6mvvAnQLHZD/Wdl UcvHrH7atwM+/u+sQWNTnvokXcLOhTpGTmDhw+IXFBmSRc8qoEXdJ24W+kgnPAC0TBW1 k26WlGLtjWatbv4RVQmjS4opZFMFha0fRlR+yxhUT8tlMFrR8R91fM7SaftZ/BJVNrqd eSiQPpJZ+ZQoigmRL4jFnKqHUac/bmWS8UNfq++ak+8xNqhoEHR8PzdgNcFsDdbmv78h 3YcHQaxDzP2A4HkvAxWQXV/pt7KiJHwktVAJlRgQVuFBqdqX1VWAoYJMppYxxVQN1wuQ wahw== X-Gm-Message-State: AMke39kf85C9FFKHY0/W4P1RTJOBqy/9tisUUpxJj1/8tFTUcR+QY2fAYCFs6FBWNYce9A== X-Received: by 10.237.34.125 with SMTP id o58mr28473614qtc.95.1487103161956; Tue, 14 Feb 2017 12:12:41 -0800 (PST) Received: from dhcp-1-235.brq.redhat.com (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id w138sm939945qka.27.2017.02.14.12.12.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 14 Feb 2017 12:12:41 -0800 (PST) From: Ilya Dryomov To: ceph-devel@vger.kernel.org Cc: Alex Elder Subject: [PATCH 08/15] rbd: use rbd_obj_bytes() more Date: Tue, 14 Feb 2017 21:11:57 +0100 Message-Id: <1487103124-2974-9-git-send-email-idryomov@gmail.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1487103124-2974-1-git-send-email-idryomov@gmail.com> References: <1487103124-2974-1-git-send-email-idryomov@gmail.com> Sender: ceph-devel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: ceph-devel@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- 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) {