||This article includes a list of references, but its sources remain unclear because it has insufficient inline citations. (June 2011)|
Soft updates is an approach to maintaining file system meta-data integrity in the event of a crash or power outage. Soft updates work by tracking and enforcing dependencies among updates to file system meta-data. Soft updates are an alternative to the more commonly used approach of journaling file systems.
Method of Operation
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.
FreeBSD supports soft updates for the UFS file system and they have been enabled by default during installation for many years. Soft updates are manually enabled or disabled during file system creation with an option to the newfs command. They can be disabled or enabled anytime thereafter with an option to the tunefs command. FreeBSD 9.0 introduced a journaling supplement to soft updates for the purpose of eliminating a background fsck for garbage collection after a crash.
Comparison to Journaling File Systems
Neither journaling, nor soft updates guarantee that no data will be lost, but they do make sure that the filesystem remains 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.
- McKusick (2005), Chapter 8, Section 8.6
- "newfs". Freebsd.org. 2011-06-22. Retrieved 2013-10-23.
- "tunefs". Freebsd.org. 2011-06-22. Retrieved 2013-10-23.
- "FreeBSD 9.0-RELEASE Release Notes". .us.freebsd.org. Retrieved 2013-10-23.
- "Manual Pages: mount". Openbsd.org. 2011-04-05. Retrieved 2013-10-23.
- "Announcing NetBSD 6.0". Netbsd.org. Retrieved 2013-10-23.
- Gregory R. Ganger and Yale N. Patt (1994). "Metadata Update Performance in File Systems." Proceedings of the USENIX Symposium on Operating Systems Design and Implementation (OSDI), Nov. 1994, pp. 49–60. (this is the original reference)
- McKusick, M. (2002). "Running "fsck" in the Background." Proceedings of the BSDCon 2002. 55-64.
- McKusick, M. and Ganger, G. (1999). "Soft Updates: A Technique for Eliminating Most Synchronous Writes in the Fast Filesystem." USENIX Annual Technical Conference. 1-18.
- McKusick, M. and Neville-Neil G. (2005). The Design and Implementation of the FreeBSD Operating System. Addison-Wesley. ISBN 0-201-70245-2.
- Seltzer, M. et al. (2000). "Journaling Versus Soft Updates: Asynchronous Meta-data Protection in File Systems." USENIX Annual Technical Conference. 71-84.