In computer file systems, soft updates is an approach to maintaining disk integrity after a crash or power outage. They are an alternative to journaling file system.
Instead of duplicating metadata writes in a journal, soft updates work by tracking and enforcing metadata update dependencies. Like journaling, soft updates do not guarantee that no data will be lost, but they do make sure the filesystem is consistent.
An advantage of a file system with soft updates is that it can be mounted immediately after a crash since there is no log replay.
Soft updates were first introduced to FreeBSD by Marshall Kirk McKusick and are now available across the BSDs. Recent versions of soft updates include a journaling mechanism which eliminates the need for a background fsck after a crash.
Soft updates allow only asynchronous metadata writes that do not render the on-disk file system inconsistent, or that the only inconsistency that ever happens is a storage space leak (space marked allocated when not used by any file). It avoids having to do ordered synchronous metadata writes by temporarily "rolling back" any part of a metadata block that depends on another potentially non-flushed or partially rolled-back block when writing it.
In effect, blocks may be flushed at any time and the soft-update code will always provide the disk a consistent version of it (as long as it knows which blocks have physically been flushed). Recovery then simply becomes a matter of running a background walk of the file system when it is next mounted to garbage collect any allocated space that has been orphaned. This also permits the filesystem to selectively flush certain files without having to flush all metadata blocks or all of the records.
Data that is unlinked from the metadata dependency graph before writing it to disk has begun does not need to be written to disk at all. For example, creating a file, using it for a short period of time, and then deleting it may cause no disk activity at all.
Soft Updates require periodic flushing of the metadata to nonvolatile storage.
In FreeBSD, the sysctl variables that control the delays between periodical data and metadata flushes to permanent storage (in seconds) are:
kern.filedelay: 30 kern.dirdelay: 29 kern.metadelay: 28
The delays for file data, directory metadata, and file allocation metadata are different to avoid IO spikes.
- McKusick's own notes on soft-updates and asynchronous writes in UFS.
de:Softupdates ja:Soft updates