Metadata management method, device and equipment of file system

CN114490514BActive Publication Date: 2026-09-22TSINGHUA UNIVERSITY
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202210092660.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-26
Publication Date
2026-09-22
Estimated Expiration
2042-01-26

AI Technical Summary

Technical Problem

[0005]本公开提供了一种文件系统的元数据管理方法、装置、设备,以解决现有技术中在进行路径解析时,需要依次发送网络请求来访问待读取数据的存储目录中的每一个目录,导致了路径解析延迟高,严重影响文件系统性能的问题

Benefits of technology

[0038]本公开提供的文件系统的元数据管理方法、装置、设备,包括:获取待读取数据的存储目录,并根据存储目录确定与存储目录中除了根目录以外的每一级目录所对应的键;存储目录中包括多级目录;根据键获取与每一级目录对应的目录元数据;其中,预先存储有键与目录元数据之间的对应关系;根据目录元数据确定是否具有每一级目录对应的访问权限,若有,则反馈与待读取数据对应的元数据,元数据用于读取待读取数据。本方案提供的元数据管理方法、装置、设备中,可以根据构建的待读取数据的存储目录中除了根目录以外的每一级目录所对应的键,并行访问存储目录中的每一个目录,可以使得路径解析的延迟降低,进而提高文件系统性能。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114490514B_ABST
    Figure CN114490514B_ABST
Patent Text Reader

Abstract

The metadata management method, device and equipment of a file system provided by the present disclosure relate to the technical field of metadata management, and include the following steps: obtaining a storage directory of to-be-read data, and determining a key corresponding to each directory except a root directory in the storage directory according to the storage directory; the storage directory includes multiple directories; obtaining directory metadata corresponding to each directory according to the key; a correspondence between the key and the directory metadata is stored in advance; determining whether there is access permission corresponding to each directory according to the directory metadata, and if yes, feeding back metadata corresponding to the to-be-read data, which is used for reading the to-be-read data. According to the key corresponding to each directory except the root directory in the storage directory of the to-be-read data, each directory in the storage directory can be accessed in parallel, so that the delay of path analysis is reduced, and the performance of the file system is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This disclosure relates to metadata management technology, and more particularly to a method, apparatus, and device for managing metadata in a file system. Background Technology

[0002] Currently, due to the directory tree semantics of the file system, the file system needs to perform path resolution on the storage directory where the data to be read is stored in order to locate the file and check permissions. The path resolution process starts from the root directory and queries the next level directory one by one until the target file is found, while simultaneously checking whether the user has permission permissions for each level of directory.

[0003] In existing technologies, many approaches employ distributed metadata management mechanisms to improve the scalability of file system metadata. For example, file and directory metadata is organized into key-value pairs and stored on multiple metadata servers, thereby supporting a massive number of files.

[0004] However, current systems need to send network requests sequentially to access each directory in the storage directory of the data to be read when performing path resolution, resulting in high path resolution latency and severely impacting file system performance. Summary of the Invention

[0005] This disclosure provides a method, apparatus, and device for managing metadata of a file system, in order to solve the problem in the prior art that when performing path resolution, it is necessary to send network requests sequentially to access each directory in the storage directory of the data to be read, which leads to high path resolution latency and seriously affects the performance of the file system.

[0006] According to a first aspect of this disclosure, a method for managing metadata in a file system is provided, comprising:

[0007] Obtain the storage directory of the data to be read, and determine the key corresponding to each level of the storage directory except the root directory; the storage directory includes multiple levels of directories;

[0008] The directory metadata corresponding to each level of directory is obtained based on the key; wherein, the correspondence between the key and the directory metadata is stored in advance;

[0009] Based on the directory metadata, determine whether you have access permissions for each level of directory. If you do, return the metadata corresponding to the data to be read. The metadata is used to read the data to be read.

[0010] In one possible implementation, determining the key corresponding to each level of directory in the storage directory, excluding the root directory, includes:

[0011] For each directory level in the storage directory other than the root directory, obtain the identifier of the first parent directory of that directory;

[0012] The key of the directory is obtained by combining the identifier of the first parent directory with the name of the directory; wherein the identifier of the root directory is preset.

[0013] In one possible implementation, the method further includes: generating a predicted identifier for the directory based on the identifier of the first parent directory, the name of the directory, and a preset version number of the directory;

