From: Eric Blake <eblake@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Cc: qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 7/7] scsi-block: always use SG_IO
Date: Mon, 23 May 2016 13:49:56 -0600 [thread overview]
Message-ID: <57435EE4.1090508@redhat.com> (raw)
In-Reply-To: <1464008051-6429-8-git-send-email-pbonzini@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 2612 bytes --]
On 05/23/2016 06:54 AM, Paolo Bonzini wrote:
> Using pread/pwrite or io_submit has the advantage of eliminating the
> bounce buffer, but drops the SCSI status. This keeps the guest from
> seeing unit attention codes, as well as statuses such as RESERVATION
> CONFLICT. Because we know scsi-block operates on an SBC device we can
> still use the DMA helpers with SG_IO; just remember to patch the CDBs
> if the transfer is split into multiple segments.
>
> This means that scsi-block will always use the thread-pool unfortunately,
> instead of respecting aio=native.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> hw/scsi/scsi-disk.c | 214 +++++++++++++++++++++++++++++++++++++++++++++++-----
> 1 file changed, 196 insertions(+), 18 deletions(-)
>
> diff --git a/hw/scsi/scsi-disk.c b/hw/scsi/scsi-disk.c
> index f823781..c0eefc0 100644
> --- a/hw/scsi/scsi-disk.c
> +++ b/hw/scsi/scsi-disk.c
> @@ -83,6 +83,7 @@ typedef struct SCSIDiskReq {
> struct iovec iov;
> QEMUIOVector qiov;
> BlockAcctCookie acct;
> + unsigned char *status;
> } SCSIDiskReq;
>
> #define SCSI_DISK_F_REMOVABLE 0
> @@ -190,6 +191,15 @@ static bool scsi_disk_req_check_error(SCSIDiskReq *r, int ret, bool acct_failed)
> return scsi_handle_rw_error(r, -ret, acct_failed);
> }
>
> + if (r->status && *r->status) {
> + if (acct_failed) {
> + SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
Another use of DO_UPCAST(); would container_of() be better?
> +
> +static BlockAIOCB *scsi_block_do_sgio(SCSIBlockReq *req,
> + int64_t offset, QEMUIOVector *iov,
> + int direction,
> + BlockCompletionFunc *cb, void *opaque)
> +{
> + sg_io_hdr_t *io_header = &req->io_header;
> + SCSIDiskReq *r = &req->req;
> + SCSIDiskState *s = DO_UPCAST(SCSIDiskState, qdev, r->req.dev);
> + int nb_logical_blocks;
> + uint64_t lba;
> + BlockAIOCB *aiocb;
> +
> + /* This is not supported yet. It can only happen if the guest does
> + * reads and writes that are not aligned to one logical sectors
s/one // ?
> + * _and_ cover multiple MemoryRegions.
> + */
> + assert(offset % s->qdev.blocksize == 0);
> + assert(iov->size % s->qdev.blocksize == 0);
Is asserting for something an ill-behaved guest can do the right behavior?
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]
next prev parent reply other threads:[~2016-05-23 19:50 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-23 12:54 [Qemu-devel] [PATCH v2 0/7] dma-helpers, scsi-block: use SG_IO for all I/O on scsi-block Paolo Bonzini
2016-05-23 12:54 ` [Qemu-devel] [PATCH 1/7] dma-helpers: change interface to byte-based Paolo Bonzini
2016-05-23 15:06 ` Eric Blake
2016-05-23 12:54 ` [Qemu-devel] [PATCH 2/7] dma-helpers: change BlockBackend to opaque value in DMAIOFunc Paolo Bonzini
2016-05-23 15:43 ` Eric Blake
2016-05-24 2:47 ` Fam Zheng
2016-05-24 7:05 ` Paolo Bonzini
2016-05-23 12:54 ` [Qemu-devel] [PATCH 3/7] scsi-disk: introduce a common base class Paolo Bonzini
2016-05-23 15:53 ` Eric Blake
2016-05-23 12:54 ` [Qemu-devel] [PATCH 4/7] scsi-disk: introduce dma_readv and dma_writev Paolo Bonzini
2016-05-23 16:09 ` Eric Blake
2016-06-01 19:07 ` Mark Cave-Ayland
2016-06-03 2:56 ` xiaoqiang zhao
2016-06-03 5:22 ` Mark Cave-Ayland
2016-06-03 6:07 ` xiaoqiang zhao
2016-05-23 12:54 ` [Qemu-devel] [PATCH 5/7] scsi-disk: add need_fua_emulation to SCSIDiskClass Paolo Bonzini
2016-05-23 16:34 ` Eric Blake
2016-05-24 3:04 ` Fam Zheng
2016-05-24 7:02 ` Paolo Bonzini
2016-05-23 12:54 ` [Qemu-devel] [PATCH 6/7] scsi-disk: introduce scsi_disk_req_check_error Paolo Bonzini
2016-05-23 19:16 ` Eric Blake
2016-05-23 12:54 ` [Qemu-devel] [PATCH 7/7] scsi-block: always use SG_IO Paolo Bonzini
2016-05-23 19:49 ` Eric Blake [this message]
2016-05-23 19:36 ` [Qemu-devel] [PATCH v2 0/7] dma-helpers, scsi-block: use SG_IO for all I/O on scsi-block Mark Cave-Ayland
2016-05-24 22:59 ` Mark Cave-Ayland
2016-05-25 8:45 ` Paolo Bonzini
2016-05-25 9:13 ` Mark Cave-Ayland
2016-05-25 10:11 ` Paolo Bonzini
2016-05-25 16:38 ` [Qemu-devel] [Qemu-block] " Kevin Wolf
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=57435EE4.1090508@redhat.com \
--to=eblake@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).