From: Stefan Hajnoczi <stefanha@redhat.com>
To: virtio-dev@lists.oasis-open.org
Cc: Stefan Hajnoczi <stefanha@redhat.com>,
"Michael S . Tsirkin" <mst@redhat.com>,
Changpeng Liu <changpeng.liu@intel.com>,
Stefano Garzarella <sgarzare@redhat.com>
Subject: [virtio-dev] [PATCH v2 1/4] virtio-blk: document data[] size constraints
Date: Thu, 31 Jan 2019 10:36:14 +0800 [thread overview]
Message-ID: <20190131023617.23007-2-stefanha@redhat.com> (raw)
In-Reply-To: <20190131023617.23007-1-stefanha@redhat.com>
The struct virtio_blk_req->data[] field is a multiple of 512 bytes long
for read and write requests. Flush requests don't use data[] at all.
The new discard and write zeroes requests being introduced in VIRTIO 1.1
put struct virtio_blk_discard_write_zeroes elements into data[], so it
must be a multiple of the struct size.
The uint8_t data[][512] pseudo-code makes it look like discard and write
zeroes requests must pad to 512 bytes. This wastes memory since struct
virtio_blk_discard_write_data is only 16 bytes long.
Furthermore, all known implementations wishing to take advantage of this
upcoming VIRTIO 1.1 feature do not use 512-byte padding (Linux
virtio_blk.ko, QEMU virtio-blk device emulation, the SPDK virtio-blk
driver, and the SPDK vhost-user-blk device backend).
This patch documents the data[] size constraints clearly in the driver
normative section. This is clearer than the current pseudo-code.
Cc: Michael S. Tsirkin <mst@redhat.com>
Cc: Changpeng Liu <changpeng.liu@intel.com>
Cc: Stefano Garzarella <sgarzare@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
content.tex | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
diff --git a/content.tex b/content.tex
index 836ee52..b185bb0 100644
--- a/content.tex
+++ b/content.tex
@@ -3941,7 +3941,7 @@ struct virtio_blk_req {
le32 type;
le32 reserved;
le64 sector;
- u8 data[][512];
+ u8 data[];
u8 status;
};
@@ -3971,6 +3971,11 @@ The \field{sector} number indicates the offset (multiplied by 512) where
the read or write is to occur. This field is unused and set to 0 for
commands other than read or write.
+VIRTIO_BLK_T_IN requests populate \field{data} with the contents of sectors
+read from the block device (in multiples of 512 bytes). VIRTIO_BLK_T_OUT
+requests write the contents of \field{data} to the block device (in multiples
+of 512 bytes).
+
The \field{data} used for discard or write zeroes command is described
by one or more virtio_blk_discard_write_zeroes structs. \field{sector}
indicates the starting offset (in 512-byte units) of the segment, while
@@ -3997,6 +4002,13 @@ A driver SHOULD accept the VIRTIO_BLK_F_RO feature if offered.
A driver MUST set \field{sector} to 0 for a VIRTIO_BLK_T_FLUSH request.
A driver SHOULD NOT include any data in a VIRTIO_BLK_T_FLUSH request.
+The length of \field{data} MUST be a multiple of 512 bytes for VIRTIO_BLK_T_IN
+and VIRTIO_BLK_T_OUT requests.
+
+The length of \field{data} MUST be a multiple of the size of struct
+virtio_blk_discard_write_zeroes for VIRTIO_BLK_T_DISCARD and
+VIRTIO_BLK_T_WRITE_ZEROES requests.
+
If the VIRTIO_BLK_F_CONFIG_WCE feature is negotiated, the driver MAY
switch to writethrough or writeback mode by writing respectively 0 and
1 to the \field{writeback} field. After writing a 0 to \field{writeback},
--
2.20.1
---------------------------------------------------------------------
To unsubscribe, e-mail: virtio-dev-unsubscribe@lists.oasis-open.org
For additional commands, e-mail: virtio-dev-help@lists.oasis-open.org
next prev parent reply other threads:[~2019-01-31 2:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-31 2:36 [virtio-dev] [PATCH v2 0/4] virtio-blk: discard and write zeroes clarifications Stefan Hajnoczi
2019-01-31 2:36 ` Stefan Hajnoczi [this message]
2019-01-31 4:14 ` [virtio-dev] Re: [PATCH v2 1/4] virtio-blk: document data[] size constraints Michael S. Tsirkin
2019-02-18 7:22 ` Jan Kiszka
2019-02-18 14:04 ` Stefan Hajnoczi
2019-02-20 3:49 ` Michael S. Tsirkin
2019-02-22 5:53 ` Michael S. Tsirkin
2019-02-22 9:55 ` Stefan Hajnoczi
2019-01-31 2:36 ` [virtio-dev] [PATCH v2 2/4] virtio-blk: move virtio_blk_discard_write_zeroes definition Stefan Hajnoczi
2019-01-31 2:36 ` [virtio-dev] [PATCH v2 3/4] virtio-blk: describe write zeroes unmap semantics Stefan Hajnoczi
2019-01-31 2:36 ` [virtio-dev] [PATCH v2 4/4] virtio-blk: avoid inconsistent "DISCARD" term Stefan Hajnoczi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190131023617.23007-2-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=changpeng.liu@intel.com \
--cc=mst@redhat.com \
--cc=sgarzare@redhat.com \
--cc=virtio-dev@lists.oasis-open.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox