thebeanogamer / rpms / qemu-kvm

Forked from rpms/qemu-kvm 5 months ago
Clone
218e99
From 5bd906f28072f5d071705801cc1dd2e9084057bc Mon Sep 17 00:00:00 2001
218e99
From: Max Reitz <mreitz@redhat.com>
218e99
Date: Wed, 6 Nov 2013 16:53:43 +0100
218e99
Subject: [PATCH 86/87] vmdk: Only read cid from image file when opening
218e99
218e99
RH-Author: Max Reitz <mreitz@redhat.com>
218e99
Message-id: <1383756824-6921-21-git-send-email-mreitz@redhat.com>
218e99
Patchwork-id: 55575
218e99
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 20/21] vmdk: Only read cid from image file when opening
218e99
Bugzilla: 980771
218e99
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
218e99
RH-Acked-by: Fam Zheng <famz@redhat.com>
218e99
RH-Acked-by: Jeffrey Cody <jcody@redhat.com>
218e99
218e99
From: Fam Zheng <famz@redhat.com>
218e99
218e99
BZ: 980771
218e99
218e99
Previously cid of parent is parsed from image file for every IO request.
218e99
We already have L1/L2 cache and don't have assumption that parent image
218e99
can be updated behind us, so remove this to get more efficiency.
218e99
218e99
The parent CID is checked only for once after opening.
218e99
218e99
Signed-off-by: Fam Zheng <famz@redhat.com>
218e99
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
218e99
(cherry picked from commit c338b6ad609699cf352c8dd6338360b7e3895ad0)
218e99
218e99
Signed-off-by: Max Reitz <mreitz@redhat.com>
218e99
---
218e99
 block/vmdk.c | 8 +++-----
218e99
 1 file changed, 3 insertions(+), 5 deletions(-)
218e99
218e99
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
218e99
---
218e99
 block/vmdk.c |    8 +++-----
218e99
 1 files changed, 3 insertions(+), 5 deletions(-)
218e99
218e99
diff --git a/block/vmdk.c b/block/vmdk.c
218e99
index ccbb0c9..8bef9f2 100644
218e99
--- a/block/vmdk.c
218e99
+++ b/block/vmdk.c
218e99
@@ -112,6 +112,7 @@ typedef struct BDRVVmdkState {
218e99
     CoMutex lock;
218e99
     uint64_t desc_offset;
218e99
     bool cid_updated;
218e99
+    bool cid_checked;
218e99
     uint32_t parent_cid;
218e99
     int num_extents;
218e99
     /* Extent array with num_extents entries, ascend ordered by address */
218e99
@@ -197,8 +198,6 @@ static int vmdk_probe(const uint8_t *buf, int buf_size, const char *filename)
218e99
     }
218e99
 }
218e99
 
218e99
-#define CHECK_CID 1
218e99
-
218e99
 #define SECTOR_SIZE 512
218e99
 #define DESC_SIZE (20 * SECTOR_SIZE)    /* 20 sectors of 512 bytes each */
218e99
 #define BUF_SIZE 4096
218e99
@@ -301,19 +300,18 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t cid)
218e99
 
218e99
 static int vmdk_is_cid_valid(BlockDriverState *bs)
218e99
 {
218e99
-#ifdef CHECK_CID
218e99
     BDRVVmdkState *s = bs->opaque;
218e99
     BlockDriverState *p_bs = bs->backing_hd;
218e99
     uint32_t cur_pcid;
218e99
 
218e99
-    if (p_bs) {
218e99
+    if (!s->cid_checked && p_bs) {
218e99
         cur_pcid = vmdk_read_cid(p_bs, 0);
218e99
         if (s->parent_cid != cur_pcid) {
218e99
             /* CID not valid */
218e99
             return 0;
218e99
         }
218e99
     }
218e99
-#endif
218e99
+    s->cid_checked = true;
218e99
     /* CID valid */
218e99
     return 1;
218e99
 }
218e99
-- 
218e99
1.7.1
218e99