Distributed data storage control method and device, and electronic equipment

By allocating distributed locks and configuring local memory locks for proxy nodes, the problem of inconsistent target metadata caused by concurrent modifications by proxy nodes in the NAS cluster is solved, thus achieving stability and consistency in data access.

CN117806561BActive Publication Date: 2025-12-19BEIJING VOLCANO ENGINE TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202311866662.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-29
Publication Date
2025-12-19
Estimated Expiration
2043-12-29

AI Technical Summary

Technical Problem

In NAS clusters, the problem of inconsistent target metadata caused by multiple agent nodes concurrently modifying the target metadata of a file is difficult to solve effectively with existing technologies.

Method used

By assigning distributed locks to agent nodes and configuring local memory locks for the distributed locks, local synchronous access is controlled, ensuring the consistency of the state of the distributed locks within a single agent node, thereby avoiding inconsistencies between the target metadata and the target metadata in the NAS cluster.

Benefits of technology

This effectively avoids the problem of inconsistency between the target metadata cached by the proxy node and the actual target metadata in the NAS cluster, improving data consistency and stability when multiple proxy nodes access the data concurrently.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117806561B_ABST
    Figure CN117806561B_ABST
Patent Text Reader

Abstract

Embodiments of the present disclosure provide a distributed data storage control method, device and electronic equipment, the method comprising: receiving, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change in target metadata of the target file; in response to the first change request, assigning, by a distributed lock management node in the NAS cluster, a corresponding distributed lock and returning a first response information to the proxy node; receiving, by the proxy node, the first response information, configuring a corresponding local memory lock for the distributed lock corresponding to the first change request; and based on the first change request having the distributed lock and the local memory lock, controlling the change in the target metadata of the target file in the NAS cluster, so as to avoid the target metadata from being disordered and improve system stability.
Need to check novelty before this filing date? Find Prior Art

Description

TECHNICAL FIELD

[0001] Embodiments of the present disclosure relate to the technical field of Internet, and particularly, to a distributed data storage control method and device and electronic equipment. BACKGROUND

[0002] A network attached storage (NAS) cluster is a cluster storage device specially designed for storing and sharing files. It is usually connected to a network and can be accessed and managed through the network. The NAS storage device can be directly connected to an Ethernet network, and then hosts with different types of operating systems in the network domain can access the cluster device.

[0003] Multiple users can use clients to send access requests to the NAS cluster. In order to alleviate the pressure on the NAS cluster caused by multiple access requests, multiple proxy nodes can be set. Please refer to Figure 1 , Figure 1 for an application scenario diagram. As shown in Figure 1 , multiple proxy nodes are set between the NAS cluster and multiple clients, and the access requests sent by multiple clients can be distributed to each proxy node based on load balancing. The proxy node can parse the received access request and send the parsed access request to the NAS storage architecture backend storage cluster.

[0004] In the process of parsing the user access request, the proxy node needs to interact with the NAS cluster. In order to avoid the conflict of multiple proxy nodes accessing the NAS device at the same time and solve the consistency of the metadata obtained from the NAS by different proxy nodes, multiple proxy nodes can use a distributed lock to access the NAS cluster, obtain and cache target metadata from the NAS cluster. In some application scenarios, there is an inconsistency between the target metadata cached in the proxy node and the target metadata in the NAS cluster. SUMMARY

[0005] Embodiments of the present disclosure provide a distributed data storage control method and device and electronic equipment.

[0006] In a first aspect, the embodiments of the present disclosure provide a distributed data storage control method, which comprises: receiving, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change of target metadata of the target file; allocating, by a distributed lock management node in the NAS cluster in response to the first change request, a corresponding distributed lock and returning first response information to the proxy node, the distributed lock being used to control exclusive access to shared data in the NAS cluster, and the first response information being used to notify of successful distributed lock allocation; configuring, by the proxy node receiving the first response information, a corresponding local memory lock for the distributed lock corresponding to the first change request, the local memory lock being used to control local synchronous access to the distributed lock and protect state consistency of the distributed lock within a single proxy node; and controlling, based on the first change request with the distributed lock and the local memory lock, a change of the target metadata of the target file in the NAS cluster.

[0007] In a second aspect, the embodiments of the present disclosure provide a distributed data storage control apparatus, which comprises: a receiving unit configured to receive, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change of target metadata of the target file; an allocating unit configured to allocate, by a distributed lock management node in the NAS cluster in response to the first change request, a corresponding distributed lock and return first response information to the proxy node, the distributed lock being used to control exclusive access to shared data in the NAS cluster, and the first response information being used to notify of successful distributed lock allocation; a configuring unit configured to configure, by the proxy node receiving the first response information, a corresponding local memory lock for the distributed lock corresponding to the first change request, the local memory lock being used to control local synchronous access to the distributed lock and protect state consistency of the distributed lock within a single proxy node; and an executing unit configured to control, based on the first change request with the distributed lock and the local memory lock, a change of the target metadata of the target file in the NAS cluster.

[0008] In a third aspect, the embodiments of the present disclosure provide an electronic device, which comprises: a processor and a memory; the memory stores computer-executable instructions; and the processor executes the computer-executable instructions stored in the memory, so that the at least one processor executes the method of the first aspect and various possible methods of the first aspect.

[0009] In a fourth aspect, the embodiments of the present disclosure provide a computer-readable storage medium, which stores computer-executable instructions, and when a processor executes the computer-executable instructions, the method of the first aspect and various possible methods of the first aspect are implemented.

[0010] In a fifth aspect, the present disclosure provides a computer program product, comprising a computer program, which, when executed by a processor, implements the method of the first aspect and various possible methods of the first aspect.

[0011] The distributed data storage control method, device and electronic equipment provided by the present disclosure can receive a first change request for a target file in a NAS cluster through a proxy node, the first change request being used to directly or indirectly trigger a change of target metadata of the target file; a corresponding distributed lock is allocated by a distributed lock management node in the NAS cluster in response to the first change request, and a first response information is returned to the proxy node; the distributed lock is used to control exclusive access to shared data in the NAS cluster; the first response information is used to notify the successful allocation of the distributed lock; the corresponding local memory lock is configured for the distributed lock corresponding to the first change request through the proxy node receiving the first response information, the local memory lock being used to control local synchronous access to the distributed lock and protect the state consistency of the distributed lock in a single proxy node; based on the first change request with the distributed lock and the local memory lock, the change of the target metadata of the target file in the NAS cluster is controlled, which can avoid the problem that the allocated distributed lock is stolen, resulting in inconsistency between the target metadata and the target metadata in the NAS cluster. The problem of target metadata disorder caused by concurrent modification of the target metadata of the file by multiple proxy nodes is solved. BRIEF DESCRIPTION OF DRAWINGS

