Skip to contentSkip to conversation

Drive reset as an EH strategy when write cache is enabled

DISCUSSION Phillip Susi 3 participants 5 messages Dec 1, 2020 – Dec 2, 2020 libata

lore
Share & tools
lore
#0 lore raw

A while back I noticed lines in my syslog indicating that a FLUSH CACHE command timed out and the drive was hard reset to recover. That made me wonder if such a thing makes any sense as a valid EH strategy. Any previous writes that returned successfully but are still sitting in the drive's write cache will be silently invalidated by resetting the drive won't they? Then the FLUSH CACHE command is retried, and of course, succeeds because it is now a NOOP. Then fsync() returns and postfix thinks my new email has been committed to the disk, when in fact, it has not.

Am I mistaken somewhere or is the kernel really doing the wrong thing here?

#1 lore raw
Quoted 10 lines · Phillip Susi

A while back I noticed lines in my syslog indicating that a FLUSH CACHE command timed out and the drive was hard reset to recover. That made me wonder if such a thing makes any sense as a valid EH strategy. Any previous writes that returned successfully but are still sitting in the drive's write cache will be silently invalidated by resetting the drive won't they? Then the FLUSH CACHE command is retried, and of course, succeeds because it is now a NOOP. Then fsync() returns and postfix thinks my new email has been committed to the disk, when in fact, it has not.

Quoted 2 lines

Am I mistaken somewhere or is the kernel really doing the wrong thing here?

If the device drops the content of the volatile write on a reset we'll have much problems than that..

#2 lore raw
Quoted 2 lines · Christoph Hellwig

If the device drops the content of the volatile write on a reset we'll have much problems than that..

How could it not? The write cache is empty after a power on reset and certainly a "hard" reset should be the same as a power on reset.

#3 lore raw
Quoted 7 lines · Phillip Susi
Quoted 2 lines · Christoph Hellwig

If the device drops the content of the volatile write on a reset we'll have much problems than that..

How could it not? The write cache is empty after a power on reset and certainly a "hard" reset should be the same as a power on reset.

As Christoph said it would be stupid behaviour to invalidate the cache after a hard reset because it would cause all deferred writes to fail. The SCSI standards committee did initially assume manufacturers knew this, but it was codified in SBC-4 and beyond with an explicit list of conditions under which the write back cache could be lost, which doesn't include hard reset.

James

#4 lore raw
Quoted 6 lines · James Bottomley

As Christoph said it would be stupid behaviour to invalidate the cache after a hard reset because it would cause all deferred writes to fail. The SCSI standards committee did initially assume manufacturers knew this, but it was codified in SBC-4 and beyond with an explicit list of conditions under which the write back cache could be lost, which doesn't include hard reset.

Wow... so a hard reset is in fact, not really a hard reset? I can see a soft reset maybe preserving the cache but I would expect a hard reset to be equal to pulsing the ^RST line. In fact, my understanding from reading the SATA spec was that the hard reset bus condition was intended to be detected by the PHY layer and pulse the ^RST signal to the higher level logic. Wait... SBC-4 applies to ATA disks too?