WO2013091244A1 - File system data storage method and access method and device therefor - Google Patents

File system data storage method and access method and device therefor Download PDF

Info

Publication number
WO2013091244A1
WO2013091244A1 PCT/CN2011/084551 CN2011084551W WO2013091244A1 WO 2013091244 A1 WO2013091244 A1 WO 2013091244A1 CN 2011084551 W CN2011084551 W CN 2011084551W WO 2013091244 A1 WO2013091244 A1 WO 2013091244A1
Authority
WO
WIPO (PCT)
Prior art keywords
file
directory
metadata
node
file system
Prior art date
Application number
PCT/CN2011/084551
Other languages
French (fr)
Chinese (zh)
Inventor
王凤
张敬亮
Original Assignee
华为技术有限公司
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 华为技术有限公司 filed Critical 华为技术有限公司
Priority to CN201180003263.2A priority Critical patent/CN103282899B/en
Priority to PCT/CN2011/084551 priority patent/WO2013091244A1/en
Publication of WO2013091244A1 publication Critical patent/WO2013091244A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/13File access structures, e.g. distributed indices

Definitions

  • the present invention relates to the field of storage technologies, and in particular, to a method, an access method and a device for storing data in a file system. Background technique
  • a file system is a method and data structure used by an operating system to clarify files on a disk or partition, that is, a method of organizing files on a disk.
  • the Namespace is the organization of file directories in the file system, or the logical organization of files in the file system. It is an important part of the file system. From the user's point of view, the namespace provides users with a logical, clear, easy-to-use, visual, and understandable form of logical files. Users perform various operations on files in the organization provided by the namespace, regardless of how the files are placed on the storage device, thereby solving or reducing the semantic separation between the human and the computer on the data store.
  • file directory organization of the tree structure is most similar to the real world organization structure, and is widely accepted. Therefore, most file systems logically organize file directories in a tree manner, including various disk file systems, such as the X extended file system (EXTx) and the log file system ( Journal file system, JFS), Reiserfs (Reiser file system), ZFS (Zettabyte File System), B+ tree file system (Btrfs), NTFS (New Technology File System), and file partition (File Allocation) Table, FAT32), etc.; network file system, such as Network File System (NFS), AFS (Old File System), Common Internet File Systems (CIFS), etc.; cluster file system, such as parallel network Parallel network file system (pNFS), parallel virtual file system (PVFS), General Parallel File System (GPFS), etc.; distributed file system, such as Google file system (google file system) System, GoogleFS ), distributed file system ( Hadoop Distr I Published File System; hadoo, HDFS), MFS (Moose File
  • the file system logically adopts a tree structure to organize the file directory, in the specific implementation, it is implemented in multiple layers and multiple levels in the disk and the memory, and the specific implementation is related to the physical organization of the file system.
  • the physical organization of the file system represents the location, connection, and cataloging of files on the file storage device (physical) in the file system. At present, most file systems have a similar physical organization.
  • the central concept of the physical organization is superblock, inode, Uata block, Uentry.
  • the super block is used to store the overall information of the file system, such as the size of the file system (the size depends on the file system); the directory entry is used to record the name and inode number of the ordinary file in the current directory, or record the current directory.
  • the name of the subdirectory and the index node number; the index node is used to record the metadata information of a common file or directory in the file system, and the metadata information includes the data block where the ordinary file is located or the next level directory entry of the directory.
  • Data block; a data block is used to place the actual contents of a normal file or to store all directory entries in a directory.
  • FIG. 1 is a schematic diagram of a disk distribution manner of the file system ext3.
  • the physical storage space (or partition) of the file system ext3 is divided into a plurality of block groups, each of which is composed of a super block, a group descriptor, a data block bitmap, and an inode. It consists of a bitmap, an inode table, a data block, and so on.
  • the data block bitmap can quickly find out which data blocks have content and which data blocks are empty blocks.
  • the data block bitmap is an indispensable part of the file system disk distribution.
  • the index node bitmap can also be used to quickly find out which index nodes are free and which index nodes have content.
  • the inode table records the inode number and the metadata information of the file or directory corresponding to the inode number, including the attributes of the file or directory and the data block where the file or directory is located.
  • the actual block file content is recorded in the data block, or the directory entry is the name of the next-level subdirectory of the current directory and the corresponding index node.
  • the file system ext3 can search and access the file directory through the index table and the directory entries recorded in the data block.
  • the existing file system namespace organization adopts a tree structure, and the physical space organization mode of the file system is implemented by hierarchical distribution.
  • the file system performs file directory lookup and access, that is, the resource mapping from the namespace to the file storage device needs to be divided into two layers: from the path (path) to the inode (inode) and from the inode (inode) to the data block (block) ).
  • the existing file system needs to start from the root directory, where the index node of the root directory is recorded in the file system. Then, the file system needs to access the disk space, and the root node is obtained according to the physical organization of the disk space.
  • the data block pointed to by the index node, and the next level of content of the root directory, that is, the directory entry, is obtained from the data block.
  • the file system matches the home with the obtained directory entry, and finds the index node corresponding to the home directory.
  • the file system accesses the disk space again, and obtains the data block pointed to by the home index node according to the physical organization of the disk space, and obtains the next level content of the home directory, that is, the directory entry from the data block.
  • the file system searches and matches the picture with the obtained directory entry, and finds the index node corresponding to the picture directory.
  • the file system accesses the disk space again, and obtains the data block pointed to by the index node of the picture according to the physical organization of the disk space, and obtains the next level content of the picture directory, that is, the directory item, from the data block.
  • the file system matches the flower.jpg with the obtained directory entry and finds the index node of the flower.jpg file.
  • the file system accesses the disk space again, and obtains the data block pointed to by the index node of the flower.jpg file according to the physical organization of the disk space, and then goes to the data block to obtain the flower.jpg file.
  • the embodiment of the invention provides a data storage method, an access method and a device in a file system, which are used to reduce the number of interactions between the memory and the disk space when the file system accesses data such as files or directories, and improve the access efficiency.
  • An embodiment of the present invention provides a method for storing data in a file system.
  • the disk space corresponding to the file system is divided into a first storage portion and a second storage portion, where the first storage portion is configured to store a metadata file.
  • the metadata file stores all path information required to access the disk space; the second storage portion is configured to store file data; and the file system converts the metadata when the data storage device in the file system is started.
  • the file is read from the disk space into the memory, and the storage method includes:
  • the file system If the file system establishes a next-level directory node under the first directory node, the file system stores the directory metadata information of the next-level directory node into a metadata file in the memory, and in the memory Adding first path information indicating the next-level directory node to the directory metadata information of the first directory node in the metadata file; the number of directory elements of the next-level directory node
  • the information includes: attribute information of the next-level directory node;
  • the file system If the file system stores a file under the first directory node, the file system acquires a free data block in the disk space, stores the file into the acquired data block, and files the file Metadata information is stored in the metadata file in the memory, and second path information pointing to the file is added to the directory metadata information of the first directory node in the metadata file in the memory;
  • the file metadata information of the file includes: attribute information of the file and a label of a data block storing the file;
  • the file system writes the metadata file in the memory into the disk space according to a preset period.
  • An embodiment of the present invention provides a storage device for data in a file system, including: a file system and a disk space corresponding to the file system;
  • the disk space is divided into a first storage portion and a second storage portion, the first storage portion is configured to store a metadata file, where the metadata file stores all path information required to access the disk space,
  • the second storage portion is configured to store file data;
  • the file system includes:
  • a first initial reading module configured to read the metadata file from the disk space into a memory when the storage device of the data in the file system is started;
  • a first storage module configured to: when the file system establishes a next-level directory node under the first directory node, store the directory metadata information of the next-level directory node into a metadata file in the memory, and Adding, to the directory metadata information of the first directory node in the metadata file in the memory, first path information that points to the next-level directory node; and the directory metadata information of the next-level directory node includes: Attribute information of the next-level directory node;
  • a second storage module configured to: when the file system stores a file under the first directory node, acquire a data block that is free in the disk space, and store the file into the acquired data block, where
  • the file metadata information of the file is stored in the metadata file in the memory, and the second path information pointing to the file is added to the metadata information of the first directory node in the metadata file in the memory.
  • the file metadata information of the file includes: attribute information of the file and a label of a data block storing the file;
  • a synchronization module configured to write the metadata file in the memory into the disk space according to a preset period.
  • An embodiment of the present invention provides a method for accessing data in a file system.
  • the disk space corresponding to the file system is divided into a first storage portion and a second storage portion, where the first storage portion is configured to store a metadata file.
  • the metadata file stores all path information required to access the disk space; the second storage portion is configured to store file data; and the file system activates the element when the data access device of the file system is started
  • the data file is read from the disk space into the memory, and the access method includes:
  • the file system starts from a root node in the metadata file in the memory, and points to a next-level directory according to directory metadata information of each directory node.
  • the first path information of the node is searched and matched in the directory metadata information of the directory nodes of each level until the target directory node is found or the search fails; if the target directory node is found, the file system is at the target Obtaining attribute information of the target directory node in the directory metadata information of the directory node;
  • the file system starts from a root node in the metadata file in the memory, and points to a next-level directory node according to directory metadata information of each directory node.
  • the first path information is searched and matched in the directory metadata information of the directory nodes of each level, and the last level directory node where the target file is located is obtained, and then pointed to according to the directory metadata information of the last level directory node.
  • the second path information of the next file is searched and matched in the file metadata information of the file under the last level directory node until the target file is found or the search fails; if the target file is found, the file
  • the system acquires, from the file metadata information of the target file, a label of a data block in the disk space in which the target file is stored, and then reads from a data block of the disk space identified by a label of the acquired data block. Take the target file.
  • An embodiment of the present invention provides an apparatus for accessing data in a file system, including: a file system and a disk space corresponding to the file system;
  • the disk space is divided into a first storage portion and a second storage portion, wherein the first storage portion is configured to store a metadata file, where the metadata file stores all path information required to access the disk space;
  • the second storage portion is configured to store file data;
  • the file system includes:
  • a second initial reading module configured to read the metadata file from the disk space into a memory when the access device of the data in the file system is started;
  • a first access module configured to start from a root node in the metadata file in the memory when the file system accesses the target directory node, and point to the next according to the directory metadata information of each directory node
  • the first path information of the level directory node performs lookup matching in the directory metadata information of the directory nodes of each level until the target directory node is found or the search fails, and if the target directory node is found, the target directory node Obtaining attribute information of the target directory node in the directory metadata information;
  • a second access module configured to: when the file system accesses the target file, start from a root node in the metadata file in the memory, and point to a next level according to directory metadata information of each directory node The first path information of the directory node is searched and matched in the directory metadata information of each directory node, and the last-level directory node where the target file is located is obtained, and then according to the directory metadata information of the last-level directory node.
  • the second path information pointing to the file below is searched and matched in the file metadata information of the file under the last level directory node until the target file is found or the search fails, and if the target file is found, Obtaining, in the file metadata information of the target file, a label of a data block storing the target file in the disk space, and then reading the data block of the disk space identified by a label of the acquired data block The target document.
  • the data storage method and device in the file system stores all path information of the disk space by using the metadata file, and reads the metadata file from the disk space into the memory when the system starts, in the When creating a next-level directory node or storing a file under a directory node, directly store the metadata information of the next-level directory node or the file to be stored into the metadata file in the memory, and at the previous level. Add the path information of the next-level directory node or the file to be stored in the metadata information of the directory node, organize the management of the namespace by using the metadata file, and divide only the space and storage file for storing the metadata file in the disk space.
  • the data block can be used, and the spatial division is not scattered as in the prior art, which improves the efficiency of the file system in storing data in the disk space, and lays a foundation for improving the efficiency of the file system accessing the data in the disk space.
  • the data access method and device in the file system provided by the embodiment of the present invention cooperate with the data storage method and device in the file system provided by the embodiment of the present invention, and the file system only needs the metadata in the disk space when the system is started.
  • the file is read into the memory space, according to the metadata information of the directory nodes and the files under the various levels of the directory stored in the metadata file (ie accessing the entire magnetic
  • the path information required for the disk space is searched.
  • the metadata file in the memory can be used to find the target file or the target directory at one time, which reduces the number of interactions between the memory and the disk space, and greatly improves the access efficiency.
  • 1 is a schematic diagram of a disk distribution manner of a file system ext3;
  • FIG. 2A is a schematic diagram of a tree structure of a metadata file according to an embodiment of the present invention
  • FIG. 2B is another schematic diagram of a tree structure of a metadata file according to an embodiment of the present invention
  • FIG. 3 is a schematic structural diagram of a data storage device in a file system according to an embodiment of the present invention.
  • FIG. 4 is a schematic structural diagram of an apparatus for accessing data in a file system according to an embodiment of the present invention.
  • the technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention.
  • the embodiments are a part of the embodiments of the invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
  • the present invention provides a metadata organization manner that can be directly mapped from a namespace to a disk space, so as to improve the file, in order to solve the problem that the file system in the prior art has a low efficiency in accessing the data in the disk space through the namespace.
  • the efficiency with which the system stores and accesses data is.
  • the namespace of the file system is implemented by a metadata file in the disk space in a specific implementation.
  • embodiments of the present invention employ a data link of a variant trie
  • the organization manages the metadata file (that is, the directory nodes at all levels in the metadata file form a tree structure), and the target file or the target directory can be found at one time through the metadata file, thereby greatly improving the search efficiency.
  • an embodiment of the present invention provides a method for storing data in a file system.
  • the file system manages the file directories in the namespace through metadata files.
  • the execution body of the embodiment of the present invention is a storage device for data in a file system, the device includes a file system and a disk space corresponding to the file system; the disk space is divided into a first storage portion and a second storage portion, and the first storage portion is used
  • the metadata file stores all the path information needed to access the entire disk space; the second storage portion is used to store the file data.
  • the storage method provided by the embodiment of the present invention includes: a file system creates a new directory (ie, a next-level directory) in a certain directory, and stores a storage operation of the information about the newly created directory and a file system that creates and stores the file in a certain directory. operating.
  • a file system creates a new directory (ie, a next-level directory) in a certain directory, and stores a storage operation of the information about the newly created directory and a file system that creates and stores the file in a certain directory. operating.
  • the file system creates a root node and stores the attribute information of the root node into a metadata file in memory.
  • the file system then creates and stores new directory nodes and/or files based on the root node.
  • the file system If the file system establishes the next-level directory node under the first directory node, the file system stores the directory metadata information of the next-level directory node into the metadata file in the memory, and the directory element in the first directory node The first path information pointing to the next-level directory node is added to the data information.
  • the directory metadata information of the next-level directory node includes: attribute information of the next-level directory node.
  • the first directory node may be any directory node that already exists in the file system namespace, and may be, for example, a root directory node, a first-level sub-directory node that may be a root directory node, or a first-level subdirectory.
  • the file system can determine in advance whether the directory or file is to be created. When it is determined that the next-level directory node is to be created under the first directory node, the file system stores the directory metadata information of the next-level directory node to be created into the metadata file in the memory to implement the metadata file. The pieces are managed for each directory node. At the same time, the file system stores the path information between the first directory node and the next-level directory node in the metadata file in the memory, that is, the storage in the directory metadata information of the first directory node points to the next The path information of the level directory node, so that the next directory node can be found through the first directory node.
  • the attribute information of the directory node may include: one of a directory node name, a type, a size, and a creation time, or any combination thereof.
  • the size of the directory node is generally 4096 bytes.
  • the directory metadata information of the directory node stored in the metadata file in the memory includes not only the attribute information of the directory node. Also includes path information for the directory node to point to its next-level directory node.
  • the structure of the metadata file can be regarded as a variant of trie.
  • Each directory node can correspond to a trie node, and the directory metadata information of each directory node can be used as the content of the corresponding trie node.
  • the variant trie of this embodiment differs from the standard trie in that each node of the standard trie stores one character, and each node of the variant trie of the embodiment stores a character string.
  • the string here mainly refers to the attribute information of each directory node and the path information to the next-level directory node.
  • the corresponding string mainly refers to the attribute information of the directory node.
  • the file system obtains the free data block in the disk space, stores the file in the acquired data block, and stores the file metadata information of the file into the metadata in the memory.
  • a second path information pointing to the file is added to the directory metadata information of the first directory node in the metadata file in the memory.
  • the file metadata information of the file includes attribute information of the file and a label of a data block in the disk space in which the file is stored.
  • the disk space corresponding to the file system is mainly divided into two parts, one part is used to store the metadata file, and the other part is used to store the data of each file.
  • the portion of the storage file is divided into a plurality of data blocks.
  • the file system also stores the file metadata information in the memory into the disk space according to a preset period.
  • the embodiments of the present invention do not limit the specific value of the preset period. For example, the period may be 10 minutes, and the cycle may be cycled once (that is, the synchronization is performed before the shutdown, so as to facilitate the data in the file system.
  • the file system can read the latest metadata file from disk space).
  • the file system creates a file in a directory, it needs to store the created file in disk space. Therefore, the file system queries the disk space for a block of data that is free in disk space and can store the file, and then stores the file in the fetched data block.
  • the file system then stores the file metadata information of the file into a metadata file in memory to manage the files in the file system's namespace through the metadata file.
  • the file metadata information mainly includes attribute information of the file and a label of a data block in the disk space in which the file is stored.
  • the attribute information of the file may include: one of the file name, the type, the size, and the creation time of the file, or any combination thereof.
  • the file name of the file can be picture.jpg, thesis.doc, etc.
  • the file type can be ordinary file, symbolic link, socket, etc.
  • the file information can be learned through the attribute information of the file, and stored in disk space.
  • the label of the data block of the file can be used to know where the file is stored in disk space in order to read or access the file from disk space.
  • each file in the metadata file may also correspond to a trie node, and the file metadata information of each file is the content of the corresponding trie node.
  • the trie node here stores a string compared to the standard trie node.
  • the string here mainly refers to the attribute information of each file and the label of the data block of the file stored in the disk space.
  • the file system further needs to store the information under the directory node directly in the metadata file, that is, add the directory path to the second path of the file in the directory metadata information of the directory node directly adjacent to the file. Information, so that the file is found by traversing the directory node.
  • the directory metadata information of the directory node includes not only the attribute information of the directory node but also the second path information of the directory node to which the directory node points.
  • the directory metadata information of the directory node includes attribute information of the directory node, second path information of the directory node to the next file, and The first path information pointing to the next-level directory node.
  • the directory node in this embodiment may also be empty, that is, the directory node has neither a file nor a next-level directory node, and the directory metadata information includes only the attribute information of the directory node.
  • the data storage device in the file system of the embodiment is activated at the time of the file.
  • the system reads the metadata file from the disk space to the memory, and operates the metadata file in the memory when storing the file or creating the new directory node, so that the metadata file stores all the directory nodes and the directory node and the lower part thereof.
  • each trie node may store attribute information of the directory node, path information of the directory node to the next file or the next-level directory node, attribute information of the file, or storage.
  • the information such as the label of the data block of the file, the namespace of the file system is managed by the metadata file, and the namespace is associated with an overall data structure.
  • the file system is convenient for data storage, thereby improving storage efficiency.
  • searching the storage location of the target directory or the target file can be found by reading the disk space at one time, which reduces the number of interactions between the memory and the disk space, and improves the efficiency of the file system to access the disk space.
  • the following describes the storage root directory /home/picture/flower.jpg file as an example.
  • the file system When the storage device (or system) of the data in the file system is started, the file system reads the metadata file from the disk space into the memory, and then, during the storage of the file or the directory establishment process, the element in the memory The data file is operated.
  • the file system creates a home directory under the root directory of the metadata file in memory, and stores the directory metadata information of the home directory into the metadata file in the memory.
  • the file system stores the directory name home, creation time, and the like of the home directory into a metadata file in memory (or a data structure stored in the variant trie).
  • the file system creates a picture directory in the home directory, stores the directory metadata information of the picture directory into the metadata file in the memory, and adds path information to the picture directory in the directory metadata information of the home directory.
  • the path information may include: a directory name of the picture directory and a pointer to the picture directory, so that the next directory of the home directory may be identified, and the next level directory may be found. Then, the file system creates a flower.jpg file in the picture directory, stores the file metadata information of the flower.jpg file into the metadata file in the memory, and adds a pointer to flower.jpg in the catalog metadata information of the picture directory. Path information for the file.
  • the path information may include: a file name of the flower.jpg file and a pointer to the flower.jpg file, so that it can identify which file is in the picture directory. You can also find the files under it.
  • the information stored in the metadata file in the memory can be represented as a tree structure as shown in FIG. 2A. Assuming that the preset period arrives at this time, the file system writes the metadata file shown in Fig. 2A into the first storage portion of the disk space.
  • the file system stores the file metadata information of the config file into the metadata file in the memory, and the directory metadata information in the root directory node. Add path information to the config file.
  • the file system also creates a video (Video) directory in the home directory
  • the file system stores the directory metadata information of the Video directory into the metadata file in the memory, and adds the directory metadata information in the home directory. Path information to the Video directory. Going a step further, suppose the file system also creates the today ( today ) directory in the picture directory and creates the sun . bmp ( sun.bmp ) file in the today directory.
  • the information stored in the metadata file in the memory can be represented as a tree structure as shown in Fig. 2B.
  • the circle indicates a non-empty directory node (i.e., there is a subordinate directory node under the directory node or a file exists or a file and a directory node at the same time).
  • a triangle indicates an empty directory node (that is, there is neither a file nor a next-level directory node under the directory node). The box represents the file node.
  • the file system writes the metadata file in the memory to the disk space, so that the metadata file in the disk space is consistent with the metadata file in the memory.
  • the variant trie shown in FIG. 2A and FIG. 2B mainly has the following differences: the standard trie stores one character per node, and the variant trie of this embodiment stores a string for each node. For example, directory name, file name, path information, and so on. Unlike the standard trie, all nodes of the variant trie of this embodiment can record information.
  • the path of the namespace of the file system corresponds to the variant trie structure of the embodiment, that is, a path from the root node to one leaf node through one or more intermediate nodes.
  • the variant trie of this embodiment is consistent with the directory tree structure of the file system itself, and can preserve the path complete semantics.
  • only the non-leaf node records the directory metadata information of the directory node, and does not need to record the correspondence between the directory node and the data block label, because in the variant trie structure, the next-level directory node of the directory node is not stored. In a data block, but directly The relationship between the directory nodes is maintained by the structure of the variant trie itself.
  • the leaf node records the file metadata information of the ordinary file and the corresponding data block label, and queries the leaf node, thereby obtaining the data block number of the storage file, which is equivalent to obtaining the content of the file.
  • Each leaf node of the variant trie of this embodiment can not only correspond to the file system file but also corresponding to the empty directory, and can record the directory metadata information of the empty directory.
  • the data structure design itself can support the establishment of an empty directory, support for reading the attribute information of the directory, support the traversal of the next level of the directory, and the operation of the file system directory can be correspondingly, which lays a foundation for the file system to access the disk space.
  • the file system may perform a linear table, a binary tree, or a hash in a metadata file in the memory for each directory node and/or each directory node and its lower file node.
  • An embodiment of the present invention provides a method for accessing data in a file system.
  • the access method is implemented based on a method for storing data in a file system provided by the foregoing embodiment.
  • the access device for data in the file system also includes a file system and a disk space corresponding to the file system.
  • the disk space is divided into a first storage portion for storing a metadata file, and a second storage portion for storing all path information required to access the disk space.
  • the metadata file stores directory metadata information of each directory node and file metadata information of a file stored in the disk space
  • the file metadata information includes file attribute information and a disk.
  • the label of the data block storing the file in the space, and the directory metadata information of the directory nodes of each level includes the attribute information of the directory node. If the directory node has a lower-level directory node, the directory metadata information further includes first path information corresponding to the next-level directory node; if the file exists under the directory node, the directory metadata information further includes a file pointing to the next file. Second path information.
  • the second storage portion is for storing file data.
  • a preferred implementation is as follows:
  • the directory nodes at each level in the metadata file form a tree structure.
  • this embodiment manages all path information through a metadata file, regardless of the file system Which access operation is performed can be based on metadata files in memory.
  • the file system If the data to be accessed by the file system is a directory node (denoted as a target directory node), the file system starts from the root node in the metadata file in the memory, according to the directory metadata information of each directory node.
  • the first path information pointing to the next-level directory node performs lookup matching in the directory metadata information of each directory node until the target directory node is found or the search fails.
  • the file system finds the target directory node in the metadata file in the memory, the file system reads the attribute information of the target directory node from the directory metadata information of the target directory node to implement reading or accessing the target directory node. It can be seen that all the path information is managed by the metadata file, so that the file system only needs to interact between the memory and the disk space when accessing the directory node (that is, the file system will be activated when the access device of the data in the file system is started).
  • the metadata file is read from the disk space into the memory), the access is completed, the number of interactions between the memory and the disk space is reduced, and the access efficiency is improved.
  • the file system starts from the root node in the metadata file in the memory, according to the directory metadata information of the directory nodes of each level.
  • the first path information pointing to the next-level directory node is searched and matched in the directory metadata information of each directory node, the last-level directory node where the target file is located, and then the directory metadata of the last-level directory node is obtained.
  • the second path information in the information pointing to the next file is searched and matched in the file element data information of the file under the last level directory node until the target file is found or the search fails.
  • the file system finds the target file from the metadata file in the memory, the file system obtains the label of the data block of the storage target file in the disk space from the file metadata information of the target file, and then the file system obtains the label of the obtained data block.
  • the target file is read in the data block of the identified disk space. That is, after obtaining the label of the data block where the target file is located, the file system reads the target file in the corresponding data block in the disk space, and reads the target file into the memory.
  • the attribute information of the directory nodes at each level includes: one of a directory name, a type, a size, and a creation time of each directory node or any combination thereof.
  • the attribute information of the file includes: one of the file name, type, size, and creation time of the file or any combination thereof.
  • the file system can use a linear table, a binary tree or a hash mode in each directory.
  • the directory metadata information of the node is searched and matched in the file metadata information of the file under the last level directory node where the target file is located.
  • the data access method in the file system provided by the embodiment is matched with the data storage method in the file system provided by the foregoing embodiment, and the file system namespace is matched with the entire data structure by using the storage structure of the metadata file.
  • the file system reads the metadata file from the disk space into the memory when the access device of the data in the file system is started.
  • the metadata file in the memory makes the parsing of the namespace directly from the path to the data block, and is no longer the path to The process of indexing the node to the data block, changing the disk space to search for multiple times, reduces the number of interactions between the file system and the disk space, and improves the efficiency of finding or accessing disk space.
  • the following describes the flow of the file access method provided by the embodiment of the present invention by taking the home/picture/flower .jpg file as an example in the metadata file structure shown in FIG. 2B.
  • the file system uses the hash algorithm when looking up to the next level.
  • the process of accessing the file is as follows:
  • Step 1 The file system reads the metadata file from the disk space into the memory when the access device of the data in the file system is started.
  • Step 2 The file system starts from the root node of the metadata file in the memory, and finds the home directory of the next-level directory node of the root node by hash.
  • Step 3 The file system continues to find the next-level directory node of the home directory node through the hash method, that is, the icture directory.
  • Step 4 The file system continues to find the flower.jpg file under the picture directory node by hash.
  • Step 5 The file system obtains the data block number of the flower.jpg file stored in the disk space from the file metadata information of the flower.jpg file.
  • the file system always looks in the metadata file in memory, does not interact with disk space, and can find the storage location of the target file in disk space by one search.
  • Step 6 The file system reads the flower.jpg file from the corresponding data block in the disk space according to the obtained data block label.
  • Step a The file system starts from the root node of the metadata file in the memory, and finds the home directory of the next-level directory node of the root node by hash.
  • Step b The file system continues to find the directory of the next level directory of the home directory node by hash.
  • Step c The file system continues to find the next directory directory of the picture directory node by hash.
  • Step d The file system obtains the attribute information of the today directory from the directory metadata information of the today directory.
  • the metadata file is the file system that reads from the disk space into the memory when the access device of the data in the file system is started, so the metadata file in the memory is directly used in the subsequent access process.
  • the file system is also searched in the metadata file in the memory, there is no interaction with the disk space, and the target directory node can be found in one search.
  • the embodiment organizes the namespace of the file system by using the metadata file, so that the file system can find the attribute information of the directory node or find the file in the disk space in the metadata file at a time.
  • the storage location there is no need to repeatedly interact between memory and disk space, which improves the efficiency of searching.
  • the data storage method in the file system provided by the embodiment of the present invention cooperates with the data access method in the file system provided by the embodiment of the present invention, and can generate the following beneficial effects: 1.
  • the namespace of the file system Managing an overall memory data structure using metadata files avoids multiple interactions between memory and disk space, with good overall performance, excellent performance, and high efficiency.
  • the data structure of the metadata file is simple and consistent with the directory tree structure of the file system itself, and can preserve the complete semantics of the path. 3.
  • the parsing process of the namespace is simplified from the path to the inode to the block process to the process directly from the path to the block, and the search is changed to the mapping one time, and the file or directory can be efficiently completed. Find.
  • FIG. 3 is a schematic structural diagram of a data storage device in a file system according to an embodiment of the present invention.
  • the apparatus of this embodiment includes: a file system 31 and a disk space 32 corresponding to the file system 31.
  • the disk space 32 of this embodiment is divided into a first storage portion and a second storage portion, A storage portion is used to store metadata files that store all path information needed to access disk space 32, and the second storage portion is used to store file data.
  • the file system 31 of this embodiment includes: a first initial reading module 311, a first storage module 312, a second storage module 313, and a synchronization module 314.
  • the first initial reading module 311 is connected to the disk space 32 for reading the metadata file from the disk space 32 into the memory when the storage device of the data in the file system is started.
  • the first storage module 312 is connected to the first initial reading module 31 1 and configured to store the directory metadata information of the next-level directory node to the first file node when the file system establishes the next-level directory node under the first directory node.
  • An initial reading module 31 1 reads into the metadata file in the memory, and adds the first path information pointing to the next-level directory node in the directory metadata information of the first directory node in the metadata file in the memory.
  • the directory metadata information of the next-level directory node includes: attribute information of the next-level directory node.
  • the attribute information of the next-level directory node includes: one of the directory name, type, size, and creation time of the next-level directory node or any combination thereof.
  • the second storage module 313 is connected to the first initial reading module 31 1 and the disk space 32, and is configured to acquire the free data block in the disk space 32 when the file system stores the file under the first directory node, and store the file to In the acquired data block, the file metadata information of the file is stored into the metadata file read by the first initial reading module 311 into the memory, and the element of the first directory node in the metadata file in the memory
  • the second path information pointing to the file is added to the data information;
  • the file metadata information of the file includes: attribute information of the file and a label of the data block of the storage file.
  • the attribute information of the file includes: one of the file name, type, size, and creation time of the file or any combination thereof.
  • the synchronization module 314 is connected to the disk space 32 and is used to write the metadata file in the memory into the disk space 32 according to a preset period. More specifically, the synchronization module 314 writes the metadata file in memory to the first storage portion of the disk space according to a preset period.
  • the directory nodes at all levels in the metadata file can form a tree structure, that is, the entire metadata file can be managed through a tree structure.
  • the first storage module 312 can organize the directory metadata information of the first directory node and the directory metadata information of the next directory node in a metadata file in the memory in a linear table, a binary tree, or a hash manner.
  • the second storage module 313 can organize the directory metadata information of the first directory node and the file metadata information of the file in a metadata file in the memory in a linear table, a binary tree, or a hash manner.
  • the function modules of the data storage device in the file system of the present embodiment can be used to execute the flow of the data storage method in the file system provided by the present invention.
  • the specific working principle is not described here. For details, refer to the description of the method embodiment.
  • the data storage device in the file system of this embodiment stores all the path information of the disk space by using the metadata file, and reads the metadata file from the disk space into the memory when the system starts, and creates a new level.
  • the directory node or a file is stored under a directory node
  • the metadata information of the next-level directory node or the file to be stored is directly stored in the metadata file in the memory
  • the element of the upper-level directory node is Add the path information to the next-level directory node or the file to be stored in the data information, and organize the management of the namespace by using the metadata file, so that only the space for storing the metadata file and the data block of the storage file are divided in the disk space.
  • the spatial division is not scattered as in the prior art, which improves the efficiency of the file system for storing data in the disk space, and lays a foundation for improving the efficiency of the file system to access data in the disk space.
  • FIG. 4 is a schematic structural diagram of an apparatus for accessing data in a file system according to an embodiment of the present invention. As shown in FIG. 4, the apparatus of this embodiment includes: a file system 41 and a disk space 42 corresponding to the file system 41.
  • the disk space 42 of this embodiment is divided into a first storage portion and a second storage portion, the first storage portion is configured to store a metadata file, and the metadata file stores all path information required to access the disk space 32.
  • the second storage portion is for storing file data.
  • the file system 41 of this embodiment includes: a second initial reading module 411, a first access module 412, and a second access module 413.
  • the second initial reading module 411 is connected to the disk space 42 for reading the metadata file from the disk space 42 into the memory when the access device of the data in the file system is started.
  • the first access module 412 is connected to the second initial reading module 41 1 for reading from the second initial reading module 41 1 into the metadata file in the memory when the file system accesses the target directory node.
  • the root directory node starts, according to the directory path metadata information of the directory nodes of each level, the first path information pointing to the next-level directory node is in the directory metadata information of each directory node. Perform a search match until the target directory node is found or the search fails. If the target directory node is found, the attribute information of the target directory node is obtained from the directory metadata information of the target directory node.
  • the attribute information of the directory nodes at each level includes: one of a directory name, a type, a size, and a creation time of each directory node or any combination thereof.
  • the second access module 413 is connected to the second initial reading module 41 1 and the disk space 42 for reading the metadata file in the memory from the second initial reading module 411 when the file system accesses the target file.
  • Starting at the root directory node searching and matching in the directory metadata information of each directory node according to the first path information pointing to the next-level directory node in the directory metadata information of each directory node, and obtaining the last of the target file
  • the first-level directory node performs matching matching in the file metadata information of the file under the last-level directory node according to the second path information in the directory metadata information of the last-level directory node, until the target is found.
  • the file or the search fails. If the target file is found, the label of the data block storing the target file in the disk space 42 is obtained from the file metadata information of the target file, and then the disk space 42 identified from the obtained data block is identified.
  • the target file is read in the data block.
  • the attribute information of the file includes: one of the file name, type, size, and creation time of the file or any combination thereof.
  • the metadata file of the embodiment is managed in a tree structure as a whole, that is, the directory nodes at each level in the metadata file constitute a tree structure.
  • the first access module 412 may specifically use a linear table, a binary tree, or a hash mode in each of the directory nodes of the metadata file and the directory node and the file to be organized and managed by using a linear table, a binary tree, or a hash mode. Lookup matching is performed in the directory metadata information of the level directory node.
  • the second access module 413 may specifically perform lookup matching in the directory metadata information of the directory nodes of each level and the file metadata information of the files in the last level directory node where the target file is located in a linear table, a binary tree or a hash manner.
  • the function modules of the data accessing device in the file system of the present embodiment can be used to execute the flow of the data access method in the file system provided by the embodiment of the present invention, and the specific working principle is not described again.
  • the data access device in the file system of the embodiment cooperates with the data storage device in the file system provided in the above embodiment, and the file system only needs to be in the disk space when the system is booted.
  • the metadata file is read into the memory space, and the metadata information (that is, the path information required to access the entire disk space) is searched according to the directory nodes stored in the metadata file and the files in the directories at all levels, through the memory.
  • the metadata file can find the target file or the target directory at one time, which reduces the number of interactions between the memory and the disk space, and greatly improves the access efficiency.