[0012] In order to more clearly illustrate the technical solutions in the embodiments of the present disclosure or the prior art, the drawings needed to be used in the embodiments or prior art description will be briefly introduced. Obviously, the drawings in the following description are some embodiments of the present disclosure, and other drawings can be obtained by those skilled in the art without creative labor.

[0013] Figure 1 An application scenario schematic diagram is provided;

[0014] Figure 2 A flowchart of a data access method provided by the embodiments of the present disclosure is provided Figure 1 ;

[0015] Figure 3 A flowchart of a scenario is provided;

[0016] Figure 4 A flowchart of a data access method provided by the embodiments of the present disclosure is provided Figure 2 ;

[0017] Figure 5 A flowchart of a data access method provided by the embodiments of the present disclosure is providedFigure 3 ;

[0018] Figure 6 A schematic structural block diagram of a data access device provided by an embodiment of the present disclosure;

[0019] Figure 7 A schematic diagram of a hardware structure of an electronic device provided by an embodiment of the present disclosure. DETAILED DESCRIPTION

[0020] To make the objectives, technical solutions, and advantages of the embodiments of the present disclosure clearer, the following will clearly and completely describe the technical solutions in the embodiments of the present disclosure with reference to the drawings in the embodiments of the present disclosure. Obviously, the described embodiments are some but not all of the embodiments of the present disclosure. Based on the embodiments in the present disclosure, all other embodiments obtained by a person of ordinary skill in the art without creative work fall within the protection scope of the present disclosure.

[0021] In a NAS storage architecture, file data is divided into data and metadata. The data refers to actual data in a file, that is, actual content of the file. The metadata of the file is system data used to describe the characteristics of a file. The metadata of the file is, for example, a file name, a file size, a file type, an owner, a sending time, an update time of file content, and the like.

[0022] The NAS cluster includes a plurality of data block service nodes (Block Server, BS for short) and distributed lock management nodes.

[0023] The proxy node can cache information of metadata obtained from the NAS cluster. In addition, a user can initiate a change request for a file to the NAS cluster through the proxy node, and the change request can change the metadata of the file. In addition, a plurality of users can concurrently initiate change requests causing metadata change. In order to solve the conflict caused by the concurrency of the metadata change requests of multiple users, the distributed lock can be used to control the change requests of the files of each proxy node, so as to solve the problem of competition for NAS resources by different proxy nodes.

[0024] For a change request directly or indirectly updating target metadata of a file, the proxy node needs to apply for a distributed lock to the distributed lock management node of the NAS cluster. When the proxy node applies for a distributed lock to the distributed lock management node according to the change request of the client, the distributed lock management node needs to cancel the distributed lock already allocated according to the conflict rule between the distributed locks, so as to allocate the corresponding distributed lock to the proxy node applying for the distributed lock. When other proxy nodes receive the cancellation request for the distributed lock sent by the distributed lock management node, the proxy node will directly invalidate the distributed lock and the cached target metadata held by itself.

[0025] After the proxy node is allocated a distributed lock by the distributed lock management node, the proxy node can initiate a write request for directly or indirectly changing the target metadata of a file to the data block proxy node in the NAS cluster according to the distributed lock held by the proxy node. If the distributed lock of the proxy node is revoked in this process, the problem of metadata disorder caused by inconsistency between the target metadata in the NAS cluster and the target metadata cached by the proxy node will occur.

[0026] In the present disclosure, metadata is taken as an example to represent the size of a file. If the current file size of a file F1 is 1M. The change request of the proxy node 1 to the file F1 is to add new content to the interval [1M, 2M). The proxy node 1 holds a distributed lock and initiates a write request to the data block service node of the NAS cluster. At this time, the proxy node 2 concurrently sends a file size update request (Truncate request) to update the file size of the file F1 to the NAS cluster. The file size update request modifies the file size of the file F1 to 0M. The proxy node 2 needs to apply for a distributed lock to the distributed lock management node for the file size update request, and the distributed lock management node sends a revoke request to revoke the distributed lock held by the proxy node.

[0027] After receiving the revoke request of the distributed lock management node, the proxy node 1 immediately releases the distributed lock held by itself. Then the distributed lock management node allocates the distributed lock to the proxy node 2, and the proxy node 2 sends a file size update request to the data block service node after obtaining the distributed lock. If the data block service node first adds new content in the range of (1M, 2M] to the file F1 according to the change request of the proxy node 1, and updates the file size of the target file to 2M in the data block service node. Then the data block service node updates the size of the target file to 0M according to the file size update request of the proxy node 2.

[0028] But the proxy node 1 first receives the content addition success response information sent by the data block service node in the NAS cluster, and prepares to update the file size of the file F1 in the cache, but finds that the distributed write lock is invalid, and needs to re-apply for a distributed lock to the distributed lock management node. Before the distributed lock management node processes the re-applied distributed lock request of the proxy node 1, the proxy node 2 receives the update success response information of the size update request of the data block service node pair, and updates the size of the file F1 in the cache to 0, and then the distributed lock of the proxy node 2 is revoked. The proxy node 1 gets the distributed lock and modifies the file size of the file F1 in the cache to 2M. This causes the file size of the file F1 in the cache of the proxy node 1 to be inconsistent with the real size of the file in the BS, which is 0M. Therefore, in the above process, due to the concurrency of the proxy node to the target metadata change request of the file F1, the proxy node F1 based on the distributed lock in the process of directly or indirectly changing the target metadata of the file, the distributed lock held by the proxy node F1 is invalid due to the competition of other proxy nodes, which causes the inconsistency between the target metadata in the cache of the proxy node F1 and the real target metadata in the data block service node in the NAS cluster, and the metadata of the file is chaotic.

[0029] The scheme provided by the present disclosure allocates a distributed lock for the first change request of the proxy node, and adds a memory lock to the distributed lock. The memory lock is used to control the local synchronous access to the distributed lock, and protects the state consistency of the distributed lock in a single proxy node. In the process of directly or indirectly changing the target metadata of the target file by the proxy node according to the distributed lock, the distributed lock will not be revoked, that is, the distributed lock held by the proxy node in the process of modifying the target metadata will not be invalid. Therefore, the target metadata in the proxy node is consistent with the real target metadata in the NAS cluster data, and the problem of target metadata disorder caused by the invalidation of the distributed lock held by the proxy node in the process of changing the target metadata when multiple proxy nodes concurrently change the target metadata of the target file can be improved.

[0030] Please refer to Figure 2 , which shows the flowchart of the distributed data storage control method provided by the embodiment of the present disclosure Figure 1 . As shown in Figure 2 , the distributed data storage control includes the following steps:

[0031] S201: receiving, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change of target metadata of the target file.

