scsi_bdev: simplify scsi_readwrite helper function
Factor out the common data direction Check Condition logic from read and write. Change-Id: Ia2fbd5f69eefd826ebb5ab2a8e99aeb380f1b7ea Signed-off-by: Daniel Verkamp <daniel.verkamp@intel.com>
This commit is contained in:
parent
8e379851ab
commit
7455910d1b
@ -1457,30 +1457,20 @@ spdk_bdev_scsi_readwrite(struct spdk_bdev *bdev,
|
||||
struct spdk_scsi_task *task,
|
||||
uint64_t lba, uint32_t xfer_len, bool is_read)
|
||||
{
|
||||
if (task->dxfer_dir != SPDK_SCSI_DIR_NONE &&
|
||||
task->dxfer_dir != (is_read ? SPDK_SCSI_DIR_FROM_DEV : SPDK_SCSI_DIR_TO_DEV)) {
|
||||
SPDK_ERRLOG("Incorrect data direction\n");
|
||||
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;
|
||||
}
|
||||
|
||||
if (is_read) {
|
||||
if ((task->dxfer_dir == SPDK_SCSI_DIR_FROM_DEV) ||
|
||||
(task->dxfer_dir == SPDK_SCSI_DIR_NONE)) {
|
||||
return spdk_bdev_scsi_read(bdev, task, lba, xfer_len);
|
||||
} else {
|
||||
SPDK_ERRLOG("Incorrect data direction\n");
|
||||
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;
|
||||
}
|
||||
return spdk_bdev_scsi_read(bdev, task, lba, xfer_len);
|
||||
} else {
|
||||
if ((task->dxfer_dir == SPDK_SCSI_DIR_TO_DEV) ||
|
||||
(task->dxfer_dir == SPDK_SCSI_DIR_NONE)) {
|
||||
return spdk_bdev_scsi_write(bdev, task, lba, xfer_len);
|
||||
} else {
|
||||
SPDK_ERRLOG("Incorrect data direction\n");
|
||||
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;
|
||||
}
|
||||
return spdk_bdev_scsi_write(bdev, task, lba, xfer_len);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user