virtualization.lists.linux-foundation.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] virtio-blk spec: document topology info, add WCE toggle
@ 2012-07-03 13:16 Paolo Bonzini
  2012-07-03 13:16 ` [PATCH 1/2] virtio-blk spec: document topology info Paolo Bonzini
  2012-07-03 13:16 ` [PATCH 2/2] virtio-blk spec: writeback cache enable improvements Paolo Bonzini
  0 siblings, 2 replies; 5+ messages in thread
From: Paolo Bonzini @ 2012-07-03 13:16 UTC (permalink / raw)
  To: virtualization, kvm, rusty

Hi Rusty, here are two improvements to the virtio-blk spec.

The first documents the status quo of an extension that has already
been supported in QEMU for several releases, but never made it to the
official spec.

The second adds support for toggling the cache mode between writethrough
and writeback.  Two mechanisms are introduced for this.  One is to not
negotiate VIRTIO_BLK_F_FLUSH; it can be done only at reset time and is
more of a refinement geared towards older or limited guests, in order to
make them safe wrt power losses.  The second is via feature bits and a
new configuration field.

Paolo Bonzini (2):
  virtio-blk spec: document topology info
  virtio-blk spec: writeback cache enable improvements

 virtio-spec.lyx |  136 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 132 insertions(+), 4 deletions(-)

-- 
1.7.10.2


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] virtio-blk spec: document topology info
  2012-07-03 13:16 [PATCH 0/2] virtio-blk spec: document topology info, add WCE toggle Paolo Bonzini
@ 2012-07-03 13:16 ` Paolo Bonzini
  2012-07-04  5:52   ` Rusty Russell
  2012-07-03 13:16 ` [PATCH 2/2] virtio-blk spec: writeback cache enable improvements Paolo Bonzini
  1 sibling, 1 reply; 5+ messages in thread
From: Paolo Bonzini @ 2012-07-03 13:16 UTC (permalink / raw)
  To: virtualization, kvm, rusty

Current QEMU and Linux drivers can export queue parameters via the
virtio-blk configuration space.  Document this, since the next patch
will have to add another configuration field after these.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 virtio-spec.lyx |   85 +++++++++++++++++++++++++++++++++++++++++++++++++++----
 1 file changed, 80 insertions(+), 5 deletions(-)

diff --git a/virtio-spec.lyx b/virtio-spec.lyx
index dd2d53b..859dbe7 100644
--- a/virtio-spec.lyx
+++ b/virtio-spec.lyx
@@ -5021,7 +5021,20 @@ VIRTIO_BLK_F_SCSI (7) Device supports scsi packet commands.
 \end_layout
 
 \begin_layout Description
-VIRTIO_BLK_F_FLUSH (9) Cache flush command support.Device
+VIRTIO_BLK_F_FLUSH (9) Cache flush command support.
+\change_inserted 1531152142 1341305427
+
+\end_layout
+
+\begin_layout Description
+
+\change_inserted 1531152142 1341301882
+VIRTIO_BLK_F_TOPOLOGY (10) Device exports information on optimal I/O alignment.
+\end_layout
+
+\end_deeper
+\begin_layout Description
+Device
 \begin_inset space ~
 \end_inset
 
@@ -5090,6 +5103,48 @@ struct virtio_blk_config {
 
 \begin_layout Plain Layout
 
+\change_inserted 1531152142 1341301807
+
+    struct virtio_blk_topology {
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted 1531152142 1341301810
+
+        u8 physical_block_exp;
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted 1531152142 1341301817
+
+        u8 alignment_offset;
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted 1531152142 1341301822
+
+        u16 min_io_size;
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted 1531152142 1341301827
+
+        u32 opt_io_size;
+\end_layout
+
+\begin_layout Plain Layout
+
+\change_inserted 1531152142 1341301911
+
+    } topology;
+\end_layout
+
+\begin_layout Plain Layout
+
 };
 \end_layout
 
@@ -5098,7 +5153,6 @@ struct virtio_blk_config {
 
 \end_layout
 
-\end_deeper
 \begin_layout Section*
 Device Initialization
 \end_layout
@@ -5119,15 +5173,36 @@ capacity
 \begin_layout Enumerate
 If the VIRTIO_BLK_F_BLK_SIZE feature is negotiated, the blk_size field can
  be read to determine the optimal sector size for the driver to use.
- This does not effect the units used in the protocol (always 512 bytes),
- but awareness of the correct value can effect performance.
+ This does not 
+\change_deleted 1531152142 1341301967
+e
+\change_inserted 1531152142 1341301967
+a
+\change_unchanged
+ffect the units used in the protocol (always 512 bytes), but awareness of
+ the correct value can 
+\change_deleted 1531152142 1341301978
+e
+\change_inserted 1531152142 1341301978
+a
+\change_unchanged
+ffect performance.
 \end_layout
 
 \begin_layout Enumerate
 If the VIRTIO_BLK_F_RO feature is set by the device, any write requests
  will fail.
-\change_inserted 1531152142 1341301982
+\change_inserted 1531152142 1341301920
+
+\end_layout
 
+\begin_layout Enumerate
+
+\change_inserted 1531152142 1341301982
+If the VIRTIO_BLK_F_TOPOLOGY feature is negotiated, the fields in the topology
+ struct can be read to determine the physical block size and optimal I/O
+ lengths for the driver to use.
+ This also does not affect the units in the protocol, only performance.
 \end_layout
 
 \begin_layout Section*
-- 
1.7.10.2



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] virtio-blk spec: writeback cache enable improvements
  2012-07-03 13:16 [PATCH 0/2] virtio-blk spec: document topology info, add WCE toggle Paolo Bonzini
  2012-07-03 13:16 ` [PATCH 1/2] virtio-blk spec: document topology info Paolo Bonzini