[0032] S202: In response to the first change request, the distributed lock management node in the NAS cluster assigns a corresponding distributed lock and returns a first response information to the proxy node; the distributed lock is used to control exclusive access to shared data in the NAS cluster; the first response information is used to notify the successful assignment of the distributed lock.

[0033] In this embodiment, the NAS cluster can include a distributed lock management node and a plurality of data block service nodes. The data block service nodes are responsible for file read and write operations and store file data, and the distributed lock management node is responsible for distributed lock services. In addition, after the data block service nodes perform corresponding operations according to the first change request and cause changes to the target metadata of the target file, the target metadata can be synchronized to the distributed lock management node. The distributed lock management node can store the metadata information of the target file.

[0034] The proxy node can be any one of a plurality of proxy nodes corresponding to the NAS cluster. The target file can be any file shared in the NAS cluster.

[0035] The target metadata can be one or more attributes of the target file, such as a file size attribute representing the size of the target file.

[0036] The proxy node can receive a first change request from a client.

[0037] In some application scenarios, the first change request can directly request to change the target metadata of the target file. For example, a truncate request is sent to the NAS cluster, which can indicate updating the target metadata.

[0038] In some application scenarios, the first change request can indirectly request to change the target metadata of the target file. For example, the first change request can request to change one data of the target file, thereby causing a change to the target metadata.

[0039] In some embodiments, the target metadata is used to represent the file size of the target file; and the first change request includes one of:

[0040] a file append write request, the file append write request is used to request to add file content to the target file; the file content addition operation corresponding to the file append write request is triggered to change the metadata of the target file when the file content addition operation is completed; or

[0041] a metadata update request, the metadata update request is used to request to change the metadata of the target file.

[0042] In some application scenarios, the first change request includes a file append write request. The file append write request writes new file content into the target file, and the file append write request changes the size of the target file. The first change request can include an instruction of target file.write(string). The target file.write() is used to write content into the target file, and the string can include a write range and write content.

[0043] In some application scenarios, the first change request can be a metadata update request for requesting to change the file size. For example, the first change request can include a truncate statement for directly updating the file size. The truncate statement can directly update the file size of the target file. For example, the truncate statement can be used to update the file size of the target file to 0M, that is, directly empty the content of the target file. For another example, the truncate statement can be used to update the target file to a specified size, and the data block service node can delete one or more data blocks at the tail of the target file according to the specified size according to the truncate statement.

[0044] After receiving the first change request, the proxy node can apply for a distributed lock to the distributed management node of the NAS cluster. As an implementation manner, the distributed lock can be a distributed write lock.

[0045] After receiving the application for the distributed lock, the distributed lock management node can detect whether there is an already allocated distributed lock that is mutually exclusive with the distributed lock. If the determination result is yes, a revoke request can be sent to other proxy nodes that have allocated the mutually exclusive distributed lock. After the distributed management node detects that other proxy nodes have revoked the distributed lock according to the revoke request, the distributed lock is allocated to the proxy node.

[0046] After successfully allocating the distributed lock to the proxy node, the distributed lock management node can send a first response information to the proxy node to notify the proxy node that the distributed lock allocation is successful.

[0047] S203: receiving the first response information through the proxy node, configuring a corresponding local memory lock for the distributed lock corresponding to the first change request, and the local memory lock is used to control the local synchronization access to the distributed lock and protect the state consistency of the distributed lock in a single proxy node.

[0048] S204: based on the first change request with the distributed lock and the local memory lock, controlling the change of the target metadata of the target file in the NAS cluster.

[0049] Upon receiving the first response information from the distributed lock management node, the aforementioned proxy node can add a local memory lock to the distributed lock. The local memory lock is used to control local synchronous access to the distributed lock and protect the state consistency of the distributed lock within a single proxy node.

[0050] During the process of directly or indirectly changing the target metadata of the target file according to the first change request, if it is ensured that the distributed lock assigned to the proxy node is not revoked (i.e., not taken away by other proxy nodes), the problem of metadata corruption caused by the inconsistency between the target metadata cached in the proxy node and the real target metadata in the NAS cluster will not occur.

[0051] A local memory lock ensures that only the thread holding the distributed lock and executing the first change request for the target file runs within the local thread pool, while other threads wait. Thus, during the operation corresponding to the first change request, if the distributed lock control node sends a revocation request to the proxy node based on a change request from another proxy node (this revocation request is used to revoke the distributed lock held by the proxy node), the proxy node will not respond to the revocation request because a memory lock has been acquired on the distributed lock, until the operation corresponding to the first change request is completed. This prevents the proxy node from losing its distributed lock and becoming ineffective when executing the operation corresponding to the first change request for the target file's target metadata (e.g., the target file size) based on the distributed lock.

[0052] The first change request is a file append write request for the target file, which changes the file size. After receiving the file append write request, agent node A can request a distributed lock from the distributed lock management node of the NAS cluster.

[0053] Upon receiving the aforementioned request, the distributed lock management node allocates a distributed lock to the proxy node. After allocating the distributed lock to proxy node A, the distributed lock management node can send a first response message to proxy node A, indicating that proxy node A holds the distributed lock.

[0054] After receiving the first response information, agent node A can add a memory lock to the distributed lock it holds. Agent node A then adds new content to the target file based on the first change request that has both a distributed lock and an internal lock (the new content can be the content indicated by the append write request).

[0055] While proxy node A is adding new content to the target file, the distributed lock control node receives a file size update request for the target file from proxy node B. Upon receiving this file size update request, the distributed lock control node detects that proxy node A currently holds the distributed lock and therefore sends a revocation request to proxy node A.

[0056] After receiving the revocation request, the agent node A adds a memory lock to the distributed lock. During the process of adding new content to the target file and updating the file size of the target file in the local cache, the agent node A does not run the revocation request. After the agent node A adds new content to the target file and updates the file size of the target file in the local cache, the revocation request can be run, and the distributed lock held by the agent node A can be revoked according to the revocation request, and the file size of the target file in the local cache can be cleared.

[0057] In this embodiment, the first change request for the target file in the NAS cluster is received by the agent node, and the first change request is used to directly or indirectly trigger the change of the target metadata of the target file; the corresponding distributed lock is allocated by the distributed lock management node in the NAS cluster in response to the first change request, and the first response information is returned to the agent node; the distributed lock is used to control the exclusive access of the shared data in the NAS cluster; the first response information is used to notify the successful allocation of the distributed lock; the corresponding local memory lock is configured for the distributed lock corresponding to the first change request based on the first response information received by the agent node, and the local memory lock is used to control the local synchronous access to the distributed lock and protect the consistency of the state of the distributed lock in a single agent node; based on the first change request with the distributed lock and the local memory lock, the change of the target metadata of the target file in the NAS cluster is controlled. Since the agent node adds a memory lock to the distributed lock, the agent node is prevented from being stolen by other agent nodes during the process of performing direct or indirect change operations on the target metadata of the target file based on the held distributed lock, and thus the problem of metadata disorder caused by the distributed lock allocated by the agent node being stolen by other agent nodes can be avoided.

