This patch only rename qcow2_cache* functions to block_cache*,
did not touch other code.

Signed-off-by: Dong Xu Wang <wdon...@linux.vnet.ibm.com>
---
 block/qcow2-cache.c    | 70 +++++++++++++++++++++++++-------------------------
 block/qcow2-cluster.c  | 48 +++++++++++++++++-----------------
 block/qcow2-refcount.c | 42 +++++++++++++++---------------
 block/qcow2.c          | 18 ++++++-------
 block/qcow2.h          | 28 ++++++++++----------
 trace-events           | 12 ++++-----
 6 files changed, 109 insertions(+), 109 deletions(-)

diff --git a/block/qcow2-cache.c b/block/qcow2-cache.c
index 2f3114e..bc057a8 100644
--- a/block/qcow2-cache.c
+++ b/block/qcow2-cache.c
@@ -27,25 +27,25 @@
 #include "qcow2.h"
 #include "trace.h"
 
-typedef struct Qcow2CachedTable {
+typedef struct BlockCachedTable {
     void*   table;
     int64_t offset;
     bool    dirty;
     int     cache_hits;
     int     ref;
-} Qcow2CachedTable;
+} BlockCachedTable;
 
-struct Qcow2Cache {
-    Qcow2CachedTable*       entries;
-    struct Qcow2Cache*      depends;
+struct BlockCache {
+    BlockCachedTable*       entries;
+    struct BlockCache*      depends;
     int                     size;
     bool                    depends_on_flush;
 };
 
-Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables)
+BlockCache *block_cache_create(BlockDriverState *bs, int num_tables)
 {
     BDRVQcowState *s = bs->opaque;
-    Qcow2Cache *c;
+    BlockCache *c;
     int i;
 
     c = g_malloc0(sizeof(*c));
@@ -59,7 +59,7 @@ Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int 
num_tables)
     return c;
 }
 
-int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c)
+int block_cache_destroy(BlockDriverState* bs, BlockCache *c)
 {
     int i;
 
@@ -74,11 +74,11 @@ int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c)
     return 0;
 }
 
-static int qcow2_cache_flush_dependency(BlockDriverState *bs, Qcow2Cache *c)
+static int block_cache_flush_dependency(BlockDriverState *bs, BlockCache *c)
 {
     int ret;
 
-    ret = qcow2_cache_flush(bs, c->depends);
+    ret = block_cache_flush(bs, c->depends);
     if (ret < 0) {
         return ret;
     }
@@ -89,7 +89,7 @@ static int qcow2_cache_flush_dependency(BlockDriverState *bs, 
Qcow2Cache *c)
     return 0;
 }
 
-static int qcow2_cache_entry_flush(BlockDriverState *bs, Qcow2Cache *c, int i)
+static int block_cache_entry_flush(BlockDriverState *bs, BlockCache *c, int i)
 {
     BDRVQcowState *s = bs->opaque;
     int ret = 0;
@@ -98,11 +98,11 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, 
Qcow2Cache *c, int i)
         return 0;
     }
 
