public inbox for [email protected]
 help / color / mirror / Atom feed
* Re: [PATCH v2] io_uring: fix short read slow path
       [not found]     ` <[email protected]>
@ 2022-07-05 13:28       ` Stefan Hajnoczi
  2022-07-05 19:23         ` Jens Axboe
  2022-07-05 22:52         ` Dominique Martinet
  0 siblings, 2 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2022-07-05 13:28 UTC (permalink / raw)
  To: Dominique Martinet, Jens Axboe
  Cc: Stefano Garzarella, Aarushi Mehta, Julia Suvorova, Kevin Wolf,
	Hanna Reitz, qemu-block, qemu-devel, Filipe Manana, io-uring

[-- Attachment #1: Type: text/plain, Size: 2007 bytes --]

On Fri, Jul 01, 2022 at 07:52:31AM +0900, Dominique Martinet wrote:
> Stefano Garzarella wrote on Thu, Jun 30, 2022 at 05:49:21PM +0200:
> > > so when we ask for more we issue an extra short reads, making sure we go
> > > through the two short reads path.
> > > (Unfortunately I wasn't quite sure what to fiddle with to issue short
> > > reads in the first place, I tried cutting one of the iovs short in
> > > luring_do_submit() but I must not have been doing it properly as I ended
> > > up with 0 return values which are handled by filling in with 0 (reads
> > > after eof) and that didn't work well)
> > 
> > Do you remember the kernel version where you first saw these problems?
> 
> Since you're quoting my paragraph about testing two short reads, I've
> never seen any that I know of; but there's also no reason these couldn't
> happen.
> 
> Single short reads have been happening for me with O_DIRECT (cache=none)
> on btrfs for a while, but unfortunately I cannot remember which was the
> first kernel I've seen this on -- I think rather than a kernel update it
> was due to file manipulations that made the file eligible for short
> reads in the first place (I started running deduplication on the backing
> file)
> 
> The older kernel I have installed right now is 5.16 and that can
> reproduce it --  I'll give my laptop some work over the weekend to test
> still maintained stable branches if that's useful.

Hi Dominique,
Linux 5.16 contains commit 9d93a3f5a0c ("io_uring: punt short reads to
async context"). The comment above QEMU's luring_resubmit_short_read()
claims that short reads are a bug that was fixed by Linux commit
9d93a3f5a0c.

If the comment is inaccurate it needs to be fixed. Maybe short writes
need to be handled too.

I have CCed Jens and the io_uring mailing list to clarify:
1. Are short IORING_OP_READV reads possible on files/block devices?
2. Are short IORING_OP_WRITEV writes possible on files/block devices?

Thanks,
Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] io_uring: fix short read slow path
  2022-07-05 13:28       ` [PATCH v2] io_uring: fix short read slow path Stefan Hajnoczi
@ 2022-07-05 19:23         ` Jens Axboe
  2022-07-06  7:16           ` Stefan Hajnoczi
  2022-07-05 22:52         ` Dominique Martinet
  1 sibling, 1 reply; 7+ messages in thread
From: Jens Axboe @ 2022-07-05 19:23 UTC (permalink / raw)
  To: Stefan Hajnoczi, Dominique Martinet
  Cc: Stefano Garzarella, Aarushi Mehta, Julia Suvorova, Kevin Wolf,
	Hanna Reitz, qemu-block, qemu-devel, Filipe Manana, io-uring

On 7/5/22 7:28 AM, Stefan Hajnoczi wrote:
> On Fri, Jul 01, 2022 at 07:52:31AM +0900, Dominique Martinet wrote:
>> Stefano Garzarella wrote on Thu, Jun 30, 2022 at 05:49:21PM +0200:
>>>> so when we ask for more we issue an extra short reads, making sure we go
>>>> through the two short reads path.
>>>> (Unfortunately I wasn't quite sure what to fiddle with to issue short
>>>> reads in the first place, I tried cutting one of the iovs short in
>>>> luring_do_submit() but I must not have been doing it properly as I ended
>>>> up with 0 return values which are handled by filling in with 0 (reads
>>>> after eof) and that didn't work well)
>>>
>>> Do you remember the kernel version where you first saw these problems?
>>
>> Since you're quoting my paragraph about testing two short reads, I've
>> never seen any that I know of; but there's also no reason these couldn't
>> happen.
>>
>> Single short reads have been happening for me with O_DIRECT (cache=none)
>> on btrfs for a while, but unfortunately I cannot remember which was the
>> first kernel I've seen this on -- I think rather than a kernel update it
>> was due to file manipulations that made the file eligible for short
>> reads in the first place (I started running deduplication on the backing
>> file)
>>
>> The older kernel I have installed right now is 5.16 and that can
>> reproduce it --  I'll give my laptop some work over the weekend to test
>> still maintained stable branches if that's useful.
> 
> Hi Dominique,
> Linux 5.16 contains commit 9d93a3f5a0c ("io_uring: punt short reads to
> async context"). The comment above QEMU's luring_resubmit_short_read()
> claims that short reads are a bug that was fixed by Linux commit
> 9d93a3f5a0c.
> 
> If the comment is inaccurate it needs to be fixed. Maybe short writes
> need to be handled too.
> 
> I have CCed Jens and the io_uring mailing list to clarify:
> 1. Are short IORING_OP_READV reads possible on files/block devices?
> 2. Are short IORING_OP_WRITEV writes possible on files/block devices?

In general we try very hard to avoid them, but if eg we get a short read
or write from blocking context (eg io-wq), then io_uring does return
that. There's really not much we can do here, it seems futile to retry
IO which was issued just like it would've been from a normal blocking
syscall yet it is still short.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] io_uring: fix short read slow path
  2022-07-05 13:28       ` [PATCH v2] io_uring: fix short read slow path Stefan Hajnoczi
  2022-07-05 19:23         ` Jens Axboe
@ 2022-07-05 22:52         ` Dominique Martinet
  2022-07-06  7:17           ` Stefan Hajnoczi
  1 sibling, 1 reply; 7+ messages in thread
From: Dominique Martinet @ 2022-07-05 22:52 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Jens Axboe, Stefano Garzarella, Aarushi Mehta, Julia Suvorova,
	Kevin Wolf, Hanna Reitz, qemu-block, qemu-devel, Filipe Manana,
	io-uring

Stefan Hajnoczi wrote on Tue, Jul 05, 2022 at 02:28:08PM +0100:
> > The older kernel I have installed right now is 5.16 and that can
> > reproduce it --  I'll give my laptop some work over the weekend to test
> > still maintained stable branches if that's useful.
> 
> Linux 5.16 contains commit 9d93a3f5a0c ("io_uring: punt short reads to
> async context"). The comment above QEMU's luring_resubmit_short_read()
> claims that short reads are a bug that was fixed by Linux commit
> 9d93a3f5a0c.
> 
> If the comment is inaccurate it needs to be fixed. Maybe short writes
> need to be handled too.
> 
> I have CCed Jens and the io_uring mailing list to clarify:
> 1. Are short IORING_OP_READV reads possible on files/block devices?
> 2. Are short IORING_OP_WRITEV writes possible on files/block devices?

Jens replied before me, so I won't be adding much (I agree with his
reply -- linux tries hard to avoid short reads but we should assume they
can happen)

In this particular case it was another btrfs bug with O_DIRECT and mixed
compression in a file, that's been fixed by this patch:
https://lore.kernel.org/all/20220630151038.GA459423@falcondesktop/

queued here:
https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git/commit/?h=dio_fixes&id=b3864441547e49a69d45c7771aa8cc5e595d18fc

It should be backported to 5.10, but the problem will likely persist in
5.4 kernels if anyone runs on that as the code changed enough to make
backporting non-trivial.


So, WRT that comment, we probably should remove the reference to that
commit and leave in that they should be very rare but we need to handle
them anyway.


For writes in particular, I haven't seen any and looking at the code
qemu would blow up that storage (IO treated as ENOSPC would likely mark
disk read-only?)
It might make sense to add some warning message that it's what happened
so it'll be obvious what needs doing in case anyone falls on that but I
think the status-quo is good enough here.

-- 
Dominique

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] io_uring: fix short read slow path
  2022-07-05 19:23         ` Jens Axboe
@ 2022-07-06  7:16           ` Stefan Hajnoczi
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2022-07-06  7:16 UTC (permalink / raw)
  To: Jens Axboe
  Cc: Stefan Hajnoczi, Dominique Martinet, Stefano Garzarella,
	Aarushi Mehta, Julia Suvorova, Kevin Wolf, Hanna Reitz,
	qemu block, qemu-devel, Filipe Manana, io-uring

On Tue, 5 Jul 2022 at 20:26, Jens Axboe <[email protected]> wrote:
>
> On 7/5/22 7:28 AM, Stefan Hajnoczi wrote:
> > On Fri, Jul 01, 2022 at 07:52:31AM +0900, Dominique Martinet wrote:
> >> Stefano Garzarella wrote on Thu, Jun 30, 2022 at 05:49:21PM +0200:
> >>>> so when we ask for more we issue an extra short reads, making sure we go
> >>>> through the two short reads path.
> >>>> (Unfortunately I wasn't quite sure what to fiddle with to issue short
> >>>> reads in the first place, I tried cutting one of the iovs short in
> >>>> luring_do_submit() but I must not have been doing it properly as I ended
> >>>> up with 0 return values which are handled by filling in with 0 (reads
> >>>> after eof) and that didn't work well)
> >>>
> >>> Do you remember the kernel version where you first saw these problems?
> >>
> >> Since you're quoting my paragraph about testing two short reads, I've
> >> never seen any that I know of; but there's also no reason these couldn't
> >> happen.
> >>
> >> Single short reads have been happening for me with O_DIRECT (cache=none)
> >> on btrfs for a while, but unfortunately I cannot remember which was the
> >> first kernel I've seen this on -- I think rather than a kernel update it
> >> was due to file manipulations that made the file eligible for short
> >> reads in the first place (I started running deduplication on the backing
> >> file)
> >>
> >> The older kernel I have installed right now is 5.16 and that can
> >> reproduce it --  I'll give my laptop some work over the weekend to test
> >> still maintained stable branches if that's useful.
> >
> > Hi Dominique,
> > Linux 5.16 contains commit 9d93a3f5a0c ("io_uring: punt short reads to
> > async context"). The comment above QEMU's luring_resubmit_short_read()
> > claims that short reads are a bug that was fixed by Linux commit
> > 9d93a3f5a0c.
> >
> > If the comment is inaccurate it needs to be fixed. Maybe short writes
> > need to be handled too.
> >
> > I have CCed Jens and the io_uring mailing list to clarify:
> > 1. Are short IORING_OP_READV reads possible on files/block devices?
> > 2. Are short IORING_OP_WRITEV writes possible on files/block devices?
>
> In general we try very hard to avoid them, but if eg we get a short read
> or write from blocking context (eg io-wq), then io_uring does return
> that. There's really not much we can do here, it seems futile to retry
> IO which was issued just like it would've been from a normal blocking
> syscall yet it is still short.

Thanks! QEMU's short I/O handling is spotty - some code paths handle
it while others don't. For the io_uring QEMU block driver we'll try to
handle short all I/Os.

Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] io_uring: fix short read slow path
  2022-07-05 22:52         ` Dominique Martinet
@ 2022-07-06  7:17           ` Stefan Hajnoczi
  2022-07-06  7:26             ` Dominique Martinet
  0 siblings, 1 reply; 7+ messages in thread
From: Stefan Hajnoczi @ 2022-07-06  7:17 UTC (permalink / raw)
  To: Dominique Martinet
  Cc: Stefan Hajnoczi, Jens Axboe, Stefano Garzarella, Aarushi Mehta,
	Julia Suvorova, Kevin Wolf, Hanna Reitz, qemu block, qemu-devel,
	Filipe Manana, io-uring

On Tue, 5 Jul 2022 at 23:53, Dominique Martinet
<[email protected]> wrote:
>
> Stefan Hajnoczi wrote on Tue, Jul 05, 2022 at 02:28:08PM +0100:
> > > The older kernel I have installed right now is 5.16 and that can
> > > reproduce it --  I'll give my laptop some work over the weekend to test
> > > still maintained stable branches if that's useful.
> >
> > Linux 5.16 contains commit 9d93a3f5a0c ("io_uring: punt short reads to
> > async context"). The comment above QEMU's luring_resubmit_short_read()
> > claims that short reads are a bug that was fixed by Linux commit
> > 9d93a3f5a0c.
> >
> > If the comment is inaccurate it needs to be fixed. Maybe short writes
> > need to be handled too.
> >
> > I have CCed Jens and the io_uring mailing list to clarify:
> > 1. Are short IORING_OP_READV reads possible on files/block devices?
> > 2. Are short IORING_OP_WRITEV writes possible on files/block devices?
>
> Jens replied before me, so I won't be adding much (I agree with his
> reply -- linux tries hard to avoid short reads but we should assume they
> can happen)
>
> In this particular case it was another btrfs bug with O_DIRECT and mixed
> compression in a file, that's been fixed by this patch:
> https://lore.kernel.org/all/20220630151038.GA459423@falcondesktop/
>
> queued here:
> https://git.kernel.org/pub/scm/linux/kernel/git/fdmanana/linux.git/commit/?h=dio_fixes&id=b3864441547e49a69d45c7771aa8cc5e595d18fc
>
> It should be backported to 5.10, but the problem will likely persist in
> 5.4 kernels if anyone runs on that as the code changed enough to make
> backporting non-trivial.
>
>
> So, WRT that comment, we probably should remove the reference to that
> commit and leave in that they should be very rare but we need to handle
> them anyway.
>
>
> For writes in particular, I haven't seen any and looking at the code
> qemu would blow up that storage (IO treated as ENOSPC would likely mark
> disk read-only?)
> It might make sense to add some warning message that it's what happened
> so it'll be obvious what needs doing in case anyone falls on that but I
> think the status-quo is good enough here.

Great! I've already queued your fix.

Do you want to send a follow-up that updates the comment?

Thanks,
Stefan

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] io_uring: fix short read slow path
  2022-07-06  7:17           ` Stefan Hajnoczi
@ 2022-07-06  7:26             ` Dominique Martinet
  2022-07-06  7:51               ` Stefan Hajnoczi
  0 siblings, 1 reply; 7+ messages in thread
From: Dominique Martinet @ 2022-07-06  7:26 UTC (permalink / raw)
  To: Stefan Hajnoczi
  Cc: Stefan Hajnoczi, Jens Axboe, Stefano Garzarella, Aarushi Mehta,
	Julia Suvorova, Kevin Wolf, Hanna Reitz, qemu block, qemu-devel,
	Filipe Manana, io-uring

Stefan Hajnoczi wrote on Wed, Jul 06, 2022 at 08:17:42AM +0100:
> Great! I've already queued your fix.

Thanks!

> Do you want to send a follow-up that updates the comment?

I don't think I'd add much value at this point, leaving it to you unless
you really would prefer me to send it.


Cheers,
-- 
Dominique

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH v2] io_uring: fix short read slow path
  2022-07-06  7:26             ` Dominique Martinet
@ 2022-07-06  7:51               ` Stefan Hajnoczi
  0 siblings, 0 replies; 7+ messages in thread
From: Stefan Hajnoczi @ 2022-07-06  7:51 UTC (permalink / raw)
  To: Dominique Martinet
  Cc: Stefan Hajnoczi, Jens Axboe, Stefano Garzarella, Aarushi Mehta,
	Julia Suvorova, Kevin Wolf, Hanna Reitz, qemu block, qemu-devel,
	Filipe Manana, io-uring

[-- Attachment #1: Type: text/plain, Size: 435 bytes --]

On Wed, Jul 06, 2022 at 04:26:59PM +0900, Dominique Martinet wrote:
> Stefan Hajnoczi wrote on Wed, Jul 06, 2022 at 08:17:42AM +0100:
> > Great! I've already queued your fix.
> 
> Thanks!
> 
> > Do you want to send a follow-up that updates the comment?
> 
> I don't think I'd add much value at this point, leaving it to you unless
> you really would prefer me to send it.

That's fine. I'll send a patch. Thanks!

Stefan

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2022-07-06  7:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <[email protected]>
     [not found] ` <[email protected]>
     [not found]   ` <20220630154921.ekl45dzer6x4mkvi@sgarzare-redhat>
     [not found]     ` <[email protected]>
2022-07-05 13:28       ` [PATCH v2] io_uring: fix short read slow path Stefan Hajnoczi
2022-07-05 19:23         ` Jens Axboe
2022-07-06  7:16           ` Stefan Hajnoczi
2022-07-05 22:52         ` Dominique Martinet
2022-07-06  7:17           ` Stefan Hajnoczi
2022-07-06  7:26             ` Dominique Martinet
2022-07-06  7:51               ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox