qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v2 08/20] block drivers: add discard/write_zeroe


From: Peter Lieven
Subject: Re: [Qemu-devel] [PATCH v2 08/20] block drivers: add discard/write_zeroes properties to bdrv_get_info implementation
Date: Thu, 21 Nov 2013 12:33:04 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.1.0

On 19.11.2013 18:07, Paolo Bonzini wrote:
Signed-off-by: Paolo Bonzini <address@hidden>
---
  block/qcow2.c | 2 ++
  block/qed.c   | 2 ++
  block/vdi.c   | 3 +++
  block/vhdx.c  | 3 +++
  block/vpc.c   | 2 ++
  5 files changed, 12 insertions(+)

diff --git a/block/qcow2.c b/block/qcow2.c
index 2fe37ed..92ed895 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1892,6 +1892,8 @@ static coroutine_fn int 
qcow2_co_flush_to_os(BlockDriverState *bs)
  static int qcow2_get_info(BlockDriverState *bs, BlockDriverInfo *bdi)
  {
      BDRVQcowState *s = bs->opaque;
+    bdi->unallocated_blocks_are_zero = (bs->backing_hd == NULL);
+    bdi->can_write_zeroes_with_unmap = (s->qcow_version >= 3);
      bdi->cluster_size = s->cluster_size;
      bdi->vm_state_offset = qcow2_vm_state_offset(s);
      return 0;
diff --git a/block/qed.c b/block/qed.c
index adc2736..1f87420 100644
--- a/block/qed.c
+++ b/block/qed.c
@@ -1475,6 +1475,8 @@ static int bdrv_qed_get_info(BlockDriverState *bs, 
BlockDriverInfo *bdi)
      memset(bdi, 0, sizeof(*bdi));
      bdi->cluster_size = s->header.cluster_size;
      bdi->is_dirty = s->header.features & QED_F_NEED_CHECK;
+    bdi->unallocated_blocks_are_zero = (bs->backing_hd == NULL);
+    bdi->can_write_zeroes_with_unmap = true;
      return 0;
  }
diff --git a/block/vdi.c b/block/vdi.c
index b6ec002..3a05027 100644
--- a/block/vdi.c
+++ b/block/vdi.c
@@ -331,6 +331,9 @@ static int vdi_get_info(BlockDriverState *bs, 
BlockDriverInfo *bdi)
      logout("\n");
      bdi->cluster_size = s->block_size;
      bdi->vm_state_offset = 0;
+
+    /* Backing file not supported yet.  */
+    bdi->unallocated_blocks_are_zero = true;
If its not supported why not checking for

(bs->backing_hd == NULL)

in case its added later and this place is overseen.


      return 0;
  }
diff --git a/block/vhdx.c b/block/vhdx.c
index 9ab2b39..d06585a 100644
--- a/block/vhdx.c
+++ b/block/vhdx.c
@@ -1050,6 +1050,9 @@ static int vhdx_get_info(BlockDriverState *bs, 
BlockDriverInfo *bdi)
      bdi->cluster_size =
          (s->logical_sector_size / BDRV_SECTOR_SIZE) * s->block_size;
+ bdi->unallocated_blocks_are_zero =
+        (s->params.data_bits & VHDX_PARAMS_HAS_PARENT) == 0;
+
      return 0;
  }
diff --git a/block/vpc.c b/block/vpc.c
index 551876f..d6a47ef 100644
--- a/block/vpc.c
+++ b/block/vpc.c
@@ -464,6 +464,8 @@ static int vpc_get_info(BlockDriverState *bs, 
BlockDriverInfo *bdi)
          bdi->cluster_size = s->block_size;
      }
+ /* Backing file not supported yet. */
+    bdi->unallocated_blocks_are_zero = true;
same here.
      return 0;
  }

Peter



reply via email to

[Prev in Thread] Current Thread [Next in Thread]