CN100543662C - A kind of management method of tree structure file system - Google Patents

A kind of management method of tree structure file system Download PDF

Info

Publication number
CN100543662C
CN100543662C CNB2007101673418A CN200710167341A CN100543662C CN 100543662 C CN100543662 C CN 100543662C CN B2007101673418 A CNB2007101673418 A CN B2007101673418A CN 200710167341 A CN200710167341 A CN 200710167341A CN 100543662 C CN100543662 C CN 100543662C
Authority
CN
China
Prior art keywords
binary search
search tree
node
numbering
numbered
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.)
Expired - Fee Related
Application number
CNB2007101673418A
Other languages
Chinese (zh)
Other versions
CN101169699A (en
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.)
Sunplus Technology Co Ltd
Original Assignee
Sunplus 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 Sunplus Technology Co Ltd filed Critical Sunplus Technology Co Ltd
Priority to CNB2007101673418A priority Critical patent/CN100543662C/en
Publication of CN101169699A publication Critical patent/CN101169699A/en
Application granted granted Critical
Publication of CN100543662C publication Critical patent/CN100543662C/en
Expired - Fee Related legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Landscapes

  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a kind of tree structure file system and management method thereof, this document system has (K+1) individual binary search tree, the node of each binary search tree comprises a logical block addresses field and a size field, at first, import a storage area demand, the storage area demand comprises a requirement logic block address and a demand number of clusters order.According to demand number of clusters order, in order to calculate corresponding one binary search tree that is numbered m.Judge in the binary search tree of numbering m whether untapped node is arranged again, if judge in the binary search tree of numbering m and have untapped node, look for the node nearest in the binary search tree by this numbering m apart from this requirement logic block address, and will be apart from removing in the nearest binary search tree of node by numbering m of this requirement logic block address.

Description

