On Mon, Nov 19, 2012 at 7:18 AM, Paolo Bonzini <pbonz...@redhat.com> wrote: > Il 19/11/2012 15:58, Peter Lieven ha scritto: >> >> - /* 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 = 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(size); >> + qemu_iovec_to_buf(acb->qiov, 0, acb->buf, size); >> + data.data = acb->buf; >> + } > > Looks good, but how hard is it to get rid of the bounce buffer > completely, as mentioned in the comment? Ronnie? >
I am working on that, but I will need the thanksgiving weekend to finish it and test it. It also means breaking the API, since it would introduce new functionality so it will take a little while after finishing the libiscsi part before we could/should introduce it in qemu. The vast majority of writes seems to be a vector with only a single element, so Peters change is a good optimization for the common case, until I get the proper fix finished and tested and pushed in a new release of libiscsi. I.e. I think Peters change is good for now. It solves the problem with "extra memcpy" for the majority of writes until we can get the full solution ready. > Paolo