ATA Hard Disk (actual hardware) write errors [solved]

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

ATA Hard Disk (actual hardware) write errors [solved]

Post by bewing »

For those of you with experience on actual hardware disk drivers; I've been wrestling with aspects of this problem for the last week. From experience, can you tell me if:

1) I have an annoyingly touchy hard drive,

OR the following two statements are true?

2) On older hard disks (up to 1GB in size), there is a 10% chance that a write of more than (say) 128 sectors will fail randomly in the middle, so

3) It is important to always code your disk driver to be able to restart a failed write from the middle of a transfer, and retry several times?


Note: It's been many years, but as I recall this drive was taken out of a working windoze system.
Note2: I have not yet completely ruled out all possible timing issues in the driver.
Last edited by bewing on Mon May 12, 2008 8:27 pm, edited 1 time in total.
octavio
Member
Member
Posts: 94
Joined: Wed Oct 25, 2006 5:12 am
Location: Barcelona España
Contact:

Re: ATA Hard Disk (actual hardware) write errors

Post by octavio »

1&3 errors are very rare on hard disk unless it is a very old disk with a lod of bad sectors.
with very very old hard disk (<100MB) my drivers also have problems to read the data,even after many retrys.
User avatar
bewing
Member
Member
Posts: 1401
Joined: Wed Feb 07, 2007 1:45 pm
Location: Eugene, OR, US

Post by bewing »

It turns out that the answer (that is not in any spec or example code that I can find) is that, for some drives:

every ATA PIO write command, no matter how long or how short, needs to be followed by an ATA Hardware Cache Flush (0xE7) command. (Unless you can guarantee the disk will be idle for one second.)

If you do not do this, you can have sectors of written data vanish, or you can have "bad sectors" magically appearing on your disk.

I am entering this into the wiki, of course.
Post Reply