WO2020259146A1 - 一种资源锁管理方法及装置 - Google Patents

一种资源锁管理方法及装置 Download PDF

Info

Publication number
WO2020259146A1
WO2020259146A1 PCT/CN2020/091650 CN2020091650W WO2020259146A1 WO 2020259146 A1 WO2020259146 A1 WO 2020259146A1 CN 2020091650 W CN2020091650 W CN 2020091650W WO 2020259146 A1 WO2020259146 A1 WO 2020259146A1
Authority
WO
WIPO (PCT)
Prior art keywords
node
lock
resource
nodes
exclusive
Prior art date
Application number
PCT/CN2020/091650
Other languages
English (en)
French (fr)
Inventor
朴君
Original Assignee
华为技术有限公司
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by 华为技术有限公司 filed Critical 华为技术有限公司
Publication of WO2020259146A1 publication Critical patent/WO2020259146A1/zh
Priority to US17/557,926 priority Critical patent/US20220114145A1/en

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores
    • G06F9/526Mutual exclusion algorithms
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F15/00Digital computers in general; Data processing equipment in general
    • G06F15/16Combinations of two or more digital computers each having at least an arithmetic unit, a program unit and a register, e.g. for a simultaneous processing of several programs
    • G06F15/163Interprocessor communication
    • G06F15/173Interprocessor communication using an interconnection network, e.g. matrix, shuffle, pyramid, star, snowflake
    • G06F15/17306Intercommunication techniques
    • G06F15/17331Distributed shared memory [DSM], e.g. remote direct memory access [RDMA]
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/17Details of further file system functions
    • G06F16/176Support for shared access to files; File sharing support
    • G06F16/1767Concurrency control, e.g. optimistic or pessimistic approaches
    • G06F16/1774Locking methods, e.g. locking methods for file systems allowing shared and concurrent access to files
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/10File systems; File servers
    • G06F16/18File system types
    • G06F16/182Distributed file systems
    • G06F16/1824Distributed file systems implemented using Network-attached Storage [NAS] architecture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/52Program synchronisation; Mutual exclusion, e.g. by means of semaphores