-    trace_qcow2_cache_entry_flush(qemu_coroutine_self(),
+    trace_block_cache_entry_flush(qemu_coroutine_self(),
                                   c == s->l2_table_cache, i);
 
     if (c->depends) {
-        ret = qcow2_cache_flush_dependency(bs, c);
+        ret = block_cache_flush_dependency(bs, c);
     } else if (c->depends_on_flush) {
         ret = bdrv_flush(bs->file);
         if (ret >= 0) {
@@ -131,17 +131,17 @@ static int qcow2_cache_entry_flush(BlockDriverState *bs, 
Qcow2Cache *c, int i)
     return 0;
 }
 
-int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c)
+int block_cache_flush(BlockDriverState *bs, BlockCache *c)
 {
     BDRVQcowState *s = bs->opaque;
     int result = 0;
     int ret;
     int i;
 
-    trace_qcow2_cache_flush(qemu_coroutine_self(), c == s->l2_table_cache);
+    trace_block_cache_flush(qemu_coroutine_self(), c == s->l2_table_cache);
 
     for (i = 0; i < c->size; i++) {
-        ret = qcow2_cache_entry_flush(bs, c, i);
+        ret = block_cache_entry_flush(bs, c, i);
         if (ret < 0 && result != -ENOSPC) {
             result = ret;
         }
@@ -157,20 +157,20 @@ int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c)
     return result;
 }
 
-int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c,
-    Qcow2Cache *dependency)
+int block_cache_set_dependency(BlockDriverState *bs, BlockCache *c,
+    BlockCache *dependency)
 {
     int ret;
 
     if (dependency->depends) {
-        ret = qcow2_cache_flush_dependency(bs, dependency);
+        ret = block_cache_flush_dependency(bs, dependency);
         if (ret < 0) {
             return ret;
         }
     }
 
     if (c->depends && (c->depends != dependency)) {
-        ret = qcow2_cache_flush_dependency(bs, c);
+        ret = block_cache_flush_dependency(bs, c);
         if (ret < 0) {
             return ret;
         }
@@ -180,12 +180,12 @@ int qcow2_cache_set_dependency(BlockDriverState *bs, 
Qcow2Cache *c,
     return 0;
 }
 
-void qcow2_cache_depends_on_flush(Qcow2Cache *c)
+void block_cache_depends_on_flush(BlockCache *c)
 {
     c->depends_on_flush = true;
 }
 
-static int qcow2_cache_find_entry_to_replace(Qcow2Cache *c)
+static int block_cache_find_entry_to_replace(BlockCache *c)
 {
     int i;
     int min_count = INT_MAX;
@@ -215,14 +215,14 @@ static int qcow2_cache_find_entry_to_replace(Qcow2Cache 
*c)
     return min_index;
 }
 
-static int qcow2_cache_do_get(BlockDriverState *bs, Qcow2Cache *c,
+static int block_cache_do_get(BlockDriverState *bs, BlockCache *c,
     uint64_t offset, void **table, bool read_from_disk)
 {
     BDRVQcowState *s = bs->opaque;
     int i;
     int ret;
 
-    trace_qcow2_cache_get(qemu_coroutine_self(), c == s->l2_table_cache,
+    trace_block_cache_get(qemu_coroutine_self(), c == s->l2_table_cache,
                           offset, read_from_disk);
 
     /* Check if the table is already cached */
@@ -233,19 +233,19 @@ static int qcow2_cache_do_get(BlockDriverState *bs, 
Qcow2Cache *c,
     }
 
     /* If not, write a table back and replace it */
-    i = qcow2_cache_find_entry_to_replace(c);
-    trace_qcow2_cache_get_replace_entry(qemu_coroutine_self(),
+    i = block_cache_find_entry_to_replace(c);
+    trace_block_cache_get_replace_entry(qemu_coroutine_self(),
                                         c == s->l2_table_cache, i);
     if (i < 0) {
         return i;
     }
 
-    ret = qcow2_cache_entry_flush(bs, c, i);
+    ret = block_cache_entry_flush(bs, c, i);
     if (ret < 0) {
         return ret;
     }
 
-    trace_qcow2_cache_get_read(qemu_coroutine_self(),
+    trace_block_cache_get_read(qemu_coroutine_self(),
                                c == s->l2_table_cache, i);
     c->entries[i].offset = 0;
     if (read_from_disk) {
@@ -270,25 +270,25 @@ found:
     c->entries[i].ref++;
     *table = c->entries[i].table;
 
-    trace_qcow2_cache_get_done(qemu_coroutine_self(),
+    trace_block_cache_get_done(qemu_coroutine_self(),
                                c == s->l2_table_cache, i);
 
     return 0;
 }
 
-int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
+int block_cache_get(BlockDriverState *bs, BlockCache *c, uint64_t offset,
     void **table)
 {
-    return qcow2_cache_do_get(bs, c, offset, table, true);
+    return block_cache_do_get(bs, c, offset, table, true);
 }
 
-int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
+int block_cache_get_empty(BlockDriverState *bs, BlockCache *c, uint64_t offset,
     void **table)
 {
-    return qcow2_cache_do_get(bs, c, offset, table, false);
+    return block_cache_do_get(bs, c, offset, table, false);
 }
 
-int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table)
+int block_cache_put(BlockDriverState *bs, BlockCache *c, void **table)
 {
     int i;
 
@@ -307,7 +307,7 @@ found:
     return 0;
 }
 
-void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table)
+void block_cache_entry_mark_dirty(BlockCache *c, void *table)
 {
     int i;
 
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index cca76d4..3b19d33 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -75,7 +75,7 @@ int qcow2_grow_l1_table(BlockDriverState *bs, uint64_t 
min_size,
         return new_l1_table_offset;
     }
 
-    ret = qcow2_cache_flush(bs, s->refcount_block_cache);
+    ret = block_cache_flush(bs, s->refcount_block_cache);
     if (ret < 0) {
         goto fail;
     }
@@ -127,7 +127,7 @@ static int l2_load(BlockDriverState *bs, uint64_t l2_offset,
     BDRVQcowState *s = bs->opaque;
     int ret;
 
-    ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table);
+    ret = block_cache_get(bs, s->l2_table_cache, l2_offset, (void**) l2_table);
 
     return ret;
 }
@@ -188,7 +188,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, 
uint64_t **table)
         return l2_offset;
     }
 
-    ret = qcow2_cache_flush(bs, s->refcount_block_cache);
+    ret = block_cache_flush(bs, s->refcount_block_cache);
     if (ret < 0) {
         goto fail;
     }
@@ -196,7 +196,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, 
uint64_t **table)
     /* allocate a new entry in the l2 cache */
 
     trace_qcow2_l2_allocate_get_empty(bs, l1_index);
-    ret = qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) 
table);
+    ret = block_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) 
table);
     if (ret < 0) {
         return ret;
     }
