TESTS: Setup and use iovectors for ALL data transfers in send_scsi_command

We need to use iovectors for iSER to work as it requires that the vectors
are attached to the task before we queue the task.

Signed-off-by: Ronnie Sahlberg <ronniesahlberg@gmail.com>
This commit is contained in:
Ronnie Sahlberg
2016-11-15 18:07:23 -08:00
parent 5228631a60
commit 8c9519b145
+23 -14
View File
@@ -276,6 +276,28 @@ static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi
{ {
static time_t last_time = 0; static time_t last_time = 0;
/* We got an actual buffer from the application. Convert it to
* a data-out iovector.
* We need to attach the iovector to the task before calling
* iscsi_scsi_command_sync() as iSER needs all iovectors to be setup
* before we queue the task.
*/
if (d != NULL && d->data != NULL) {
struct scsi_iovec *iov;
iov = scsi_malloc(task, sizeof(struct scsi_iovec));
iov->iov_base = d->data;
iov->iov_len = d->size;
switch (task->xfer_dir) {
case SCSI_XFER_WRITE:
scsi_task_set_iov_out(task, iov, 1);
break;
case SCSI_XFER_READ:
scsi_task_set_iov_in(task, iov, 1);
break;
}
}
if (sdev->iscsi_url) { if (sdev->iscsi_url) {
time_t current_time = time(NULL); time_t current_time = time(NULL);
@@ -283,7 +305,7 @@ static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi
free(discard_const(sdev->error_str)); free(discard_const(sdev->error_str));
sdev->error_str = NULL; sdev->error_str = NULL;
} }
task = iscsi_scsi_command_sync(sdev->iscsi_ctx, sdev->iscsi_lun, task, d); task = iscsi_scsi_command_sync(sdev->iscsi_ctx, sdev->iscsi_lun, task, NULL);
if (task == NULL) { if (task == NULL) {
sdev->error_str = strdup(iscsi_get_error(sdev->iscsi_ctx)); sdev->error_str = strdup(iscsi_get_error(sdev->iscsi_ctx));
} }
@@ -307,19 +329,6 @@ static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi
return task; return task;
} }
/* We got an actual buffer from the application. Convert it to
* a data-out iovector.
*/
if (d != NULL && d->data != NULL) {
struct scsi_iovec *iov;
iov = scsi_malloc(task, sizeof(struct scsi_iovec));
iov->iov_base = d->data;
iov->iov_len = d->size;
scsi_task_set_iov_out(task, iov, 1);
}
#ifdef HAVE_SG_IO #ifdef HAVE_SG_IO
if (sdev->sgio_dev) { if (sdev->sgio_dev) {
sg_io_hdr_t io_hdr; sg_io_hdr_t io_hdr;