Abstract

The present invention provides a file system data storage method and an access method and device therefor. A magnetic disk space corresponding to a file system is divided into a first storage portion and a second storage portion, the first storage portion is used for storing a metadata file, and all path information required for accessing the magnetic disk space is stored in the metadata file; the second storage portion is used for storing file data; when the system is started, the metadata file is read into an internal memory from the magnetic disk space, and then the file system performs storage and access operations on the magnetic disk space based on the metadata file in the internal memory. All the path information is stored in the metadata file, so the storage location of a target node or file may be found from the metadata file just once, thereby reducing the number of times of interaction between the internal memory and the magnetic disk space, and greatly improving the access efficiency.

Description

文件系统中数据的存储方法、 访问方法及装置 技术领域 本发明涉及存储技术领域, 尤其涉及一种文件系统中数据的存储方法、 访问方法及装置。 背景技术  The present invention relates to the field of storage technologies, and in particular, to a method, an access method and a device for storing data in a file system. Background technique
文件系统是操作系统用于明确磁盘或分区上的文件的方法和数据结构, 即在磁盘上组织文件的方法。 而命名空间 ( Namespace )是文件系统中文件 目录的组织方式, 或者称之为文件系统中文件的逻辑组织方式, 是文件系统 的重要组成部分。 命名空间从用户的角度出发, 为用户提供了一种逻辑结构 清晰、 使用方便、 可视化、 可理解的逻辑文件形式。 用户按照命名空间提供 的组织形式对文件执行各种操作,而不用关心文件在存储设备上是如何放置 的, 从而解决或降低了人类与计算机之间在数据存储上的语义间隔。  A file system is a method and data structure used by an operating system to clarify files on a disk or partition, that is, a method of organizing files on a disk. The Namespace is the organization of file directories in the file system, or the logical organization of files in the file system. It is an important part of the file system. From the user's point of view, the namespace provides users with a logical, clear, easy-to-use, visual, and understandable form of logical files. Users perform various operations on files in the organization provided by the namespace, regardless of how the files are placed on the storage device, thereby solving or reducing the semantic separation between the human and the computer on the data store.
目前, 树状结构的文件目录组织方式与现实世界的组织结构最为相似, 被人们所广泛接受。 因此, 绝大多数的文件系统在逻辑上均以树(Tree )方 式来组织文件目录, 包括各种磁盘文件系统, 例如第 X代扩展文件系统(X extended file system, EXTx ) 、 日志文件系统 ( journal file system, JFS ) 、 Reiserfs ( Reiser file system), ZFS ( Zettabyte File System), B+树文件系统 (B+ tree file system, Btrfs)、 NTFS ( New Technology File System ) 、 文当分酉己表 ( File Allocation Table , FAT32 ) 等; 网络文件系统, 例如网络文件系统 ( Network File System, NFS ) 、 AFS ( Andrew File System ) 、 通用互联网 文件系统( Common Internet File Systems , CIFS )等; 集群文件系统, 例如 并行网络文件系统(parallel network file system, pNFS ) 、 并行虚拟文件系 统( parallel virtural file system, PVFS )、通用并行文件系统( General Parallel File System, GPFS )等; 分布式文件系统, 例如谷歌文件系统( google file system, GoogleFS )、分布文件系统 ( Hadoop Distributed File System;hadoo , HDFS ) 、 MFS ( Moose File System ) 、 KFS ( Kosmos distributed file system ) 、 淘宝文件系统 ( taobao file system, TaobaoFS )等。 尽管文件系统在逻辑上采用树状结构来组织文件目录,但在具体实现上 是多层多级地在磁盘和内存中实现的,具体实现与文件系统的物理组织方式 有关。 文件系统的物理组织方式表示了文件系统中的文件在文件存储设备 (物理上的)上的位置、 连接和编目形式。 目前, 大部分文件系统具有类似 的物理组织方式, 该物理组织方式的中心概念是超级块( superblock ) 、 索 引节点 (inode ) 、 数据块 Uata block ) 、 目录项 Uentry )等。 其中, 超级 块用于存储文件系统的总体信息, 比如文件系统的大小(该大小具体视文件 系统而定); 目录项用来记录当前目录下普通文件的名字和索引节点号, 或 记录当前目录的子目录的名字和索引节点号; 索引节点用来记录文件系统中 某一普通文件或目录的元数据信息,该元数据信息包括普通文件所在的数据 块或该目录的下一级目录项所在的数据块;数据块用来放置普通文件真正的 内容或存放某一目录的所有目录项。 At present, the file directory organization of the tree structure is most similar to the real world organization structure, and is widely accepted. Therefore, most file systems logically organize file directories in a tree manner, including various disk file systems, such as the X extended file system (EXTx) and the log file system ( Journal file system, JFS), Reiserfs (Reiser file system), ZFS (Zettabyte File System), B+ tree file system (Btrfs), NTFS (New Technology File System), and file partition (File Allocation) Table, FAT32), etc.; network file system, such as Network File System (NFS), AFS (Old File System), Common Internet File Systems (CIFS), etc.; cluster file system, such as parallel network Parallel network file system (pNFS), parallel virtual file system (PVFS), General Parallel File System (GPFS), etc.; distributed file system, such as Google file system (google file system) System, GoogleFS ), distributed file system ( Hadoop Distr Ibuted File System; hadoo, HDFS), MFS (Moose File System), KFS (Kosmos distributed file system), Taobao file system (taobao file system, TaobaoFS). Although the file system logically adopts a tree structure to organize the file directory, in the specific implementation, it is implemented in multiple layers and multiple levels in the disk and the memory, and the specific implementation is related to the physical organization of the file system. The physical organization of the file system represents the location, connection, and cataloging of files on the file storage device (physical) in the file system. At present, most file systems have a similar physical organization. The central concept of the physical organization is superblock, inode, Uata block, Uentry. The super block is used to store the overall information of the file system, such as the size of the file system (the size depends on the file system); the directory entry is used to record the name and inode number of the ordinary file in the current directory, or record the current directory. The name of the subdirectory and the index node number; the index node is used to record the metadata information of a common file or directory in the file system, and the metadata information includes the data block where the ordinary file is located or the next level directory entry of the directory. Data block; a data block is used to place the actual contents of a normal file or to store all directory entries in a directory.
图 1为文件系统 ext3的磁盘分布方式的示意图。如图 1所示,文件系统 ext3的物理存储空间 (或称为分区)被分成了多个块组(block group ) , 每 个块组由超级块、 组描述符、 数据块位图、 索引节点位图、 索引节点表、 数 据块等部分组成。 其中, 通过数据块位图可以快速查找到哪些数据块有内容 哪些数据块是空块, 数据块位图是文件系统磁盘分布中必不可少的一个部 分。通过索引节点位图同样可以快速查找哪些索引节点是空闲的哪些索引节 点有内容。索引节点表记录了索引节点号以及该索引节点号对应的文件或目 录的元数据信息, 包括文件或目录的属性和文件或目录所在的数据块等。 数 据块中记录的是真实的普通文件内容,或者是目录项即当前目录的下一级子 目录的名称以及对应的索引节点。文件系统 ext3通过索引节点表和数据块中 记载的目录项, 可以进行文件目录的查找和访问。  FIG. 1 is a schematic diagram of a disk distribution manner of the file system ext3. As shown in FIG. 1, the physical storage space (or partition) of the file system ext3 is divided into a plurality of block groups, each of which is composed of a super block, a group descriptor, a data block bitmap, and an inode. It consists of a bitmap, an inode table, a data block, and so on. Among them, the data block bitmap can quickly find out which data blocks have content and which data blocks are empty blocks. The data block bitmap is an indispensable part of the file system disk distribution. The index node bitmap can also be used to quickly find out which index nodes are free and which index nodes have content. The inode table records the inode number and the metadata information of the file or directory corresponding to the inode number, including the attributes of the file or directory and the data block where the file or directory is located. The actual block file content is recorded in the data block, or the directory entry is the name of the next-level subdirectory of the current directory and the corresponding index node. The file system ext3 can search and access the file directory through the index table and the directory entries recorded in the data block.
从整体上来讲, 现有的文件系统的命名空间组织方式采用树状结构, 而 文件系统的物理空间组织方式是分级分布实现的。文件系统进行文件目录的 查找和访问, 即由命名空间到文件存储设备上的资源映射需要分两层: 从路 径( path )到索引节点( inode )以及从索引节点( inode )到数据块( block ) 。 以访问家 (home ) /图片 (picture ) /花. jpg ( flower.jpg ) 文件为例, 现有文 件系统需要从根目录出发, 其中, 文件系统中记录了根目录的索引节点。 然 后, 文件系统需要访问磁盘空间, 根据磁盘空间的物理组织方式得到根节点 的索引节点指向的数据块,并从该数据块中得到根目录的下一级内容即目录 项。 接着, 文件系统将 home与得到的目录项进行查找匹配, 找到 home 目 录对应的索引节点。 然后, 文件系统再次去访问磁盘空间, 根据磁盘空间的 物理组织方式得到 home 的索引节点指向的数据块, 并从该数据块中得到 home目录的下一级内容, 即目录项。 接着, 文件系统将 picture与得到的目 录项进行查找匹配, 找到 picture 目录对应的索引节点。 然后, 文件系统再 次去访问磁盘空间, 根据磁盘空间的物理组织方式得到 picture 的索引节点 指向的数据块, 并从该数据块中得到 picture目录的下一级内容, 即目录项。 接着, 文件系统将 flower.jpg与得到的目录项进行查找匹配, 找到 flower.jpg 文件的索引节点。 然后, 文件系统再次访问磁盘空间, 根据磁盘空间的物理 组织方式得到 flower.jpg文件的索引节点指向的数据块, 然后去该数据块中 获取 flower.jpg文件。 As a whole, the existing file system namespace organization adopts a tree structure, and the physical space organization mode of the file system is implemented by hierarchical distribution. The file system performs file directory lookup and access, that is, the resource mapping from the namespace to the file storage device needs to be divided into two layers: from the path (path) to the inode (inode) and from the inode (inode) to the data block (block) ). Take the home/picture (picture)/flower.jpg (flower.jpg) file as an example. The existing file system needs to start from the root directory, where the index node of the root directory is recorded in the file system. Then, the file system needs to access the disk space, and the root node is obtained according to the physical organization of the disk space. The data block pointed to by the index node, and the next level of content of the root directory, that is, the directory entry, is obtained from the data block. Then, the file system matches the home with the obtained directory entry, and finds the index node corresponding to the home directory. Then, the file system accesses the disk space again, and obtains the data block pointed to by the home index node according to the physical organization of the disk space, and obtains the next level content of the home directory, that is, the directory entry from the data block. Then, the file system searches and matches the picture with the obtained directory entry, and finds the index node corresponding to the picture directory. Then, the file system accesses the disk space again, and obtains the data block pointed to by the index node of the picture according to the physical organization of the disk space, and obtains the next level content of the picture directory, that is, the directory item, from the data block. Next, the file system matches the flower.jpg with the obtained directory entry and finds the index node of the flower.jpg file. Then, the file system accesses the disk space again, and obtains the data block pointed to by the index node of the flower.jpg file according to the physical organization of the disk space, and then goes to the data block to obtain the flower.jpg file.
由上述可见, 现有文件系统通过命名空间访问文件或目录等数据时, 操 作复杂, 需要在内存与磁盘空间之间进行多次交互才能完成, 其访问或读取 效率较低。 发明内容  It can be seen from the above that when an existing file system accesses data such as a file or a directory through a namespace, the operation is complicated, and multiple interactions between the memory and the disk space are required to complete, and the access or read efficiency is low. Summary of the invention
本发明实施例提供一种文件系统中数据的存储方法、 访问方法及装置 , 用以减少文件系统访问文件或目录等数据时在内存与磁盘空间之间的交互 次数, 提高访问效率。  The embodiment of the invention provides a data storage method, an access method and a device in a file system, which are used to reduce the number of interactions between the memory and the disk space when the file system accesses data such as files or directories, and improve the access efficiency.
本发明实施例一方面提供一种文件系统中数据的存储方法 ,文件系统对 应的磁盘空间被划分为第一存储部分和第二存储部分,所述第一存储部分用 于存储元数据文件 ,所述元数据文件存储有访问所述磁盘空间所需的所有路 径信息; 所述第二存储部分用于存储文件数据; 所述文件系统在文件系统中 数据的存储装置启动时, 将所述元数据文件从所述磁盘空间读取到内存中, 所述存储方法包括:  An embodiment of the present invention provides a method for storing data in a file system. The disk space corresponding to the file system is divided into a first storage portion and a second storage portion, where the first storage portion is configured to store a metadata file. The metadata file stores all path information required to access the disk space; the second storage portion is configured to store file data; and the file system converts the metadata when the data storage device in the file system is started The file is read from the disk space into the memory, and the storage method includes:
如果所述文件系统在第一目录节点下建立下一级目录节点,所述文件系 统将所述下一级目录节点的目录元数据信息存储到内存中的元数据文件中, 并在所述内存中的元数据文件中的第一目录节点的目录元数据信息中添加 指向所述下一级目录节点的第一路径信息; 所述下一级目录节点的目录元数 据信息包括: 所述下一级目录节点的属性信息; If the file system establishes a next-level directory node under the first directory node, the file system stores the directory metadata information of the next-level directory node into a metadata file in the memory, and in the memory Adding first path information indicating the next-level directory node to the directory metadata information of the first directory node in the metadata file; the number of directory elements of the next-level directory node The information includes: attribute information of the next-level directory node;
如果所述文件系统在所述第一目录节点下存储文件,所述文件系统获取 所述磁盘空间中空闲的数据块, 将所述文件存储到所获取的数据块中, 将所 述文件的文件元数据信息存储到所述内存中的元数据文件中,并在所述内存 中的元数据文件中的第一目录节点的目录元数据信息中添加指向所述文件 的第二路径信息; 所述文件的文件元数据信息包括: 所述文件的属性信息和 存储所述文件的数据块的标号;  If the file system stores a file under the first directory node, the file system acquires a free data block in the disk space, stores the file into the acquired data block, and files the file Metadata information is stored in the metadata file in the memory, and second path information pointing to the file is added to the directory metadata information of the first directory node in the metadata file in the memory; The file metadata information of the file includes: attribute information of the file and a label of a data block storing the file;
所述文件系统按照预设周期,将所述内存中的元数据文件写入所述磁盘 空间中。  The file system writes the metadata file in the memory into the disk space according to a preset period.
本发明实施例一方面提供一种文件系统中数据的存储装置, 包括: 文件 系统和与所述文件系统对应的磁盘空间;  An embodiment of the present invention provides a storage device for data in a file system, including: a file system and a disk space corresponding to the file system;
所述磁盘空间被划分为第一存储部分和第二存储部分,所述第一存储部 分用于存储元数据文件 ,所述元数据文件存储有访问所述磁盘空间所需的所 有路径信息, 所述第二存储部分用于存储文件数据;  The disk space is divided into a first storage portion and a second storage portion, the first storage portion is configured to store a metadata file, where the metadata file stores all path information required to access the disk space, The second storage portion is configured to store file data;
所述文件系统包括:  The file system includes:
第一初始读取模块, 用于在所述文件系统中数据的存储装置启动时, 将 所述元数据文件从所述磁盘空间中读取到内存中;  a first initial reading module, configured to read the metadata file from the disk space into a memory when the storage device of the data in the file system is started;
第一存储模块,用于在所述文件系统在第一目录节点下建立下一级目录 节点时,将所述下一级目录节点的目录元数据信息存储到内存中的元数据文 件中,并在所述内存中的元数据文件中的第一目录节点的目录元数据信息中 添加指向所述下一级目录节点的第一路径信息; 所述下一级目录节点的目录 元数据信息包括: 所述下一级目录节点的属性信息;  a first storage module, configured to: when the file system establishes a next-level directory node under the first directory node, store the directory metadata information of the next-level directory node into a metadata file in the memory, and Adding, to the directory metadata information of the first directory node in the metadata file in the memory, first path information that points to the next-level directory node; and the directory metadata information of the next-level directory node includes: Attribute information of the next-level directory node;
第二存储模块, 用于在所述文件系统在所述第一目录节点下存储文件 时, 获取所述磁盘空间中空闲的数据块, 将所述文件存储到所获取的数据块 中, 将所述文件的文件元数据信息存储到所述内存中的元数据文件中, 并在 所述内存中的元数据文件中的第一目录节点的元数据信息中添加指向所述 文件的第二路径信息; 所述文件的文件元数据信息包括: 所述文件的属性信 息和存储所述文件的数据块的标号;  a second storage module, configured to: when the file system stores a file under the first directory node, acquire a data block that is free in the disk space, and store the file into the acquired data block, where The file metadata information of the file is stored in the metadata file in the memory, and the second path information pointing to the file is added to the metadata information of the first directory node in the metadata file in the memory. The file metadata information of the file includes: attribute information of the file and a label of a data block storing the file;
同步模块, 用于按照预设周期, 将所述内存中的元数据文件写入所述磁 盘空间中。 本发明实施例另一方面提供一种文件系统中数据的访问方法, 文件系统对应 的磁盘空间被划分为第一存储部分和第二存储部分, 所述第一存储部分用 于存储元数据文件, 所述元数据文件存储有访问所述磁盘空间所需的所有 路径信息; 所述第二存储部分用于存储文件数据; 所述文件系统在文件系 统中数据的访问装置启动时, 将所述元数据文件从所述磁盘空间读取到内 存中, 所述访问方法包括: a synchronization module, configured to write the metadata file in the memory into the disk space according to a preset period. An embodiment of the present invention provides a method for accessing data in a file system. The disk space corresponding to the file system is divided into a first storage portion and a second storage portion, where the first storage portion is configured to store a metadata file. The metadata file stores all path information required to access the disk space; the second storage portion is configured to store file data; and the file system activates the element when the data access device of the file system is started The data file is read from the disk space into the memory, and the access method includes:
如果所述文件系统要访问的数据为目标目录节点, 所述文件系统从所 述内存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元 数据信息中指向下一级目录节点的第一路径信息在各级目录节点的目录 元数据信息中进行查找匹配, 直到查找到所述目标目录节点或者查找失 败; 如果查找到所述目标目录节点, 所述文件系统在所述目标目录节点的 目录元数据信息中获取所述目标目录节点的属性信息;  If the data to be accessed by the file system is a target directory node, the file system starts from a root node in the metadata file in the memory, and points to a next-level directory according to directory metadata information of each directory node. The first path information of the node is searched and matched in the directory metadata information of the directory nodes of each level until the target directory node is found or the search fails; if the target directory node is found, the file system is at the target Obtaining attribute information of the target directory node in the directory metadata information of the directory node;
如果所述文件系统要访问的数据为目标文件, 所述文件系统从所述内 存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元数据 信息中指向下一级目录节点的第一路径信息在各级目录节点的目录元数 据信息中进行查找匹配, 获取所述目标文件所在的最后一级目录节点, 然 后根据所述最后一级目录节点的目录元数据信息中指向其下文件的第二 路径信息在所述最后一级目录节点下的文件的文件元数据信息中进行查 找匹配,直到查找到所述目标文件或查找失败;如果查找到所述目标文件, 所述文件系统从所述目标文件的文件元数据信息中获取所述磁盘空间中 存储所述目标文件的数据块的标号, 然后从所获取的数据块的标号所标识 的所述磁盘空间的数据块中读取所述目标文件。  If the data to be accessed by the file system is a target file, the file system starts from a root node in the metadata file in the memory, and points to a next-level directory node according to directory metadata information of each directory node. The first path information is searched and matched in the directory metadata information of the directory nodes of each level, and the last level directory node where the target file is located is obtained, and then pointed to according to the directory metadata information of the last level directory node. The second path information of the next file is searched and matched in the file metadata information of the file under the last level directory node until the target file is found or the search fails; if the target file is found, the file The system acquires, from the file metadata information of the target file, a label of a data block in the disk space in which the target file is stored, and then reads from a data block of the disk space identified by a label of the acquired data block. Take the target file.
本发明实施例另一方面提供一种文件系统中数据的访问装置, 包括: 文件系统和与所述文件系统对应的磁盘空间;  An embodiment of the present invention provides an apparatus for accessing data in a file system, including: a file system and a disk space corresponding to the file system;
所述磁盘空间被划分为第一存储部分和第二存储部分, 所述第一存储 部分用于存储元数据文件, 所述元数据文件存储有访问所述磁盘空间所需 的所有路径信息; 所述第二存储部分用于存储文件数据;  The disk space is divided into a first storage portion and a second storage portion, wherein the first storage portion is configured to store a metadata file, where the metadata file stores all path information required to access the disk space; The second storage portion is configured to store file data;
所述文件系统包括:  The file system includes:
第二初始读取模块, 用于在所述文件系统中数据的访问装置启动时, 将所述元数据文件从所述磁盘空间中读取到内存中; 第一访问模块, 用于在所述文件系统对目标目录节点进行访问时, 从 所述内存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录 元数据信息中指向下一级目录节点的第一路径信息在各级目录节点的目 录元数据信息中进行查找匹配, 直到查找到所述目标目录节点或查找失 败, 如果查找到所述目标目录节点, 在所述目标目录节点的目录元数据信 息中获取所述目标目录节点的属性信息; a second initial reading module, configured to read the metadata file from the disk space into a memory when the access device of the data in the file system is started; a first access module, configured to start from a root node in the metadata file in the memory when the file system accesses the target directory node, and point to the next according to the directory metadata information of each directory node The first path information of the level directory node performs lookup matching in the directory metadata information of the directory nodes of each level until the target directory node is found or the search fails, and if the target directory node is found, the target directory node Obtaining attribute information of the target directory node in the directory metadata information;
第二访问模块, 用于在所述文件系统对目标文件进行访问时, 从所述 内存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元数 据信息中指向下一级目录节点的第一路径信息在各级目录节点的目录元 数据信息中进行查找匹配, 获取所述目标文件所在的最后一级目录节点, 然后根据所述最后一级目录节点的目录元数据信息中指向其下文件的第 二路径信息在所述最后一级目录节点下的文件的文件元数据信息中进行 查找匹配, 直到查找到所述目标文件或查找失败, 如果查找到所述目标文 件, 从所述目标文件的文件元数据信息中获取所述磁盘空间中存储所述目 标文件的数据块的标号, 然后从所获取的数据块的标号所标识的所述磁盘 空间的数据块中读取所述目标文件。  a second access module, configured to: when the file system accesses the target file, start from a root node in the metadata file in the memory, and point to a next level according to directory metadata information of each directory node The first path information of the directory node is searched and matched in the directory metadata information of each directory node, and the last-level directory node where the target file is located is obtained, and then according to the directory metadata information of the last-level directory node. The second path information pointing to the file below is searched and matched in the file metadata information of the file under the last level directory node until the target file is found or the search fails, and if the target file is found, Obtaining, in the file metadata information of the target file, a label of a data block storing the target file in the disk space, and then reading the data block of the disk space identified by a label of the acquired data block The target document.
本发明实施例提供的文件系统中数据的存储方法及装置, 通过使用元 数据文件存储访问磁盘空间的所有路径信息, 并在系统启动时将元数据文 件从磁盘空间中读取到内存中, 在新建下一级目录节点或在某一目录节点 下存储文件时, 直接将要建立的下一级目录节点或要存储的文件的元数据 信息存储到内存中的元数据文件中, 并在上一级目录节点的元数据信息中 添加指向下一级目录节点或所要存储的文件的路径信息, 使用元数据文件 对命名空间进行组织管理, 使磁盘空间中仅划分出存储元数据文件的空间 和存储文件的数据块即可, 不再像现有技术那样将空间划分的比较散, 提 高了文件系统在磁盘空间中存储数据的效率, 同时为提高文件系统访问磁 盘空间中的数据的效率打下了基础。  The data storage method and device in the file system provided by the embodiment of the present invention stores all path information of the disk space by using the metadata file, and reads the metadata file from the disk space into the memory when the system starts, in the When creating a next-level directory node or storing a file under a directory node, directly store the metadata information of the next-level directory node or the file to be stored into the metadata file in the memory, and at the previous level. Add the path information of the next-level directory node or the file to be stored in the metadata information of the directory node, organize the management of the namespace by using the metadata file, and divide only the space and storage file for storing the metadata file in the disk space. The data block can be used, and the spatial division is not scattered as in the prior art, which improves the efficiency of the file system in storing data in the disk space, and lays a foundation for improving the efficiency of the file system accessing the data in the disk space.
本发明实施例提供的文件系统中数据的访问方法及装置, 与本发明实 施例提供的文件系统中数据的存储方法及装置相配合, 文件系统只需在系 统启动时将磁盘空间中的元数据文件读取到内存空间中, 根据元数据文件 中存储的各级目录节点和各级目录下的文件的元数据信息(即访问整个磁 盘空间所需的路径信息)进行查找, 通过内存中的元数据文件可以一次性 找到目标文件或目标目录, 减少了在内存与磁盘空间之间的交互次数, 大 大提高访问效率。 附图说明 The data access method and device in the file system provided by the embodiment of the present invention cooperate with the data storage method and device in the file system provided by the embodiment of the present invention, and the file system only needs the metadata in the disk space when the system is started. The file is read into the memory space, according to the metadata information of the directory nodes and the files under the various levels of the directory stored in the metadata file (ie accessing the entire magnetic The path information required for the disk space is searched. The metadata file in the memory can be used to find the target file or the target directory at one time, which reduces the number of interactions between the memory and the disk space, and greatly improves the access efficiency. DRAWINGS
实施例或现有技术描述中所需要使用的附图作一简单地介绍, 显而易见 地, 下面描述中的附图是本发明的一些实施例, 对于本领域普通技术人员 来讲, 在不付出创造性劳动性的前提下, 还可以根据这些附图获得其他的 附图。 The drawings used in the embodiments or the description of the prior art are briefly described. It is obvious that the drawings in the following description are some embodiments of the present invention, and are not creative to those skilled in the art. Other drawings can also be obtained from these drawings on the premise of labor.
图 1为文件系统 ext3的磁盘分布方式的示意图;  1 is a schematic diagram of a disk distribution manner of a file system ext3;
图 2A为本发明一实施例提供的元数据文件的一种树状结构示意图; 图 2B 为本发明一实施例提供的元数据文件的另一种树状结构示意 图;  2A is a schematic diagram of a tree structure of a metadata file according to an embodiment of the present invention; FIG. 2B is another schematic diagram of a tree structure of a metadata file according to an embodiment of the present invention;
图 3为本发明一实施例提供的文件系统中数据的存储装置的结构示意 图;  3 is a schematic structural diagram of a data storage device in a file system according to an embodiment of the present invention;
图 4为本发明一实施例提供的文件系统中数据的访问装置的结构示意 图。 具体实施方式 为使本发明实施例的目的、 技术方案和优点更加清楚, 下面将结合本 发明实施例中的附图, 对本发明实施例中的技术方案进行清楚、 完整地描 述, 显然, 所描述的实施例是本发明一部分实施例, 而不是全部的实施例。 基于本发明中的实施例, 本领域普通技术人员在没有作出创造性劳动前提 下所获得的所有其他实施例, 都属于本发明保护的范围。  FIG. 4 is a schematic structural diagram of an apparatus for accessing data in a file system according to an embodiment of the present invention. The technical solutions in the embodiments of the present invention are clearly and completely described in the following with reference to the accompanying drawings in the embodiments of the present invention. The embodiments are a part of the embodiments of the invention, and not all of the embodiments. All other embodiments obtained by a person of ordinary skill in the art based on the embodiments of the present invention without creative efforts are within the scope of the present invention.
针对现有技术中存在的文件系统通过命名空间访问磁盘空间中的数 据效率较低的问题, 本发明实施例提供一种能够直接由命名空间映射到磁 盘空间的元数据组织方式, 用以提高文件系统存储和访问数据时的效率。 在本发明实施例中, 文件系统的命名空间在具体实现上通过磁盘空间中的 一个元数据文件实现。 其中, 本发明各实施例采用一种变种 trie的数据结 构来组织管理元数据文件(即元数据文件中各级目录节点构成树状结构), 通过元数据文件可以一次性找到目标文件或目标目录, 大大提高查找效 率。 The present invention provides a metadata organization manner that can be directly mapped from a namespace to a disk space, so as to improve the file, in order to solve the problem that the file system in the prior art has a low efficiency in accessing the data in the disk space through the namespace. The efficiency with which the system stores and accesses data. In the embodiment of the present invention, the namespace of the file system is implemented by a metadata file in the disk space in a specific implementation. Wherein, embodiments of the present invention employ a data link of a variant trie The organization manages the metadata file (that is, the directory nodes at all levels in the metadata file form a tree structure), and the target file or the target directory can be found at one time through the metadata file, thereby greatly improving the search efficiency.
基于上述的元数据文件, 本发明实施例提供一种文件系统中数据的存 储方法。 在该存储方法中, 文件系统通过元数据文件对命名空间中的文件 目录进行管理。 本发明实施例的执行主体是文件系统中数据的存储装置, 该装置包括文件系统和与文件系统对应的磁盘空间; 磁盘空间被划分为第 一存储部分和第二存储部分, 第一存储部分用于存储元数据文件, 元数据 文件存储有访问整个磁盘空间所需的所有路径信息; 第二存储部分用于存 储文件数据。 在文件系统中数据的存储装置启动 (或者说系统启动) 时, 文件系统将元数据文件从磁盘空间中读取到内存中。 后续所创建的各个目 录以及各个目录下的文件都通过内存中的元数据文件进行管理。 本发明实 施例提供存储方法包括: 文件系统在某个目录下建立新目录(即下一级目 录)并存储新建目录的有关信息的存储操作和文件系统在某个目录下创建 并存储文件的存储操作。  Based on the foregoing metadata file, an embodiment of the present invention provides a method for storing data in a file system. In this storage method, the file system manages the file directories in the namespace through metadata files. The execution body of the embodiment of the present invention is a storage device for data in a file system, the device includes a file system and a disk space corresponding to the file system; the disk space is divided into a first storage portion and a second storage portion, and the first storage portion is used For storing metadata files, the metadata file stores all the path information needed to access the entire disk space; the second storage portion is used to store the file data. When the storage device for data in the file system is booted (or the system is booted), the file system reads the metadata file from disk space into memory. Subsequently created directories and files in each directory are managed by metadata files in memory. The storage method provided by the embodiment of the present invention includes: a file system creates a new directory (ie, a next-level directory) in a certain directory, and stores a storage operation of the information about the newly created directory and a file system that creates and stores the file in a certain directory. operating.
首先, 文件系统会创建一个根目录节点, 并将根目录节点的属性信息 存储到内存中的元数据文件中。 然后, 文件系统会以根目录节点为基础, 进行创建和存储新目录节点和 /或文件的操作。  First, the file system creates a root node and stores the attribute information of the root node into a metadata file in memory. The file system then creates and stores new directory nodes and/or files based on the root node.
其中, 如果文件系统在第一目录节点下建立下一级目录节点, 文件系 统将下一级目录节点的目录元数据信息存储到内存中的元数据文件中, 并 在第一目录节点的目录元数据信息中添加指向下一级目录节点的第一路 径信息。 所述下一级目录节点的目录元数据信息包括: 下一级目录节点的 属性信息。  If the file system establishes the next-level directory node under the first directory node, the file system stores the directory metadata information of the next-level directory node into the metadata file in the memory, and the directory element in the first directory node The first path information pointing to the next-level directory node is added to the data information. The directory metadata information of the next-level directory node includes: attribute information of the next-level directory node.
其中, 第一目录节点可以是文件系统的命名空间中已经存在的任一目 录节点,例如可以是根目录节点、可以是根目录节点的第一级子目录节点、 还可以是第一级子目录节点的下一级子目录节点等。 本实施例以在任一目 录节点下创建新目录节点 (即下一级目录节点) 为例。  The first directory node may be any directory node that already exists in the file system namespace, and may be, for example, a root directory node, a first-level sub-directory node that may be a root directory node, or a first-level subdirectory. The next-level subdirectory node of the node, and so on. This embodiment takes a new directory node (i.e., the next-level directory node) under any of the directory nodes as an example.
文件系统预先可以确定所要创建的是目录还是文件。 当确定要在第一 目录节点下创建下一级目录节点时, 文件系统将所要创建的下一级目录节 点的目录元数据信息存储到内存中的元数据文件中, 以实现通过元数据文 件对每个目录节点进行管理。 同时, 文件系统在内存中的元数据文件中存 储第一目录节点到其下一级目录节点之间的路径信息, 即所述的在第一目 录节点的目录元数据信息中存储指向其下一级目录节点的路径信息, 这样 通过第一目录节点就可以找到其下一级目录节点。 其中, 目录节点的属性 信息可以包括: 目录节点的目录名、 类型、 大小和创建时间其中之一或其 任意组合。 其中, 目录节点的大小一般为 4096个字节。 The file system can determine in advance whether the directory or file is to be created. When it is determined that the next-level directory node is to be created under the first directory node, the file system stores the directory metadata information of the next-level directory node to be created into the metadata file in the memory to implement the metadata file. The pieces are managed for each directory node. At the same time, the file system stores the path information between the first directory node and the next-level directory node in the metadata file in the memory, that is, the storage in the directory metadata information of the first directory node points to the next The path information of the level directory node, so that the next directory node can be found through the first directory node. The attribute information of the directory node may include: one of a directory node name, a type, a size, and a creation time, or any combination thereof. The size of the directory node is generally 4096 bytes.
也就是说, 如果文件系统的命名空间中的目录节点存在下一级目录节 点, 则在内存中的元数据文件中所存储的该目录节点的目录元数据信息中 不仅包括该目录节点的属性信息, 还包括该目录节点指向其下一级目录节 点的路径信息。 其中, 元数据文件的这种结构可以看作是一种变种的 trie, 每个目录节点可以对应一个 trie节点, 每个目录节点的目录元数据信息可 以作为相应 trie节点的内容。本实施例的变种 trie与标准 trie的区别在于, 标准 trie的每个节点所存储的是一个字符, 而本实施例的变种 trie的每个 节点所存储的是字符串。 此处的字符串主要是指每个目录节点的属性信息 和指向其下一级目录节点的路径信息等。 其中, 对于没有下一级目录节点 的目录节点, 其对应的字符串主要是指该目录节点的属性信息。  That is, if the directory node in the namespace of the file system has a lower-level directory node, the directory metadata information of the directory node stored in the metadata file in the memory includes not only the attribute information of the directory node. Also includes path information for the directory node to point to its next-level directory node. The structure of the metadata file can be regarded as a variant of trie. Each directory node can correspond to a trie node, and the directory metadata information of each directory node can be used as the content of the corresponding trie node. The variant trie of this embodiment differs from the standard trie in that each node of the standard trie stores one character, and each node of the variant trie of the embodiment stores a character string. The string here mainly refers to the attribute information of each directory node and the path information to the next-level directory node. For the directory node that does not have the next-level directory node, the corresponding string mainly refers to the attribute information of the directory node.
如果文件系统要在第一目录节点下存储文件, 文件系统获取磁盘空间 中空闲的数据块, 将该文件存储到所获取的数据块中, 将文件的文件元数 据信息存储到内存中的元数据文件中, 并在内存中的元数据文件中的第一 目录节点的目录元数据信息中添加指向该文件的第二路径信息。 其中, 该 文件的文件元数据信息包括该文件的属性信息和磁盘空间中存储该文件 的数据块的标号。  If the file system is to store the file under the first directory node, the file system obtains the free data block in the disk space, stores the file in the acquired data block, and stores the file metadata information of the file into the metadata in the memory. In the file, a second path information pointing to the file is added to the directory metadata information of the first directory node in the metadata file in the memory. The file metadata information of the file includes attribute information of the file and a label of a data block in the disk space in which the file is stored.
在本实施例中, 文件系统对应的磁盘空间主要被划分为两大部分, 一 部分用于存放元数据文件, 另一部分用于存放各个文件的数据。 其中, 存 储文件的部分又被划分为多个数据块。 为了使内存中的元数据文件与磁盘 空间中的元数据文件保持同步, 文件系统还会按照预设周期, 将内存中的 文件元数据信息存储到磁盘空间中。 本发明各实施例对预设周期的具体数 值不做限定, 例如该周期可以是 10分钟,还可以以一次开关机为周期(也 就是说在关机之前进行一次同步, 以便于在文件系统中数据的存储装置重 新启动时, 文件系统能够从磁盘空间中读取到最新的元数据文件) 。 当文件系统在某个目录下创建文件时, 就需要将所创建的文件存储到 磁盘空间中。 因此, 文件系统就会查询磁盘空间获取磁盘空间中空闲的且 能够存储该文件的数据块, 然后将该文件存储到获取的数据块中。 然后, 文件系统将该文件的文件元数据信息存储到内存中的元数据文件中, 以通 过元数据文件对文件系统的命名空间中的文件进行管理。 其中, 文件元数 据信息主要包括文件的属性信息和磁盘空间中存储该文件的数据块的标 号。 其中, 文件的属性信息可以包括: 文件的文件名、 类型、 大小和创建 时间等其中之一或其任意组合。 例如, 文件的文件名可以是 picture.jpg、 论文. doc等; 文件的类型可以是普通文件、 符号链接、 套接字等通过文件 的属性信息可以了解到文件的相关信息, 通过磁盘空间中存储该文件的数 据块的标号可以知道文件在磁盘空间中的存储位置, 以便于从磁盘空间中 读取或访问该文件。 In this embodiment, the disk space corresponding to the file system is mainly divided into two parts, one part is used to store the metadata file, and the other part is used to store the data of each file. Wherein, the portion of the storage file is divided into a plurality of data blocks. In order to keep the metadata files in the memory synchronized with the metadata files in the disk space, the file system also stores the file metadata information in the memory into the disk space according to a preset period. The embodiments of the present invention do not limit the specific value of the preset period. For example, the period may be 10 minutes, and the cycle may be cycled once (that is, the synchronization is performed before the shutdown, so as to facilitate the data in the file system. When the storage device is restarted, the file system can read the latest metadata file from disk space). When the file system creates a file in a directory, it needs to store the created file in disk space. Therefore, the file system queries the disk space for a block of data that is free in disk space and can store the file, and then stores the file in the fetched data block. The file system then stores the file metadata information of the file into a metadata file in memory to manage the files in the file system's namespace through the metadata file. The file metadata information mainly includes attribute information of the file and a label of a data block in the disk space in which the file is stored. The attribute information of the file may include: one of the file name, the type, the size, and the creation time of the file, or any combination thereof. For example, the file name of the file can be picture.jpg, thesis.doc, etc.; the file type can be ordinary file, symbolic link, socket, etc. The file information can be learned through the attribute information of the file, and stored in disk space. The label of the data block of the file can be used to know where the file is stored in disk space in order to read or access the file from disk space.
在本实施例中, 元数据文件中每个文件也可以对应一个 trie节点, 每 个文件的文件元数据信息为相应 trie节点的内容。 此处的 trie节点与标准 trie的节点相比, 所存储的是字符串。 此处的字符串主要是指每个文件的 属性信息和磁盘空间中存储文件的数据块的标号等。  In this embodiment, each file in the metadata file may also correspond to a trie node, and the file metadata information of each file is the content of the corresponding trie node. The trie node here stores a string compared to the standard trie node. The string here mainly refers to the attribute information of each file and the label of the data block of the file stored in the disk space.
进一步, 文件系统还需要将该文件直接建立在哪个目录节点下等信息 存储到元数据文件中, 即在文件所直属的目录节点的目录元数据信息中添 加该目录节点指向该文件的第二路径信息, 以便于通过遍历目录节点找到 该文件。  Further, the file system further needs to store the information under the directory node directly in the metadata file, that is, add the directory path to the second path of the file in the directory metadata information of the directory node directly adjacent to the file. Information, so that the file is found by traversing the directory node.
也就是说, 如果某个目录节点下存在文件, 该目录节点的目录元数据 信息中不仅包括该目录节点的属性信息, 还包括该目录节点指向其下文件 的第二路径信息。  That is, if a file exists under a directory node, the directory metadata information of the directory node includes not only the attribute information of the directory node but also the second path information of the directory node to which the directory node points.
进一步, 如果某个目录节点下既存在文件又存在下一级目录节点, 则 该目录节点的目录元数据信息中将包括目录节点的属性信息、 该目录节点 指向其下文件的第二路径信息和指向其下一级目录节点的第一路径信息。  Further, if a directory node has both a file and a next-level directory node, the directory metadata information of the directory node includes attribute information of the directory node, second path information of the directory node to the next file, and The first path information pointing to the next-level directory node.
更进一步, 本实施例的目录节点还可以为空, 即该目录节点下既没有 文件又没有下一级目录节点, 则其目录元数据信息将只包括该目录节点的 属性信息。  Further, the directory node in this embodiment may also be empty, that is, the directory node has neither a file nor a next-level directory node, and the directory metadata information includes only the attribute information of the directory node.
由上述可见, 本实施例的文件系统中数据的存储装置在启动时, 文件 系统将元数据文件从磁盘空间中读取到内存, 在存储文件或新建目录节点 时通过对内存中的元数据文件进行操作, 以使元数据文件中存储有各级目 录节点以及目录节点与其下各文件之间的路径信息, 然后按照预设周期对 磁盘空间中的元数据文件进行同步。 由于本实施例的元数据文件是一种变 种 trie结构, 每个 trie节点可能存储有目录节点的属性信息、 目录节点指 向其下文件或下一级目录节点的路径信息、 文件的属性信息或存储文件的 数据块的标号等信息, 通过元数据文件对文件系统的命名空间进行管理, 将命名空间与一个整体数据结构相对应, 一方面便于文件系统进行数据存 储, 提高了存储效率, 另一方面在查找时能够通过一次读取磁盘空间就找 到目标目录或目标文件的存储位置, 减少了内存与磁盘空间之间的交互次 数, 提高了文件系统访问磁盘空间的效率。 It can be seen from the above that the data storage device in the file system of the embodiment is activated at the time of the file. The system reads the metadata file from the disk space to the memory, and operates the metadata file in the memory when storing the file or creating the new directory node, so that the metadata file stores all the directory nodes and the directory node and the lower part thereof. The path information between the files, and then synchronize the metadata files in the disk space according to a preset period. Since the metadata file of this embodiment is a variant trie structure, each trie node may store attribute information of the directory node, path information of the directory node to the next file or the next-level directory node, attribute information of the file, or storage. The information such as the label of the data block of the file, the namespace of the file system is managed by the metadata file, and the namespace is associated with an overall data structure. On the one hand, the file system is convenient for data storage, thereby improving storage efficiency. When searching, the storage location of the target directory or the target file can be found by reading the disk space at one time, which reduces the number of interactions between the memory and the disk space, and improves the efficiency of the file system to access the disk space.
为进一步说明本发明实施例提供的文件系统中数据的存储方法的流 程, 下面将以存储根目录 /home/picture/ flower.jpg文件为例进行说明。  To further illustrate the flow of the data storage method in the file system provided by the embodiment of the present invention, the following describes the storage root directory /home/picture/flower.jpg file as an example.
在文件系统中数据的存储装置(或称为系统)启动时, 文件系统将元 数据文件从磁盘空间中读取到内存中, 然后在文件的存储或目录的建立过 程中, 对内存中的元数据文件进行操作。  When the storage device (or system) of the data in the file system is started, the file system reads the metadata file from the disk space into the memory, and then, during the storage of the file or the directory establishment process, the element in the memory The data file is operated.
在本实施例中, 假设从磁盘空间读取到内存中的元数据文件中已经存 在根目录。基于此,文件系统在内存中的元数据文件的根目录下建立 home 目录, 并将 home目录的目录元数据信息存储到内存中的元数据文件中。 举例说明, 文件系统将 home目录的目录名 home、 创建时间等存储到内存 中的元数据文件 (或者说存储到变种 trie的数据结构) 中。 接着, 文件系 统在 home目录下建立 picture目录,将 picture目录的目录元数据信息存储 到内存中的元数据文件中, 并在 home目录的目录元数据信息添加指向 picture目录的路径信息。 其中, 该路径信息可以包括: picture目录的目录 名和指向 picture目录的指针, 这样既可以标识出 home目录的下一级目录 是谁, 又可以找到其下一级目录。 再接着, 文件系统在 picture目录下建立 flower.jpg文件,将 flower.jpg文件的文件元数据信息存储到内存中的元数 据文件中, 并在 picture目录的目录元数据信息中添加指向 flower.jpg文件 的路径信息。 其中, 该路径信息可以包括: flower.jpg文件的文件名和指 向 flower.jpg文件的指针,这样既可以标识出 picture目录的下有哪个文件, 又可以找到其下的文件。 In this embodiment, it is assumed that the root directory already exists in the metadata file read from the disk space into the memory. Based on this, the file system creates a home directory under the root directory of the metadata file in memory, and stores the directory metadata information of the home directory into the metadata file in the memory. For example, the file system stores the directory name home, creation time, and the like of the home directory into a metadata file in memory (or a data structure stored in the variant trie). Next, the file system creates a picture directory in the home directory, stores the directory metadata information of the picture directory into the metadata file in the memory, and adds path information to the picture directory in the directory metadata information of the home directory. The path information may include: a directory name of the picture directory and a pointer to the picture directory, so that the next directory of the home directory may be identified, and the next level directory may be found. Then, the file system creates a flower.jpg file in the picture directory, stores the file metadata information of the flower.jpg file into the metadata file in the memory, and adds a pointer to flower.jpg in the catalog metadata information of the picture directory. Path information for the file. The path information may include: a file name of the flower.jpg file and a pointer to the flower.jpg file, so that it can identify which file is in the picture directory. You can also find the files under it.
经过上述操作后,内存中的元数据文件中存储的信息可以表示为图 2A 所示的一种树状结构。 假设, 此时预先设定的周期到达, 则文件系统将图 2 A所示的元数据文件写入磁盘空间的第一存储部分中。  After the above operation, the information stored in the metadata file in the memory can be represented as a tree structure as shown in FIG. 2A. Assuming that the preset period arrives at this time, the file system writes the metadata file shown in Fig. 2A into the first storage portion of the disk space.
进一步, 假设文件系统还要在根目录节点下建立配置(config )文件, 则文件系统将 config文件的文件元数据信息存储到内存中的元数据文件 中,并在根目录节点的目录元数据信息中添加指向 config文件的路径信息。 进一步, 假设文件系统还要在 home目录下建立视频(Video ) 目录, 则文 件系统将 Video目录的目录元数据信息存储到内存中的元数据文件中, 并 在 home目录的目录元数据信息中添加指向 Video目录的路径信息。 更进 一步, 假设文件系统还在 picture目录下建立了今天 ( today ) 目录, 并在 today目录下建立了太阳. bmp ( sun.bmp ) 文件。 经过上述操作后, 内存中 的元数据文件中存储的信息可以表示为图 2B所示的一种树状结构。  Further, assuming that the file system also needs to create a configuration (config) file under the root directory node, the file system stores the file metadata information of the config file into the metadata file in the memory, and the directory metadata information in the root directory node. Add path information to the config file. Further, assuming that the file system also creates a video (Video) directory in the home directory, the file system stores the directory metadata information of the Video directory into the metadata file in the memory, and adds the directory metadata information in the home directory. Path information to the Video directory. Going a step further, suppose the file system also creates the today ( today ) directory in the picture directory and creates the sun . bmp ( sun.bmp ) file in the today directory. After the above operation, the information stored in the metadata file in the memory can be represented as a tree structure as shown in Fig. 2B.
其中, 在图 2A和图 2B中, 圆圈表示非空目录节点 (即该目录节点 下或者存在下一级目录节点或者存在文件或者同时存在文件和下一级目 录节点) 。 三角表示空目录节点 (即该目录节点下既没有文件也没有下一 级目录节点) 。 方框表示文件节点。  In Fig. 2A and Fig. 2B, the circle indicates a non-empty directory node (i.e., there is a subordinate directory node under the directory node or a file exists or a file and a directory node at the same time). A triangle indicates an empty directory node (that is, there is neither a file nor a next-level directory node under the directory node). The box represents the file node.
更进一步, 当预先设定的周期再次到达时, 文件系统将内存中的元数 据文件写入磁盘空间中, 这样磁盘空间中的元数据文件就会与内存中的元 数据文件保持一致。  Further, when the preset period arrives again, the file system writes the metadata file in the memory to the disk space, so that the metadata file in the disk space is consistent with the metadata file in the memory.
在图 2A和图 2B所示的变种 trie与标准 trie相比 ,主要存在以下区别: 标准的 trie每个节点存的是一个字符, 而本实施例的变种 trie每个节点存 放的是字符串, 例如目录名、 文件名、 路径信息等。 不同于标准 trie, 本 实施例的变种 trie的所有节点能记载信息。  Compared with the standard trie, the variant trie shown in FIG. 2A and FIG. 2B mainly has the following differences: the standard trie stores one character per node, and the variant trie of this embodiment stores a string for each node. For example, directory name, file name, path information, and so on. Unlike the standard trie, all nodes of the variant trie of this embodiment can record information.
综上所述, 文件系统的命名空间的路径对应于本实施例的变种 trie结 构即为从根节点开始, 经过一个或多个中间节点, 到达某个叶子节点的一 条路径。 本实施例的变种 trie和文件系统本身目录树状结构一致, 能保留 路径完整语义。 本实施例的变种 trie中非叶子节点只记录目录节点的目录 元数据信息,无需记录目录节点与数据块标号的对应关系,因为在变种 trie 结构下, 目录节点的下一级目录节点不会存储在某个数据块中, 而是直接 通过变种 trie本身的结构来维持目录节点之间的关系。本实施例的变种 trie 中叶子节点记录了普通文件的文件元数据信息和对应的数据块标号, 查询 到叶子节点, 也就得到了存储文件的数据块标号, 相当于得到了文件的内 容。 本实施例的变种 trie的每个叶子节点不仅可以对应文件系统的文件还 可以对应空目录, 可记录空目录的目录元数据信息。 该数据结构设计本身 可以支持建立空目录, 支持读取目录的属性信息, 支持对目录下一级的遍 历等, 和文件系统目录的操作可以——对应, 为文件系统访问磁盘空间打 下了基础。 In summary, the path of the namespace of the file system corresponds to the variant trie structure of the embodiment, that is, a path from the root node to one leaf node through one or more intermediate nodes. The variant trie of this embodiment is consistent with the directory tree structure of the file system itself, and can preserve the path complete semantics. In the variant trie of this embodiment, only the non-leaf node records the directory metadata information of the directory node, and does not need to record the correspondence between the directory node and the data block label, because in the variant trie structure, the next-level directory node of the directory node is not stored. In a data block, but directly The relationship between the directory nodes is maintained by the structure of the variant trie itself. In the variant trie of the embodiment, the leaf node records the file metadata information of the ordinary file and the corresponding data block label, and queries the leaf node, thereby obtaining the data block number of the storage file, which is equivalent to obtaining the content of the file. Each leaf node of the variant trie of this embodiment can not only correspond to the file system file but also corresponding to the empty directory, and can record the directory metadata information of the empty directory. The data structure design itself can support the establishment of an empty directory, support for reading the attribute information of the directory, support the traversal of the next level of the directory, and the operation of the file system directory can be correspondingly, which lays a foundation for the file system to access the disk space.
进一步, 在上述各实施例中, 文件系统可以以线性表、 二叉树或哈希 ( hash )方式, 在内存中的元数据文件中对各级目录节点和 /或各级目录节 点与其下文件节点进行组织和存储管理。  Further, in the foregoing embodiments, the file system may perform a linear table, a binary tree, or a hash in a metadata file in the memory for each directory node and/or each directory node and its lower file node. Organization and storage management.
本发明一实施例提供一种文件系统中数据的访问方法, 该访问方法基 于上述实施例提供的文件系统中数据的存储方法实现。 在本实施例中, 文 件系统中数据的访问装置也包括文件系统和与文件系统对应的磁盘空间。 磁盘空间被划分为第一存储部分和第二存储部分, 第一存储部分用于存储 元数据文件, 元数据文件保存有访问磁盘空间所需的所有路径信息。 如上 述存储方法实施例所描述的, 该元数据文件存储有各级目录节点的目录元 数据信息和磁盘空间中存储的文件的文件元数据信息, 该文件元数据信息 包括文件的属性信息和磁盘空间中存储该文件的数据块的标号, 各级目录 节点的目录元数据信息包括目录节点的属性信息。 如果目录节点存在下一 级目录节点, 该目录元数据信息还包括指向其下一级目录节点的第一路径 信息; 如果目录节点下存在文件, 该目录元数据信息还包括指向其下文件 的第二路径信息。 第二存储部分用于存储文件数据。 在文件系统中数据的 访问装置开机时, 文件系统将元数据文件从磁盘空间中读取到内存, 然后 基于内存中的元数据文件中的路径信息对磁盘空间进行访问。 其中, 本实 施例的访问方法包括: 文件系统访问某个目录节点的属性信息的操作和文 件系统访问磁盘存储空间中存储的某个文件的操作。  An embodiment of the present invention provides a method for accessing data in a file system. The access method is implemented based on a method for storing data in a file system provided by the foregoing embodiment. In this embodiment, the access device for data in the file system also includes a file system and a disk space corresponding to the file system. The disk space is divided into a first storage portion for storing a metadata file, and a second storage portion for storing all path information required to access the disk space. As described in the foregoing storage method embodiment, the metadata file stores directory metadata information of each directory node and file metadata information of a file stored in the disk space, and the file metadata information includes file attribute information and a disk. The label of the data block storing the file in the space, and the directory metadata information of the directory nodes of each level includes the attribute information of the directory node. If the directory node has a lower-level directory node, the directory metadata information further includes first path information corresponding to the next-level directory node; if the file exists under the directory node, the directory metadata information further includes a file pointing to the next file. Second path information. The second storage portion is for storing file data. When the access device of the data in the file system is powered on, the file system reads the metadata file from disk space into memory, and then accesses the disk space based on the path information in the metadata file in the memory. The access method of this embodiment includes: an operation of the file system to access attribute information of a directory node and an operation of the file system to access a file stored in the disk storage space.
较为优选的一种实现方式为: 元数据文件中各级目录节点构成树状结 构。  A preferred implementation is as follows: The directory nodes at each level in the metadata file form a tree structure.
由于本实施例通过元数据文件对所有路径信息进行管理, 无论文件系 统执行哪一种访问操作, 都可以基于内存中的元数据文件。 Since this embodiment manages all path information through a metadata file, regardless of the file system Which access operation is performed can be based on metadata files in memory.
如果文件系统要访问的数据是目录节点(为示区别, 记为目标目录节 点) , 则文件系统从内存中的元数据文件中的根目录节点开始, 根据各级 目录节点的目录元数据信息中指向下一级目录节点的第一路径信息在各 级目录节点的目录元数据信息中进行查找匹配, 直到查找到目标目录节点 或查找失败。  If the data to be accessed by the file system is a directory node (denoted as a target directory node), the file system starts from the root node in the metadata file in the memory, according to the directory metadata information of each directory node. The first path information pointing to the next-level directory node performs lookup matching in the directory metadata information of each directory node until the target directory node is found or the search fails.
如果文件系统在内存中的元数据文件中查找到目标目录节点, 则文件 系统从目标目录节点的目录元数据信息中读取目标目录节点的属性信息, 实现对目标目录节点的读取或访问。 由此可见, 通过元数据文件对所有路 径信息进行整体管理, 使得文件系统在访问目录节点时只需要在内存与磁 盘空间之间交互一次(即在文件系统中数据的访问装置启动时文件系统将 元数据文件从磁盘空间读取到内存中的操作) 即可完成访问, 减少了内存 与磁盘空间之间的交互次数, 提高了访问效率。  If the file system finds the target directory node in the metadata file in the memory, the file system reads the attribute information of the target directory node from the directory metadata information of the target directory node to implement reading or accessing the target directory node. It can be seen that all the path information is managed by the metadata file, so that the file system only needs to interact between the memory and the disk space when accessing the directory node (that is, the file system will be activated when the access device of the data in the file system is started). The metadata file is read from the disk space into the memory), the access is completed, the number of interactions between the memory and the disk space is reduced, and the access efficiency is improved.
进一步, 如果文件系统要访问的数据为一文件(为示区别, 记为目标 文件) , 则文件系统从内存中的元数据文件中的根目录节点开始, 根据各 级目录节点的目录元数据信息中指向下一级目录节点的第一路径信息在 各级目录节点的目录元数据信息中进行查找匹配, 获取该目标文件所在的 最后一级目录节点, 然后根据最后一级目录节点的目录元数据信息中指向 其下文件的第二路径信息在最后一级目录节点下的文件的文件元素数据 信息中进行查找匹配, 直到查找到目标文件或查找失败。  Further, if the data to be accessed by the file system is a file (for the difference, it is recorded as the target file), the file system starts from the root node in the metadata file in the memory, according to the directory metadata information of the directory nodes of each level. The first path information pointing to the next-level directory node is searched and matched in the directory metadata information of each directory node, the last-level directory node where the target file is located, and then the directory metadata of the last-level directory node is obtained. The second path information in the information pointing to the next file is searched and matched in the file element data information of the file under the last level directory node until the target file is found or the search fails.
如果文件系统从内存中的元数据文件中找到目标文件, 文件系统从目 标文件的文件元数据信息中获取磁盘空间中存储目标文件的数据块的标 号, 然后文件系统从所获取的数据块的标号所标识的磁盘空间的数据块中 读取目标文件。 即在获取到目标文件所在数据块的标号后, 文件系统去磁 盘空间中相应数据块中读取目标文件, 将目标文件读取到内存中。  If the file system finds the target file from the metadata file in the memory, the file system obtains the label of the data block of the storage target file in the disk space from the file metadata information of the target file, and then the file system obtains the label of the obtained data block. The target file is read in the data block of the identified disk space. That is, after obtaining the label of the data block where the target file is located, the file system reads the target file in the corresponding data block in the disk space, and reads the target file into the memory.
其中,各级目录节点的属性信息包括: 各级目录节点的目录名、类型、 大小和创建时间其中之一或其任意组合。 文件的属性信息包括: 所述文件 的文件名、 类型、 大小和创建时间其中之一或其任意组合。  The attribute information of the directory nodes at each level includes: one of a directory name, a type, a size, and a creation time of each directory node or any combination thereof. The attribute information of the file includes: one of the file name, type, size, and creation time of the file or any combination thereof.
进一步, 结合文件系统对元数据文件中各级目录节点以及文件节点的 组织管理方式,文件系统可以使用线性表、二叉树或 hash方式在各级目录 节点的目录元数据信息中和在目标文件所在的最后一级级目录节点下的 文件的文件元数据信息中进行查找匹配。 Further, in combination with the file system management mode of the directory nodes and file nodes in the metadata file, the file system can use a linear table, a binary tree or a hash mode in each directory. The directory metadata information of the node is searched and matched in the file metadata information of the file under the last level directory node where the target file is located.
本实施例提供的文件系统中数据的访问方法, 上述实施例提供的文件 系统中数据的存储方法相配合, 通过使用元数据文件这种存储结构, 将文 件系统的命名空间与整个数据结构相对应, 文件系统在文件系统中数据的 访问装置启动时从磁盘空间中读取元数据文件到内存, 基于内存中的元数 据文件使得命名空间的解析直接由路径到数据块, 不再是由路径到索引节 点再到数据块的过程, 变多次查找磁盘空间为一次映射, 减少了文件系统 在内存与磁盘空间之间的交互次数, 提高了查找或访问磁盘空间的效率。  The data access method in the file system provided by the embodiment is matched with the data storage method in the file system provided by the foregoing embodiment, and the file system namespace is matched with the entire data structure by using the storage structure of the metadata file. The file system reads the metadata file from the disk space into the memory when the access device of the data in the file system is started. The metadata file in the memory makes the parsing of the namespace directly from the path to the data block, and is no longer the path to The process of indexing the node to the data block, changing the disk space to search for multiple times, reduces the number of interactions between the file system and the disk space, and improves the efficiency of finding or accessing disk space.
下面以在图 2B所示元数据文件结构中查找 home/picture/flower .jpg文 件为例, 说明本发明实施例提供的文件访问方法的流程。  The following describes the flow of the file access method provided by the embodiment of the present invention by taking the home/picture/flower .jpg file as an example in the metadata file structure shown in FIG. 2B.
在本实施例中, 4叚设文件系统在向下一级查找时使用 hash算法。该文 件访问的流程具体如下:  In this embodiment, the file system uses the hash algorithm when looking up to the next level. The process of accessing the file is as follows:
步骤 1、 文件系统在文件系统中数据的访问装置启动时从磁盘空间中 读取元数据文件到内存中。  Step 1. The file system reads the metadata file from the disk space into the memory when the access device of the data in the file system is started.
步骤 2、文件系统从内存中的元数据文件的根目录节点开始,通过 hash 方式找到根目录节点的下一级目录节点 home目录。  Step 2. The file system starts from the root node of the metadata file in the memory, and finds the home directory of the next-level directory node of the root node by hash.
步骤 3、 文件系统继续通过 hash方式找到 home目录节点的下一级目 录节点, 即 icture目录。  Step 3. The file system continues to find the next-level directory node of the home directory node through the hash method, that is, the icture directory.
步骤 4、 文件系统继续通过 hash方式找到 picture目录节点下的 flower.jpg文件。  Step 4. The file system continues to find the flower.jpg file under the picture directory node by hash.
步骤 5、 文件系统从 flower.jpg文件的文件元数据信息中获取磁盘空 间中存储 flower.jpg文件的数据块标号。  Step 5. The file system obtains the data block number of the flower.jpg file stored in the disk space from the file metadata information of the flower.jpg file.
在上述步骤 2-步骤 5中,文件系统一直在内存中的元数据文件中进行 查找, 没有与磁盘空间发生交互, 并且通过一次查找即可找到目标文件在 磁盘空间中的存储位置。  In steps 2 through 5 above, the file system always looks in the metadata file in memory, does not interact with disk space, and can find the storage location of the target file in disk space by one search.
步骤 6、 文件系统根据获取的数据块标号, 从磁盘空间中相应数据块 中读取 flower.jpg文件。  Step 6. The file system reads the flower.jpg file from the corresponding data block in the disk space according to the obtained data block label.
进一步, 假设文件系统要在图 2B所示元数据文件结构中继续查找 home/picture/today目录, 则该目录访问方法的流程具体如下: 步骤 a、文件系统从内存中的元数据文件的根目录节点开始,通过 hash 方式找到根目录节点的下一级目录节点 home目录。 Further, assuming that the file system continues to look up the home/picture/today directory in the metadata file structure shown in FIG. 2B, the flow of the directory access method is as follows: Step a: The file system starts from the root node of the metadata file in the memory, and finds the home directory of the next-level directory node of the root node by hash.
步骤 b、 文件系统继续通过 hash方式找到 home目录节点的下一级目 录节点 icture目录。  Step b. The file system continues to find the directory of the next level directory of the home directory node by hash.
步骤 c、文件系统继续通过 hash方式找到 picture目录节点的下一级目 录节点 today目录。  Step c. The file system continues to find the next directory directory of the picture directory node by hash.
步骤 d、文件系统从 today目录的目录元数据信息中获取 today目录的 属性信息。  Step d: The file system obtains the attribute information of the today directory from the directory metadata information of the today directory.
其中, 元数据文件是文件系统在文件系统中数据的访问装置启动时从 磁盘空间读取到内存中的, 故在后续访问过程中直接使用内存中的元数据 文件。 在上述步骤 a-步骤 d中, 文件系统也是在内存中的元数据文件进行 查找, 没有与磁盘空间发生交互, 并且一次查找即可找到目标目录节点。  The metadata file is the file system that reads from the disk space into the memory when the access device of the data in the file system is started, so the metadata file in the memory is directly used in the subsequent access process. In the above steps a-step d, the file system is also searched in the metadata file in the memory, there is no interaction with the disk space, and the target directory node can be found in one search.
由上述文件和目录的访问流程可见, 本实施例通过元数据文件对文件 系统的命名空间进行组织管理, 使得文件系统在元数据文件中一次即可找 到目录节点的属性信息或找到文件在磁盘空间中的存储位置, 不需要在内 存与磁盘空间之间反复多次进行交互, 提高了查找效率。  As can be seen from the access process of the foregoing file and directory, the embodiment organizes the namespace of the file system by using the metadata file, so that the file system can find the attribute information of the directory node or find the file in the disk space in the metadata file at a time. In the storage location, there is no need to repeatedly interact between memory and disk space, which improves the efficiency of searching.
综上所述, 本发明实施例提供的文件系统中数据的存储方法与本发明 实施例提供的文件系统中数据的访问方法相互配合, 能够产生以下有益效 果: 1、 对文件系统的命名空间的管理使用元数据文件这样一个整体的内 存数据结构, 避免了在内存与磁盘空间之间进行多次交互, 整体性好, 性 能优, 效率高。 2、 元数据文件这种数据结构简单, 并且和文件系统本身 的目录树状结构一致, 能保留路径完整语义。 3、 通过元数据文件这种数 据结构, 使得命名空间的解析过程由 path到 inode再到 block过程简化为 直接由 path到 block的过程, 变多次查找为一次映射, 可以高效完成文件 或目录的查找。 4、 使用元数据文件对命名空间进行组织, 能够很好并简 单地支持文件系统的目录操作。  In summary, the data storage method in the file system provided by the embodiment of the present invention cooperates with the data access method in the file system provided by the embodiment of the present invention, and can generate the following beneficial effects: 1. The namespace of the file system Managing an overall memory data structure using metadata files avoids multiple interactions between memory and disk space, with good overall performance, excellent performance, and high efficiency. 2. The data structure of the metadata file is simple and consistent with the directory tree structure of the file system itself, and can preserve the complete semantics of the path. 3. Through the data structure of the metadata file, the parsing process of the namespace is simplified from the path to the inode to the block process to the process directly from the path to the block, and the search is changed to the mapping one time, and the file or directory can be efficiently completed. Find. 4. Organize namespaces with metadata files to support directory operations for file systems very well and simply.
图 3为本发明一实施例提供的文件系统中数据的存储装置的结构示意 图。 如图 3所示, 本实施例的装置包括: 文件系统 31和与文件系统 31对 应的磁盘空间 32。  FIG. 3 is a schematic structural diagram of a data storage device in a file system according to an embodiment of the present invention. As shown in FIG. 3, the apparatus of this embodiment includes: a file system 31 and a disk space 32 corresponding to the file system 31.
本实施例的磁盘空间 32被划分为第一存储部分和第二存储部分, 第 一存储部分用于存储元数据文件,所述元数据文件存储有访问磁盘空间 32 所需的所有路径信息, 所述第二存储部分用于存储文件数据。 The disk space 32 of this embodiment is divided into a first storage portion and a second storage portion, A storage portion is used to store metadata files that store all path information needed to access disk space 32, and the second storage portion is used to store file data.
本实施例的文件系统 31包括: 第一初始读取模块 311、 第一存储模块 312、 第二存储模块 313和同步模块 314。  The file system 31 of this embodiment includes: a first initial reading module 311, a first storage module 312, a second storage module 313, and a synchronization module 314.
其中, 第一初始读取模块 311 , 与磁盘空间 32连接, 用于在文件系统 中数据的存储装置启动时, 将元数据文件从磁盘空间 32中读取到内存中。  The first initial reading module 311 is connected to the disk space 32 for reading the metadata file from the disk space 32 into the memory when the storage device of the data in the file system is started.
第一存储模块 312, 与第一初始读取模块 31 1连接, 用于在文件系统 在第一目录节点下建立下一级目录节点时, 将下一级目录节点的目录元数 据信息存储到第一初始读取模块 31 1读取到内存中的元数据文件中, 并在 内存中的元数据文件中的第一目录节点的目录元数据信息中添加指向下 一级目录节点的第一路径信息; 所述下一级目录节点的目录元数据信息包 括: 下一级目录节点的属性信息。 下一级目录节点的属性信息包括: 所述 下一级目录节点的目录名、类型、大小和创建时间其中之一或其任意组合。  The first storage module 312 is connected to the first initial reading module 31 1 and configured to store the directory metadata information of the next-level directory node to the first file node when the file system establishes the next-level directory node under the first directory node. An initial reading module 31 1 reads into the metadata file in the memory, and adds the first path information pointing to the next-level directory node in the directory metadata information of the first directory node in the metadata file in the memory. The directory metadata information of the next-level directory node includes: attribute information of the next-level directory node. The attribute information of the next-level directory node includes: one of the directory name, type, size, and creation time of the next-level directory node or any combination thereof.
第二存储模块 313 , 与第一初始读取模块 31 1和磁盘空间 32连接, 用 于在文件系统在第一目录节点下存储文件时, 获取磁盘空间 32中空闲的 数据块, 将文件存储到所获取的数据块中, 将文件的文件元数据信息存储 到第一初始读取模块 311读取到内存中的元数据文件中, 并在内存中的元 数据文件中的第一目录节点的元数据信息中添加指向文件的第二路径信 息; 所述文件的文件元数据信息包括: 文件的属性信息和存储文件的数据 块的标号。 文件的属性信息包括: 所述文件的文件名、 类型、 大小和创建 时间其中之一或其任意组合。  The second storage module 313 is connected to the first initial reading module 31 1 and the disk space 32, and is configured to acquire the free data block in the disk space 32 when the file system stores the file under the first directory node, and store the file to In the acquired data block, the file metadata information of the file is stored into the metadata file read by the first initial reading module 311 into the memory, and the element of the first directory node in the metadata file in the memory The second path information pointing to the file is added to the data information; the file metadata information of the file includes: attribute information of the file and a label of the data block of the storage file. The attribute information of the file includes: one of the file name, type, size, and creation time of the file or any combination thereof.
同步模块 314, 与磁盘空间 32连接, 用于按照预设周期, 将内存中的 元数据文件写入磁盘空间 32中。 更为具体的, 同步模块 314按照预设周 期将内存中的元数据文件写入磁盘空间的第一存储部分中。  The synchronization module 314 is connected to the disk space 32 and is used to write the metadata file in the memory into the disk space 32 according to a preset period. More specifically, the synchronization module 314 writes the metadata file in memory to the first storage portion of the disk space according to a preset period.
其中, 元数据文件中各级目录节点可以构成一种树状结构, 即整个元 数据文件可以通过树状结构进行管理。 而对于各级目录节点之间以及目录 节点与文件之间可以采用线性表、 二叉树或 hash方式进行组织管理。  Among them, the directory nodes at all levels in the metadata file can form a tree structure, that is, the entire metadata file can be managed through a tree structure. For each level of directory nodes and between directory nodes and files, you can use the linear table, binary tree or hash mode for organization and management.
具体的, 第一存储模块 312可以以线性表、 二叉树或 hash方式, 在内 存中的元数据文件中对第一目录节点的目录元数据信息和下一级目录节 点的目录元数据信息进行组织存储。 第二存储模块 313可以以线性表、二叉树或 hash方式,在内存中的元 数据文件中对第一目录节点的目录元数据信息和文件的文件元数据信息 进行组织存储。 Specifically, the first storage module 312 can organize the directory metadata information of the first directory node and the directory metadata information of the next directory node in a metadata file in the memory in a linear table, a binary tree, or a hash manner. . The second storage module 313 can organize the directory metadata information of the first directory node and the file metadata information of the file in a metadata file in the memory in a linear table, a binary tree, or a hash manner.
本实施例的文件系统中数据的存储装置的各功能模块可用于执行本 发明提供的文件系统中数据的存储方法的流程, 其具体工作原理不再赘 述, 详见方法实施例的描述。  The function modules of the data storage device in the file system of the present embodiment can be used to execute the flow of the data storage method in the file system provided by the present invention. The specific working principle is not described here. For details, refer to the description of the method embodiment.
本实施例的文件系统中数据的存储装置, 通过使用元数据文件存储访 问磁盘空间的所有路径信息, 并在系统启动时将元数据文件从磁盘空间中 读取到内存中, 在新建下一级目录节点或在某一目录节点下存储文件时, 直接将要建立的下一级目录节点或要存储的文件的元数据信息存储到内 存中的元数据文件中, 并在上一级目录节点的元数据信息中添加指向下一 级目录节点或所要存储的文件的路径信息, 使用元数据文件对命名空间进 行组织管理, 使磁盘空间中仅划分出存储元数据文件的空间和存储文件的 数据块即可, 不再像现有技术那样将空间划分的比较散, 提高了文件系统 在磁盘空间中存储数据的效率, 同时为提高文件系统访问磁盘空间中的数 据的效率打下了基础。  The data storage device in the file system of this embodiment stores all the path information of the disk space by using the metadata file, and reads the metadata file from the disk space into the memory when the system starts, and creates a new level. When the directory node or a file is stored under a directory node, the metadata information of the next-level directory node or the file to be stored is directly stored in the metadata file in the memory, and the element of the upper-level directory node is Add the path information to the next-level directory node or the file to be stored in the data information, and organize the management of the namespace by using the metadata file, so that only the space for storing the metadata file and the data block of the storage file are divided in the disk space. However, the spatial division is not scattered as in the prior art, which improves the efficiency of the file system for storing data in the disk space, and lays a foundation for improving the efficiency of the file system to access data in the disk space.
图 4为本发明一实施例提供的文件系统中数据的访问装置的结构示意 图。 如图 4所示, 本实施例的装置包括: 文件系统 41和与文件系统 41对 应的磁盘空间 42。  FIG. 4 is a schematic structural diagram of an apparatus for accessing data in a file system according to an embodiment of the present invention. As shown in FIG. 4, the apparatus of this embodiment includes: a file system 41 and a disk space 42 corresponding to the file system 41.
本实施例的磁盘空间 42被划分为第一存储部分和第二存储部分, 所 述第一存储部分用于存储元数据文件, 所述元数据文件存储有访问磁盘空 间 32所需的所有路径信息; 所述第二存储部分用于存储文件数据。  The disk space 42 of this embodiment is divided into a first storage portion and a second storage portion, the first storage portion is configured to store a metadata file, and the metadata file stores all path information required to access the disk space 32. The second storage portion is for storing file data.
本实施例的文件系统 41包括: 第二初始读取模块 411、 第一访问模块 412和第二访问模块 413。  The file system 41 of this embodiment includes: a second initial reading module 411, a first access module 412, and a second access module 413.
其中, 第二初始读取模块 411 , 与磁盘空间 42连接, 用于在文件系统 中数据的访问装置启动时, 将元数据文件从磁盘空间 42中读取到内存中。  The second initial reading module 411 is connected to the disk space 42 for reading the metadata file from the disk space 42 into the memory when the access device of the data in the file system is started.
第一访问模块 412, 与第二初始读取模块 41 1连接, 用于在文件系统 对目标目录节点进行访问时, 从第二初始读取模块 41 1读取到内存中的元 数据文件中的根目录节点开始, 根据各级目录节点的目录元数据信息中指 向下一级目录节点的第一路径信息在各级目录节点的目录元数据信息中 进行查找匹配, 直到查找到目标目录节点或查找失败, 如果查找到目标目 录节点, 在目标目录节点的目录元数据信息中获取目标目录节点的属性信 自 The first access module 412 is connected to the second initial reading module 41 1 for reading from the second initial reading module 41 1 into the metadata file in the memory when the file system accesses the target directory node. The root directory node starts, according to the directory path metadata information of the directory nodes of each level, the first path information pointing to the next-level directory node is in the directory metadata information of each directory node. Perform a search match until the target directory node is found or the search fails. If the target directory node is found, the attribute information of the target directory node is obtained from the directory metadata information of the target directory node.
其中,各级目录节点的属性信息包括: 各级目录节点的目录名、类型、 大小和创建时间其中之一或其任意组合。  The attribute information of the directory nodes at each level includes: one of a directory name, a type, a size, and a creation time of each directory node or any combination thereof.
第二访问模块 413 , 与第二初始读取模块 41 1和磁盘空间 42连接, 用 于在文件系统对目标文件进行访问时, 从第二初始读取模块 411读取到内 存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元数据 信息中指向下一级目录节点的第一路径信息在各级目录节点的目录元数 据信息中进行查找匹配, 获取目标文件所在的最后一级目录节点, 然后根 据最后一级目录节点的目录元数据信息中指向其下文件的第二路径信息 在最后一级目录节点下的文件的文件元数据信息中进行查找匹配, 直到查 找到目标文件或查找失败, 如果查找述目标文件, 从目标文件的文件元数 据信息中获取磁盘空间 42 中存储目标文件的数据块的标号, 然后从所获 取的数据块的标号所标识的磁盘空间 42的数据块中读取目标文件。  The second access module 413 is connected to the second initial reading module 41 1 and the disk space 42 for reading the metadata file in the memory from the second initial reading module 411 when the file system accesses the target file. Starting at the root directory node, searching and matching in the directory metadata information of each directory node according to the first path information pointing to the next-level directory node in the directory metadata information of each directory node, and obtaining the last of the target file The first-level directory node performs matching matching in the file metadata information of the file under the last-level directory node according to the second path information in the directory metadata information of the last-level directory node, until the target is found. The file or the search fails. If the target file is found, the label of the data block storing the target file in the disk space 42 is obtained from the file metadata information of the target file, and then the disk space 42 identified from the obtained data block is identified. The target file is read in the data block.
其中, 文件的属性信息包括: 文件的文件名、 类型、 大小和创建时间 其中之一或其任意组合。  The attribute information of the file includes: one of the file name, type, size, and creation time of the file or any combination thereof.
较为优选的, 本实施例的元数据文件从整体上采用树状结构进行管 理, 也就是说, 元数据文件中的各级目录节点构成树状结构。  Preferably, the metadata file of the embodiment is managed in a tree structure as a whole, that is, the directory nodes at each level in the metadata file constitute a tree structure.
其中, 如果元数据文件中各级目录节点之间以及目录节点与文件之间 使用线性表、二叉树或 hash方式进行组织管理, 则第一访问模块 412具体 可以以线性表、二叉树或 hash方式在各级目录节点的目录元数据信息中进 行查找匹配。第二访问模块 413具体可以以线性表、二叉树或 hash方式在 各级目录节点的目录元数据信息中以及在目标文件所在的最后一级目录 节点下的文件的文件元数据信息中进行查找匹配。  The first access module 412 may specifically use a linear table, a binary tree, or a hash mode in each of the directory nodes of the metadata file and the directory node and the file to be organized and managed by using a linear table, a binary tree, or a hash mode. Lookup matching is performed in the directory metadata information of the level directory node. The second access module 413 may specifically perform lookup matching in the directory metadata information of the directory nodes of each level and the file metadata information of the files in the last level directory node where the target file is located in a linear table, a binary tree or a hash manner.
本实施例的文件系统中数据的访问装置的各功能模块可用于执行本 发明实施例提供的文件系统中数据的访问方法的流程, 其具体工作原理不 再赘述。  The function modules of the data accessing device in the file system of the present embodiment can be used to execute the flow of the data access method in the file system provided by the embodiment of the present invention, and the specific working principle is not described again.
本实施例的文件系统中数据的访问装置, 与上述实施例提供的文件系 统中数据的存储装置相配合, 文件系统只需在系统启动时将磁盘空间中的 元数据文件读取到内存空间中, 根据元数据文件中存储的各级目录节点和 各级目录下的文件的元数据信息 (即访问整个磁盘空间所需的路径信息) 进行查找, 通过内存中的元数据文件可以一次性找到目标文件或目标目 录, 减少了在内存与磁盘空间之间的交互次数, 大大提高访问效率。 The data access device in the file system of the embodiment cooperates with the data storage device in the file system provided in the above embodiment, and the file system only needs to be in the disk space when the system is booted. The metadata file is read into the memory space, and the metadata information (that is, the path information required to access the entire disk space) is searched according to the directory nodes stored in the metadata file and the files in the directories at all levels, through the memory. The metadata file can find the target file or the target directory at one time, which reduces the number of interactions between the memory and the disk space, and greatly improves the access efficiency.
本领域普通技术人员可以理解: 实现上述方法实施例的全部或部分步 骤可以通过程序指令相关的硬件来完成, 前述的程序可以存储于一计算机 可读取存储介质中, 该程序在执行时, 执行包括上述方法实施例的步骤; 而前述的存储介质包括: ROM、 RAM, 磁碟或者光盘等各种可以存储程 序代码的介质。  A person skilled in the art can understand that all or part of the steps of implementing the above method embodiments may be completed by using hardware related to program instructions, and the foregoing program may be stored in a computer readable storage medium, and the program is executed when executed. The foregoing steps include the steps of the foregoing method embodiments; and the foregoing storage medium includes: a medium that can store program codes, such as a ROM, a RAM, a magnetic disk, or an optical disk.
最后应说明的是: 以上实施例仅用以说明本发明的技术方案, 而非对 其限制; 尽管参照前述实施例对本发明进行了详细的说明, 本领域的普通 技术人员应当理解: 其依然可以对前述各实施例所记载的技术方案进行修 改, 或者对其中部分技术特征进行等同替换; 而这些修改或者替换, 并不 使相应技术方案的本质脱离本发明各实施例技术方案的范围。  It should be noted that the above embodiments are only for explaining the technical solutions of the present invention, and are not intended to be limiting; although the present invention has been described in detail with reference to the foregoing embodiments, it will be understood by those skilled in the art that: The technical solutions described in the foregoing embodiments are modified, or some of the technical features are equivalently replaced; and the modifications or substitutions do not deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

