From patchwork Mon Dec 3 19:35:15 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Lieven X-Patchwork-Id: 203423 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 629E52C0089 for ; Tue, 4 Dec 2012 06:40:43 +1100 (EST) Received: from localhost ([::1]:49689 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Tfbni-0006vQ-Tq for incoming@patchwork.ozlabs.org; Mon, 03 Dec 2012 14:35:34 -0500 Received: from eggs.gnu.org ([208.118.235.92]:51377) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfbnV-0006eA-3I for qemu-devel@nongnu.org; Mon, 03 Dec 2012 14:35:25 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TfbnQ-0002rG-Qi for qemu-devel@nongnu.org; Mon, 03 Dec 2012 14:35:21 -0500 Received: from ssl.dlhnet.de ([91.198.192.8]:33805 helo=ssl.dlh.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TfbnQ-0002r4-GA for qemu-devel@nongnu.org; Mon, 03 Dec 2012 14:35:16 -0500 Received: from localhost (localhost [127.0.0.1]) by ssl.dlh.net (Postfix) with ESMTP id 0509414CE3E; Mon, 3 Dec 2012 20:35:16 +0100 (CET) X-Virus-Scanned: Debian amavisd-new at ssl.dlh.net Received: from ssl.dlh.net ([127.0.0.1]) by localhost (ssl.dlh.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tRgLz6IukkuE; Mon, 3 Dec 2012 20:35:15 +0100 (CET) Received: from [82.141.7.8] (unknown [82.141.7.8]) by ssl.dlh.net (Postfix) with ESMTPSA id 7C65714CA5D; Mon, 3 Dec 2012 20:35:15 +0100 (CET) Message-ID: <50BCFEF3.4070805@dlhnet.de> Date: Mon, 03 Dec 2012 20:35:15 +0100 From: Peter Lieven User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:15.0) Gecko/20120827 Thunderbird/15.0 MIME-Version: 1.0 To: "qemu-devel@nongnu.org" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 91.198.192.8 Cc: Kevin Wolf , Paolo Bonzini , ronnie sahlberg Subject: [Qemu-devel] [PATCH] iscsi: add support for iovectors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org This patch adds support for directly passing the iovec array from QEMUIOVector if libiscsi supports it. Signed-off-by: Peter Lieven --- block/iscsi.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/block/iscsi.c b/block/iscsi.c index c0b70b3..6f3ee4a 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -55,7 +55,9 @@ typedef struct IscsiAIOCB { QEMUBH *bh; IscsiLun *iscsilun; struct scsi_task *task; +#if !defined(LIBISCSI_FEATURE_IOVECTOR) uint8_t *buf; +#endif int status; int canceled; size_t read_size; @@ -192,7 +194,9 @@ iscsi_aio_write16_cb(struct iscsi_context *iscsi, int status, trace_iscsi_aio_write16_cb(iscsi, status, acb, acb->canceled); +#if !defined(LIBISCSI_FEATURE_IOVECTOR) g_free(acb->buf); +#endif if (acb->canceled != 0) { return; @@ -225,7 +229,9 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num, size_t size; uint32_t num_sectors; uint64_t lba; +#if !defined(LIBISCSI_FEATURE_IOVECTOR) struct iscsi_data data; +#endif acb = qemu_aio_get(&iscsi_aiocb_info, bs, cb, opaque); trace_iscsi_aio_writev(iscsi, sector_num, nb_sectors, opaque, acb); @@ -240,8 +246,11 @@ 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; + +#if !defined(LIBISCSI_FEATURE_IOVECTOR) acb->buf = g_malloc(size); qemu_iovec_to_buf(acb->qiov, 0, acb->buf, size); +#endif acb->task = malloc(sizeof(struct scsi_task)); if (acb->task == NULL) { @@ -262,6 +271,17 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num, *(uint32_t *)&acb->task->cdb[10] = htonl(num_sectors); acb->task->expxferlen = size; +#if defined(LIBISCSI_FEATURE_IOVECTOR) + if (iscsi_scsi_command_async(iscsi, iscsilun->lun, acb->task, + iscsi_aio_write16_cb, + NULL, + acb) != 0) { + scsi_free_scsi_task(acb->task); + qemu_aio_release(acb); + return NULL; + } + scsi_task_set_iov_out(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov); +#else data.data = acb->buf; data.size = size; @@ -274,6 +294,7 @@ iscsi_aio_writev(BlockDriverState *bs, int64_t sector_num, qemu_aio_release(acb); return NULL; } +#endif iscsi_set_events(iscsilun); @@ -312,7 +333,9 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num, struct iscsi_context *iscsi = iscsilun->iscsi; IscsiAIOCB *acb; size_t qemu_read_size; +#if !defined(LIBISCSI_FEATURE_IOVECTOR) int i; +#endif uint64_t lba; uint32_t num_sectors; @@ -328,7 +351,9 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num, acb->bh = NULL; acb->status = -EINPROGRESS; acb->read_size = qemu_read_size; +#if !defined(LIBISCSI_FEATURE_IOVECTOR) acb->buf = NULL; +#endif /* If LUN blocksize is bigger than BDRV_BLOCK_SIZE a read from QEMU * may be misaligned to the LUN, so we may need to read some extra @@ -383,11 +408,15 @@ iscsi_aio_readv(BlockDriverState *bs, int64_t sector_num, return NULL; } +#if defined(LIBISCSI_FEATURE_IOVECTOR) + scsi_task_set_iov_in(acb->task, (struct scsi_iovec*) acb->qiov->iov, acb->qiov->niov); +#else for (i = 0; i < acb->qiov->niov; i++) { scsi_task_add_data_in_buffer(acb->task, acb->qiov->iov[i].iov_len, acb->qiov->iov[i].iov_base); } +#endif iscsi_set_events(iscsilun); @@ -557,7 +586,9 @@ static BlockDriverAIOCB *iscsi_aio_ioctl(BlockDriverState *bs, acb->canceled = 0; acb->bh = NULL; acb->status = -EINPROGRESS; +#if !defined(LIBISCSI_FEATURE_IOVECTOR) acb->buf = NULL; +#endif acb->ioh = buf; acb->task = malloc(sizeof(struct scsi_task));