@ 2012-07-03 13:16 ` Paolo Bonzini
  1 sibling, 0 replies; 5+ messages in thread
From: Paolo Bonzini @ 2012-07-03 13:16 UTC (permalink / raw)
  To: virtualization, kvm, rusty

This patch introduces two improvements to writeback cache handling
in the virtio-blk spec.

1) The VIRTIO_BLK_F_FLUSH feature is renamed to VIRTIO_BLK_F_WCE, and
QEMU's behavior is documented explicitly as part of the spec: the host
negotiates the feature only if its cache is writeback.  The obvious dual
requirement is imposed on the guest: it should negotiate the feature
only if it is able to send flushes.  And in order to protect against
data loss, the spec now mandates that the host operates in writethrough
mode if the guest does not negotiate VIRTIO_BLK_F_WCE (this behavior
was already _allowed_ by the spec so far).  This can change with every
reset of course; typically the BIOS will run as writethrough, while the
"main" OS will run in writeback mode.  This is a backwards-compatible
refinement geared towards old or limited guests, so there is no need
for a new feature bit.

2) a second feature is added, VIRTIO_BLK_F_CONFIG_WCE, that provides
the same information in the configuration.  This will enable the driver
to modify the write-cache setting at runtime (via sysfs for Linux, via
MODE SELECT for Windows).

Patches for QEMU and Linux will come soonish.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 virtio-spec.lyx |   57 +++++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 55 insertions(+), 2 deletions(-)

diff --git a/virtio-spec.lyx b/virtio-spec.lyx
index 859dbe7..fccbd28 100644
--- a/virtio-spec.lyx
+++ b/virtio-spec.lyx
@@ -5021,9 +5021,19 @@ VIRTIO_BLK_F_SCSI (7) Device supports scsi packet commands.
 \end_layout
 
 \begin_layout Description
-VIRTIO_BLK_F_FLUSH (9) Cache flush command support.
+VIRTIO_BLK_F_
+\change_deleted 1531152142 1341302299
+FLUSH
+\change_inserted 1531152142 1341302304
+WCE
+\change_unchanged
+ (9) 
+\change_deleted 1531152142 1341302317
+Cache flush command support.
 \change_inserted 1531152142 1341305427
-
+Device cache starts in writeback mode after reset.
+ Guests should not negotiate this feature unless they are capable of sending
+ VIRTIO_BLK_T_FLUSH commands.
 \end_layout
 
 \begin_layout Description
@@ -5032,6 +5042,13 @@ VIRTIO_BLK_F_FLUSH (9) Cache flush command support.
 VIRTIO_BLK_F_TOPOLOGY (10) Device exports information on optimal I/O alignment.
 \end_layout
 
+\begin_layout Description
+
+\change_inserted 1531152142 1341302349
+VIRTIO_BLK_F_CONFIG_WCE (11) Device can toggle its cache between writeback
+ and writethrough modes.
+\end_layout
+
 \end_deeper
 \begin_layout Description
 Device
@@ -5145,6 +5162,15 @@ struct virtio_blk_config {
 
 \begin_layout Plain Layout
 
+\change_inserted 1531152142 1341301918
+
+    u8 writeback;
+\change_unchanged
+
+\end_layout
+
+\begin_layout Plain Layout
+
 };
 \end_layout
 
@@ -5205,6 +5231,33 @@ If the VIRTIO_BLK_F_TOPOLOGY feature is negotiated, the fields in the topology
  This also does not affect the units in the protocol, only performance.
 \end_layout
 
+\begin_layout Enumerate
+
+\change_inserted 1531152142 1341305949
+The cache mode should be read from the writeback field of the configuration
+ if the VIRTIO_BLK_F_CONFIG_WCE feature if available; the driver can also
+ write to the field in order to toggle the cache between writethrough (0)
+ and writeback (1) mode.
+ If the feature is not available, the driver can instead look at the result
+ of negotiating VIRTIO_BLK_F_WCE: the cache will be in writeback mode after
+ reset if and only if VIRTIO_BLK_F_WCE is negotiated
+\begin_inset Foot
+status open
+
+\begin_layout Plain Layout
+
+\change_inserted 1531152142 1341306004
+Until version 1.1, QEMU remained in writeback mode even after a guest announced
+ lack of support for VIRTIO_BLK_F_FLUSH.
+\change_unchanged
+
+\end_layout
+
+\end_inset
+
+.
+\end_layout
+
 \begin_layout Section*
 Device Operation
 \end_layout
-- 
1.7.10.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] virtio-blk spec: document topology info
  2012-07-03 13:16 ` [PATCH 1/2] virtio-blk spec: document topology info Paolo Bonzini
