C-Otto

Cache and power loss

Recommended Posts

Hi there.

With new disks having 16 MB Cache (and more?) I see a larger problem in case of a power loss. Obviously the cache might hold a lot of precious data, that is not yet written to the disk. If the cache is enabled (which is not the case in all good raid setups I know) and the system has no USV, this data might be lost forever and trash the filesystem or corrupt important (time critical, not yet backuped?) data.

My question:

Is there some feature, using a some kind of power storage inside the disk, that solves this problem by ensuring that write-commands from the disk are executed even in the case of a powerloss?

I know, that writing 16 MB of wildly random data can take quite some time, but I'd like to see this feature in my disks. Perhaps some disks have a special area (flash storage?), where this random data can be written linearly (and written correctly when power is available)?

Any information is welcome!

Thanks,

Carsten

Share this post


Link to post
Share on other sites

Some manufacturers allow you to "tweak" any write-caching strategy for the disk. It might even be possible to turn the cache off completely.

If you're using a hardware RAID controller, you can also normally tune the write strategy.

However, in my opinion, a much better strategy would be to use a UPS to avoid most power-loss, power sag, or spike/surge scenarios.

Share this post


Link to post
Share on other sites

Data doesn't stay in the disk cache for long - much less than a second, generally. Even a 16 MB cache can be filled in about 0.15s or less, so at that point it has to start flushing the cache before it can write more data. And there's often a set limit how long data can remain in the cache before being written to disk.

However, if you are constantly writing data, then there's a high chance that at least some data in the cache will not have been flushed yet when power goes out.

The same applies to controller cache often found in expensive RAID controllers.

Depending on how critical the data is, you can disable write caching, use a battery backed write cache on the controller (which will retain the data in the controller cache until the power comes back on, at which point it gets written to disk), use redundant PSUs to reduce the risk of a power loss, and set up a UPS to shut down the system automatically before it runs out of power.

If you're just an ordinary desktop user whose livelihood doesn't depend on the data stored on that machine, then not worrying about it is a perfectly acceptable plan.

Share this post


Link to post
Share on other sites

I actually think that, for most consumer IDE drives, writes are not buffered to begin with (i.e. the cache is write-through, not write-back). I might be wrong though. Under linux hdparm can be used to turn write-back caching on.

Share this post


Link to post
Share on other sites

You've got it the wrong way round. Most consumer drives have caching turned on by default. Some enterprise drives have it off by default. Not many, but more than consumer anyway. As far as I've seen.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now