CN109189583B - Distributed lock implementation method and device - Google Patents

Distributed lock implementation method and device Download PDF

Info

Publication number
CN109189583B
CN109189583B CN201811103385.9A CN201811103385A CN109189583B CN 109189583 B CN109189583 B CN 109189583B CN 201811103385 A CN201811103385 A CN 201811103385A CN 109189583 B CN109189583 B CN 109189583B
Authority
CN
China
Prior art keywords
storage pool
type
sanlock
execution mode
distributed lock
Prior art date
Legal status (The legal status 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 status listed.)
Active
Application number
CN201811103385.9A
Other languages
Chinese (zh)
Other versions
CN109189583A (en
Inventor
马怀旭
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Zhengzhou Yunhai Information Technology Co Ltd
Original Assignee
Zhengzhou Yunhai Information Technology Co Ltd
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 Zhengzhou Yunhai Information Technology Co Ltd filed Critical Zhengzhou Yunhai Information Technology Co Ltd
Priority to CN201811103385.9A priority Critical patent/CN109189583B/en
Publication of CN109189583A publication Critical patent/CN109189583A/en
Application granted granted Critical
Publication of CN109189583B publication Critical patent/CN109189583B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

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

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Retrieval, Db Structures And Fs Structures Therefor (AREA)

Abstract

The invention discloses a distributed lock implementation method and device. The method relates to the field of computing resource virtualization, and solves the problem of supporting the storage pool type lock resources. The method comprises the following steps: identifying a current storage pool type; selecting an execution mode according to the type of the current storage pool; and finishing reading and writing of the distributed lock under the selected execution mode. The technical scheme provided by the invention is suitable for computer clusters, and realizes the compatibility of distributed locks of various different storage pools.

Description

Distributed lock implementation method and device
Technical Field
The present invention relates to computing resource virtualization technologies, and in particular, to a distributed lock implementation method and apparatus.
Background
With the rapid development of computer technology and network technology, large clusters are widely used in practical production environments. And forming the cloud computing platform by virtualizing the cluster. In virtualized systems, there is often a need to coordinate actions, with different systems or different hosts within the same system sharing the same resource or set of resources. When sharing resources, mutual exclusion is often required to prevent mutual interference and ensure consistency, so a distributed lock is required to ensure the above situation.
Distributed locks are generally required to support the use of distributed locks in large-format environments, and so sanlock is used to manage resources in a virtualized system. For sanlock, there are generally two ways of use: one is to take a storage pool alone in a cluster to use the distributed lock service provided by sanlock, and the other is to put the lock resource of sanlock on the used storage pool, i.e. the storage pool that serves the upper layers. The second scheme can enable the sanlock to sense the pressure problem of the storage pool and the disconnection problem of the storage pool, so that the effect of guaranteeing the stable operation of the virtual machine is achieved. In the second scheme, however, sanlock does not provide support for various storage pools (e.g., RBD storage pools, etc.) due to the large number of storage pool implementations.
Disclosure of Invention
In order to solve the technical problem, the invention provides a distributed lock implementation method and a distributed lock implementation device.
In order to achieve the purpose of the invention, the invention provides a distributed lock implementation method, which comprises the following steps:
identifying a current storage pool type;
selecting an execution mode according to the type of the current storage pool;
and finishing reading and writing of the distributed lock under the selected execution mode.
Preferably, the storage pool type at least comprises: rados block device RBD storage pool.
Preferably, the step of identifying the current storage pool type comprises:
receiving a path parameter, and extracting a storage pool type label from the path parameter;
and determining the storage pool type according to the content of the storage pool type label.
Preferably, the step of selecting the execution mode according to the current storage pool type comprises:
and when the current storage pool type is the RBD storage pool, selecting a preset I/O model matched with the RBD storage pool.
Preferably, the step of identifying the current storage pool type further comprises:
configuring execution modes corresponding to different storage pool types, wherein the execution modes at least comprise I/O models.
The invention also provides a distributed lock implementation device, which comprises:
the storage pool identification module is used for identifying the type of the current storage pool;
the execution mode selection module is used for selecting an execution mode according to the type of the current storage pool;
and the lock reading and writing module is used for finishing reading and writing of the distributed lock under the selected execution mode.
Preferably, the storage pool identification module comprises:
the label extraction unit is used for receiving the path parameter and extracting the storage pool type label from the path parameter;
and the type matching unit is used for determining the storage pool type according to the content of the storage pool type label.
Preferably, the apparatus further comprises:
and the configuration module is used for configuring execution modes corresponding to different storage pool types, and the execution modes at least comprise I/O models.
The invention provides a method and a device for realizing a distributed lock, which aim at different storage pool types, firstly identify, then select an execution mode according to an identification result, and finish the reading and writing of the distributed lock by using the selected execution mode. The distributed lock compatible with various different storage pools is realized, and the problem of supporting the storage pool type lock resources is solved.
Additional features and advantages of the invention will be set forth in the description which follows, and in part will be obvious from the description, or may be learned by practice of the invention. The objectives and other advantages of the invention will be realized and attained by the structure particularly pointed out in the written description and claims hereof as well as the appended drawings.
Drawings
The accompanying drawings are included to provide a further understanding of the invention and are incorporated in and constitute a part of this specification, illustrate embodiments of the invention and together with the example serve to explain the principles of the invention and not to limit the invention.
Fig. 1 is a schematic flowchart of a distributed lock implementation method according to an embodiment of the present invention;
fig. 2 is a schematic structural diagram of a distributed lock implementation apparatus according to an embodiment of the present invention;
fig. 3 is a schematic diagram of the storage pool identification module 201 in fig. 2.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that the embodiments and features of the embodiments in the present application may be arbitrarily combined with each other without conflict.
The steps illustrated in the flow charts of the figures may be performed in a computer system such as a set of computer-executable instructions. Also, while a logical order is shown in the flow diagrams, in some cases, the steps shown or described may be performed in an order different than here.
Due to the large number of storage pool implementations, sanlock does not provide support for various storage pools (e.g., RBD storage pools, etc.).
In order to solve the above problem, embodiments of the present invention provide a distributed lock implementation method and apparatus. The RBD supports locks without leases, but distributed locks with leases are required during normal use, so that sanlock is required to support the RBD storage pool, and the RBD storage pool supports lock services with leases.
By adding an I/O model of sanlock, support for I/O issuing of sanlock on different types of storage pools such as RBD storage pools and the like is provided, so that the purpose of managing the different types of storage pools by sanlock is achieved.
An embodiment of the present invention provides a distributed lock implementation method, where a process of completing reading and writing of a distributed lock based on multiple different types of storage pools by using the method is shown in fig. 1, and includes:
step 101, configuring execution modes corresponding to different storage pool types.
The execution mode includes at least an I/O model that defines I/O flows for the storage pool. The execution mode may be uniquely identified by the storage pool type tag.
In the embodiment of the invention, a code of the sanlock is modified, an I/O model is added in diskio, and a structural body supporting the RBD storage pool is added in an I/O process of the sanlock, namely, the RBD storage pool is ensured to be opened once, I/O can be normally issued, and handles of the opened cluster and the like are closed when rem _ lockspace is used.
Sanlock supports three I/O models, a common I/O model, an AI/O model, and a linux AI/O model. The general situation is that a file handle is opened and then saved, and I/O operations are performed on the file handle, i.e., all operations may use the same set of I/O flow.
For the RBD storage pool, the pool is opened after the cluster is connected, the I/O context is prepared, the img is opened later, and then the I/O is performed. I/O flows are more complex than general I/O flows, and therefore require specialized I/O models to support the operation of RBD storage pools. The sanlock code is recompiled and the sanlock is reinstalled.
Because the opened file handle is stored in the sync _ disk structure in the general I/O model, in the embodiment of the invention, a structure for supporting the RBD storage pool can be added in the structure.
Preferably, because the RBD storage pool is used, the stored fd file handle becomes useless, and a special value can be set to indicate that the I/O model on the storage pool is the I/O model matching the RBD storage pool, so as to avoid entering other I/O models and causing errors.
Step 102, identifying a current storage pool type.
The storage pool type includes at least: an RBD storage pool.
In this step, when the operator operates sanlock, the operator inputs the storage pool type tag indicating the RBD at the same time as inputting pathr, which indicates that the RBD storage pool is currently used. And receiving the path parameter, extracting the storage pool type label from the path parameter, and then determining the storage pool type according to the content of the storage pool type label. For example, the path of the RBD storage pool when add _ lockspace, rem _ lockspace, acquire and release is modified, and the storage pool type tag is added as a unique identifier, which indicates that the current storage pool is the RBD storage pool.
The function of identifying the RBD storage pool is added in the sanlock code, the RBD storage pool can be identified, and different I/O models can be selected according to different storage pools.
And 103, selecting an execution mode according to the type of the current storage pool.
And when the current storage pool type is the RBD storage pool, selecting a preset I/O model matched with the RBD storage pool.
And 104, finishing reading and writing of the distributed lock under the selected execution mode.
And executing connection, io _ ctx preparation and img opening operations of the RBD storage pool in an open process, directly executing I/O operations in the I/O process, and executing close operations and disconnect operations after the I/O operations are finished.
An embodiment of the present invention further provides a distributed lock implementation apparatus, the structure of which is shown in fig. 2, including:
a storage pool identification module 201, configured to identify a type of a current storage pool;
an execution mode selection module 202, configured to select an execution mode according to the current storage pool type;
and the lock read-write module 203 is configured to complete reading and writing of the distributed lock in the selected execution mode.
Preferably, the storage pool identification module 201 is configured as shown in fig. 3, and includes:
a tag extraction unit 2011, configured to receive the path parameter, and extract the storage pool type tag from the path parameter;
a type matching unit 2012 for determining the storage pool type according to the contents of the storage pool type tag.
Preferably, the apparatus further comprises:
a configuration module 204, configured to configure execution modes corresponding to different storage pool types, where the execution modes at least include an I/O model.
The embodiment of the invention provides a method and a device for realizing a distributed lock, which aim at different storage pool types, firstly identify, then select an execution mode according to an identification result, and use the selected execution mode to finish reading and writing of the distributed lock. The distributed lock compatible with various different storage pools is realized, and the problem of supporting the storage pool type lock resources is solved. The support of the sanlock on the RBD storage pool is realized, the normal I/O transmission of the sanlock on the RBD storage pool can be realized, the modification amount of the sanlock is reduced, and the use range of the sanlock is increased.
By modifying the sanlock code, an I/O model of the sanlock is increased, the normal operation of the sanlock on various storage pools including an RBD storage pool and the like is identified and supported, and the distributed lock with the stable lease based on the RBD storage pool is realized.
It will be understood by those of ordinary skill in the art that all or some of the steps of the methods, systems, functional modules/units in the devices disclosed above may be implemented as software, firmware, hardware, and suitable combinations thereof. In a hardware implementation, the division between functional modules/units mentioned in the above description does not necessarily correspond to the division of physical components; for example, one physical component may have multiple functions, or one function or step may be performed by several physical components in cooperation. Some or all of the components may be implemented as software executed by a processor, such as a digital signal processor or microprocessor, or as hardware, or as an integrated circuit, such as an application specific integrated circuit. Such software may be distributed on computer readable media, which may include computer storage media (or non-transitory media) and communication media (or transitory media). The term computer storage media includes volatile and nonvolatile, removable and non-removable media implemented in any method or technology for storage of information such as computer readable instructions, data structures, program modules or other data, as is well known to those of ordinary skill in the art. Computer storage media includes, but is not limited to, RAM, ROM, EEPROM, flash memory or other memory technology, CD-ROM, Digital Versatile Disks (DVD) or other optical disk storage, magnetic cassettes, magnetic tape, magnetic disk storage or other magnetic storage devices, or any other medium which can be used to store the desired information and which can accessed by a computer. In addition, communication media typically embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transport mechanism and includes any information delivery media as known to those skilled in the art.

Claims (6)

1. A distributed lock implementation method, comprising:
configuring an execution mode corresponding to sanlock and different storage pool types, wherein the execution mode at least comprises an I/O (input/output) model, and the I/O model is used for providing support for sanlock to issue I/O (input/output) on different storage pools, and the method comprises the following steps: adding an I/O model in diskio of sanlock, and simultaneously adding a structural body supporting different storage pools in an I/O process of sanlock, wherein the storage pools support locks without leases;
identifying a current storage pool type, including: the method comprises the steps that when a sanlock input path parameter is operated, a storage pool label indicating the type of a storage pool is obtained, and the type of the storage pool is determined according to the content of the storage pool type label;
selecting an execution mode of sanlock according to the type of the current storage pool;
and completing the reading and writing of the distributed lock with the lease of the storage pool under the selected execution mode.
2. The distributed lock implementation method of claim 1, wherein the storage pool type comprises at least: rados block device RBD storage pool.
3. The distributed lock implementation method of claim 1, wherein the step of identifying a current storage pool type comprises:
receiving a path parameter, and extracting a storage pool type label from the path parameter;
and determining the storage pool type according to the content of the storage pool type label.
4. The distributed lock implementation method of claim 2, wherein the step of selecting an execution mode based on the current storage pool type comprises:
and when the current storage pool type is the RBD storage pool, selecting a preset I/O model matched with the RBD storage pool.
5. A distributed lock implementation apparatus, comprising:
a configuration module, configured to configure an execution mode corresponding to sanlock and different storage pool types, where the execution mode at least includes an I/O model, and the I/O model is used to provide support for sanlock to issue I/O on different storage pools, and includes: adding an I/O model in diskio of sanlock, and simultaneously adding a structural body supporting different storage pools in an I/O process of sanlock, wherein the storage pools support locks without leases;
a storage pool identification module for identifying a current storage pool type, comprising: the method comprises the steps that when a sanlock input path parameter is operated, a storage pool label indicating the type of a storage pool is obtained, and the type of the storage pool is determined according to the content of the storage pool type label;
the execution mode selection module is used for selecting an execution mode of the sanlock according to the type of the current storage pool;
and the lock read-write module is used for finishing the read-write of the distributed lock with the lease in the storage pool in the selected execution mode.
6. The distributed lock implementation of claim 5, wherein the storage pool identification module comprises:
the label extraction unit is used for receiving the path parameter and extracting the storage pool type label from the path parameter;
and the type matching unit is used for determining the storage pool type according to the content of the storage pool type label.
CN201811103385.9A 2018-09-20 2018-09-20 Distributed lock implementation method and device Active CN109189583B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201811103385.9A CN109189583B (en) 2018-09-20 2018-09-20 Distributed lock implementation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201811103385.9A CN109189583B (en) 2018-09-20 2018-09-20 Distributed lock implementation method and device

Publications (2)

Publication Number Publication Date
CN109189583A CN109189583A (en) 2019-01-11
CN109189583B true CN109189583B (en) 2021-10-01

Family

ID=64909281

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201811103385.9A Active CN109189583B (en) 2018-09-20 2018-09-20 Distributed lock implementation method and device

Country Status (1)

Country Link
CN (1) CN109189583B (en)

Families Citing this family (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112148219A (en) * 2020-09-16 2020-12-29 北京优炫软件股份有限公司 Design method and device for ceph type distributed storage cluster

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106527985A (en) * 2016-11-02 2017-03-22 郑州云海信息技术有限公司 Storage interaction device and storage system based on ceph
CN106897029A (en) * 2017-02-24 2017-06-27 郑州云海信息技术有限公司 A kind of control method and device of LVM data consistencies
CN107577431A (en) * 2017-09-07 2018-01-12 郑州云海信息技术有限公司 A kind of storage pool construction method and device

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20080263183A1 (en) * 2007-04-20 2008-10-23 Lisa Midori Nishiyama Management of Kernel configurations for nodes in a clustered system
WO2010087803A1 (en) * 2009-01-29 2010-08-05 Lsi Corporation Allocate-on-write snapshot mechanism to provide dynamic storage tiering on-line data placement for volumes

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106527985A (en) * 2016-11-02 2017-03-22 郑州云海信息技术有限公司 Storage interaction device and storage system based on ceph
CN106897029A (en) * 2017-02-24 2017-06-27 郑州云海信息技术有限公司 A kind of control method and device of LVM data consistencies
CN107577431A (en) * 2017-09-07 2018-01-12 郑州云海信息技术有限公司 A kind of storage pool construction method and device

Non-Patent Citations (1)

* Cited by examiner, † Cited by third party
Title
sanlock及其用法;tsi0120;《CSDN》;20130908;第1页最后一段至第2页第1、4段、第4页第12-15段 *

Also Published As

Publication number Publication date
CN109189583A (en) 2019-01-11

Similar Documents

Publication Publication Date Title
US9019977B2 (en) Configuration management of distributed virtual switch
CN103281248B (en) The discover method of network topology, device and system
US20160092119A1 (en) Data migration between different types of storage systems
US8566821B2 (en) Cloning virtual machines
CN105653372B (en) The method for realizing multiple virtualization mixed management and scheduling based on cloud platform
CN109525515B (en) Management method and device for network card in cloud platform
WO2013162596A1 (en) Mapping application dependencies at runtime
US20160283275A1 (en) Dynamic workload deployment for data integration services
CN106095528B (en) A method of detection virtual machine drive
US9959157B1 (en) Computing instance migration
CN105704188A (en) Deployment method and apparatus of applications and services
CN104104705B (en) The cut-in method and equipment of distributed memory system
WO2020093976A1 (en) Resource change method and device, apparatus, and storage medium
US11474749B2 (en) Configuring host access for virtual volumes
CN102413183B (en) Cloud intelligence switch and processing method and system thereof
US20230266958A1 (en) Method for creating private image in public cloud and related device
CN109445923A (en) A kind of method and device of micro services task schedule
CN107566518A (en) The method and apparatus of management equipment information during installation file
CN109189583B (en) Distributed lock implementation method and device
US9542200B2 (en) Dynamic port naming in a chassis
CN106484719A (en) A kind of method of extended mobile phone storage and terminal
US20140359114A1 (en) Computer-readable recording medium, usage mode data generation method, and usage mode data generation device
US10397130B2 (en) Multi-cloud resource reservations
CN113626144B (en) Method, device, equipment and readable medium for creating and storing double live volumes by clusters
CN112328363B (en) Cloud hard disk mounting method and device

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant