Directory tree operation method, file system, electronic device, and storage medium

By adding a lock identifier to the directory tree node attributes, the holding and referencing of lock objects are controlled, which solves the performance bottleneck of directory tree locking and improves the performance of file system metadata operations and overall performance.

CN116483778BActive Publication Date: 2026-03-27ALIBABA (CHINA) CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-03-03
Publication Date
2026-03-27

AI Technical Summary

Technical Problem

In existing technologies, the performance bottleneck of locking operations on the directory tree restricts the performance of metadata operations in the file system, affecting overall performance. Especially in multi-threaded concurrent scenarios, too many lock objects lead to increased memory usage, while too few lock objects lead to an increased probability of conflicts.

Method used

By adding a lock identifier to the node attributes of the directory tree, the validity of the lock identifier controls the node's holding and referencing of the lock object, reducing memory resource consumption and effectively controlling the number of lock objects. The CAS algorithm is used to improve the reliability of locking operations.

Benefits of technology

It greatly improves the locking performance of the directory tree, enhances the metadata operation performance and overall performance of the file system, and solves the memory usage and conflict problems caused by too many or too few lock objects.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN116483778B_ABST
    Figure CN116483778B_ABST
Patent Text Reader

Abstract

The embodiment of the application provides a directory tree operation method, a file system, an electronic device and a storage medium. In the embodiment of the application, a lock identifier is added in the node attribute of the directory tree, the node holds and references the lock object based on the validity of the lock identifier, and the lock operation is performed on the referenced lock object. The memory resource occupied by the lock identifier added in the node attribute is small, and the number of lock objects that need to be created is effectively controlled, thereby preferably balancing the problems of "too many lock objects increasing the memory usage" and "too few lock objects increasing the probability of lock conflict", and greatly improving the locking performance of the directory tree. In particular, the reliable basis is provided for improving the metadata operation performance and the overall performance of the file system.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] The present application relates to the technical field of computer, and particularly relates to a directory tree operation method, a file system, an electronic device and a storage medium. BACKGROUND

[0002] A file system is a method and data structure used by an operating system to explicitly store files on a storage device or partition, that is, a method of organizing files on a storage device or partition. A file system organizes and manages files in the entire file system by using a directory tree, and any operation on a file is accompanied by at least one metadata operation, which requires access to the directory tree. In order to ensure the integrity and consistency of the directory tree under multi-thread concurrent operation, the nodes on the directory tree involved in the metadata operation need to be locked. The performance bottleneck of the directory tree locking operation will restrict the metadata operation performance, and directly affect the overall performance of the file system. SUMMARY

[0003] The present application provides a directory tree operation method, a file system, an electronic device and a storage medium, which improves the directory tree operation performance and provides a reliable basis for improving the metadata operation performance and overall performance of the file system.

[0004] The present application provides a directory tree operation method, comprising: in response to a locking request for a target node in a directory tree, judging the validity of a first lock identifier in a node attribute of the target node;

[0005] If the first lock identifier is invalid, a lock object corresponding to a second lock identifier is created; in a case where the first lock identifier in the node attribute of the target node is successfully updated to the second lock identifier, the target node is controlled to hold and reference the lock object corresponding to the second lock identifier; if the first lock identifier is valid, in a case where a holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, the target node is controlled to reference the lock object corresponding to the first lock identifier; and a locking operation is performed on a target lock object referenced by the target node, the target lock object being the lock object corresponding to the first lock identifier or the second lock identifier.

[0006] The present application also provides an electronic device, comprising: a memory and a processor; the memory is used to store a computer program; and the processor is coupled to the memory and is used to execute the computer program to perform the steps in the directory tree operation method.

[0007] In the embodiments of the present application, the lock identifier is added in the node attribute of the directory tree, and the node holds and references the lock object based on the validity of the lock identifier, and the referenced lock object is locked. The memory resource occupied by the lock identifier added in the node attribute is less, and at the same time, the number of lock objects to be created is effectively controlled, and the problems of "too many lock objects increasing the memory usage" and "too few lock objects increasing the probability of lock conflict" are well balanced, and the locking performance of the directory tree is greatly improved. In particular, it provides a reliable basis for improving the metadata operation performance and overall performance of the file system. BRIEF DESCRIPTION OF DRAWINGS

[0008] The drawings described herein are used to provide further understanding of the present application, and form a part of the present application. The illustrative embodiments of the present application and their descriptions serve to explain the present application, and do not constitute improper limitations on the present application. In the drawings:

[0009] Figure 1 A system architecture diagram of an exemplary distributed file system;

[0010] Figure 2 A flowchart of a directory tree operation method provided by the embodiments of the present application;

[0011] Figure 3 A flowchart of another directory tree operation method provided by the embodiments of the present application;

[0012] Figure 4 A flowchart of another directory tree operation method provided by the embodiments of the present application;

[0013] Figure 5 A structural schematic diagram of a directory tree operation device provided by the embodiments of the present application;

[0014] Figure 6 A structural schematic diagram of an electronic device provided by the embodiments of the present application. DETAILED DESCRIPTION

[0015] To make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be described clearly and completely below in combination with the specific embodiments of the present application and corresponding drawings. Obviously, the described embodiments are only some of the embodiments of the present application, not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.

