CN101162459A - Built-in file systems - Google Patents

Built-in file systems Download PDF

Info

Publication number
CN101162459A
CN101162459A CNA200610117114XA CN200610117114A CN101162459A CN 101162459 A CN101162459 A CN 101162459A CN A200610117114X A CNA200610117114X A CN A200610117114XA CN 200610117114 A CN200610117114 A CN 200610117114A CN 101162459 A CN101162459 A CN 101162459A
Authority
CN
China
Prior art keywords
tree
file system
data
cluster
node
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CNA200610117114XA
Other languages
Chinese (zh)
Inventor
李禹雄
于涛
范树春
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
SHANGHAI WAN'AN ELECTRONICS TECHNOLOGY Co Ltd
Original Assignee
SHANGHAI WAN'AN ELECTRONICS TECHNOLOGY Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by SHANGHAI WAN'AN ELECTRONICS TECHNOLOGY Co Ltd filed Critical SHANGHAI WAN'AN ELECTRONICS TECHNOLOGY Co Ltd
Priority to CNA200610117114XA priority Critical patent/CN101162459A/en
Publication of CN101162459A publication Critical patent/CN101162459A/en
Pending legal-status Critical Current

Links

Images

Abstract

The present invention relates to an embedded type file system. A whole file system is set into a tree-shaped data structure; Phase Tree algorithm is adopted, and a root node points to the file system; the system is subdivided into three tree-shaped subdata structures which are respectively a complete tree, a branch tree and a processive tree; three tree-shaped data structures can continuously execute conversion and modifies the root nodes of the file system; the operation of the whole file system has atomicity; each tree-shaped data structure only modifies discrepant parts in conversion. The present invention has the advantages of promoting performance greatly and realizing the reliability of the file system. When the system is in unnormal electricity failure, the whole file system can still keep consistency without being damaged and needs no file system scanning and repairing operation when starting up again, which ensures that the system can start up as rapidly as in normal conditions. The present invention has the advantages that the present invention is simple to be realized and high in efficiency, does not consume too many system resources, and occupies no extra system space, which is very applicable to embedded type systems.

Description

