Soft Updates: A technique for eliminating most synchronous writes (II.)

Source: Internet
Author: User

Section 3rd tracking and ensuring update dependencies

This section describes the BSD Soft updates data structure and the role it plays in ensuring the update dependencies described in section Ii. The data structures and algorithms described here can completely eliminate the synchronous write operations of BSD FFS in all cases except file truncation and Fsync system calls.

The key feature of Softupdates is to track the update dependencies between each change in the cache block. Thus, for blocks that include 64 I-nodes, the system may maintain up to 64 dependency structures for these I-nodes in the buffer. Similarly, for directory blocks that contain 50 of names, the system maintains a maximum of 50 dependency structures for these names.

With such detailed dependency information, circular dependencies between blocks will no longer be a problem. Whenever the system wants to write the I-node in the buffer, they can be safely written and eventually enter the disk. The I-node, which cannot be safely written for a while, will be temporarily rolled back to a secure value in the past when the buffer is synchronized, and the current value is restored when the write disk is finished. The buffer is locked at the time of the rollback and is unlocked after the content is restored. The process that requests the write buffer will be blocked until the buffer is restored to its original state.

3.1 Dependency Data structure

Our implementation uses a variety of data structures to track pending update dependencies in the file system architecture. Table 1 lists the dependency structures used, the primary features, and the blocks associated with them. These dependency data structures are assigned and associated to blocks when a file operation completes. In kernel-memory replicas, they are associated with pointers to the headers of the corresponding blocks. The two general styles for all listed dependency structures are the worksheet (worklist) structure and the structure that holds the tracking dependency state.

Table 1 dependency structures used in the BSD softupdates implementation

The worklist structure acts as the public header for the first item of all dependency structures. It contains a series of connection pointers, and a field that represents the type of struct to which it is embedded. The worklist structure makes it possible to connect different types of dependency structures to the same list. Softupdates code can traverse this heterogeneous list, use the Type field to identify the dependency structure it encounters, and do the appropriate action accordingly.

A typical application to worklist is to associate a series of dependencies to the buffer. Each buffer in the entire system is appended with a worklist header pointer. Any update dependencies associated with the buffer are received in this list. After the buffer is locked, the I/O system sends the buffer to the relevant code before the write begins, softupdates that it will begin a write operation and traverse the dependencies associated to the buffer for proper data rollback. After disk writes are complete, the I/O subsystem calls the Softupdates code again to tell the write operation to complete before unlocking the buffer. The code will perform the appropriate roll-forward operation to free those dependency structures that have completed writing.

Another softupdates code-maintained table is Tasklist, which indicates the background tasks that the work daemon needs to perform. The dependencies that have been safely written, but that have been blocked for some reason (such as locks or I/O) are described by a tray program appended to the tasklist. The Syncer daemon is awakened every second (this process is also a softupdates worker process) that invokes Softupdates code to handle the project in Tasklist. Actions in a table are related to the type of project. For example, the blocks listed in the FREEBLKS structure will be marked as idle in the block-bit mapping table, and the reference count for the associated I-node will be reduced for the DIRREM structure and may trigger a file deletion operation.

The state of the dependency relationship. Most dependency structures have a series of flags to describe the completion state of the related relationships. The modified cache block may be written to disk at any time. When the I/O system hands the buffer to the Softupdates program (before and after the disk is written), the state associated with it determines what action will be performed. Although different structures have different meanings, the three main, pervasive states are:

Attachment (attached)

This flag indicates that the buffer containing this dependency structure has not yet been written to disk. This flag is zeroed to reflect the rollback in the buffer before the buffer write disk that includes the dependencies that must be rolled back. When the write disk completes, the buffer of the dependency structure that the flag is zeroed in will revert to its original state. Therefore, if this flag is reset, the corresponding dependency must not be released because it includes the need for a recovery operation, at which time the release will cause the loss of the information.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.