From patchwork Mon Jul 9 14:34:13 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 169862 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 CF17C2C0200 for ; Tue, 10 Jul 2012 00:34:32 +1000 (EST) Received: from localhost ([::1]:44763 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoF2k-0002GY-MW for incoming@patchwork.ozlabs.org; Mon, 09 Jul 2012 10:34:30 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40292) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoF2a-0002G5-3Y for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoF2V-0007JL-3c for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:34:19 -0400 Received: from verein.lst.de ([213.95.11.211]:45178 helo=newverein.lst.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoF2U-0007JA-Th for qemu-devel@nongnu.org; Mon, 09 Jul 2012 10:34:15 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id B6BBA13EBA; Mon, 9 Jul 2012 16:34:13 +0200 (CEST) Date: Mon, 9 Jul 2012 16:34:13 +0200 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20120709143413.GA5226@lst.de> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.17 (2007-11-01) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 213.95.11.211 Cc: sheepdog@lists.wpkg.org Subject: [Qemu-devel] [PATCH v3] sheepdog: do not blindly memset all read buffers 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 Only buffers that map to unallocated blocks need to be zeroed. Signed-off-by: Christoph Hellwig Acked-by: MORITA Kazutaka --- block/sheepdog.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) Index: qemu/block/sheepdog.c =================================================================== --- qemu.orig/block/sheepdog.c 2012-07-09 16:16:01.216467182 +0200 +++ qemu/block/sheepdog.c 2012-07-09 16:22:11.039798306 +0200 @@ -1556,18 +1556,25 @@ static int coroutine_fn sd_co_rw_vector( len = MIN(total - done, SD_DATA_OBJ_SIZE - offset); - if (!inode->data_vdi_id[idx]) { - if (acb->aiocb_type == AIOCB_READ_UDATA) { + switch (acb->aiocb_type) { + case AIOCB_READ_UDATA: + if (!inode->data_vdi_id[idx]) { + qemu_iovec_memset_skip(acb->qiov, 0, len, done); goto done; } - - create = 1; - } else if (acb->aiocb_type == AIOCB_WRITE_UDATA - && !is_data_obj_writable(inode, idx)) { - /* Copy-On-Write */ - create = 1; - old_oid = oid; - flags = SD_FLAG_CMD_COW; + break; + case AIOCB_WRITE_UDATA: + if (!inode->data_vdi_id[idx]) { + create = 1; + } else if (!is_data_obj_writable(inode, idx)) { + /* Copy-On-Write */ + create = 1; + old_oid = oid; + flags = SD_FLAG_CMD_COW; + } + break; + default: + break; } if (create) { @@ -1655,20 +1662,12 @@ static coroutine_fn int sd_co_readv(Bloc int nb_sectors, QEMUIOVector *qiov) { SheepdogAIOCB *acb; - int i, ret; + int ret; acb = sd_aio_setup(bs, qiov, sector_num, nb_sectors, NULL, NULL); acb->aiocb_type = AIOCB_READ_UDATA; acb->aio_done_func = sd_finish_aiocb; - /* - * TODO: we can do better; we don't need to initialize - * blindly. - */ - for (i = 0; i < qiov->niov; i++) { - memset(qiov->iov[i].iov_base, 0, qiov->iov[i].iov_len); - } - ret = sd_co_rw_vector(acb); if (ret <= 0) { qemu_aio_release(acb);