Embedded file system
Technical field
The present invention relates to a kind of, particularly a kind of embedded file system.
Technical background
The reliability of computer document system is meant in improper outage etc. in particular cases, the robustness of file system.After special circumstances occurred, a reliable file system can guarantee oneself still to be in a correct state, and did not influence in the above continuation operation (may lost part data).After the PC special circumstances appearance in use, even file system does not guarantee its reliability, the user also can come file system is repaired by moving similar fsck program or third party's instrument.Yet in embedded system, this method is then unworkable, because suitable embedded system does not have software administration person, they may be installed under the unattended operation environment in a large number, if carry out file system reparation operation in case the appearance outage will be fetched them, this is inconceivable.So reliability is particularly important for embedded file system.
Summary of the invention
The objective of the invention is to the invention provides a kind of embedded file system at the defective that exists in the prior art.Whole file system is configured to tree-like data structure, adopt Phase Tree algorithm, and there is a root node to point to file system, be subdivided into three tree-like sub-data structure in the system, be respectively Recorded Tree, Branching Tree and Recording Tree, Recorded Tree has write down the file system mirror image that is currently located on the disk, Recording Tree has write down up-to-date file system mirror image, Branching Tree has write down the mirror image that is positioned at coherency state apart from nearest so far file system, three tree form data structures can constantly be changed, and the root node of revised file system, whole file system operation has atomicity, each tree data knot is only revised the part of difference in conversion, system comprises following steps:
The atomization of A file system;
B determines root node (metaroot);
C opens up a perform region;
The D conversion operations, all carry out operating on the FAT2 of FAT, and all operations do not influence the consistance that is currently located at file system on the disk, after modification is finished, revise root node (BPB) again, with FAT2 as new effective FAT table, with the root directory workspace as new root directory;
E sets up FAT Phase Tree data structure, and former subfile system adopts Fat Phase Tree algorithm;
The F system initialization is noted down the position of this directories/files in the meta subtree;
The G operating writing-file, adopt the mode of copy-on-write to carry out write operation, relate to the data of modification for all, all must get and duplicate a modification in the above then on the free space, more amended data are replaced legacy data at last at original system;
The newly-built node Cluster operation of H;
I deletion of node Cluster operation;
The J read operation.
Because revising the root node operation is (finish, or do not do, can not produce a situation of having done half) of atomicity, institute is so that whole file system operation also has atomicity, thereby can not produce inconsistent state again.In order to raise the efficiency, every tree is only revised the part of difference in conversion, so just avoided the modification of big data, in addition, critical data is cushioned the access speed that also can accelerate critical data in internal memory, also will promote the efficient of this document system significantly.
This document system adopts Phase Tree algorithm, in the time of the improper outage of system, whole file system still can keep consistency and not be damaged, and need not to do any file system scanning when starting shooting once more and repair operation, the system that makes can start up as normal condition is quick.
Utilize and optimize improved Phase Tree algorithm, successful has become a reliable file system with the original ext2 filesystem conversion of Linux.
Node in the tree data is file system metadata Meta Data, but not directory tree, when write operation is arranged, just in free space, create the branch of this tree form data structure, carry out atomizing renewal again, old tree form data structure is updated to branch, one step of operation finishes, the centre can not be interrupted, and guarantees the consistance of file system.
Three tree-like sub-data structure Phase Treee exist simultaneously, and each tree-like sub-data structure all has oneself independently meta root.Wherein one has been write down the current complete consistent state that writes on the disk, is called Recorded Tree, and this tree-like total data all is positioned at disk.Another tree-like sub-data structure has also write down a consistent state, but its meta root is arranged in Installed System Memory, and wherein has some data and also be not written in the disk and (be Dirty Buffer), is called Recording Tree.The 3rd tree-like sub-data structure all is arranged in Installed System Memory, is not in consistent state, and we are called Branching Tree to it.
Three tree-like sub-data structure are represented different states respectively, and constantly cyclic transformation, and Recorded Tree has write down the state when front disk accurately; Recording Tree has write down the data that next time will be written into, and Branching Tree has then write down operating system and it seems up-to-date file system data, and it has also comprised one and has discharged tabulation, has write down d/d inode and block.When making atomic update each time, three file system are just done once and are switched, Recording Tree is written to disk and is converted to Recorded Tree, Branching Tree is corrected to a up-to-date coherency state and is converted to Recorded Tree, and Recorded Tree becomes BranchingTree after then upgrading write operation.
All adopt the copy-on-write mode when all operations carries out, not only guarantee the consistance of file system metadata, also guarantee the consistance of file data.
Advantage of the present invention is to promote performance significantly, and the reliability of realization file system, in the time of the improper outage of system, whole file system still can keep consistency and not be damaged, and need not to do any file system scanning when starting shooting once more and repair operation, the system that makes can start up as normal condition is quick, have the advantage that realization is simple, efficient is high, exceed consume system resources and can additionally not occupy file system space, be suitable for very much embedded system.
Description of drawings
Fig. 1 tree-like sub-data structure synoptic diagram of the present invention;
Fig. 2 three tree form data structure synoptic diagram of the present invention;
Fig. 3 node structure synoptic diagram of the present invention;
1 bitmap block Block bitmaps, 2 node bitmap Inode bitmaps, 3 groups of description block GroupDescriptors, 4 constituent element file Group metafile, 5 root node Meraroot, 6 node meta file Inode metafile, 7 ode table Inode Table
Embodiment
Further specify embodiments of the invention below in conjunction with accompanying drawing: referring to Fig. 1, the atomization of FAT32 file system
Mean that with the FAT32 compatibility storage of this document system on disk meets the FAT32 standard of Microsoft fully, atomization means in the file system part to be wanted to carry out according to the mode of former subfile system fully to the tissue and the operation of data.
Root node (metaroot)
Must there be a root node (metaroot) in atomization file system demand file system, and this root node has pointed to the current file system data.In the FAT32 file system, BPB just can be used as root node and treat, because stored the position of every other file system in this sector: FAT table position and root directory position.
The workspace
Former subfile system requirement except the current file system data area is arranged, also will be opened up a workspace in addition on storage medium.We can utilize the two FAT list structures among the FAT32BPB to realize this point.At first have a look the description of FAT32 expansion:
>>_u32?fat32_length;/*sectors/FAT*/
>>_u16?flags;/*bit?8:fat?mirroring,low?4:active?fat*/
>>_u8?version[2];/*major,minor?filesystem?version*/
>>_u32?root_cluster:/*first?cluster?in?root?directory*/
>>_u16?info_sector;/*filesystem?info?sector*/
Exist two FAT tables in the FAT32 file system altogether, having only first generally speaking is effectively, and second FAT table only plays a part backup.But flags has also made regulation to how using this two FAT table: if when the most significant digit of flags is set up, system only can use in these two FAT tables, flags low four then Mk system use which FAT table.We can be provided with the most significant digit of flags like this, and when FAT1 was current effective FAT table, we can use FAT2 as the workspace, otherwise when FAT2 was current effective FAT table, we can use FAT1 as the workspace.
File system data also has catalogue except the FAT off-balancesheet, and we can look for the workspace of a free space as catalogue on disk when needs are revised catalogue data.
Conversion operations
Suppose that current effective FAT table is FAT1, when carrying out file operation, if modification directory information, we can look for the workspace of a clear area as catalogue again on disk space, all catalogues are modified in above the catalogue workspace carries out, and all carry out operating on the FAT2 of FAT.All like this operations do not influence the consistance that is currently located at file system on the disk.After modification is finished, revise root node (BPB) again, with FAT2 as new effective FAT table, with the root directory workspace as new root directory.
Algorithm and data structure, referring to Fig. 2,
Former subfile system adopts Fat Phase Tree algorithm, file system organization is become form (the metadata tree of one tree, rather than directory tree), when carrying out file system operation, (workspace) creates a new tree on the original file system free space, switches by revising metaroot then.Conversion operations uses 3 trees simultaneously in system for convenience, is called Recorded Tree respectively, Recording Tree, Branching Tree.Recorded Tree is noting down current file system on the disk, and Recording Tree is noting down present file system, and Branching Tree is noting down that consistent file system mirror image nearest apart from the current file system.Operating on the Branching Tree of file system carried out, and when Branching Tree reaches a consistent state, just at once it copied to RecodingTree.The system backstage has a process to be responsible for regularly triggering conversion operations, and the content of RecordingTree is copied to and replaces Recorded Tree on the disk in the time of conversion.
FAT PHASE TREE algorithm
Because phase tree algorithm proposes on ext2 file system basis, and ext2 belongs to typical UNIX INODE type file system, each file or catalogue all have the inode node of a correspondence, in this inode node order stored all its block that take number, so just can the position of locating file/catalogue data on disk by inquiring about that block in the inode node shows.What but the FAT file system adopted but is the chained list mode.
File system gets reliability loose definition and strict definition, and under the situation of the improper power down of system encounters, the loose definition only metadata of demand file system keeps consistency, and strict definition also will guarantee the consistance of file internal data.If directly on FAT, use phase tree algorithm, then can't guarantee the consistance (because it can't accomplish copy on write) of file data.So phasetree can not be directly used in the FAT file system, must make modification to it, create a kind of brand-new algorithm and data structure---FAT Phase Tree.
FAT Phase Tree data structure, referring to Fig. 3,
Describe the file system of FAT32 with a binary tree, the root node of tree is represented MetaRoot, and its left subtree is represented MetaData, and right subtree is represented the FAT table.
Two category nodes are arranged in the MetaData subtree, and a kind of Cluster of being node (representing with circle) is represented one already used bunch, and another kind is file/directory node (representing with square), represents a file/catalogue.For the Cluster node, its left subtree is represented next Cluster in the chained list of living in its place FAT table.If this Cluster belongs to a file, then it does not have right subtree, if Cluster belongs to a catalogue, then its right subtree is represented the file/sub-directory in this catalogue Cluster data.
For file/directory node, its left subtree is represented the FAT chained list of this document/catalogue, and right subtree is represented the alternative document/sub-directory in this document/catalogue catalogue of living in.
Right subtree is represented the FAT table, and it also is a binary tree, and right node is represented the next Cluster on its place chained list, and left sibling is represented next bar chained list.For easy-to-look-up, idle Cluster also is organized into an idle Cluster chained list (so not doing) on disk.
Algorithm
System initialization
Check the proof test value of BPB in the time of system start-up, if the verification failure then recovers the BPB of backup.System reads in current FAT and shows into buffer zone from disk, set up Recording Tree and Branching Tree then.
Open the directories/files operation
Because catalogue also is a file in the FAT32 file system, also be open file operation so open directory operation.
This operation is fairly simple relatively, with opening not too big difference of directories/files operation in traditional FAT32 file system, in the process of just opening, needs the record position of this directories/files in the meta subtree down, to make things convenient for subsequent operation.
Operating writing-file
Because catalogue also is a file in the FAT32 file system, also be operating writing-file so write directory operation.
This operation is that most critical also is the most complicated one in all operations, because we are except guaranteeing the consistance of file system metadata (FAT table), also to guarantee the consistance (consistance of directory content and the consistance that writes data) of its data, so we must adopt the mode of a kind of copy-on-write to carry out write operation, just relate to the data of modification for all, we must get at original system and duplicate a modification in the above then on the free space, again amended data are replaced legacy data at last, and can not directly on legacy data, revise, because if directly on legacy data, revise, when retouching operation cuts off the power supply to half the time, then can cause file system to get inconsistency.
The concrete operations step can followingly be carried out:
1) determines cluster number (being called Cluster A) that will write according to the cluster chained list (can in the meta subtree, obtain) of this document;
2), look for the Cluster (being called Cluster B) of a free time by searching the FAT subtree of Branching Tree.And copy the content of Cluster A to Cluster B;
3) a newly-built Cluster type node, its content is Cluster B, on Cluster B, carry out write operation, then it is replaced the ClusterA node on the former meta subtree, discharge Cluster A node again, and in the FAT subtree, Cluster A is moved in the idle Cluster chained list;
4) check the position of Cluster B in the meta subtree, obtain its father node Node P.If its father node is the Cluster type node, then forward step 8 to; If its father node is file/Directory Type node, then forward step 5 to; If its father node is metaroot, then forward step 7 to;
5) Node P is file/Directory Type node, and Cluster B is first bunch of this document.Node P is constantly searched the father node operation, and up to the father node that finds its first Cluster type (Cluster C), this is exactly the residing Cluster of Node P.By searching the FAT subtree of Branching Tree, look for the Cluster (being called Cluster D) of a free time; And copy the content of Cluster C to Cluster D, discharge Cluster C node then, and in the FAT subtree, Cluster C is moved in the idle Cluster chained list;
6) Cluster D is regarded as Cluster B, change step 4 over to;
7) Node P is the metaroot node, and Cluster B is first bunch of this document, that is to say that Cluster B becomes new root directory starting cluster, and this changes and the new starting cluster of root directory down in record;
8) modification that will set writes disk (content of Cluster and FAT table content).Particularly importantly for being marked as idle Cluster afterwards, if it in have modification, then the content of revising should not write back yet, and should on disk, keep its data constant.
Newly-built Cluster operation
Newly-built Cluster operation is similar substantially with write operation, and the concrete operations step can followingly be carried out:
1), looks for the Cluster (being called Cluster A) of a free time by searching the FAT subtree of Branching Tree;
2) a newly-built Cluster type node, its content is Cluster A, and this node is inserted into tram in the meta subtree;
3) check the position of Cluster A in the meta subtree, obtain its father node Node P.If its father node is the Cluster type node, then forward step 6 to; If its father node is file/Directory Type node, then forward step 4 to;
4) Node P is file/Directory Type node, and Cluster A is first bunch of this document.Node P is constantly searched the father node operation, and up to the father node that finds its first Cluster type (Cluster B), this is exactly the residing Cluster of Node P.By searching the FAT subtree of Branching Tree, look for the Cluster (being called Cluster C) of a free time; And copy the content of Cluster B to Cluster C, discharge Cluster B node then, and in the FAT subtree, Cluster B is moved in the idle Cluster chained list;
5) Cluster C is regarded as Cluster A, change step 4 over to;
Modification on the tree is write disk (content of Cluster and FAT table content).Particularly importantly for being marked as idle Cluster afterwards, if it in have modification, then the content of revising should not write back yet, and should on disk, keep its data constant;
Deletion Cluster operation
Deletion Cluster operation is similar substantially with newly-built Cluster operation, and the concrete operations step can followingly be carried out:
1) Cluster A is discharged from the meta subtree, and in the FAT subtree, it is labeled as the free time;
2) check the preceding position in the meta subtree of Cluster A deletion, obtain its father node Node P;
If its father node is the Cluster type node, then forward step 5 to; If its father node is file/Directory Type node, then forward step 3 to;
3) Node P is file/Directory Type node, and Cluster A is first bunch of this document before the deletion.Node P is constantly searched the father node operation, and up to the father node that finds its first Cluster type (Cluster B), this is exactly the residing Cluster of Node P.By searching the FAT subtree of Branching Tree, look for the Cluster (being called Cluster C) of a free time; And copy the content of Cluster B to Cluster C, discharge Cluster B node then, and in the FAT subtree, Cluster B is moved in the idle Cluster chained list;
4) Cluster C is regarded as Cluster A, change step 4 over to;
5) modification that will set writes disk (content of Cluster and FAT table content).Particularly importantly for being marked as idle Cluster afterwards, if it in have modification, then the content of revising should not write back yet, and should on disk, keep its data constant.
Read operation
Read operation is fairly simple, we should not use Recorded Tree and Recording Tree to locate the content that reads to be positioned at which Cluster, and should finish positioning action by Branching Tree, call the interface that file system bottom Drive Layer provides then, read this Cluster and get final product.