[0058] In some embodiments, the step S203 includes:

[0059] First, after adding the memory lock to the distributed lock, it is detected whether the distributed lock is currently valid.

[0060] Second, in response to detecting that the distributed lock is valid, the first change request is sent to the data block access node of the NAS cluster to change the file content of the target file by the data block access node.

[0061] After acquiring a memory lock on the distributed lock, the proxy node checks whether the distributed lock is still valid (whether it still holds the distributed lock). For example, it checks if a revocation request was received and responded to during the acquisition of the memory lock. If no revocation request was received, or if a revocation request was received but not responded to, the distributed lock it holds is considered valid after acquiring the memory lock. If the distributed lock with the local memory lock is valid, the proxy node can send a first change request with both the distributed lock and the memory lock to the data block service node. Upon receiving the first change request, the data block service node responds by performing the corresponding operation on the target file, thereby changing the target metadata of the target file. After the data block service node performs the above operation, the proxy node can obtain and cache the target metadata after the above operation. After the first change request is completed, the proxy node can release the memory lock and the distributed lock.

[0062] In some embodiments, step S203 above includes the following steps:

[0063] First, in response to the detection that the distributed lock is invalid, the proxy node releases the memory lock and resends the distributed lock request to the distributed lock management node.

[0064] Secondly, after receiving the first response information from the distributed lock management node for the first change request to reallocate the distributed lock, the local memory lock is reconfigured for the allocated distributed lock.

[0065] In these embodiments, after adding a memory lock to the distributed lock, it checks whether the distributed lock is still valid (whether it still holds the distributed lock). If it is invalid, it means that the distributed lock on the proxy node was revoked during the process of requesting the distributed lock and configuring the memory lock. That is, the proxy node has lost the distributed lock and needs to re-request the distributed lock from the distributed lock management node. Therefore, it needs to release the memory lock and then re-request the distributed lock. After regaining the distributed lock, a local memory lock is then configured on the distributed lock.

[0066] Please refer to Figure 3 , Figure 3 Illustrative flow of the data access method provided in this disclosure Figure 2 .like Figure 3 As shown, the method includes the following steps:

[0067] S301: Receives the first change request for a target file in the NAS cluster through the agent node. The first change request is used to directly or indirectly trigger changes to the target metadata of the target file. The first change request is a file append write request.

[0068] S302: In response to the first change request, the distributed lock management node in the NAS cluster allocates a corresponding distributed lock and returns a first response information to the proxy node; the distributed lock is used to control exclusive access to shared data in the NAS cluster; the first response information is used to notify the successful allocation of the distributed lock.

[0069] S303: The proxy node receives the first response information and configures a corresponding local memory lock for the distributed lock corresponding to the first change request; the local memory lock is used to control local synchronization access to the distributed lock and protect the consistency of the state of the distributed lock in a single proxy node.

[0070] The steps S301-S303 can refer to the steps S201-S203 shown in Figure 2 The steps S201-S203 are not described here.

[0071] S304: The proxy node obtains a first file size of the target file from the distributed management node, wherein the distributed management node stores the file size of the target file.

[0072] S305: Determine a second file size obtained by appending the content of the target file according to the first change request.

[0073] S306: If it is detected that the second file size is smaller than the first file size, the first change request is changed to an overwrite request, and the local memory lock is released; the overwrite request is used to request to modify the existing part of the content of the target file.

[0074] S307: Based on the allocated distributed lock, send an overwrite request to the NAS cluster to complete the overwrite of part of the content of the target file.

[0075] Since the NAS cluster corresponds to multiple proxy nodes, each proxy node provides services for multiple clients. Therefore, it is possible that different proxy nodes respectively request a distributed lock from the distributed lock management node according to the received first change request of the client, and send the first change request to the NAS cluster based on the distributed lock and the memory lock. Due to the existence of the memory lock and the distributed lock, only one proxy node can modify the target metadata of the target file at the same time. The first change request of the other proxy node is in a waiting state. If the other proxy node is allocated a distributed lock, the other proxy node can add a memory lock to the held distributed lock. After the other proxy node adds a memory lock to the distributed lock, the other proxy node can send a file size obtaining request of the target file to the distributed lock management node in the NAS cluster.

[0076] The distributed lock management node can send a first file size of the stored target file to the proxy node according to the file size request. After receiving the first file size sent by the distributed management node, the proxy node can determine a second file size obtained after content addition of the target file indicated by the first change request of the proxy node. Then, it is judged whether the first file size is less than or equal to the second file size. If yes, the file addition write request indicates that the content addition of the target file has been performed by other proxy nodes, and the first file size obtained after the content addition exceeds the file size corresponding to the request of the proxy node. In this way, after the operation corresponding to the first change request of the proxy node is performed, the file size of the target file will not change, and thus the distributed lock allocated during the execution of the operation corresponding to the first change request of the proxy node will not cause metadata confusion even if it is revoked, so that the local memory lock can be released. After the local memory lock is released, the distributed lock can be immediately obtained when the concurrent addition write is initiated by other proxy nodes, thereby improving the concurrency performance between multiple proxy nodes.

[0077] For example, three proxy nodes initiate concurrent addition write to the target file: proxy node 1 writes [0M, 100M), proxy node 2 writes [0M, 200M), and proxy node 3 writes [200M, 300M). Assuming that proxy node 2 first acquires the size distributed write lock and adds the memory lock, the distributed lock applications of proxy node 1 and proxy node 3 will be blocked. After waiting for proxy node 2 to complete the addition write and release the memory lock, assuming that proxy node 1 acquires the distributed lock before proxy node 3, proxy node 1 acquires the distributed lock and adds the memory lock, and then detects that the write request of proxy node 1 becomes an overwrite request, proxy node 1 can immediately release the memory lock. After proxy node 1 releases the memory lock, proxy node 3 can successfully apply for the distributed lock, so that proxy node 1 and proxy node 3 can implement concurrent file addition write requests to the target file.

[0078] In the embodiment, it is described that after the proxy node adds the memory lock to the distributed lock, it is detected that the file addition write request becomes an overwrite request, and the memory lock is released, so that the concurrency performance between multiple proxy nodes can be improved.

[0079] In some embodiments, the above target metadata is used to represent the file size of the target file, Figure 2 The step S203 of the embodiment shown Figure 3 The step S303 of the embodiment shown includes:

[0080] If the first change request is a file addition write request, a local memory read lock is configured for the distributed lock;

