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