From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54510) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1b4vra-0006oN-Av for qemu-devel@nongnu.org; Mon, 23 May 2016 15:50:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1b4vrY-00020c-55 for qemu-devel@nongnu.org; Mon, 23 May 2016 15:50:05 -0400 References: <1464008051-6429-1-git-send-email-pbonzini@redhat.com> <1464008051-6429-8-git-send-email-pbonzini@redhat.com> From: Eric Blake Message-ID: <57435EE4.1090508@redhat.com> Date: Mon, 23 May 2016 13:49:56 -0600 MIME-Version: 1.0 In-Reply-To: <1464008051-6429-8-git-send-email-pbonzini@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="oroseDfK5DloTkakMkqEsd6lQMAjkSKnW" Subject: Re: [Qemu-devel] [PATCH 7/7] scsi-block: always use SG_IO List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini , qemu-devel@nongnu.org Cc: qemu-block@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --oroseDfK5DloTkakMkqEsd6lQMAjkSKnW Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > This means that scsi-block will always use the thread-pool unfortunatel= y, > instead of respecting aio=3Dnative. >=20 > Signed-off-by: Paolo Bonzini > --- > hw/scsi/scsi-disk.c | 214 ++++++++++++++++++++++++++++++++++++++++++++= +++----- > 1 file changed, 196 insertions(+), 18 deletions(-) >=20 > 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; > =20 > #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); > } > =20 > + if (r->status && *r->status) { > + if (acct_failed) { > + SCSIDiskState *s =3D DO_UPCAST(SCSIDiskState, qdev, r->req= =2Edev); Another use of DO_UPCAST(); would container_of() be better? > + > +static BlockAIOCB *scsi_block_do_sgio(SCSIBlockReq *req, > + int64_t offset, QEMUIOVector *io= v, > + int direction, > + BlockCompletionFunc *cb, void *o= paque) > +{ > + sg_io_hdr_t *io_header =3D &req->io_header; > + SCSIDiskReq *r =3D &req->req; > + SCSIDiskState *s =3D 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 doe= s > + * reads and writes that are not aligned to one logical sectors s/one // ? > + * _and_ cover multiple MemoryRegions. > + */ > + assert(offset % s->qdev.blocksize =3D=3D 0); > + assert(iov->size % s->qdev.blocksize =3D=3D 0); Is asserting for something an ill-behaved guest can do the right behavior= ? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --oroseDfK5DloTkakMkqEsd6lQMAjkSKnW Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXQ17kAAoJEKeha0olJ0NqD9gH/25rIlD6+UGcF/MsA2TNFjVY EbuB8YnyYzhFqyNsGwqEn0fqSS9kMgrjY8TKc+ee+rZIqG3ouUW2JItSBlVV8SIu aCOpmYOmX0C0boaL+K8lmiLmULWjGf+2GfNw8DoGHyuRV96xuBngqkGZrPOj75NH hkTJ7OsgBGul2hpU5EvenvVFwLJFuAl9An7u+Ma/WsIyTxor+wiuIuZdxFzmtkIl i1z/dCMz3XoyYNW2lIovjIZPjWO7kdaF4h3gOZFgYEfbbnx3iIXdckEIRwUlCznb vJxb6qE3m0Lv7dqrmI4j9MCBhZVNXSCZbPbph/w1f4ZLz8oIYL1Infs+eeE+hGg= =Cb8O -----END PGP SIGNATURE----- --oroseDfK5DloTkakMkqEsd6lQMAjkSKnW--