@@ -211,7 +211,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, 
uint64_t **table)
 
         /* if there was an old l2 table, read it from the disk */
         BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_COW_READ);
-        ret = qcow2_cache_get(bs, s->l2_table_cache,
+        ret = block_cache_get(bs, s->l2_table_cache,
             old_l2_offset & L1E_OFFSET_MASK,
             (void**) &old_table);
         if (ret < 0) {
@@ -220,7 +220,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, 
uint64_t **table)
 
         memcpy(l2_table, old_table, s->cluster_size);
 
-        ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &old_table);
+        ret = block_cache_put(bs, s->l2_table_cache, (void**) &old_table);
         if (ret < 0) {
             goto fail;
         }
@@ -230,8 +230,8 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, 
uint64_t **table)
     BLKDBG_EVENT(bs->file, BLKDBG_L2_ALLOC_WRITE);
 
     trace_qcow2_l2_allocate_write_l2(bs, l1_index);
-    qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
-    ret = qcow2_cache_flush(bs, s->l2_table_cache);
+    block_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
+    ret = block_cache_flush(bs, s->l2_table_cache);
     if (ret < 0) {
         goto fail;
     }
@@ -250,7 +250,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, 
uint64_t **table)
 
 fail:
     trace_qcow2_l2_allocate_done(bs, l1_index, ret);
-    qcow2_cache_put(bs, s->l2_table_cache, (void**) table);
+    block_cache_put(bs, s->l2_table_cache, (void**) table);
     s->l1_table[l1_index] = old_l2_offset;
     return ret;
 }
@@ -486,7 +486,7 @@ int qcow2_get_cluster_offset(BlockDriverState *bs, uint64_t 
offset,
         abort();
     }
 
-    qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
 
     nb_available = (c * s->cluster_sectors);
 
@@ -597,13 +597,13 @@ uint64_t 
qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
      * allocated. */
     cluster_offset = be64_to_cpu(l2_table[l2_index]);
     if (cluster_offset & L2E_OFFSET_MASK) {
-        qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+        block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
         return 0;
     }
 
     cluster_offset = qcow2_alloc_bytes(bs, compressed_size);
     if (cluster_offset < 0) {
-        qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+        block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
         return 0;
     }
 
@@ -618,9 +618,9 @@ uint64_t 
qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
     /* compressed clusters never have the copied flag */
 
     BLKDBG_EVENT(bs->file, BLKDBG_L2_UPDATE_COMPRESSED);
-    qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
+    block_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
     l2_table[l2_index] = cpu_to_be64(cluster_offset);
-    ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    ret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     if (ret < 0) {
         return 0;
     }
@@ -652,7 +652,7 @@ static int perform_cow(BlockDriverState *bs, QCowL2Meta *m, 
Qcow2COWRegion *r)
      * need to be sure that the refcounts have been increased and COW was
      * handled.
      */
-    qcow2_cache_depends_on_flush(s->l2_table_cache);
+    block_cache_depends_on_flush(s->l2_table_cache);
 
     return 0;
 }
