Blame 0101-qcow2-Pass-discard-type-to-qcow2_discard_clusters.patch

298366
From 411a7e4ad457f7f3c9f1d02ef9f726ce13a35f08 Mon Sep 17 00:00:00 2001
298366
From: Kevin Wolf <kwolf@redhat.com>
298366
Date: Fri, 6 Sep 2013 12:32:25 +0200
298366
Subject: [PATCH] qcow2: Pass discard type to qcow2_discard_clusters()
298366
298366
The function will be used internally instead of only being called for
298366
guest discard requests.
298366
298366
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
298366
---
298366
 block/qcow2-cluster.c | 8 ++++----
298366
 block/qcow2.c         | 2 +-
298366
 block/qcow2.h         | 2 +-
298366
 3 files changed, 6 insertions(+), 6 deletions(-)
298366
298366
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
298366
index cca76d4..8c3185d 100644
298366
--- a/block/qcow2-cluster.c
298366
+++ b/block/qcow2-cluster.c
298366
@@ -1317,7 +1317,7 @@ int qcow2_decompress_cluster(BlockDriverState *bs, uint64_t cluster_offset)
298366
  * clusters.
298366
  */
298366
 static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
298366
-    unsigned int nb_clusters)
298366
+    unsigned int nb_clusters, enum qcow2_discard_type type)
298366
 {
298366
     BDRVQcowState *s = bs->opaque;
298366
     uint64_t *l2_table;
298366
@@ -1346,7 +1346,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
298366
         l2_table[l2_index + i] = cpu_to_be64(0);
298366
 
298366
         /* Then decrease the refcount */
298366
-        qcow2_free_any_clusters(bs, old_offset, 1, QCOW2_DISCARD_REQUEST);
298366
+        qcow2_free_any_clusters(bs, old_offset, 1, type);
298366
     }
298366
 
298366
     ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table);
298366
@@ -1358,7 +1358,7 @@ static int discard_single_l2(BlockDriverState *bs, uint64_t offset,
298366
 }
298366
 
298366
 int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset,
298366
-    int nb_sectors)
298366
+    int nb_sectors, enum qcow2_discard_type type)
298366
 {
298366
     BDRVQcowState *s = bs->opaque;
298366
     uint64_t end_offset;
298366
@@ -1381,7 +1381,7 @@ int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset,
298366
 
298366
     /* Each L2 table is handled by its own loop iteration */
298366
     while (nb_clusters > 0) {
298366
-        ret = discard_single_l2(bs, offset, nb_clusters);
298366
+        ret = discard_single_l2(bs, offset, nb_clusters, type);
298366
         if (ret < 0) {
298366
             goto fail;
298366
         }
298366
diff --git a/block/qcow2.c b/block/qcow2.c
298366
index 7f7282e..16e45a0 100644
298366
--- a/block/qcow2.c
298366
+++ b/block/qcow2.c
298366
@@ -1506,7 +1506,7 @@ static coroutine_fn int qcow2_co_discard(BlockDriverState *bs,
298366
 
298366
     qemu_co_mutex_lock(&s->lock);
298366
     ret = qcow2_discard_clusters(bs, sector_num << BDRV_SECTOR_BITS,
298366
-        nb_sectors);
298366
+        nb_sectors, QCOW2_DISCARD_REQUEST);
298366
     qemu_co_mutex_unlock(&s->lock);
298366
     return ret;
298366
 }
298366
diff --git a/block/qcow2.h b/block/qcow2.h
298366
index dba9771..52cf193 100644
298366
--- a/block/qcow2.h
298366
+++ b/block/qcow2.h
298366
@@ -405,7 +405,7 @@ uint64_t qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
298366
 
298366
 int qcow2_alloc_cluster_link_l2(BlockDriverState *bs, QCowL2Meta *m);
298366
 int qcow2_discard_clusters(BlockDriverState *bs, uint64_t offset,
298366
-    int nb_sectors);
298366
+    int nb_sectors, enum qcow2_discard_type type);
298366
 int qcow2_zero_clusters(BlockDriverState *bs, uint64_t offset, int nb_sectors);
298366
 
298366
 /* qcow2-snapshot.c functions */