[0014] After obtaining the directory metadata corresponding to each level of directory based on the key, the method further includes:

[0015] Obtain the true identifier of the directory from the directory metadata;

[0016] If the actual identifier differs from the predicted identifier, then determining the key corresponding to each level of directory in the storage directory (excluding the root directory) based on the storage directory includes:

[0017] Using the actual identifier of the directory, generate the keys corresponding to the subdirectories of the directory.

[0018] One possible implementation also includes:

[0019] Retrieve the creation request used to create the new directory;

[0020] In response to the creation request, the first identifier of the new directory is generated based on the identifier of the first parent directory of the new directory, the name of the new directory, and the preset version number of the new directory;

[0021] The target identifier of the new directory is determined based on the first identifier and the identifier of the existing directory.

[0022] In one possible implementation, determining the target identifier of the new directory based on the first identifier and the identifier of the existing directory includes:

[0023] Compare whether the first identifier is the same as the identifier of any of the existing directories;

[0024] If they are not the same, then the first identifier is determined to be the target identifier of the new directory.

[0025] In one possible implementation, if the first identifier is the same as the identifier of any of the existing directories, then:

[0026] Update the default version number of the new directory;

[0027] The first identifier of the new directory is generated again based on the updated preset version number, the identifier of the first parent directory of the new directory, and the name of the new directory;

[0028] The step of comparing whether the first identifier is the same as the identifier of any of the existing directories is performed based on the first identifier of the newly generated directory.

[0029] According to a second aspect of this disclosure, a metadata management apparatus for a file system is provided, comprising:

[0030] A key determination unit is used to obtain the storage directory of the data to be read, and determine the key corresponding to each level of the storage directory except the root directory; the storage directory includes multiple levels of directories;

[0031] The directory metadata acquisition unit is used to acquire the directory metadata corresponding to each level of directory according to the key; wherein, the correspondence between the key and the directory metadata is stored in advance;

[0032] The permission determination unit is used to determine whether it has the access permissions corresponding to each level of directory based on the directory metadata. If it does, it feeds back the metadata corresponding to the data to be read, and the metadata is used to read the data to be read.

[0033] According to a third aspect of this disclosure, an electronic device is provided, including a memory and a processor; wherein,

[0034] The memory is used to store computer programs;

[0035] The processor is configured to read a computer program stored in the memory and execute a metadata management method for the file system as described in the first aspect, based on the computer program in the memory.

[0036] According to a fourth aspect of this disclosure, a computer-readable storage medium is provided, wherein computer-executable instructions are stored therein, and when a processor executes the computer-executable instructions, a metadata management method for a file system as described in the first aspect is implemented.

[0037] According to a fifth aspect of this disclosure, a computer program product is provided, including a computer program that, when executed by a processor, implements a metadata management method for a file system as described in the first aspect.

[0038] The metadata management method, apparatus, and device for a file system provided in this disclosure include: obtaining the storage directory of the data to be read, and determining the key corresponding to each level of directory in the storage directory except for the root directory; the storage directory includes multiple levels of directories; obtaining the directory metadata corresponding to each level of directory according to the key; wherein, the correspondence between keys and directory metadata is pre-stored; determining whether there is access permission for each level of directory according to the directory metadata, and if so, feeding back the metadata corresponding to the data to be read, which is used to read the data to be read. In the metadata management method, apparatus, and device provided in this solution, each directory in the storage directory can be accessed in parallel according to the key corresponding to each level of directory in the constructed storage directory of the data to be read except for the root directory, which can reduce the latency of path resolution and thus improve the performance of the file system. Attached Figure Description

[0039] Figure 1 This is a flowchart illustrating a metadata management method for a file system, as shown in an exemplary embodiment of this disclosure.

[0040] Figure 2 A flowchart illustrating a metadata management method for a file system, as shown in another exemplary embodiment of this disclosure;

[0041] Figure 3 This is a schematic diagram illustrating the process of determining the directory identifier of a new directory, as shown in an exemplary embodiment of this disclosure.

[0042] Figure 4 A schematic diagram illustrating the representation of keys for different metadata in an exemplary embodiment of this disclosure;

[0043] Figure 5 A schematic diagram illustrating a metadata management method for a file system, as shown in an exemplary embodiment of this disclosure;

