scsi: Use spdk_bdev_writev_blocks instead of spdk_bdev_writev
This is in a effort to consolidate SCSI read and write I/O for the upcoming transparent DIF support. Previously conversion of bytes and blocks are done both in SCSI layer and BDEV layer. After the patch series, conversion is consolidated into SCSI layer. Change-Id: Ib964a41ec22757f2a09cea22f398903f78d0781f Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-on: https://review.gerrithub.io/c/444779 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com>
This commit is contained in:
parent
56e12b0071
commit
07e9a00b60
@ -1386,29 +1386,36 @@ spdk_bdev_scsi_write(struct spdk_bdev *bdev, struct spdk_bdev_desc *bdev_desc,
|
||||
struct spdk_io_channel *bdev_ch, struct spdk_scsi_task *task,
|
||||
uint64_t lba)
|
||||
{
|
||||
uint64_t blen;
|
||||
uint64_t offset;
|
||||
uint64_t offset_blocks, num_blocks;
|
||||
int rc;
|
||||
|
||||
blen = spdk_bdev_get_block_size(bdev);
|
||||
offset = lba * blen;
|
||||
if (_bytes_to_blocks(spdk_bdev_get_block_size(bdev), task->offset, &offset_blocks,
|
||||
task->length, &num_blocks) != 0) {
|
||||
SPDK_ERRLOG("task's offset %" PRIu64 " or length %" PRIu32 " is not block multiple\n",
|
||||
task->offset, task->length);
|
||||
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
|
||||
SPDK_SCSI_SENSE_NO_SENSE,
|
||||
SPDK_SCSI_ASC_NO_ADDITIONAL_SENSE,
|
||||
SPDK_SCSI_ASCQ_CAUSE_NOT_REPORTABLE);
|
||||
return SPDK_SCSI_TASK_COMPLETE;
|
||||
}
|
||||
|
||||
offset_blocks += lba;
|
||||
|
||||
SPDK_DEBUGLOG(SPDK_LOG_SCSI,
|
||||
"Write: lba=%"PRIu64", len=%lu\n",
|
||||
lba, task->length / blen);
|
||||
"Write: lba=%"PRIu64", len=%"PRIu64"\n",
|
||||
offset_blocks, num_blocks);
|
||||
|
||||
offset += task->offset;
|
||||
rc = spdk_bdev_writev(bdev_desc, bdev_ch, task->iovs,
|
||||
task->iovcnt, offset, task->length,
|
||||
spdk_bdev_scsi_task_complete_cmd,
|
||||
task);
|
||||
rc = spdk_bdev_writev_blocks(bdev_desc, bdev_ch, task->iovs, task->iovcnt,
|
||||
offset_blocks, num_blocks,
|
||||
spdk_bdev_scsi_task_complete_cmd, task);
|
||||
|
||||
if (rc) {
|
||||
if (rc == -ENOMEM) {
|
||||
spdk_bdev_scsi_queue_io(task, spdk_bdev_scsi_process_block_resubmit, task);
|
||||
return SPDK_SCSI_TASK_PENDING;
|
||||
}
|
||||
SPDK_ERRLOG("spdk_bdev_writev failed\n");
|
||||
SPDK_ERRLOG("spdk_bdev_writev_blocks() failed\n");
|
||||
spdk_scsi_task_set_status(task, SPDK_SCSI_STATUS_CHECK_CONDITION,
|
||||
SPDK_SCSI_SENSE_NO_SENSE,
|
||||
SPDK_SCSI_ASC_NO_ADDITIONAL_SENSE,
|
||||
|
@ -203,10 +203,10 @@ spdk_bdev_readv_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
|
||||
}
|
||||
|
||||
int
|
||||
spdk_bdev_writev(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
|
||||
struct iovec *iov, int iovcnt,
|
||||
uint64_t offset, uint64_t len,
|
||||
spdk_bdev_io_completion_cb cb, void *cb_arg)
|
||||
spdk_bdev_writev_blocks(struct spdk_bdev_desc *desc, struct spdk_io_channel *ch,
|
||||
struct iovec *iov, int iovcnt,
|
||||
uint64_t offset_blocks, uint64_t num_blocks,
|
||||
spdk_bdev_io_completion_cb cb, void *cb_arg)
|
||||
{
|
||||
return _spdk_bdev_io_op(cb, cb_arg);
|
||||
}
|
||||
@ -860,6 +860,8 @@ _xfer_test(bool bdev_io_pool_full)
|
||||
to_be64(&cdb[2], 0); /* LBA */
|
||||
to_be32(&cdb[10], 1); /* transfer length */
|
||||
task.transfer_len = 1 * 512;
|
||||
task.offset = 0;
|
||||
task.length = 1 * 512;
|
||||
g_bdev_io_pool_full = bdev_io_pool_full;
|
||||
rc = spdk_bdev_scsi_execute(&task);
|
||||
CU_ASSERT(rc == SPDK_SCSI_TASK_PENDING);
|
||||
|
Loading…
x
Reference in New Issue
Block a user