A kind of management method of tree structure file system
Technical field
The present invention relates to the technical field of file system, relate in particular to a kind of management method of tree structure file system.
Background technology
In the management of remaining space,, can obtain the best efficiency of management according to the theoretical linear algorithm that uses initial hit (First Hit).So in actual file system, all use the linear algorithm of First Hit, search the remaining space on the medium as well-known file system such as FAT, Ext2, Ext3.This document system becomes some bunch (Cluster) or blocks (Block) with the space segmentation on the medium earlier, and this bunch or block are adopted linear management.For example, whether Ext2, Ext3 file system use bit vector (Bit Vector) record bunch to be used, and the FAT file system uses file configuration table (File Alloction Table) record bunch to use a situation.
Yet, use the shortcoming of the linear algorithm of First Hit mainly can on medium, produce dialysis (Fragement) situation.Because using, the linear algorithm of First Hit travels through first remaining space that (Traverse) arrives each time, and do not consider the size in this space, so a whenever newly-increased file logging may need to carry out repeatedly the remaining space traversal, and this document record may be stored in discontinuous space.And after the action through repeatedly newly-increased file, deleted file, the file in the file system is often stored on medium with the situation of dialysis degree varies.
Because the dialysis of file when reading file, can't once promptly obtain required data, and the transmission that often need carry out repeatedly could obtain required data.Simultaneously also because the dialysis of file, when writing file, also need carry out the action that repeatedly transmission just can be finished the write-once file.
In having the medium of read/write head (for example: Winchester disk drive, CD-ROM drive), the situation of the dialysis of file can cause the search time (Seek Time) of read/write head and rotational time (Rotating Time) to heighten, and makes file read-write efficient significantly glide.And in real-time system since linear search time of First Hit linear algorithm be difficult to estimate, so the file system of use First Hit linear algorithm is difficult to use in real-time system.Hence one can see that, and known file system and management method thereof still have the space of improvement.
Summary of the invention
The management method that the purpose of this invention is to provide a kind of file system to reduce the phenomenon of dialysis in the file system, is avoided remaining space problem difficult in maintenance, significantly promotes file-system access usefulness.
According to characteristics of the present invention, the present invention proposes a kind of management method of tree structure file system, this document system has n bunch and reaches (K+1) individual binary search tree, wherein n is the integer greater than 2, K is a positive integer, should be numbered 0 by (K+1) individual binary search tree, 1,2, ..., K, the node of each above-mentioned binary search tree comprises a logical block addresses field and a size field, this logical block addresses is in order to put down in writing the initial logical block addresses of the corresponding continuous available cluster of this node, this size field is in order to put down in writing the number of clusters order of the corresponding continuous available cluster of this node, this method comprises the following step: (A) input one storage area demand, and this storage area demand comprises a requirement logic block address and a demand number of clusters order; (B) according to this demand number of clusters order, in order to calculate corresponding one binary search tree that is numbered m, 0≤m≤K; (C) judge in this binary search tree that is numbered m whether node is arranged; (D) if judge in the step (C) in this binary search tree that is numbered m node is arranged, be numbered in the binary search tree of m by this and look for the node nearest, and will from this is numbered the binary search tree of m, remove apart from the nearest node of this requirement logic block address apart from this requirement logic block address; (E) if the continuous available cluster size of the nodes records of looking in the step (D), is deducted required number of clusters order remaining continuous available cluster afterwards greater than needed number of clusters order, form a new node, and add in the suitable binary search tree; (F) if in the binary search tree of numbering m, look in the step (D), can look for numbering m+1 or the binary search tree of m-1 and repeating step (C) less than node.
Adopt the management method of tree structure file system of the present invention, adopt tree structure and mixed the best and hit (Best Hit) and first hit, can reduce the phenomenon of dialysis in the file system, also can avoid remaining space problem difficult in maintenance, significantly promote simultaneously file-system access usefulness, its time complexity also reduces greatly, is suitable in the real-time system.
Description of drawings
Fig. 1 is the synoptic diagram of tree structure file system of the present invention;
Fig. 2 is the synoptic diagram of binary search tree of the present invention;
Fig. 3 is the process flow diagram of the management method of tree structure file system of the present invention;
Fig. 4 is the synoptic diagram of embodiments of the invention.
Embodiment
Fig. 1 is the synoptic diagram of tree structure file system of the present invention, and this tree structure file system applies in a disc driver or the flash memory, with the method for operating (File Operation) that file is provided in this disc driver or flash memory.
This tree structure file system comprises that n bunch (Cluster) reaches (K+1) individual binary search tree (BinarySearch Tree).This n bunch in order to storage data, and wherein n is the positive integer greater than 2.Its corresponding bunch of the nodes records of each above-mentioned binary search tree, K is a positive integer.Wherein, the node of each binary search tree (Node) is according to logical block addresses (Logical Block Address, size LBA) and arranging.
It is relevant with number of clusters order n to be somebody's turn to do (K+1) individual binary search tree.Be that the K value is Ceiling[log 2(n)], wherein, n is the number of clusters order of this tree structure file system, and Ceiling is the ceiling function.
Fig. 2 is the synoptic diagram of binary search tree of the present invention.Should (K+1) individual binary search tree be numbered 0,1,2 ..., K, the binary search tree of a numbering j is up to 2j node.The number of clusters order of each node correspondence of the binary search tree of this numbering j is n 2 j ~ n 2 j - 1 , j=1、2、...、(K-1)。The number of clusters order of the node correspondence of the binary search tree of this numbering 0 is n.The number of clusters order of the node correspondence of the binary search tree of this numbering K is 1.
With a capacity is that the flash memory file system of 1G byte (byte) is an example, and bunch unit is the 4K byte, so this document system has 262144 (=2 18) individual bunch.K is 18 (to be Ceiling (log 2(2 18))), so have 19 binary search trees be numbered 0,1,2 ..., 18.The binary search tree of numbering 0 is up to 1 node, and the number of clusters order of the node correspondence of the binary search tree of this numbering 0 is 262144.The binary search tree of numbering 1 is up to 2 nodes, and the number of clusters order of the node correspondence of the binary search tree of this numbering 1 is 131072 (=262144/2)~262143.Analogize in regular turn, the binary search tree tool of numbering 18 has 262144 nodes at most, and the number of clusters order of the node correspondence of the binary search tree of this numbering 18 is 1.
The node of each binary search tree comprises a logical block addresses (Logical Block Address, LBA) field and a size field.This logical block addresses (LBA) field is in order to put down in writing the corresponding continuously available bunch initial logical block addresses of this node.This size field is in order to put down in writing the corresponding continuously available bunch number of clusters order of this node.
Fig. 3 is the process flow diagram of the management method of tree structure file system of the present invention.This document system has n bunch and (K+1) individual binary search tree, and wherein n be the positive integer greater than 2, and K is a positive integer, this (K+1) individual binary search tree is numbered 0,1,2 ..., K.The node of each binary search tree comprises a logical block addresses (LBA) field and a size field, this logical block addresses (LBA) is in order to putting down in writing continuous available bunch initial logical block addresses of this node correspondence, and this size field is in order to put down in writing continuous available bunch number of clusters order of this node correspondence.Nodes records in the binary search tree of label i be continuously that available size is that n/ (2^i) is to individual bunch of n/ (2^ (i-1)).
At first, in step S205, import a storage area demand, this storage area demand comprises a requirement logic block address (LBA) and a demand number of clusters order s.
In step S210, initialization one index (index) i, and it is initialized as 0.
In step S215, number the binary search tree of m, 0≤m≤K to calculate one of correspondence according to this demand number of clusters order s.M is according to formula log 2(n)-floor (log 2(s))+and i calculating, wherein n is the number of clusters order of this document system, and s is a demand number of clusters order, and floor is a floor function.
In step S220, judge in the binary search tree of this numbering m whether node is arranged, the node in the binary search tree of this numbering m is promptly represented continuously available bunch logical blocks.
In step S225,, be illustrated in the node that suitable this storage area demand is arranged in the binary search tree of this numbering m if judge among the step S220 in the binary search tree of this numbering m that node is arranged.So in the binary search tree of this numbering m, look for apart from the nearest node of this requirement logic block address (LBA), and will be somebody's turn to do apart from removing in the nearest binary search tree of node of this requirement logic block address by this numbering m.
Because m is according to formula log 2(n)-floor (log 2(s))+and i calculating, so the size of the continuous available cluster that node write down in the binary search tree of this numbering m is more than or equal to this demand number of clusters order s.When the continuous available cluster size of the nodes records of looking among the step S225 during greater than needed number of clusters order, deduct remaining continuous available cluster after the required number of clusters order, form a new node, add in the suitable binary search tree.
In step S230, the balance computing carried out in the binary search tree of this numbering m.Since remove node among the step S225, need balance (Balance) computing carried out in this binary search tree, to allow the right and left interstitial content of this binary search tree equate as far as possible, to keep the search speed of binary search tree.
If judging among the step S220 in the binary search tree of this numbering m does not have node, be illustrated in the node that does not have suitable this storage area demand in the binary search tree of this numbering m.So in the upper strata binary search tree of the binary search tree of this numbering m, look for untapped node.The upper strata binary search tree of indication is meant the binary search tree that numbering is little than m herein.Search in the binary search tree of numbering (m-1) whether node is arranged earlier,, in the binary search tree of this numbering (m-1), look for again apart from the nearest node of this requirement logic block address (LBA) if having; If do not have, then search in the binary search tree of numbering (m-2) whether node is arranged in regular turn, until the binary search tree of numbering 0.
Herein, the node that in the binary search tree of this numbering m, does not have to be fit to this storage area demand, untapped node is looked for by elder generation from the upper strata binary search tree of the binary search tree of this numbering m, rather than from lower floor's binary search tree of the binary search tree of this numbering m, look for, be for fear of looking for time-out that the situation of sub-demand may take place memory space requirements is divided into from lower floor earlier.
If still do not have untapped node in numbering 0 the binary search tree, then look for untapped node in the lower floor's binary search tree by the binary search tree of this numbering m.Lower floor's binary search tree of indication means the binary search tree that numbering is big than m herein.Search in the binary search tree of numbering (m+1) whether untapped node is arranged earlier,, in the binary search tree of this numbering (m+1), look for again apart from the nearest node of this requirement logic block address (LBA) if having; If do not have, then search in the binary search tree of numbering (m+2) whether untapped node is arranged in regular turn, until the binary search tree of numbering K.
In step S235, whether judge index i is less than or equal to 0, if execution in step S240, if not, execution in step S255.
Execution in step S240 looks for untapped node in the upper strata binary search tree of expression by the binary search tree of this numbering m.So in step S240, i subtracts 1 with this index.Execution in step S255 looks for untapped node in lower floor's binary search tree of expression by the binary search tree of this numbering m.
In step S245, judge that this binary search tree numbering whether more than or equal to 0, if more than or equal to 0, re-executes step S220, if less than 0, execution in step S250 then.If the binary search tree numbering is represented the search of the intact upper strata of executed binary search tree less than 0.So execution in step S250, to look for untapped node in the lower floor's binary search tree by the binary search tree of this numbering m.In step S245, binary search tree is numbered one and upgrades numbering m '=log 2(n)-floor (log 2(s))+i.
In step S250, i is set at 0 with this index.
In step S255, i adds 1 with this index.
In step S260, whether judge binary search tree numbering greater than K, if look for untapped node in lower floor's binary search tree of the intact binary search tree by this numbering m of expression executed, so the end searching procedure.If not, execution in step S220 then is to look for untapped node.In step S260, binary search tree is numbered one and upgrades numbering m "=log 2(n)-floor (log 2(s))+and i, judge that whether binary search tree numbering is to carry out following formula greater than K:
log 2(n)-floor(log 2(s))+i>Ceiling(log 2(n))
Wherein, wherein n is the number of clusters order of this document system, and s is a demand number of clusters order, and floor is a floor function, and Ceiling is the ceiling function.
When searching the untapped node of lower floor's binary search tree, the node that it found bunch littler than demand number of clusters order s needs this storage area demand is divided into sub-demand this moment, promptly uses the node that disperses to satisfy this storage area demand.
Fig. 4 is the synoptic diagram of one embodiment of the invention.In this embodiment, the capacity of a disc driver is 1G byte (byte), and bunch unit is the 4K byte, so this disc driver has 262144 (=2 18) individual bunch.K is 18 (=Ceiling (log 2(2 18))), so have 19 binary search trees be numbered 0,1,2 ..., 18.As shown in Figure 3, having number of nodes simultaneously at most in the present embodiment is the node summation of above-mentioned 19 binary search trees, also is 524287 nodes.Node is represented one section continuous bunch.Suppose that addressing length is 32, then node needs 8 bytes, thus altogether need 4096 (
Figure C200710167341D0009081330QIETU
) individual sector stores above-mentioned node.Event needs 4/1000ths storage space with memory node.
In the present invention, be the remaining space of individual bunch of s if file system will be looked for one near position a, size.Best situation is that Floor (s/2) tree structure just has node, because the maximum height of this tree structure is Floor (s/2), so at most only need carry out that Floor (s/2) is inferior relatively can to find suitable node.The worst situation is to have only Ceiling (log 2(n)) there is node tree structure inside, owing to can inspect other Ceiling (log earlier 2(n))-1 a tree structure inside has or not node, is Ceiling (log in maximum height then 2(n)) Ceiling (log 2(n)) individual tree structure is made s time traversal, so have [Ceiling (log during the worst situation altogether 2(n))-1]+[Ceiling (log 2(n)) * and s] inferior traversal.
As shown in the above description, when a medium has x bunch, when looking for a remaining space of a close position a, the big or small s of being bunch, known technology is owing to use linear first hit mode to search, so can't the degree of solution space dialysis, the continuous increase that the situation of dialysis is also inevitable is so the time complexity of known technology is O (x*s).The present invention is owing to adopt tree structure and mixed best hit and first hit, even the operation when long, the degree of space dialysis still can see through simple mode and grasp, so time complexity of the present invention is O (log 2(x) * s).Compare that first hit technology search time is long in the known technology, time complexity is high, be not suitable for the defective of real-time system, the present invention more is applicable to real-time system.The present invention can reduce the phenomenon of dialysis in the file system, also can avoid remaining space problem difficult in maintenance, significantly promotes file-system access usefulness simultaneously.
Certainly; the present invention also can have other various embodiments; under the situation that does not deviate from spirit of the present invention and essence thereof; those of ordinary skill in the art work as can make various corresponding changes and distortion according to the present invention, but these corresponding changes and distortion all should belong to the protection domain of the appended claim of the present invention.

