[haiku-bugs] Re: [Haiku] #15569: usb_disk stalls & unmounts when large I/O transfers are not queued

  • From: "Haiku" <trac@xxxxxxxxxxxx>
  • To: undisclosed-recipients: ;
  • Date: Thu, 12 Mar 2020 18:54:15 -0000

#15569: usb_disk stalls & unmounts when large I/O transfers are not queued
--------------------------------+----------------------------
   Reporter:  X512              |      Owner:  nobody
       Type:  bug               |     Status:  new
   Priority:  normal            |  Milestone:  Unscheduled
  Component:  Drivers/Disk/USB  |    Version:  R1/Development
 Resolution:                    |   Keywords:
 Blocked By:                    |   Blocking:
Has a Patch:  0                 |   Platform:  All
--------------------------------+----------------------------
Comment (by pulkomandy):

 As to why the usb_disk device stalls:

 https://git.haiku-os.org/haiku/tree/src/add-
 ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp#n695

 Here you can see that USB mass storage has a 2-stage process. First it
 sends a command, and then it read or writes the data. What happens here is
 that the first step succeeds, but the second one fails. This leaves the
 device waiting for the data transfer forever.

 We can do better error handling to recover from the stall, I guess, rather
 than unmounting the disk. However, it's hard to know the state of the
 device then. Did it "gracefully" fail just that transfer? Or did it crash
 and also lost all the data that was still in its cache?

 I don't see why it should be usb_disk responsibility to split the transfer
 in smaller chunks. It can't know the limitations of the underlying levels,
 and should let those decide how to handle things. At the hardware level
 there does not appear to be any constraint, so, if we know we will be
 reading a very large chunk, I don't see why we shouldn't do that in a
 single go.

 There can be two reasons to limit the size, and both are out of control of
 usb_disk:
 - Limitations of the underlying USB stack, if we can't remove them, there
 should be a way to ask for the max allowed size, I would not hardcode it
 in usb_disk,
 - Reducing latency (as large transfers will keep the device busy for some
 time): this should be done in io_scheduler, the usb_disk driver is not the
 right place to take such decisions.
-- 
Ticket URL: <https://dev.haiku-os.org/ticket/15569#comment:11>
Haiku <https://dev.haiku-os.org>
The Haiku operating system.

Other related posts: