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