From patchwork Tue Apr 25 19:59:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9699551 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 491A360245 for ; Tue, 25 Apr 2017 20:00:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3976628674 for ; Tue, 25 Apr 2017 20:00:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2E10D28676; Tue, 25 Apr 2017 20:00:14 +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 BC2AE28674 for ; Tue, 25 Apr 2017 20:00:13 +0000 (UTC) Received: from localhost ([::1]:51172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36dA-0006n5-Uh for patchwork-qemu-devel@patchwork.kernel.org; Tue, 25 Apr 2017 16:00:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52482) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d36bu-0006ja-1x for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:58:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d36bt-0003uo-D3 for qemu-devel@nongnu.org; Tue, 25 Apr 2017 15:58:54 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35690) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d36bt-0003uT-7G; Tue, 25 Apr 2017 15:58:53 -0400 Received: by mail-pf0-x241.google.com with SMTP id a188so12347592pfa.2; Tue, 25 Apr 2017 12:58:53 -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=IlnxF6kfjqlPCG3CQGlgRbUb7F2oQkuehDnoRyUmjOE=; b=AirGPs4iJ33o7v9+STaDnU+TYPur5AIcXMVYQjcm4yWCnD/MIsaAXKqIJgqRbiBBVj CCWxIgdEpI8K5K0HTIdOnwMvMmw28BpTgYaIo8DKP4MzAolDDCTOJyQMyLmwoPjcrkmg JtlUlCSHD/kX2ojCmZwSW4poJ2t1d8KqFEvFCJipN3X90d0peOUfSr3WOskeT/lpQ6k5 JwWbQKN3rRD5yTQvwRg6QxsL795Uy7BBADiugM7zz8GOorrkfdxR8mTU3nSUFQhN3gSN E7HpAuYjX868MUqa8oUn19X565IwkuhUE8W8Fov6B0cOJxZI/CVFWzBkRA9ptTLJBJns tOrQ== 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=IlnxF6kfjqlPCG3CQGlgRbUb7F2oQkuehDnoRyUmjOE=; b=SH/czzvYCPu4p+fKsOlKEcj3p6NnGaUlDqPHfMAk5D6czVx+4Ht84L77E4AFUk2YXk BNl1P/cKlc9g07uqbRmKDazGTLIw83piolkTVNAlpa5qiHR59S3qYyyArHnTMdufWPUj PRvT6ShmGD7fbPbV/mcstEGLbNXg4BhWpnv0Ff8whs4dVHqa/upQNHmfISWxDQ49fJ8p gzOl3v2+T4uQPenz3GW15v6fThW5Vc6AyGCDZ26/l5dROhm5Njbex42rJGiat3uY+4L4 6cAAZrxNIiMvtmYrV3gSoCSbw8dkx3YgW/Sr99O3jPPhpnehsrhME/EE645K+NbdYsCJ 5l3Q== X-Gm-Message-State: AN3rC/4ZnRuHZ/GuxykIboSUgLJn5OFqdD0HngRI/JFNTuNaaPESNKZI H3FKnfDrXp+xcw== X-Received: by 10.84.176.100 with SMTP id u91mr39255274plb.39.1493150332167; Tue, 25 Apr 2017 12:58:52 -0700 (PDT) Received: from linux.local ([157.51.23.94]) by smtp.gmail.com with ESMTPSA id y187sm37931530pfy.67.2017.04.25.12.58.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 25 Apr 2017 12:58:51 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Wed, 26 Apr 2017 01:29:04 +0530 Message-Id: <1493150351-28918-2-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: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH v1 1/8] dmg: Introduce a new struct to cache random access points 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 We need to cache the random access point while performing partial decompression so that we can resume decompression from that point onwards in our next sequential read request. Introduce a new struct DMGReadState which will help us do this. Signed-off-by: Ashijeet Acharya --- block/dmg.h | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/block/dmg.h b/block/dmg.h index b592d6f..ee67ae1 100644 --- a/block/dmg.h +++ b/block/dmg.h @@ -31,6 +31,15 @@ #include "block/block_int.h" #include +/* used to cache current position in compressed input stream */ +typedef struct DMGReadState { + uint8_t *saved_next_in; + int64_t saved_avail_in; + int32_t saved_chunk_type; + int64_t sectors_read; /* possible sectors read in each cycle */ + int32_t sector_offset_in_chunk; +} DMGReadState; + typedef struct BDRVDMGState { CoMutex lock; /* each chunk contains a certain number of sectors, @@ -51,6 +60,7 @@ typedef struct BDRVDMGState { uint8_t *compressed_chunk; uint8_t *uncompressed_chunk; z_stream zstream; + DMGReadState *drs; } BDRVDMGState; extern int (*dmg_uncompress_bz2)(char *next_in, unsigned int avail_in,