Definitions

  • This application relates to the field of communication technology, and in particular to a resource lock management method and device.
  • the distributed file system contains multiple nodes, and files are stored in some nodes in a distributed manner, and other nodes can access the node through the network to perform read and write operations on the file.
  • the distributed file system may also be called a shared storage file system.
  • nodes can manage files stored in other nodes through a resource lock mechanism to improve the efficiency and security of file management.
  • Resource locks include exclusive locks and shared locks. Among them, the node can view, modify and delete the file by adding an exclusive lock to the file, and after the exclusive lock is added to the file, it cannot add any type of resource lock; the node can view the file by adding a shared lock to the file. Cannot modify or delete the file.
  • the distributed file system can adopt the distributed lock manager (DLM) technology of the decentralized architecture or the semi-distributed lock manager (SDLM) technology of the centralized architecture to realize the
  • DLM distributed lock manager
  • SDLM semi-distributed lock manager
  • the principle of DLM technology is: communication based on transmission control protocol (TCP)/internet protocol (IP), where the DLM runs on each computer in the cluster and has a lock database with the cluster scope. The same copy, thereby achieving synchronous access to shared resources.
  • TCP transmission control protocol
  • IP internet protocol
  • the principle of SDLM technology is: the storage server centrally processes lock requests, thereby achieving synchronous access to shared resources.
  • the prior art has the problem of locked nodes and locked starvation when performing distributed system management.
  • the present application provides a resource lock management method and device, which are used to avoid the problem of lock nodes and lock starvation when performing distributed system management in the prior art.
  • an embodiment of the present application provides a resource lock management method, including:
  • the first node determines to add a resource lock to the target resource, and obtains resource lock information corresponding to the target resource, where the resource lock information is used to characterize whether the target resource has added a resource lock, and the queue of waiting nodes requesting to add the resource lock Information, the type of the resource lock is an exclusive lock or a shared lock; the first node determines whether the first resource lock addition condition is satisfied according to the resource lock information; if so, the first node adds to the target resource Resource lock, and update the resource lock information, so that the updated resource lock information indicates that the target resource has added a resource lock; otherwise, the first node queues up for adding a resource lock, and updates the resource lock Information, so that the updated resource lock information indicates that the first node has joined the waiting node queue; and the resource lock information is monitored until it is determined that the resource lock information satisfies the second resource lock addition condition , Adding a resource lock to the target resource, and updating the resource lock information so that the updated resource lock information characterizes: the target resource has added
  • the first node when the first node adds a resource lock to the target resource, it performs a lock operation according to the resource lock information corresponding to the target resource, where it can be determined whether the target resource is currently Adding resource locks and the queue information of nodes requesting to add resource locks effectively improves the problem of locked nodes and starvation during distributed system management.
  • node can refer to physical devices, such as a physical server, virtual machines, containers, and other virtualized devices, or it can be considered as a thread or process in an operating system used for computing and processing. element.
  • the acquiring, by the first node, the resource lock information corresponding to the target resource includes: the first node locally acquiring the resource lock information corresponding to the target resource; or The first node obtains the resource lock information corresponding to the target resource from the second node.
  • the first node of the present application may obtain the resource lock information corresponding to the target resource locally, or obtain the resource lock information corresponding to the target resource from a second node.
  • the obtaining, by the first node, the resource lock information corresponding to the target resource from the second node includes: the first node determining the storage of the target resource The second node; the first node obtains the resource lock information corresponding to the target resource from the second node.
  • this application describes in detail how the first node obtains the resource lock information corresponding to the target resource from the second node.
  • the first node determining the second node storing the target resource includes: the first node determining the master node of the first node according to a master-slave node mapping relationship Is the second node.
  • the present application provides a mapping rule between a first node and a second node, so that the first node determines the corresponding second node according to the mapping rule.
  • that the first node obtains the resource lock information corresponding to the target resource from the second node includes: the first node uses remote direct memory access (remote direct memory access). , RDMA) technology to obtain the resource lock information corresponding to the target resource from the second node.
  • remote direct memory access remote direct memory access
  • RDMA remote direct memory access
  • the RDMA technology can greatly improve the unlocking efficiency and reduce the delay.
  • the resource lock information includes: exclusive lock indication information, a queue of waiting nodes, and the number of shared nodes; wherein the exclusive lock indication information is used to indicate whether an exclusive lock is added to the target resource, so
  • the number of shared nodes is the number of nodes that have added a shared lock to the target resource
  • the queue of waiting nodes includes the identifier of the node requesting to add the resource lock to the target resource, and the node identifiers in the queue of waiting nodes are added as requested
  • the resource locks are arranged in sequence.
  • this application divides the resource lock information into exclusive lock indication information, waiting node queue, and number of shared nodes, so that when the first node performs the resource lock operation on the target resource, it can be
  • the resource lock information determines whether an exclusive lock or a shared lock is currently added to the target resource, the number of nodes that are added to the shared lock, and whether there are nodes waiting to add a resource lock to the target resource.
  • the first resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the shared lock The number of nodes is 0, and the waiting node queue is empty;
  • the second resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, the number of shared nodes is 0, and The node identifier of the first node is located at the top of the waiting node queue.
  • the first node when the first node performs an exclusive lock operation on a target resource, it can determine whether the first exclusive lock adding condition is currently met according to the resource lock information corresponding to the target resource, and then directly perform the lock operation If it is not satisfied, it will queue up and wait for the exclusive lock operation in the order in which the resource lock is added to the target resource. Wherein, if the first node determines that the second exclusive lock adding condition is satisfied during the queuing and waiting process, the exclusive lock operation is added to the target resource. Obviously, this method can effectively avoid the situation that the first node waiting for the exclusive lock to be added in the waiting node queue is continuously inserted in the queue and cannot be successfully locked for a long time, and can solve the problem of starvation of the first node after locking.
  • the resource lock information further includes the number of exclusive lock requesting nodes, where the number of exclusive lock requesting nodes is the number of nodes in the waiting node queue requesting to add an exclusive lock;
  • the first The node updates the resource lock information, so that the updated resource lock information indicates that the first node has joined the waiting node queue, including: the first node adds the node identifier of the first node To the waiting node queue, and add 1 to the number of exclusive lock requesting nodes;
  • the first node updates the resource lock information so that the updated resource lock information indicates that the target resource has been added Resource lock, and the first node has been deleted from the waiting node queue, including: the first node updates the exclusive lock indication information, reduces the number of exclusive lock requesting nodes by 1, and reduces the waiting node
  • the node identifier of the first node in the queue is deleted; wherein the updated exclusive lock indication information indicates that an exclusive lock has been added to the target resource.
  • the resource lock information in this application also includes the number of exclusive lock request nodes, so that when the first node performs a lock operation on the target resource, it can also determine the waiting pair according to the resource lock information. The number of nodes to which an exclusive lock is added to the target resource.
  • the waiting node queue further includes: resource lock type indication information of each node, wherein the resource lock type indication information of any node is used to indicate the type of resource lock requested by the node
  • the first node updates the resource lock information, so that the updated resource lock information indicates that the first node has been added to the waiting node queue, including: the first node transfers the first node The node identifier of the node and the indication information of the first node indicating the exclusive lock are added to the waiting node queue; the first node updates the resource lock information so that the updated resource lock information characterizes: The resource lock has been added to the target resource, and the first node has been deleted from the waiting node queue, including: the first node updates the exclusive lock indication information, and the first node in the waiting node queue The node identifier of a node and the indication information of the first node indicating the exclusive lock are deleted; wherein the updated exclusive lock indication information indicates that the target resource has added an exclusive lock.
  • the waiting node queue in this application further includes: resource lock type indication information of each node, wherein the resource lock type indication information of any node is used to indicate the type of resource lock requested by the node. Therefore, the first node can determine the number of nodes waiting to add a shared lock to the target resource and the number of nodes adding an exclusive lock according to the waiting node queue in the resource lock information.
  • the resource lock information when the resource lock is a shared lock, the resource lock information further includes the number of exclusive lock requesting nodes, where the number of exclusive lock requesting nodes is the number of nodes in the waiting node queue requesting to add The number of nodes with an exclusive lock;
  • the first resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the number of exclusive lock request nodes is 0;
  • the second resource lock is added The condition is: the exclusive lock indication information indicates that no exclusive lock is added to the target resource, and the node identifier of the first node is at the top of the waiting node queue.
  • the first node when the first node performs a shared lock operation on a target resource, it can determine whether the first shared lock adding condition is currently satisfied according to the resource lock information corresponding to the target resource, and then directly perform the lock operation If it is not satisfied, it will queue up and wait for the operation of adding a shared lock according to the order in which resource locks are added to the target resource.
  • the target resource adds a shared lock operation.
  • the first node updates the resource lock information so that the updated resource lock information indicates that the target resource has added a resource lock, including: The number of shared nodes is increased by 1; the first node updates the resource lock information so that the updated resource lock information characterizes: the target resource has added a resource lock, and the first node has Deleting from the waiting node queue includes: the first node increments the number of shared nodes by 1, and deleting the node identifier of the first node in the waiting node queue.
  • the first node of the present application can determine the number of nodes that currently add a shared lock to the target resource according to the resource lock information.
  • the resource lock information further includes the number of shared lock requesting nodes, where the number of shared lock requesting nodes is the number of nodes in the waiting node queue requesting to add a shared lock;
  • the first The node updates the resource lock information, so that the updated resource lock information indicates that the first node has joined the waiting node queue, including: the first node adds the node identifier of the first node To the waiting node queue, and increase the number of shared lock requesting nodes by one;
  • the first node updates the resource lock information so that the updated resource lock information characterizes: the target resource The resource lock has been added, and the first node has been deleted from the queue of waiting nodes, including: the first node increases the number of shared nodes by 1, subtracts the number of shared lock requesting nodes by 1, and The node identifier of the first node in the waiting node queue is deleted.
  • the resource lock information in this application also includes the number of shared lock request nodes, so that when the first node performs a lock operation on the target resource, it can also determine the waiting pair according to the resource lock information. The number of nodes to which the shared lock is added to the target resource.
  • the waiting node queue when the resource lock is a shared lock, the waiting node queue also includes resource lock type indication information of each node, and the resource lock type indication information of any node is used to indicate The type of the resource lock requested by the node;
  • the first resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the waiting node queue does not include the corresponding resource lock type
  • the indication information indicates the node of the exclusive lock;
  • the second resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the node identifier of the first node is at the top of the waiting node queue .
  • the waiting node queue in this application further includes: resource lock type indication information of each node, wherein the resource lock type indication information of any node is used to indicate the type of resource lock requested by the node. Therefore, the first node can determine the number of nodes waiting to add a shared lock to the target resource and the number of nodes adding an exclusive lock according to the waiting node queue in the resource lock information.
  • the first node updates the resource lock information so that the updated resource lock information indicates that the target resource has added a resource lock, including: The number of shared nodes is increased by 1; the first node updates the resource lock information so that the updated resource lock information characterizes: the target resource has added a resource lock, and the first node has Deleting from the waiting node queue includes: the first node adds 1 to the number of shared nodes, and deleting the node identifier of the first node in the waiting node queue and the resource lock type indication information of the first node .
  • the present application provides a method for updating the resource lock information based on when the waiting node queue also contains the resource lock type indication information of each node.
  • the method further includes: the first node releases the exclusive lock to the target resource, and updates the Exclusive lock indication information, wherein the updated exclusive lock indication information indicates that no exclusive lock is added to the target resource.
  • this application provides a method for the first node to release the exclusive lock added to the target resource.
  • the method further includes: the first node releases the shared lock to the target resource, and sets the shared lock The number of nodes is reduced by 1.
  • the present application provides a method for the first node to release the shared lock added to the target resource.
  • an embodiment of the present application provides a resource lock management device, which can be used to perform the operations in the first aspect and any possible implementation of the first aspect.
  • the apparatus may include a module unit for performing the operations in the first aspect or any possible implementation of the first aspect.
  • an embodiment of the present application provides a resource lock management device, which can be used to perform the operations in the first aspect and any possible implementation manner of the first aspect.
  • the device includes a transceiver and a memory.
  • the processor may be configured to support the device to perform the corresponding functions of the above-mentioned first node, and the memory may store data used by the processor when performing operations.
  • the embodiments of the present application provide a chip system including a processor and optionally a memory; wherein the memory is used to store a computer program, and the processor is used to call and run the computer program from the memory, so that the The communication device of the chip system executes the foregoing first aspect or any method in any possible implementation of the first aspect.
  • the embodiments of the present application provide a computer program product, the computer program product includes: computer program code, when the computer program code is run by the communication unit, processing unit or transceiver, or processor of the communication device, the communication device Perform any method of the foregoing first aspect or any possible implementation of the first aspect.
  • the embodiments of the present application provide a computer-readable storage medium.
  • the computer-readable storage medium stores a program.
  • the program enables a communication device (for example, a terminal device or a network device) to execute the above-mentioned first aspect or the first aspect. Any method of any possible implementation.
  • the embodiments of the present application provide a computer program.
  • the computer program When the computer program is executed on a computer, it will enable the computer to implement the first aspect or any one of the possible implementations of the first aspect.
  • Figure 1 is a schematic diagram of the architecture of a resource lock management system provided by this application.
  • FIG. 2 is a schematic diagram of another resource lock management system architecture provided by this application.
  • Figure 3 is a schematic diagram of a resource lock management scenario provided by this application.
  • Figure 4 is a schematic diagram of the first resource lock management method provided by this application.
  • FIG. 5 is a schematic diagram of the first resource lock information division provided by this application.
  • FIG. 6 is a schematic diagram of the second type of resource lock information division provided by this application.
  • FIG. 7 is a schematic diagram of the third resource lock information division provided by this application.
  • FIG. 8 is a schematic diagram of an operation flow of adding and decomposing exclusive locks to target resources according to resource lock information provided by this application;
  • FIG. 9 is a schematic diagram of releasing the exclusive lock on the target resource according to the resource lock information provided by this application.
  • FIG. 10 is a schematic diagram of a first node directly adding an exclusive lock to a target resource provided by this application;
  • FIG. 11 is a schematic diagram of resource lock information in the process of the first node's exclusive lock on the target resource provided by this application;
  • FIG. 12 is a schematic diagram of a first node queuing to add an exclusive lock to a target resource provided by this application;
  • FIG. 13 is a schematic diagram of the resource lock information in the process of adding and unlocking the exclusive lock to the target resource by the first node of the second type provided by this application;
  • FIG. 14 is a schematic diagram of an operation flow of adding and releasing a shared lock to a target resource according to the resource lock information provided by this application;
  • FIG. 15 is a schematic diagram of releasing the shared lock on the target resource according to the resource lock information provided by this application;
  • FIG. 16 is a schematic diagram of a first node directly adding a shared lock to a target resource provided by this application;
  • FIG. 17 is a schematic diagram of resource lock information in the process of adding and releasing a shared lock to a target resource by a first node provided by this application;
  • FIG. 18 is a schematic diagram of a first node queuing to add a shared lock to a target resource provided by this application;
  • FIG. 19 is a schematic diagram of resource lock information in the process of adding and releasing a shared lock to a target resource by a first node provided by this application;
  • FIG. 20 is a schematic diagram of the resource lock information of the third type provided by the application for the first node to add and release the shared lock to the target resource;
  • FIG. 21 is a schematic diagram of an implementation scenario of a first node based on RDMA technology provided by this application.
  • FIG. 22 is a schematic diagram of the startup and shutdown process of the first cluster file system based on the RDLM device provided by this application;
  • FIG. 23 is a schematic diagram of the unlocking process of the first cluster file system based on the RDLM device provided by this application;
  • FIG. 24 is a schematic diagram of a hash table of resource lock information and index nodes provided by this application.
  • FIG. 25 is a schematic diagram of the unlocking process of the second cluster file system based on RDLM device provided by this application.
  • FIG. 26 is a schematic diagram of the first resource lock management device provided by this application.
  • FIG. 27 is a schematic diagram of the second resource lock management device provided by this application.
  • the present application provides a resource lock management method and device, which are used to avoid the problem of lock nodes and lock starvation when performing distributed system management in the prior art.
  • the embodiments of the present application will be described below in conjunction with the drawings.
  • Remote direct memory access is a direct memory access technology that directly transfers data from the memory of one computer to another computer without the intervention of both operating systems. This allows high-throughput, low-latency network communication, and is especially suitable for use in massively parallel computer clusters.
  • Distributed file system which contains multiple nodes.
  • files are stored in some nodes in a distributed manner, and other nodes can access the node through the network to perform read and write operations on the file.
  • the distributed file system may also be called a shared storage file system.
  • the distributed file system can also be called a cluster file system.
  • the cluster file system can integrate and virtualize the storage space resources of the nodes in the cluster and provide external file access services.
  • the cluster file system (oracle cluster file system 2, ocfs2) includes two parts: user mode tools and kernel mode modules.
  • User mode tools are mainly used to configure the cluster environment, perform management operations such as formatting or mounting or unmounting the file system, and the kernel mode handles specific file input/output (input/output, I/O) operations and cluster lock functions.
  • Node refers to a device in a distributed file system.
  • the node can store resources and can also access resources located in other nodes.
  • the node may be a computing node, server, host, computer, etc.
  • RDMA network interface controller refers to a network interface controller (network card) based on RDMA technology, which provides the nodes in the distributed file system with the underlying communication capabilities of RDMA.
  • Resources which can be various types of files such as text, video, picture, and audio.
  • files can be various types of files such as text, video, picture, and audio.
  • both resources and files represent the same concept and can be interchanged.
  • the resource lock is set in order to realize the management of resources in the distributed file system and improve the efficiency and security of resource management.
  • a node can add resource locks to resources in the local or other nodes to obtain access rights to read and write the resources.
  • resource locks generally include shared locks and exclusive locks.
  • shared locks are also called read locks. After the node adds a shared lock to a resource, the resource can be viewed (that is, read operation), but the resource cannot be modified or deleted. It should be noted that multiple nodes in the distributed file system can add shared locks to the same resource at the same time; in addition, when an exclusive lock has been added to a resource, other nodes can no longer add shared locks to the resource.
  • Exclusive lock also known as exclusive lock or write lock. After a node adds an exclusive lock to a resource, it can perform various operations such as viewing, modifying, and deleting the resource. It should be noted that in a distributed file system, at the same time, only one node can add an exclusive lock to a resource; similarly, when a shared lock has been added to a resource, other nodes can no longer add an exclusive lock to the resource.
  • a node adding a type of resource lock to a resource needs to ensure that the resource does not add any type of resource lock.
  • At least one means one or more
  • plural means two or more.
  • “And/or” describes the association relationship of the associated objects, indicating that there can be three relationships, for example, A and/or B, which can mean: A alone exists, both A and B exist, and B exists alone, where A , B can be singular or plural.
  • the character “/” generally indicates that the associated objects are in an "or” relationship.
  • the following at least one item (item) or similar expressions refer to any combination of these items, including any combination of single item (item) or plural items (item).
  • at least one item (a) of a, b, or c can mean: a, b, c, ab, ac, bc, or abc, where a, b, and c can be single or multiple .
  • ordinal numbers such as “first” and “second” mentioned in the embodiments of this application are used to distinguish multiple objects, and are not used to limit the order, timing, priority, or importance of multiple objects .
  • the embodiment of the present application provides a distributed file network system to which a resource lock management method may be applicable.
  • a resource lock management method may be applicable.
  • there are multiple nodes in the distributed file system such as node01, node02, node03, and node4 in the figure.
  • a certain node can store shared resources, and other nodes can access the resources, and by adding a resource lock to the shared resources, the access rights for reading and writing the resources are obtained.
  • This node can be called a shared node, or a master node.
  • other nodes that access the resources in the node can be called child nodes, slave nodes, and visiting nodes.
  • node4 in Figure 1 can store shared resource 1, node1, node2, and node3 as slave nodes of node4, and can access shared resource 1 in node4.
  • node5 in FIG. 1 stores shared resource 2 and node6 and node7 serve as slave nodes of node5 and can access shared resource 2.
  • each node in the distributed file system can store shared resources, or some nodes in the distributed file system store shared resources, and the number of some nodes is not limited.
  • the distributed file system may adopt DLM architecture, SDLM architecture or RDLM architecture to implement resource lock management.
  • the distributed file system may permanently allocate corresponding shared nodes to certain nodes.
  • the distributed file system includes a control node, and the control node can set the master-slave node mapping relationship in the distributed file system.
  • the master-slave node mapping relationship can be: node4 serves as the master node of node1, node2, and node3; node5 serves as the master node of node6 and node7.
  • the master-slave node mapping relationship may be represented by Table 1.
  • the control node may send the master-slave node mapping relationship to each node (or each slave node) in the distributed file system; or the control node may map the master-slave node containing the identification of each slave node The relationship is sent to the corresponding slave node; or the child node may obtain the master-slave node mapping relationship from the control node when it needs to access the resources of the master node.
  • control node may send the master-slave node mapping relationship shown in Table 1 above to node1-node7, or to node1-node3, as well as node6 and node7.
  • control node sends master-slave node mapping relationship: node1 ⁇ ->node4 to node1, master-slave node mapping relationship: node2 ⁇ ->node4 to node2..., node7 ⁇ ->node5 to node7 .
  • the node storing the resource can be determined according to the master-slave node mapping relationship.
  • the distributed file system includes a control node, and the control node can obtain the correspondence between the shared node in the distributed file system and the resources contained in it.
  • the corresponding relationship between the shared node and the resources it contains may be: the shared node node4 stores the shared resource 1; the shared node node5 stores the shared resource 2.
  • the corresponding relationship between the shared node and the shared resource may be represented by Table 2.
  • the control node may send the correspondence between all shared nodes and the resources it contains to each node (or each slave node) in the system, or send the correspondence between a certain shared node and the resources it contains Give the corresponding slave node to this node.
  • the control node may send the correspondence between shared nodes and shared resources described in Table 2 to node1-node7, or to node1-node3, as well as node6 and node7.
  • the control node may send the corresponding relationship between shared node 4 and shared resource: node4 ⁇ ->shared resource 1 to node1-node3, and send the corresponding relationship between shared node 5 and shared resource: node5 ⁇ ->shared resource 2 Send to node6 and node7.
  • the node storing the resource can be determined according to the correspondence between the shared node and the resource contained therein.
  • the communication between the nodes in the above-mentioned distributed file system can be implemented through RDMA technology.
  • RDMA technology As shown in Figure 3, when node 2 or node 3 needs to perform resource lock operations and read/write operations on the target resource, it is determined that the shared node storing the target resource is node 1. Then, the node 2 or the node 3 can perform the above operations on the target resource through RDMA technology respectively.
  • the node 2 or the node 3 can bypass the node when the node 2 or the node 3 sends instructions corresponding to the resource lock operation and read and write operations to the node 1.
  • the core network protocol stack of 1 reduces the number of data copies, does not require the host CPU and operating system of node 1, and greatly improves the network transmission performance of the distributed file system.
  • the method for a node in a distributed file system to lock and unlock a target resource is generally:
  • Method 1 Use the DLM technology of the decentralized architecture to perform resource lock management on target resources.
  • Method 2 Use the SDLM technology of the centralized architecture to perform resource lock management on target resources.
  • node 1, node 2, node 3, and node 4 concurrently lock the target resource.
  • node 2 requests to lock the target resource earlier than other nodes, but node 1, node 3, and node 4 successfully complete the lock operation of the target resource, and node 2 has been unable to successfully lock the target resource. . Therefore, node 2 has been waiting infinitely for locking, resulting in lock starvation.
  • an embodiment of the present application provides a resource lock management method.
  • This method can be applied to the distributed file system shown in Figure 1.
  • the node storing the shared resource maintains a resource lock information for each shared resource, which is used to implement lock management of the shared resource by other nodes in the system.
  • the node that needs to perform the resource lock operation on the target resource is referred to as the first node.
  • the method specifically includes the following processes:
  • the first node determines to add a resource lock to the target resource, and obtains resource lock information corresponding to the target resource.
  • the resource lock information is used to characterize whether a resource lock has been added to the target resource, and information about the queue of waiting nodes requesting to add the resource lock, and the type of the resource lock is an exclusive lock or a shared lock.
  • the first node may obtain the resource lock information in the following manner:
  • Scenario 1 When the target resource is located in the first node, the first node obtains the resource lock information corresponding to the target resource locally.
  • Scenario 2 When the target resource is located in another node (for ease of description, it may be referred to as a second node in the following), the first node obtains the resource lock information corresponding to the target resource from the second node.
  • the first node needs to determine the second node storing the target resource before acquiring the resource lock information corresponding to the target resource from the second node.
  • the first node may, but is not limited to, determine the second node in the following manner.
  • Determination method 1 The first node determines the second node according to the master-slave node mapping relationship sent by the control node.
  • the first node determines the node4 as the second node.
  • Determination method 2 The first node determines the shared node corresponding to the target resource according to the correspondence between all shared nodes sent by the control node and the resources contained therein, and determines the shared node corresponding to the target resource Is the second node.
  • the target resource requested by the first node for unlocking operation is shared resource 1, and all shared nodes sent by the control node received by the first node and the resources contained therein
  • Table 2 The corresponding relationship is shown in Table 2, and the first node can determine that the shared node corresponding to the target resource is node4 according to Table 2. Therefore, the first node determines the node4 as the second node.
  • the first node determines whether the first resource lock addition condition is satisfied according to the resource lock information, if yes, execute step S402, if not, execute step S403.
  • the first node adds a resource lock to the target resource, and updates the resource lock information, so that the updated resource lock information indicates that the target resource has added a resource lock.
  • the first node queues up for adding a resource lock, and updates the resource lock information so that the updated resource lock information indicates that the first node has joined the waiting node queue, and continues to perform step S404 .
  • the first node monitors the resource lock information until it is determined that the resource lock information satisfies the second resource lock addition condition, adds a resource lock to the target resource, and updates the resource lock information so that the updated resource lock information
  • the resource lock information indicates that: the target resource has added a resource lock, and the first node has been deleted from the waiting node queue.
  • the first node when adding a resource lock to a target resource, the first node can perform a lock operation according to the resource lock information corresponding to the target resource. Among them, because the first node can determine whether an exclusive resource lock is currently added to the target resource according to the resource lock information, and the queue information of the node requesting to add the resource lock, thereby effectively improving the existence of locks when performing distributed system management. The problem of node lock and starvation.
  • the resource lock information is shown in FIG. 5, and includes: exclusive lock indication information, waiting node queue, number of shared nodes, and number of exclusive lock request nodes.
  • the exclusive lock indication information is used to indicate whether to add an exclusive lock to the target resource;
  • the number of shared nodes is the number of nodes that have added a shared lock to the target resource; and the waiting node queue contains requests to the target resource.
  • the target resource adds a resource lock to a queue consisting of node IDs, and the node IDs of the nodes in the waiting node queue are arranged in the order before and after the request to add the resource lock;
  • the number of exclusive lock requesting nodes is the number of requests in the waiting node queue The number of nodes to add exclusive locks.
  • the resource lock information is shown in FIG. 6, and further includes: the number of shared lock request nodes. Wherein, the number of shared lock requesting nodes is the number of nodes in the waiting node queue requesting to add an exclusive lock.
  • the resource lock information is divided into exclusive lock indication information, waiting node queue, number of shared nodes, number of exclusive lock requesting nodes, and number of shared lock requesting nodes, so that the first node is checking the target resource
  • the resource lock operation it can be determined according to the resource lock information whether an exclusive lock or a shared lock is currently added to the target resource, whether there are nodes waiting to add a resource lock to the target resource and the corresponding number of nodes.
  • the resource lock information is as shown in FIG. 7, and the waiting node queue further includes: resource lock type indication information of each node, and resource lock type indication information of any node Used to indicate the type of resource lock requested by the node.
  • the first node may determine the number of nodes waiting to add a shared lock to the target resource and the number of nodes adding an exclusive lock according to the waiting node queue. Therefore, there is no need to divide the number of exclusive lock requesting nodes and the number of shared lock requesting nodes in the resource lock information.
  • the distributed file system may also set a threshold n for the number of shared nodes in the resource lock information, that is, the target resource supports at most n nodes to add shared locks at the same time.
  • n the number of shared nodes in the resource lock information
  • S401-S404 will be specifically introduced according to the type of resource lock requested by the first node to add, in which the method of dividing resource lock information as shown in FIG. 6 is selected for detailed description.
  • Resource lock type 1 The first node performs an exclusive lock operation on the target resource.
  • this application provides a process for adding an exclusive lock to a target resource, including:
  • S800 The first node obtains resource lock information corresponding to the target resource.
  • the first node determines, according to the resource lock information, whether the target resource satisfies the first exclusive lock addition condition, if so, execute S802, otherwise execute S803.
  • the first exclusive lock adding condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the shared lock The number of nodes is 0, and the number of nodes in the waiting node queue is 0.
  • S802 The first node adds an exclusive lock to the target resource, and updates the exclusive lock indication information.
  • the exclusive lock indication information updated in this application indicates that the target file resource has currently been added with an exclusive lock by the first node.
  • S803 The first node adds 1 to the number of exclusive lock request nodes in the resource lock information.
  • S804 The first node continuously monitors the resource lock information.
  • S805 The first node judges whether the resource lock information satisfies the second exclusive lock adding condition, if yes, execute S806, otherwise, execute S804.
  • the second exclusive lock addition condition in this application is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, the number of shared nodes is 0, and the first node identifier is located at the beginning of the waiting node queue Start position.
  • S806 The first node adds an exclusive lock to the target resource, updates the lock indication information, and subtracts one from the number of exclusive lock requesting nodes.
  • the first node of the present application adds an exclusive lock to the target resource, when a certain condition is met, it will also perform an exclusive lock release operation on the target resource.
  • the first node determines the shared node storing the target resource. The first node searches for resource lock information corresponding to the target resource, and then reads the resource lock information. The first node releases the exclusive lock on the target resource, and clears the first node information recorded in the exclusive lock indication information.
  • the first node when the first node performs an exclusive lock operation on a target resource, it can determine whether the first exclusive lock adding condition is currently satisfied according to the resource lock information corresponding to the target resource, and then directly perform the lock operation If it is not satisfied, it will queue up and wait for the exclusive lock operation in the order in which the resource lock is added to the target resource. Wherein, if the first node determines that the second exclusive lock adding condition is satisfied during the queuing and waiting process, the exclusive lock operation is added to the target resource. Obviously, this method can effectively avoid the situation that the first node waiting for the exclusive lock to be added in the waiting node queue is continuously inserted in the queue and cannot be successfully locked for a long time, and can solve the problem of starvation of the first node after locking.
  • this application also provides an example of performing an exclusive lock operation on a target resource. Examples are described below.
  • Example 1 As shown in Figure 10, suppose the first node is node 20, the second node determined by the first node according to the master-slave node mapping relationship is node 4, and the first node obtains from the second node
  • the resource lock information corresponding to the target resource is shown in Figure 11.
  • the first node adds an exclusive lock to the target resource, and adds the node information of the first node to all In the exclusive lock indication information, the resource lock information is updated last.
  • Example 2 As shown in Figure 12, suppose the first node is node 20, the second node determined by the first node according to the master-slave node mapping relationship is node 4, and the first node obtains from the second node
  • the resource lock information corresponding to the target resource is shown in FIG. 13. Wherein, it can be determined from FIG. 12 that the current target resource does not satisfy the first exclusive lock adding condition. Therefore, if the first node needs to queue up to wait for the exclusive lock to be added to the target resource, the first node records the node information in the waiting node queue in the resource lock information in order, and adds the resource lock information to the waiting node queue.
  • the number of exclusive lock request nodes increases by 1.
  • the first node continuously monitors the resource lock information, wherein when the node 13 releases the exclusive lock added to the target resource, the node 2 in the waiting node queue adds the exclusive lock to the target resource in order, and The node information of the node 2 is added to the exclusive lock indication information, and the number of exclusive lock requesting nodes is reduced by one.
  • the node 8 in the waiting node queue adds the exclusive lock to the target resource in order, and adds the node information of the node 8 to all the target resources.
  • the exclusive lock indication information and the number of exclusive lock requesting nodes is reduced by one.
  • the first node continues to monitor the resource lock information until the node 8 releases the exclusive lock added to the target resource, and the node information of the first node is located at the start position of the waiting node queue. At this time, the first node determines, according to the resource lock information, that the current target resource satisfies the second exclusive lock addition condition.
  • the first node adds an exclusive lock to the target resource, adds the node information of the first node to the exclusive lock indication information, and reduces the number of exclusive lock requesting nodes by 1, and finally updates The resource lock information.
  • Resource lock type 2 The first node performs a shared lock operation on the target resource.
  • this application provides a process for adding a shared lock to a target resource, including:
  • S1400 The first node obtains resource lock information corresponding to the target resource.
  • the first node determines, according to the resource lock information, whether the target resource satisfies the first shared lock adding condition, if so, execute S1402, otherwise execute S1403.
  • the condition for adding the first shared lock in this application is that the exclusive lock indication information indicates that no exclusive lock is added to the target file resource, and the number of nodes in the first queue of nodes waiting to add an exclusive lock is 0.
  • S1402 The first node adds an exclusive lock to the target resource, and adds 1 to the number of shared nodes.
  • S1403 The first node adds 1 to the number of nodes in the second queue waiting to add the shared lock.
  • S1404 The first node continuously monitors the resource lock information.
  • S1405 The first node judges whether the resource lock information satisfies the second shared lock adding condition, if yes, execute S1406, otherwise, execute S1404.
  • the condition for adding the second shared lock in this application is that the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the first node identifier is located at the start position of the first waiting node queue.
  • S1406 The first node adds a shared lock to the target resource, increases the number of shared nodes by 1, and decreases the number of shared lock requesting nodes by 1.
  • the first node in this application adds a shared lock to the target resource, when a certain condition is met, it will also perform an operation to release the shared lock on the target resource.
  • the first node determines the shared node storing the target resource. The first node searches for resource lock information corresponding to the target resource, and then reads the resource lock information. The first node releases the shared lock on the target resource, and reduces the number of shared nodes by one.
  • the first node when the first node performs a shared lock operation on a target resource, it can determine whether the first shared lock adding condition is currently satisfied according to the resource lock information corresponding to the target resource, and then directly perform the lock operation If it is not satisfied, it will queue up and wait for the operation of adding a shared lock in the order in which resource locks are added to the target resource.
  • the target resource adds a shared lock operation.
  • this application also provides an example of performing a shared lock operation on target resources. Examples are described below.
  • Example 1 As shown in Figure 16, suppose the first node is node 20, the second node determined by the first node according to the master-slave node mapping relationship is node 4, and the first node obtains from the second node
  • the resource lock information corresponding to the target resource is shown in FIG. 17.
  • the first node adds a shared lock to the target resource, and adds the number of shared nodes in the resource lock information. 1. Finally update the resource lock information.
  • Example 2 As shown in Figure 18, suppose the first node is node 20, the second node determined by the first node according to the master-slave node mapping relationship is node 4, and the first node obtains from the second node
  • the resource lock information corresponding to the target resource is shown in Figure 19. Wherein, it can be determined from FIG. 19 that the current target resource does not satisfy the first shared lock adding condition. Therefore, if the first node needs to queue up for adding a shared lock, the first node records the node information in the waiting node queue in the resource lock information in order, and stores the shared lock in the resource lock information. Increase the number of requested nodes by 1.
  • the order of the node identification in the waiting node queue is the node that needs to add an exclusive lock to the target resource, the node that needs to add a shared lock to the target resource, the node that needs to add a shared lock to the target resource 11 , Need to add an exclusive lock to the target resource node 9.
  • the first node continuously monitors the resource lock information, wherein when the node 13 releases the exclusive lock added to the target resource, the node 2 in the waiting node queue adds the exclusive lock to the target resource in order, and The node information of the node 2 is added to the exclusive lock indication information, and the number of exclusive lock requesting nodes is reduced by one.
  • the node 6 in the waiting node queue adds a shared lock to the target resource in order, and adds 1 to the number of shared nodes, And subtract one from the number of shared lock request nodes.
  • the node 11 in the waiting node queue may also add a shared lock to the target resource, increase the number of shared nodes by one, and decrease the number of shared lock requesting nodes by one.
  • the node 9 at the beginning of the waiting node queue adds an exclusive lock to the target resource in order, and the node The node information of 9 is added to the exclusive lock indication information, and the number of exclusive lock requesting nodes is reduced by one.
  • the first node continues to monitor the resource lock information until the node 9 releases the exclusive lock added to the target resource, and the node information of the first node is located at the start position of the waiting node queue. At this time, the first node determines, according to the resource lock information, that the current target resource satisfies the second shared lock adding condition.
  • the first node adds a shared lock to the target resource, increases the number of shared nodes by 1, and reduces the number of shared lock requesting nodes by 1, and finally updates the resource lock information.
  • Example 3 The first node is node 20, and the resource lock information corresponding to the target resource is shown in FIG. 20, and it is assumed that each shared resource in the distributed file system supports at most 4 nodes to add shared locks at the same time.
  • the first node needs to queue to wait for adding a shared lock to the target resource, and the first node records the node information in the waiting node queue in the resource lock information in order, and locks the resource
  • the number of shared lock request nodes in the message is increased by 1.
  • the first node continuously monitors the resource lock information until the number of nodes to which the shared lock is currently added to the target resource is less than 4, and the node information of the first node is located at the start position of the waiting node queue. At this time, the first node adds a shared lock to the target resource, increases the number of shared nodes by 1, and decreases the number of shared lock requesting nodes by 1, and finally updates the resource lock information.
  • this application is based on the advantages of RDMA technology and introduces a distributed lock manager RDLM based on RDMA technology in the process of resource lock management of the distributed file system.
  • the file system module shown in FIG. 21 is used to provide file management services for upper-level applications, including file reading and writing, modification, and deletion operations.
  • the file operation module is used to provide file read/write, modify, and delete operations for upper-level applications by registering common file operation functions with the virtual machine file system (VFS).
  • the metadata operation module mainly manages the attribute information of the file, such as file size, permission, modification time, location in the disk, and so on.
  • the disk space management module mainly manages the storage space of the file system, such as allocating disk space and reclaiming disk space.
  • the RDLM module is used to provide a distributed lock service for upper-level applications to ensure that cluster nodes concurrently access shared file resources.
  • the resource lock management module manages resource lock information through a hash table (hash table) data structure.
  • the resource lock recovery module is responsible for recovering resource lock information.
  • the RDMA communication module is responsible for initializing the remote virtual memory space, and is used to perform resource lock data interaction with the remote computing node.
  • the present application can store the resource lock information corresponding to the target resource in the node of the distributed file system. Obviously, this method can effectively reduce the system overhead that may be caused by the process of acquiring the resource lock information through a third-party storage server when the first node in the prior art unlocks and unlocks the target resource, and the system is stuck. .
  • a cluster configuration file is created on all hosts in the cluster, and node information is added, including the name and IP address of the node.
  • the cluster configuration information is transferred to the kernel mode through the user mode tool, and the RDMA network monitoring process is started in the kernel mode.
  • the metadata information of the file system is initialized and written into the disk area.
  • the RDLM module is initialized, and a mutual trust connection is established with the RDLM of other computing nodes, and then the file operation function of ocfs2 is registered in a virtual file system (VFS), so that upper-layer applications can manipulate files through system calls.
  • VFS virtual file system
  • the dirty memory data of the file system is synchronized to the disk, all cluster locks are released, the RDLM connection is disconnected from all nodes and the RDLM module is uninstalled, and finally the file system module is uninstalled.
  • This application also provides an embodiment of a resource lock management method. As shown in FIG. 23, the process of unlocking and unlocking cluster nodes of the open source ocfs2 cluster file system is as follows:
  • the user mode application calls the read/write (read/write) system call interface through the device (glibc) library, and then triggers in the kernel to call the file read and write functions registered by ocfs2 at the VFS layer.
  • the file index node number is obtained, the index node number is hashed (hash) operation rule one, the node number of the second node corresponding to the resource lock information is generated, and then the index node number is hashed rule two to find the resource
  • the specific position of the lock information in the hash table is shown in Figure 24.
  • the locking is retried.
  • the compare and swap/fetch and add command returns to fail, it means that the resource lock has been locked by other nodes, and it tries to join the lock queue and waits for the lock. If the second node is found to be down and faulty, the lock request is redirected to the new second node to complete the lock.
  • allocate memory and disk space for this IO operation compose user data into a block input/output (block input output, bio) structure, issue a bio request to the physical address of the corresponding block device, and wait for the IO result to return .
  • block input/output block input output, bio
  • a user-mode distributed lock solution is taken as an example to introduce the unlocking process of RDLM.
  • the specific process is shown in FIG. 25.
  • create a cluster configuration file on all hosts in the cluster add the host name and IP address information, and then plan the first node and the second node.
  • start the cluster lock service on the first node monitor the connection of the remote second node, and then allocate memory space for the resource lock hashtable and register the memory to RDMA for remote data exchange.
  • a universally unique identifier (UUID) is calculated, and the UUID is hashed. The corresponding second node number is generated. The second hash operation rule is generated. Find the specific location of the resource lock information in the hash table. Read the resource lock information and judge whether it can be locked according to the current state of the resource lock. Through the compare and swap/fetch and add commands provided by RDMA, the value of the resource lock information in the hash table is modified to complete the exclusive lock/shared lock lock operation.
  • the locking is retried.
  • the compare and swap/fetch and add command returns to fail, it means that the resource lock has been locked by other nodes, and it tries to join the lock queue and waits for the lock. If the first node is found to be down and faulty, the lock request is redirected to the new first node to complete the lock.
  • the critical area enters the protection state, and the application can access and operate.
  • the compare and swap/fetch and add commands provided by RDMA are used to modify the value of the resource lock information in the hash table and release the exclusive lock/shared lock.
  • the above-mentioned realization devices include hardware structures and/or software modules corresponding to the respective functions.
  • the present application can be implemented in the form of hardware or a combination of hardware and computer software. Whether a certain function is executed by hardware or computer software-driven hardware depends on the specific application and design constraint conditions of the technical solution. Professionals and technicians can use different methods for each specific application to implement the described functions, but such implementation should not be considered beyond the scope of this application.
  • a resource lock management device of the present application includes a processor 2600, a memory 2601, and a communication interface 2602.
  • the processor 2600 is responsible for managing the bus architecture and general processing, and the memory 2601 can store data used by the processor 2600 when performing operations.
  • the communication interface 2602 is used for data communication between the processor 2600 and the memory 2601.
  • the processor 2600 may be a central processing unit (CPU), a network processor (NP), or a combination of CPU and NP.
  • the processor 2600 may further include a hardware chip.
  • the aforementioned hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD) or a combination thereof.
  • the above-mentioned PLD may be a complex programmable logic device (CPLD), a field-programmable gate array (FPGA), a generic array logic (GAL) or any combination thereof.
  • the memory 1601 may include: U disk, mobile hard disk, read-only memory (read-only memory, ROM), random access memory (random access memory, RAM), magnetic disk or optical disk and other various media that can store program codes.
  • the processor 2600, the memory 2601, and the communication interface 2602 are connected to each other.
  • the processor 2600, the memory 2601, and the communication interface 2602 may be connected to each other through a bus 2603; the bus 2603 may be a peripheral component interconnect (PCI) bus or an extended industry Standard structure (extended industry standard architecture, EISA) bus, etc.
  • PCI peripheral component interconnect
  • EISA extended industry Standard architecture
  • the bus can be divided into address bus, data bus, control bus, etc. For ease of representation, only one thick line is used to represent in FIG. 26, but it does not mean that there is only one bus or one type of bus.
  • the processor 2600 is configured to read a program in the memory 2601 and execute:
  • the type of the resource lock is an exclusive lock or a shared lock; it is determined whether the first resource lock addition condition is satisfied according to the resource lock information; if so, the resource lock is added to the target resource, and the resource lock information is updated, So that the updated resource lock information indicates that the target resource has added a resource lock; otherwise, queues to wait for adding a resource lock, and updates the resource lock information, so that the updated resource lock information indicates the first A node has joined the queue of waiting nodes; and monitors the resource lock information until it is determined that the resource lock information satisfies the second resource lock addition condition, adds a resource lock to the target resource, and updates the resource lock information , So that the updated resource lock information characterizes: the target resource has added a resource lock, and the first no
  • the processor 2600 is specifically configured to:
  • the processor 2600 is specifically configured to:
  • Determining the second node storing the target resource acquiring the resource lock information corresponding to the target resource from the second node.
  • the processor 2600 is specifically configured to:
  • the master node of the first node is determined to be the second node.
  • the processor 2600 is specifically configured to:
  • the resource lock information corresponding to the target resource is obtained from the second node.
  • the resource lock information includes: exclusive lock indication information, a queue of waiting nodes, and the number of shared nodes; wherein the exclusive lock indication information is used to indicate whether an exclusive lock is added to the target resource, so
  • the number of shared nodes is the number of nodes that have added a shared lock to the target resource
  • the queue of waiting nodes includes the identifier of the node requesting to add the resource lock to the target resource, and the node identifiers in the queue of waiting nodes are added as requested
  • the resource locks are arranged in sequence.
  • the first resource lock addition condition is: the exclusive lock indication information indicates that the target resource is not added with an exclusive lock, and the shared lock The number of nodes is 0, and the waiting node queue is empty;
  • the second resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, the number of shared nodes is 0, and The node identifier of the first node is located at the top of the waiting node queue.
  • the resource lock information further includes the number of exclusive lock requesting nodes, where the number of exclusive lock requesting nodes is the number of nodes in the waiting node queue requesting to add an exclusive lock;
  • the processor 2600 is specifically configured to:
  • Update the exclusive lock indication information reduce the number of exclusive lock requesting nodes by 1, and delete the node identifier of the first node in the waiting node queue; wherein the updated exclusive lock indication information indicates the An exclusive lock has been added to the target resource.
  • the waiting node queue further includes: resource lock type indication information of each node, wherein the resource lock type indication information of any node is used to indicate the type of resource lock requested by the node ;
  • the processor 2600 is specifically configured to:
  • the exclusive lock indication information is updated, and the node identifier of the first node in the waiting node queue and the indication information indicating the exclusive lock of the first node are deleted; wherein the updated exclusive lock indication information indicates An exclusive lock has been added to the target resource.
  • the resource lock information when the resource lock is a shared lock, the resource lock information further includes the number of exclusive lock requesting nodes, where the number of exclusive lock requesting nodes is the number of nodes requesting addition in the waiting node queue The number of nodes with exclusive lock;
  • the first resource lock adding condition is:
  • the exclusive lock indication information indicates that no exclusive lock is added to the target resource, and the number of exclusive lock request nodes is 0;
  • the second resource lock addition condition is:
  • the exclusive lock indication information indicates that no exclusive lock has been added to the target resource, and the node identifier of the first node is at the top of the waiting node queue.
  • the processor 2600 is further configured to:
  • the number of shared nodes is increased by 1, and the node identifier of the first node in the waiting node queue is deleted.
  • the resource lock information further includes the number of shared lock requesting nodes, where the number of shared lock requesting nodes is the number of nodes in the waiting node queue requesting to add a shared lock;
  • the processor 2600 is specifically configured to:
  • the number of shared nodes is increased by 1, the number of shared lock requesting nodes is decreased by 1, and the node identifier of the first node in the waiting node queue is deleted.
  • the waiting node queue when the resource lock is a shared lock, the waiting node queue also contains resource lock type indication information of each node, and the resource lock type indication information of any node is used to indicate The type of the resource lock requested by the node;
  • the first resource lock adding condition is:
  • the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the waiting node queue does not include a node whose corresponding resource lock type indication information indicates an exclusive lock;
  • the second resource lock adding condition is:
  • the exclusive lock indication information indicates that no exclusive lock has been added to the target resource, and the node identifier of the first node is at the top of the waiting node queue.
  • the processor 2600 is specifically configured to:
  • the first node adds 1 to the number of shared nodes; or adds 1 to the number of shared nodes, and indicates the node identifier of the first node in the waiting node queue and the resource lock type of the first node Information deleted.
  • the processor 2600 is further configured to:
  • the exclusive lock is released for the target resource, and the exclusive lock indication information is updated, wherein the updated exclusive lock indication information indicates that the target resource has not added an exclusive lock.
  • the processor 2600 is further configured to:
  • the present application provides a resource lock management device, which includes:
  • Obtaining module 2700 used to determine to add a resource lock to a target resource, and obtain resource lock information corresponding to the target resource, where the resource lock information is used to characterize whether the target resource has added a resource lock, and the wait for adding a resource lock Information of the node queue, the type of the resource lock is an exclusive lock or a shared lock;
  • Processing module 2701 used to determine whether the first resource lock addition condition is satisfied according to the resource lock information; if so, add a resource lock to the target resource, and update the resource lock information so that the updated resource
  • the lock information indicates that the target resource has added a resource lock; otherwise, it queues up for adding a resource lock, and updates the resource lock information so that the updated resource lock information indicates that the first node has joined the waiting node Queue; and monitor the resource lock information until it is determined that the resource lock information meets the second resource lock addition condition, add a resource lock to the target resource, update the resource lock information, so that the updated resource lock information
  • the resource lock information characterizes: a resource lock has been added to the target resource, and the first node has been deleted from the waiting node queue.
  • the obtaining module 2700 is specifically configured to:
  • the obtaining module 2700 is specifically configured to:
  • Determining the second node storing the target resource acquiring the resource lock information corresponding to the target resource from the second node.
  • the processing module 2701 is specifically configured to:
  • the master node of the first node is determined to be the second node.
  • the processing module 2701 is specifically configured to:
  • the resource lock information corresponding to the target resource is obtained from the second node.
  • the resource lock information includes: exclusive lock indication information, a queue of waiting nodes, and the number of shared nodes; wherein the exclusive lock indication information is used to indicate whether an exclusive lock is added to the target resource, so
  • the number of shared nodes is the number of nodes that have added a shared lock to the target resource
  • the queue of waiting nodes includes the identifier of the node requesting to add the resource lock to the target resource, and the node identifiers in the queue of waiting nodes are added as requested
  • the resource locks are arranged in sequence.
  • the first resource lock addition condition is: the exclusive lock indication information indicates that the target resource is not added with an exclusive lock, and the shared lock The number of nodes is 0, and the waiting node queue is empty;
  • the second resource lock addition condition is: the exclusive lock indication information indicates that the target resource has not added an exclusive lock, the number of shared nodes is 0, and The node identifier of the first node is located at the top of the waiting node queue.
  • the resource lock information further includes the number of exclusive lock requesting nodes, where the number of exclusive lock requesting nodes is the number of nodes in the waiting node queue requesting to add an exclusive lock;
  • the processing module 2701 is specifically configured to:
  • Update the exclusive lock indication information reduce the number of exclusive lock requesting nodes by 1, and delete the node identifier of the first node in the waiting node queue; wherein the updated exclusive lock indication information indicates the An exclusive lock has been added to the target resource.
  • the waiting node queue further includes: resource lock type indication information of each node, wherein the resource lock type indication information of any node is used to indicate the type of resource lock requested by the node ;
  • the processing module 2701 is specifically configured to:
  • the exclusive lock indication information is updated, and the node identifier of the first node in the waiting node queue and the indication information indicating the exclusive lock of the first node are deleted; wherein the updated exclusive lock indication information indicates An exclusive lock has been added to the target resource.
  • the resource lock information when the resource lock is a shared lock, the resource lock information further includes the number of exclusive lock requesting nodes, where the number of exclusive lock requesting nodes is the number of nodes requesting addition in the waiting node queue The number of nodes with exclusive lock;
  • the first resource lock adding condition is:
  • the exclusive lock indication information indicates that no exclusive lock is added to the target resource, and the number of exclusive lock request nodes is 0;
  • the second resource lock addition condition is:
  • the exclusive lock indication information indicates that no exclusive lock has been added to the target resource, and the node identifier of the first node is at the top of the waiting node queue.
  • the processing module 2701 is further configured to:
  • the number of shared nodes is increased by 1, and the node identifier of the first node in the waiting node queue is deleted.
  • the resource lock information further includes the number of shared lock requesting nodes, where the number of shared lock requesting nodes is the number of nodes in the waiting node queue requesting to add a shared lock;
  • the processing module 2701 is specifically configured to:
  • the number of shared nodes is increased by 1, the number of shared lock requesting nodes is decreased by 1, and the node identifier of the first node in the waiting node queue is deleted.
  • the waiting node queue when the resource lock is a shared lock, the waiting node queue also contains resource lock type indication information of each node, and the resource lock type indication information of any node is used to indicate The type of the resource lock requested by the node;
  • the first resource lock adding condition is:
  • the exclusive lock indication information indicates that the target resource has not added an exclusive lock, and the waiting node queue does not include a node whose corresponding resource lock type indication information indicates an exclusive lock;
  • the second resource lock adding condition is:
  • the exclusive lock indication information indicates that no exclusive lock has been added to the target resource, and the node identifier of the first node is at the top of the waiting node queue.
  • the processing module 2701 is specifically configured to:
  • the first node adds 1 to the number of shared nodes; or adds 1 to the number of shared nodes, and indicates the node identifier of the first node in the waiting node queue and the resource lock type of the first node Information deleted.
  • the processing module 2701 is further configured to:
  • the exclusive lock is released for the target resource, and the exclusive lock indication information is updated, wherein the updated exclusive lock indication information indicates that the target resource has not added an exclusive lock.
  • the processing module 2701 is further configured to:
  • various aspects of the resource lock management method provided in the embodiments of the present application can also be implemented in the form of a program product, which includes program code.
  • program code runs on a computer device
  • the program code is used to make the computer device execute the steps in the resource lock management method according to various exemplary embodiments of the present application described in this specification.
  • the program product can use any combination of one or more readable media.
  • the readable medium may be a readable signal medium or a readable storage medium.
  • the readable storage medium may be, for example, but not limited to, an electric, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or device, or any combination of the above. More specific examples (non-exhaustive list) of readable storage media include: electrical connections with one or more wires, portable disks, hard disks, random access memory (RAM), read only memory (ROM), erasable Type programmable read only memory (EPROM or flash memory), optical fiber, portable compact disk read only memory (CD-ROM), optical storage device, magnetic storage device, or any suitable combination of the above.
  • the program product for resource lock management may adopt a portable compact disk read-only memory (CD-ROM) and include program code, and may run on a server device.
  • CD-ROM portable compact disk read-only memory
  • the program product of this application is not limited to this.
  • the readable storage medium can be any tangible medium that contains or stores a program, and the program can be used by or in combination with information transmission, devices, or devices.
  • the readable signal medium may include a data signal propagated in baseband or as a part of a carrier wave, and readable program code is carried therein. This propagated data signal can take many forms, including, but not limited to, electromagnetic signals, optical signals, or any suitable combination of the foregoing.
  • the readable signal medium may also be any readable medium other than a readable storage medium, and the readable medium may send, propagate, or transmit a program for use by or in combination with a periodic network action system, device, or device.
  • the program code contained on the readable medium can be transmitted by any suitable medium, including, but not limited to, wireless, wired, optical cable, RF, etc., or any suitable combination of the above.
  • the program code used to perform the operations of this application can be written in any combination of one or more programming languages.
  • the programming languages include object-oriented programming languages—such as Java, C++, etc., as well as conventional procedural Programming language-such as "C" language or similar programming language.
  • the program code can be executed entirely on the user's computing device, partly on the user's device, executed as an independent software package, partly on the user's computing device and partly executed on the remote computing device, or entirely on the remote computing device or server Executed on.
  • the remote computing device may be connected to a user computing device through any kind of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computing device.
  • LAN local area network
  • WAN wide area network
  • the embodiment of the present application also provides a computing device readable storage medium for the resource lock management method, that is, the content is not lost after power off.
  • the storage medium stores a software program, including program code, and when the program code runs on a computing device, the software program can implement any of the above embodiments of the present application when it is read and executed by one or more processors Resource lock management scheme.
  • this application may take the form of a computer program product on a computer-usable or computer-readable storage medium, which has a computer-usable or computer-readable program code implemented in the medium to be used by the instruction execution system or Used in conjunction with the instruction execution system.
  • a computer-usable or computer-readable medium can be any medium that can contain, store, communicate, transmit, or transmit a program for use by an instruction execution system, device, or device, or in combination with an instruction execution system, Device or equipment use.

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Computer Hardware Design (AREA)
  • Mathematical Physics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

