Soft updates
Encyclopedia
In computer
Computer
A computer is a programmable machine designed to sequentially and automatically carry out a sequence of arithmetic or logical operations. The particular sequence of operations can be changed readily, allowing the computer to solve more than one kind of problem...

 file system
File system
A file system is a means to organize data expected to be retained after a program terminates by providing procedures to store, retrieve and update data, as well as manage the available space on the device which contain it. A file system organizes data in an efficient manner and is tuned to the...

s, soft updates is an approach to maintaining disk integrity after a crash or power outage. They are an alternative to journaling file system
Journaling file system
A journaling file system is a file system that keeps track of the changes that will be made in a journal before committing them to the main file system...

s.

Instead of duplicating metadata writes in a journal, soft updates work by properly ordering the metadata writes to guarantee consistency after a crash. Like journaling, soft updates do not guarantee that no data will be lost, but 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
FreeBSD
FreeBSD is a free Unix-like operating system descended from AT&T UNIX via BSD UNIX. Although for legal reasons FreeBSD cannot be called “UNIX”, as the direct descendant of BSD UNIX , FreeBSD’s internals and system APIs are UNIX-compliant...

 by Marshall Kirk McKusick
Marshall Kirk McKusick
Marshall Kirk McKusick is a computer scientist, known for his extensive work on BSD, from the 1980s to FreeBSD in the present day. He was president of the USENIX Association from 1990 to 1992 and again from 2002 to 2004, and still serves on the board. He is also on the editorial board of...

 and are now available across the BSD
Berkeley Software Distribution
Berkeley Software Distribution is a Unix operating system derivative developed and distributed by the Computer Systems Research Group of the University of California, Berkeley, from 1977 to 1995...

s.

Operation

Soft updates allow only asynchronous metadata
Metadata
The term metadata is an ambiguous term which is used for two fundamentally different concepts . Although the expression "data about data" is often used, it does not apply to both in the same way. Structural metadata, the design and specification of data structures, cannot be about data, because at...

 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 meta-data writes by temporarily "rolling back" any part of a meta-data 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 at this time). Recovery then simply becomes a matter of running a background walk of the file system when it is next mounted to garbage collect
Garbage collection (computer science)
In computer science, garbage collection is a form of automatic memory management. The garbage collector, or just collector, attempts to reclaim garbage, or memory occupied by objects that are no longer in use by the program...

 any allocated space orphaned in leaks. This also permits the filesystem to selectively flush certain files without having to flush all meta-data blocks or all of the records.

Data that is unlinked from the meta-data 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. However, some disadvantages of soft updates are that it is very complex to implement correctly, that it still causes a lot of scattered meta-data writes that have to be forced to disk periodically to make sure that the on-disk version does not lag behind the in-memory one too much, and that these scattered writes may be more likely to trigger inconsistencies when the disk (or the RAID controller) flushes its internal write cache in arbitrary order.

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.

External links

  • McKusick's own notes on soft-updates and asynchronous writes in UFS
    Unix File System
    The Unix file system is a file system used by many Unix and Unix-like operating systems. It is also called the Berkeley Fast File System, the BSD Fast File System or FFS...

    .
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK