[prev in list] [next in list] [prev in thread] [next in thread]
List: ceph-devel
Subject: Re: [PATCH 17/18] target: add rbd backend
From: Mike Christie <mchristi () redhat ! com>
Date: 2015-07-29 17:07:16
Message-ID: 55B90844.4050007 () redhat ! com
[Download RAW message or body]
On 07/29/2015 09:27 AM, Bart Van Assche wrote:
> 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. That code was copy and pasted and slightly modified from iblock.
I will code up your suggestion in the next posting.
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic