From 60a0289d740884d85838a9a37b9b1f284f17d987 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sat, 18 Apr 2015 21:05:19 +0200 Subject: [PATCH] iscsi-test-cu: set up vectored transfer length properly I didn't set up the transfer length properly for the vectored SG_IO support in the previous patch, which makes some implementations of the ioctl unhappy. Fix this up per the spec. --- test-tool/iscsi-support.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/test-tool/iscsi-support.c b/test-tool/iscsi-support.c index c4aaa44..54f788a 100644 --- a/test-tool/iscsi-support.c +++ b/test-tool/iscsi-support.c @@ -212,6 +212,16 @@ static int check_result(const char *opcode, struct scsi_device *sdev, return 0; } +static size_t iov_tot_len(struct scsi_iovec *iov, int niov) +{ + size_t len = 0; + int i; + + for (i = 0; i < niov; i++) + len += iov[i].iov_len; + return len; +} + static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi_task *task, struct iscsi_data *d) { if (sdev->iscsi_url) { @@ -266,8 +276,10 @@ static struct scsi_task *send_scsi_command(struct scsi_device *sdev, struct scsi switch (task->xfer_dir) { case SCSI_XFER_WRITE: io_hdr.dxfer_direction = SG_DXFER_TO_DEV; + io_hdr.iovec_count = task->iovector_out.niov; io_hdr.dxferp = task->iovector_out.iov; - io_hdr.dxfer_len = task->iovector_out.niov; + io_hdr.dxfer_len = iov_tot_len(task->iovector_out.iov, + task->iovector_out.niov); break; case SCSI_XFER_READ: io_hdr.dxfer_direction = SG_DXFER_FROM_DEV;