[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 05/33] qcow2-cache: Empty cache
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 05/33] qcow2-cache: Empty cache |
Date: |
Fri, 13 Sep 2013 13:50:35 +0200 |
From: Max Reitz <address@hidden>
Add a function for emptying a cache, i.e., flushing it and marking all
elements invalid.
Signed-off-by: Max Reitz <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
block/qcow2-cache.c | 18 ++++++++++++++++++
block/qcow2.h | 2 ++
2 files changed, 20 insertions(+)
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 7bcae09..40a5a3f 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -202,6 +202,24 @@ void qcow2_cache_depends_on_flush(Qcow2Cache *c)
c->depends_on_flush = true;
}
+int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c)
+{
+ int ret, i;
+
+ ret = qcow2_cache_flush(bs, c);
+ if (ret < 0) {
+ return ret;
+ }
+
+ for (i = 0; i < c->size; i++) {
+ assert(c->entries[i].ref == 0);
+ c->entries[i].offset = 0;
+ c->entries[i].cache_hits = 0;
+ }
+
+ return 0;
+}
+
static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c)
{
int i;
diff --git a/block/qcow2.h b/block/qcow2.h
index 49eed82..35c822b 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -478,6 +478,8 @@ int qcow2_cache_set_dependency(BlockDriverState *bs,
Qcow2Cache *c,
Qcow2Cache *dependency);
void qcow2_cache_depends_on_flush(Qcow2Cache *c);
+int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c);
+
int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
void **table);
int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
--
1.8.1.4
- [Qemu-devel] [PULL 00/33] Block patches, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 03/33] raw-win32.c: Fix incorrect handling behaviour of small block files, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 04/33] block: Image file option amendment, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 06/33] qcow2-cluster: Expand zero clusters, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 05/33] qcow2-cache: Empty cache,
Kevin Wolf <=
- [Qemu-devel] [PULL 07/33] qcow2: Save refcount order in BDRVQcowState, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 01/33] qcow2: Pass discard type to qcow2_discard_clusters(), Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 02/33] qcow2: Discard VM state in active L1 after creating snapshot, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 11/33] qemu-iotests: add infrastructure of fd passing via SCM, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 10/33] qemu-iotests: add unix socket help program, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 09/33] qemu-iotest: qcow2 image option amendment, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 08/33] qcow2: Implement bdrv_amend_options, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 12/33] qemu-iotests: add tests for runtime fd passing via SCM rights, Kevin Wolf, 2013/09/13
- [Qemu-devel] [PULL 13/33] qemu-iotests: New test case in 061, Kevin Wolf, 2013/09/13