一种资源锁管理方法及装置,该方法包括:第一节点获取目标资源的资源锁信息,所述资源锁信息表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息;根据所述资源锁信息确定满足第一资源锁添加条件,则对所述目标资源添加资源锁;否则排队等待添加资源锁,更新所述资源锁信息;并监测所述资源锁信息,在满足第二资源锁添加条件时,添加资源锁,更新所述资源锁信息。通过上述方法,所述第一节点在对目标资源添加资源锁时,根据对应的所述资源锁信息可以确定所述目标资源当前是否添加资源锁,以及请求添加资源锁的节点队列信息,从而有效改善了进行分布式系统管理时存在加锁节点加锁饿死的问题。

Description

一种资源锁管理方法及装置
相关申请的交叉引用
本申请要求在2019年06月26日提交中国专利局、申请号为201910563273.X、申请名称为“一种资源锁管理方法及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
技术领域
本申请涉及通信技术领域,尤其涉及一种资源锁管理方法及装置。
背景技术
在分布式文件系统中包含多个节点,文件会分布式存储在部分节点中,其他节点可以通过网络访问该节点实现对该文件进行读写操作。所述分布式文件系统又可以称为共享存储型文件系统。
在分布式文件系统中,节点可以通过资源锁机制实现对存储在其他节点的文件进行管理,以提高文件管理的效率和安全性。资源锁包括独占锁和共享锁两类。其中,节点通过对文件添加独占锁可以对文件进行查看、修改和删除,且在该文件被添加独占锁之后无法再加任何类型的资源锁;节点通过对文件添加共享锁可以对文件进行查看但无法对文件进行修改和删除。
目前,分布式文件系统可以采用去中心化架构的分布式锁管理器(distributed lock manager,DLM)技术或采用中心化架构的半分布式锁管理器(semi-distributed lock manager,SDLM)技术实现对上述资源锁进行加锁和解锁管理。
DLM技术原理为:基于传输控制协议(transmission control protocol,TCP)/网络协议(internet protocol,IP)进行通信,其中,所述DLM在群集中的每台计算机上运行,具有与群集范围的锁数据库相同的副本,从而实现同步访问共享资源。
SDLM技术原理为:由存储服务器集中处理锁请求,从而实现同步访问共享资源。
而通过上述两种方法进行分布式文件系统管理时,经常存在加锁饿死现象,即需要进行加锁的节点一直无法进行加锁操作,无限等待。
综上,现有技术进行分布式系统管理时存在加锁节点加锁饿死的问题。
发明内容
本申请提供一种资源锁管理方法及装置,用以避免现有技术进行分布式系统管理时存在加锁节点加锁饿死的问题。
第一方面,本申请实施例提供一种资源锁管理方法,包括:
第一节点确定向目标资源添加资源锁,获取目标资源对应的资源锁信息,其中,所述资源锁信息用于表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息,所述资源锁的类型为独占锁或共享锁;所述第一节点根据所述资源锁信息确定是否满足第一资源锁添加条件;若是,则所述第一节点对所述目标资源添加资源锁,并更 新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁;否则,所述第一节点排队等待添加资源锁,且更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中;并监测所述资源锁信息,直至确定所述资源锁信息满足第二资源锁添加条件时,对所述目标资源添加资源锁,更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除。
基于该方案,所述第一节点在对目标资源添加资源锁时,根据所述目标资源对应的资源锁信息进行加锁操作,其中,因为根据所述资源锁信息可以确定所述目标资源当前是否添加资源锁,以及请求添加资源锁的节点队列信息,从而有效改善了进行分布式系统管理时存在加锁节点加锁饿死的问题。
本申请中提到的“节点”可以指物理设备,如一台物理服务器,也可以指虚拟机、容器等虚拟化设备,或也可以认为是一个线程或进程等用于计算处理的操作系统内的元素。
在一种可能的实现方式中,所述第一节点获取所述目标资源对应的所述资源锁信息,包括:所述第一节点从本地获取所述目标资源对应的所述资源锁信息;或所述第一节点从第二节点获取所述目标资源对应的所述资源锁信息。
基于该方案,本申请所述第一节点可以从本地获取所述目标资源对应的所述资源锁信息,或者从第二节点获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方式中,所述第一节点从所述第二节点获取所述目标资源对应的所述资源锁信息,包括:所述第一节点确定存储有所述目标资源的所述第二节点;所述第一节点从所述第二节点中获取所述目标资源对应的所述资源锁信息。
基于该方案,本申请详细介绍了所述第一节点如何从第二节点获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方式中所述第一节点确定存储有所述目标资源的所述第二节点,包括:所述第一节点根据主从节点映射关系,确定所述第一节点的主节点为所述第二节点。
基于该方案,本申请提供第一节点与第二节点的映射规则,从而使所述第一节点根据所述映射规则确定对应的所述第二节点。
在一种可能的实现方式中,所述第一节点从所述第二节点获取所述目标资源对应的所述资源锁信息,包括:所述第一节点通过远程直接内存访问(remote direct memory access,RDMA)技术,从所述第二节点获取所述目标资源对应的所述资源锁信息。
基于该方案,本申请进行分布式系统资源锁管理时,通过采用RDMA技术可以大幅提升加解锁效率,降低延迟。
在一种可能的实现方式中,所述资源锁信息包含:独占锁指示信息、等待节点队列、共享节点数量;其中,所述独占锁指示信息用于指示所述目标资源是否添加独占锁,所述共享节点数量为已对所述目标资源添加共享锁的节点数量,所述等待节点队列包含请求对所述目标资源添加资源锁的节点标识,且所述等待节点队列中的节点标识按照请求添加资源锁的前后顺序排列。
基于该方案,本申请将所述资源锁信息划分为独占锁指示信息、等待节点队列、共享节点数量,从而使所述第一节点在对所述目标资源进行加资源锁操作时,可以根据所述资源锁信息确定所述目标资源当前是否添加独占锁或共享锁,添加共享锁节点的数量以及是否有等待对所述目标资源添加资源锁的节点。
在一种可能的实现方式中,当所述资源锁的类型为独占锁时,所述第一资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述等待节点队列为空;所述第二资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述第一节点的节点标识位于所述等待节点队列首位。
基于该方案,所述第一节点对目标资源进行加独占锁操作时,可根据所述目标资源对应的所述资源锁信息确定当前是否满足第一独占锁添加条件,满足则直接进行加锁操作,不满足则按照请求对目标资源添加资源锁的顺序排队等待进行加独占锁操作。其中,所述第一节点在排队等待过程中,若确定满足第二独占锁添加条件,则对所述目标资源添加独占锁操作。显然,该方法可以有效避免等待节点队列中的请求添加独占锁的第一节点被不断插队抢占,长时间无法加锁成功的情况,可以解决所述第一节点加锁饿死的问题。
在一种可能的实现方式中,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,包括:所述第一节点将所述第一节点的节点标识添加到所述等待节点队列中,并将所述独占锁请求节点数量加1;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:所述第一节点更新所述独占锁指示信息,将所述独占锁请求节点数量减1,将所述等待节点队列中所述第一节点的节点标识删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
基于该方案,本申请中所述资源锁信息还包括独占锁请求节点数量,从而使所述第一节点在对所述目标资源进行加锁操作时,还可以根据所述资源锁信息确定等待对所述目标资源添加独占锁的节点数量。
在一种可能的实现方式中,所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,包括:所述第一节点将所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息添加到所述等待节点队列中;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:所述第一节点更新所述独占锁指示信息,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
基于该方案,本申请中所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型。从而所述第一节点可以根据所述资源锁信息中的所述等待节点队列确定等待对所述目标资源添加共享锁的节点数量以及添加独占锁的节点数量。在一种可能的实现方式中,当所述资源锁为共享锁时,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;所述第一资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁,且所述独占锁请求节点数量为0;所述第二资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁,且所述 第一节点的节点标识位于所述等待节点队列首位。
基于该方案,所述第一节点对目标资源进行加共享锁操作时,可根据所述目标资源对应的所述资源锁信息确定当前是否满足第一共享锁添加条件,满足则直接进行加锁操作,不满足则按照请求对目标资源添加资源锁的顺序排队等待进行加共享锁操作。其中,所述第一节点在排队等待过程中,若确定满足第二共享锁添加条件,则所述目标资源添加共享锁操作。显然,该方法可以有效避免等待队列中的请求添加共享锁的第一节点被不断插队抢占,长时间无法加锁成功的情况,可以解决所述第一节点加锁饿死的问题。
在一种可能的实现方式中,所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁,包括:所述第一节点将所述共享节点数量加1;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:所述第一节点将所述共享节点数量加1,以及将所述等待节点队列中所述第一节点的节点标识删除。
基于该方案,本申请所述第一节点可根据所述资源锁信息确定当前对所述目标资源添加共享锁的节点的数量。
在一种可能的实现方式中,所述资源锁信息还包含共享锁请求节点数量,其中,所述共享锁请求节点数量为所述等待节点队列中请求添加共享锁的节点数量;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,包括:所述第一节点将所述第一节点的节点标识添加到所述等待节点队列中,并将所述共享锁请求节点数量加1;所述第一节点更新所述所资源锁信息,以使更新后的所述所资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:所述第一节点将所述共享节点数量加1,将所述共享锁请求节点数量减1,以及将所述等待节点队列中所述第一节点的节点标识删除。
基于该方案,本申请中所述资源锁信息还包括共享锁请求节点数量,从而使所述第一节点在对所述目标资源进行加锁操作时,还可以根据所述资源锁信息确定等待对所述目标资源添加共享锁的节点数量。
在一种可能的实现方式中,当所述资源锁为共享锁时,所述等待节点队列中还包含每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;所述第一资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁,且所述等待节点队列中不包含对应的资源锁类型指示信息指示独占锁的节点;所述第二资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
基于该方案,本申请中所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型。从而所述第一节点可以根据所述资源锁信息中的所述等待节点队列确定等待对所述目标资源添加共享锁的节点数量以及添加独占锁的节点数量。
在一种可能的实现方式中,所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁,包括:所述第一节点将所述共享节点数量加1;所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:所述第一节点将所述共享节点数量加1,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的资 源锁类型指示信息删除。
基于该方案,本申请提供了一种基于所述等待节点队列中还包含每个节点的资源锁类型指示信息时,所述资源锁信息更新的方法。
在一种可能的实现方式中,所述第一节点对所述目标资源添加独占锁之后,所述方法还包括:所述第一节点对所述目标资源解除所述独占锁,并更新所述独占锁指示信息,其中,更新后的所述独占锁指示信息指示所述目标资源未添加独占锁。
基于该方案,本申请提供了所述第一节点解除对所述目标资源添加的独占锁的方法。
在一种可能的实现方式中所述第一节点对所述目标资源添加共享锁之后,所述方法还包括:所述第一节点对所述目标资源解除所述共享锁,并将所述共享节点数量减1。
基于该方案,本申请提供了所述第一节点解除对所述目标资源添加的共享锁的方法。
第二方面,本申请实施例提供了一种资源锁管理装置,该装置可以用来执行上述第一方面及第一方面的任意可能的实现方式中的操作。例如,装置可以包括用于执行上述第一方面或第一方面的任意可能的实现方式中的各个操作的模块单元。
第三方面,本申请实施例提供了一种资源锁管理装置,该装置可以用来执行上述第一方面及第一方面的任意可能的实现方式中的操作。该装置包括:收发器和存储器。该处理器可被配置为支持该装置执行以上所述第一节点的相应功能,该存储器可以存储所述处理器在执行操作时所使用的数据。第四方面,本申请实施例提供了一种芯片系统,包括处理器,可选的还包括存储器;其中,存储器用于存储计算机程序,处理器用于从存储器中调用并运行计算机程序,使得安装有芯片系统的通信设备执行上述第一方面或第一方面的任意可能的实现方式中的任一方法。
第五方面,本申请实施例提供了一种计算机程序产品,计算机程序产品包括:计算机程序代码,当计算机程序代码被通信设备的通信单元、处理单元或收发器、处理器运行时,使得通信设备执行上述第一方面或第一方面的任意可能的实现方式中的任一方法。
第六方面,本申请实施例提供了一种计算机可读存储介质,计算机可读存储介质存储有程序,程序使得通信设备(例如,终端设备或网络设备)执行上述第一方面或第一方面的任意可能的实现方式中的任一方法。
第七方面,本申请实施例提供了一种计算机程序,计算机程序在某一计算机上执行时,将会使得计算机实现上述第一方面或第一方面的任意可能的实现方式中的任一方法。
附图说明
图1为本申请提供的一种资源锁管理系统架构示意图;
图2为本申请提供的另一种资源锁管理系统架构示意图;
图3为本申请提供的一种资源锁管理场景示意图;
图4为本申请提供的第一种资源锁管理的方法示意图;
图5为本申请提供的第一种资源锁信息划分示意图;
图6为本申请提供的第二种资源锁信息划分示意图;
图7为本申请提供的第三种资源锁信息划分示意图;
图8为本申请提供的一种根据资源锁信息对目标资源进行加解独占锁操作流程示意图;
图9为本申请提供的一种根据资源锁信息对目标资源解除独占锁示意图;
图10为本申请提供的一种第一节点对目标资源直接添加独占锁示意图;
图11为本申请提供的第一种第一节点对目标资源加解独占锁过程中资源锁信息示意图;
图12为本申请提供的一种第一节点排队等待对目标资源添加独占锁示意图;
图13为本申请提供的第二种第一节点对目标资源加解独占锁过程中资源锁信息示意图;
图14为本申请提供的一种根据资源锁信息对目标资源加解共享锁操作流程示意图;
图15为本申请提供的一种根据资源锁信息对目标资源解除共享锁示意图;
图16为本申请提供的一种第一节点对目标资源直接添加共享锁示意图;
图17为本申请提供的第一种第一节点对目标资源加解共享锁过程资源锁信息示意图;
图18为本申请提供的一种第一节点排队等待对目标资源添加共享锁示意图;
图19为本申请提供的第二种第一节点对目标资源加解共享锁过程资源锁信息示意图;
图20为本申请提供的第三种第一节点对目标资源加解共享锁的资源锁信息示意图;
图21为本申请提供的一种第一节点基于RDMA技术的实现场景示意图;
图22为本申请提供的第一种基于RDLM装置的集群文件系统启动及停止流程示意图;
图23为本申请提供的第一种基于RDLM装置的集群文件系统加解锁流程示意图;
图24为本申请提供的一种资源锁信息与索引节点的哈希表示意图;
图25为本申请提供的第二种基于RDLM装置的集群文件系统加解锁流程示意图;
图26为本申请提供的第一种资源锁管理的装置示意图;
图27为本申请提供的第二种资源锁管理的装置示意图。
具体实施方式
本申请提供一种资源锁管理方法及装置,用以避免现有技术进行分布式系统管理时存在加锁节点加锁饿死的问题。下面结合附图,对本申请实施例进行描述。
以下对本申请实施例中的部分用语进行解释说明,以便于理解。
1)远程直接内存访问(remote direct memory access,RDMA),是一种直接存储器访问技术,它将数据直接从一台计算机的内存传输到另一台计算机,无需双方操作系统的介入。这允许高通量、低延迟的网络通信,尤其适合在大规模并行计算机集群中使用。
2)分布式文件系统,其中包含多个节点。在分布式文件系统中,文件会分布式存储在部分节点中,其他节点可以通过网络访问该节点实现对该文件进行读写操作。所述分布式文件系统又可以称为共享存储型文件系统。
当分布式文件系统中包含的节点数量较大时,分布式文件系统又可以称为集群文件系统。
集群文件系统可以将集群内的节点的存储空间资源整合、虚拟化并对外提供文件访问服务。其中,集群文件系统(oracle cluster file system 2,ocfs2)包括用户态工具和内核态模块两部分。用户态工具主要用于配置集群环境,执行格式化或挂载或卸载文件系统等管理操作,内核态处理具体文件输入/输出(input/output,I/O)操作以及集群锁功能。
3)节点(node),是指分布式文件系统中的设备。所述节点可以存储资源,也可以访问位于其他节点中的资源。具体地,所述节点可以是计算节点、服务器、主机、计算机等。
4)RDMA网络接口控制器(RDMA network interface controller,RNIC),是指基于RDMA技术的网络接口控制器(网卡),为分布式文件系统中的节点提供RDMA的底层通 信能力。
5)资源,具体可以是文本、视频、图片、音频等各种类型的文件。在本申请实施例中,资源和文件二者表示同一概念,可以互换。
6)资源锁,为了实现对分布式文件系统中的资源进行管理,提高资源管理的效率和安全性设置的。节点可以通过对本地或其他节点中的资源添加资源锁,获取对该资源进行读操作、写操作的访问权限。
目前,资源锁一般包括共享锁和独占锁。
其中,共享锁,又称为读锁。当节点对某资源添加共享锁后,可以对该资源进行查看(即读操作),但无法对该资源进行修改和删除。需要说明的是,分布式文件系统中的多个节点可以同时对同一资源添加共享锁;另外,当某资源已添加独占锁时,其他节点无法再对该资源添加共享锁。
独占锁,又称排他锁或写锁。当节点对某资源添加独占锁后,可以对该资源进行查看,修改和删除等各种操作。需要说明的是,分布式文件系统中,在同一时刻,只能存在一个节点对某资源添加独占锁;同样的,当某资源已添加共享锁时,其他节点无法再对该资源添加独占锁。
总之,在分布式文件系统中,节点对某资源添加一种类型的资源锁需要保证该资源未添加任何类型的资源锁。
另外,本申请实施例中的术语“系统”和“网络”可被互换使用。“至少一个”是指一个或者多个,“多个”是指两个或两个以上。“和/或”,描述关联对象的关联关系,表示可以存在三种关系,例如,A和/或B,可以表示:单独存在A,同时存在A和B,单独存在B的情况,其中,A,B可以是单数或者复数。字符“/”一般表示前后关联对象是一种“或”的关系。以下至少一项(个)下或其类似表达,是指的这些项中的任意组合,包括单项(个)或复数项(个)的任意组合。例如,a,b,或c中的至少一项(个),可以表示:a,b,c,a-b,a-c,b-c,或a-b-c,其中a,b,c可以是单个,也可以是多个。
除非有相反的说明,本申请实施例提及“第一”、“第二”等序数词是用于对多个对象进行区分,不用于限定多个对象的顺序、时序、优先级或者重要程度。
此外,本申请实施例和权利要求书及附图中的术语“包括”和“具有”不是排他的。例如,包括了一系列步骤或模块的过程、方法、系统、产品或设备,不限定于已列出的步骤或模块,还可以包括没有列出的步骤或模块。
本申请实施例提供了一种资源锁管理方法可能适用的一种分布式文件网络系统。如图1所示,所述分布式文件系统中有多个节点,例如图中的node01、node02、node03、node4等。
在所述分布式文件系统,某个节点可以存储共享资源,其他节点可以对该节点进行资源访问,并通过对该共享资源添加资源锁以获取对该资源进行读操作、写操作的访问权限。该节点可以称为共享节点,或主节点。那么访问该节点中的资源的其他节点可以称为子节点、从节点、访问节点。
例如图1中node4中可以存储有共享资源1,node1、node2和node3作为该node4的从节点,可以对node4中的共享资源1进行访问。
又例如,图1中的node5中存储有共享资源2,node6和node7作为node5的从节点,可以对共享资源2进行访问。
需要说明的是,分布式文件系统中每个节点均可以存储共享资源,或者分布式文件系统中部分节点存储共享资源,且部分节点的数量不作限定。
可选的,所述分布式文件系统可以采用DLM架构、SDLM架构或者RDLM架构,以实现资源锁管理。
在一种实施方式中,分布式文件系统可以固定为某些节点分配对应的共享节点。
在第一个设计中,所述分布式文件系统中包含一个控制节点,该控制节点可以设置分布式文件系统中的主从节点映射关系。如图2所示,该主从节点映射关系可以为:node4作为node1、node2和node3的主节点;node5作为node6和node7的主节点。
可选的,所述主从节点映射关系可以通过表1来表示。
Figure PCTCN2020091650-appb-000001
表1主从节点映射关系
所述控制节点可以将所述主从节点映射关系发送给分布式文件系统中的每个节点(或每个从节点);或者所述控制节点将包含每个从节点的标识的主从节点映射关系发送给对应的从节点;再或者子节点可以在需要访问主节点的资源时,从所述控制节点获取所述主从节点映射关系。
例如,所述控制节点可以将上述表1所示的主从节点映射关系发送给node1-node7,或者发送给node1-node3,以及node6和node7。又例如,所述控制节点将主从节点映射关系:node1<->node4发送给node1,将主从节点映射关系:node2<->node4发送给node2……,将node7<->node5发送给node7。
通过该设计,分布式文件系统中的节点需要访问某资源或者需要对某资源添加资源锁时,可以根据所述主从节点映射关系,确定存储有所述资源的节点。
在另一个设计中,所述分布式文件系统中包含一个控制节点,该控制节点可以获取分布式文件系统中的共享节点与其包含的资源之间的对应关系。所述共享节点与其包含的资源之间的对应关系可以为:共享节点node4存储有共享资源1;共享节点node5存储有共享资源2。可选的,所述共享节点与共享资源的对应关系可以通过表2来表示。
共享节点 共享资源
node4 共享资源1
node5 共享资源2
表2共享节点与共享资源的对应关系
所述控制节点可以将所有共享节点与其包含的资源之间的对应关系发送给系统中的每个节点(或每个从节点),或者将某个共享节点与其包含的资源之间的对应关系发送给该节点对应的从节点。例如,所述控制节点可以将表2所述的共享节点与共享资源的对应关系发送给node1-node7,或者发送给node1-node3,以及node6和node7。又例如,所述控制节点可以将共享节点4与共享资源的对应关系:node4<->共享资源1发送给node1-node3,将共享节点5与共享资源的对应关系:node5<->共享资源2发送给node6和node7。
通过该设计,分布式文件系统中的节点需要访问某资源或者需要对某资源添加资源锁时,可以根据所述共享节点与其包含的资源之间的对应关系,确定存储有所述资源的节点。
在一种可能的实现方式中,上述分布式文件系统中的节点之间进行通信(例如,节点对共享节点进行资源访问)时,可以通过RDMA技术来实现。如图3所示,当节点2或节点3需要对目标资源进行加解资源锁操作和读写操作时,确定存储有目标资源的共享节点为节点1。然后,所述节点2或节点3可以分别通过RDMA技术,对所述目标资源进行上述操作。
由于RDMA技术可以将节点的网络通信处理能力卸载在网卡上,因此,所述节点2或节点3在向所述节点1发送加解资源锁操作和读写操作对应的指令时,可以绕过节点1的内核网络协议栈,减少数据的拷贝次数,无需节点1的主机CPU和操作系统,极大地提升了分布式文件系统的网络传输性能。
目前,现有技术中,分布式文件系统中的节点对目标资源进行加解资源锁的方法一般是:
方法一:采用去中心化架构的DLM技术对目标资源进行加解资源锁管理。
方法二:采用中心化架构的SDLM技术对目标资源进行加解资源锁管理。
但是,上述分布式文件系统对共享资源进行加解资源锁管理的主要问题是:无论是通过方法一还是方法二对共享资源进行加资源锁时,经常出现多个节点并发对目标资源进行加锁操作时,存在节点无限加锁等待的情况。
例如,假设节点1、节点2、节点3、节点4并发对目标资源进行加锁操作。其中,假设节点2请求对目标资源加锁的操作早于其他节点,但节点1、节点3、节点4都成功完成对目标资源加锁操作,而节点2一直无法成功对目标资源进行加锁操作。因此,节点2一直进行无限加锁等待,造成加锁饿死现象。
为解决该问题,本申请实施例提供一种资源锁管理方法。该方法可应用于如图1所示的分布式文件系统中。在该系统中,存储有共享资源的节点针对每个共享资源,均维护一个资源锁信息,用于实现系统中的其他节点对该共享资源进行锁管理。
为方便对本申请实施例进行介绍,下述实施例中,将需要对目标资源进行加解资源锁操作的节点称为第一节点。
如图4所示,该方法具体包括以下流程:
S400:第一节点确定向目标资源添加资源锁,获取目标资源对应的资源锁信息。
其中,所述资源锁信息用于表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息,所述资源锁的类型为独占锁或共享锁。
根据具体的场景不同,所述第一节点可以通过以下方式获取所述资源锁信息:
场景一:在所述目标资源位于所述第一节点时,所述第一节点从本地获取所述目标资 源对应的所述资源锁信息。
场景二:在所述目标资源位于其他节点(为了便于描述,后续可以称为第二节点)时,所述第一节点从第二节点获取所述目标资源对应的所述资源锁信息。
其中,在上述场景二中,所述第一节点在从所述第二节点获取所述目标资源对应的所述资源锁信息之前,需要确定存储有所述目标资源的所述第二节点。
可选的,所述第一节点可以但不限于通过以下方式确定所述第二节点。
确定方式1:所述第一节点根据所述控制节点发送的主从节点映射关系,确定所述第二节点。
例如,假设所述第一节点为node2,所述第一节点接收到的所述控制节点发送的主从节点映射关系如表1所示,则当所述第一节点需要访问某资源或者需要对某资源添加资源锁时,通过表1可以确定出所述第一节点对应的主节点为node4。因此,所述第一节点将所述node4确定为所述第二节点。
确定方式2:所述第一节点根据所述控制节点发送的所有共享节点与其包含的资源之间的对应关系,确定所述目标资源对应的共享节点,并将所述目标资源对应的共享节点确定为所述第二节点。
例如,假设所述第一节点为node2,所述第一节点请求进行加解锁操作的目标资源为共享资源1,所述第一节点接收到的所述控制节点发送的所有共享节点与其包含的资源之间的对应关系如表2所示,则所述第一节点根据所述表2,可以确定出所述目标资源对应的共享节点为node4。因此,所述第一节点将所述node4确定为所述第二节点。
S401:所述第一节点根据所述资源锁信息确定是否满足第一资源锁添加条件,若是,执行步骤S402,若否,执行步骤S403。
S402:所述第一节点对所述目标资源添加资源锁,并更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁。
S403:所述第一节点排队等待添加资源锁,且更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,继续执行步骤S404。
S404:所述第一节点监测所述资源锁信息,直至确定所述资源锁信息满足第二资源锁添加条件时,对所述目标资源添加资源锁,更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除。
通过上述方法,所述第一节点在对目标资源添加资源锁时,可以根据所述目标资源对应的资源锁信息进行加锁操作。其中,因为所述第一节点根据所述资源锁信息可以确定所述目标资源当前是否添加独占资源锁,以及请求添加资源锁的节点队列信息,从而有效改善了进行分布式系统管理时存在加锁节点加锁饿死的问题。
可选的,在一个实施例中,所述资源锁信息如图5所示,包含:独占锁指示信息、等待节点队列、共享节点数量、独占锁请求节点数量。
其中,所述独占锁指示信息用于指示所述目标资源是否添加独占锁;所述共享节点数量为已对所述目标资源添加共享锁的节点数量;所述等待节点队列为包含请求对所述目标资源添加资源锁的节点标识组成的队列,且所述等待节点队列中的节点的标识节点标识按照请求添加资源锁的前后顺序排列;所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量。可选的,在另一个实施例中,所述资源锁信息如图6所示,还包含:共享锁请求节点数量。其中,所述共享锁请求节点数量为所述等待节点队列中请求添 加独占锁的节点数量。
通过上述方法,将所述资源锁信息划分为独占锁指示信息、等待节点队列、共享节点数量、独占锁请求节点数量以及共享锁请求节点数量,从而使所述第一节点在对所述目标资源进行加资源锁操作时,可以根据所述资源锁信息确定所述目标资源当前是否添加独占锁或共享锁,是否有等待对所述目标资源添加资源锁的节点以及对应的节点数量。
可选的,在一个实施例中,所述资源锁信息如图7所示,所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型。此时,所述第一节点可根据所述等待节点队列确定等待对所述目标资源添加共享锁的节点数量以及添加独占锁的节点数量。因此,所述资源锁信息中可无需划分所述独占锁请求节点数量以及共享锁请求节点数量。
另外,在一个实施例中,分布式文件系统还可对所述资源锁信息中的共享节点数量设置一个阈值n,也就是所述目标资源同一时刻最多支持n个节点添加共享锁。当节点需要对所述目标资源添加共享锁时,确定所述资源锁信息中共享节点数量为n时,需要进行排队等待。
下面,按照所述第一节点请求添加的资源锁的类型对S401-S404进行具体介绍,其中,选取如图6所示的资源锁信息划分的方式进行详细说明。
资源锁类型1:所述第一节点对目标资源进行加解独占锁操作。
如图8所示,本申请提供了一种对目标资源添加独占锁的流程,包括:
S800:所述第一节点获取目标资源对应的资源锁信息。
S801:所述第一节点根据所述资源锁信息确定所述目标资源是否满足第一独占锁添加条件,若是,执行S802,否则执行S803。
根据以上对独占锁的描述中独占锁的添加规则,在本申请实施例中,所述第一独占锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述等待节点队列的节点数量为0。
S802:所述第一节点对所述目标资源添加独占锁,并更新所述独占锁指示信息。
其中,本申请更新后的所述独占锁指示信息指示所述目标文件资源当前已被所述第一节点添加独占锁。
S803:所述第一节点将所述资源锁信息中独占锁请求节点数量加1。
S804:所述第一节点持续监测所述资源锁信息。
S805:所述第一节点判断所述资源锁信息是否满足第二独占锁添加条件,若是,执行S806,否则,执行S804。
本申请所述第二独占锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述第一节点标识位于所述等待节点队列起始位置。
S806:所述第一节点对所述目标资源添加独占锁,并更新所述锁指示信息,以及将所述独占锁请求节点数量减1。
可选的,本申请所述第一节点对所述目标资源添加独占锁后,在满足一定条件时,还会对所述目标资源进行解除独占锁操作。如图9所示,当所述第一节点需要解除对所述目标资源添加的独占锁时,所述第一节点确定存储有所述目标资源的共享节点。所述第一节点查找所述目标资源对应的资源锁信息,然后读取所述资源锁信息。所述第一节点对所述目标资源解除所述独占锁,并将所述独占锁指示信息中所记录的所述第一节点信息清除。
通过上述方法,所述第一节点对目标资源进行加独占锁操作时,可根据所述目标资源对应的所述资源锁信息确定当前是否满足第一独占锁添加条件,满足则直接进行加锁操作,不满足则按照请求对目标资源添加资源锁的顺序排队等待进行加独占锁操作。其中,所述第一节点在排队等待过程中,若确定满足第二独占锁添加条件,则对所述目标资源添加独占锁操作。显然,该方法可以有效避免等待节点队列中的请求添加独占锁的第一节点被不断插队抢占,长时间无法加锁成功的情况,可以解决所述第一节点加锁饿死的问题。
基于以上实施例,本申请还提供了对目标资源进行加解独占锁操作的实例。下面对实例进行说明。
实例一:如图10所示,假设第一节点为节点20,所述第一节点根据主从节点映射关系确定的第二节点为节点4,且所述第一节点从所述第二节点获取的所述目标资源对应的资源锁信息如图11所示。
其中,从图11中可以确定当前所述目标资源满足第一独占锁添加条件,因此,所述第一节点对所述目标资源添加独占锁,并将所述第一节点的节点信息添加到所述独占锁指示信息中,最后更新所述资源锁信息。
实例二:如图12所示,假设第一节点为节点20,所述第一节点根据主从节点映射关系确定的第二节点为节点4,且所述第一节点从所述第二节点获取的所述目标资源对应的资源锁信息如图13所示。其中,从图12中可以确定当前所述目标资源不满足第一独占锁添加条件。因此,所述第一节点需要排队等待对目标资源添加独占锁,则所述第一节点将节点信息按照顺序记录到所述资源锁信息中的等待节点队列中,并将所述资源锁信息中的独占锁请求节点数量加1。
所述第一节点持续监测所述资源锁信息,其中,当节点13解除对目标资源添加的独占锁后,位于所述等待节点队列中的节点2按照顺序对所述目标资源添加独占锁,并将所述节点2的节点信息添加到所述独占锁指示信息中,以及将所述独占锁请求节点数量减1。
其中,当所述节点2解除对目标资源添加的独占锁后,位于所述等待节点队列中的节点8按照顺序对所述目标资源添加独占锁,并将所述节点8的节点信息添加到所述独占锁指示信息中,以及将所述独占锁请求节点数量减1。
所述第一节点继续监测所述资源锁信息,直至所述节点8解除对目标资源添加的独占锁,且所述第一节点的节点信息位于所述等待节点队列起始位置。此时,所述第一节点根据所述资源锁信息确定当前所述目标资源满足第二所述独占锁添加条件。
因此,所述第一节点对所述目标资源添加独占锁,并将所述第一节点的节点信息添加到所述独占锁指示信息中,以及将所述独占锁请求节点数量减1,最后更新所述资源锁信息。
资源锁类型2:所述第一节点对目标资源进行加解共享锁操作。
如图14所示,本申请提供了一种对目标资源添加共享锁的流程,包括:
S1400:所述第一节点获取目标资源对应的资源锁信息。
S1401:所述第一节点根据所述资源锁信息确定所述目标资源是否满足第一共享锁添加条件,若是,执行S1402,否则执行S1403。
本申请中所述第一共享锁添加条件为:所述独占锁指示信息指示所述目标文件资源未添加独占锁,且所述等待添加独占锁的节点第一队列中的节点数量为0。
S1402:所述第一节点对所述目标资源添加独占锁,并将所述共享节点数量加1。
S1403:所述第一节点将所述等待添加共享锁的第二队列中的节点数量加1。
S1404:所述第一节点持续监测所述资源锁信息。
S1405:所述第一节点判断所述资源锁信息是否满足第二共享锁添加条件,若是,执行S1406,否则执行S1404。
本申请中所述第二共享锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点标识位于所述第一等待节点队列起始位置。
S1406:所述第一节点对所述目标资源添加共享锁,并将所述共享节点数量加1,以及将所述共享锁请求节点数量减1。
可选的,本申请中所述第一节点对所述目标资源添加共享锁后,在满足一定条件时,还会对所述目标资源进行解除共享锁操作。如图15所示,当所述第一节点需要解除对所述目标资源添加的共享锁时,所述第一节点确定存储有所述目标资源的共享节点。所述第一节点查找所述目标资源对应的资源锁信息,然后读取所述资源锁信息。所述第一节点对所述目标资源解除所述共享锁,并将所述共享节点数量减1。
通过上述方法,所述第一节点对目标资源进行加共享锁操作时,可根据所述目标资源对应的所述资源锁信息确定当前是否满足第一共享锁添加条件,满足则直接进行加锁操作,不满足则按照请求对目标资源添加资源锁的顺序排队等待进行加共享锁操作。其中,所述第一节点在排队等待过程中,若确定满足第二共享锁添加条件,则所述目标资源添加共享锁操作。显然,该方法可以有效避免等待队列中的请求添加共享锁的第一节点被不断插队抢占,长时间无法加锁成功的情况,可以解决所述第一节点加锁饿死的问题。
基于以上实施例,本申请还提供了对目标资源进行加解共享锁操作的实例。下面对实例进行说明。
实例一:如图16所示,假设第一节点为节点20,所述第一节点根据主从节点映射关系确定的第二节点为节点4,且所述第一节点从所述第二节点获取的所述目标资源对应的资源锁信息如图17所示。
其中,从图17中可以确定当前所述目标资源满足第一共享锁添加条件,因此,所述第一节点对所述目标资源添加共享锁,并将所述资源锁信息中的共享节点数量加1,最后更新所述资源锁信息。
实例二:如图18所示,假设第一节点为节点20,所述第一节点根据主从节点映射关系确定的第二节点为节点4,且所述第一节点从所述第二节点获取的所述目标资源对应的资源锁信息如图19所示。其中,从图19中可以确定当前所述目标资源不满足第一共享锁添加条件。因此,所述第一节点需要排队等待添加共享锁,则所述第一节点将节点信息按照顺序记录到所述资源锁信息中的等待节点队列中,并将所述资源锁信息中的共享锁请求节点数量加1。
其中,实例二中假设等待节点队列中排队等待的节点标识顺序依次为需要对目标资源添加独占锁的节点2、需要对目标资源添加共享锁的节点6、需要对目标资源添加共享锁的节点11、需要对目标资源添加独占锁的节点9。所述第一节点持续监测所述资源锁信息,其中,当节点13解除对目标资源添加的独占锁后,位于所述等待节点队列中的节点2按照顺序对所述目标资源添加独占锁,并将所述节点2的节点信息添加到所述独占锁指示信息中,以及将所述独占锁请求节点数量减1。
其中,当所述节点2解除对所述目标资源添加的独占锁后,位于所述等待节点队列中 的节点6按照顺序对所述目标资源添加共享锁,并将所述共享节点数量加1,以及将所述共享锁请求节点数量减1。
可选的,因当前所述目标资源添加的是共享锁,而目标资源可以同时添加多个共享锁。因此,位于所述等待节点队列中的节点11也可以对所述目标资源添加共享锁,并将所述共享节点数量加1,以及将所述共享锁请求节点数量减1。
当所述节点11、节点6全部对目标资源解除添加的共享锁后,此时,位于所述等待节点队列起始位置的节点9按照顺序对所述目标资源添加独占锁,并将所述节点9的节点信息添加到所述独占锁指示信息中,以及将所述独占锁请求节点数量减1。
所述第一节点继续监测所述资源锁信息,直至所述节点9解除对目标资源添加的独占锁,且所述第一节点的节点信息位于所述等待节点队列起始位置。此时,所述第一节点根据所述资源锁信息确定当前所述目标资源满足所述第二共享锁添加条件。
因此,则所述第一节点对所述目标资源添加共享锁,并将所述共享节点数量加1,以及将所述共享锁请求节点数量减1,最后更新所述资源锁信息。
实例三:第一节点为节点20,目标资源对应的资源锁信息如图20所示,且假设所述分布式文件系统中每个共享资源同一时刻最多支持4个节点添加共享锁。
其中,从图20中可以确定当前所述目标资源满足第一共享锁添加条件,但是所述目标资源当前已达到添加共享锁的阈值4。因此,所述第一节点需要排队等待对所述目标资源添加共享锁,则所述第一节点将节点信息按照顺序记录到所述资源锁信息中的等待节点队列中,并将所述资源锁信息中的共享锁请求节点数量加1。
所述第一节点持续监测所述资源锁信息,直到所述目标资源当前添加共享锁的节点数量小于4,且所述第一节点的节点信息位于所述等待节点队列起始位置。此时,所述第一节点对所述目标资源添加共享锁,并将所述共享节点数量加1,以及将所述共享锁请求节点数量减1,最后更新所述资源锁信息。
可选的,如图21所示,本申请基于RDMA技术的优势,在分布式文件系统进行资源锁管理过程中引入基于RDMA技术的分布式锁管理器RDLM。其中,图21中所示的文件系统模块用于为上层应用程序提供文件管理服务,包括文件读写、修改、删除操作等。
所述文件操作模块用于通过向虚拟机文件系统(VFS)注册通用的文件操作函数,为上层应用提供文件读写、修改、删除等操作。所述元数据操作模块主要管理文件的属性信息,比如文件大小、权限、修改时间、在磁盘中的位置等。所述磁盘空间管理模块主要管理文件系统的存储空间,比如,分配磁盘空间、回收磁盘空间等。
所述RDLM模块用于为上层应用程序提供分布式锁服务,保证集群节点并发访问共享文件资源。所述资源锁管理模块通过哈希表(hash table)数据结构管理资源锁信息。所述资源锁恢复模块负责恢复资源锁信息。所述RDMA通信模块负责初始化远程虚拟内存空间,用于和远端计算节点进行资源锁的数据交互。
由此,通过RDMA技术,本申请可将所述目标资源对应的资源锁信息存储在分布式文件系统的节点中。显然,该方法可以有效降低现有技术中第一节点对目标资源进行加解锁时,需要通过第三方存储服务器获取所述资源锁信息过程中可能造成的系统开销过大,出现系统卡死的问题。
其中,本申请基于RDLM装置进行资源锁管理的方式有多种,下面列举几种分布式网络系统通过RDLM进行资源锁管理的启动流程以及第一节点的加解锁流程。
本申请的一个实施例,如图22所示,开源的ocfs2集群文件系统启动和停止流程如下:
S2200:配置集群信息。
具体的,在集群中所有主机上创建集群配置文件,并添加节点信息,包括节点的名称、IP地址等。
S2201:启动集群服务。
具体的,通过用户态工具将集群配置信息传递到内核态,并在内核态启动RDMA网络监听进程。
S2202:格式化文件系统。
具体的,初始化文件系统的元数据信息,并写入磁盘区域。
S2203:挂载文件系统。
具体的,初始化RDLM模块,并与其它计算节点的RDLM建立互信连接,然后将ocfs2的文件操作函数注册到虚拟文件系统(virtual filesystem,VFS)中,以便上层应用可以通过系统调用操作文件。
S2204:卸载文件系统。
具体的,将文件系统的内存脏数据同步到磁盘,释放所有集群锁,与所有节点断开RDLM连接并卸载RDLM模块,最后卸载文件系统模块。
S2205:停止集群服务。
具体的,断开RDMA网络连接,停止RDMA网络通信进程,最后清理集群配置信息。
本申请还提供了一个资源锁管理方法的实施例,如图23所示,开源的ocfs2集群文件系统集群节点的加解锁流程如下:
S2300:文件读写。
具体的,用户态应用程序通过装置(glibc)库,调用读/写(read/write)系统调用接口,然后,在内核触发调用ocfs2在VFS层注册的文件读写函数。
S2301:加集群锁。
具体的,获取文件索引节点号,对索引节点号进行哈希(hash)运算规则一,生成资源锁信息对应的第二节点的节点编号,然后再对索引节点号进行hash运算规则二,找到资源锁信息在hash table中的具体位置。其中,所述hash table如图24所示。读取资源锁信息,根据资源锁的当前状态,判断是否可以加锁。通过RDMA提供的比较和交换(compare and swap)/获取并添加(fetch and add)命令,修改hash table中的资源锁信息的值,完成独占锁/共享锁的加锁操作。
S2302:确定加锁是否成功。
其中,若确定加锁失败,则重试加锁。
具体的,如果compare and swap/fetch and add命令返回失败,表示资源锁已经被其它节点加锁,则尝试加入锁队列,排队等待加锁。如果发现第二节点宕机故障,则将加锁请求重定向到新的第二节点,完成加锁。
S2303:文件系统执行IO操作。
具体的,为本次IO操作分配内存和磁盘空间,将用户数据组成块设备的输入/输出(block input output,bio)结构体,向对应块设备的物理地址下发bio请求,等待IO结果返回。
S2304:释放集群锁。
具体的,IO结果返回后,通过RDMA提供的compare and swap/fetch and add命令,修改hashtable中的资源锁信息的值,释放独占锁/共享锁,至此本次IO结束。
本申请的一个实施例,以用户态分布式锁方案为例,介绍RDLM的加解锁流程,具体流程如图25所示。
S2500:安装RDLM函数库。
具体的,在集群所有主机上安装RDLM函数库和接口头文件,应用程序包含头文件后就可以调用RDLM加解锁接口。
S2501:配置集群锁信息。
具体的,在集群所有主机上创建集群配置文件,并添加主机名称和IP地址信息,然后规划第一节点和第二节点。
S2502:启动集群锁服务。
具体的,在第一节点上启动集群锁服务,监听远端第二节点连接,然后为资源锁hashtable分配内存空间并将内存注册到RDMA,用于远程数据交换。
S2503:加集群锁。
具体的,根据需要保护的临界区域的内容或者特征,计算出全局唯一通用唯一识别码(universally unique identifier,UUID),对UUID进行hash运算规则一生成对应的第二节点编号,然后再对UUID进行hash运算规则二生成。找到资源锁信息在hash table中的具体位置。读取资源锁信息,根据资源锁的当前状态,判断是否可以加锁。通过RDMA提供的compare and swap/fetch and add命令,修改hash table中的资源锁信息的值,完成独占锁/共享锁的加锁操作。
S2504:确定加锁是否成功。
其中,若确定加锁失败,则重试加锁。
具体的,如果compare and swap/fetch and add命令返回失败,表示资源锁已经被其它节点加锁,则尝试加入锁队列,排队等待加锁。如果发现第一节点宕机故障,则将加锁请求重定向到新的第一节点,完成加锁。
S2505:操作临界区域。
具体的,加锁成功后,表示临界区域进入保护状态,应用程序可以访问操作。
S2506:释放集群锁。
具体的,临界区域操作完成后,通过RDMA提供的compare and swap/fetch and add命令,修改hash table中的资源锁信息的值,释放独占锁/共享锁。
通过上述对本申请方案的介绍,可以理解的是,上述实现各设备为了实现上述功能,其包含了执行各个功能相应的硬件结构和/或软件模块。本领域技术人员应该很容易意识到,结合本文中所公开的实施例描述的各示例的单元及算法步骤,本申请能够以硬件或硬件和计算机软件的结合形式来实现。某个功能究竟以硬件还是计算机软件驱动硬件的方式来执行,取决于技术方案的特定应用和设计约束条件。专业技术人员可以对每个特定的应用来使用不同方法来实现所描述的功能,但是这种实现不应认为超出本申请的范围。
如图26所示,本申请一种资源锁管理装置,该装置包括处理器2600、存储器2601和通信接口2602。
处理器2600负责管理总线架构和通常的处理,存储器2601可以存储处理器2600在执行操作时所使用的数据。通信接口2602用于处理器2600与存储器2601进行数据通信。
所述处理器2600可以是中央处理器(central processing unit,CPU),网络处理器(network processor,NP)或者CPU和NP的组合。所述处理器2600还可以进一步包括硬件芯片。上述硬件芯片可以是专用集成电路(application-specific integrated circuit,ASIC),可编程逻辑器件(programmable logic device,PLD)或其组合。上述PLD可以是复杂可编程逻辑器件(complex programmable logic device,CPLD),现场可编程逻辑门阵列(field-programmable gate array,FPGA),通用阵列逻辑(generic array logic,GAL)或其任意组合。存储器1601可以包括:U盘、移动硬盘、只读存储器(read-only memory,ROM)、随机存取存储器(random access memory,RAM)、磁碟或者光盘等各种可以存储程序代码的介质。
所述处理器2600、所述存储器2601以及所述通信接口2602之间相互连接。可选的,所述处理器2600、所述存储器2601以及所述通信接口2602可以通过总线2603相互连接;所述总线2603可以是外设部件互连标准(peripheral component interconnect,PCI)总线或扩展工业标准结构(extended industry standard architecture,EISA)总线等。所述总线可以分为地址总线、数据总线、控制总线等。为便于表示,图26中仅用一条粗线表示,但并不表示仅有一根总线或一种类型的总线。
具体地,所述处理器2600,用于读取存储器2601中的程序并执行:
用于确定向目标资源添加资源锁,获取目标资源对应的资源锁信息,其中,所述资源锁信息用于表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息,所述资源锁的类型为独占锁或共享锁;根据所述资源锁信息确定是否满足第一资源锁添加条件;若是,则对所述目标资源添加资源锁,并更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁;否则,排队等待添加资源锁,且更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中;并监测所述资源锁信息,直至确定所述资源锁信息满足第二资源锁添加条件时,对所述目标资源添加资源锁,更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除。
在一种可能的实现方法中,所述处理器2600具体用于:
从本地获取所述目标资源对应的所述资源锁信息;或从第二节点获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方法中,所述处理器2600具体用于:
确定存储有所述目标资源的所述第二节点;从所述第二节点中获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方法中,所述处理器2600具体用于:
根据主从节点映射关系,确定所述第一节点的主节点为所述第二节点。
在一种可能的实现方法中,所述处理器2600具体用于:
通过远程直接内存访问RDMA技术,从所述第二节点获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方法中,所述资源锁信息包含:独占锁指示信息、等待节点队列、共享节点数量;其中,所述独占锁指示信息用于指示所述目标资源是否添加独占锁,所述共享节点数量为已对所述目标资源添加共享锁的节点数量,所述等待节点队列包含请求对所述目标资源添加资源锁的节点标识,且所述等待节点队列中的节点标识按照请求添加资 源锁的前后顺序排列。
在一种可能的实现方法中,当所述资源锁的类型为独占锁时,所述第一资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述等待节点队列为空;所述第二资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述第一节点的节点标识位于所述等待节点队列首位。
在一种可能的实现方法中,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
所述处理器2600具体用于:
将所述第一节点的节点标识添加到所述等待节点队列中,并将所述独占锁请求节点数量加1;或者
更新所述独占锁指示信息,将所述独占锁请求节点数量减1,将所述等待节点队列中所述第一节点的节点标识删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
在一种可能的实现方法中,所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
所述处理器2600具体用于:
将所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息添加到所述等待节点队列中;或者
更新所述独占锁指示信息,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
在一种可能的实现方法中,当所述资源锁为共享锁时,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
所述第一资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述独占锁请求节点数量为0;所述第二资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
在一种可能的实现方法中,所述处理器2600还用于:
将所述共享节点数量加1;或
将所述共享节点数量加1,以及将所述等待节点队列中所述第一节点的节点标识删除。
在一种可能的实现方法中,所述资源锁信息还包含共享锁请求节点数量,其中,所述共享锁请求节点数量为所述等待节点队列中请求添加共享锁的节点数量;
所述处理器2600具体用于:
将所述第一节点的节点标识添加到所述等待节点队列中,并将所述共享锁请求节点数量加1;或
将所述共享节点数量加1,将所述共享锁请求节点数量减1,以及将所述等待节点队列中所述第一节点的节点标识删除。
在一种可能的实现方法中,当所述资源锁为共享锁时,所述等待节点队列中还包含每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
所述第一资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述等待节点队列中不包含对应的资源锁类型指示信息指示独占锁的节点;
所述第二资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
在一种可能的实现方法中,所述处理器2600具体用于:
所述第一节点将所述共享节点数量加1;或将所述共享节点数量加1,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的资源锁类型指示信息删除。
在一种可能的实现方法中,所述处理器2600还用于:
对所述目标资源解除所述独占锁,并更新所述独占锁指示信息,其中,更新后的所述独占锁指示信息指示所述目标资源未添加独占锁。
在一种可能的实现方法中,所述处理器2600还用于:
对所述目标资源解除所述共享锁,并将所述共享节点数量减1。
如图27所示,本申请提供一种资源锁管理装置,该装置包括:
获取模块2700:用于确定向目标资源添加资源锁,获取目标资源对应的资源锁信息,其中,所述资源锁信息用于表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息,所述资源锁的类型为独占锁或共享锁;
处理模块2701:用于根据所述资源锁信息确定是否满足第一资源锁添加条件;若是,则对所述目标资源添加资源锁,并更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁;否则,排队等待添加资源锁,且更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中;并监测所述资源锁信息,直至确定所述资源锁信息满足第二资源锁添加条件时,对所述目标资源添加资源锁,更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除。
在一种可能的实现方法中,所述获取模块2700具体用于:
从本地获取所述目标资源对应的所述资源锁信息;或从第二节点获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方法中,所述获取模块2700具体用于:
确定存储有所述目标资源的所述第二节点;从所述第二节点中获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方法中,所述处理模块2701具体用于:
根据主从节点映射关系,确定所述第一节点的主节点为所述第二节点。
在一种可能的实现方法中,所述处理模块2701具体用于:
通过远程直接内存访问RDMA技术,从所述第二节点获取所述目标资源对应的所述资源锁信息。
在一种可能的实现方法中,所述资源锁信息包含:独占锁指示信息、等待节点队列、共享节点数量;其中,所述独占锁指示信息用于指示所述目标资源是否添加独占锁,所述共享节点数量为已对所述目标资源添加共享锁的节点数量,所述等待节点队列包含请求对所述目标资源添加资源锁的节点标识,且所述等待节点队列中的节点标识按照请求添加资源锁的前后顺序排列。
在一种可能的实现方法中,当所述资源锁的类型为独占锁时,所述第一资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述等待节点队列为空;所述第二资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述第一节点的节点标识位于所述等待节点队列首位。
在一种可能的实现方法中,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
所述处理模块2701具体用于:
将所述第一节点的节点标识添加到所述等待节点队列中,并将所述独占锁请求节点数量加1;或者
更新所述独占锁指示信息,将所述独占锁请求节点数量减1,将所述等待节点队列中所述第一节点的节点标识删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
在一种可能的实现方法中,所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
所述处理模块2701具体用于:
将所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息添加到所述等待节点队列中;或者
更新所述独占锁指示信息,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
在一种可能的实现方法中,当所述资源锁为共享锁时,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
所述第一资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述独占锁请求节点数量为0;所述第二资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
在一种可能的实现方法中,所述处理模块2701还用于:
将所述共享节点数量加1;或
将所述共享节点数量加1,以及将所述等待节点队列中所述第一节点的节点标识删除。
在一种可能的实现方法中,所述资源锁信息还包含共享锁请求节点数量,其中,所述共享锁请求节点数量为所述等待节点队列中请求添加共享锁的节点数量;
所述处理模块2701具体用于:
将所述第一节点的节点标识添加到所述等待节点队列中,并将所述共享锁请求节点数量加1;或
将所述共享节点数量加1,将所述共享锁请求节点数量减1,以及将所述等待节点队列中所述第一节点的节点标识删除。
在一种可能的实现方法中,当所述资源锁为共享锁时,所述等待节点队列中还包含每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
所述第一资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述等待节点队列中不包含对应的资源锁类型指示信息指示独占锁的节点;
所述第二资源锁添加条件为:
所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
在一种可能的实现方法中,所述处理模块2701具体用于:
所述第一节点将所述共享节点数量加1;或将所述共享节点数量加1,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的资源锁类型指示信息删除。
在一种可能的实现方法中,所述处理模块2701还用于:
对所述目标资源解除所述独占锁,并更新所述独占锁指示信息,其中,更新后的所述独占锁指示信息指示所述目标资源未添加独占锁。
在一种可能的实现方法中,所述处理模块2701还用于:
对所述目标资源解除所述共享锁,并将所述共享节点数量减1。
在一些可能的实施方式中,本申请实施例提供的资源锁管理方法的各个方面还可以实现为一种程序产品的形式,其包括程序代码,当所述程序代码在计算机设备上运行时,所述程序代码用于使所述计算机设备执行本说明书中描述的根据本申请各种示例性实施方式的资源锁管理方法中的步骤。
所述程序产品可以采用一个或多个可读介质的任意组合。可读介质可以是可读信号介质或者可读存储介质。可读存储介质例如可以是——但不限于——电、磁、光、电磁、红外线、或半导体的系统、装置或器件,或者任意以上的组合。可读存储介质的更具体的例子(非穷举的列表)包括:具有一个或多个导线的电连接、便携式盘、硬盘、随机存取存储器(RAM)、只读存储器(ROM)、可擦式可编程只读存储器(EPROM或闪存)、光纤、便携式紧凑盘只读存储器(CD-ROM)、光存储器件、磁存储器件、或者上述的任意合适的组合。
根据本申请的实施方式的用于资源锁管理程序产品,其可以采用便携式紧凑盘只读存储器(CD-ROM)并包括程序代码,并可以在服务器设备上运行。然而,本申请的程序产品不限于此,在本文件中,可读存储介质可以是任何包含或存储程序的有形介质,该程序可以被信息传输、装置或者器件使用或者与其结合使用。
可读信号介质可以包括在基带中或者作为载波一部分传播的数据信号,其中承载了可读程序代码。这种传播的数据信号可以采用多种形式,包括——但不限于——电磁信号、光信号或上述的任意合适的组合。可读信号介质还可以是可读存储介质以外的任何可读介质,该可读介质可以发送、传播或者传输用于由周期网络动作系统、装置或者器件使用或 者与其结合使用的程序。
可读介质上包含的程序代码可以用任何适当的介质传输,包括——但不限于——无线、有线、光缆、RF等,或者上述的任意合适的组合。
可以以一种或多种程序设计语言的任意组合来编写用于执行本申请操作的程序代码,所述程序设计语言包括面向对象的程序设计语言—诸如Java、C++等,还包括常规的过程式程序设计语言—诸如“C”语言或类似的程序设计语言。程序代码可以完全地在用户计算设备上执行、部分地在用户设备上执行、作为一个独立的软件包执行、部分在用户计算设备上部分在远程计算设备上执行、或者完全在远程计算设备或服务器上执行。在涉及远程计算设备的情形中,远程计算设备可以通过任意种类的网络——包括局域网(LAN)或广域网(WAN)—连接到用户计算设备,或者,可以连接到外部计算设备。
本申请实施例针对资源锁管理的方法还提供一种计算设备可读存储介质,即断电后内容不丢失。该存储介质中存储软件程序,包括程序代码,当所述程序代码在计算设备上运行时,该软件程序在被一个或多个处理器读取并执行时可实现本申请实施例上面任何一种资源锁管理的方案。
以上参照示出根据本申请实施例的方法、装置(系统)和/或计算机程序产品的框图和/或流程图描述本申请。应理解,可以通过计算机程序指令来实现框图和/或流程图示图的一个块以及框图和/或流程图示图的块的组合。可以将这些计算机程序指令提供给通用计算机、专用计算机的处理器和/或其它可编程数据处理装置,以产生机器,使得经由计算机处理器和/或其它可编程数据处理装置执行的指令创建用于实现框图和/或流程图块中所指定的功能/动作的方法。
相应地,还可以用硬件和/或软件(包括固件、驻留软件、微码等)来实施本申请。更进一步地,本申请可以采取计算机可使用或计算机可读存储介质上的计算机程序产品的形式,其具有在介质中实现的计算机可使用或计算机可读程序代码,以由指令执行系统来使用或结合指令执行系统而使用。在本申请上下文中,计算机可使用或计算机可读介质可以是任意介质,其可以包含、存储、通信、传输、或传送程序,以由指令执行系统、装置或设备使用,或结合指令执行系统、装置或设备使用。
尽管结合具体特征及其实施例对本申请进行了描述,显而易见的,在不脱离本申请的精神和范围的情况下,可对其进行各种修改和组合。相应地,本说明书和附图仅仅是所附权利要求所界定的本申请的示例性说明,且视为已覆盖本申请范围内的任意和所有修改、变化、组合或等同物。显然,本领域的技术人员可以对本申请进行各种改动和变型而不脱离本申请的范围。这样,倘若本申请的这些修改和变型属于本申请权利要求及其等同技术的范围之内,则本申请也意图包括这些改动和变型在内。

