[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC PATCH 10/17] ide/scsi: add discard_zeroes_data propert
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [RFC PATCH 10/17] ide/scsi: add discard_zeroes_data property |
Date: |
Thu, 8 Mar 2012 18:15:10 +0100 |
Now that the block layer guarantees stable semantics for discard,
we can expose them to guests.
Signed-off-by: Paolo Bonzini <address@hidden>
---
block.h | 7 +++++--
hw/ide/core.c | 6 +++++-
hw/scsi-disk.c | 5 ++++-
3 files changed, 14 insertions(+), 4 deletions(-)
diff --git a/block.h b/block.h
index ef07bb0..e28321e 100644
--- a/block.h
+++ b/block.h
@@ -423,6 +423,7 @@ typedef struct BlockConf {
uint32_t opt_io_size;
int32_t bootindex;
uint32_t discard_granularity;
+ uint32_t discard_zeroes_data;
} BlockConf;
static inline unsigned int get_physical_block_exp(BlockConf *conf)
@@ -444,10 +445,12 @@ static inline unsigned int
get_physical_block_exp(BlockConf *conf)
_conf.logical_block_size, 512), \
DEFINE_PROP_UINT16("physical_block_size", _state, \
_conf.physical_block_size, 512), \
- DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \
+ DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \
DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \
DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1), \
- DEFINE_PROP_UINT32("discard_granularity", _state, \
+ DEFINE_PROP_BIT("discard_zeroes_data", _state, \
+ _conf.discard_zeroes_data, 0, false), \
+ DEFINE_PROP_UINT32("discard_granularity", _state, \
_conf.discard_granularity, 0)
#endif
diff --git a/hw/ide/core.c b/hw/ide/core.c
index f12470e..1530b61 100644
--- a/hw/ide/core.c
+++ b/hw/ide/core.c
@@ -128,7 +128,11 @@ static void ide_identify(IDEState *s)
put_le16(p + 67, 120);
put_le16(p + 68, 120);
if (dev && dev->conf.discard_granularity) {
- put_le16(p + 69, (1 << 14)); /* determinate TRIM behavior */
+ int val;
+
+ val = 0x4000;
+ val |= dev->conf.discard_zeroes_data ? 0x20 : 0;
+ put_le16(p + 69, val); /* determinate TRIM behavior */
}
if (s->ncq_queues) {
diff --git a/hw/scsi-disk.c b/hw/scsi-disk.c
index add399e..f489078 100644
--- a/hw/scsi-disk.c
+++ b/hw/scsi-disk.c
@@ -1295,8 +1295,11 @@ static int scsi_disk_emulate_command(SCSIDiskReq *r)
outbuf[13] = get_physical_block_exp(&s->qdev.conf);
/* set TPE bit if the format supports discard */
- if (s->qdev.conf.discard_granularity) {
+ if (s->qdev.type == TYPE_DISK && s->qdev.conf.discard_granularity)
{
outbuf[14] = 0x80;
+ if (s->qdev.conf.discard_zeroes_data) {
+ outbuf[14] |= 0x40;
+ }
}
/* Protection, exponent and lowest lba field left blank. */
--
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, 2012/03/08
- [Qemu-devel] [RFC PATCH 06/17] block: use bdrv_{co, aio}_discard for write_zeroes operations, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 04/17] qed: implement bdrv_aio_discard, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 10/17] ide/scsi: add discard_zeroes_data property,
Paolo Bonzini <=
- [Qemu-devel] [RFC PATCH 09/17] ide: issue discard asynchronously but serialize the pieces, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 05/17] block: pass around qiov for write_zeroes operation, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 12/17] ide/scsi: turn on discard, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 01/17] qemu-iotests: add a simple test for write_zeroes, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 11/17] ide/scsi: prepare for flipping the discard defaults, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 16/17] qemu-io: fix the alloc command, Paolo Bonzini, 2012/03/08
- [Qemu-devel] [RFC PATCH 07/17] block: make high level discard operation always zero, Paolo Bonzini, 2012/03/08