From: Mike Christie <michael.christie@oracle.com>
To: "Michael S. Tsirkin" <mst@redhat.com>
Cc: linux-scsi@vger.kernel.org, target-devel@vger.kernel.org,
stefanha@redhat.com, jasowang@redhat.com, sgarzare@redhat.com,
virtualization@lists.linux-foundation.org
Subject: Re: [PATCH 1/3] vhost-scsi: Fix alignment handling with windows
Date: Thu, 25 May 2023 10:43:52 -0500 [thread overview]
Message-ID: <8c843c3a-1ea9-9e6f-3206-bbd98d097593@oracle.com> (raw)
In-Reply-To: <20230525034741-mutt-send-email-mst@kernel.org>
On 5/25/23 2:57 AM, Michael S. Tsirkin wrote:
> On Wed, May 24, 2023 at 06:34:05PM -0500, Mike Christie wrote:
>> The linux block layer requires bios/requests to have lengths with a 512
>> byte alignment. Some drivers/layers like dm-crypt and the directi IO code
>> will test for it and just fail. Other drivers like SCSI just assume the
>> requirement is met and will end up in infinte retry loops. The problem
>> for drivers like SCSI is that it uses functions like blk_rq_cur_sectors
>> and blk_rq_sectors which divide the request's length by 512. If there's
>> lefovers then it just gets dropped. But other code in the block/scsi
>> layer may use blk_rq_bytes/blk_rq_cur_bytes and end up thinking there is
>> still data left and try to retry the cmd. We can then end up getting
>> stuck in retry loops where part of the block/scsi thinks there is data
>> left, but other parts think we want to do IOs of zero length.
>>
>> Linux will always check for alignment, but windows will not. When
>> vhost-scsi then translates the iovec it gets from a windows guest to a
>> scatterlist, we can end up with sg items where the sg->length is not
>> divisible by 512 due to the misaligned offset:
>>
>> sg[0].offset = 255;
>> sg[0].length = 3841;
>> sg...
>> sg[N].offset = 0;
>> sg[N].length = 255;
>>
>> When the lio backends then convert the SG to bios or other iovecs, we
>> end up sending them with the same misaligned values and can hit the
>> issues above.
>>
>> This just has us drop down to allocating a temp page and copying the data
>> when this happens. Because this adds a check that needs to loop over the
>> iovec in the main IO path, this patch adds an attribute that can be turned
>> on for just windows.
>>
>> Signed-off-by: Mike Christie <michael.christie@oracle.com>
>
> I am assuming this triggers rarely, yes?
>
> If so I would like to find a way to avoid setting an attribute.
>
> I am guessing the main cost is an extra scan of iov.
The scan and a memory allocation to dup the iter. However, I see
iov_iter_revert and I think that might be what I needed before to
avoid the mem alloc so will try it out.
> vhost_scsi_iov_to_sgl already does a scan, how about changing
> it to fail if misaligned?
> We can then detect the relevant error code and try with a copy.
>
next prev parent reply other threads:[~2023-05-25 15:44 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-24 23:34 [PATCH 0/3] vhost-scsi: Fix IO hangs when using windows Mike Christie
2023-05-24 23:34 ` [PATCH 1/3] vhost-scsi: Fix alignment handling with windows Mike Christie
2023-05-25 7:57 ` Michael S. Tsirkin
2023-05-25 15:43 ` Mike Christie [this message]
2023-05-25 19:05 ` kernel test robot
2023-05-24 23:34 ` [PATCH 2/3] vhost-scsi: Remove unused write argument Mike Christie
2023-05-24 23:34 ` [PATCH 3/3] vhost-scsi: Rename vhost_scsi_iov_to_sgl Mike Christie
2023-05-25 7:59 ` [PATCH 0/3] vhost-scsi: Fix IO hangs when using windows Michael S. Tsirkin
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=8c843c3a-1ea9-9e6f-3206-bbd98d097593@oracle.com \
--to=michael.christie@oracle.com \
--cc=jasowang@redhat.com \
--cc=linux-scsi@vger.kernel.org \
--cc=mst@redhat.com \
--cc=sgarzare@redhat.com \
--cc=stefanha@redhat.com \
--cc=target-devel@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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