From patchwork Tue Apr 25 19:59:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9699571 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 377C660245 for ; Tue, 25 Apr 2017 20:06:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 26C092866C for ; Tue, 25 Apr 2017 20:06:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A6E028681; Tue, 25 Apr 2017 20:06:49 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id BF42E2866C for ; Tue, 25 Apr 2017 20:06:48 +0000 (UTC) Received: from localhost ([::1]:51218 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36jY-0003qs-1F for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Apr 2017 16:06:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52731) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36cV-0007Em-9x for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36cU-00045W-DL for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:59:31 -0400 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]:33578) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36cU-000459-7E; Tue, 25 Apr 2017 15:59:30 -0400 Received: by mail-pg0-x243.google.com with SMTP id 63so13418410pgh.0; Tue, 25 Apr 2017 12:59:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=lff7WGyzQ58LVkveJGMjRFsgZQpZnAiyqM4mf2m6OKk=; b=HKzSZSMW17+bNDoqc6ZXvDFEQkBPgZeQD5Q4uDV6vn5O7DEGdbSPTzt559if2rZuQK FkL1RKSKGBbb1z6amqZX+Yg5HPJseiqjxl+gwGV/UK8x21istMdLAxrJgoXCjxf9l9TT jb1f6uU/3X6d+V6V3/80mhFKoWVide3lwS1p8KxkpmyY0yidpqt1k3a3wBW9Dh5dy9ty /CuKjhGx2qlMTdgvrHEvw8Dq+URSoUOQjfbkWqSbjYBfWY7bYE+WX8cQX50p4NGtQZwg qbV8Y6DsSDfttjTLnoQ/i7t9TWVSW/5JO/r7l2YF7CzEfp88YgTXuSK3d9qcT2eCthWd DOAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=lff7WGyzQ58LVkveJGMjRFsgZQpZnAiyqM4mf2m6OKk=; b=kF0GZu8lhKL+Z6y1rTA61lkYtr6A4e2AqaPt2s884ZWvI0mT7eeoWAuh6lCNSJ8J0c ZkCcOLBaIgOssUye/o5R7OQx8hw8I5/pEiERe/XNow2OQYcpSkfTDSNTT9bj0xH7rM4I +vnCplIYoABAJUME+WJm+iGWMBA5joATzmexk6XwiomToHsJTo8O7FN+p85lZfS999Rw NP5I62peawHxvx/HgtaCaPHK242zbLWitp+D8stCgp68FxWorqE43/ufn5EvE7r4MLlc /FvFCMpMTey8yUSiiIe7m/VAIn6HBvPBvXKeAs28RFc4DAslwXA5pCIPoxh9xW9bA+Oa ZXAw== X-Gm-Message-State: AN3rC/4tCTpOsVMl95Fa3/1cjSmbz0NGIU6do+RihczOtp29a2pGG45v vS5gWRrIjU56aA== X-Received: by 10.99.121.67 with SMTP id u64mr15696310pgc.230.1493150369294; Tue, 25 Apr 2017 12:59:29 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.59.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:59:28 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:10 +0530 Message-Id: <1493150351-28918-8-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> References: <1493150351-28918-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c05::243 Subject: [Qemu-devel] [PATCH v1 7/8] dmg: Refactor dmg_co_preadv() to start reading multiple sectors X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, mreitz@redhat.com, peter@lekensteyn.nl, Ashijeet Acharya , jsnow@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP At the moment, dmg_co_preadv() reads one sector at a time. Make it read multiple sectors at a time depending on the number of sectors stored in "drs->sectors_read". This does not provide any significant optimization in the I/O process of DMG but is still a nicer way. Adjust the 'data' variable depending on our cached access point situation to align our read requests appropriately. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index f643e41..b0f3c84 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -718,7 +718,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, BDRVDMGState *s = bs->opaque; uint64_t sector_num = offset >> BDRV_SECTOR_BITS; int nb_sectors = bytes >> BDRV_SECTOR_BITS; - int ret, i; + int ret, i = 0; DMGReadState *drs = s->drs; assert((offset & (BDRV_SECTOR_SIZE - 1)) == 0); @@ -726,8 +726,7 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, qemu_co_mutex_lock(&s->lock); - for (i = 0; i < nb_sectors; i++) { - uint32_t sector_offset_in_chunk; + while (i < nb_sectors) { void *data; if (dmg_read_chunk(bs, sector_num + i, drs) != 0) { @@ -738,12 +737,20 @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, * s->uncompressed_chunk may be too small to cover the large all-zeroes * section. dmg_read_chunk is called to find s->current_chunk */ if (s->types[s->current_chunk] == 2) { /* all zeroes block entry */ - qemu_iovec_memset(qiov, i * 512, 0, 512); - continue; + qemu_iovec_memset(qiov, i * 512, 0, + 512 * drs->sectors_read); + goto increment; + } + + if (drs->saved_next_in == NULL) { + data = s->uncompressed_chunk + drs->sector_offset_in_chunk * 512; + } else { + data = s->uncompressed_chunk; } - sector_offset_in_chunk = sector_num + i - s->sectors[s->current_chunk]; - data = s->uncompressed_chunk + sector_offset_in_chunk * 512; - qemu_iovec_from_buf(qiov, i * 512, data, 512); + qemu_iovec_from_buf(qiov, i * 512, data, drs->sectors_read * 512); + +increment: + i += drs->sectors_read; } ret = 0;