[0044] Figure 6 A structural diagram of a file system metadata management apparatus illustrated in an exemplary embodiment of this disclosure;

[0045] Figure 7 This is a structural diagram of an electronic device illustrated in an exemplary embodiment of the present disclosure. Detailed Implementation

[0046] A Distributed File System (DFS) connects multiple physical nodes via a high-speed network, enabling unified management of multi-node resources and providing users with a file system access interface and a unified file system namespace. DFS is generally designed based on a client / server model. The client provides a standard file system access interface for applications, while the server stores all data and metadata within the file system. DFS typically employs a data and metadata separation architecture, with file data stored on multiple data servers and file metadata stored on one or more metadata servers. DFS offers advantages such as cost savings, ease of management, good scalability, high reliability, and high availability, and is now widely used. With the advent of the big data era, the global data volume has exploded. Rapidly expanding modern data centers often contain massive amounts of files, easily exceeding the capacity of a single instance of current distributed file systems such as GFS, HDFS, QFS, Panasas, and LocoFS. Since modern data centers typically contain hundreds or even trillions of files, metadata management services become a bottleneck for scalability in large distributed file systems. The scalability and efficiency of metadata access in distributed systems are the most critical issues facing distributed file systems. Currently, due to the directory tree semantics of file systems, the file system needs to perform path resolution on the storage directory of the data to be read in order to locate the file and check permissions. The path resolution process starts from the root directory and queries the next level directory one by one until the target file is found, while simultaneously checking whether the user has access permissions at each level of the directory. In existing technologies, in order to improve the scalability of file system metadata, many practices adopt distributed metadata management mechanisms. For example, the metadata of files and directories is organized into key-value pairs and stored on multiple metadata servers, thereby supporting a massive number of files.

[0047] However, current systems need to send network requests sequentially to access each directory in the storage directory of the data to be read when performing path resolution, resulting in high path resolution latency and severely impacting file system performance.

[0048] To address the aforementioned technical issues, the solution provided in this disclosure allows parallel access to each directory in the storage directory, excluding the root directory, based on the keys corresponding to each level of the storage directory containing the data to be read. This reduces path resolution latency and improves file system performance.

[0049] Figure 1 This is a flowchart illustrating a metadata management method for a file system, as shown in an exemplary embodiment of this disclosure.

[0050] like Figure 1 As shown, the file system metadata management method provided in this embodiment includes:

[0051] Step 101: Obtain the storage directory of the data to be read, and determine the key corresponding to each level of the storage directory except the root directory; the storage directory includes multiple levels of directories.

[0052] The method provided in this disclosure can be executed by an electronic device with computing capabilities, such as a computer. This electronic device can obtain the storage directory of the data to be read and determine the keys corresponding to each level of the storage directory, excluding the root directory.

[0053] Specifically, the storage directory includes multiple levels of directories. For example, it may include a root directory, a file directory, and intermediate directories other than the root directory and the file directory.

[0054] Specifically, the directory structure of a file system can be organized into a single-rooted inverted tree structure, starting from the root directory and represented by / . File names are case-sensitive (case sensitivity also depends on the specific file system format), files starting with a dot (.) are hidden files, and paths are separated by / (in Windows, they are separated by \).

[0055] For example, if the storage directory of the data to be read is / A / B / File, then the leading / represents the root directory; File is the file directory; and A and B are intermediate directories.

[0056] File systems can employ a design architecture that separates data from metadata. File data is stored in databases on multiple data servers, while file metadata is stored in metadata databases on one or more metadata servers. Specifically, the metadata database can be a key-value database. A key-value database stores data in key-value pairs, where each key corresponds to a unique value. File metadata includes directory metadata and directory entry metadata; directory metadata includes file inode metadata and directory inode metadata. Specifically, the metadata corresponding to a file directory is file inode metadata; the metadata corresponding to an intermediate directory is directory inode metadata.

[0057] Specifically, the file inode metadata can include file permission information: owner identifier (i.e., directory identifier), group identifier and access permissions (e.g., read-only, read-write, executable, etc.); file timestamp information: creation time, last access time and attribute modification time; file data information: file size and file-to-data-block mapping.

[0058] The metadata of a directory index node can include the directory's identifier; the directory's permission information: the owner's identifier (i.e., the directory's identifier), group identifier, and access permissions (e.g., read-only, read-write, executable, etc.); and the directory's timestamp information: creation time, last access time, and attribute modification time.

