Patchwork [RFC,12/17] ide/scsi: turn on discard

login
register
mail settings
Submitter Paolo Bonzini
Date March 8, 2012, 5:15 p.m.
Message ID <1331226917-6658-13-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/145595/
State New
Headers show

Comments

Paolo Bonzini - March 8, 2012, 5:15 p.m.
Turn on discard support in the device models by default, with
compatibility properties for older machine types.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 block.h      |    4 +-
 hw/pc_piix.c |  224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 226 insertions(+), 2 deletions(-)
Avi Kivity - March 8, 2012, 6:17 p.m.
On 03/08/2012 07:15 PM, Paolo Bonzini wrote:
> Turn on discard support in the device models by default, with
> compatibility properties for older machine types.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  block.h      |    4 +-
>  hw/pc_piix.c |  224 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  2 files changed, 226 insertions(+), 2 deletions(-)
>
> diff --git a/block.h b/block.h
> index aa224d3..1a8fd2d 100644
> --- a/block.h
> +++ b/block.h
> @@ -449,9 +449,9 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
>      DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0),    \
>      DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1),        \
>      DEFINE_PROP_BIT("discard_zeroes_data", _state,                      \
> -                    _conf.discard_zeroes_data, 0, false),               \
> +                    _conf.discard_zeroes_data, 0, true),                \
>      DEFINE_PROP_INT32("discard_granularity", _state,                    \
> -                      _conf.discard_granularity, 0)
> +                      _conf.discard_granularity, -1)
>  
>  #endif
>  
> diff --git a/hw/pc_piix.c b/hw/pc_piix.c
> index 6c5c40f..0356424 100644
> --- a/hw/pc_piix.c
> +++ b/hw/pc_piix.c
> @@ -381,6 +381,38 @@ static QEMUMachine pc_machine_v1_0 = {
>      .max_cpus = 255,
>      .compat_props = (GlobalProperty[]) {
>          {
> +            .driver   = "ide-drive",
> +            .property = "discard_granularity",
> +            .value    = stringify(0),
> +	}, {
> +            .driver   = "ide-drive",
> +            .property = "discard_zeroes_data",
> +            .value    = "off",
> +	}, {
> +            .driver   = "ide-hd",
> +            .property = "discard_granularity",
> +            .value    = stringify(0),
> +	}, {
> +            .driver   = "ide-hd",
> +            .property = "discard_zeroes_data",
> +            .value    = "off",
> +	}, {
> +            .driver   = "scsi-disk",
> +            .property = "discard_granularity",
> +            .value    = stringify(0),
> +	}, {
> +            .driver   = "scsi-disk",
> +            .property = "discard_zeroes_data",
> +            .value    = "off",
> +	}, {
> +            .driver   = "scsi-hd",
> +            .property = "discard_granularity",
> +            .value    = stringify(0),
> +	}, {
> +            .driver   = "scsi-hd",
> +            .property = "discard_zeroes_data",
> +            .value    = "off",
> +	}, {
>              .driver   = "pc-sysfw",
>              .property = "rom_only",
>              .value    = stringify(1),
> @@ -400,6 +432,38 @@ static QEMUMachine pc_machine_v0_15 = {
>      .max_cpus = 255,
>      .compat_props = (GlobalProperty[]) {
>          {
> +            .driver   = "ide-drive",
> +            .property = "discard_granularity",
> +            .value    = stringify(0),
>

<snip>

We should define machines differentially.  0.15 is 1.0, with the
following differences: { }.

Patch

diff --git a/block.h b/block.h
index aa224d3..1a8fd2d 100644
--- a/block.h
+++ b/block.h
@@ -449,9 +449,9 @@  static inline unsigned int get_physical_block_exp(BlockConf *conf)
     DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0),    \
     DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1),        \
     DEFINE_PROP_BIT("discard_zeroes_data", _state,                      \
-                    _conf.discard_zeroes_data, 0, false),               \
+                    _conf.discard_zeroes_data, 0, true),                \
     DEFINE_PROP_INT32("discard_granularity", _state,                    \
-                      _conf.discard_granularity, 0)
+                      _conf.discard_granularity, -1)
 
 #endif
 
diff --git a/hw/pc_piix.c b/hw/pc_piix.c
index 6c5c40f..0356424 100644
--- a/hw/pc_piix.c
+++ b/hw/pc_piix.c
@@ -381,6 +381,38 @@  static QEMUMachine pc_machine_v1_0 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "pc-sysfw",
             .property = "rom_only",
             .value    = stringify(1),
@@ -400,6 +432,38 @@  static QEMUMachine pc_machine_v0_15 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "pc-sysfw",
             .property = "rom_only",
             .value    = stringify(1),
@@ -419,6 +483,38 @@  static QEMUMachine pc_machine_v0_14 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "qxl",
             .property = "revision",
             .value    = stringify(2),
@@ -463,6 +559,38 @@  static QEMUMachine pc_machine_v0_13 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "virtio-9p-pci",
             .property = "vectors",
             .value    = stringify(0),
@@ -519,6 +647,38 @@  static QEMUMachine pc_machine_v0_12 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "virtio-serial-pci",
             .property = "max_ports",
             .value    = stringify(1),
@@ -579,6 +739,38 @@  static QEMUMachine pc_machine_v0_11 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "virtio-blk-pci",
             .property = "vectors",
             .value    = stringify(0),
@@ -647,6 +839,38 @@  static QEMUMachine pc_machine_v0_10 = {
     .max_cpus = 255,
     .compat_props = (GlobalProperty[]) {
         {
+            .driver   = "ide-drive",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-drive",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "ide-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-disk",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_granularity",
+            .value    = stringify(0),
+	}, {
+            .driver   = "scsi-hd",
+            .property = "discard_zeroes_data",
+            .value    = "off",
+	}, {
             .driver   = "virtio-blk-pci",
             .property = "class",
             .value    = stringify(PCI_CLASS_STORAGE_OTHER),