On 07/29/2015 09:27 AM, Bart Van Assche wrote: > On 07/29/15 02:23, mchristi@xxxxxxxxxx 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 target-devel" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html