The integrality that log file system can cut off the power in systematic happening or integral data assures when other system breakdown,Linux is one of operating systems with at present most system of supportive log file,The log file system that article key studied Linux is commonly used:EXT3, ReiserFS, XFS and JFS log technology,The test tool PostMark that uses a level and Bonnie++ had a test to them,Gave out detailed function is analysed,To Linux server application has fundamental referenced value.
One, overview
System of file of so-called daily record is on the foundation of traditional file system,The daily record that adds file system to change is recorded,Its design thought is:Dog the change that records file system,Record metabolic content the daily record.Log file system stores a log to record in disk partition,Keeping an operation is above all to recording a file to undertake operating,If whole because some is planted,keep an operation reason (if the system drops report) and interrupt,When the system restarts,Before can restore to interrupt according to log record keep an operation.In log file system,The change of all file systems is recorded to the log,At regular intervals,The metadata after the meeting will be newer and file content keep file system into disk.Making any changes to metadata previously,File system driver can write an entry to the middle of the log,This entry described it what to will do,Next its modification metadata.At present the log file system of Linux basically has:In the Ext3 that develops on Ext2 foundation,According to the ReiserFS that object-oriented thought designs,By the XFS that transplanting of SGI IRIX system comes over,By the JFS that transplanting of IBM AIX system comes over,Among them EXT3 is completely compatible EXT2,Its disk structure and EXT2 just the same,Just add log skill;After that system of three kinds of files used B extensively to cultivate in order to improve the efficiency of file system.
Two, Ext3
System of Ext3 file is direct develop from Ext2 file system and come,Ext3 file system is already special and at present stable reliable,It is completely compatible Ext2 file system,The user transfers smoothly the file system with sound function of a log.The thought of system of Ext3 log file undertakes to file system namely any advanced revise divide two paces to undertake.Above all,Wait for write piece a carbon is deposited in the log;Next,When the I/O number that should send past daily record is finished according to conveying (namely data submits a daily record) ,Piece keep file system.When the I/O number that should send past file system is stopped according to conveying (namely data refers file system) ,A carbon in the log be discarded.
2.1Ext3 log mode
Ext3 can make a daily record to metadata only already,OK also to the file at the same time data piece makes a daily record.Specific for,Ext3 is offerred the following mode of three kinds of logs:
Log (Journal)
Know exactly about sth of file system place is occupied and the change of metadata notes a daily record.This kind of mode decreased to lose every file place to make modification opportunity,But it needs a lot of additional disk to visit.For example,When a new document is founded,Its place data piece must duplicate to regard a log as the record.This is the safest with the slowest Ext3 log mode.
Book (Ordered)
Just note a daily record to the change of file system metadata only.However,Ext3 file system mixes metadata relevant data piece undertake in group,So that write metadata,data piece is written before disk.Such,The chance that can reduce the data inside the file to damage;For example,Ensure any writes a visit to get a daily record completely protection that increase a file.This is default mode of Ext3 log.
Write time (Writeback)
Just note a daily record to the change of file system metadata only;This is the method that discovers in system of other log file,Also be the fastest mode.
2.2 log piece equipment (JBD)
Itself of system of Ext3 file does not handle a daily record,Use log piece device however (Journaling Block Device) or the general kernel layer that calls JBD.Ext3 file system calls JDB exemple Cheng to be in in order to ensure system in case its follow-up operation when occurrence breakdown won't damage disk data structure.Between Ext3 and JDB be based on three main unit substantially interactively:The log is recorded,Atomic operation and general affairs.
The description that log record is the elementary operation that file system will give out substantially.In system of certain log file,The byte range that log record includes to operate place to revise only and byte are in the position of rest in file system.However,The whole buffer that the log record that JDB layer uses revises by elementary operation is comprised.This kind of means may waste space of a lot of logs (for example,A when change bitmap merely when elementary operation when) ,But,It is quite fast still,Because JBD layer is direct strong to buffer gentle area undertakes first times operating.
The system calls the either of modification file system to differentiate normally to operate a series of elementary operations of disk data structure.If these elementary operations return machine of accident without the whole system that finish delay,With respect to data of meeting attaint disk.To prevent data to damage,Ext3 file system must ensure every system moves means of atomic of in order to to undertake handling.A group of atomic operation is pair of disk data structures elementary operations,This group of elementary operations are corresponding a separate advanced operation.
The reason that stems from efficiency,JBD layer is used to the processing of the log in group method,In putting the log record that attributes processing of a few atomic operations in an alone general affairs in group namely.In addition,All log record related to a processing must be included in same a general affairs is medium.All log record of a general affairs is deposited in the log successive piece in.JBD layer comes to every general affairs handle as whole.For example,This office just reclaims to use when all data in should including the log in a general affairs to record only refer file system piece.
Three, ReiserFS
ReiserFS is a very excellent file system,Its developer has daring and resolution very much,Whole file system is completely design from the beginning.At present,The file system that ReiserFS can run about a hundred G easily,This is in company level application is very important.ReiserFS is the thought design with object-oriented basis,By semantic layer (Semantic Layer) and memory layer (Storage Layer) is comprised.The definition that semantic layer basically is the government that names a space to the object and object interface,In order to decide the function of the object.The management that stores the layer basically is pair of disk spaces.Semantic layer and memory layer are to pass key (Key) of connection.Semantic layer is passed undertake to object name analytic make key,Memory layer finds a target through key in space of the storage on disk,Key value is overall situation is unique.
3.1 semantic layer is main interface
Every file owns port of 1) file an interface ID,This ID marks collect of a method,All interface that this method collect includes file of visit ReiserFS.
ReiserFS of interface of 2) attribute realized a kind of new interface,The attribute of avery kind of the file should make a file,The content that the value of attribute is this file,Visit in order to come true to the catalog type of file attribute.
Catalog of 3) Hash interface is file name to the map watch of the file,ReiserFS is to pass B + tree to realize this piece of map to express.Because file name is,lengthen,And sometimes file name will be very long,So file name does not suit to regard key as the value,Reason introduced Hash function to produce key to be worth.
Interface of safety of 4) safe port handles all security to check,It is normally spark by file interface.It is with reading a document below exemple:The Read method of file interface can call the method of Read Chech of safe port to undertake security is checked before reading in file data, and so that check,the Read method that latter can call attribute file again reads in file attribute.
5) (Item) interface interface basically is a few pairs a method that has balancing handling,Include:fractionation,evaluate,Fu is written,increase,delete,Insert reach search.
6) key allocates (Key Assignment) interface should allocate a key when,Key allocation interface can be sparked.Avery kind of an as corresponding as its key allocates a method.
Layer of 3.2 memory
ReiserFS is with B+ the tree stores of data, if its structure pursues:
There is to call in each node in B+ tree (Item) data structure.It is container of a data,Belong to a node only,The main unit that is node management space.The place that be like a graph is shown,Include the following content:
1) Item_body:data region
2) Item_key:key value
3) Item_offset:The start of data region is measured in the deflection in node
4) Item_length:The length of data region
5) Item_Plugin_id:Interface ID.
A differs in order to store data that ReiserFS designed a variety of differring,Basically the following is plant:
1) Static_stat_data:Static statistic data,Those who include a file is possessory,Visit attributive,Found time,The closest modification time,Link number
2) Cmpnd_dir_item:Include each list
3) Extend_pointers:Point to dish of area (Extend)
4) Node_pointers:Point to a node
5) Bodies:Those who include is the fraction data of the file
3.3ReiserFS log
Like Ext3,ReiserFS also has pattern of three kinds of logs,Namely Journal, ordered, writeback.At the same time,ReiserFS introduced two kinds of logs to optimize a method:Copy-on-capture and Steal-on-capture.Copy-on-capture: ?ale of Ru of ? of a surname of contraction of money post Mou looks Xing of Duo of contraction of bad neon of Jiao of post Xin thorn protects firewood Zou a flat stone on iron rammer with ropes attached at the sides ? bucket Teal-on-capture of ? of excuse me of laborious of ? of ? of round ? of tip of besmear of contraction of Mou of reef of shelfing ? of ? of Jin of annulus of thick Bu of last of colour Sun Zhui putting in order climbing over a wall:Become piece when be being revised by many general affairs,That general affairs that refers the latest only just this piece keep file system actually,Other work does not write this piece.
Four, XFS
XFS is a kind of high-powered 64 file system,Develop to replace system of original EFS file by SGI company.Data of the consistency through maintaining Cache, fixed position and request of distributinging processing disk come to XFS the visit that offers the low defer of data, tall to file system bandwidth.At present SGI has transplanted XFS file system from IRIX Linux.
Group of 4.1 allocation (Allocation Groups)
When establishing system of XFS file,Equipment of ground floor piece is broken up eight or more the linear area with many equal size (Region) ,The user can imagine them " piece " (Chunk) or " linear limits (Range) " ,In XFS,Every area calls " of group of a " allocation.Allocate group it is exclusive,Because every allocate group of index node that manage his (Inode) with free space,It is actually allocate these group translate into subsystem of a kind of file,These subsystem transparently inside system of file of consist in XFS.Had allocate group,XFS code will allow many lines Cheng and process to move with collateral means continuously,Although they make multi-line Cheng and process mediumly carrying out large-scale IO on same document system,operate.Because of this,XFS and union of photograph of hardware of certain high end,Will obtain high-powered and won't make file system becomes bottleneck.Allocate group interiorly to use efficient B+ tree to dog main data,Have superior performance and huge but expansibility.
4.2 log is recorded
XFS also is system of file of record of a kind of log,Restore after it allows to guide afresh accidentally quickly.Like ReiserFS,XFS uses logistic daily record;It unlike Ext3 in that way literal file systematic piece records a daily record,What use a kind of efficient disk format to record metadata however is fluctuant.With respect to XFS character,Logistic log record is suit very much;On high-end hardware,The log often is the contention in whole file system.
Textual link:Http://www.linuxfans.org/nuke/modules.php? Name=Forums%26file=viewtopic%26t=167667
...