[0016] In the embodiments of the present application, "at least one" means one or more, and "multiple" means two or more. "And / or" describes the access relationship of the associated objects, which means that there can be three relationships, for example, A and / or B can represent the following three cases: A exists alone, A and B exist together, and B exists alone, where A and B can be singular or plural. In the character description of the present application, the character " / " generally represents an "or" relationship between the associated objects. In addition, in the embodiments of the present application, "first", "second", "third", and the like are only used to distinguish the contents of different objects and have no other special meanings.

[0017] Several common file system directory tree locking schemes are introduced below.

[0018] 1. Global lock scheme

[0019] In the lock mechanism implementation, some distributed file systems (DFS) use global locks to uniformly control concurrent read and write. In directory tree operations, obtaining information of any node on the directory tree must first obtain a global read lock; any node on the directory tree must first obtain a global write lock for addition, deletion, or modification. The global lock scheme simplifies the lock model, does not need to consider additional lock dependency relationships, reduces complexity, and reduces engineering effort. However, using global locks to uniformly control concurrent read and write blocks other read requests or write requests to operate the directory tree at any time, causing the entire cluster directory tree operation to be executed serially, and the performance of the directory tree locking operation is poor, which seriously restricts the improvement of the metadata operation performance and affects the overall performance of the file system.

[0020] 2. Layer lock scheme

[0021] Because the global lock scheme seriously restricts the improvement of the metadata operation performance, some file systems use the layer lock scheme. For each layer of the directory tree, the file system maintains a group of lock objects (including multiple lock objects) in each layer, and each lock object corresponds to a lock address. Specifically, in the path resolution process, for a directory or file in the current layer of the directory tree, a hash value is calculated, and the lock address of the directory or file in the current layer is determined through the hash value; according to the application requirements, a read lock or a write lock is added to the lock object corresponding to the lock address of the current layer.

[0022] With the layer lock scheme, because the hash values of the same directory or file name are the same, mutual exclusion is achieved, and only where a write lock is really needed, the lock object has a conflict operation to perform a mutual exclusion operation, and a read lock can be obtained concurrently, effectively improving the concurrency capability of the file system.

[0023] However, because of the existence of hash collision, the access of different directories has a probability of mapping to the same lock object, that is, lock conflict occurs, in order to reduce the lock conflict, increasing the number of lock objects will increase the memory usage. In addition, the layer lock scheme needs to create a fixed number of locks in advance for each layer, too many lock objects will waste memory space, and too few lock objects will increase the probability of lock conflict. The number of layers of files created by the user on the directory tree is not fixed, and the deeper the directory space is, the greater the probability of lock conflict is, although the problem of global lock is overcome, under the condition of large concurrent pressure, lock conflict is still very obvious, and it is difficult to meet the application requirements.

[0024] 3. Lock table (also known as lock pool) scheme

[0025] The global lock can only be executed in series, and the layer lock has a hash collision problem, and the preferred scheme is to generate a lock object for each node in the directory tree. However, for a distributed file system, the size of the directory tree is large, and it is not realistic to generate a lock object for each node, which will greatly increase the memory usage. Therefore, in order to achieve balance, the scheme of using an external lock table (lock pool) is usually used.

[0026] In this scheme, the mapping relationship between the nodes in a directory tree and the lock objects can be managed through an efficient hash table, and the lock objects are created only when the nodes need lock protection, thereby reducing the memory usage and solving the hash collision problem of the layer lock. However, using this scheme, in a multi-thread concurrent scenario, the conflict of the directory tree is converted into the conflict of concurrent insertion and deletion of the hash table, which can easily make the hash table operation a hot spot and affect the performance, so the file system cannot still serve at full capacity.

[0027] Therefore, the embodiment of the present application provides a directory tree operation method, a file system, an electronic device and a storage medium. In the embodiment of the present application, a lock identifier is added to the node attribute of the directory tree, and based on the validity of the lock identifier, the node can hold and reference the lock object, and the lock object can be locked. Adding the lock identifier to the node attribute occupies less memory resources, and at the same time, the number of lock objects that need to be created is effectively controlled, which better balances the problem of "increasing the number of lock objects too much will increase the memory usage" and "too few lock objects will increase the probability of lock conflict", and greatly improves the locking performance of the directory tree. In particular, it provides a reliable basis for improving the metadata operation performance and overall performance of the file system.

[0028] Figure 1 For example, the system architecture diagram of a distributed file system. Referring to Figure 1The distributed file system can include a plurality of clients, a metadata server cluster composed of a plurality of metadata servers 10, and a storage server cluster composed of a plurality of storage servers 20. The metadata server cluster is used to maintain and manage metadata. The metadata includes, for example but not limited to, directory metadata and file metadata. The directory metadata includes, for example but not limited to, directory name, directory ID, access permission of the directory, timestamp of the directory, file name under the directory, and the like. The file metadata includes, for example but not limited to, file name, file ID, file size, access permission of the file, storage location of the file. The storage server cluster is used to store files.

[0029] When the client accesses the file stored in the storage server cluster, the client first sends a metadata query request to the metadata server cluster to request the metadata server cluster to query the metadata, and then the client sends a file access request to the storage server cluster based on the queried metadata to perform various file access operations such as read operation and write operation on the file stored in the storage server cluster.