@@ -685,7 +685,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, 
QCowL2Meta *m)
         qcow2_mark_dirty(bs);
     }
     if (qcow2_need_accurate_refcounts(s)) {
-        qcow2_cache_set_dependency(bs, s->l2_table_cache,
+        block_cache_set_dependency(bs, s->l2_table_cache,
                                    s->refcount_block_cache);
     }
 
@@ -693,7 +693,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, 
QCowL2Meta *m)
     if (ret < 0) {
         goto err;
     }
-    qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
+    block_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
 
     for (i = 0; i < m->nb_clusters; i++) {
         /* if two concurrent writes happen to the same unallocated cluster
@@ -710,7 +710,7 @@ int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, 
QCowL2Meta *m)
      }
 
 
-    ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    ret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     if (ret < 0) {
         goto err;
     }
@@ -923,7 +923,7 @@ static int handle_copied(BlockDriverState *bs, uint64_t 
guest_offset,
 
     /* Cleanup */
 out:
-    pret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    pret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     if (pret < 0) {
         return pret;
     }
@@ -1051,7 +1051,7 @@ static int handle_alloc(BlockDriverState *bs, uint64_t 
guest_offset,
      * wrong with our code. */
     assert(nb_clusters > 0);
 
-    ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    ret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     if (ret < 0) {
         return ret;
     }
@@ -1342,14 +1342,14 @@ static int discard_single_l2(BlockDriverState *bs, 
uint64_t offset,
         }
 
         /* First remove L2 entries */
-        qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
+        block_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
         l2_table[l2_index + i] = cpu_to_be64(0);
 
         /* Then decrease the refcount */
         qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
     }
 
-    ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    ret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     if (ret < 0) {
         return ret;
     }
@@ -1426,7 +1426,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t 
offset,
         old_offset = be64_to_cpu(l2_table[l2_index + i]);
 
         /* Update L2 entries */
-        qcow2_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
+        block_cache_entry_mark_dirty(s->l2_table_cache, l2_table);
         if (old_offset & QCOW_OFLAG_COMPRESSED) {
             l2_table[l2_index + i] = cpu_to_be64(QCOW_OFLAG_ZERO);
             qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
@@ -1435,7 +1435,7 @@ static int zero_single_l2(BlockDriverState *bs, uint64_t 
offset,
         }
     }
 
-    ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+    ret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     if (ret < 0) {
         return ret;
     }
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index 1244693..5eb698a 100644
--- a/block/qcow2-refcount.c
+++ b/block/qcow2-refcount.c
@@ -71,7 +71,7 @@ static int load_refcount_block(BlockDriverState *bs,
     int ret;
 
     BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_LOAD);
-    ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
+    ret = block_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
         refcount_block);
 
     return ret;
@@ -98,7 +98,7 @@ static int get_refcount(BlockDriverState *bs, int64_t 
cluster_index)
     if (!refcount_block_offset)
         return 0;
 