Claims (8)

1, a kind of management method of tree structure file system, this document system has n bunch and reaches (K+1) individual binary search tree, wherein n is the integer greater than 2, K is a positive integer, should be numbered 0 by (K+1) individual binary search tree, 1,2, ..., K, the node of each described binary search tree comprises a logical block addresses field and a size field, described logical block addresses is in order to put down in writing the corresponding continuously available bunch initial logical block addresses of this node, described size field is in order to put down in writing the corresponding continuously available bunch number of clusters order of this node, and this method comprises the following step:
(A) input one storage area demand, this storage area demand comprises a requirement logic block address and a demand number of clusters order;
(B), calculate corresponding one binary search tree that is numbered m, 0≤m≤K according to this demand number of clusters order;
(C) judge in this binary search tree that is numbered m whether node is arranged; And
(D), be numbered in the binary search tree of m by this and look for the node nearest apart from this requirement logic block address if judge in the step (C) in this binary search tree that is numbered m that node is arranged;
(E) if the continuous available number of clusters order of the node representative of finding in the binary search tree that is numbered m in the step (D) greater than required number of clusters order, deduct afterwards remaining available continuously bunch another node of formation of required number of clusters order, the new node that forms adds corresponding binary search tree, and will remove from this is numbered the binary search tree of m apart from the nearest node of this requirement logic block address.
2, management method as claimed in claim 1 is characterized in that,
In described step (E), after the new node that forms adds corresponding binary search tree, the balance computing carried out in the described binary search tree that is numbered m.
3, management method as claimed in claim 1 is characterized in that,
The corresponding number of clusters order of each node that is numbered the binary search tree of j is
Figure C200710167341C00021
J=1,2 ..., (K-1), this corresponding number of clusters order of node that is numbered 0 binary search tree is n, this corresponding number of clusters order of node that is numbered the binary search tree of K is 1.
4, management method as claimed in claim 3 is characterized in that,
If judging in the step (C) in this binary search tree that is numbered m does not have untapped node, carry out the following step:
(F) should number m and subtract 1, upgrade numbering m ' to obtain one; And
(G) whether judge this renewal numbering m ' more than or equal to 0, if, execution in step (C).
5, management method as claimed in claim 4 is characterized in that,
If it is non-more than or equal to 0 to judge in the step (G) that this upgrades numbering m ', carry out the following step:
(H) will number m and add 1, to obtain incremental update numbering m ", and as this incremental update numbering m " when being not more than K, execution in step (C).
6, management method as claimed in claim 3 is characterized in that,
The K value is Ceiling[log 2(n)], wherein, n is the number of clusters order of this tree structure file system, and Ceiling is the ceiling function.
7, management method as claimed in claim 6 is characterized in that,
The binary search tree of numbering j is up to 2j node.
8, management method as claimed in claim 7 is characterized in that,
In described step (B), described numbering m is log 2(n)-floor (log 2(s)), wherein n is the number of clusters order of this tree structure file system, and s is a demand number of clusters order.
CNB2007101673418A 2007-10-25 2007-10-25 A kind of management method of tree structure file system Expired - Fee Related CN100543662C (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CNB2007101673418A CN100543662C (en) 2007-10-25 2007-10-25 A kind of management method of tree structure file system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007101673418A CN100543662C (en) 2007-10-25 2007-10-25 A kind of management method of tree structure file system

Publications (2)

Publication Number Publication Date
CN101169699A CN101169699A (en) 2008-04-30
CN100543662C true CN100543662C (en) 2009-09-23

Family

ID=39390342

Family Applications (1)

Application Number Title Priority Date Filing Date
CNB2007101673418A Expired - Fee Related CN100543662C (en) 2007-10-25 2007-10-25 A kind of management method of tree structure file system

Country Status (1)

Country Link
CN (1) CN100543662C (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306168B (en) * 2011-08-23 2014-07-09 华为数字技术(成都)有限公司 Log operation method and device and file system
CN107783733B (en) * 2013-11-07 2020-12-29 航天云网数据研究院(广东)有限公司 Sequential access detection system and method

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4536837A (en) * 1982-05-25 1985-08-20 Elxsi Improved disk file allocation and mapping system utilizing cylinder control blocks and file map having unbalanced tree structure

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4536837A (en) * 1982-05-25 1985-08-20 Elxsi Improved disk file allocation and mapping system utilizing cylinder control blocks and file map having unbalanced tree structure

Also Published As

Publication number Publication date
CN101169699A (en) 2008-04-30

Similar Documents

Publication Publication Date Title
CN103186350B (en) The moving method of mixing storage system and hot spot data block
US8225029B2 (en) Data storage processing method, data searching method and devices thereof
US8037112B2 (en) Efficient access of flash databases
US4827462A (en) Modular data storage directories for large-capacity data storage units
US5119291A (en) Modular data storage directories for large-capacity data storage units wherein the index to the records in a sector is located in the next adjacent sector
US8161240B2 (en) Cache management
CN109445713A (en) A kind of storage state recording method, system and the associated component of metadata volume
US7761648B2 (en) Caching method for NAND flash translation layer
US6622226B1 (en) Method and system for using a mark-list for garbage collection
CN104346357A (en) File accessing method and system for embedded terminal
CN101645043B (en) Methods for reading and writing data and memory device
JP2010218529A (en) Method for storing data in flash memory by isolation-method at dbms, using page-differencial
CN101030165A (en) Magnetic disk space management and managing system
CN106502587A (en) Data in magnetic disk management method and magnetic disk control unit
CN103514249A (en) Method and system for automatic data reduction and storage device
CN102567415B (en) Control method and device of database
KR101438667B1 (en) Database method for b+ tree based on PRAM
US8239427B2 (en) Disk layout method for object-based storage devices
CN103473298A (en) Data archiving method and device and storage system
CN111522507A (en) Low-delay file system address space management method, system and medium
CN114416646A (en) Data processing method and device of hierarchical storage system
CN1684049A (en) Information storage apparatus, information storage method and information storage processing program product
CN113722319A (en) Data storage method based on learning index
CN102520885B (en) Data management system for hybrid hard disk
CN100543662C (en) A kind of management method of tree structure file system

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
C14 Grant of patent or utility model
GR01 Patent grant
CF01 Termination of patent right due to non-payment of annual fee
CF01 Termination of patent right due to non-payment of annual fee

Granted publication date: 20090923

Termination date: 20171025