[0030] In the distributed file system, metadata operations are frequently triggered, and therefore, it is crucial to improve the metadata operation performance of the distributed file system. Metadata operations involve accessing a directory tree, which is a hierarchical tree structure composed of directory metadata and file metadata. A root directory node representing a root directory is at the top layer of the directory tree, and each layer of nodes can be a directory node describing directory metadata or a file node describing file metadata, and some nodes have one or more child nodes. The metadata operation performance is related to the operation performance of the directory tree locking operation. Therefore, improving the operation performance of the directory tree locking operation can significantly improve the metadata operation performance and ensure the overall performance of the distributed file system. The technical solutions provided by the embodiments of the present application are described in detail below in combination with the accompanying drawings.

[0031] Figure 2 A flowchart of a directory tree operation method provided by an embodiment of the present application. The method can be executed by a directory tree operation device, which can be composed of software and / or hardware and can generally be configured in an electronic device. Referring to Figure 2 The method can include the following steps:

[0032] 201. In response to a locking request for a target node in the directory tree, determine the validity of a first lock identifier in the node attribute of the target node. If the first lock identifier is invalid, perform step 202, and if the first lock identifier is valid, perform step 204.

[0033] In the embodiment, the directory tree operation method can be applied in a centralized file system or a distributed file system, and of course, can be applied in various storage systems using a directory tree to organize and manage files, without limitation. Any operation on a file can involve accessing a directory tree, and in order to effectively perform concurrency control, the nodes on the directory tree involved need to be locked. In order to facilitate understanding and distinction, the nodes on the directory tree currently needing to be locked are referred to as target nodes. In the embodiment, the node attributes of the target nodes include, in addition to basic attributes, a lock identifier. The basic attributes are related to the node type, and if the node type is a directory node, the basic attributes include, but are not limited to, a directory name, a directory ID, access permissions of the directory, a timestamp of the directory, and file names under the directory. If the node type is a file node, the basic attributes include, but are not limited to, a file name, a file ID, a file size, access permissions of the file, and a storage location of the file.

[0034] Over time, the target nodes can hold a lock object (Lock) or can not hold the lock object, or the target nodes hold different lock objects. Accordingly, the lock identifier in the node attributes of the target nodes changes. In order to facilitate understanding and distinction, the lock identifier in the current node attributes of the target nodes is referred to as a first lock identifier. When it is necessary to lock the target nodes, first, the validity of the first lock identifier in the node attributes of the target nodes needs to be determined. If the first lock identifier is invalid, a new lock object needs to be created, and the target nodes need to hold and reference the new lock object. If the first lock identifier is valid, it indicates that the target nodes hold a lock object corresponding to the first lock identifier, and in this case, the target nodes reference the lock object corresponding to the first lock identifier. In actual applications, the value of an invalid lock identifier can be set in advance, for example, if the value of the lock identifier is 0, the lock identifier is considered to be invalid. If the value of the lock identifier is not 0, the lock identifier is considered to be valid.

[0035] 202. Create a lock object corresponding to the second lock identifier.

[0036] 203. In a case where the first lock identifier in the node attributes of the target nodes is successfully updated to the second lock identifier, control the target nodes to hold and reference the lock object corresponding to the second lock identifier.

[0037] In the embodiment, if the first lock identifier in the node attribute of the target node is invalid, a new lock object is created. The attribute information of the new lock object can include: a lock identifier (LockId), a holder identifier (OwnerId), and a reference count value (RefCnt) used to record the reference times of the lock object. The holder identifier of the lock object which has not been held by any node in the directory tree is an initial value, for example, 0. After the new lock object is held by any node in the directory tree, the holder identifier is set to the node identifier (InodeId) of the corresponding node. The reference count value of the lock object which has not been referenced is 0, and the reference count value is increased by 1 each time the lock object is referenced.

[0038] For the convenience of distinguishing and understanding, the lock identifier of the new lock object is referred to as a second lock identifier. After the lock object corresponding to the second lock identifier is created, the first lock identifier in the node attribute of the target node is updated to the second lock identifier. Further optionally, in order to improve the updating efficiency, the CAS (Compare and swap) lock-free algorithm can be used to attempt to update the first lock identifier in the node attribute of the target node to the second lock identifier.

[0039] In the case where the first lock identifier in the node attribute of the target node is successfully updated to the second lock identifier, the target node is controlled to hold and reference the lock object corresponding to the second lock identifier. In actual application, in order to improve the reliability of locking, in the case where the first lock identifier in the node attribute of the target node is successfully updated to the second lock identifier, the holder identifier of the lock object corresponding to the second lock identifier is set to the node identifier of the target node, and the reference count value of the lock object corresponding to the second lock identifier is set to 1, so that the target node holds and references the first lock object, wherein the reference count value of the lock object corresponding to the second lock identifier records the reference times of the lock object corresponding to the second lock identifier. It can be understood that when the holder identifier of the lock object corresponding to the second lock identifier is set to the node identifier of the target node, it indicates that the lock object corresponding to the second lock identifier is held by the target node, and in addition, the reference times of the lock object corresponding to the second lock identifier are increased by 1.

[0040] Further optionally, in order to improve the reliability of locking, in the case where the first lock identifier in the node attribute of the target node is not successfully updated to the second lock identifier, the lock object corresponding to the second lock identifier is deleted, and the step of judging the validity of the first lock identifier in the node attribute of the target node is returned to be executed.

[0041] 204、In the case where the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, the target node is controlled to reference the lock object corresponding to the first lock identifier.

