aboutsummaryrefslogtreecommitdiff
path: root/block/iscsi.c
diff options
context:
space:
mode:
authorPeter Lieven <pl@dlhnet.de>2012-11-19 15:58:31 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2013-01-22 15:07:03 +0100
commit4cc841b57c1dc91d71bafc25b53ffab4eff7959b (patch)
treeb70c91057c520fce8aba483f7b794706ff37a96b /block/iscsi.c
parentde8864e5ae645fc22aa4ecf1999705c2dd5cf93c (diff)
downloadqemu-4cc841b57c1dc91d71bafc25b53ffab4eff7959b.zip
qemu-4cc841b57c1dc91d71bafc25b53ffab4eff7959b.tar.gz
qemu-4cc841b57c1dc91d71bafc25b53ffab4eff7959b.tar.bz2
iscsi: partly avoid iovec linearization in iscsi_aio_writev
libiscsi expects all write16 data in a linear buffer. If the iovec only contains one buffer we can skip the linearization step as well as the additional malloc/free and pass the buffer directly. Reported-by: Ronnie Sahlberg <ronniesahlberg@gmail.com> Signed-off-by: Peter Lieven <pl@kamp.de> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'block/iscsi.c')
-rw-r--r--block/iscsi.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/block/iscsi.c b/block/iscsi.c
index d8382fd..259192f 100644
--- a/block/iscsi.c
+++ b/block/iscsi.c
@@ -241,8 +241,17 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
/* XXX we should pass the iovec to write16 to avoid the extra copy */
/* this will allow us to get rid of 'buf' completely */
size = nb_sectors * BDRV_SECTOR_SIZE;
- acb->buf = g_malloc(size);
- qemu_iovec_to_buf(acb->qiov, 0, acb->buf, size);
+ data.size = MIN(size, acb->qiov->size);
+
+ /* if the iovec only contains one buffer we can pass it directly */
+ if (acb->qiov->niov == 1) {
+ acb->buf = NULL;
+ data.data = acb->qiov->iov[0].iov_base;
+ } else {
+ acb->buf = g_malloc(data.size);
+ qemu_iovec_to_buf(acb->qiov, 0, acb->buf, data.size);
+ data.data = acb->buf;
+ }
acb->task = malloc(sizeof(struct scsi_task));
if (acb->task == NULL) {
@@ -263,9 +272,6 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num,
*(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors);
acb->task->expxferlen = size;
- data.data = acb->buf;
- data.size = size;
-
if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task,
iscsi_aio_write16_cb,
&data,