Claims (34)

  1. 一种资源锁管理方法,其特征在于,包括:
    第一节点确定向目标资源添加资源锁,获取目标资源对应的资源锁信息,其中,所述资源锁信息用于表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息,所述资源锁的类型为独占锁或共享锁;
    所述第一节点根据所述资源锁信息确定是否满足第一资源锁添加条件;
    若是,则所述第一节点对所述目标资源添加资源锁,并更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁;
    否则,所述第一节点排队等待添加资源锁,且更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中;并监测所述资源锁信息,直至确定所述资源锁信息满足第二资源锁添加条件时,对所述目标资源添加资源锁,更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除。
  2. 如权利要求1所述的方法,其特征在于,所述第一节点获取所述目标资源对应的所述资源锁信息,包括:
    所述第一节点从本地获取所述目标资源对应的所述资源锁信息;或
    所述第一节点从第二节点获取所述目标资源对应的所述资源锁信息。
  3. 如权利要求2所述的方法,其特征在于,所述第一节点从所述第二节点获取所述目标资源对应的所述资源锁信息,包括:
    所述第一节点确定存储有所述目标资源的所述第二节点;
    所述第一节点从所述第二节点中获取所述目标资源对应的所述资源锁信息。
  4. 如权利要求3所述的方法,其特征在于,所述第一节点确定存储有所述目标资源的所述第二节点,包括:
    所述第一节点根据主从节点映射关系,确定所述第一节点的主节点为所述第二节点。
  5. 如权利要求2或3所述的方法,其特征在于,所述第一节点从所述第二节点获取所述目标资源对应的所述资源锁信息,包括:
    所述第一节点通过远程直接内存访问RDMA技术,从所述第二节点获取所述目标资源对应的所述资源锁信息。
  6. 如权利要求1-5任一项所述的方法,其特征在于,所述资源锁信息包含:独占锁指示信息、等待节点队列、共享节点数量;
    其中,所述独占锁指示信息用于指示所述目标资源是否添加独占锁,所述共享节点数量为已对所述目标资源添加共享锁的节点数量,所述等待节点队列包含请求对所述目标资源添加资源锁的节点标识,且所述等待节点队列中的节点标识按照请求添加资源锁的前后顺序排列。
  7. 如权利要求6所述的方法,其特征在于,当所述资源锁的类型为独占锁时,所述第一资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述等待节点队列为空;
    所述第二资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述第一节点的节点标识位于所述等待节点队列首位。
  8. 如权利要求7所述的方法,其特征在于,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,包括:
    所述第一节点将所述第一节点的节点标识添加到所述等待节点队列中,并将所述独占锁请求节点数量加1;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:
    所述第一节点更新所述独占锁指示信息,将所述独占锁请求节点数量减1,将所述等待节点队列中所述第一节点的节点标识删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
  9. 如权利要求7所述的方法,其特征在于,所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,包括:
    所述第一节点将所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息添加到所述等待节点队列中;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:
    所述第一节点更新所述独占锁指示信息,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
  10. 如权利要求6所述的方法,其特征在于,当所述资源锁为共享锁时,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
    所述第一资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述独占锁请求节点数量为0;所述第二资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
  11. 如权利要求10所述的方法,其特征在于,所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁,包括:
    所述第一节点将所述共享节点数量加1;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:
    所述第一节点将所述共享节点数量加1,以及将所述等待节点队列中所述第一节点的节点标识删除。
  12. 如权利要求10所述的方法,其特征在于,所述资源锁信息还包含共享锁请求节点数量,其中,所述共享锁请求节点数量为所述等待节点队列中请求添加共享锁的节点数量;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中,包括:
    所述第一节点将所述第一节点的节点标识添加到所述等待节点队列中,并将所述共享锁请求节点数量加1;
    所述第一节点更新所述所资源锁信息,以使更新后的所述所资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:
    所述第一节点将所述共享节点数量加1,将所述共享锁请求节点数量减1,以及将所述等待节点队列中所述第一节点的节点标识删除。
  13. 如权利要求6所述的方法,其特征在于,当所述资源锁为共享锁时,所述等待节点队列中还包含每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
    所述第一资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述等待节点队列中不包含对应的资源锁类型指示信息指示独占锁的节点;
    所述第二资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
  14. 如权利要求13所述的方法,其特征在于,所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁,包括:
    所述第一节点将所述共享节点数量加1;
    所述第一节点更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除,包括:
    所述第一节点将所述共享节点数量加1,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的资源锁类型指示信息删除。
  15. 如权利要求7-9任一所述的方法,其特征在于,所述第一节点对所述目标资源添加独占锁之后,所述方法还包括:
    所述第一节点对所述目标资源解除所述独占锁,并更新所述独占锁指示信息,其中,更新后的所述独占锁指示信息指示所述目标资源未添加独占锁。
  16. 如权利要求10-14任一所述的方法,其特征在于,所述第一节点对所述目标资源添加共享锁之后,所述方法还包括:
    所述第一节点对所述目标资源解除所述共享锁,并将所述共享节点数量减1。
  17. 一种资源锁管理装置,其特征在于,包括:处理单元和通信单元;
    所述处理单元,用于确定向目标资源添加资源锁,获取目标资源对应的资源锁信息,其中,所述资源锁信息用于表征所述目标资源是否已添加资源锁,以及请求添加资源锁的等待节点队列的信息,所述资源锁的类型为独占锁或共享锁;根据所述资源锁信息确定是否满足第一资源锁添加条件;若是,则对所述目标资源添加资源锁,并更新所述资源锁信息,以使更新后的所述资源锁信息表征所述目标资源已添加资源锁;否则,排队等待添加资源锁,且更新所述资源锁信息,以使更新后的所述资源锁信息表征所述第一节点已加入所述等待节点队列中;并监测所述资源锁信息,直至确定所述资源锁信息满足第二资源锁添加条件时,对所述目标资源添加资源锁,更新所述资源锁信息,以使更新后的所述资源锁信息表征:所述目标资源已添加资源锁,且所述第一节点已从所述等待节点队列中删除。
  18. 如权利要求17所述的装置,其特征在于,所述处理单元具体用于:
    从本地获取所述目标资源对应的所述资源锁信息;或从第二节点获取所述目标资源对应的所述资源锁信息。
  19. 如权利要求18所述的装置,其特征在于,所述处理单元具体用于:
    确定存储有所述目标资源的所述第二节点;从所述第二节点中获取所述目标资源对应的所述资源锁信息。
  20. 如权利要求19所述的装置,其特征在于,所述处理单元具体用于:
    根据主从节点映射关系,确定所述第一节点的主节点为所述第二节点。
  21. 如权利要求18或19所述的装置,其特征在于,所述处理单元具体用于:
    通过远程直接内存访问RDMA技术,从所述第二节点获取所述目标资源对应的所述资源锁信息。
  22. 如权利要求17-21任一所述的装置,其特征在于,所述资源锁信息包含:独占锁指示信息、等待节点队列、共享节点数量;其中,所述独占锁指示信息用于指示所述目标资源是否添加独占锁,所述共享节点数量为已对所述目标资源添加共享锁的节点数量,所述等待节点队列包含请求对所述目标资源添加资源锁的节点标识,且所述等待节点队列中 的节点标识按照请求添加资源锁的前后顺序排列。
  23. 如权利要求22所述的装置,其特征在于,当所述资源锁的类型为独占锁时,所述第一资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述等待节点队列为空;所述第二资源锁添加条件为:所述独占锁指示信息指示所述目标资源未添加独占锁、所述共享节点数量为0,且所述第一节点的节点标识位于所述等待节点队列首位。
  24. 如权利要求23所述的装置,其特征在于,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
    所述处理单元具体用于:
    将所述第一节点的节点标识添加到所述等待节点队列中,并将所述独占锁请求节点数量加1;或者
    更新所述独占锁指示信息,将所述独占锁请求节点数量减1,将所述等待节点队列中所述第一节点的节点标识删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
  25. 如权利要求23所述的装置,其特征在于,所述等待节点队列中还包含:每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
    所述处理单元具体用于:
    将所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息添加到所述等待节点队列中;或者
    更新所述独占锁指示信息,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的指示独占锁的指示信息删除;其中,更新后的所述独占锁指示信息指示所述目标资源已添加独占锁。
  26. 如权利要求22所述的装置,其特征在于,当所述资源锁为共享锁时,所述资源锁信息还包含独占锁请求节点数量,其中,所述独占锁请求节点数量为所述等待节点队列中请求添加独占锁的节点数量;
    所述第一资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述独占锁请求节点数量为0;所述第二资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
  27. 如权利要求26所述的装置,其特征在于,所述处理单元具体用于:
    将所述共享节点数量加1;或
    将所述共享节点数量加1,以及将所述等待节点队列中所述第一节点的节点标识删除。
  28. 如权利要求26所述的装置,其特征在于,所述资源锁信息还包含共享锁请求节点数量,其中,所述共享锁请求节点数量为所述等待节点队列中请求添加共享锁的节点数量;
    所述处理单元具体用于:
    将所述第一节点的节点标识添加到所述等待节点队列中,并将所述共享锁请求节点数量加1;或
    将所述共享节点数量加1,将所述共享锁请求节点数量减1,以及将所述等待节点队列中所述第一节点的节点标识删除。
  29. 如权利要求22所述的装置,其特征在于,当所述资源锁为共享锁时,所述等待节点队列中还包含每个节点的资源锁类型指示信息,其中任一个节点的资源锁类型指示信息用于指示所述节点请求添加资源锁的类型;
    所述第一资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述等待节点队列中不包含对应的资源锁类型指示信息指示独占锁的节点;
    所述第二资源锁添加条件为:
    所述独占锁指示信息指示所述目标资源未添加独占锁,且所述第一节点的节点标识位于所述等待节点队列首位。
  30. 如权利要求29所述的装置,其特征在于,所述处理单元具体用于:
    所述第一节点将所述共享节点数量加1;或将所述共享节点数量加1,将所述等待节点队列中所述第一节点的节点标识和所述第一节点的资源锁类型指示信息删除。
  31. 如权利要求23-25任一所述的装置,其特征在于,所述处理单元还用于:
    对所述目标资源解除所述独占锁,并更新所述独占锁指示信息,其中,更新后的所述独占锁指示信息指示所述目标资源未添加独占锁。
  32. 如权利要求26-30任一所述的装置,其特征在于,所述处理单元还用于:
    对所述目标资源解除所述共享锁,并将所述共享节点数量减1。
  33. 一种节点,其特征在于,包括:处理器、通信接口和存储器;
    所述存储器,用于存储程序指令;
    所述处理器,用于通过调用所述存储器存储的程序指令,通过所述通信接口执行如权利要求1至16中任意一项所述的方法。
  34. 一种计算机可读存储介质,其特征在于,所述计算机可读存储介质存储有计算机可执行指令,所述计算机可执行指令用于使计算机执行如权利要求1至16中任一项所述的方法。