[0042] In this embodiment, if the first lock identifier in the node attributes of the target node is valid, it is necessary to determine whether the lock object corresponding to the first lock identifier is held by the target node. If the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, it means that the lock object corresponding to the first lock identifier is held by the target node, and the target node can reference the lock object corresponding to the first lock identifier. In practical applications, to improve the reliability of locking, if the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, the reference count value of the lock object corresponding to the first lock identifier is incremented by 1. The reference count value of the lock object corresponding to the first lock identifier records the number of times the lock object corresponding to the first lock identifier is referenced; if the reference count value of the lock object corresponding to the first lock identifier is successfully incremented by 1, it is determined that the target node references the lock object corresponding to the first lock identifier.

[0043] Further optionally, to improve the reliability of locking, if the holder identifier of the lock object corresponding to the first lock identifier is not the node identifier of the target node, the process returns to the step of determining the validity of the first lock identifier in the node attributes of the target node. Alternatively, if incrementing the reference count value of the lock object corresponding to the first lock identifier fails, the process returns to the step of determining the validity of the first lock identifier in the node attributes of the target node.

[0044] 205. Perform a locking operation on the target lock object referenced by the target node. The target lock object is the lock object corresponding to the first lock identifier or the second lock identifier.

[0045] After the target node references the target lock object, a locking operation can be performed on the target lock object referenced by the target node. For example, a read lock (also known as a shared lock) or a write lock (also known as an exclusive lock) can be acquired.

[0046] The technical solution provided in this application adds a lock identifier to the node attributes of the directory tree. Based on the validity of the lock identifier, it can control whether a node holds and references a lock object, and perform locking operations on the referenced lock object. Adding a lock identifier to the node attributes consumes relatively few memory resources. At the same time, it effectively controls the number of lock objects that need to be created, effectively balancing the problems of "too many lock objects leading to excessive memory usage" and "too few lock objects leading to an increased probability of lock conflicts," thus greatly improving the locking performance of the directory tree. In particular, it provides a reliable foundation for improving the metadata operation performance and overall performance of the file system.

[0047] In some optional embodiments, in order to better reduce lock conflicts, before step 201 is performed, it can also be judged whether the target node is a newly created node in the directory tree; if the target node is not a newly created node in the directory tree, step 201 is performed. If the target node is a newly created node in the directory tree, a third lock identifier is obtained by performing a hash operation on the node identifier of the target node and the node identifier of the parent node of the target node; a lock object with the third lock identifier is controlled by the target node, and a lock operation is performed on the lock object with the third lock identifier. It is worth noting that when a file or a directory is created, the newly created file or the directory corresponding to the new node is controlled to hold and reference the lock object by the hash method, so that a large number of lock objects (that is, the lock space is relatively large) can be created, thereby greatly reducing the probability of lock conflicts.

[0048] In order to better understand the technical solutions provided by the embodiments of the present application, a specific directory tree operation method is introduced below.

[0049] Figure 3 A flowchart of another directory tree operation method provided by the embodiments of the present application. The method can be performed by a directory tree operation device, which can be composed of software and / or hardware, and can generally be configured in an electronic device. Referring to Figure 3 , the method can include the following steps:

[0050] 301、In response to a lock request for a target node in a directory tree, judging the validity of a first lock identifier in the node attribute of the target node. If the first lock identifier is invalid, step 302 is performed, and if the first lock identifier is valid, step 306 is performed.

[0051] 302、Creating a lock object corresponding to a second lock identifier.

[0052] 303、Updating the first lock identifier in the node attribute of the target node to the second lock identifier, if the update fails, step 304 is performed, and if the update succeeds, step 305 is performed.

[0053] 304、Deleting the lock object corresponding to the second lock identifier, and returning to step 301.

[0054] 305、Setting the holder identifier of the lock object corresponding to the second lock identifier to the node identifier of the target node, and setting the reference count value of the lock object corresponding to the second lock identifier to 1, so that the target node holds and references the lock object corresponding to the second lock identifier, and step 309 is performed.

[0055] 306、Judging whether the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node. If yes, step 307 is performed, and if no, step 301 is performed.

[0056] 307. Increment the reference count of the lock object corresponding to the first lock identifier by 1. If the increment is successful, proceed to step 308; if the increment fails, return to step 301.

[0057] 308. Determine the lock object corresponding to the first lock identifier referenced by the target node, and proceed to step 309.

[0058] 309. Perform a locking operation on the target lock object referenced by the target node. The target lock object is the lock object corresponding to the first lock identifier or the second lock identifier.

[0059] The implementation methods of each step in the method provided in this embodiment can be found in the implementation methods of each step in the foregoing embodiments, and will not be repeated here.

[0060] The technical solution provided in this embodiment adds a lock identifier to the node attributes of the directory tree. Based on the validity of the lock identifier, it can control whether a node holds and references a lock object, and perform locking operations on the referenced lock object. Adding a lock identifier to the node attributes increases memory usage minimally, saving memory resources. Simultaneously, it effectively controls the number of lock objects that need to be created, effectively balancing the problems of "too many lock objects leading to excessive memory usage" and "too few lock objects leading to an increased probability of lock conflicts," thus greatly improving the locking performance of the directory tree. In particular, it provides a reliable foundation for improving the metadata operation performance and overall performance of the file system.