权 利 要 求 书 Claim
1、 一种文件系统中数据的存储方法, 其特征在于, 文件系统对应的 磁盘空间被划分为第一存储部分和第二存储部分, 所述第一存储部分用于 存储元数据文件, 所述元数据文件存储有访问所述磁盘空间所需的所有路 径信息; 所述第二存储部分用于存储文件数据; 所述文件系统在文件系统 中数据的存储装置启动时, 将所述元数据文件从所述磁盘空间读取到内存 中, 所述存储方法包括:  A method for storing data in a file system, wherein a disk space corresponding to a file system is divided into a first storage portion and a second storage portion, and the first storage portion is configured to store a metadata file, The metadata file stores all path information required to access the disk space; the second storage portion is configured to store file data; and the file system converts the metadata file when the data storage device in the file system is started Read from the disk space into the memory, the storage method includes:
如果所述文件系统在第一目录节点下建立下一级目录节点, 所述文件 系统将所述下一级目录节点的目录元数据信息存储到内存中的元数据文 件中, 并在所述内存中的元数据文件中的第一目录节点的目录元数据信息 中添加指向所述下一级目录节点的第一路径信息; 所述下一级目录节点的 目录元数据信息包括: 所述下一级目录节点的属性信息;  If the file system establishes a next-level directory node under the first directory node, the file system stores the directory metadata information of the next-level directory node into a metadata file in the memory, and in the memory The first path information of the next-level directory node is added to the directory metadata information of the first directory node in the metadata file; the directory metadata information of the next-level directory node includes: the next Attribute information of the level directory node;
如果所述文件系统在所述第一目录节点下存储文件, 所述文件系统获 取所述磁盘空间中空闲的数据块, 将所述文件存储到所获取的数据块中, 将所述文件的文件元数据信息存储到所述内存中的元数据文件中, 并在所 述内存中的元数据文件中的第一目录节点的目录元数据信息中添加指向 所述文件的第二路径信息; 所述文件的文件元数据信息包括: 所述文件的 属性信息和存储所述文件的数据块的标号;  If the file system stores a file under the first directory node, the file system acquires a free data block in the disk space, stores the file in the acquired data block, and files the file Metadata information is stored in the metadata file in the memory, and second path information pointing to the file is added to the directory metadata information of the first directory node in the metadata file in the memory; The file metadata information of the file includes: attribute information of the file and a label of a data block storing the file;
所述文件系统按照预设周期, 将所述内存中的元数据文件写入所述磁 盘空间中。  The file system writes the metadata file in the memory into the disk space according to a preset period.
2、 根据权利要求 1所述的文件系统中数据的存储方法, 其特征在于, 所述元数据文件中各级目录节点构成一种树状结构。  2. The method for storing data in a file system according to claim 1, wherein the directory nodes at each level in the metadata file form a tree structure.
3、 根据权利要求 1所述的文件系统中数据的存储方法, 其特征在于, 所述文件系统以线性表、 二叉树或哈希方式, 在所述内存中的元数据文件 中对所述第一目录节点的目录元数据信息、 所述下一级目录节点的目录元 数据信息和所述文件的文件元数据信息进行组织存储。  The method for storing data in a file system according to claim 1, wherein the file system is in the linear table, the binary tree or the hash mode, and the first file is in the metadata file in the memory. The directory metadata information of the directory node, the directory metadata information of the next-level directory node, and the file metadata information of the file are organized and stored.
4、 根据权利要求 1或 2或 3所述的文件系统中数据的存储方法, 其 特征在于, 所述下一级目录节点的属性信息包括: 所述下一级目录节点的 目录名、 类型、 大小和创建时间其中之一或其任意组合;  The method for storing data in the file system according to claim 1 or 2 or 3, wherein the attribute information of the next-level directory node includes: a directory name and a type of the next-level directory node, One or any combination of size and creation time;
所述文件的属性信息包括: 所述文件的文件名、 类型、 大小和创建时 间其中之一或其任意组合。 The attribute information of the file includes: a file name, a type, a size, and a creation time of the file. One of them or any combination thereof.
5、 一种文件系统中数据的访问方法, 其特征在于, 文件系统对应的 磁盘空间被划分为第一存储部分和第二存储部分, 所述第一存储部分用于 存储元数据文件, 所述元数据文件存储有访问所述磁盘空间所需的所有路 径信息; 所述第二存储部分用于存储文件数据; 所述文件系统在文件系统 中数据的访问装置启动时, 将所述元数据文件从所述磁盘空间读取到内存 中, 所述访问方法包括:  A method for accessing data in a file system, wherein a disk space corresponding to a file system is divided into a first storage portion and a second storage portion, and the first storage portion is configured to store a metadata file, The metadata file stores all path information required to access the disk space; the second storage portion is configured to store file data; and the file system activates the metadata file when the data access device of the file system is started Read from the disk space into the memory, the access method includes:
如果所述文件系统要访问的数据为目标目录节点, 所述文件系统从所 述内存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元 数据信息中指向下一级目录节点的第一路径信息在各级目录节点的目录 元数据信息中进行查找匹配, 直到查找到所述目标目录节点或者查找失 败; 如果查找到所述目标目录节点, 所述文件系统在所述目标目录节点的 目录元数据信息中获取所述目标目录节点的属性信息;  If the data to be accessed by the file system is a target directory node, the file system starts from a root node in the metadata file in the memory, and points to a next-level directory according to directory metadata information of each directory node. The first path information of the node is searched and matched in the directory metadata information of the directory nodes of each level until the target directory node is found or the search fails; if the target directory node is found, the file system is at the target Obtaining attribute information of the target directory node in the directory metadata information of the directory node;
如果所述文件系统要访问的数据为目标文件, 所述文件系统从所述内 存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元数据 信息中指向下一级目录节点的第一路径信息在各级目录节点的目录元数 据信息中进行查找匹配, 获取所述目标文件所在的最后一级目录节点, 然 后根据所述最后一级目录节点的目录元数据信息中指向其下文件的第二 路径信息在所述最后一级目录节点下的文件的文件元数据信息中进行查 找匹配,直到查找到所述目标文件或查找失败;如果查找到所述目标文件, 所述文件系统从所述目标文件的文件元数据信息中获取所述磁盘空间中 存储所述目标文件的数据块的标号, 然后从所获取的数据块的标号所标识 的所述磁盘空间的数据块中读取所述目标文件。  If the data to be accessed by the file system is a target file, the file system starts from a root node in the metadata file in the memory, and points to a next-level directory node according to directory metadata information of each directory node. The first path information is searched and matched in the directory metadata information of the directory nodes of each level, and the last level directory node where the target file is located is obtained, and then pointed to according to the directory metadata information of the last level directory node. The second path information of the next file is searched and matched in the file metadata information of the file under the last level directory node until the target file is found or the search fails; if the target file is found, the file The system acquires, from the file metadata information of the target file, a label of a data block in the disk space in which the target file is stored, and then reads from a data block of the disk space identified by a label of the acquired data block. Take the target file.
6、 根据权利要求 5所述的文件系统中数据的访问方法, 其特征在于, 所述元数据文件中各级目录节点构成一种树状结构。  The method for accessing data in a file system according to claim 5, wherein the directory nodes at each level in the metadata file form a tree structure.
7、 根据权利要求 5所述的文件系统中数据的访问方法, 其特征在于, 所述文件系统以线性表、 二叉树或哈希方式在各级目录节点的目录元数据 信息中和在所述最后一级目录节点下的文件的文件元数据信息中进行查 找匹配。  The method for accessing data in a file system according to claim 5, wherein the file system is in a linear table, a binary tree or a hash manner in directory metadata information of each directory node and at the last Find matching in the file metadata information of the file under the primary directory node.
8、 根据权利要求 5或 6或 7所述的文件系统中数据的访问方法, 其 特征在于, 所述各级目录节点的属性信息包括: 所述各级目录节点的目录 名、 类型、 大小和创建时间其中之一或其任意组合; 8. A method of accessing data in a file system according to claim 5 or 6 or 7, The attribute information of the directory nodes of the levels includes: one of a directory name, a type, a size, and a creation time of the directory nodes of the levels; or any combination thereof;
所述文件的属性信息包括: 所述文件的文件名、 类型、 大小和创建时 间其中之一或其任意组合。  The attribute information of the file includes: one of a file name, a type, a size, and a creation time of the file, or any combination thereof.
9、 一种文件系统中数据的存储装置, 其特征在于, 包括: 文件系统 和与所述文件系统对应的磁盘空间;  9. A storage device for data in a file system, comprising: a file system and a disk space corresponding to the file system;
所述磁盘空间被划分为第一存储部分和第二存储部分, 所述第一存储 部分用于存储元数据文件, 所述元数据文件存储有访问所述磁盘空间所需 的所有路径信息, 所述第二存储部分用于存储文件数据;  The disk space is divided into a first storage portion and a second storage portion, where the first storage portion is configured to store a metadata file, where the metadata file stores all path information required to access the disk space, The second storage portion is configured to store file data;
所述文件系统包括:  The file system includes:
第一初始读取模块, 用于在所述文件系统中数据的存储装置启动时, 将所述元数据文件从所述磁盘空间中读取到内存中;  a first initial reading module, configured to read the metadata file from the disk space into a memory when a storage device of data in the file system is started;
第一存储模块, 用于在所述文件系统在第一目录节点下建立下一级目 录节点时, 将所述下一级目录节点的目录元数据信息存储到内存中的元数 据文件中, 并在所述内存中的元数据文件中的第一目录节点的目录元数据 信息中添加指向所述下一级目录节点的第一路径信息; 所述下一级目录节 点的目录元数据信息包括: 所述下一级目录节点的属性信息;  a first storage module, configured to: when the file system establishes a next-level directory node under the first directory node, store the directory metadata information of the next-level directory node into a metadata file in the memory, and Adding, to the directory metadata information of the first directory node in the metadata file in the memory, first path information that points to the next-level directory node; and the directory metadata information of the next-level directory node includes: Attribute information of the next-level directory node;
第二存储模块, 用于在所述文件系统在所述第一目录节点下存储文件 时, 获取所述磁盘空间中空闲的数据块, 将所述文件存储到所获取的数据 块中, 将所述文件的文件元数据信息存储到所述内存中的元数据文件中, 并在所述内存中的元数据文件中的第一目录节点的元数据信息中添加指 向所述文件的第二路径信息; 所述文件的文件元数据信息包括: 所述文件 的属性信息和存储所述文件的数据块的标号;  a second storage module, configured to: when the file system stores a file under the first directory node, acquire a data block that is free in the disk space, and store the file into the acquired data block, where The file metadata information of the file is stored in the metadata file in the memory, and the second path information pointing to the file is added to the metadata information of the first directory node in the metadata file in the memory. The file metadata information of the file includes: attribute information of the file and a label of a data block storing the file;
同步模块, 用于按照预设周期, 将所述内存中的元数据文件写入所述 磁盘空间中。  And a synchronization module, configured to write the metadata file in the memory into the disk space according to a preset period.
10、根据权利要求 9所述的文件系统中数据的存储装置,其特征在于, 所述元数据文件中各级目录节点构成一种树状结构。  The data storage device in the file system according to claim 9, wherein the directory nodes at each level in the metadata file form a tree structure.
1 1、根据权利要求 9所述的文件系统中数据的存储装置,其特征在于, 所述第一存储模块以线性表、 二叉树或哈希方式, 在所述内存中的元数据 文件中对所述第一目录节点的目录元数据信息和所述下一级目录节点的 目录元数据信息进行组织存储; The storage device for data in the file system according to claim 9, wherein the first storage module is in a metadata file in the memory in a linear table, a binary tree or a hash mode. Directory metadata information of the first directory node and the next-level directory node Directory metadata information is organized for storage;
所述第二存储模块以线性表、 二叉树或哈希方式, 在所述内存中的元 数据文件中对所述第一目录节点的目录元数据信息和所述文件的文件元 数据信息进行组织存储。  The second storage module organizes the directory metadata information of the first directory node and the file metadata information of the file in a metadata file in the memory in a linear table, a binary tree or a hash manner. .
12、 根据权利要求 9或 10或 1 1所述的文件系统中数据的存储装置, 其特征在于, 所述下一级目录节点的属性信息包括: 所述下一级目录节点 的目录名、 类型、 大小和创建时间其中之一或其任意组合;  The storage device for data in the file system according to claim 9 or 10 or 11, wherein the attribute information of the next-level directory node comprises: a directory name and a type of the next-level directory node. One of, size and creation time, or any combination thereof;
所述文件的属性信息包括: 所述文件的文件名、 类型、 大小和创建时 间其中之一或其任意组合。  The attribute information of the file includes: one of a file name, a type, a size, and a creation time of the file, or any combination thereof.
13、 一种文件系统中数据的访问装置, 其特征在于, 包括: 文件系统 和与所述文件系统对应的磁盘空间;  13. A device for accessing data in a file system, comprising: a file system and a disk space corresponding to the file system;
所述磁盘空间被划分为第一存储部分和第二存储部分, 所述第一存储 部分用于存储元数据文件, 所述元数据文件存储有访问所述磁盘空间所需 的所有路径信息; 所述第二存储部分用于存储文件数据;  The disk space is divided into a first storage portion and a second storage portion, wherein the first storage portion is configured to store a metadata file, where the metadata file stores all path information required to access the disk space; The second storage portion is configured to store file data;
所述文件系统包括:  The file system includes:
第二初始读取模块, 用于在所述文件系统中数据的访问装置启动时, 将所述元数据文件从所述磁盘空间中读取到内存中;  a second initial reading module, configured to read the metadata file from the disk space into a memory when the access device of the data in the file system is started;
第一访问模块, 用于在所述文件系统对目标目录节点进行访问时, 从 所述内存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录 元数据信息中指向下一级目录节点的第一路径信息在各级目录节点的目 录元数据信息中进行查找匹配, 直到查找到所述目标目录节点或查找失 败, 如果查找到所述目标目录节点, 在所述目标目录节点的目录元数据信 息中获取所述目标目录节点的属性信息;  a first access module, configured to start from a root node in the metadata file in the memory when the file system accesses the target directory node, and point to the next according to the directory metadata information of each directory node The first path information of the level directory node performs lookup matching in the directory metadata information of the directory nodes of each level until the target directory node is found or the search fails, and if the target directory node is found, the target directory node Obtaining attribute information of the target directory node in the directory metadata information;
第二访问模块, 用于在所述文件系统对目标文件进行访问时, 从所述 内存中的元数据文件中的根目录节点开始, 根据各级目录节点的目录元数 据信息中指向下一级目录节点的第一路径信息在各级目录节点的目录元 数据信息中进行查找匹配, 获取所述目标文件所在的最后一级目录节点, 然后根据所述最后一级目录节点的目录元数据信息中指向其下文件的第 二路径信息在所述最后一级目录节点下的文件的文件元数据信息中进行 查找匹配, 直到查找到所述目标文件或查找失败, 如果查找到所述目标文 件, 从所述目标文件的文件元数据信息中获取所述磁盘空间中存储所述目 标文件的数据块的标号, 然后从所获取的数据块的标号所标识的所述磁盘 空间的数据块中读取所述目标文件。 a second access module, configured to: when the file system accesses the target file, start from a root node in the metadata file in the memory, and point to a next level according to directory metadata information of each directory node The first path information of the directory node is searched and matched in the directory metadata information of each directory node, and the last-level directory node where the target file is located is obtained, and then according to the directory metadata information of the last-level directory node. The second path information pointing to the file below is searched and matched in the file metadata information of the file under the last level directory node until the target file is found or the search fails, if the target file is found Obtaining, from the file metadata information of the target file, a label of a data block in the disk space in which the target file is stored, and then in a data block of the disk space identified by a label of the acquired data block Read the target file.
14、 根据权利要求 13 所述的文件系统中数据的访问装置, 其特征在 于, 所述元数据文件中各级目录节点构成一种树状结构。  14. The data access device of the file system according to claim 13, wherein the directory nodes at each level in the metadata file form a tree structure.
15、 根据权利要求 13 所述的文件系统中数据的访问装置, 其特征在 于, 所述第一访问模块具体以线性表、 二叉树或哈希方式在各级目录节点 的目录元数据信息中进行查找匹配;  The device for accessing data in the file system according to claim 13, wherein the first access module searches for directory metadata information of each directory node in a linear table, a binary tree or a hash manner. Match
所述第二访问模块具体以线性表、 二叉树或哈希方式在各级目录节点 的目录元数据信息中和所述最后一级目录节点下的文件的文件元数据信 息中进行查找匹配。  The second access module performs search matching in the directory metadata information of each directory node and the file metadata information of the file under the last-level directory node in a linear table, a binary tree or a hash manner.
16、 根据权利要求 13或 14或 15所述的文件系统中数据的访问装置, 其特征在于, 所述各级目录节点的属性信息包括: 所述各级目录节点的目 录名、 类型、 大小和创建时间其中之一或其任意组合;  The device for accessing data in the file system according to claim 13 or 14 or 15, wherein the attribute information of the directory nodes of the levels includes: a directory name, a type, a size, and One of the creation times or any combination thereof;
所述文件的属性信息包括: 所述文件的文件名、 类型、 大小和创建时 间其中之一或其任意组合。  The attribute information of the file includes: one of a file name, a type, a size, and a creation time of the file, or any combination thereof.
PCT/CN2011/084551 2011-12-23 2011-12-23 File system data storage method and access method and device therefor WO2013091244A1 (en)

