From: Bart Van Assche <bart.vanassche@sandisk.com>
To: mchristi@redhat.com, ceph-devel@vger.kernel.org,
target-devel@vger.kernel.org
Subject: Re: [PATCH 17/18] target: add rbd backend
Date: Wed, 29 Jul 2015 07:27:35 -0700 [thread overview]
Message-ID: <55B8E2D7.2040605@sandisk.com> (raw)
In-Reply-To: <1438161835-27960-17-git-send-email-mchristi@redhat.com>
On 07/29/15 02:23, mchristi@redhat.com wrote:
> +static sector_t tcm_rbd_get_blocks(struct se_device *dev)
> +{
> + struct tcm_rbd_dev *tcm_rbd_dev = TCM_RBD_DEV(dev);
> + sector_t blocks_long = tcm_rbd_dev->rbd_dev->mapping.size >>
> + SECTOR_SHIFT;
> +
> + if (SECTOR_SIZE == dev->dev_attrib.block_size)
> + return blocks_long;
> +
> + switch (SECTOR_SIZE) {
> + case 4096:
> + switch (dev->dev_attrib.block_size) {
> + case 2048:
> + blocks_long <<= 1;
> + break;
> + case 1024:
> + blocks_long <<= 2;
> + break;
> + case 512:
> + blocks_long <<= 3;
> + default:
> + break;
> + }
> + break;
> + case 2048:
> + switch (dev->dev_attrib.block_size) {
> + case 4096:
> + blocks_long >>= 1;
> + break;
> + case 1024:
> + blocks_long <<= 1;
> + break;
> + case 512:
> + blocks_long <<= 2;
> + break;
> + default:
> + break;
> + }
> + break;
> + case 1024:
> + switch (dev->dev_attrib.block_size) {
> + case 4096:
> + blocks_long >>= 2;
> + break;
> + case 2048:
> + blocks_long >>= 1;
> + break;
> + case 512:
> + blocks_long <<= 1;
> + break;
> + default:
> + break;
> + }
> + break;
> + case 512:
> + switch (dev->dev_attrib.block_size) {
> + case 4096:
> + blocks_long >>= 3;
> + break;
> + case 2048:
> + blocks_long >>= 2;
> + break;
> + case 1024:
> + blocks_long >>= 1;
> + break;
> + default:
> + break;
> + }
> + break;
> + default:
> + break;
> + }
> +
> + return blocks_long;
> +}
Hello Mike,
Had you already considered to replace the above switch / case statement
by something like the following ?
static sector_t tcm_rbd_get_blocks(struct se_device *dev)
{
return TCM_RBD_DEV(dev)->rbd_dev->mapping.size >>
ilog2(dev->dev_attrib.block_size);
}
Thanks,
Bart.
next prev parent reply other threads:[~2015-07-29 14:27 UTC|newest]
Thread overview: 33+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-29 9:23 [PATCH 01/18] libceph: add scatterlist messenger data type mchristi
2015-07-29 9:23 ` [PATCH 02/18] rbd: add support for scatterlist obj_request_type mchristi
2015-07-29 9:23 ` [PATCH 03/18] rbd: add lio specific data area mchristi
2015-07-29 9:23 ` [PATCH 04/18] libceph: support bidirectional requests mchristi
2015-11-21 23:32 ` Goldwyn Rodrigues
2015-07-29 9:23 ` [PATCH 05/18] libceph: add support for CMPEXT compare extent requests mchristi
2015-07-29 9:23 ` [PATCH 06/18] rbd: add write test helper mchristi
2015-07-29 9:23 ` [PATCH 07/18] rbd: add num ops calculator helper mchristi
2015-07-29 9:23 ` [PATCH 08/18] rbd: add support for COMPARE_AND_WRITE/CMPEXT mchristi
2015-07-29 9:23 ` [PATCH 09/18] libceph: add support for write same requests mchristi
2015-07-29 9:23 ` [PATCH 10/18] rbd: add support for writesame requests mchristi
2015-07-29 9:23 ` [PATCH 11/18] target: add compare and write callback mchristi
2015-07-29 9:23 ` [PATCH 12/18] target: compare and write backend driver sense handling mchristi
2015-09-04 19:41 ` Mike Christie
2015-09-04 22:34 ` Andy Grover
2015-09-06 6:38 ` Sagi Grimberg
2015-09-06 7:12 ` Christoph Hellwig
2015-07-29 9:23 ` [PATCH 13/18] target: add COMPARE_AND_WRITE sg creation helper mchristi
2015-07-29 9:23 ` [PATCH 14/18] libceph: fix pr_fmt compile issues mchristi
2015-07-29 9:23 ` [PATCH 15/18] rbd: export some functions used by lio rbd backend mchristi
2015-07-29 9:23 ` [PATCH 16/18] rbd: move structs used by lio rbd to new header mchristi
2015-07-29 9:23 ` [PATCH 17/18] target: add rbd backend mchristi
2015-07-29 14:27 ` Bart Van Assche [this message]
2015-07-29 17:07 ` Mike Christie
2015-07-29 9:23 ` [PATCH 18/18] target: add lio rbd to makefile/Kconfig mchristi
2015-07-29 13:34 ` [PATCH 01/18] libceph: add scatterlist messenger data type Alex Elder
2015-07-29 17:49 ` Mike Christie
2015-07-29 17:55 ` Christoph Hellwig
2015-07-29 22:59 ` Mike Christie
2015-07-29 23:40 ` Mike Christie
2015-07-30 7:34 ` Nicholas A. Bellinger
2015-07-30 14:55 ` Christoph Hellwig
2016-02-04 10:33 ` David Disseldorp
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=55B8E2D7.2040605@sandisk.com \
--to=bart.vanassche@sandisk.com \
--cc=ceph-devel@vger.kernel.org \
--cc=mchristi@redhat.com \
--cc=target-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