[0061] Figure 4 A flowchart illustrating another directory tree operation method provided in this application embodiment. This method can be executed by a directory tree operation device, which may consist of software and / or hardware, and is generally configured in an electronic device. See also... Figure 4 The method may include the following steps:

[0062] 401. In response to the unlock request for the target node, perform an unlock operation on the target lock object.

[0063] 402. Determine whether the reference count of the target lock object is greater than 1 or equal to 1.

[0064] 403. If the reference count of the target lock object is greater than 1, decrement the reference count of the target lock object by 1.

[0065] 404. If the reference count of the target lock object is successfully decremented by 1, then the target lock object is considered to have been successfully released.

[0066] 405. If the reference count of the target lock object is equal to 1, then set the holder identifier of the target lock object to an illegal identifier;

[0067] 406、If the holder identifier of the target lock object is successfully set to the illegal identifier, update the lock identifier in the node attribute of the target node to the invalid lock identifier, and delete the target lock object.

[0068] In the multi-thread scenario, after any thread successfully locks the target node, if the thread finishes the corresponding task, the target lock object referenced by the target node needs to be unlocked. For the locked target node, the target lock object referenced by the target node is unlocked. After the unlocking, it is determined whether the reference count value of the target lock object is greater than 1 or equal to 1. If the reference count value of the target lock object is greater than 1, it means that the target lock object is referenced multiple times, and at this time, the reference count value of the target lock object is decremented by 1. If the decrementing of the reference count value of the target lock object is successful, it is determined that the target lock object is successfully released this time. Further optionally, in order to improve the reliability of the lock object release, if the decrementing of the reference count value of the target lock object fails, the step 402 is returned to be executed. If the reference count value of the target lock object is equal to 1, it means that this is the last reference of the target lock object, and at this time, the holder identifier of the target lock object is set to the illegal identifier, and the illegal identifier is, for example, -1. If the holder identifier of the target lock object is successfully set to the illegal identifier, the lock identifier in the node attribute of the target node is updated to the invalid lock identifier, that is, the target node is restored to the case of not holding the lock object, and the target lock object is deleted to save the memory resource. Further optionally, in order to improve the reliability of the lock object release, if the holder identifier of the target lock object is not successfully set to the illegal identifier, the step 402 is returned to be executed.

[0069] The technical scheme provided by the embodiment of the application greatly improves the unlocking performance of the directory tree after the lock object is unlocked, and determines whether the lock object is deleted or the reference times of the lock object are released based on the reference count value of the target lock object. In particular, it provides a reliable basis for improving the metadata operation performance and overall performance of the file system.

[0070] The embodiment of the application further provides a file system, which comprises a client, a metadata server cluster and a storage server cluster.

[0071] The client is configured to send a metadata query request to the metadata server cluster, receive file metadata returned by the metadata server cluster, send a file access request comprising the file metadata to the storage server cluster, and receive a file access result returned by the storage server cluster.

[0072] The metadata server cluster is configured to determine a target node in a directory tree to be accessed according to the metadata query request, execute the locking operation on the target lock object referenced by the target node according to the directory tree operation method, query file metadata from the target node, and return the file metadata to the client.

[0073] A storage server cluster is configured to perform a file access operation on a locally stored file according to file metadata in a file access request, and obtain a file access result.

[0074] Specifically, the metadata server cluster is configured to maintain and manage metadata. The metadata includes, for example but not limited to, directory metadata and file metadata. The directory metadata includes, for example but not limited to, directory name, directory ID, access permission of the directory, timestamp of the directory, file name under the directory, and the like. The file metadata includes, for example but not limited to, file name, file ID, file size, access permission of the file, storage location of the file. The storage server cluster is configured to store files.

[0075] When a client accesses a file stored in the storage server cluster, the client first sends a metadata query request to the metadata server cluster to request the metadata server cluster to query metadata. The metadata server cluster determines a target node in a directory tree involved in the metadata query request, performs a lock operation on a target lock object referenced by the target node, queries file metadata from the target node, and returns the file metadata to the client. Then, the client sends a file access request to the storage server cluster based on the queried file metadata, to perform various file access operations such as read operation and write operation on the file stored in the storage server cluster.

[0076] The technical scheme provided by the embodiments of the present application significantly improves the metadata operation performance by improving the operation performance of the directory tree lock operation, and further guarantees the overall performance of the file system.

[0077] Figure 5 A structural schematic diagram of a directory tree operation device provided by the embodiments of the present application is shown in FIG. 1. Referring to FIG. 1, Figure 5 The device can include:

[0078] The judging module 51 is configured to judge the validity of the first lock identifier in the node attribute of the target node in response to the lock request of the target node in the directory tree.

[0079] The creating module 52 is configured to create a lock object corresponding to the second lock identifier if the first lock identifier is invalid.

[0080] The control module 53 is configured to control the target node to hold and reference the lock object corresponding to the second lock identifier if the first lock identifier in the node attribute of the target node is successfully updated to the second lock identifier.

[0081] The control module 53 is further configured to control the target node to reference the lock object corresponding to the first lock identifier if the first lock identifier is valid and the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node.

[0082] The locking module 54 is configured to perform a locking operation on the target lock object referenced by the target node, the target lock object being the lock object corresponding to the first lock identifier or the second lock identifier.