Priority Applications (2)

Application Number Priority Date Filing Date Title
CN201180003263.2A CN103282899B (en) 2011-12-23 2011-12-23 The storage method of data, access method and device in file system
PCT/CN2011/084551 WO2013091244A1 (en) 2011-12-23 2011-12-23 File system data storage method and access method and device therefor

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
PCT/CN2011/084551 WO2013091244A1 (en) 2011-12-23 2011-12-23 File system data storage method and access method and device therefor

Publications (1)

Publication Number Publication Date
WO2013091244A1 true WO2013091244A1 (en) 2013-06-27

Family

ID=48667689

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2011/084551 WO2013091244A1 (en) 2011-12-23 2011-12-23 File system data storage method and access method and device therefor

Country Status (2)

Country Link
CN (1) CN103282899B (en)
WO (1) WO2013091244A1 (en)

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461911A (en) * 2014-07-14 2015-03-25 北京君正集成电路股份有限公司 Data storage method and device
CN104881257A (en) * 2015-06-09 2015-09-02 北京世纪铭辰科技有限公司 Real-time massive data storage system and method
CN113467698A (en) * 2020-03-30 2021-10-01 珠海全志科技股份有限公司 Writing method and device based on file system, computer equipment and storage medium
WO2023092942A1 (en) * 2021-11-23 2023-06-01 苏州浪潮智能科技有限公司 Data storage method and apparatus, and electronic device and readable storage medium

