From patchwork Tue Jul 10 14:12:27 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 170189 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 605D12C01B4 for ; Wed, 11 Jul 2012 00:12:56 +1000 (EST) Received: from localhost ([::1]:56550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SobBN-0001jL-P5 for incoming@patchwork.ozlabs.org; Tue, 10 Jul 2012 10:12:53 -0400 Received: from eggs.gnu.org ([208.118.235.92]:40183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SobBB-0001iu-NT for qemu-devel@nongnu.org; Tue, 10 Jul 2012 10:12:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SobB0-00012g-Cd for qemu-devel@nongnu.org; Tue, 10 Jul 2012 10:12:41 -0400 Received: from verein.lst.de ([213.95.11.211]:47568 helo=newverein.lst.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SobB0-000123-6F for qemu-devel@nongnu.org; Tue, 10 Jul 2012 10:12:30 -0400 Received: by newverein.lst.de (Postfix, from userid 2407) id F2E0613ECA; Tue, 10 Jul 2012 16:12:27 +0200 (CEST) Date: Tue, 10 Jul 2012 16:12:27 +0200 From: Christoph Hellwig To: qemu-devel@nongnu.org Message-ID: <20120710141227.GA24243@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 v4] 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-10 15:46:51.433323624 +0200 +++ qemu/block/sheepdog.c 2012-07-10 15:47:59.329989886 +0200 @@ -1590,18 +1590,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(acb->qiov, done, 0, len); 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) { @@ -1687,20 +1694,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);