scsi: Use data block size not including metadata instead of block size

SPDK iSCSI and SCSI target don't expose any metadata and DIF settings
to the corresponding iSCSI and SCSI initiator.

Even when SPDK iSCSI and SCSI target allocate any bdev formatted
with DIF,  SCSI commands sent from iSCSI and SCSI initiator don't
have any metadata and DIF information.

For that case, iSCSI target inserts and strips DIF on behalf of
iSCSI and SCSI initiator.

Hence SPDK SCSI target has to use data block size not including
metadata to process SCSI commands correctly.

This patch replaces spdk_bdev_get_block_size by
spdk_bdev_get_data_block_size in necessary places.

Change-Id: I264c8e532d1d1b016f6d8774c8ec03389528044f
Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/445083
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2019-03-01 16:01:56 +09:00 committed by Changpeng Liu
parent fb16799191
commit adc8da4aac
2 changed files with 8 additions and 5 deletions

View File

@ -541,7 +541,7 @@ spdk_bdev_scsi_inquiry(struct spdk_bdev *bdev, struct spdk_scsi_task *task,
}
case SPDK_SPC_VPD_BLOCK_LIMITS: {
uint32_t block_size = spdk_bdev_get_block_size(bdev);
uint32_t block_size = spdk_bdev_get_data_block_size(bdev);
/* PAGE LENGTH */
memset(&data[4], 0, 60);
@ -1103,7 +1103,7 @@ spdk_bdev_scsi_mode_sense(struct spdk_bdev *bdev, int md,
int page, int subpage, uint8_t *data, struct spdk_scsi_task *task)
{
uint64_t num_blocks = spdk_bdev_get_num_blocks(bdev);
uint32_t block_size = spdk_bdev_get_block_size(bdev);
uint32_t block_size = spdk_bdev_get_data_block_size(bdev);
uint8_t *hdr, *bdesc, *pages;
int hlen;
int blen;
@ -1417,7 +1417,7 @@ spdk_bdev_scsi_readwrite(struct spdk_scsi_task *task,
return SPDK_SCSI_TASK_COMPLETE;
}
block_size = spdk_bdev_get_block_size(bdev);
block_size = spdk_bdev_get_data_block_size(bdev);
/* Transfer Length is limited to the Block Limits VPD page Maximum Transfer Length */
max_xfer_len = SPDK_WORK_BLOCK_SIZE / block_size;
@ -1708,7 +1708,7 @@ spdk_bdev_scsi_process_block(struct spdk_scsi_task *task)
} else {
to_be32(buffer, num_blocks - 1);
}
to_be32(&buffer[4], spdk_bdev_get_block_size(bdev));
to_be32(&buffer[4], spdk_bdev_get_data_block_size(bdev));
len = spdk_min(task->length, sizeof(buffer));
if (spdk_scsi_task_scatter_data(task, buffer, len) < 0) {
@ -1726,7 +1726,7 @@ spdk_bdev_scsi_process_block(struct spdk_scsi_task *task)
uint8_t buffer[32] = {0};
to_be64(&buffer[0], spdk_bdev_get_num_blocks(bdev) - 1);
to_be32(&buffer[8], spdk_bdev_get_block_size(bdev));
to_be32(&buffer[8], spdk_bdev_get_data_block_size(bdev));
/*
* Set the TPE bit to 1 to indicate thin provisioning.
* The position of TPE bit is the 7th bit in 14th byte

View File

@ -72,6 +72,9 @@ DEFINE_STUB(spdk_bdev_get_name, const char *,
DEFINE_STUB(spdk_bdev_get_block_size, uint32_t,
(const struct spdk_bdev *bdev), 512);
DEFINE_STUB(spdk_bdev_get_data_block_size, uint32_t,
(const struct spdk_bdev *bdev), 512);
uint64_t
spdk_bdev_get_num_blocks(const struct spdk_bdev *bdev)
{