[0083] Further, the control module 53 is configured to control the target node to hold and reference the lock object corresponding to the second lock identifier if the first lock identifier is successfully updated to the second lock identifier in the node attribute of the target node.

[0084] If the first lock identifier is successfully updated to the second lock identifier in the node attribute of the target node, the holder identifier of the lock object corresponding to the second lock identifier is set to the node identifier of the target node, and the reference count value of the lock object corresponding to the second lock identifier is set to 1, so that the target node holds and references the lock object corresponding to the second lock identifier, where the reference count value of the lock object corresponding to the second lock identifier records the reference times of the lock object corresponding to the second lock identifier.

[0085] Further, the control module 53 is configured to control the target node to reference the lock object corresponding to the first lock identifier if the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node.

[0086] If the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, the reference count value of the lock object corresponding to the first lock identifier is increased by 1, and the reference count value of the lock object corresponding to the first lock identifier records the reference times of the lock object corresponding to the first lock identifier.

[0087] If the reference count value of the lock object corresponding to the first lock identifier is successfully increased by 1, the target node references the lock object corresponding to the first lock identifier.

[0088] Further, the control module 53 is further configured to trigger the judging module 51 if the reference count value of the lock object corresponding to the first lock identifier fails to be increased by 1.

[0089] Further, the control module 53 is further configured to delete the lock object corresponding to the second lock identifier and trigger the judging module 51 if the first lock identifier is invalid and the first lock identifier fails to be successfully updated to the second lock identifier in the node attribute of the target node, or trigger the judging module 51 if the first lock identifier is valid and the holder identifier of the lock object corresponding to the first lock identifier is not the node identifier of the target node.

[0090] Further optionally, the judgment module 51 is used to: before judging the validity of the first lock identifier in the node attributes of the target node, judge whether the target node is a newly created node in the directory tree; if the target node is not a newly created node in the directory tree, then perform the step of judging the validity of the first lock identifier in the node attributes of the target node.

[0091] Further optionally, the judgment module 51 is used to: if the target node is a newly created node in the directory tree, perform a hash operation on the node identifiers of the target node and its parent node to obtain the third lock identifier;

[0092] Control module 53 is also used to: control the target node to hold and reference the lock object of the third lock identifier;

[0093] The locking module 54 is also used to perform locking operations on the lock object identified by the third lock.

[0094] Further optionally, the above device also includes: an unlocking module, used to perform an unlocking operation on the target lock object in response to an unlocking request for the target node;

[0095] The judgment module 51 is also used to: determine whether the reference count value of the target lock object is greater than 1 or equal to 1;

[0096] The control module 53 is further configured to decrement the reference count of the target lock object by 1 if the reference count of the target lock object is greater than 1; if the reference count of the target lock object is successfully decremented by 1, then the target lock object is determined to have been successfully released; if the reference count of the target lock object is equal to 1, then the holder identifier of the target lock object is set to an invalid identifier; if the holder identifier of the target lock object is successfully set to an invalid identifier, then the lock identifier in the node attribute of the target node is updated to an invalid lock identifier, and the target lock object is deleted.

[0097] Further optionally, the control module 53 is also configured to trigger the judgment module 51 if the reference count value of the target lock object fails to be decremented by 1; or, if the holder identifier of the target lock object is not successfully set to an illegal identifier, trigger the judgment module 51.

[0098] Figure 5 The device shown can perform Figures 2 to 4 The implementation principle and technical effects of the method will not be elaborated further. Regarding the above embodiments... Figure 5 The specific ways in which each module and unit of the device performs operations have been described in detail in the embodiments of the method, and will not be elaborated here.

[0099] For a detailed description of the implementation process of each action by the processor, please refer to the relevant descriptions in the foregoing method embodiments or device embodiments, which will not be repeated here.

[0100] It should be noted that the execution subject of each step of the method provided in the above embodiments can be the same device, or the method can be executed by different devices. For example, the execution subject of steps 201 to 205 can be device A; or the execution subject of steps 201 and 202 can be device A, and the execution subject of steps 203 to 205 can be device B; and so on.

[0101] Furthermore, in some of the processes described in the above embodiments and accompanying drawings, multiple operations appear in a specific order. However, it should be clearly understood that these operations may not be executed in the order they appear herein, or they may be executed in parallel. The operation numbers, such as 201, 202, etc., are merely used to distinguish different operations and do not represent any execution order. Additionally, these processes may include more or fewer operations, and these operations may be executed sequentially or in parallel. It should be noted that the descriptions such as "first" and "second" in this document are used to distinguish different messages, devices, modules, etc., and do not represent a sequential order, nor do they limit "first" and "second" to different types.

[0102] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, data stored, data displayed, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties. Furthermore, the collection, use and processing of the relevant data must comply with the relevant laws, regulations and standards of the relevant countries and regions, and corresponding operation portals are provided for users to choose to authorize or refuse.

[0103] Figure 6 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 6 As shown, the electronic device includes: a memory 61 and a processor 62;

[0104] Memory 61 is used to store computer programs and can be configured to store various other data to support operation on the computing platform. Examples of this data include instructions for any application or method operating on the computing platform, contact data, phone book data, messages, pictures, videos, etc.

[0105] The memory 61 can be implemented by any type of volatile or nonvolatile storage devices or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read only memory (EEPROM), erasable programmable read only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk or optical disk.

[0106] The processor 62 is coupled to the memory 61 and configured to execute the computer program in the memory 61, so as to perform the steps in the directory tree operation method.

