From patchwork Thu Apr 27 08:06:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9702485 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 94B99602CC for ; Thu, 27 Apr 2017 08:09:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89A7326E73 for ; Thu, 27 Apr 2017 08:09:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7CDF4285F3; Thu, 27 Apr 2017 08:09:32 +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 2A19C26E73 for ; Thu, 27 Apr 2017 08:09:32 +0000 (UTC) Received: from localhost ([::1]:59297 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3eUV-0005Ya-Bw for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Apr 2017 04:09:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3eRd-0003X8-FD for qemu-devel@nongnu.org; Thu, 27 Apr 2017 04:06:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3eRc-00007Q-IB for qemu-devel@nongnu.org; Thu, 27 Apr 2017 04:06:33 -0400 Received: from mail-pf0-x243.google.com ([2607:f8b0:400e:c00::243]:35652) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d3eRc-00007B-CL; Thu, 27 Apr 2017 04:06:32 -0400 Received: by mail-pf0-x243.google.com with SMTP id a188so7474760pfa.2; Thu, 27 Apr 2017 01:06:32 -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=4acXijkNEnMWOZC9MFvY1Q35rJXGr9zjf34TMnSb0so=; b=IWEjEdMPQSk8vW6Z9K9z6KtAJAkaI8rWJvwdETXAW4X1ZPGIfhDnSt7aiiP6ahMyRj nIphAdRBQ8UVZbOZstzS6OLpNTtFsSB6E9dK3aOKbwlsulisds9YE21O0uaIpLFNX0Wm JDzMl/RuHOzQdScueBsoWg+3dXmW+38OwK3EOgg96+Tm5Bu0MwOudZRXIetHhNBzD8fr 4LGbUZ7sMYXoz9EXCP/sCwv7Mc1VprmJxn5kYOcLZKvniVxeuQAs4kVFnV+Qh1tBzY7d HGIesVDqdf1YmbJngFIvzxRBZOiGOdZejl0v0O4TGxPAia4DME4mhegjuU+rO2dLW2Io 7fTg== 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=4acXijkNEnMWOZC9MFvY1Q35rJXGr9zjf34TMnSb0so=; b=XN08jnRIZ5wPVDketLfVGBOXJUmvZdcq1UNCfL5Rwl1s5OsudehhZ3McAyhNW12Tl7 g+gKI0gNQGuGDBL9K5k0FLJ45ESWpBBT+j9aQyzbuh59uZgdKkcEMc51mXPwMId0OgVu x4GUu1eLpHWGyQ8Qtr1eiSBCVtz6kXdbr1nr86X5aZRAsLwIFdlZIqEMz73akVpO5TeI cim8m+ZkfrVi5yTdp0cf6lpsyZn2FTllT0uw/g2sXR0gxb+jl5GMLutPZ1VGT3WvRGHw 57hi1A49d0hkNkSLVWlUK73SFf6aTH36wDTXT6lyG+n4EHxPjDNZBtOG9KdCqDdRsKdD 0nDg== X-Gm-Message-State: AN3rC/70F+d+tQlDhHhKnzvsMzu+L7dwDJgENcwLWQjvcAOTh2ydfbkj xZQNVF3D90krmTNs X-Received: by 10.84.245.1 with SMTP id i1mr487586pll.51.1493280391604; Thu, 27 Apr 2017 01:06:31 -0700 (PDT) Received: from linux.local ([157.51.104.251]) by smtp.gmail.com with ESMTPSA id 12sm3295277pgb.35.2017.04.27.01.06.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Apr 2017 01:06:31 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Thu, 27 Apr 2017 13:36:36 +0530 Message-Id: <1493280397-9622-7-git-send-email-ashijeetacharya@gmail.com> X-Mailer: git-send-email 2.6.2 In-Reply-To: <1493280397-9622-1-git-send-email-ashijeetacharya@gmail.com> References: <1493280397-9622-1-git-send-email-ashijeetacharya@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::243 Subject: [Qemu-devel] [PATCH v2 6/7] 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 f9045f9..8b7460c 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;