[0059] The directory entry metadata can record the names of all direct subdirectories and files under this directory, as well as the mapping between the subdirectory names and the subdirectory identifiers.

[0060] Specifically, based on the preset root directory identifier, as well as the names of each directory and the preset version number of each directory, an encrypted hash function can be used to determine the identifiers of each directory in the storage directory other than the root directory, and then determine the keys of each directory in the storage directory other than the root directory.

[0061] For example, if the storage directory of the data to be read is / A / B / File, then the first parent directory of directory B is A. If the identifier of A is 1, then the key of directory B can be represented as 1:B.

[0062] Step 102: Obtain the directory metadata corresponding to each level of directory based on the key; wherein, the correspondence between the key and the directory metadata is stored in advance.

[0063] Specifically, the key-value database pre-stores the mapping between keys and directory metadata. You can query the key-value database to retrieve the directory metadata corresponding to each level of directory.

[0064] Specifically, directory metadata can include file inode metadata and directory inode metadata. Among them, the metadata corresponding to the file directory is file inode metadata; the metadata corresponding to the intermediate directory is directory inode metadata.

[0065] Step 103: Determine whether you have access permissions for each directory level based on the directory metadata. If you do, return the metadata corresponding to the data to be read. The metadata is used to read the data to be read.

[0066] Specifically, the access permissions for each directory level can be determined based on the access permissions included in the metadata of each directory corresponding to the storage directory.

[0067] If so, it indicates that the user has permission to access the data to be read, and the system will provide the corresponding file inode metadata. The file data information included in the file inode metadata is used to read the data to be read from the database.

[0068] If not, it means that the user does not have permission to access the data to be read.

[0069] Specifically, the file's data information includes the file size and the file-to-data-block mapping. The file system can access the database and retrieve the data to be read based on the file's data information in the file inode metadata corresponding to the data to be read; then, it sends the data to the user terminal.

[0070] The file system metadata management method disclosed herein includes: obtaining the storage directory of the data to be read, and determining the key corresponding to each level of directory in the storage directory except for the root directory; the storage directory includes multiple levels of directories; obtaining the directory metadata corresponding to each level of directory according to the key; wherein, the correspondence between keys and directory metadata is pre-stored; determining whether there is access permission for each level of directory according to the directory metadata, and if so, returning the metadata corresponding to the data to be read, which is used to read the data to be read. The method used in this disclosure can access each directory in the storage directory in parallel according to the key corresponding to each level of directory in the constructed storage directory of the data to be read except for the root directory, which can reduce the latency of path resolution and thus improve the file system performance.

[0071] Figure 2 This is a flowchart illustrating a metadata management method for a file system, as shown in another exemplary embodiment of this disclosure.

[0072] like Figure 2 As shown, the file system metadata management method provided in this embodiment includes:

[0073] Step 201: Obtain the creation request for creating a new directory; respond to the creation request and generate the first identifier of the new directory based on the identifier of the first parent directory of the new directory, the name of the new directory, and the preset version number of the new directory.

[0074] Specifically, the electronic device can receive a creation request for creating a new directory and respond to that creation request.

[0075] The default version number of the new directory can be set to, for example, 1.

[0076] For example, a new directory A, i.e., / A, can be created under the root directory. The first parent directory of the new directory A is the root directory, and the root directory's identifier can be preset to 0. Based on the root directory's identifier 0, the name of the new directory A, and the preset version number of the new directory 1, a cryptographic hash function can be used to generate the first identifier of the new directory A.

[0077] A cryptographic hash function is a one-way mathematical algorithm used to map data of any size to a fixed-size bit string. Cryptographic hash functions are widely used in information security practices, such as digital signatures, message authentication codes, and other forms of authentication.

[0078] Step 202: Determine the target identifier of the new directory based on the first identifier and the identifier of the existing directory.

[0079] Specifically, you can query the identifier of an existing directory in the directory item metadata of the key-value database.

[0080] A first identifier that is different from the identifier of an existing directory can be found by calculation, which is determined as the target identifier of the new directory and stored in a key-value database.

[0081] In one possible implementation, the first identifier is compared to the identifier of any existing directory;

[0082] If they are different, the first identifier is determined to be the target identifier of the new directory.