[0107] Further, as shown in Figure 6 , the electronic device further includes a communication component 63, a display 64, a power supply component 65, an audio component 66 and other components. Figure 6 Some components are only schematically shown in the electronic device, and it does not mean that the electronic device only includes Figure 6 the components shown. In addition, Figure 6 the components in the dashed box are optional components, rather than mandatory components, and the specific implementation can be determined according to the product form of the electronic device. The electronic device of the embodiment can be implemented as a terminal device such as a desktop computer, a notebook computer, a smart phone or an IOT (Internet of things) device, or a server device such as a general server, a cloud server or a server array. If the electronic device of the embodiment is implemented as a terminal device such as a desktop computer, a notebook computer, a smart phone or an IOT (Internet of things) device, it can include Figure 6 the components in the dashed box; if the electronic device of the embodiment is implemented as a server device such as a general server, a cloud server or a server array, it can not include Figure 6 the components in the dashed box.

[0108] The detailed implementation process of the processor performing each action can refer to the related description in the foregoing method embodiment or device embodiment, which will not be described here.

[0109] Correspondingly, the embodiment of the application further provides a computer readable storage medium storing a computer program, and the computer program is executed to implement each step that can be performed by the electronic device in the method embodiment.

[0110] Accordingly, the embodiments of the present application also provide a computer program product, including computer programs / instructions, which, when executed by a processor, enable the processor to implement each step of the above-mentioned method embodiments that can be performed by an electronic device.

[0111] The communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G, or the like, or a combination thereof. In an example embodiment, the communication component receives broadcast signals or broadcast-related information from an external broadcast management system via a broadcast channel. In an example embodiment, the communication component further includes a Near Field Communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on Radio Frequency Identification (RFID) technology, The Infrared Data Association (IrDA) technology, Ultra Wide Band (UWB) technology, Bluetooth (BT) technology, and other technologies.

[0112] The display includes a screen, which can include a Liquid Crystal Display (LCD) and a touch panel (TP). If the screen includes the touch panel, the screen can be implemented as a touch screen to receive an input signal from a user. The touch panel includes one or more touch sensors to sense a touch, a slide, and a gesture on the touch panel. The touch sensor can not only sense a boundary of a touch or a slide action, but also detect a duration and a pressure related to a touch or a slide operation.

[0113] The power supply component provides power to various components of the device where the power supply component is located. The power supply component can include a power management system, one or more power sources, and other components associated with generating, managing, and distributing power to the device where the power supply component is located.

[0114] The audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC) that is configured to receive an external audio signal when the device where the audio component is located is in an operation mode, such as a call mode, a recording mode, and a voice recognition mode. The received audio signal can be further stored in a memory or transmitted via the communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.

[0115] Those skilled in the art will appreciate that embodiments of the present application can be readily used as a method, apparatus, or computer program product. Accordingly, the present application can take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment combining software and hardware aspects. Furthermore, the present application can take the form of a computer program product on one or more computer readable storage media (including, but not limited to, disk memory, CD-ROMs, optical storage devices, etc.) embodying computer readable program code.

[0116] The present application is described in reference to the flowchart illustrations and / or block diagrams of methods, apparatus (systems) and computer program products according to embodiments of the application. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general purpose computer, special purpose computer, embedded processing device or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 means for carrying out each of the one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0117] These computer program instructions can also be stored in a computer readable memory that can direct a computer or other programmable data processing apparatus to function in a particular manner, such that the instructions stored in the computer readable memory produce an article of manufacture including instructions which implement the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 means for carrying out each of the one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0118] These computer program instructions can also be loaded onto a computer or other programmable data processing apparatus to cause a series of operational steps to be performed on the computer or other programmable apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide steps for implementing the flowchart illustrations and / or block diagrams block or blocks. Figure 1 one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks. Figure 1 means for carrying out each of the one or more functions specified in the flowchart illustrations and / or block diagrams block or blocks.

[0119] In one typical configuration, the computing device includes one or more processors (central processing units, CPUs), input / output interfaces, network interfaces, and memory.

[0120] Memory can include non-persistent memory in computer-readable media, Random Access Memory (RAM), and / or non-volatile memory, such as Read Only Memory (ROM) or flash memory, etc. Memory is an example of computer-readable media.

[0121] Computer-readable media includes permanent and non-permanent, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, Phase Change RAM (PRAM), Static Random-Access Memory (SRAM), Dynamic Random Access Memory (DRAM), other types of Random Access Memory (RAM), Read Only Memory (ROM), Electrically-Erasable Programmable Read-Only Memory (EEPROM), flash memory or other memory technology, Compact Disc Read Only Memory (CD-ROM), Digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other non-transmission medium that can be used to store information accessible to a computing device. According to the definition herein, computer-readable media does not include transitory media such as modulated data signals and carrier waves.

[0122] It should also be noted that the terms "comprising," "including," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but can also include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the statement "comprising a" does not exclude the existence of additional identical elements in the process, method, article, or apparatus including the element.

[0123] The above merely provides an example of the present application, and is not intended to limit the present application. For those skilled in the art, the present application can have various modifications and changes. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present application shall fall into the scope of claims of the present application.

Claims