[0081] If the first change request is a metadata update request, a local memory write lock is configured for the distributed lock; wherein the memory locks corresponding to the same metadata exist the following mutual exclusion rules: the memory read lock is compatible with the memory read lock, the memory read lock is mutually exclusive with the memory write lock, and the memory write lock is mutually exclusive with the memory write lock.

[0082] In some application scenarios, the first change request is a file append write request for increasing the content of the target file. Since each proxy node provides services to multiple clients, each client can send a file append write request, so there are multiple concurrent file append write requests in each proxy node, and the performance of the append write of a single proxy node must be ensured. For the file append write request, a memory read lock is configured, because the read lock is compatible with the read lock, and the memory read lock is used for multiple file append write requests, so that the proxy node can concurrently send file append write requests to the data block service node of the NAS cluster, thereby improving the concurrent performance of the file append write request.

[0083] If the concurrent file append write requests in the proxy node are not subject to the above constraints, assume that thread 1 of the proxy node first completes the [1M, 2M) append content write to the target file in the data block service node, and then changes the file size to 2M. Subsequently, thread 2 completes the [0, 1M) append content write to the target file in the data block service node, and then changes the file size to 1M. However, the file append write request of thread 2 is treated as an overwrite write request by the distributed management node, and therefore, the file append write request of thread 2 does not update the file size of the target file in the distributed management node, that is, the file size of the target file in the distributed management node is 2M. However, the file size cached in the proxy node is 1M, resulting in inconsistency between the file sizes of the target file in the proxy node and the distributed management node.

[0084] Therefore, in the concurrent file append write request scenario, the proxy node determines the second file size corresponding to each file append write request after the first change request is executed on the target file, respectively. Only the file append write request corresponding to the second file size greater than or equal to the second file size corresponding to other file append write requests is executed, that is, only the file append write request that causes the file size to increase is executed, thereby ensuring the consistency of the file size of the target file. After the proxy node completes the content append to the target file in the data block service node, the file size of the target file can be updated.

[0085] In some application scenarios, the first change request is an update request for the target metadata. Different update requests for the target metadata in the same proxy node need to be mutually exclusive, otherwise the target metadata of the target file in the proxy node and the target metadata of the target file in the data block service node will be inconsistent.

[0086] Assuming that the current file size of the target file is 1M, two threads in a single proxy node concurrently request to update the target metadata. The update request 1 of thread 1 updates the file size to 0M; the update request of thread 2 updates the file size of the target file to 2M. The proxy node sends the update request 1 and the update request 2 to the data block service node at the same time. Assuming that the data block service node completes the update request 1 first and then the update request 2. Finally, the data block service node changes the file size of the target file to 2M. However, when the proxy node processes the two update requests, it cannot guarantee the order of sending each update request to the NAS cluster. If the update request 1 is sent later, the proxy node will update the file size of the target file on the data block service node to 0 based on the memory read lock and the distributed lock, and the file size in the data block service node can be synchronized to the distributed management node storage. However, the file size cached by the proxy node is 2M, so the target metadata of the target file in the proxy node and the distributed management node will be inconsistent due to the concurrency of the update request. Therefore, the update request for the target metadata needs to be configured with a memory write lock to ensure the consistency of the target metadata.

[0087] In these embodiments, by adding a memory read lock to the file append write request and using a memory write lock for the update request, the parallel processing capability of a single proxy node can be increased while ensuring the consistency of the target metadata of the target file.

[0088] Reference is made to Figure 4 , Figure 4 a schematic flow of the data access method provided by the present disclosure Figure 3 . As shown in Figure 4 , the method comprises the following steps:

[0089] S401: receiving, by a proxy node, a read request for target metadata of a target file.

[0090] S402: responding, by a distributed lock management node in a NAS cluster, to the read request, determining a distributed read lock of the read request, and determining whether there is a distributed lock that is mutually exclusive with the distributed read lock.

[0091] S403: if it is determined that there is a distributed lock that is mutually exclusive with the distributed read lock, feeding back second response information to the proxy node, the second response information comprising rejection information rejecting to allocate the corresponding distributed read lock to the proxy node.

[0092] S404: sending temporary target metadata to the proxy node, so that the proxy node returns the temporary target metadata to a client sending the read request.

[0093] In an embodiment, the proxy node can receive a read request of target metadata of a target file sent by a client. The proxy node sends a distributed read lock request to the distributed lock management node according to the received read request of target metadata. Since it is a metadata read request, the read request does not change the size of the metadata.

[0094] After receiving the request of the proxy node for applying for a read lock of target metadata (for example, the size of the target file), in order to reduce the impact of unnecessary distributed lock revocation on the first change request, if the distributed lock management node detects that a distributed lock has been allocated for the first change request of another proxy node, the distributed lock management node can refuse to allocate a distributed read lock for the read request of the proxy node, and only returns a temporary file size to the proxy node. The temporary file size can be the file size of the target file stored in the distributed management node. After receiving the temporary file size, the proxy node can use the temporary metadata in the context of the corresponding operation requested by the client, and does not cache it.

[0095] In this embodiment, it is described that if the proxy node receives a read request of target metadata of a target file, the proxy node can send a distributed read lock request to the distributed lock management node, if another proxy node uses a distributed lock that is mutually exclusive with the distributed read lock, the distributed read lock is not allocated for the request, the temporary target metadata is obtained, and the temporary target metadata is returned, thereby reducing the contention of distributed locks among multiple proxy nodes, and improving the concurrent read-write performance.

[0096] In Figure 4 In the embodiment shown in the figure, the above method further includes the following steps:

[0097] First, if it is determined that there is no distributed lock that is mutually exclusive with the distributed read lock corresponding to the read request, the distributed read lock is allocated for the read request, and a third response information is returned to the proxy node, the third response information includes information that the distributed read lock is successfully allocated for the read request.

[0098] Second, the proxy node reads the information of the target metadata from the NAS cluster based on the distributed read lock. In some application scenarios, if the distributed lock management node detects that no distributed write lock has been allocated to another proxy node, the distributed lock can be allocated for the read lock request.

[0099] In some application scenarios, if the distributed lock management node detects that the distributed lock allocated for the first change request of another proxy node has been revoked, the distributed read lock can be allocated for the read request of the target metadata of the proxy node. The proxy node can read the information of the target metadata from the distributed management node of the NAS cluster based on the allocated distributed read lock.

[0100] In some embodiments, the distributed lock management node described above can revoke the distributed lock based on one or more of the following:

[0101] The holding time of the distributed lock by the other proxy node exceeds a first preset time length;

[0102] The other proxy node holding the distributed lock does not perform the operation corresponding to the first change request within a second preset time length.

[0103] That is, if the distributed write lock is allocated to the other proxy node, the holding time of the distributed write lock by the other proxy node exceeds the first preset time length, and the distributed write lock of the other proxy node can be revoked.

