[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 03/17] block: add discard properties to BlockDri
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [RFC PATCH 03/17] block: add discard properties to BlockDriverInfo |
Date: |
Thu, 8 Mar 2012 18:15:03 +0100 |
In the next patches we will declare the guest's semantics for discard
to be "always zero the data". We need to know whether the operation
need to be emulated or can be passed down. For this purpose we need
to know the semantics of the operation and its granularity.
The granularity may not be related to the cluster size (for example
"raw" does not have a cluster size), so add it separately.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block.h | 4 ++++
block/qcow2.c | 2 ++
qemu-io.c | 5 ++++-
3 files changed, 10 insertions(+), 1 deletions(-)
diff --git a/block.h b/block.h
index 48d0bf3..7feda73 100644
--- a/block.h
+++ b/block.h
@@ -15,6 +15,10 @@ typedef struct BlockDriverInfo {
int cluster_size;
/* offset at which the VM state can be saved (0 if not possible) */
int64_t vm_state_offset;
+ /* whether discard is guaranteed to zero bytes */
+ bool discard_zeroes_data;
+ /* discard granularity in sectors */
+ int discard_granularity;
} BlockDriverInfo;
typedef struct QEMUSnapshotInfo {
diff --git a/block/qcow2.c b/block/qcow2.c
index eb5ea48..2908484 100644
--- a/block/qcow2.c
+++ b/block/qcow2.c
@@ -1256,6 +1256,8 @@ static int qcow2_get_info(BlockDriverState *bs,
BlockDriverInfo *bdi)
BDRVQcowState *s = bs->opaque;
bdi->cluster_size = s->cluster_size;
bdi->vm_state_offset = qcow2_vm_state_offset(s);
+ bdi->discard_zeroes_data = (bs->backing_hd == NULL);
+ bdi->discard_granularity = s->cluster_size / BDRV_SECTOR_SIZE;
return 0;
}
diff --git a/qemu-io.c b/qemu-io.c
index 3189530..8f28b6a 100644
--- a/qemu-io.c
+++ b/qemu-io.c
@@ -1437,7 +1437,7 @@ static const cmdinfo_t length_cmd = {
static int info_f(int argc, char **argv)
{
BlockDriverInfo bdi;
- char s1[64], s2[64];
+ char s1[64], s2[64], s3[64];
int ret;
if (bs->drv && bs->drv->format_name) {
@@ -1454,9 +1454,12 @@ static int info_f(int argc, char **argv)
cvtstr(bdi.cluster_size, s1, sizeof(s1));
cvtstr(bdi.vm_state_offset, s2, sizeof(s2));
+ cvtstr(bdi.discard_granularity * BDRV_SECTOR_SIZE, s3, sizeof(s3));
printf("cluster size: %s\n", s1);
printf("vm state offset: %s\n", s2);
+ printf("discard zeroes: %s\n", bdi.discard_zeroes_data ? "yes" : "no");
+ printf("discard granularity: %s\n", s3);
return 0;
}
--
1.7.7.6
- [Qemu-devel] [RFC PATCH 00/17] Improvements around discard and write zeroes, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 02/17] qed: make write-zeroes bounce buffer smaller than a single cluster, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 03/17] block: add discard properties to BlockDriverInfo,
Paolo Bonzini <=
- [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Paolo Bonzini, 2012/03/08
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Kevin Wolf, 2012/03/09
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Paolo Bonzini, 2012/03/09
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Richard Laager, 2012/03/10
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Paolo Bonzini, 2012/03/12
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Kevin Wolf, 2012/03/12
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Richard Laager, 2012/03/13
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Paolo Bonzini, 2012/03/14
- Re: [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Kevin Wolf, 2012/03/14