Claims (4)

1. embedded file system, whole file system is configured to tree-like data structure, adopt Phase Tree (phase place tree) algorithm, and there is a root node to point to file system, be subdivided into three tree-like sub-data structure in the system, be respectively and finish tree Recorded Tree, branch sets Branching Tree and sets Recording Tree, Recorded Tree has write down the file system mirror image that is currently located on the disk, Recording Tree has write down up-to-date file system mirror image, Branching Tree has write down the mirror image that is positioned at coherency state apart from nearest so far file system, three tree form data structures can constantly be changed, and the root node of revised file system, whole file system operation has atomicity, each tree data knot is only revised the part of difference in conversion, system comprises following steps:
The atomization of A file system;
B determines root node (metaroot);
C opens up a perform region;
The D conversion operations, all carry out operating on the FAT2 of FAT, and all operations do not influence the consistance that is currently located at file system on the disk, after modification is finished, revise root node (BPB) again, with FAT2 as new effective FAT table, with the root directory workspace as new root directory;
E sets up FAT Phase Tree data structure, and former subfile system adopts Fat Phase Tree algorithm;
The F system initialization is noted down the position of this directories/files in the meta subtree;
The G operating writing-file, adopt the mode of copy-on-write (instant copy) to carry out write operation, relate to the data of modification for all, all must get and duplicate a modification in the above then on the free space, more amended data are replaced legacy data at last at original system;
The newly-built node Cluster operation of H;
I deletion of node Cluster operation;
The J read operation.
2. a kind of embedded file system according to claim 1, node in the tree data is file system metadata Meta Data, but not directory tree, when write operation is arranged, just in free space, create the branch of this tree form data structure, carry out atomizing renewal again, old tree form data structure is updated to branch, one step of operation finishes, and the centre can not be interrupted, and guarantees the consistance of file system.
3. a kind of embedded file system according to claim 1, Recorded Tree have write down the state when front disk accurately; Recording Tree has write down the data that next time will be written into, Branching Tree has then write down operating system and it seems up-to-date file system data, it has also comprised one and has discharged tabulation, d/d inode and block have been write down, when making atomic update each time, the tree form data structure of three file system is just done once and is switched, Recording Tree is written to disk and is converted to Recorded Tree, Branching Tree is corrected to a up-to-date coherency state and is converted to Recorded Tree, and Recorded Tree becomes Branching Tree after then upgrading write operation.
4. a kind of embedded file system according to claim 1 all adopts the copy-on-write mode when all operations carries out, guarantee the consistance of file system metadata, guarantees the consistance of file data.
CNA200610117114XA 2006-10-13 2006-10-13 Built-in file systems Pending CN101162459A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNA200610117114XA CN101162459A (en) 2006-10-13 2006-10-13 Built-in file systems

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNA200610117114XA CN101162459A (en) 2006-10-13 2006-10-13 Built-in file systems

