[PATCH v6 03/12] block/qcow2-cluster: assert no data_file on compressed write path

Vladimir Sementsov-Ogievskiy posted 12 patches 4 years, 9 months ago
Maintainers: Max Reitz <mreitz@redhat.com>, Kevin Wolf <kwolf@redhat.com>
There is a newer version of this series
[PATCH v6 03/12] block/qcow2-cluster: assert no data_file on compressed write path
Posted by Vladimir Sementsov-Ogievskiy 4 years, 9 months ago
First, we return 0 here, but it's not a success, we didn't set
host_offset out parameter.

Next, it can't happen, as has_data_file() is checked in
qcow2_co_pwritev_compressed_part(). So, let's just assert it.

Signed-off-by: Vladimir Sementsov-Ogievskiy <vsementsov@virtuozzo.com>
---
 block/qcow2-cluster.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index bd0597842f..6105d4e7e0 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -821,9 +821,7 @@ int qcow2_alloc_compressed_cluster_offset(BlockDriverState *bs,
     int64_t cluster_offset;
     int nb_csectors;
 
-    if (has_data_file(bs)) {
-        return 0;
-    }
+    assert(!has_data_file(bs));
 
     ret = get_cluster_table(bs, offset, &l2_slice, &l2_index);
     if (ret < 0) {
-- 
2.29.2