[0083] The identifier of any existing directory can be obtained from the directory entry metadata in the key-value database.

[0084] If the first identifier is the same as the identifier of any existing directory, then:

[0085] Update the default version number of the new directory;

[0086] For example, you can add 1 to the default version number of the current new directory.

[0087] The first identifier of the new directory is generated again based on the updated preset version number, the identifier of the first parent directory of the new directory, and the name of the new directory;

[0088] Specifically, a cryptographic hash function can be used to regenerate the first identifier of the new directory.

[0089] Perform a step to compare the first identifier of the newly generated directory with the identifier of any existing directory.

[0090] like Figure 3 The diagram shows the process of generating directory identifiers for a newly created directory.

[0091] Step 203: Obtain the storage directory of the data to be read; the storage directory includes multiple levels of directories.

[0092] Specifically, the storage directory includes multiple levels of directories. For example, it may include a root directory, a file directory, and intermediate directories other than the root directory and the file directory.

[0093] For example, if the storage directory of the data to be read is / A / B / File, then the leading / represents the root directory; File is the file directory; and A and B are intermediate directories.

[0094] Step 204: For each level of directory in the storage directory other than the root directory, obtain the identifier of the first parent directory of that directory.

[0095] Specifically, the identifiers of each directory can be obtained based on the storage directory of the data to be read.

[0096] For example, if the storage directory of the data to be read is / A / B / File, then the first parent directory of directory B is A. If the identifier of A is 1, then the identifier representing the first parent directory of directory B is 1.

[0097] Step 205: Combine the identifier of the first parent directory with the name of the directory to obtain the directory key; where the identifier of the root directory is preset.

[0098] The identifier can be preset, for example, it can be set to 0.

[0099] For example, if the storage directory of the data to be read is / A / B / File, then the first parent directory of directory B is A. If the identifier of A is 1, then the identifier representing the first parent directory of directory B is 1. Therefore, the key of directory B can be represented as 1: B.

[0100] like Figure 4 The image shows the representation of keys for the three types of metadata included in a key-value database.

[0101] Step 206: Obtain the directory metadata corresponding to each level of directory based on the key; wherein, the correspondence between the key and the directory metadata is stored in advance.

[0102] Specifically, the key-value database pre-stores the mapping between keys and directory metadata. You can query the key-value database to retrieve the directory metadata corresponding to each level of directory.

[0103] Specifically, directory metadata can include file inode metadata and directory inode metadata. Among them, the metadata corresponding to the file directory is file inode metadata; the metadata corresponding to the intermediate directory is directory inode metadata.

[0104] In one possible implementation, the method further includes: generating a predicted identifier for the directory based on the identifier of the first parent directory, the name of the directory, and the preset version number of the directory;

[0105] Specifically, the root directory identifier can be preset, for example, to 0. The preset version number of the directory can also be preset to 0. For example, if the storage directory of the data to be read is / A / B / File, then the predicted identifier of directory A can be obtained using an encrypted hash function based on the root directory identifier 0, the directory name A, and the preset version number 0; similarly, the predicted identifiers of other directories at all levels in the storage directory can be obtained.

[0106] Specifically, in the method provided in this embodiment, the predicted identifiers of each level of the storage directory, excluding the root directory, can be obtained according to the above method.

[0107] Next, using the predicted identifiers of each level of directory, keys for each level of directory are generated; then, using the obtained keys, the key-value database is queried to obtain the metadata of each directory corresponding to each level of directory.

[0108] Obtain the true identifier of the directory from the directory metadata;

[0109] Specifically, the directory identifier included in the directory metadata can be called the directory's true identifier, and the directory's true identifier can be obtained from the directory metadata.

[0110] If the actual identifier differs from the predicted identifier, then the actual identifier of the directory is used to generate the keys corresponding to the subdirectories of the directory.

[0111] Specifically, the actual identifier and predicted identifier of each level of directory are compared. If they are different, the actual identifier of the directory is used to generate the key corresponding to the subdirectories of that directory. The regenerated key can then be used to continue querying the key-value database until the actual identifier and predicted identifier of each level of directory are the same.

[0112] By calculating predicted identifiers, the keys of each directory can be obtained, enabling parallel access to each directory in the storage directory. This reduces path resolution latency and improves file system performance.