Publications (1)

Publication Number Publication Date
CN101162459A true CN101162459A (en) 2008-04-16

Family

ID=39297384

Family Applications (1)

Application Number Title Priority Date Filing Date
CNA200610117114XA Pending CN101162459A (en) 2006-10-13 2006-10-13 Built-in file systems

Country Status (1)

Country Link
CN (1) CN101162459A (en)

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105607960A (en) * 2015-10-26 2016-05-25 成都华为技术有限公司 Repairing method and device of file system directory tree
CN108228097A (en) * 2017-12-25 2018-06-29 中国航空工业集团公司洛阳电光设备研究所 A kind of power-off protection method based on FAT32 file system
CN109977092A (en) * 2019-03-26 2019-07-05 武汉深之度科技有限公司 A kind of method and calculating equipment of duplication file

Cited By (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN105607960A (en) * 2015-10-26 2016-05-25 成都华为技术有限公司 Repairing method and device of file system directory tree
US10817469B2 (en) 2015-10-26 2020-10-27 Huawei Technologies Co., Ltd. Method and apparatus for repairing file system directory tree
CN108228097A (en) * 2017-12-25 2018-06-29 中国航空工业集团公司洛阳电光设备研究所 A kind of power-off protection method based on FAT32 file system
CN109977092A (en) * 2019-03-26 2019-07-05 武汉深之度科技有限公司 A kind of method and calculating equipment of duplication file
CN109977092B (en) * 2019-03-26 2021-06-08 武汉深之度科技有限公司 Method and computing device for copying files

Similar Documents

Publication Publication Date Title
US8028006B2 (en) Method and apparatus for exchanging sub-hierarchical structures within a hierarchical file system
US7873683B2 (en) File system having transaction record coalescing
EP1739535B1 (en) File system storing transaction records in flash-like media
JP5500309B2 (en) Storage device
US6678809B1 (en) Write-ahead log in directory management for concurrent I/O access for block storage
JP6309103B2 (en) Snapshot and clone replication
TWI258663B (en) Writable file system snapshot with ditto address feature
US9183129B2 (en) Method and system for managing large write-once tables in shadow page databases
US8032498B1 (en) Delegated reference count base file versioning
US7685169B2 (en) Multiple concurrent active file systems
EP1744246B1 (en) File system having deferred verification of data integrity
US7774565B2 (en) Methods and apparatus for point in time data access and recovery
US7831789B1 (en) Method and system for fast incremental backup using comparison of descriptors
US6934725B1 (en) Management of file extent mapping to hasten mirror breaking in file level mirrored backups
US5875444A (en) Computer file system check and repair utility
US8667029B2 (en) Optimized startup verification of file system integrity
US20120005163A1 (en) Block-based incremental backup
AU2018236167A1 (en) Methods, devices and systems for maintaining consistency of metadata and data across data centers
US7970804B2 (en) Journaling FAT file system and accessing method thereof
TW200303469A (en) Providing a snapshot of a subset of a file system
KR20070003577A (en) File system having inverted hierarchical structure
JP2021533495A (en) Data recovery methods, equipment, servers and computer programs
CN102053879A (en) Self-recovery real-time file system based on FLASH
US7194486B2 (en) Method and system for data processing with data replication for the same
CN101162459A (en) Built-in file systems

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C02 Deemed withdrawal of patent application after publication (patent law 2001)
WD01 Invention patent application deemed withdrawn after publication

Application publication date: 20080416