usb_disk fails to handle USB stick, panic KDL when trying to boot from it
|Reported by:||jua||Owned by:||kallisti5|
|Keywords:||usb_disk usb stick boot kdl panic||Cc:|
|Blocked By:||Blocking:||#10155, #10174|
|Has a Patch:||yes||Platform:||x86|
The changes to usb_disk driver in hrev46099 broke booting an anyboot-image from one of my USB sticks for me. When the disk icon lights up in the boot splash, it shows a KDL "PANIC: could not mount boot device". (With a different USB stick it stills works fine...)
Here's what I found out:
The updated usb_disk driver wrongly detects the USB stick as read-only device (the
KPartition::Dump printed to the serial console while booting shows the boot partition flags as 0xa... while with the usb_disk driver from hrev46098 it is the correct 0x2). This later leads to failed mounting.
The problem has its roots in
usb_disk_device_added(), in the part starting at line 795. For some reason, the problematic USB stick responds to the 'unit ready'-inquiry with ASC
0x2800: "Not ready to ready change, medium may have changed" (maybe a device quirk?). In
scsi_sense.h this is associated with
err_act_fail, so it will drop out of the loop without retrying...
lun->write_protected doesn't get set to
false and it will then wrongly assume a read-only medium.
As a test-hack, I overrode it by just setting
lun->write_protected always to
true. It then works, boots fine, without any further changes.
A better fix would be to set the entry for
err_act_retry. This fixes the problem, it will retry the command on the stick and the second time it succeeds and can mount the boot volume. Attaching a patch which does this. I'm not sure whether this is the correct solution though.
Change History (16)
by , 7 years ago