From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M8aUr-0000I0-3O for qemu-devel@nongnu.org; Mon, 25 May 2009 09:45:45 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M8aUl-0000FV-QE for qemu-devel@nongnu.org; Mon, 25 May 2009 09:45:44 -0400 Received: from [199.232.76.173] (port=39206 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M8aUl-0000FQ-GX for qemu-devel@nongnu.org; Mon, 25 May 2009 09:45:39 -0400 Received: from verein.lst.de ([213.95.11.210]:44142) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_3DES_EDE_CBC_SHA1:24) (Exim 4.60) (envelope-from ) id 1M8aUk-0008Qc-Si for qemu-devel@nongnu.org; Mon, 25 May 2009 09:45:39 -0400 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id n4PDjbIF020529 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 25 May 2009 15:45:37 +0200 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-6.6) id n4PDjbTU020527 for qemu-devel@nongnu.org; Mon, 25 May 2009 15:45:37 +0200 Date: Mon, 25 May 2009 15:45:37 +0200 From: Christoph Hellwig Message-ID: <20090525134537.GA20420@lst.de> References: <20090525103732.GA11391@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20090525103732.GA11391@lst.de> Subject: [Qemu-devel] [PATCH] qcow: add qcow_aio_setup helper List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org [this one is required for [PATCH] fully split aio_pool from BlockDriver, sorry for not sending it out earlier] Add a qcow_aio_setup helper to qcow to shared common code between the aio_readv and aio_writev methods. Based on the function with the same name in qcow2. Signed-off-by: Christoph Hellwig Index: qemu/block/qcow.c =================================================================== --- qemu.orig/block/qcow.c 2009-05-25 11:44:33.135832179 +0200 +++ qemu/block/qcow.c 2009-05-25 11:47:33.176222551 +0200 @@ -538,6 +538,32 @@ typedef struct QCowAIOCB { BlockDriverAIOCB *hd_aiocb; } QCowAIOCB; + +static QCowAIOCB *qcow_aio_setup(BlockDriverState *bs, + int64_t sector_num, QEMUIOVector *qiov, int nb_sectors, + BlockDriverCompletionFunc *cb, void *opaque, int is_write) +{ + QCowAIOCB *acb; + + acb = qemu_aio_get(bs, cb, opaque); + if (!acb) + return NULL; + acb->hd_aiocb = NULL; + acb->sector_num = sector_num; + acb->qiov = qiov; + if (qiov->niov > 1) { + acb->buf = acb->orig_buf = qemu_blockalign(bs, qiov->size); + if (is_write) + qemu_iovec_to_buffer(qiov, acb->buf); + } else { + acb->buf = (uint8_t *)qiov->iov->iov_base; + } + acb->nb_sectors = nb_sectors; + acb->n = 0; + acb->cluster_offset = 0; + return acb; +} + static void qcow_aio_read_cb(void *opaque, int ret) { QCowAIOCB *acb = opaque; @@ -635,19 +661,9 @@ static BlockDriverAIOCB *qcow_aio_readv( { QCowAIOCB *acb; - acb = qemu_aio_get(bs, cb, opaque); + acb = qcow_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque, 0); if (!acb) return NULL; - acb->hd_aiocb = NULL; - acb->sector_num = sector_num; - acb->qiov = qiov; - if (qiov->niov > 1) - acb->buf = acb->orig_buf = qemu_blockalign(bs, qiov->size); - else - acb->buf = (uint8_t *)qiov->iov->iov_base; - acb->nb_sectors = nb_sectors; - acb->n = 0; - acb->cluster_offset = 0; qcow_aio_read_cb(acb, 0); return &acb->common; @@ -730,20 +746,10 @@ static BlockDriverAIOCB *qcow_aio_writev s->cluster_cache_offset = -1; /* disable compressed cache */ - acb = qemu_aio_get(bs, cb, opaque); + acb = qcow_aio_setup(bs, sector_num, qiov, nb_sectors, cb, opaque, 0); if (!acb) return NULL; - acb->hd_aiocb = NULL; - acb->sector_num = sector_num; - acb->qiov = qiov; - if (qiov->niov > 1) { - acb->buf = acb->orig_buf = qemu_blockalign(bs, qiov->size); - qemu_iovec_to_buffer(qiov, acb->buf); - } else { - acb->buf = (uint8_t *)qiov->iov->iov_base; - } - acb->nb_sectors = nb_sectors; - acb->n = 0; + qcow_aio_write_cb(acb, 0); return &acb->common;