Re: Linux kernel - Libata bad block error handling to user mode program

Mike Hayward
2010-03-04T17:14:30Z

I have seen a couple of your posts on this and thought I'd chime in
since I know a bit about storage.

I frequently see io errors come through to user space (both read and
write requests) from usb flash drives, so there is a functioning error
path there to some degree. When I see the errors, the kernel is also
logging the sector and eventually resetting the device.

There is no doubt a disk drive will slow down when it hits a bad spot
since it will retry numerous times, most likely trying to remap bad
blocks. Of course your write succeeded because you probably have the
drive cache enabled. Flush or a full cache hangs while the drive
retries all of the sectors that are bad, remapping them until finally
it can remap no more. At some point it probably returns an error if
flush is timing out or it can't remap any more sectors, but it won't
include the bad sector.

I would suggest turning the drive cache off. Then the drive won't lie
to you about completing writes and you'll at least know which sectors
are bad. Just a thought :-)

- Mike