[0113] Step 207: Determine whether you have access permissions for each directory level based on the directory metadata. If you do, return the metadata corresponding to the data to be read. The metadata is used to read the data to be read.

[0114] Specifically, the principle and implementation of step 207 are similar to those of step 103, and will not be repeated here.

[0115] Figure 5 This is a schematic diagram illustrating a metadata management method for a file system, as shown in an exemplary embodiment of this disclosure.

[0116] like Figure 5As shown, if the storage directory of the data to be read is / A / B / File, the root directory identifier can be preset to 0; the preset version number of the directory can be preset to 0. Then the subdirectories of the root directory are A / B / File. A cryptographic hash function can be used to obtain the predicted identifiers of each intermediate directory within this subdirectory. Assuming the predicted identifier of directory A is 1 and the predicted identifier of directory B is 2, then the key of directory A can be represented as 0: A; the key of directory B can be represented as 1: B; and the key of directory File can be represented as 2: File. Based on the key, the key-value database is queried to obtain the metadata corresponding to each directory, and the real identifier and permission information are obtained from each metadata. The real identifier and predicted identifier of each directory are compared. If they are the same, the permission information of each directory is checked to determine whether the device has the corresponding access permissions for each level of directory. If so, the metadata corresponding to the data to be read is returned, and the metadata is used to read the data to be read. If any level of directory does not have access permissions, it means that the electronic device does not have permission to access the data to be read.

[0117] like Figure 5 As shown, if the actual identifier of directory A differs from the predicted identifier, then based on the actual identifier of directory A, a cryptographic hash function is used to generate predicted identifiers for each directory in subdirectory B / File. Next, based on the predicted identifiers of each directory in subdirectory B / File, the key for each directory in subdirectory B / File is determined. The regenerated keys can be used to continue querying the key-value database until the actual identifiers and predicted identifiers of all queried directories at each level are the same. Then, the permission information of each directory is checked to determine if the device has the corresponding access permissions for each level of directory. If so, metadata corresponding to the data to be read is returned, and this metadata is used to read the data. If any level of directory lacks access permissions, it means that the electronic device does not have permission to access the data to be read.

[0118] Figure 6 This is a structural diagram of a metadata management device for a file system, illustrating an exemplary embodiment of the present disclosure.

[0119] like Figure 6 As shown, the metadata management device 600 for the file system provided in this disclosure includes:

[0120] The key determination unit 610 is used to obtain the storage directory of the data to be read, and determine the key corresponding to each level of directory in the storage directory except for the root directory; the storage directory includes multiple levels of directories;

[0121] The directory metadata acquisition unit 620 is used to acquire the directory metadata corresponding to each level of directory based on the key; wherein, the correspondence between the key and the directory metadata is pre-stored.

[0122] The permission determination unit 630 is used to determine whether it has the corresponding access permissions for each level of directory based on the directory metadata. If it does, it will return the metadata corresponding to the data to be read. The metadata is used to read the data to be read.

[0123] The key determination unit 610 is specifically used to obtain the identifier of the first parent directory of each directory except the root directory in the storage directory.

[0124] Combine the identifier of the first parent directory with the name of the directory to obtain the directory key; the identifier of the root directory is preset.

[0125] The key determination unit 610 is also used to generate a predicted identifier for the directory based on the identifier of the first parent directory, the name of the directory, and the preset version number of the directory.

[0126] The key determination unit 610 is also used to obtain the true identifier of the directory from the directory metadata;

[0127] The key determination unit 610 is also used to generate the key corresponding to the subdirectories of the directory using the actual identifier of the directory if the actual identifier is different from the predicted identifier.

[0128] The metadata management device 600 for the file system provided in this disclosure also includes:

[0129] The identification unit 640 is used to obtain the creation request for creating a new directory;

[0130] Respond to the creation request and generate the first identifier of the new directory based on the identifier of the first parent directory, the name of the new directory, and the preset version number of the new directory;

[0131] Determine the target identifier of the new directory based on the first identifier and the identifier of the existing directory.

[0132] The identifier determination unit 640 is specifically used to compare whether the first identifier is the same as the identifier of any existing directory;

[0133] If they are different, the first identifier is determined to be the target identifier of the new directory.

[0134] The identifier determination unit 640 is specifically used to determine the following if the first identifier is the same as the identifier of any existing directory:

[0135] Update the default version number of the new directory;