[0104] Alternatively, the other proxy node holding the distributed write lock does not perform an operation that directly or indirectly causes the target metadata to be updated within a second preset time length, and the distributed lock allocated to the other proxy node can be revoked.

[0105] The first preset time length and the second preset time length described above can be set according to specific application scenarios, which are not limited here.

[0106] By using the revocation conditions described above, the distributed lock held by the proxy node can be revoked when there is no conflict with other write requests, so as to allocate a distributed read lock to other requests.

[0107] After receiving the request of the proxy node to apply for the distributed read lock, in order to reduce the unnecessary revocation of the distributed lock allocated to the first change request and affect the execution of the operation corresponding to the first change request, the distributed lock management node can not allocate the distributed read lock to the proxy node after finding that the distributed lock has been allocated to the first change request of the other proxy node, and only returns the temporary size metadata.

[0108] However, if the temporary size metadata is returned every time the read lock is applied, assuming that there is no first change request subsequently and the target metadata no longer changes, the read request of the target metadata of the other proxy node needs to make a remote procedure call to the distributed lock management node to obtain the file size of the target file each time, which will affect the performance of the distributed lock management node.

[0109] Therefore, in the scenario where the target metadata of the target file does not change for a long time, the distributed lock management node can revoke the distributed lock allocated to the first change request, and allocate a distributed read lock to the read request of the target metadata. The proxy node can obtain the target metadata from the distributed lock management node according to the distributed read lock. In this way, the proxy node holding the distributed read lock can directly read from its own cache and return to the client when receiving the target metadata read request of the target file from the client, reducing the resource overhead required for remote procedure call to the distributed lock management node.

[0110] As an example, please refer to Figure 5 , Figure 5 for an application scenario. As shown in Figure 5 , the proxy node receives a first change request, determines that the first change request is a write request for writing file content of a target file, detects whether it holds a distributed read lock, and in response to determining that it does not hold the distributed read lock, applies for a distributed read lock from a distributed lock management node. After determining that it holds the distributed read lock, it detects whether the write request is an overwrite write. If it is detected that the write request is an overwrite write, a distributed read request is used to send an overwrite write request to a NAS cluster (for example, to a data block service node) to overwrite an existing part of the content of the target file. The proxy node receives a return result fed back by the NAS cluster according to the overwrite write request. The overwrite write does not update the file size of the target file.

[0111] If it is detected that the write request is a file append write request, it is detected whether the proxy node holds a distributed write lock. If it does not hold the distributed write lock, it applies for a distributed write lock from the distributed lock management node. After receiving a first response information returned by the distributed lock management node that a distributed write lock has been allocated for the first change request, a local memory lock is added to the distributed write lock of the first change request. If the memory lock fails, the memory lock is added again. If the memory lock is successfully added, it is detected whether the distributed write lock with the added memory lock is still valid. If it is not valid, the distributed memory write lock is applied for again from the distributed lock management node. The memory lock is added to the distributed memory write lock allocated by the distributed lock management node.

[0112] If the distributed write lock with the added memory lock is valid, the first change request with the distributed write lock and the memory lock is sent to the data block service node. The data block service node can respond to the first change request, and the data block service node can complete an append write operation on the content of the target file according to the first response information. After the completion of the append write operation corresponding to the first change request, the data block service node updates the file size and saves the updated file size to the distributed lock management node. Then the proxy node releases the memory lock and the distributed write lock.

[0113] When determining whether the write request is an append write or an overwrite write, the first file size of the target file obtained from the distributed lock management node can be compared with a second file size indicated by the first change request. If the first file size is greater than or equal to the second file size, the first change request becomes an overwrite write request, otherwise the first change request is a file append write request.

[0114] In these embodiments, in order to prevent the distributed write lock from being revoked between the application of the distributed write lock and the application of the memory lock, it can be detected whether the distributed write lock is valid after the memory lock is applied to the distributed write lock. If it is invalid, the distributed write lock is re-applied. In this way, the target metadata can be prevented from being confused due to the revocation of the distributed write lock between the application of the distributed write lock and the application of the memory lock and the distributed write lock being grabbed by other proxy nodes.

[0115] Corresponding to the above Figure 2 The distributed data storage control method of the embodiments, Figure 6 An illustrative structural block diagram of a distributed data storage control apparatus provided by the embodiments of the present disclosure is shown. For ease of illustration, only parts related to the embodiments of the present disclosure are shown. Refer to Figure 6 The apparatus 60 includes a receiving unit 601, an allocating unit 602, a configuring unit 603, and an executing unit 604. Among them,

[0116] The receiving unit 601 is configured to receive, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change of target metadata of the target file;

[0117] The allocating unit 602 is configured to allocate, by a distributed lock management node in the NAS cluster, a corresponding distributed lock in response to the first change request and return a first response information to the proxy node; the distributed lock is used to control exclusive access to shared data in the NAS cluster; and the first response information is used to notify that the distributed lock is successfully allocated;

[0118] The configuring unit 603 is configured to receive, by the proxy node, the first response information, configure a corresponding local memory lock for the distributed lock corresponding to the first change request, and the local memory lock is used to control local synchronous access to the distributed lock and protect the state consistency of the distributed lock in a single proxy node;

[0119] The executing unit 604 is configured to control the change of the target metadata of the target file in the NAS cluster based on the first change request with the distributed lock and the local memory lock.

[0120] In some embodiments, the target metadata is used to represent the file size of the target file; and the first change request includes one of:

[0121] a file append write request, the file append write request being used to request to increase file content for the target file; the metadata change of the target file being triggered when a file content increase operation corresponding to the file append write request is executed; or

[0122] a metadata update request, the metadata update request being used to request to change the metadata of the target file.

[0123] In some embodiments, the first change request is a file append write request, and the receiving unit 601 is further configured to:

[0124] If the first change request is a file append write request, a local memory read lock is configured for the distributed lock;

[0125] If the first change request is a metadata update request, a local memory write lock is configured for the distributed lock; wherein the memory locks corresponding to the same metadata exist the following mutual exclusion rules: the memory read lock is compatible with the memory read lock, the memory read lock is mutually exclusive with the memory write lock, and the memory write lock is mutually exclusive with the memory write lock.

[0126] In some embodiments, the execution unit 603 is further configured to:

[0127] detect whether the distributed lock is currently valid;

[0128] In response to detecting that the distributed lock is valid, the first change request is sent to a data block access node of the NAS cluster by the proxy node, so that the data block access node completes the operation corresponding to the first change request.

[0129] In some embodiments, the execution unit 603 is further configured to:

[0130] In response to detecting that the distributed lock is invalid, the proxy node releases the memory lock and resends the distributed lock request to the distributed lock management node;

