From patchwork Thu Apr 27 08:06:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashijeet Acharya X-Patchwork-Id: 9702493 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 337A9603F7 for ; Thu, 27 Apr 2017 08:13:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 27774268AE for ; Thu, 27 Apr 2017 08:13:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1C380285EE; Thu, 27 Apr 2017 08:13:56 +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 C2397268AE for ; Thu, 27 Apr 2017 08:13:55 +0000 (UTC) Received: from localhost ([::1]:59327 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3eYl-00017R-34 for patchwork-qemu-devel@patchwork.kernel.org; Thu, 27 Apr 2017 04:13:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56520) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1d3eRZ-0003UG-NW for qemu-devel@nongnu.org; Thu, 27 Apr 2017 04:06:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1d3eRX-0008UX-GN for qemu-devel@nongnu.org; Thu, 27 Apr 2017 04:06:29 -0400 Received: from mail-pf0-x244.google.com ([2607:f8b0:400e:c00::244]:36640) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1d3eRX-0008Tk-Ai; Thu, 27 Apr 2017 04:06:27 -0400 Received: by mail-pf0-x244.google.com with SMTP id v14so7447528pfd.3; Thu, 27 Apr 2017 01:06:27 -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=dx8DVoQIxQQ2QPeCG+pUqSdoSz3OnbHLU6+77A/H6D4=; b=fzDcEotg8hEa6QIoEVN0RvN3l/wNIOpM3AQZOFVObiVIEOOKStI+Py6Z9mr+hNYWop Qjv7/tMk1WFYXDIkx+m4wYozhsOpQRHi3017tdaEM1VD9E/fr+UZx+2vRFqEzPMeRW0e 9FechYhZ1XTkAdA60aPpfUVmGTcVa4YXws64geWX47l+vgncu29FJaWwONiw4dmyHYPV qya5eYFtRmjptbF9HNZ2FuAUGmHA4kyruwvsjrj4PomizxqVCGTz5Ap67JfHCI1c5MIr AA9lnoNXU0tTYr93jyD7s7gbZxnxBH2nCrtbKWqkyTWLjLu1lrfP+gIQKCpxqRlTSW8O TlLA== 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=dx8DVoQIxQQ2QPeCG+pUqSdoSz3OnbHLU6+77A/H6D4=; b=iwk2nAksqbi0Ym0X3xEb/OtWHxwSZlg45D6xumIKS0DtsxjmUQlRo5xCYe5AyirEvv VhK2MAclmJ/J5OWVj7uMTIIc/qAWg4RzZUAIMgtfpRi/bRwsjzNem9yRkMBsruXKJ8eV hYJJa88+J+NfGF4ODDDAugLD7+o/pHB9q0ExBMq7nSbVSqQ6vBivgoVTCXqX1hLOVxIp O3TdP5GjTzH2onWF/0pRcsJBRI7Ojxd9wW+Yt7iLsa5FLvXKlpBU6kiwEd8+Qdx7osUe slGgKZOT4yrD8iqc0Mewy6enjGKirqaUlO3ttqM7mxJBXyM0ppYyBWfRE3Eqh8MSS1fh gh4Q== X-Gm-Message-State: AN3rC/5ntxsZF6eN+W3Xcrrs/3Q4uKBmpLZoe9/HknS8VDdChH1yUqdr A4zlW/kK8r2r5A== X-Received: by 10.98.34.5 with SMTP id i5mr4398259pfi.228.1493280386438; Thu, 27 Apr 2017 01:06:26 -0700 (PDT) Received: from linux.local ([157.51.104.251]) by smtp.gmail.com with ESMTPSA id 12sm3295277pgb.35.2017.04.27.01.06.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 27 Apr 2017 01:06:26 -0700 (PDT) From: Ashijeet Acharya To: stefanha@gmail.com Date: Thu, 27 Apr 2017 13:36:35 +0530 Message-Id: <1493280397-9622-6-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::244 Subject: [Qemu-devel] [PATCH v2 5/7] dmg: Handle bz2 compressed/raw/zeroed chunks 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 do not need to cache the access point for these chunks but need to update our various supporting variables like chunk, sectors_read etc. to keep maintaining our code structure. Call cache_access_point() after reading chunks of these types. Signed-off-by: Ashijeet Acharya --- block/dmg.c | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/block/dmg.c b/block/dmg.c index 073e864..f9045f9 100644 --- a/block/dmg.c +++ b/block/dmg.c @@ -680,20 +680,30 @@ update: (char *)s->uncompressed_chunk, (unsigned int) (512 * s->sectorcounts[chunk])); + if (ret < 0) { return ret; } + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); break; case 1: /* copy */ - ret = bdrv_pread(bs->file, s->offsets[chunk], - s->uncompressed_chunk, s->lengths[chunk]); - if (ret != s->lengths[chunk]) { - return -1; + if (drs->sectors_read == -1) { + ret = bdrv_pread(bs->file, s->offsets[chunk], + s->uncompressed_chunk, s->lengths[chunk]); + if (ret != s->lengths[chunk]) { + return -1; + } } + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); break; case 2: /* zero */ /* see dmg_read, it is treated specially. No buffer needs to be * pre-filled, the zeroes can be set directly. */ + cache_access_point(drs, NULL, -1, chunk, sectors_read, + sector_offset); + break; } s->current_chunk = chunk;