[0136] The first identifier of the new directory is generated again based on the updated preset version number, the identifier of the first parent directory of the new directory, and the name of the new directory;

[0137] Perform a step to compare the first identifier of the newly generated directory with the identifier of any existing directory.

[0138] Figure 7 This is a structural diagram of an electronic device illustrated in an exemplary embodiment of the present disclosure.

[0139] like Figure 7 As shown, the electronic device provided in this embodiment includes:

[0140] Memory 701;

[0141] Processor 702; and

[0142] Computer programs;

[0143] The computer program is stored in memory 701 and configured to be executed by processor 702 to implement any of the above-described file system metadata management methods.

[0144] This embodiment also provides a computer-readable storage medium storing a computer program thereon, which is executed by a processor to implement any of the above-described file system metadata management methods.

[0145] This embodiment also provides a computer program product, including a computer program that, when executed by a processor, implements any of the above-described file system metadata management methods.

[0146] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0147] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, and not to limit them; although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some or all of the technical features; and these modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for managing metadata in a file system, characterized in that, The method includes: Obtain the storage directory of the data to be read, and determine the key corresponding to each level directory in the storage directory except for the root directory; the step of determining the key corresponding to each level directory in the storage directory except for the root directory includes: for each level directory in the storage directory except for the root directory, obtaining the identifier of the first parent directory of the directory; generating a predicted identifier of the directory using a cryptographic hash function based on the identifier of the first parent directory, the name of the directory, and the preset version number of the directory; combining the predicted identifier with the name of the directory to obtain the key of the directory; the storage directory includes multiple levels of directories; Based on the key, the directory metadata corresponding to each level of directory is obtained in parallel; wherein, the correspondence between the key and the directory metadata is stored in advance; Based on the directory metadata, it is determined in parallel whether there is access permission for each level of directory. If so, the metadata corresponding to the data to be read is fed back, and the metadata is used to read the data to be read. After obtaining the directory metadata corresponding to each level of directory in parallel based on the key, the method further includes: Obtain the true identifier of the directory from the directory metadata; If the actual identifier is different from the predicted identifier, then the actual identifier of the directory is used to generate the key corresponding to the subdirectory of the directory, and the key value database is queried again based on the regenerated key until the actual identifier and predicted identifier of each level of directory are the same.

2. The method according to claim 1, characterized in that, Also includes: Get the creation request used to create the new directory; In response to the creation request, the first identifier of the new directory is generated based on the identifier of the first parent directory of the new directory, the name of the new directory, and the preset version number of the new directory; The target identifier of the new directory is determined based on the first identifier and the identifier of the existing directory.

3. The method according to claim 2, characterized in that, Determining the target identifier of the new directory based on the first identifier and the identifier of the existing directory includes: Compare whether the first identifier is the same as the identifier of any of the existing directories; If they are not the same, then the first identifier is determined to be the target identifier of the new directory.

4. The method according to claim 3, characterized in that, If the first identifier is the same as the identifier of any of the existing directories, then: Update the default version number of the new directory; The first identifier of the new directory is generated again based on the updated preset version number, the identifier of the first parent directory of the new directory, and the name of the new directory; The step of comparing whether the first identifier is the same as the identifier of any of the existing directories is performed based on the first identifier of the newly generated directory.

5. A metadata management device for a file system, wherein the metadata management device for the file system is used to execute the metadata management method for the file system according to any one of claims 1-4, characterized in that, include: A key determination unit is used to obtain the storage directory of the data to be read, and determine the key corresponding to each level directory in the storage directory except the root directory. The storage directory includes multiple levels of directories; The directory metadata acquisition unit is used to acquire the directory metadata corresponding to each level of directory according to the key; wherein, the correspondence between the key and the directory metadata is stored in advance; The permission determination unit is used to determine whether it has the access permissions corresponding to each level of directory based on the directory metadata. If it does, it feeds back the metadata corresponding to the data to be read, and the metadata is used to read the data to be read.

6. An electronic device, characterized in that, Includes memory and processor; among which, The memory is used to store computer programs; The processor is configured to read a computer program stored in the memory and execute the method described in any one of claims 1-4 according to the computer program in the memory.

7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, implement the method described in any one of claims 1-4.

8. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1-4.

Citation Information

Patent Citations

  • File system building method and device in key-value storage system, and electronic device

    CN103902632A