[go: up one dir, main page]

CN101169699A - Tree-structured file system and management method thereof - Google Patents

Tree-structured file system and management method thereof Download PDF

Info

Publication number
CN101169699A
CN101169699A CNA2007101673418A CN200710167341A CN101169699A CN 101169699 A CN101169699 A CN 101169699A CN A2007101673418 A CNA2007101673418 A CN A2007101673418A CN 200710167341 A CN200710167341 A CN 200710167341A CN 101169699 A CN101169699 A CN 101169699A
Authority
CN
China
Prior art keywords
binary search
node
search tree
numbered
tree
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.)
Granted
Application number
CNA2007101673418A
Other languages
Chinese (zh)
Other versions
CN100543662C (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 tree-structured file system and a management method thereof, the file system is provided with (K +1) binary search trees, the node of each binary search tree comprises a logic block address field and a size field, firstly, a storage space requirement is input, and the storage space requirement comprises a required logic block address and a required cluster number. And according to the number of the required clusters, calculating a corresponding binary search tree with the number of m. And then judging whether the binary search tree with the number m has unused nodes, if so, searching the node closest to the required logic block address from the binary search tree with the number m, and removing the node closest to the required logic block address from the binary search tree with the number m.

Description

一种树状结构文件系统及其管理方法 A tree structure file system and its management method

技术领域technical field

本发明涉及文件系统的技术领域,尤其涉及一种树状结构文件系统及其管理方法。The invention relates to the technical field of file systems, in particular to a tree structure file system and a management method thereof.

背景技术Background technique

在剩余空间的管理中,依据理论使用首次命中(First Hit)的线性算法,可以获得最佳的管理效率。所以在实际文件系统中,如FAT、Ext2、Ext3等知名文件系统均使用First Hit的线性算法,来搜寻存储媒体上的剩余空间。该文件系统是先将存储媒体上的空间分割成若干的簇(Cluster)或是区块(Block),并对该簇或区块采用线性的管理。例如,Ext2、Ext3文件系统使用位向量(Bit Vector)记录簇是否已经被使用,FAT文件系统使用文件配置表(File Alloction Table)记录簇使用情形。In the management of the remaining space, the best management efficiency can be obtained by using the linear algorithm of the first hit (First Hit) according to the theory. Therefore, in the actual file system, well-known file systems such as FAT, Ext2, and Ext3 all use the linear algorithm of First Hit to search for the remaining space on the storage medium. The file system first divides the space on the storage medium into several clusters or blocks, and adopts linear management for the clusters or blocks. For example, Ext2 and Ext3 file systems use bit vectors (Bit Vector) to record whether clusters have been used, and FAT file systems use file allocation tables (File Allocation Table) to record cluster usage.

然而,使用First Hit的线性算法的缺点主要会在存储媒体上产生断离(Fragement)情形。由于First Hit的线性算法使用每一次遍历(Traverse)到的第一块剩余空间,而不考虑该空间的大小,故每新增一笔文件记录可能需要执行多次剩余空间遍历,而该文件记录可能存储在不连续的空间。而经过多次的新增文件、删除文件的动作后,文件系统中的文件常以断离程度不一的情况在存储媒体上进行存储。However, the disadvantage of using the linear algorithm of First Hit is mainly to generate a fragmentation (Fragement) situation on the storage medium. Since the linear algorithm of First Hit uses the first remaining space in each traversal (Traverse), regardless of the size of the space, each new file record may need to perform multiple remaining space traversals, and the file record May be stored in non-contiguous spaces. And after adding files and deleting files many times, the files in the file system are often stored on the storage medium with different degrees of disconnection.

由于文件的断离,在读取文件时,无法一次即获得所需的数据,而往往需执行多次的传输才能获得所需的数据。同时亦由于文件的断离,在写入文件时,亦需执行多次的传输才能完成一次写入文件的动作。Due to the disconnection of the file, when the file is read, the required data cannot be obtained at one time, and it is often necessary to perform multiple transmissions to obtain the required data. At the same time, due to the disconnection of the file, when writing the file, multiple transmissions are required to complete the action of writing the file once.

在具有读写头的存储媒体(例如:硬盘机、光驱)中,文件的断离的情形会造成读写头的搜寻时间(Seek Time)及旋转时间(Rotating Time)大增,而使得文件读写效率大幅下滑。而在实时系统中,由于First Hit线性算法的线性搜寻时间难以预估,故使用First Hit线性算法的文件系统难以在实时系统中使用。由此可知,已知文件系统及其管理方法仍有改善的空间。In a storage medium with a read-write head (for example: a hard disk drive, an optical drive), the separation of the file will cause a large increase in the seek time (Seek Time) and rotation time (Rotating Time) of the read-write head, which makes the file read Write efficiency dropped drastically. In a real-time system, since the linear search time of the First Hit linear algorithm is difficult to predict, it is difficult to use a file system using the First Hit linear algorithm in a real-time system. It can be seen that there is still room for improvement in the known file system and its management method.

发明内容Contents of the invention

本发明的目的是提供一种文件系统及其管理方法,以减少文件系统中断离的现象,避免剩余空间维护困难的问题,大幅提升文件系统存取效能。The object of the present invention is to provide a file system and its management method, so as to reduce the disconnection of the file system, avoid the problem of difficult maintenance of remaining space, and greatly improve the access performance of the file system.

依据本发明的特点,本发明提出一种树状结构文件系统的管理方法,该文件系统具有n个簇及(K+1)个二叉查找树,其中n为大于2的整数,K为正整数,该(K+1)个二叉查找树编号为0、1、2、...、K,每一个上述二叉查找树的节点包含一逻辑区块地址字段及一大小字段,该逻辑区块地址用以记载该节点相对应的连续可用簇的起始逻辑区块地址,该大小字段用以记载该节点相对应的连续可用簇的簇数目,该方法包含下列步骤:(A)输入一储存空间需求,该储存空间需求包含一需求逻辑区块地址及一需求簇数目;(B)依据该需求簇数目,用以计算相对应的一编号为m的二叉查找树,0≤m≤K;(C)判断该编号为m的二叉查找树中是否有节点;(D)若步骤(C)中判定该编号为m的二叉查找树中有节点,由该编号为m的二叉查找树中找寻距离该需求逻辑区块地址最近的节点,并将距离该需求逻辑区块地址最近的节点从该编号为m的二叉查找树中移除;(E)若步骤(D)中找寻到的节点记录的连续可用簇大小大于所需要的簇数目,扣除所需的簇数目之后剩余的连续可用簇,形成一新的节点,并加入适当的二叉查找树中;(F)若步骤(D)中在编号m的二叉查找树中找寻不到节点,可以找寻编号m+1或是m-1的二叉查找树并重复步骤(C)。According to the characteristics of the present invention, the present invention proposes a management method for a tree-structured file system, the file system has n clusters and (K+1) binary search trees, wherein n is an integer greater than 2, and K is a positive Integer, the (K+1) binary search trees are numbered 0, 1, 2, ..., K, each node of the binary search tree includes a logical block address field and a size field, the logical The block address is used to record the starting logical block address of the continuous available cluster corresponding to the node, and the size field is used to record the cluster number of the continuous available cluster corresponding to the node. The method includes the following steps: (A) Input A storage space requirement, the storage space requirement includes a required logical block address and a required number of clusters; (B) according to the required number of clusters, it is used to calculate a corresponding binary search tree numbered m, 0≤m ≤K; (C) judge whether there is a node in the binary search tree numbered m; (D) if it is judged in step (C) that there is a node in the binary search tree numbered m, the number m Find the nearest node from the demand logical block address in the binary search tree, and remove the nearest node from the demand logical block address from the binary search tree whose number is m; (E) if step (D The size of the continuous available clusters found in the node records found in ) is greater than the required number of clusters, and the remaining continuous available clusters after deducting the required number of clusters form a new node and add to an appropriate binary search tree; (F ) If no node can be found in the binary search tree with number m in step (D), you can find the binary search tree with number m+1 or m-1 and repeat step (C).

依据本发明的另一特点,本发明提出一种树状结构文件系统,包括n个簇及(K+1)个二叉查找树。该n个簇用以储存数据,其中n为大于2的正整数;该(K+1)个二叉查找树的每一个节点纪录对应的连续可用的簇;其中,每一个二叉查找树的节点是按照逻辑区块地址的大小而排列。According to another feature of the present invention, the present invention proposes a tree structure file system, including n clusters and (K+1) binary search trees. The n clusters are used to store data, wherein n is a positive integer greater than 2; each node record of the (K+1) binary search trees corresponds to a continuous available cluster; wherein, each binary search tree Nodes are arranged according to the size of the logical block address.

采用本发明的树状结构文件系统及其管理方法,采用树状结构、以及混合了最佳命中(Best Hit)及first hit,可减少文件系统中断离的现象,也可避免剩余空间维护困难的问题,同时大幅提升文件系统存取效能,其时间复杂度亦大大降低,适合于实时系统中。Adopting the tree structure file system and its management method of the present invention, adopting the tree structure, and mixing Best Hit (Best Hit) and first hit, can reduce the phenomenon of disconnection in the file system, and can also avoid the difficulty of remaining space maintenance At the same time, the file system access performance is greatly improved, and its time complexity is also greatly reduced, which is suitable for real-time systems.

附图说明Description of drawings

图1是本发明树状结构文件系统的示意图;Fig. 1 is the schematic diagram of tree structure file system of the present invention;

图2是本发明的二叉查找树的示意图;Fig. 2 is the schematic diagram of the binary search tree of the present invention;

图3是本发明树状结构文件系统的管理方法的流程图;Fig. 3 is a flow chart of the management method of the tree structure file system of the present invention;

图4是本发明的实施例的示意图。Figure 4 is a schematic diagram of an embodiment of the present invention.

具体实施方式Detailed ways

图1是本发明树状结构文件系统的示意图,该树状结构文件系统运用于一磁盘驱动器或一闪存中,以在该磁盘驱动器或闪存中提供文件的操作方法(File Operation)。1 is a schematic diagram of a tree-structured file system of the present invention, which is used in a disk drive or a flash memory to provide a file operation method (File Operation) in the disk drive or flash memory.

该树状结构文件系统包括n个簇(Cluster)及(K+1)个二叉查找树(BinarySearch Tree)。该n个簇用以储存数据,其中n为大于2的正整数。每一个上述二叉查找树的节点记录其相对应的簇,K为正整数。其中,每一个二叉查找树的节点(Node)是按照逻辑区块地址(Logical Block Address,LBA)的大小而排列。The tree structure file system includes n clusters (Cluster) and (K+1) binary search trees (BinarySearch Tree). The n clusters are used to store data, where n is a positive integer greater than 2. Each node of the above-mentioned binary search tree records its corresponding cluster, and K is a positive integer. Among them, each node (Node) of the binary search tree is arranged according to the size of the logical block address (Logical Block Address, LBA).

该(K+1)个二叉查找树与簇数目n相关。即K值为Ceiling[log2(n)],其中,n为该树状结构文件系统的簇数目,Ceiling为天花板函数。The (K+1) binary search trees are related to the cluster number n. That is, the value of K is Ceiling[log 2 (n)], where n is the number of clusters in the tree structure file system, and Ceiling is a ceiling function.

图2是本发明的二叉查找树的示意图。该(K+1)个二叉查找树编号为0、1、2、...、K,一编号j的二叉查找树最多具有2j个节点。该编号j的二叉查找树的每一个节点对应的簇数目为 n 2 j ~ n 2 j - 1 , j=1、2、...、(K-1)。该编号0的二叉查找树的节点对应的簇数目为n。该编号K的二叉查找树的节点对应的簇数目为1。Fig. 2 is a schematic diagram of the binary search tree of the present invention. The (K+1) binary search trees are numbered 0, 1, 2, . . . , K, and a binary search tree with number j has at most 2 j nodes. The number of clusters corresponding to each node of the binary search tree with the number j is no 2 j ~ no 2 j - 1 , j=1, 2, . . . , (K-1). The number of clusters corresponding to the nodes of the binary search tree numbered 0 is n. The number of clusters corresponding to the nodes of the binary search tree with the number K is 1.

以一个容量为1 G字节(byte)的闪存文件系统为例,簇单位为4K字节,故该文件系统有262144(=218)个簇。K为18(即Ceiling(log2(218))),故共有19个二叉查找树编号为0、1、2、...、18。编号0的二叉查找树最多具有1个节点,该编号0的二叉查找树的节点对应的簇数目为262144。编号1的二叉查找树最多具有2个节点,该编号1的二叉查找树的节点对应的簇数目为131072(=262144/2)~262143。依序类推,编号18的二叉查找树具最多有262144个节点,该编号18的二叉查找树的节点对应的簇数目为1。Taking a flash memory file system with a capacity of 1 Gbyte (byte) as an example, the cluster unit is 4K bytes, so the file system has 262144 (=2 18 ) clusters. K is 18 (that is, Ceiling(log 2 (2 18 ))), so there are 19 binary search trees numbered 0, 1, 2, ..., 18. The binary search tree with number 0 has at most 1 node, and the number of clusters corresponding to the nodes of the binary search tree with number 0 is 262144. The binary search tree numbered 1 has at most 2 nodes, and the number of clusters corresponding to the nodes of the binary search tree numbered 1 is 131072 (=262144/2)˜262143. By analogy, the number 18 binary search tree has a maximum of 262144 nodes, and the number of clusters corresponding to the nodes of the number 18 binary search tree is 1.

每一个二叉查找树的节点包含一逻辑区块地址(Logical Block Address、LBA)字段及一大小字段。该逻辑区块地址(LBA)字段用以记载该节点相对应的连续可用的簇的起始逻辑区块地址。该大小字段用以记载该节点相对应的连续可用的簇的簇数目。Each node of the binary search tree includes a logical block address (Logical Block Address, LBA) field and a size field. The logical block address (LBA) field is used to record the starting logical block address of the continuously available cluster corresponding to the node. The size field is used to record the number of continuously available clusters corresponding to the node.

图3是本发明树状结构文件系统的管理方法的流程图。该文件系统具有n个簇及(K+1)个二叉查找树,其中n为大于2的正整数,K为正整数,该(K+1)个二叉查找树编号为0、1、2、...、K。每一个二叉查找树的节点包含一逻辑区块地址(LBA)字段及一大小字段,该逻辑区块地址(LBA)用以记载该节点对应的连续可用的簇的起始逻辑区块地址,该大小字段用以记载该节点对应的连续可用的簇的簇数目。标号i的二叉查找树中的节点记录的是连续可用的大小为n/(2^i)到n/(2^(i-1))个簇。Fig. 3 is a flow chart of the management method of the tree structure file system of the present invention. The file system has n clusters and (K+1) binary search trees, where n is a positive integer greater than 2, K is a positive integer, and the (K+1) binary search trees are numbered 0, 1, 2, ..., K. Each node of the binary search tree includes a logical block address (LBA) field and a size field, and the logical block address (LBA) is used to record the initial logical block address of the continuous available cluster corresponding to the node, The size field is used to record the number of continuously available clusters corresponding to the node. The nodes in the binary search tree labeled i record consecutively available clusters of size n/(2^i) to n/(2^(i-1)).

首先,在步骤S205中,输入一储存空间需求,该储存空间需求包含一需求逻辑区块地址(LBA)及一需求簇数目s。First, in step S205 , a storage space requirement is input, and the storage space requirement includes a required Logical Block Address (LBA) and a required cluster number s.

在步骤S210中,初始化一指标(index)i,并将其初始化为0。In step S210, initialize an index (index) i, and initialize it to 0.

在步骤S215中,依据该需求簇数目s以计算对应的一编号m的二叉查找树,0≤m≤K。m是依据公式log2(n)-floor(log2(s))+i计算,其中n为该文件系统的簇数目,s为需求簇数目,floor为地板函数。In step S215 , a binary search tree corresponding to number m is calculated according to the required number of clusters s, 0≤m≤K. m is calculated according to the formula log 2 (n)-floor(log 2 (s))+i, where n is the number of clusters in the file system, s is the number of required clusters, and floor is the floor function.

在步骤S220中,判断该编号m的二叉查找树中是否有节点,该编号m的二叉查找树中的节点即代表连续可用的簇的逻辑区块。In step S220, it is judged whether there is a node in the binary search tree with the number m, and the nodes in the binary search tree with the number m represent logical blocks of continuously available clusters.

在步骤S225中,若步骤S220中判定该编号m的二叉查找树中有节点,表示在该编号m的二叉查找树中有适合该储存空间需求的节点。故在该编号m的二叉查找树中找寻距离该需求逻辑区块地址(LBA)最近的节点,并将该距离该需求逻辑区块地址最近的节点由该编号m的二叉查找树中移除。In step S225, if it is determined in step S220 that there is a node in the binary search tree with number m, it means that there is a node suitable for the storage space requirement in the binary search tree with number m. Therefore, in the binary search tree of the number m, find the node closest to the required logical block address (LBA), and move the node closest to the required logical block address from the binary search tree of the number m remove.

由于m是依据公式log2(n)-floor(log2(s))+i计算,故该编号m的二叉查找树中的节点所记录的连续可用簇的大小大于或等于该需求簇数目s。当步骤S225中找寻到的节点记录的连续可用簇大小大于所需要的簇数目时,扣除所需的簇数目之后剩余的连续可用簇,形成一新的节点,加入适当的二叉查找树中。Since m is calculated according to the formula log 2 (n)-floor(log 2 (s))+i, the size of the continuous available cluster recorded by the node in the binary search tree with the number m is greater than or equal to the number of required clusters s. When the continuous available cluster size of the node record found in step S225 is greater than the required number of clusters, the remaining continuous available clusters after deducting the required number of clusters form a new node and add to the appropriate binary search tree.

在步骤S230中,对该编号m的二叉查找树执行平衡运算。由于步骤S225中移去节点,故需对该二叉查找树执行平衡(Balance)运算,以让该二叉查找树的左右两边节点数目尽量相等,以保持二叉查找树的搜寻速度。In step S230, a balancing operation is performed on the binary search tree numbered m. Since the node is removed in step S225, a balance operation needs to be performed on the binary search tree so that the number of nodes on the left and right sides of the binary search tree is as equal as possible to maintain the search speed of the binary search tree.

若步骤S220中判定该编号m的二叉查找树中没有节点,表示在该编号m的二叉查找树中没有适合该储存空间需求的节点。故在该编号m的二叉查找树的上层二叉查找树中找寻未使用的节点。此处所指的上层二叉查找树是指编号较m小的二叉查找树。先搜寻编号(m-1)的二叉查找树中是否有节点,若有,再在该编号(m-1)的二叉查找树中找寻距离该需求逻辑区块地址(LBA)最近的节点;若没有,则依序搜寻编号(m-2)的二叉查找树中是否有节点,直至编号0的二叉查找树。If it is determined in step S220 that there is no node in the binary search tree with number m, it means that there is no node suitable for the storage space requirement in the binary search tree with number m. Therefore, unused nodes are found in the upper binary search tree of the number m binary search tree. The upper-level binary search tree referred to here refers to a binary search tree with a smaller number m. First search whether there is a node in the binary search tree of the number (m-1), if there is, then find the node closest to the required logical block address (LBA) in the binary search tree of the number (m-1) ; If not, search sequentially whether there is a node in the binary search tree numbered (m-2), until the binary search tree numbered 0.

此处,在该编号m的二叉查找树中没有适合该储存空间需求的节点,先从该编号m的二叉查找树的上层二叉查找树中找寻未使用的节点,而不是从该编号m的二叉查找树的下层二叉查找树中找寻,是为了避免先从下层找起时可能会发生将存储空间需求分割成子需求的情况。Here, there is no node suitable for the storage space requirement in the binary search tree of the number m, first find an unused node from the upper binary search tree of the binary search tree of the number m instead of the node of the number m The purpose of searching in the lower binary search tree of m's binary search tree is to avoid the situation that the storage space requirement may be divided into sub-requirements when searching from the lower layer first.

若编号0的二叉查找树中仍没有未使用的节点,则由该编号m的二叉查找树的下层二叉查找树中找寻未使用的节点。此处所指的下层二叉查找树系指编号较m大的二叉查找树。先搜寻编号(m+1)的二叉查找树中是否有未使用的节点,若有,再在该编号(m+1)的二叉查找树中找寻距离该需求逻辑区块地址(LBA)最近的节点;若没有,则依序搜寻编号(m+2)的二叉查找树中是否有未使用的节点,直至编号K的二叉查找树。If there is still no unused node in the binary search tree numbered 0, the unused node is searched from the lower binary search tree of the binary search tree numbered m. The lower layer binary search tree referred to here refers to the binary search tree whose number is larger than m. First search whether there is an unused node in the binary search tree of the number (m+1), if there is, then find the distance from the required logical block address (LBA) in the binary search tree of the number (m+1) The nearest node; if not, then search sequentially whether there is an unused node in the binary search tree of number (m+2), until the binary search tree of number K.

在步骤S235中,判断指标i是否小于或等于0,若是执行步骤S240,若否,执行步骤S255。In step S235, it is determined whether the index i is less than or equal to 0, if yes, step S240 is executed, if not, step S255 is executed.

执行步骤S240是表示由该编号m的二叉查找树的上层二叉查找树中找寻未使用的节点。故于步骤S240中,将该指标i减1。执行步骤S255是表示由该编号m的二叉查找树的下层二叉查找树中找寻未使用的节点。Execution of step S240 means searching for unused nodes in the upper binary search tree of the number m binary search tree. Therefore, in step S240, the index i is decremented by 1. Executing step S255 means searching for unused nodes in the lower binary search tree of the number m binary search tree.

在步骤S245中,判断此二叉查找树编号是否大于或等于0,若大于或等于0,重新执行步骤S220,若小于0,则执行步骤S250。二叉查找树编号若小于0,表示已执行完上层二叉查找树的搜寻。故执行步骤S250,以由该编号m的二叉查找树的下层二叉查找树中找寻未使用的节点。在步骤S245中,二叉查找树编号为一更新编号m’=log2(n)-floor(log2(s))+i。In step S245, it is judged whether the binary search tree number is greater than or equal to 0, if greater than or equal to 0, re-execute step S220, if less than 0, then execute step S250. If the binary search tree number is less than 0, it means that the search of the upper binary search tree has been executed. Therefore, step S250 is executed to find unused nodes in the lower binary search tree of the number m binary search tree. In step S245, the binary search tree number is an update number m'=log 2 (n)-floor(log 2 (s))+i.

在步骤S250中,将该指标i设定为0。In step S250, the index i is set to 0.

在步骤S255中,将该指标i加1。In step S255, 1 is added to the index i.

在步骤S260中,判断二叉查找树编号是否大于K,若是,表示已执行完由该编号m的二叉查找树的下层二叉查找树中找寻未使用的节点,故结束搜寻程序。若否,则执行步骤S220,以找寻未使用的节点。在步骤S260中,二叉查找树编号为一更新编号m”=log2(n)-floor(log2(s))+i,判断二叉查找树编号是否大于K是执行下列公式:In step S260, it is judged whether the number of the binary search tree is greater than K, if so, it means that the search for unused nodes in the lower binary search tree of the binary search tree with the number m has been executed, so the search procedure ends. If not, execute step S220 to find unused nodes. In step S260, the binary search tree number is an update number m"=log 2 (n)-floor(log 2 (s))+i, and whether the binary search tree number is greater than K is to execute the following formula:

log2(n)-floor(log2(s))+i>Ceiling(log2(n))log 2 (n)-floor(log 2 (s))+i>Ceiling(log 2 (n))

其中,其中n为该文件系统的簇数目,s为需求簇数目,floor为地板函数,Ceiling为天花板函数。Among them, n is the number of clusters in the file system, s is the number of required clusters, floor is a floor function, and Ceiling is a ceiling function.

在搜寻下层二叉查找树未使用的节点时,其所找到的节点的簇比需求簇数目s小,此时需将该储存空间需求分割成子需求,即使用分散的节点以满足该储存空间需求。When searching for unused nodes in the lower binary search tree, the clusters of the found nodes are smaller than the required number of clusters s. At this time, the storage space requirement needs to be divided into sub-requirements, that is, scattered nodes are used to meet the storage space requirement .

图4是本发明一实施例的示意图。在该实施例中,一磁盘驱动器的容量为1G字节(byte),簇单位为4K字节,故该磁盘驱动器共有262144(=218)个簇。K为18(=Ceiling(log2(218))),故共有19个二叉查找树编号为0、1、2、...、18。如图3所示,在本实施例中最多同时存在节点数量为上述19个二叉查找树的节点总和,亦即为524287个节点。一个节点代表一段连续的簇。假设寻址长度为32位,则一个节点需要8个字节,故共需4096(524287*8/512)个扇区储存上述节点。故需千分之四的存储空间以存储节点。Fig. 4 is a schematic diagram of an embodiment of the present invention. In this embodiment, the capacity of a disk drive is 1G byte, and the cluster unit is 4K bytes, so the disk drive has a total of 262144 (=2 18 ) clusters. K is 18 (=Ceiling(log 2 (2 18 ))), so there are 19 binary search trees numbered 0, 1, 2, . . . , 18. As shown in FIG. 3 , in this embodiment, the maximum number of concurrently existing nodes is the sum of the nodes of the above 19 binary search trees, that is, 524,287 nodes. A node represents a continuous cluster. Assuming that the addressing length is 32 bits, one node needs 8 bytes, so a total of 4096 (524287*8/512) sectors are needed to store the above nodes. Therefore, four thousandths of the storage space is required to store nodes.

在本发明中,如果文件系统要找寻一块靠近位置a、大小为s个簇的剩余空间。最好的状况是第Floor(s/2)树状结构就有节点,由于这个树状结构的最大高度是Floor(s/2),所以最多只需进行Floor(s/2)次比较即可找到适当的节点。最坏的状况是只有Ceiling(log2(n))树状结构内部存有节点,由于会先检视其它Ceiling(log2(n))-1个树状结构内部有无节点,然后在最大高度为Ceiling(log2(n))的第Ceiling(log2(n))个树状结构作s次的遍历,所以最坏的状况时一共会有[Ceiling(log2(n))-1]+[Ceiling(log2(n))×s]次的遍历。In the present invention, if the file system is to find a piece of remaining space close to position a with a size of s clusters. The best situation is that there are nodes in the Floor(s/2)th tree structure. Since the maximum height of this tree structure is Floor(s/2), it only needs to perform Floor(s/2) comparisons at most. Find the appropriate node. The worst case is that there are only nodes in the Ceiling(log 2 (n)) tree structure, because it will first check whether there are nodes in the other Ceiling(log 2 (n))-1 tree structures, and then at the maximum height Do s traversals for the Ceiling(log 2 (n)) tree structure of Ceiling(log 2 (n)), so in the worst case there will be a total of [Ceiling(log 2 (n))-1] +[Ceiling(log 2 (n))×s] traversals.

由上述说明可知,当一存储媒体具有x个簇,要找寻一块靠近位置a、大小为s个簇的剩余空间时,已知技术由于使用线性的first hit方式搜寻,所以无法了解空间断离的程度,断离的情形也必然的不断的增加,故已知技术的时间复杂度是O(x*s)。本发明由于采用树状结构、以及混合了best hit及first hit,即使经过长时的操作,空间断离的程度仍然能透过简单的方式掌握,故本发明的时间复杂度是O(log2(x)*s)。相比已知技术中first hit技术搜寻时间长、时间复杂度高、不适用于实时系统的缺陷,本发明更适用于实时系统。本发明可减少文件系统中断离的现像,也可避免剩余空间维护困难的问题,同时大幅提升文件系统存取效能。From the above description, it can be known that when a storage medium has x clusters and it is necessary to find a remaining space of s clusters close to the position a, the known technology cannot understand the spatial separation because it uses a linear first hit search method. The degree of disconnection will inevitably increase continuously, so the time complexity of the known technology is O(x*s). Since the present invention adopts a tree structure and mixes best hit and first hit, even after a long period of operation, the degree of spatial separation can still be grasped in a simple way, so the time complexity of the present invention is O(log 2 (x)*s). Compared with the disadvantages of long search time, high time complexity and unsuitability for real-time systems in the prior art, the present invention is more suitable for real-time systems. The present invention can reduce the phenomenon of disconnection in the file system, avoid the problem of difficult maintenance of remaining space, and greatly improve the access performance of the file system.

当然,本发明还可有其他多种实施例,在不背离本发明精神及其实质的情况下,熟悉本领域的技术人员当可根据本发明作出各种相应的改变和变形,但这些相应的改变和变形都应属于本发明所附的权利要求的保护范围。Of course, the present invention can also have other various embodiments, and those skilled in the art can make various corresponding changes and deformations according to the present invention without departing from the spirit and essence of the present invention, but these corresponding Changes and deformations should belong to the scope of protection of the appended claims of the present invention.

Claims (13)

1. the management method of a 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) 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; And
(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 bunch size 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 corresponding binary search tree of node adding that forms.
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,
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) this is numbered m and subtracts 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).
4. management method as claimed in claim 3 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).
5. management method as claimed in claim 1 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.
6. management method as claimed in claim 1 is characterized in that,
This corresponding number of clusters order of each node that is numbered the binary search tree of j is n 2 j ~ n 2 j - 1 , 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.
7. management method as claimed in claim 1 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.
8. tree structure file system comprises:
N bunch, in order to storage data, wherein n is the integer greater than 2; And
(K+1) individual binary search tree, K are positive integer, and the node of each described binary search tree is in order to write down corresponding continuously available bunch;
Wherein, the node of each described binary search tree is to arrange according to the size of logical block addresses.
9. tree structure file system as claimed in claim 8 is characterized in that,
Described K value is Ceiling[log 2(n)], in the middle of, n is the number of clusters order of this tree structure file system, Ceiling is the ceiling function.
10. tree structure file system as claimed in claim 9 is characterized in that,
Described (K+1) individual binary search tree is numbered 0,1,2 ..., K, and this binary search tree that is numbered j has maximum 2 jIndividual node, j=0,1,2 ..., K.
11. tree structure file system as claimed in claim 10 is characterized in that,
This number of clusters order that is numbered each the node correspondence in the binary search tree of j is n 2 j ~ n 2 j - 1 , 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.
12. tree structure file system as claimed in claim 10 is characterized in that,
The node of each described binary search tree more comprises:
One logical block addresses field is in order to put down in writing the initial logical block addresses of corresponding bunch of this node; And
One size field is in order to put down in writing the number of clusters order of corresponding bunch of this node.
13. tree structure file system as claimed in claim 12 is characterized in that,
Described tree structure file system is applicable in a disc driver or the flash memory.
CNB2007101673418A 2007-10-25 2007-10-25 Management method of tree-structured 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 Management method of tree-structured file system

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CNB2007101673418A CN100543662C (en) 2007-10-25 2007-10-25 Management method of tree-structured file system