[0131] After obtaining the first response information in which the distributed lock management node reassigns the distributed lock for the first change request, the local memory lock is reconfigured for the assigned distributed lock.

[0132] In some embodiments, the first change request is a file append write request, and after the proxy node configures the corresponding local memory lock for the distributed lock corresponding to the first change request, the method further comprises:

[0133] The proxy node obtains a first file size of the target file from the distributed management node, wherein the distributed management node stores the file size of the target file;

[0134] determine a second file size obtained by appending the content of the target file according to the first change request;

[0135] If it is detected that the second file size is smaller than the first file size, the first change request is changed to an overwrite write request, and the local memory lock is released; the overwrite write request is used to request to modify the existing part of the content of the target file;

[0136] Based on the distributed lock that has been assigned, the overwrite write request is sent to the NAS cluster to complete the overwrite of the part of the content of the target file.

[0137] In some embodiments, the apparatus further comprises a reading unit (not shown in the figure) configured to:

[0138] receiving, by the proxy node, a read request for target metadata of a target file;

[0139] determining, by the distributed lock management node in the NAS cluster in response to the read request, a distributed read lock of the read request, and determining whether there exists a distributed lock that is mutually exclusive with the distributed read lock;

[0140] if it is determined that there exists a distributed lock that is mutually exclusive with the distributed read lock, feeding back second response information to the proxy node, the second response information comprising rejection information rejecting allocation of the corresponding distributed read lock to the proxy node;

[0141] sending temporary target metadata to the proxy node, so that the proxy node returns the temporary target metadata to a client sending the read request.

[0142] In some embodiments, the apparatus further comprises a reading unit further configured to:

[0143] if it is determined that there exists no distributed lock that is mutually exclusive with the distributed read lock corresponding to the read request, allocating a distributed read lock for the read request, and returning third response information to the proxy node, the third response information comprising information of successfully allocating the distributed read lock for the read request;

[0144] reading, by the proxy node, information of the target metadata from the NAS cluster based on the distributed read lock.

[0145] To implement the above-mentioned embodiments, the present disclosure further provides an electronic device.

[0146] Reference Figure 7 , which shows a structural schematic diagram of an electronic device Figure 7 adapted to be used to implement the embodiments of the present disclosure. The electronic device 700 can be a terminal device or a server. Among them, the terminal device can include but is not limited to mobile terminals such as mobile phones, notebook computers, digital broadcast receivers, personal digital assistants (PDA), tablet computers (Portable Android Device, PAD), portable multimedia players (Portable Media Player, PMP), vehicle-mounted terminals (such as vehicle-mounted navigation terminals), etc., and fixed terminals such as digital TVs, desktop computers, etc. Figure 7 The electronic device shown is only an example and should not impose any limitation on the functions and use range of the embodiments of the present disclosure.

[0147] As Figure 7As shown, the electronic device 700 can include a processing device (e.g., a central processor, a graphics processor, etc.) 701 that can perform various suitable actions and processes in accordance with programs stored in a Read Only Memory (ROM) 702 or loaded from a storage device 708 into a Random Access Memory (RAM) 703. Various programs and data required by the electronic device 700 for operation are also stored in the RAM 703. The processing device 701, the ROM 702, and the RAM 703 are connected to each other by a bus 704. An input / output (I / O) interface 705 is also connected to the bus 704.

[0148] Generally, the following devices can be connected to the I / O interface 705: input devices 706 including, for example, a touch screen, a touch pad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; output devices 707 including, for example, a Liquid Crystal Display (LCD), a speaker, a vibrator, etc.; storage devices 708 including, for example, a magnetic tape, a hard disk, etc.; and communication devices 709. The communication devices 709 can allow the electronic device 700 to communicate wirelessly or wired with other devices to exchange data. Although Figure 7 The electronic device 700 is shown with various devices, but it should be understood that not all of the shown devices are required to be implemented or present. More or fewer devices can alternatively be implemented or present.

[0149] In particular, the processes described above with reference to the flowcharts can be implemented as a computer software program according to embodiments of the present disclosure. For example, embodiments of the present disclosure include a computer program product comprising a computer program (computer-executable instructions) carried on a computer-readable medium, the computer program containing program code for performing the methods illustrated by the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via the communication devices 709, or installed from the storage devices 708, or installed from the ROM 702. When the computer program is executed by the processing device 701, the above-mentioned functions defined in the methods of embodiments of the present disclosure are performed.

[0150] It should be noted that the computer-readable medium in the above disclosure can be a computer-readable signal medium or a computer-readable storage medium or any combination of the two. The computer-readable storage medium may, for example, but is not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or apparatus, or any combination of the above. More specific examples of the computer-readable storage medium can include, but are not limited to, an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, the computer-readable storage medium can be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, device or apparatus. In the present disclosure, the computer-readable signal medium can include a data signal carried in a baseband or as a part of a carrier wave, which carries computer-readable program code. Such a propagated data signal can take many forms, including but not limited to an electromagnetic signal, an optical signal or any suitable combination of the above. The computer-readable signal medium can also be any computer-readable medium other than the computer-readable storage medium, which can send, propagate or transmit a program for use by or in conjunction with an instruction execution system, device or apparatus. The program code contained in the computer-readable medium can be transmitted by any suitable medium, including but not limited to a wire, a cable, an RF (radio frequency) or the like, or any suitable combination of the above.

[0151] The computer-readable medium described above can be contained in the electronic device described above; or can exist separately and not be assembled into the electronic device.

[0152] The computer-readable medium described above carries one or more programs, which, when executed by the electronic device, cause the electronic device to perform the methods shown in the above embodiments.

[0153] Computer program code for carrying out operations of the present disclosure can be written in any combination of one or more programming languages, including an object oriented programming language such as Java, Smalltalk, C++ or the like and conventional procedural programming languages, such as the "C" programming language or similar programming languages. The program code can execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer or entirely on the remote computer or server. In the latter scenario, the remote computer can be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection can be made to an external computer (for example, through the Internet using an Internet Service Provider).

[0154] The computer program instructions can also be loaded onto a computer or other programmable information processing apparatus to cause a series of operations to be performed on the computer or other programmable information processing apparatus to produce a computer implemented process such that the instructions which execute on the computer or other programmable information processing apparatus implement the functions / acts specified in the flowchart and / or block diagram block or blocks.

[0155] The units described in the embodiments of the present disclosure can be implemented by hardware, software, or a combination of hardware and software. In some cases, the names of the units do not constitute a limitation on the units themselves.

[0156] The functions described in this specification can be implemented in part or in whole through one or more hardware logic components. For example, and without limitation, illustrative types of hardware logic components that can be used include Field-programmable Gate Arrays (FPGAs), Program-specific Integrated Circuits (ASICs), Program-specific Standard Products (ASSPs), System-on-a-chip systems (SOCs), Complex Programmable Logic Devices (CPLDs), etc.