-    ret = qcow2_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
+    ret = block_cache_get(bs, s->refcount_block_cache, refcount_block_offset,
         (void**) &refcount_block);
     if (ret < 0) {
         return ret;
@@ -108,7 +108,7 @@ static int get_refcount(BlockDriverState *bs, int64_t 
cluster_index)
         ((1 << (s->cluster_bits - REFCOUNT_SHIFT)) - 1);
     refcount = be16_to_cpu(refcount_block[block_index]);
 
-    ret = qcow2_cache_put(bs, s->refcount_block_cache,
+    ret = block_cache_put(bs, s->refcount_block_cache,
         (void**) &refcount_block);
     if (ret < 0) {
         return ret;
@@ -201,7 +201,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
     *refcount_block = NULL;
 
     /* We write to the refcount table, so we might depend on L2 tables */
-    ret = qcow2_cache_flush(bs, s->l2_table_cache);
+    ret = block_cache_flush(bs, s->l2_table_cache);
     if (ret < 0) {
         return ret;
     }
@@ -220,7 +220,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
 
     if (in_same_refcount_block(s, new_block, cluster_index << 
s->cluster_bits)) {
         /* Zero the new refcount block before updating it */
-        ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
+        ret = block_cache_get_empty(bs, s->refcount_block_cache, new_block,
             (void**) refcount_block);
         if (ret < 0) {
             goto fail_block;
@@ -241,14 +241,14 @@ static int alloc_refcount_block(BlockDriverState *bs,
             goto fail_block;
         }
 
-        ret = qcow2_cache_flush(bs, s->refcount_block_cache);
+        ret = block_cache_flush(bs, s->refcount_block_cache);
         if (ret < 0) {
             goto fail_block;
         }
 
         /* Initialize the new refcount block only after updating its refcount,
          * update_refcount uses the refcount cache itself */
-        ret = qcow2_cache_get_empty(bs, s->refcount_block_cache, new_block,
+        ret = block_cache_get_empty(bs, s->refcount_block_cache, new_block,
             (void**) refcount_block);
         if (ret < 0) {
             goto fail_block;
@@ -259,8 +259,8 @@ static int alloc_refcount_block(BlockDriverState *bs,
 
     /* Now the new refcount block needs to be written to disk */
     BLKDBG_EVENT(bs->file, BLKDBG_REFBLOCK_ALLOC_WRITE);
-    qcow2_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block);
-    ret = qcow2_cache_flush(bs, s->refcount_block_cache);
+    block_cache_entry_mark_dirty(s->refcount_block_cache, *refcount_block);
+    ret = block_cache_flush(bs, s->refcount_block_cache);
     if (ret < 0) {
         goto fail_block;
     }
@@ -280,7 +280,7 @@ static int alloc_refcount_block(BlockDriverState *bs,
         return 0;
     }
 
-    ret = qcow2_cache_put(bs, s->refcount_block_cache, (void**) 
refcount_block);
+    ret = block_cache_put(bs, s->refcount_block_cache, (void**) 
refcount_block);
     if (ret < 0) {
         goto fail_block;
     }
@@ -415,7 +415,7 @@ fail_table:
     g_free(new_table);
 fail_block:
     if (*refcount_block != NULL) {
-        qcow2_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
+        block_cache_put(bs, s->refcount_block_cache, (void**) refcount_block);
     }
     return ret;
 }
@@ -509,7 +509,7 @@ static int QEMU_WARN_UNUSED_RESULT 
update_refcount(BlockDriverState *bs,
     }
 
     if (addend < 0) {
-        qcow2_cache_set_dependency(bs, s->refcount_block_cache,
+        block_cache_set_dependency(bs, s->refcount_block_cache,
             s->l2_table_cache);
     }
 
@@ -526,7 +526,7 @@ static int QEMU_WARN_UNUSED_RESULT 
update_refcount(BlockDriverState *bs,
         /* Load the refcount block and allocate it if needed */
         if (table_index != old_table_index) {
             if (refcount_block) {
-                ret = qcow2_cache_put(bs, s->refcount_block_cache,
+                ret = block_cache_put(bs, s->refcount_block_cache,
                     (void**) &refcount_block);
                 if (ret < 0) {
                     goto fail;
@@ -540,7 +540,7 @@ static int QEMU_WARN_UNUSED_RESULT 
update_refcount(BlockDriverState *bs,
         }
         old_table_index = table_index;
 
-        qcow2_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);
+        block_cache_entry_mark_dirty(s->refcount_block_cache, refcount_block);
 
         /* we can update the count and save it */
         block_index = cluster_index &
@@ -571,7 +571,7 @@ fail:
     /* Write last changed block to disk */
     if (refcount_block) {
         int wret;
-        wret = qcow2_cache_put(bs, s->refcount_block_cache,
+        wret = block_cache_put(bs, s->refcount_block_cache,
             (void**) &refcount_block);
         if (wret < 0) {
             return ret < 0 ? ret : wret;
@@ -755,7 +755,7 @@ int64_t qcow2_alloc_bytes(BlockDriverState *bs, int size)
      * or explicitly by update_cluster_refcount().  Refcount blocks must be
      * flushed before the caller's L2 table updates.
      */
-    qcow2_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);
+    block_cache_set_dependency(bs, s->l2_table_cache, s->refcount_block_cache);
     return offset;
 }
 
@@ -854,7 +854,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
             old_l2_offset = l2_offset;
             l2_offset &= L1E_OFFSET_MASK;
 
-            ret = qcow2_cache_get(bs, s->l2_table_cache, l2_offset,
+            ret = block_cache_get(bs, s->l2_table_cache, l2_offset,
                 (void**) &l2_table);
             if (ret < 0) {
                 goto fail;
@@ -900,16 +900,16 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
                     }
                     if (offset != old_offset) {
                         if (addend > 0) {
-                            qcow2_cache_set_dependency(bs, s->l2_table_cache,
+                            block_cache_set_dependency(bs, s->l2_table_cache,
                                 s->refcount_block_cache);
                         }
                         l2_table[j] = cpu_to_be64(offset);
-                        qcow2_cache_entry_mark_dirty(s->l2_table_cache, 
l2_table);
+                        block_cache_entry_mark_dirty(s->l2_table_cache, 
l2_table);
                     }
                 }
             }
 
-            ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+            ret = block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
             if (ret < 0) {
                 goto fail;
             }
@@ -937,7 +937,7 @@ int qcow2_update_snapshot_refcount(BlockDriverState *bs,
     ret = bdrv_flush(bs);
 fail:
     if (l2_table) {
-        qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
+        block_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
     }
 
     s->cache_discards = false;
diff --git a/block/qcow2.c b/block/qcow2.c
index b876d96..a93df45 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -470,8 +470,8 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, 
int flags)
     }
 
     /* alloc L2 table/refcount block cache */
-    s->l2_table_cache = qcow2_cache_create(bs, L2_CACHE_SIZE);
-    s->refcount_block_cache = qcow2_cache_create(bs, REFCOUNT_CACHE_SIZE);
+    s->l2_table_cache = block_cache_create(bs, L2_CACHE_SIZE);
+    s->refcount_block_cache = block_cache_create(bs, REFCOUNT_CACHE_SIZE);
 
     s->cluster_cache = g_malloc(s->cluster_size);
     /* one more sector for decompressed data alignment */
@@ -583,7 +583,7 @@ static int qcow2_open(BlockDriverState *bs, QDict *options, 
int flags)
     qcow2_refcount_close(bs);
     g_free(s->l1_table);
     if (s->l2_table_cache) {
-        qcow2_cache_destroy(bs, s->l2_table_cache);
+        block_cache_destroy(bs, s->l2_table_cache);
     }
     g_free(s->cluster_cache);
     qemu_vfree(s->cluster_data);
@@ -948,13 +948,13 @@ static void qcow2_close(BlockDriverState *bs)
     BDRVQcowState *s = bs->opaque;
     g_free(s->l1_table);
 
-    qcow2_cache_flush(bs, s->l2_table_cache);
-    qcow2_cache_flush(bs, s->refcount_block_cache);
+    block_cache_flush(bs, s->l2_table_cache);
+    block_cache_flush(bs, s->refcount_block_cache);
 
     qcow2_mark_clean(bs);
 
-    qcow2_cache_destroy(bs, s->l2_table_cache);
-    qcow2_cache_destroy(bs, s->refcount_block_cache);
+    block_cache_destroy(bs, s->l2_table_cache);
+    block_cache_destroy(bs, s->refcount_block_cache);
 
     g_free(s->unknown_header_fields);
     cleanup_unknown_header_ext(bs);
@@ -1659,14 +1659,14 @@ static coroutine_fn int 
qcow2_co_flush_to_os(BlockDriverState *bs)
     int ret;
 
     qemu_co_mutex_lock(&s->lock);
-    ret = qcow2_cache_flush(bs, s->l2_table_cache);
+    ret = block_cache_flush(bs, s->l2_table_cache);
     if (ret < 0) {
         qemu_co_mutex_unlock(&s->lock);
         return ret;
     }
 
     if (qcow2_need_accurate_refcounts(s)) {
-        ret = qcow2_cache_flush(bs, s->refcount_block_cache);
+        ret = block_cache_flush(bs, s->refcount_block_cache);
         if (ret < 0) {
             qemu_co_mutex_unlock(&s->lock);
             return ret;
diff --git a/block/qcow2.h b/block/qcow2.h
index dba9771..ed25806 100644
--- a/block/qcow2.h
+++ b/block/qcow2.h
@@ -100,8 +100,8 @@ typedef struct QCowSnapshot {
     uint64_t vm_clock_nsec;
 } QCowSnapshot;
 
-struct Qcow2Cache;
-typedef struct Qcow2Cache Qcow2Cache;
+struct BlockCache;
+typedef struct BlockCache BlockCache;
 
 typedef struct Qcow2UnknownHeaderExtension {
     uint32_t magic;
@@ -168,8 +168,8 @@ typedef struct BDRVQcowState {
     uint64_t l1_table_offset;
     uint64_t *l1_table;
 
-    Qcow2Cache* l2_table_cache;
-    Qcow2Cache* refcount_block_cache;
+    BlockCache* l2_table_cache;
+    BlockCache* refcount_block_cache;
 
     uint8_t *cluster_cache;
     uint8_t *cluster_data;
@@ -419,19 +419,19 @@ void qcow2_free_snapshots(BlockDriverState *bs);
 int qcow2_read_snapshots(BlockDriverState *bs);
 
 /* qcow2-cache.c functions */
-Qcow2Cache *qcow2_cache_create(BlockDriverState *bs, int num_tables);
-int qcow2_cache_destroy(BlockDriverState* bs, Qcow2Cache *c);
+BlockCache *block_cache_create(BlockDriverState *bs, int num_tables);
+int block_cache_destroy(BlockDriverState* bs, BlockCache *c);
 
-void qcow2_cache_entry_mark_dirty(Qcow2Cache *c, void *table);
-int qcow2_cache_flush(BlockDriverState *bs, Qcow2Cache *c);
-int qcow2_cache_set_dependency(BlockDriverState *bs, Qcow2Cache *c,
-    Qcow2Cache *dependency);
-void qcow2_cache_depends_on_flush(Qcow2Cache *c);
+void block_cache_entry_mark_dirty(BlockCache *c, void *table);
+int block_cache_flush(BlockDriverState *bs, BlockCache *c);
+int block_cache_set_dependency(BlockDriverState *bs, BlockCache *c,
+    BlockCache *dependency);
+void block_cache_depends_on_flush(BlockCache *c);
 
-int qcow2_cache_get(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
+int block_cache_get(BlockDriverState *bs, BlockCache *c, uint64_t offset,
     void **table);
-int qcow2_cache_get_empty(BlockDriverState *bs, Qcow2Cache *c, uint64_t offset,
+int block_cache_get_empty(BlockDriverState *bs, BlockCache *c, uint64_t offset,
     void **table);
-int qcow2_cache_put(BlockDriverState *bs, Qcow2Cache *c, void **table);
+int block_cache_put(BlockDriverState *bs, BlockCache *c, void **table);
 
 #endif
diff --git a/trace-events b/trace-events
index 3856b5c..77ed487 100644
--- a/trace-events
+++ b/trace-events
@@ -514,12 +514,12 @@ qcow2_l2_allocate_write_l1(void *bs, int l1_index) "bs %p 
l1_index %d"
 qcow2_l2_allocate_done(void *bs, int l1_index, int ret) "bs %p l1_index %d ret 
%d"
 
 # block/qcow2-cache.c
-qcow2_cache_get(void *co, int c, uint64_t offset, bool read_from_disk) "co %p 
is_l2_cache %d offset %" PRIx64 " read_from_disk %d"
-qcow2_cache_get_replace_entry(void *co, int c, int i) "co %p is_l2_cache %d 
index %d"
-qcow2_cache_get_read(void *co, int c, int i) "co %p is_l2_cache %d index %d"
-qcow2_cache_get_done(void *co, int c, int i) "co %p is_l2_cache %d index %d"
-qcow2_cache_flush(void *co, int c) "co %p is_l2_cache %d"
-qcow2_cache_entry_flush(void *co, int c, int i) "co %p is_l2_cache %d index %d"
+block_cache_get(void *co, int c, uint64_t offset, bool read_from_disk) "co %p 
is_l2_cache %d offset %" PRIx64 " read_from_disk %d"
+block_cache_get_replace_entry(void *co, int c, int i) "co %p is_l2_cache %d 
index %d"
+block_cache_get_read(void *co, int c, int i) "co %p is_l2_cache %d index %d"
+block_cache_get_done(void *co, int c, int i) "co %p is_l2_cache %d index %d"
+block_cache_flush(void *co, int c) "co %p is_l2_cache %d"
+block_cache_entry_flush(void *co, int c, int i) "co %p is_l2_cache %d index %d"
 
 # block/qed-l2-cache.c
 qed_alloc_l2_cache_entry(void *l2_cache, void *entry) "l2_cache %p entry %p"
-- 
1.7.11.7


Reply via email to