Lock management method in cluster, lock server, and client
AssigneeHuawei Technologies Co., Ltd.
InventorsWenhai Lan, Wei Zhang, Xueyou Wang, Yue Zhang
Life of this patent
Estimating the term…
Abstract
A lock management solution in a cluster, where the cluster includes a client and a lock server, the lock server includes an interface card and a memory, the memory stores a read lock request queue recording an identifier of a client waiting for a read lock or obtaining the read lock, the memory further stores a write lock request queue recording an identifier of a client waiting for a write lock or obtains the write lock, and the memory further includes a read lock allocation count and a write lock allocation identifier, where the read lock allocation count records an allocated read lock, and the write lock allocation identifier indicates whether the write lock has been allocated.
Claims13
A lock management method in a cluster, the cluster comprising a plurality of clients and a lock server, the lock server comprising an interface card and a memory, and the method comprising:
- receiving, by the interface card, a first write lock request carrying an identifier of a first client in the clients and a memory address of a queue head of a write lock request queue in the memory from the first client, the write lock request queue recording an identifier of a client in a write lock waiting state for a shared resource and an identifier of a client obtaining a write lock for the shared resource, a write lock allocation identifier indicating whether the write lock for the shared resource is allocated, and a read lock allocation count indicating a quantity of read locks allocated for the shared resource;
- writing, by the interface card, the identifier of the first client into the memory address of the queue head of the write lock request queue;
- querying, by the interface card, the read lock allocation count to determine whether a read lock has been allocated;
- setting, by the interface card, the write lock allocation identifier to a write lock allocated state when the read lock is not allocated;
- sending, by the interface card, a first message to the first client indicating that the first client obtains the write lock;
- and
- sending, by the interface card, a second message indicating that the first client is in the write lock waiting state to the first client.
A lock server, applied to a cluster comprising a plurality of clients, comprising:
- a memory configured to store a write lock request queue, the write lock request queue recording an identifier of a client in a write lock waiting state for a shared resource and an identifier of a client obtaining a write lock for the shared resource, a write lock allocation identifier indicating whether the write lock for the shared resource is allocated, and a read lock allocation count indicating a quantity of read locks allocated for the shared resource;
- and
- an interface card coupled to the memory and configured to:
- receive a first write lock request carrying an identifier of a first client in the clients and a memory address of a queue head of the write lock request queue from the first client;
- write the identifier of the first client into the memory address of the queue head of the write lock request queue;
- query the read lock allocation count to determine whether a read lock has been allocated;
- set the write lock allocation identifier to a write lock allocated state when the read lock is not allocated;
- send a first message to the first client indicating that the first client obtains the write lock;
- and
- send a second message indicating that the first client is in a write lock waiting state to the first client when the read lock has been allocated.
Dependencies are inferred from the claim text.