Nuno Magalhaes said:
Is it possible to disable hardware disk cache?
Presumably you mean the one on the physical drive itself.
Really depends on what you mean by disable. Any hard drive
has to have somewhere to store stuff when its been received
from the PC while waiting for the platters to rotate to the
correct position where the sector(s) its going to start to pass
under the heads and can be written to the platter surface.
In that sense the cache cant be disabled because thats a
very fundamental part of how a drive works, basic physics.
The cache in modern drives is also used for more than just
that tho. With writes some stuff is kept in the cache while
the platter rotation and head movement system puts the
heads over the appropriate part of the platter where its to go.
In that sense its obviously possible to minimise whats in the
cache and not have it filled up with quite a bit of pending stuff.
So its obviously possible to MINIMISE the use of the cache.
You might want to do that to minimise the risk to the data
if there is a power failure before the data is on the platter.
Same with reads. Most modern drives do tend to read
ahead of what they have requests for, when there is nothing
else to do, in case that data is requested later. Its obviously
possible to read more than just the sector requested from
a track in case the drive might get a request for following
data if the drive doesnt have any other ops pending. Then
the data can come out of the cache instead of having to
wait for the platters to rotate so the new requested sector
is under the head again. This read ahead is optional, but
there isnt really any point in being able to disable that.
Some drives do have some capacity to have the
detail of the use of the cache disabled by command.
One example is how the drive reports on a write.
The write can be acknowledged when its been received
into the cache, but not yet written to the platters. That
behaviour can be changed in the drive so it only reports
the write as having been complete once the data has
been written to the platters successfully. There is a sense
in which that last is disabling the write cache in effect even
tho the data still obviously goes thru the cache to the platters.
You generally have more control over the cache use with SCSI
drives than IDEs, but even say the Hitachi/IBM 180GPX drives
do allow control over how writes are reported cache wise.
Not the software cache. I can read files with no software cache,
opening them without buffering (FILE_FLAG_NO_BUFFERING)
but I can't avoid the hardware cache.
Is it possible to get the hardware disk cache size?
Not with most drives.
In the sense of only reporting write complete once the
data has been successfully written to the platters, yes.
There is also a flush cache command.