Ext3 log Mode

Source: Internet
Author: User

Ext3 log Mode

Http://blog.sina.com.cn/s/blog_5d4ab4b40100dosx.html

EXT3 supports multiple logging modes

Ext3 is a high-level version of the Ext2 file system, fully compatible with EXT2, and the main difference from ext2 is the ability to store fast-updating files. When the computer reads or writes data from the disk, it must guarantee the consistency of the files and directories in the file system, and all the data in the log files are stored in the storage device as chunks, and the file system is created when the disk is partitioned, and the storage data and organization data are supported in the form of file and directory. Linux files and directories using a hierarchical file system, the file system is generally installed in the system by using the "mount" command installed, used by the file linked list stored in the file/etc/fstab, for maintenance and installation of the file list is stored in the/etc/mtab.

EXT3 provides a variety of logging modes, that is, whether to change the file system metadata, or change the file system data (including the changes in the file itself), the Ext3 file system can be supported, the following is the/etc/fstab file boot when the three different log modes activated:

Data=journal Log Mode
The log records include all data and metadata that changed the file system. It is the slowest of the three ext3 log modes, but it minimizes the likelihood of errors occurring. Using the "Data= Journal" mode requires the ext3 to write each change to the file system 2 times and write to the log 1 times, which reduces the overall performance of the file system, but it is indeed the most beloved mode of the consumer. Since the metadata and data updates are recorded in ext3, these logs will work when a system restarts.

data=ordered Log Mode
Only metadata that changes the file system is recorded, and the overflow file data is added to the disk. This is the default ext3 log mode. This mode reduces the redundancy between writing to the file system and writing to the log, and is therefore faster, although the changes in the file data are not recorded in the log, but they must be done and executed by the EXT3 daemon program before changes in the file system metadata associated with it, that is, in the number of record elements This will slightly reduce the performance (speed) of the system, but ensures that the file data in the file system is synchronized with the corresponding file system metadata.

Data=writeback Log Mode
Only records changes to the file system's metadata, but according to the standard file system, the write program still records changes to the file data on disk to maintain file system consistency. This is the fastest ext3 log mode. Because it only records metadata changes, without waiting for updates related to file data such as file size, directory information, and so on, the update to the file data and record metadata changes can be out of sync, that is, ext3 is a log that supports asynchronous. The flaw is that when the system shuts down, the updated data is not resolved because it cannot be written to the disk, which is not yet possible.

There are differences between the different log modes, but the method is as convenient as the settings. You can use the Ext3 file system to specify the logging mode, which is done by/etc/fstab startup. For example, choose Data=writeback Log mode, which can be set up as follows:
/dev/hda5/opt ext3 Data=writeback1 0

In general, the Data=ordered log mode is the default mode for the Ext3 file system.

Select log Mode

1. Consider data integrity
With the Ext3 file system, data integrity can be reliably guaranteed when an abnormal shutdown occurs, and the type and level of data protection can be selected. For example, you can choose to ensure that the file system is consistent, allowing data on the file system to be compromised when it is not properly shut down, which can increase some speed (but not all) in some situations. Alternatively, you can choose to keep the data consistent with the file system, which means that no data garbage will be seen in the newly written file after an abnormal shutdown. This security choice to keep the data consistent with the file system is usually the default setting.

In most cases, the user is adding write data at the end of the file. In some cases (such as a database), users write data in the middle of an existing file or even overwrite an existing file. This is typically done by truncating the file before writing the data. If you select data=ordered mode and the system crashes while the file is being written, the data block may be partially overwritten, but the newly added data write process is not completed, so this incomplete data block will not be part of the file data. The only way to get the remaining chunks of data after a crash is to have a program rewriting the middle of an existing file during a crash, which uses the Fsync () and O_sync forced write operations to ensure that in this case the write is in a specific order.

2. Consider the speed
Ext3 writes data more often than ext2, however, ext3 is still faster than ext2 (even for high-speed data streams). This is because the EXT3 log has the ability to optimize the drive head rotation. By selecting one of the 3 log modes, you can choose to optimize the speed, but this will more or less result in some incomplete data, and then compare these three log modes.

Using option Data=writeback can significantly improve speed, but it also reduces the protection of data consistency. Choose other log mode, the data consistency protection is basically the same as the Ext2 file system. The difference is that in normal operation, the system is constantly maintaining the integrity of the file system, including frequent shared write operations to create and delete large numbers of small files. If you switch from ext2 to ext3 and find that the application performance is significantly degraded, the option Data=writeback may be helpful in improving performance. Even if you don't get data consistency protection, you can still enjoy the benefits of ext3 (the filesystem is always consistent). In many log file systems, this mode is set to the default mode.
data=ordered (default mode) provides the ability to keep data consistent with the file system, which means that no junk data is seen in newly written files when it is not properly shut down.
to ensure a moderate speed in most cases, the data=journal mode requires a larger log. Of course, the recovery time required after an abnormal shutdown is also longer, but some database operations are faster.

in general, it is recommended to use the default mode. To change the mode, add the data= mode option to the appropriate file system in the/etc/fstab file.

In this way, you can weigh tradeoffs between speed and file data integrity, and you can adjust the speed for some special applications.

The Linux operating system is the fastest growing number of users in recent years, ext3 as the first officially supported log file system, fully compatible with ext2. EXT3 provides a variety of log mode support, improve the performance of Linux system, solve the problem of inconsistencies in the system. The Ext3 file system is a great and promising file system.

Ext3 log Mode

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.