|
|
9ae3a8 |
From 3a454be93c4750bad515dc3dacc83a3feff5e02c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 7 Jan 2014 21:57:10 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 05/14] qcow2-cache: Empty cache
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1389131839-12920-6-git-send-email-mreitz@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56541
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 05/14] qcow2-cache: Empty cache
|
|
|
9ae3a8 |
Bugzilla: 1033490
|
|
|
9ae3a8 |
RH-Acked-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Fam Zheng <famz@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
BZ: 1033490
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Add a function for emptying a cache, i.e., flushing it and marking all
|
|
|
9ae3a8 |
elements invalid.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit e7108feaace8e02b3a4bf010448fc2744f753381)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Max Reitz <mreitz@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/qcow2-cache.c | 18 ++++++++++++++++++
|
|
|
9ae3a8 |
block/qcow2.h | 2 ++
|
|
|
9ae3a8 |
2 files changed, 20 insertions(+)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
block/qcow2-cache.c | 18 ++++++++++++++++++
|
|
|
9ae3a8 |
block/qcow2.h | 2 ++
|
|
|
9ae3a8 |
2 files changed, 20 insertions(+), 0 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
|
|
|
9ae3a8 |
index eb1d69b..8ecbb5b 100644
|
|
|
9ae3a8 |
--- a/block/qcow2-cache.c
|
|
|
9ae3a8 |
+++ b/block/qcow2-cache.c
|
|
|
9ae3a8 |
@@ -200,6 +200,24 @@ void qcow2_cache_depends_on_flush(Qcow2Cache *c)
|
|
|
9ae3a8 |
c->depends_on_flush = true;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c)
|
|
|
9ae3a8 |
+{
|
|
|
9ae3a8 |
+ int ret, i;
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ ret = qcow2_cache_flush(bs, c);
|
|
|
9ae3a8 |
+ if (ret < 0) {
|
|
|
9ae3a8 |
+ return ret;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ for (i = 0; i < c->size; i++) {
|
|
|
9ae3a8 |
+ assert(c->entries[i].ref == 0);
|
|
|
9ae3a8 |
+ c->entries[i].offset = 0;
|
|
|
9ae3a8 |
+ c->entries[i].cache_hits = 0;
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
+ return 0;
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int i;
|
|
|
9ae3a8 |
diff --git a/block/qcow2.h b/block/qcow2.h
|
|
|
9ae3a8 |
index e4c140c..5ca6b78 100644
|
|
|
9ae3a8 |
--- a/block/qcow2.h
|
|
|
9ae3a8 |
+++ b/block/qcow2.h
|
|
|
9ae3a8 |
@@ -489,6 +489,8 @@ int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c,
|
|
|
9ae3a8 |
Qcow2Cache *dependency);
|
|
|
9ae3a8 |
void qcow2_cache_depends_on_flush(Qcow2Cache *c);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
+int qcow2_cache_empty(BlockDriverState *bs, Qcow2Cache *c);
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
|
|
|
9ae3a8 |
void **table);
|
|
|
9ae3a8 |
int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.1
|
|
|
9ae3a8 |
|