[0157] In the context of this disclosure, a machine-readable medium can be a tangible medium that contains or stores a program for use by or in connection with an instruction execution system, apparatus, or device. The machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include but is not limited to an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any suitable combination of the foregoing. More specific examples of the machine-readable storage medium would include a lined- up electrical connection, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0158] The above description is only preferred embodiments of the present disclosure and the explanation of the applied technical principles. It should be understood by those skilled in the art that the disclosure range involved in the present disclosure is not limited to the technical solutions formed by the specific combinations of the above technical features, and also covers other technical solutions formed by any combination of the above technical features or equivalent features without departing from the above disclosed concept. For example, the technical solutions formed by replacing the above features with the technical features disclosed in the present disclosure (but not limited to) having similar functions.

[0159] In addition, although each operation is described in a particular order, this should not be understood as requiring the operations to be performed in the specific order shown or in a sequential order. In certain circumstances, multitasking and parallel processing can be advantageous. Similarly, although several implementation details are included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Certain features described in the context of separate embodiments can also be combined in a single embodiment. Conversely, various features described in the context of a single embodiment can also be separated and implemented in multiple embodiments.

[0160] Although the subject matter has been described in language specific to structural features and / or methodological acts, it is to be understood that the subject defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are disclosed as example forms of implementing the claims.

Claims

1. A distributed data storage control method characterized by, The method comprises: receiving, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change to target metadata of the target file; allocating, by a distributed lock management node in the NAS cluster, a corresponding distributed lock in response to the first change request and returning first response information to the proxy node; the distributed lock is used to control exclusive access to shared data in the NAS cluster; the first response information is used to notify the successful allocation of the distributed lock; receiving, by the proxy node, the first response information, configuring a corresponding local memory lock for the distributed lock corresponding to the first change request, the local memory lock being used to control local synchronization access to the distributed lock and protect the consistency of the state of the distributed lock within a single proxy node; controlling the change to the target metadata of the target file in the NAS cluster based on the first change request with the distributed lock and the local memory lock.

2. The method of claim 1, wherein, The target metadata is used to represent the file size of the target file; and the first change request comprises one of: a file append write request, the file append write request being used to request an increase in file content for the target file; the metadata change of the target file being triggered when the file content increase operation corresponding to the file append write request is completed; or, a metadata update request, the metadata update request being used to request a change to the metadata of the target file.

3. The method of claim 2, wherein, The receiving, by the proxy node, the first response information, and configuring the corresponding local memory lock for the distributed lock corresponding to the first change request comprises: if the first change request is the file append write request, configuring a local memory read lock for the distributed lock; if the first change request is the metadata update request, configuring a local memory write lock for the distributed lock; wherein the memory locks corresponding to the same metadata have the following mutual exclusion rules: a memory read lock is compatible with a memory read lock, a memory read lock is mutually exclusive with a memory write lock, and a memory write lock is mutually exclusive with a memory write lock.

4. The method of claim 2, wherein, The controlling the change to the target metadata of the target file in the NAS cluster based on the first change request with the distributed lock and the local memory lock comprises: detecting whether the distributed lock is currently valid; in response to detecting that the distributed lock is valid, sending, by the proxy node, the first change request to a data block access node of the NAS cluster, and controlling the data block access node to perform an operation corresponding to the first change request.

5. The method of claim 4, wherein, The controlling the change to the target metadata of the target file in the NAS cluster based on the first change request with the distributed lock and the local memory lock further comprises: in response to detecting that the distributed lock is invalid, the proxy node releases the memory lock and resends a distributed lock request to the distributed lock management node; after obtaining first response information in which the distributed lock management node reallocates a distributed lock for the first change request, reconfiguring a local memory lock for the allocated distributed lock.

6. The method of claim 2, wherein, The first change request is an append write request, and after the proxy node configures a corresponding local memory lock for the distributed lock corresponding to the first change request, the method further includes: The proxy node obtains a first file size of the target file from the distributed lock management node, where the distributed lock management node is configured to store file sizes of the target file; Determining a second file size obtained by appending content of the target file according to the first change request; If it is detected that the second file size is smaller than the first file size, the first change request is changed to an overwrite request, and the local memory lock is released; the overwrite request is used to request to modify the existing part of the content of the target file; Based on the distributed lock allocated, an overwrite request is sent to the NAS cluster to complete the overwrite of the part of the content of the target file.

7. The method of claim 1, wherein, The method further includes: receiving, by a proxy node, a read request for target metadata of the target file; determining, by a distributed lock management node in the NAS cluster, a distributed read lock of the read request and determining whether there is a distributed lock that is mutually exclusive with the distributed read lock in response to the read request; if it is determined that there is a distributed lock that is mutually exclusive with the distributed read lock, feeding back second response information to the proxy node, the second response information including rejection information rejecting allocation of a corresponding distributed read lock to the proxy node; sending temporary target metadata to the proxy node, so that the proxy node returns the temporary target metadata to a client sending the read request.

8. The method of claim 7, wherein, The method further includes: if it is determined that there is no distributed lock that is mutually exclusive with the distributed read lock corresponding to the read request, allocating a distributed read lock for the read request and returning third response information to the proxy node, the third response information including information that the distributed read lock is successfully allocated for the read request; reading, by the proxy node, information of the target metadata from the distributed lock management node based on the distributed read lock.

9. A distributed data storage control device, comprising: a receiving unit configured to receive, by a proxy node, a first change request for a target file in a NAS cluster, the first change request being used to directly or indirectly trigger a change to target metadata of the target file; an allocation unit configured to allocate, by a distributed lock management node in the NAS cluster, a corresponding distributed lock in response to the first change request and return first response information to the proxy node; the distributed lock is used to control exclusive access to shared data in the NAS cluster; the first response information is used to notify the success of distributed lock allocation; a configuration unit configured to receive, by the proxy node, the first response information, configure a corresponding local memory lock for the distributed lock corresponding to the first change request, the local memory lock being used to control local synchronous access to the distributed lock and protect the consistency of the state of the distributed lock within a single proxy node; An execution unit is configured to control a change to target metadata of the target file in the NAS cluster based on the first change request with the distributed lock and the local memory lock.

10. An electronic device, comprising: Comprise: A processor and a memory; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor executes the method in any one of claims 1 to 8.

11. A computer readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, and when the processor executes the computer-executable instructions, the method in any one of claims 1 to 8 is realized.

Citation Information

Patent Citations

  • Request processing method and device

    CN112804279A

  • System and Method for Consistent Metadata Access Based on Local Locks Semantics in a Multi-Node Cluster

    US20220350787A1