Publications (2)

Publication Number Publication Date
CN101169699A true CN101169699A (en) 2008-04-30
CN100543662C 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 Management method of tree-structured file system

Country Status (1)

Country Link
CN (1) CN100543662C (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306168A (en) * 2011-08-23 2012-01-04 成都市华为赛门铁克科技有限公司 Log operation method and device and file system
CN107783733A (en) * 2013-11-07 2018-03-09 深圳迈辽技术转移中心有限公司 Sequential access detecting system and method

Family Cites Families (4)

* 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
US7483906B2 (en) * 2004-04-14 2009-01-27 Microsoft Corporation Method and system for renaming consecutive keys in a B-tree
US7730114B2 (en) * 2004-11-12 2010-06-01 Microsoft Corporation Computer file system
US7756898B2 (en) * 2006-03-31 2010-07-13 Isilon Systems, Inc. Systems and methods for notifying listeners of events

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102306168A (en) * 2011-08-23 2012-01-04 成都市华为赛门铁克科技有限公司 Log operation method and device and file system
CN107783733A (en) * 2013-11-07 2018-03-09 深圳迈辽技术转移中心有限公司 Sequential access detecting system and method
CN107783733B (en) * 2013-11-07 2020-12-29 航天云网数据研究院(广东)有限公司 Sequential access detection system and method

Also Published As

Publication number Publication date
CN100543662C (en) 2009-09-23

Similar Documents

Publication Publication Date Title
CN104246764B (en) The method and apparatus for placing record in non-homogeneous access memory using non-homogeneous hash function
Bender et al. Don't thrash: How to cache your hash on flash
US8161240B2 (en) Cache management
CN109558084B (en) A data processing method and related equipment
CN103186350B (en) The moving method of mixing storage system and hot spot data block
US7890550B2 (en) Flash memory system and garbage collection method thereof
KR101289931B1 (en) Method and apparatus for storing data in flash memory using address mapping with various block sizes
CN108628753B (en) Memory space management method and device
KR101467589B1 (en) One or more device readable media having a data structure, and one or more device readable media having device executable instructions
JP5943095B2 (en) Data migration for composite non-volatile storage
CN103064639A (en) Method and device for storing data
CN113535670B (en) Virtual resource mirror image storage system and implementation method thereof
KR101438667B1 (en) Database method for b+ tree based on PRAM
CN103229164A (en) Data access method and device
CN109407985B (en) Data management method and related device
JP5447523B2 (en) Data processing apparatus, data recording method, and data recording program
CN113722319A (en) Data storage method based on learning index
CN113253926A (en) Memory internal index construction method for improving query and memory performance of novel memory
KR101123335B1 (en) Method and apparatus for configuring hash index, and apparatus for storing data having the said apparatus, and the recording media storing the program performing the said method
KR102546741B1 (en) File System-based Block Allocation Apparatus and Method
CN106227466A (en) A kind of data segment moving method and system
CN107203479B (en) Hierarchical storage system, storage controller and hierarchical control method
CN101169699A (en) Tree-structured file system and management method thereof
JP6006740B2 (en) Index management device
KR100878142B1 (en) Modified 수정 -tree index construction method for efficient operation on flash memory

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

Granted publication date: 20090923

Termination date: 20171025

CF01 Termination of patent right due to non-payment of annual fee