@ 2012-07-04  5:52   ` Rusty Russell
  2012-07-04 15:49     ` Michael S. Tsirkin
  0 siblings, 1 reply; 5+ messages in thread
From: Rusty Russell @ 2012-07-04  5:52 UTC (permalink / raw)
  To: Paolo Bonzini, virtualization, kvm

On Tue,  3 Jul 2012 15:16:51 +0200, Paolo Bonzini <pbonzini@redhat.com> wrote:
> Current QEMU and Linux drivers can export queue parameters via the
> virtio-blk configuration space.  Document this, since the next patch
> will have to add another configuration field after these.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Applied, thanks for the grammar fix, too!

> +        u8 physical_block_exp;
> +        u8 alignment_offset;
> +        u16 min_io_size;
> +        u32 opt_io_size;

These aren't entirely self-evident though :(

I've put the latest on github (your changes included!), so please patch
against that:

https://github.com/rustyrussell/virtio-spec

Thanks,
Rusty.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] virtio-blk spec: document topology info
  2012-07-04  5:52   ` Rusty Russell
@ 2012-07-04 15:49     ` Michael S. Tsirkin
  0 siblings, 0 replies; 5+ messages in thread
From: Michael S. Tsirkin @ 2012-07-04 15:49 UTC (permalink / raw)
  To: Rusty Russell; +Cc: Paolo Bonzini, virtualization, kvm

On Wed, Jul 04, 2012 at 03:22:36PM +0930, Rusty Russell wrote:
> On Tue,  3 Jul 2012 15:16:51 +0200, Paolo Bonzini <pbonzini@redhat.com> wrote:
> > Current QEMU and Linux drivers can export queue parameters via the
> > virtio-blk configuration space.  Document this, since the next patch
> > will have to add another configuration field after these.
> > 
> > Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> Applied, thanks for the grammar fix, too!
> 
> > +        u8 physical_block_exp;
> > +        u8 alignment_offset;
> > +        u16 min_io_size;
> > +        u32 opt_io_size;
> 
> These aren't entirely self-evident though :(
> 
> I've put the latest on github (your changes included!), so please patch
> against that:
> 
> https://github.com/rustyrussell/virtio-spec
> 
> Thanks,
> Rusty.

Cool!
Could you please add tags that refer to various point releases
v0.8.9 to 0.9.5?

> --
> To unsubscribe from this list: send the line "unsubscribe kvm" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2012-07-04 15:49 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-07-03 13:16 [PATCH 0/2] virtio-blk spec: document topology info, add WCE toggle Paolo Bonzini
2012-07-03 13:16 ` [PATCH 1/2] virtio-blk spec: document topology info Paolo Bonzini
2012-07-04  5:52   ` Rusty Russell
2012-07-04 15:49     ` Michael S. Tsirkin
2012-07-03 13:16 ` [PATCH 2/2] virtio-blk spec: writeback cache enable improvements Paolo Bonzini

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).