PCT/CN2020/091650 2019-06-26 2020-05-21 一种资源锁管理方法及装置 WO2020259146A1 (zh)

Priority Applications (1)

Application Number Priority Date Filing Date Title
US17/557,926 US20220114145A1 (en) 2019-06-26 2021-12-21 Resource Lock Management Method And Apparatus

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201910563273.X 2019-06-26
CN201910563273.XA CN112148695A (zh) 2019-06-26 2019-06-26 一种资源锁管理方法及装置

Related Child Applications (1)

Application Number Title Priority Date Filing Date
US17/557,926 Continuation US20220114145A1 (en) 2019-06-26 2021-12-21 Resource Lock Management Method And Apparatus

Publications (1)

Publication Number Publication Date
WO2020259146A1 true WO2020259146A1 (zh) 2020-12-30

Family

ID=73869979

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2020/091650 WO2020259146A1 (zh) 2019-06-26 2020-05-21 一种资源锁管理方法及装置

Country Status (3)

Country Link
US (1) US20220114145A1 (zh)
CN (1) CN112148695A (zh)
WO (1) WO2020259146A1 (zh)

Families Citing this family (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN113704191B (zh) * 2021-07-23 2023-11-03 郑州云海信息技术有限公司 一种集群文件系统访问方法、装置、设备及可读存储介质
CN114679465A (zh) * 2022-03-28 2022-06-28 北京火山引擎科技有限公司 资源操作方法、装置、电子设备及存储介质
US11907117B2 (en) * 2022-06-08 2024-02-20 Dell Products L.P. Efficient method to dynamically select a protection duration for retention locking deduplicated objects
CN117519945A (zh) * 2023-12-07 2024-02-06 北京优炫软件股份有限公司 一种数据库资源调度方法、装置及系统
CN117742979B (zh) * 2024-02-18 2024-04-23 中国电子科技集团公司第十五研究所 一种面向时空数据处理的分布式锁方法及电子设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040002974A1 (en) * 2002-06-27 2004-01-01 Intel Corporation Thread based lock manager
CN101236509A (zh) * 2007-01-30 2008-08-06 国际商业机器公司 用于管理锁的系统和方法
US20090094243A1 (en) * 2004-06-23 2009-04-09 Exanet Ltd. Method for managing lock resources in a distributed storage system
CN101446909A (zh) * 2007-11-30 2009-06-03 国际商业机器公司 用于管理任务事件的方法和系统
CN104536834A (zh) * 2014-11-26 2015-04-22 华为技术有限公司 一种授权锁权限的方法和分布式锁管理器
CN107181789A (zh) * 2017-03-31 2017-09-19 北京奇艺世纪科技有限公司 一种分布式锁实现方法及装置

Family Cites Families (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US7640315B1 (en) * 2000-08-04 2009-12-29 Advanced Micro Devices, Inc. Implementing locks in a distributed processing system
US7346720B2 (en) * 2005-10-21 2008-03-18 Isilon Systems, Inc. Systems and methods for managing concurrent access requests to a shared resource
CN101256509B (zh) * 2008-04-07 2010-09-01 中兴通讯股份有限公司 一种锁机制的加锁方法、解锁方法和实现方法
US8145817B2 (en) * 2009-04-28 2012-03-27 Microsoft Corporation Reader/writer lock with reduced cache contention
CN102103523A (zh) * 2009-12-22 2011-06-22 国际商业机器公司 锁分配控制的方法和装置
CN102355473B (zh) * 2011-06-28 2013-12-25 用友软件股份有限公司 分布式计算环境下的锁定控制系统和方法
US8868604B2 (en) * 2012-09-26 2014-10-21 Oracle International Corporation Methods and apparatus for implementing Semi-distributed Lock Management
US9747288B1 (en) * 2012-12-10 2017-08-29 Amazon Technologies, Inc. Scalable transaction-based data repository service
CN104376025B (zh) * 2013-08-16 2017-10-10 华为技术有限公司 分布式数据库的数据存储方法和装置
CN106991008B (zh) * 2016-01-20 2020-12-18 华为技术有限公司 一种资源锁管理方法、相关设备及系统
WO2018176397A1 (zh) * 2017-03-31 2018-10-04 华为技术有限公司 一种锁分配的方法、装置和计算设备

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20040002974A1 (en) * 2002-06-27 2004-01-01 Intel Corporation Thread based lock manager
US20090094243A1 (en) * 2004-06-23 2009-04-09 Exanet Ltd. Method for managing lock resources in a distributed storage system
CN101236509A (zh) * 2007-01-30 2008-08-06 国际商业机器公司 用于管理锁的系统和方法
CN101446909A (zh) * 2007-11-30 2009-06-03 国际商业机器公司 用于管理任务事件的方法和系统
CN104536834A (zh) * 2014-11-26 2015-04-22 华为技术有限公司 一种授权锁权限的方法和分布式锁管理器
CN107181789A (zh) * 2017-03-31 2017-09-19 北京奇艺世纪科技有限公司 一种分布式锁实现方法及装置

Also Published As

Publication number Publication date
CN112148695A (zh) 2020-12-29
US20220114145A1 (en) 2022-04-14

Similar Documents

Publication Publication Date Title
WO2020259146A1 (zh) 一种资源锁管理方法及装置
US10382380B1 (en) Workload management service for first-in first-out queues for network-accessible queuing and messaging services
US8935560B2 (en) System and method of file locking in a network file system federated namespace
EP3564835A1 (en) Data redistribution method and apparatus, and database cluster
CN110119304B (zh) 一种中断处理方法、装置及服务器
US9747323B1 (en) Method for reconstruction of a distributed lock state after a node addition or removal using a consistent hash
EP4160425A1 (en) Data transmission method, chip, and device
WO2021057108A1 (zh) 一种读数据方法、写数据方法及服务器
US8185633B1 (en) Method and apparatus for offloading network processes in a computer storage system
WO2021082465A1 (zh) 一种保证数据一致性的方法及相关设备
US11231964B2 (en) Computing device shared resource lock allocation
US10732904B2 (en) Method, system and computer program product for managing storage system
CN110162395B (zh) 一种内存分配的方法及装置
WO2023029485A1 (zh) 数据处理方法、装置、计算机设备及计算机可读存储介质
CN108920092B (zh) 内存数据的数据操作方法、装置及电子设备
US8090832B1 (en) Method and apparatus for allocating network protocol operation resources
WO2022218218A1 (zh) 数据处理方法、装置、归约服务器及映射服务器
JP6947421B2 (ja) 監視装置、排他制御システム、プログラム及び制御方法
KR101889749B1 (ko) 메시지 스케줄링 방법
CN114281765A (zh) 分布式文件系统中的元数据处理方法及设备
WO2018188416A1 (zh) 一种数据搜索的方法、装置和相关设备
JP7305898B2 (ja) 操作応答方法、操作応答装置、電子機器及び記憶媒体
CN111782634A (zh) 数据分布式存储方法、装置、电子设备及存储介质
WO2020207078A1 (zh) 数据处理方法、装置和分布式数据库系统
EP4170513A1 (en) Database system, and method and apparatus for managing transactions

Legal Events

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

Ref document number: 20830528

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 20830528

Country of ref document: EP

Kind code of ref document: A1