Families Citing this family (12)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106951521B (en) * 2017-03-20 2020-09-15 Oppo广东移动通信有限公司 Method, device and system for reading and writing log file
WO2020006771A1 (en) * 2018-07-06 2020-01-09 华为技术有限公司 File system adjustment method and device
CN110555001B (en) * 2019-09-05 2021-05-28 腾讯科技(深圳)有限公司 Data processing method, device, terminal and medium
CN111008195A (en) * 2019-10-31 2020-04-14 苏州浪潮智能科技有限公司 Database free space management method, system, terminal and storage medium
CN113127415B (en) * 2019-12-31 2024-02-27 浙江宇视科技有限公司 Real-time stream file processing method, device, medium and electronic equipment
CN111400101B (en) * 2020-03-18 2021-06-01 北京北亚宸星科技有限公司 Data recovery method and system for deleting JFS2 file system data
CN111427862B (en) * 2020-03-19 2022-11-04 国电南瑞科技股份有限公司 Metadata management method for distributed file system in power grid dispatching control system
CN111913915B (en) * 2020-07-30 2023-10-03 杭州宏杉科技股份有限公司 File hiding method and device
CN113296700A (en) * 2021-04-20 2021-08-24 新华三信息技术有限公司 Storage space management method and device and server
CN115190136B (en) * 2021-04-21 2024-03-01 统信软件技术有限公司 Data storage method, data transmission method and computing equipment
CN113986838B (en) * 2021-12-28 2022-03-11 成都云祺科技有限公司 Mass small file processing method and system based on file system and storage medium
CN114327290B (en) * 2021-12-31 2022-12-02 科东(广州)软件科技有限公司 Structure, formatting method and access method of disk partition

Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067822A (en) * 2006-05-03 2007-11-07 国际商业机器公司 Hierarchical storage management of metadata
CN101719141A (en) * 2009-12-24 2010-06-02 成都市华为赛门铁克科技有限公司 File processing method and system based on directory object
CN101743546A (en) * 2007-08-06 2010-06-16 国际商业机器公司 Hierarchical storage management for a file system providing snapshots
CN102184260A (en) * 2011-06-09 2011-09-14 中国人民解放军国防科学技术大学 Method for accessing mass data in cloud calculation environment

