[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 6/7] vmdk: Only read cid from image file when opening
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PULL 6/7] vmdk: Only read cid from image file when opening |
Date: |
Fri, 18 Oct 2013 16:18:34 +0200 |
From: Fam Zheng <address@hidden>
Previously cid of parent is parsed from image file for every IO request.
We already have L1/L2 cache and don't have assumption that parent image
can be updated behind us, so remove this to get more efficiency.
The parent CID is checked only for once after opening.
Signed-off-by: Fam Zheng <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
block/vmdk.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/block/vmdk.c b/block/vmdk.c
index 5a9f278..b8901e2 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -112,6 +112,7 @@ typedef struct BDRVVmdkState {
CoMutex lock;
uint64_t desc_offset;
bool cid_updated;
+ bool cid_checked;
uint32_t parent_cid;
int num_extents;
/* Extent array with num_extents entries, ascend ordered by address */
@@ -197,8 +198,6 @@ static int vmdk_probe(const uint8_t *buf, int buf_size,
const char *filename)
}
}
-#define CHECK_CID 1
-
#define SECTOR_SIZE 512
#define DESC_SIZE (20 * SECTOR_SIZE) /* 20 sectors of 512 bytes each */
#define BUF_SIZE 4096
@@ -301,19 +300,18 @@ static int vmdk_write_cid(BlockDriverState *bs, uint32_t
cid)
static int vmdk_is_cid_valid(BlockDriverState *bs)
{
-#ifdef CHECK_CID
BDRVVmdkState *s = bs->opaque;
BlockDriverState *p_bs = bs->backing_hd;
uint32_t cur_pcid;
- if (p_bs) {
+ if (!s->cid_checked && p_bs) {
cur_pcid = vmdk_read_cid(p_bs, 0);
if (s->parent_cid != cur_pcid) {
/* CID not valid */
return 0;
}
}
-#endif
+ s->cid_checked = true;
/* CID valid */
return 1;
}
--
1.8.3.1
- [Qemu-devel] [PULL 0/7] Block patches, Stefan Hajnoczi, 2013/10/18
- [Qemu-devel] [PULL 2/7] sd: Avoid access to NULL BlockDriverState, Stefan Hajnoczi, 2013/10/18
- [Qemu-devel] [PULL 1/7] hmp: drop bogus "[not inserted]", Stefan Hajnoczi, 2013/10/18
- [Qemu-devel] [PULL 5/7] virtio: Remove unneeded memcpy, Stefan Hajnoczi, 2013/10/18
- [Qemu-devel] [PULL 3/7] blockdev: fix cdrom read_only flag, Stefan Hajnoczi, 2013/10/18
- [Qemu-devel] [PULL 4/7] block/raw-win32: Always use -errno in hdev_open, Stefan Hajnoczi, 2013/10/18
- [Qemu-devel] [PULL 6/7] vmdk: Only read cid from image file when opening,
Stefan Hajnoczi <=
- [Qemu-devel] [PULL 7/7] vmdk: fix VMFS extent parsing, Stefan Hajnoczi, 2013/10/18