From: Paolo Bonzini <pbonzini@redhat.com>
To: Alex Pyrgiotis <apyrgio@arrikto.com>,
qemu-devel@nongnu.org,
Kevin Wolf <kwolf@redhat.com>Alex Pyrgiotis <apyrgio@arrikto.com>
Subject: Re: [Qemu-devel] [PATCH 3/9] dma-helpers: Do not truncate small qiovs
Date: Thu, 11 Feb 2016 12:08:45 +0100 [thread overview]
Message-ID: <56BC6BBD.2070907@redhat.com> (raw)
In-Reply-To: <1450284917-10508-4-git-send-email-apyrgio@arrikto.com>
On 16/12/2015 17:55, Alex Pyrgiotis wrote:
> If the size of the qiov is smaller than the sector size, do not truncate
> the qiov, which would effectively make it empty. Instead, allow it to
> pass as is.
>
> This is necessary for SCSI requests like READ CAPACITY which have small
> buffers, e.g. 32 bytes.
>
> Signed-off-by: Alex Pyrgiotis <apyrgio@arrikto.com>
> Signed-off-by: Dimitris Aragiorgis <dimara@arrikto.com>
>
> diff --git a/dma-helpers.c b/dma-helpers.c
> index e1ea7b3..b8f2ae0 100644
> --- a/dma-helpers.c
> +++ b/dma-helpers.c
> @@ -162,7 +162,16 @@ static void dma_map_sg(DMAAIOCB *dbs)
> return;
> }
>
> - if (dbs->iov.size & ~BDRV_SECTOR_MASK) {
> + /*
> + * If the size of the qiov is not a multiple of the sector size, truncate
> + * the qiov.
> + *
> + * NOTE: If the qiov is less than a sector, we can assume that there is a
> + * reason for it, e.g., a SCSI request such as READ CAPACITY, and we should
> + * not truncate it.
> + */
I'm afraid this is wrong. It is legal to send SCSI requests that are
e.g. 513 bytes in size. The sector limit is arbitrary.
I think the "if" statement is wrong too, however. In particular it has
not broken IDE TRIM only because the ATA standard makes 512 bytes the
unit of DMA transfer. Rather, it is the IDE device that should discard
extra data in the QEMUSGList.
Paolo
> + if (dbs->iov.size & ~BDRV_SECTOR_MASK &&
> + dbs->iov.size > BDRV_SECTOR_SIZE) {
> qemu_iovec_discard_back(&dbs->iov, dbs->iov.size & ~BDRV_SECTOR_MASK);
> }
> }
>
next prev parent reply other threads:[~2016-02-11 11:08 UTC|newest]
Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-16 16:55 [Qemu-devel] [PATCH 0/9] Add full scatter-gather support for SCSI generic devices Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 1/9] dma-helpers: Expose the sg mapping logic Alex Pyrgiotis
2016-02-11 11:17 ` Paolo Bonzini
2016-02-19 11:50 ` Alex Pyrgiotis
2016-02-22 10:43 ` Paolo Bonzini
2016-02-25 10:10 ` Alex Pyrgiotis
2016-02-25 10:22 ` Paolo Bonzini
2016-02-25 11:19 ` Alex Pyrgiotis
2016-02-25 13:01 ` Paolo Bonzini
2016-02-26 9:20 ` Kevin Wolf
2015-12-16 16:55 ` [Qemu-devel] [PATCH 2/9] dma-helpers: Add support for ioctl operations Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 3/9] dma-helpers: Do not truncate small qiovs Alex Pyrgiotis
2016-02-11 11:08 ` Paolo Bonzini [this message]
2015-12-16 16:55 ` [Qemu-devel] [PATCH 4/9] scsi-generic: Add common functions Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 5/9] scsi-generic: Separate `sg_io_hdr' initializations Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 6/9] scsi-generic: Make request execution buf-specific Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 7/9] scsi-generic: Make data-copying logic clearer Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 8/9] scsi-generic: Factor out response interception Alex Pyrgiotis
2015-12-16 16:55 ` [Qemu-devel] [PATCH 9/9] scsi-generic: Allow full scatter-gather support Alex Pyrgiotis
2015-12-16 18:16 ` [Qemu-devel] [PATCH 0/9] Add full scatter-gather support for SCSI generic devices Paolo Bonzini
2015-12-17 8:47 ` Alex Pyrgiotis
2015-12-17 10:31 ` Paolo Bonzini
2015-12-17 13:10 ` Alex Pyrgiotis
2015-12-17 13:13 ` Paolo Bonzini
2015-12-21 10:58 ` Alex Pyrgiotis
2016-01-11 13:30 ` Alex Pyrgiotis
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=56BC6BBD.2070907@redhat.com \
--to=pbonzini@redhat.com \
--cc=apyrgio@arrikto.com \
--cc=kwolf@redhat.com \
--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).