Family Cites Families (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN1786944A (en) * 2004-12-11 2006-06-14 鸿富锦精密工业(深圳)有限公司 System and method for resetting-up tree type file catalogue structure
CN101446984B (en) * 2009-01-09 2011-04-13 成都市华为赛门铁克科技有限公司 Method and device for storing files and method and device for deleting files
US20100287205A1 (en) * 2009-05-06 2010-11-11 Htc Corporation Operating system / electronic device and method for storing or reading a file
US8321484B2 (en) * 2010-02-26 2012-11-27 Microsoft Corporation Minimizing bandwidth in file path-centric protocol message
CN102122306A (en) * 2011-03-28 2011-07-13 中国人民解放军国防科学技术大学 Data processing method and distributed file system applying same

Patent Citations (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101067822A (en) * 2006-05-03 2007-11-07 国际商业机器公司 Hierarchical storage management of metadata
CN101743546A (en) * 2007-08-06 2010-06-16 国际商业机器公司 Hierarchical storage management for a file system providing snapshots
CN101719141A (en) * 2009-12-24 2010-06-02 成都市华为赛门铁克科技有限公司 File processing method and system based on directory object
CN102184260A (en) * 2011-06-09 2011-09-14 中国人民解放军国防科学技术大学 Method for accessing mass data in cloud calculation environment

Cited By (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104461911A (en) * 2014-07-14 2015-03-25 北京君正集成电路股份有限公司 Data storage method and device
CN104881257A (en) * 2015-06-09 2015-09-02 北京世纪铭辰科技有限公司 Real-time massive data storage system and method
CN113467698A (en) * 2020-03-30 2021-10-01 珠海全志科技股份有限公司 Writing method and device based on file system, computer equipment and storage medium
WO2023092942A1 (en) * 2021-11-23 2023-06-01 苏州浪潮智能科技有限公司 Data storage method and apparatus, and electronic device and readable storage medium

Also Published As

Publication number Publication date
CN103282899A (en) 2013-09-04
CN103282899B (en) 2016-06-15

Similar Documents

Publication Publication Date Title
WO2013091244A1 (en) File system data storage method and access method and device therefor
CN106663056B (en) Metadata index search in a file system
US8849759B2 (en) Unified local storage supporting file and cloud object access
US9317511B2 (en) System and method for managing filesystem objects
US9043372B2 (en) Metadata subsystem for a distributed object store in a network storage system
US10467188B2 (en) In-line policy management with multi-level object handle
EP3103025B1 (en) Content based organization of file systems
US9565254B2 (en) Object location service for network-based content repository
US20150302111A1 (en) Method and Apparatus for Constructing File System in Key-Value Storage System, and Electronic Device
Seltzer et al. Hierarchical File Systems Are Dead.
US8180813B1 (en) Content repository implemented in a network storage server system
US20150347553A1 (en) Object Storage System with Local Transaction Logs, a Distributed Namespace, and Optimized Support for User Directories
US8661054B2 (en) File management method and system
US20110137966A1 (en) Methods and systems for providing a unified namespace for multiple network protocols
WO2014101000A1 (en) Metadata management method and system
CN111045857B (en) Method for data backup and recovery, electronic device and computer readable storage medium
WO2012149884A1 (en) File system, and method and device for retrieving, writing, modifying or deleting file
CN106484820B (en) Renaming method, access method and device
US9020994B1 (en) Client-based migrating of data from content-addressed storage to file-based storage
US10229127B1 (en) Method and system for locality based cache flushing for file system namespace in a deduplicating storage system
KR20120106544A (en) Method for accessing files of a file system according to metadata and device implementing the method
US11194763B1 (en) Scalable augmented enumeration and metadata operations for large filesystems
Shang et al. Ndnfs: An ndn-friendly file system
WO2023179787A1 (en) Metadata management method and apparatus for distributed file system
van Staereling et al. Efficient, modular metadata management with loris

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 11877653

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 11877653

Country of ref document: EP

Kind code of ref document: A1