1. A method for manipulating a directory tree, comprising: In response to a lock request for a target node in the directory tree, determine the validity of the first lock identifier in the node attributes of the target node; If the first lock identifier is invalid, a lock object corresponding to the second lock identifier is created. The second lock identifier is the lock identifier of the newly created lock object. The first lock identifier in the node attribute of the target node is updated to the second lock identifier. If the first lock identifier in the node attributes of the target node is successfully updated to the second lock identifier, the target node is controlled to hold and reference the lock object corresponding to the second lock identifier; If the first lock identifier is valid, then if the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, the target node is controlled to reference the lock object corresponding to the first lock identifier; A locking operation is performed on the target lock object referenced by the target node, wherein the target lock object is the lock object corresponding to the first lock identifier or the second lock identifier.

2. The method according to claim 1, wherein, when the first lock identifier in the node attributes of the target node is successfully updated to the second lock identifier, controlling the target node to hold and reference the lock object corresponding to the second lock identifier includes: If the first lock identifier in the node attributes of the target node is successfully updated to the second lock identifier, then the holder identifier of the lock object corresponding to the second lock identifier is set to the node identifier of the target node, and the reference count value of the lock object corresponding to the second lock identifier is set to 1, so that the target node holds and references the lock object corresponding to the second lock identifier, wherein the reference count value of the lock object corresponding to the second lock identifier records the number of times the lock object corresponding to the second lock identifier is referenced.

3. The method according to claim 1, wherein when the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, controlling the target node to reference the lock object corresponding to the first lock identifier includes: If the holder identifier of the lock object corresponding to the first lock identifier is the node identifier of the target node, then the reference count value of the lock object corresponding to the first lock identifier is incremented by 1, and the reference count value of the lock object corresponding to the first lock identifier records the number of times the lock object corresponding to the first lock identifier has been referenced. If the reference count of the lock object corresponding to the first lock identifier is successfully incremented by 1, it is determined that the target node references the lock object corresponding to the first lock identifier.

4. The method according to claim 3, further comprising: If incrementing the reference count of the lock object corresponding to the first lock identifier fails, the process returns to the step of determining the validity of the first lock identifier in the node attributes of the target node.

5. The method according to any one of claims 1 to 4, further comprising: If the first lock identifier is invalid, and the first lock identifier in the node attribute of the target node is not successfully updated to the second lock identifier, then delete the lock object corresponding to the second lock identifier, and return to the step of judging the validity of the first lock identifier in the node attribute of the target node; or, If the first lock identifier is valid, then if the holder identifier of the lock object corresponding to the first lock identifier is not the node identifier of the target node, return to the step of determining the validity of the first lock identifier in the node attributes of the target node.

6. The method according to claim 1, further comprising, before determining the validity of the first lock identifier in the node attributes of the target node: Determine whether the target node is a newly created node in the directory tree; If the target node is not a newly created node in the directory tree, then the step of determining the validity of the first lock identifier in the node attributes of the target node is executed.

7. The method according to claim 6, further comprising: If the target node is a newly created node in the directory tree, then a hash operation is performed on the node identifiers of the target node and its parent node to obtain the third lock identifier; The target node is controlled to hold and reference the lock object identified by the third lock identifier, and a locking operation is performed on the lock object identified by the third lock identifier.

8. The method according to any one of claims 1 to 4, after performing a locking operation on the target lock object referenced by the target node, further comprising: In response to the unlock request for the target node, the target lock object is unlocked. Determine whether the reference count value of the target lock object is greater than 1 or equal to 1; If the reference count of the target lock object is greater than 1, decrement the reference count of the target lock object by 1; If the reference count of the target lock object is successfully decremented by 1, then the target lock object is determined to have been successfully released. If the reference count of the target lock object is equal to 1, then the holder identifier of the target lock object is set to an illegal identifier; If the holder identifier of the target lock object is successfully set to an invalid identifier, then the lock identifier in the node attributes of the target node is updated to an invalid lock identifier, and the target lock object is deleted.

9. The method according to claim 8, further comprising: If decrementing the reference count of the target lock object by 1 fails, then return to the step of determining whether the reference count of the target lock object is greater than 1 or equal to 1; or, If the holder identifier of the target lock object is not successfully set to an invalid identifier, then return to the step of determining whether the reference count value of the target lock object is greater than 1 or equal to 1.

10. A file system, comprising: Client, metadata server cluster, and storage server cluster; The client is used to send metadata query requests to the metadata server cluster; And receive file metadata returned by the metadata server cluster; Send a file access request including the file metadata to the storage server cluster, and receive the file access result returned by the storage server cluster; The metadata server cluster is configured to determine the target node in the directory tree to be accessed based on the metadata query request, and execute the directory tree operation method according to any one of claims 1 to 9 to perform a locking operation on the target lock object referenced by the target node, query file metadata from the target node, and return the file metadata to the client; The storage server cluster is used to perform file access operations on locally stored files based on the file metadata in the file access request, and obtain the file access result.

11. An electronic device, comprising: Memory and processor; The memory is used to store computer programs; The processor is coupled to the memory for executing the computer program to perform the steps of the method according to any one of claims 1-9.

12. A computer-readable storage medium storing a computer program that, when executed by a processor, causes the processor to perform the steps of the method according to any one of claims 1-9.

Citation Information

Patent Citations

  • Lock operation method of database system and equipment

    CN103336789A

  • Scalable locking techniques

    US20210286802A1