Virtual disk access method, system, computer device and storage medium

Through the locking mechanism based on logical blocks, the problem of data inconsistency and low performance caused by multiple virtual machines writing to the virtual disk at the same time is solved, achieving more efficient virtual disk access and improving read and write performance and sharing.

CN115033173BActive Publication Date: 2024-10-22INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202210556136.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-20
Publication Date
2024-10-22
Estimated Expiration
2042-05-20

AI Technical Summary

Technical Problem

When multiple virtual machines write data to a virtual disk at the same time, it is easy to cause data inconsistency. The existing technology locks the entire virtual disk, resulting in low read and write performance and unable to fully utilize the sharing of the virtual disk.

Method used

Adopt a locking mechanism based on logical blocks to extract the data operation information of data access instructions in the authorization list, group and sort according to the number of logical blocks, determine conflicts, add to the waiting list or authorization list, and only perform write operation logic The block is locked and the next logical block is allowed to be written after being unlocked.

Benefits of technology

It avoids data inconsistency problems, reduces the locking area, improves the read and write performance and shareability of the virtual disk, and reduces the waiting time.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115033173B_ABST
    Figure CN115033173B_ABST
Patent Text Reader

Abstract

The present invention relates to a virtual disk access method, system, computer equipment and storage medium, the method comprising: extracting data operation information from a data access instruction in an authorization list; performing a data write operation in units of logic blocks according to the data operation information; and performing a locking operation on the logic block performing the data write operation; wherein the data access instruction in the authorization list is grouped according to the number of logic blocks operated by the instruction to form an instruction group, the number of logic blocks operated by the data operation instructions of the same instruction group is the same, and the number of logic blocks operated by the data operation instructions of different instruction groups is different. By adopting the present invention, the locking operation is performed in units of logic blocks, which avoids the problem of data inconsistency, and there is no need to lock the entire virtual disk, only the logic block needs to be locked, which reduces the locking area, performs the locking of the write operation in a finer granularity, reduces the waiting time, and improves the read and write performance and sharing of the virtual disk.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of data storage, and in particular to a virtual disk access method, system, computer equipment and storage medium. Background Art

[0002] In the era of big data, data storage has become an important field. How to use hard disks efficiently, improve hard disk utilization, and quickly and safely read and write data to hard disks is an important topic in the field of data storage. In order to improve the utilization of expensive hard disks, multiple hard disks are generally combined into a virtual disk in storage, and the virtual disk is usually shared by multiple vmware hosts (Virtual Machineware, virtual machines).

[0003] If multiple vmware hosts write data to a virtual disk at the same time, it will easily cause data inconsistency. In addition, in order to avoid data inconsistency caused by multiple vmware hosts writing data to the same virtual disk at the same time, multiple vmware hosts need to lock the virtual disk through the mcs system (MutipleControllerSystem, multi-controller storage system of the storage server) when writing data. The locking mechanism of the mcs system locks the entire virtual disk, that is, only one vmware host can read / write data to this virtual disk at the same time, and the sharing of the virtual disk cannot be fully utilized, which leads to relatively low read and write performance of multiple vmware hosts. Summary of the invention

[0004] Based on this, it is necessary to provide a virtual disk access method, system, computer device and storage medium that can improve the data writing rate in order to solve the above technical problems.

[0005] In one aspect, a virtual disk access method is provided, the virtual disk access method comprising:

[0006] Extract data operation information of data access instructions in the authorization list;

[0007] Performing a data write operation in units of logical blocks according to the data operation information;

[0008] Lock the logic block that performs the data writing operation;

[0009] The data access instructions in the authorization list are grouped into instruction groups according to the number of logic blocks they operate on. The data operation instructions of the same instruction group operate on the same number of logic blocks, while the data operation instructions of different instruction groups operate on different numbers of logic blocks.

[0010] In one embodiment, before performing the data writing operation in units of logical blocks according to the data operation information, the method further includes:

[0011] Receive a data access instruction, and determine whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information;

[0012] If the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction is added to the waiting list;

[0013] If the current data access instruction does not conflict with the data access instruction in the authorization list, the current data access instruction is added to the authorization list.

[0014] In one embodiment, determining whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information includes:

[0015] Sort the instruction groups in the authorization list from most to least according to the number of logic blocks they operate on;

[0016] According to the data operation information, the current data access instruction is compared with the instruction groups in the authorization list in descending order to make a judgment.

[0017] In one embodiment, adding the current data access instruction to a waiting list includes:

[0018] Add the current data access instruction to the end of all data access instructions in the waiting list;

[0019] The data access instructions added to the waiting queue are put into a dormant state.

[0020] In one embodiment, after the locking operation is performed on the logic block that performs the data writing operation, the method further includes:

[0021] After any data access instruction in the authorization list completes the write operation, the logic block corresponding to the write operation is unlocked;

[0022] The data access instructions in the waiting queue are awakened in chronological order to determine whether the awakened data access instructions conflict with the data access instructions in the authorization list.

[0023] In one embodiment, the storage device includes a plurality of nodes, and the receiving of the data access instruction and determining whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information includes:

[0024] Select one of the nodes of the storage device as the master node;

[0025] If the master node receives a data access instruction, the current data access instruction is compared with the data access instructions in the master node's authorization list;

[0026] If the non-master node receives the data access instruction, the current data access instruction is compared with the data access instructions in the authorization list of the non-master node and compared with the data access instructions in the authorization list of the master node.

[0027] In one of the embodiments, the virtual disk access method further includes:

[0028] If the master node crashes, one of the non-master nodes is selected as the master node.

[0029] In another aspect, a virtual disk access system is provided, the virtual disk access system comprising:

[0030] A logic block writing module is used to write data in units of logic blocks;

[0031] A logic block lock module is used to perform locking and unlocking operations on logic blocks;

[0032] The authorization list module is used to store the data access instructions being executed and to group and sort the data access instructions.

[0033] In another aspect, a computer device is provided, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:

[0034] Extract data operation information of data access instructions in the authorization list;

[0035] Performing a data write operation in units of logical blocks according to the data operation information;

[0036] Lock the logical block that performs the data write operation.

[0037] On the other hand, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a program, and when the program is executed by a processor, the processor performs the following steps:

[0038] Extract data operation information of data access instructions in the authorization list;

[0039] Performing a data write operation in units of logical blocks according to the data operation information;

[0040] Lock the logical block that performs the data write operation.

[0041] The above technical solution of the present invention has the following advantages compared with the prior art:

[0042] The above-mentioned virtual disk access method, system, computer device and storage medium perform read and write operations on the virtual disk in units of logical blocks, and perform locking operations in units of logical blocks when performing write operations. After the locking operation, the logical block no longer allows other data access instructions to perform write operations on the locked logical block, thereby avoiding the problem of data inconsistency. In addition, there is no need to lock the entire virtual disk, only the logical block needs to be locked, which reduces the locked area and performs more fine-grained locking of write operations, thereby improving the read and write performance and sharing of the virtual disk. BRIEF DESCRIPTION OF THE DRAWINGS

[0043] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the drawings required for use in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without creative work.

[0044] Figure 1 is a first method flow chart of the virtual disk access method of the present invention;

[0045] Figure 2 is a second method flow chart of the virtual disk access method of the present invention;

[0046] Figure 3 is a third method flow chart of the virtual disk access method of the present invention;

[0047] Figure 4 is a system structure diagram of a virtual disk access system of the present invention;

[0048] Figure 5 It is a device structure diagram of the computer device of the present invention. DETAILED DESCRIPTION

[0049] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] When multiple vmware hosts write data to a virtual disk at the same time, the virtual disk needs to be locked through the MCS system. The locking mechanism of the MCS system is to lock the entire virtual disk, that is, only one vmware host can read and write data to the virtual disk at the same time, and the sharing of the virtual disk cannot be fully utilized, which leads to relatively low read and write performance of multiple vmware hosts. Therefore, the present invention proposes a virtual disk access method, system, computer device and storage medium, which can lock the virtual disk in units of logical blocks, and can reduce waiting time and improve read and write efficiency.

[0051] Embodiment 1:

[0052] The virtual disk access method of this embodiment refers to Figure 1-2 As shown, Figure 1 A first method flow chart of the virtual disk access method of the present invention; Figure 2 It is a second method flow chart of the virtual disk access method of the present invention.

[0053] The method comprises the following steps:

[0054] Extract data operation information of data access instructions in the authorization list;

[0055] Performing a data write operation in units of logical blocks according to the data operation information;

[0056] Lock the logic block that performs the data writing operation;

[0057] In order to solve the problem of poor read and write performance caused by locking the entire virtual disk when multiple virtual hosts write to a virtual disk at the same time, a mechanism for locking in units of logical blocks is proposed. The data access instructions for data write operations are stored in the authorization list. The data access instructions store data operation information, that is, the ID of the virtual disk, the starting address of the logical block, and the number of logical blocks. Therefore, the address for data write operations can be determined according to the data operation information in the data access instructions, and then the data write operation is performed in the corresponding logical block; while performing the data write operation, in order to prevent other data access instructions from performing write operations on the logical block performing the write operation, it is necessary to lock the logical block performing the write operation, that is, to perform a lock operation on the logical block for which the data access instruction in the authorization list performs the write operation. After the lock operation is performed, the logical block no longer allows other data access instructions to perform write operations on the locked logical block, avoiding the problem of data inconsistency caused by simultaneous write operations, and there is no need to lock the entire virtual disk, only the logical block needs to be locked, which reduces the lock area, performs a more fine-grained lock for write operations, and improves the read and write performance and sharing of the virtual disk.

[0058] The data access instructions in the authorization list are grouped into instruction groups according to the number of logic blocks they operate on. The data operation instructions of the same instruction group operate on the same number of logic blocks, while the data operation instructions of different instruction groups operate on different numbers of logic blocks.

[0059] The authorization list is used to store data access instructions that are currently performing data write operations, and the data access instructions in the authorization list are grouped according to the number of logical blocks they operate on to form an instruction group; the data access instructions are caw (CompareAndWrite, compare / write instruction) operation instructions of the NVME (NonVolatile Memory Host Controller Interface Specification) protocol; the data access instructions perform data write operations with LBA (Logical Block Address, called "logical block") as the minimum unit; one LBA size is 512B. For the vmware host (referred to as the "virtual machine" in this article), the current storage supports write operations of 1 to 8 logical blocks. If a data access instruction performs a write operation on a larger number of logical blocks, the write operation will take longer, because the probability that the current data access instruction will conflict with other instructions when executing the data write operation is greater. Therefore, in order to reduce the locking and waiting time, the authorization list is grouped according to the number of logic blocks it operates to form instruction groups. Preferably, the grouping is performed according to the maximum number of logic blocks that the virtual machine can operate, that is, the data access instructions in the authorization list are divided into eight groups of instruction groups. The number of logic blocks operated by the data operation instructions of the same instruction group is the same, and the number of logic blocks operated by the data operation instructions of different instruction groups is different, that is, the data access instructions of the first group of instruction groups perform a write operation on 1 logic block; the data access instructions of the second group of instruction groups perform a write operation on 2 logic blocks; the data access instructions of the third group of instruction groups perform a write operation on 3 logic blocks; recursively, the data access instructions of the eighth group of instruction groups perform a write operation on 8 logic blocks. By grouping the data access instructions in the authorization list so as to facilitate subsequent comparison and judgment by probability, the waiting time can be effectively reduced and the read and write performance can be improved.

[0060] In one embodiment, before performing the data writing operation in units of logical blocks according to the data operation information, the method further includes:

[0061] Receive a data access instruction, and determine whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information;

[0062] If the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction is added to the waiting list;

[0063] If the current data access instruction does not conflict with the data access instruction in the authorization list, the current data access instruction is added to the authorization list.

[0064] Before executing the data write operation in units of logical blocks according to the data operation information, it is necessary to receive the data access instruction, and then determine whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information of the current data access instruction; if the current data access instruction conflicts with the data access instruction in the authorization list, it means that the address of the write operation to be performed by the current data access instruction is in the state of being written, that is, there are other data access instructions that are already performing write operations, so it is necessary to add the current data access instruction to the waiting list, and wait for any data access instruction in the authorization list that is performing write operations to be completed before performing the write operation of the data access instruction; if the current data access instruction does not conflict with the data access instruction in the authorization list, it means that there are no other data access instructions performing data write operations at the address of the write operation to be performed by the current data access instruction, so it is necessary to add the current data access instruction to the authorization list to perform the data write operation. Among them, the conflict between the current data access instruction and the data access instruction in the authorization list means that the write operation address of the current data access instruction conflicts with the write operation address of the data access instruction in the authorization list, that is, the address of the logical block.

[0065] In one implementation manner, determining whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information includes:

[0066] Sort the instruction groups in the authorization list from most to least according to the number of logic blocks they operate on;

[0067] According to the data operation information, the current data access instruction is compared with the instruction groups in the authorization list in descending order to make a judgment.

[0068] The data access instructions in the authorization list are grouped according to the number of logic blocks they operate to form instruction groups. These instruction groups are sorted from most to least according to the number of logic blocks they operate, that is, the eighth group, the seventh group, the sixth group, and so on to the first group. All the data access instructions in the eighth group can operate the largest number of logic blocks, that is, all the data access instructions in the eighth group can operate 8 logic blocks. Therefore, the probability of the current data access instruction conflicting with the data access instruction in the eighth group is the highest. Therefore, the instruction groups in the authorization list are sorted from most to least according to the number of logic blocks they operate. When performing comparison and judgment, the current data access instruction is compared with the instruction groups sorted from most to least in the authorization list in turn for judgment, that is, the current data access instruction is first compared and judged with the eighth group. If the current data access instruction does not conflict with the eighth group, it continues to be compared and judged with the seventh group. If the current data access instruction does not conflict with the seventh group, it continues to be compared and judged with the seventh group, so it is executed recursively. If the current data access instruction conflicts with the eighth group, the current data access instruction is directly added to the waiting list, which effectively reduces the time of comparison and judgment through probability and effectively improves the reading and writing rate.

[0069] In one embodiment, before determining whether the current data access instruction conflicts with the data access instruction in the authorization list, the method further includes:

[0070] Determine the legality of the data access instruction. If the data access instruction is legal, determine whether the data access instruction exists in the authorization list.

[0071] If the data access instruction is illegal, an error instruction is returned and the virtual machine modifies the instruction.

[0072] The received data access instruction is illegal, for example, the ID of the virtual disk specified by the data access instruction does not exist; the starting address or the starting address + the number of logical blocks specified by the data access instruction exceeds the capacity of the virtual disk; the number of logical blocks operated by the data access instruction exceeds 8, etc. Therefore, after receiving the data access instruction, it is necessary to determine whether the data access instruction is legal. If the data access instruction is legal, it will continue to be executed; if the data access instruction is illegal, the error code corresponding to the error instruction will be returned to the virtual machine, and the virtual machine will modify the instruction. If it is still illegal after the modification and exceeds the preset number of times, an alarm is required to notify the operation and maintenance personnel to perform maintenance.

[0073] In one implementation manner, determining whether there is a data access instruction in the authorization list includes:

[0074] If there is a data access instruction in the authorization list, determine whether the current data access instruction conflicts with the data access instruction in the authorization list;

[0075] If the data access instruction does not exist in the authorization list, the current data access instruction is added to the authorization list and the data write operation is performed.

[0076] After the data access instruction is judged to be legal, it is necessary to determine whether the data access instruction exists in the authorization list. If the data access instruction exists in the authorization list, it means that there is a data access instruction that is performing a write operation, and it is necessary to further determine whether the current data access instruction conflicts with the data access instruction in the authorization list; if the data access instruction does not exist in the authorization list, it means that there is no data access instruction that is performing a write operation, and the current data access instruction can directly perform the data write operation.

[0077] In one embodiment, adding the current data access instruction to the waiting list includes:

[0078] Add the current data access instruction to the end of all data access instructions in the waiting list;

[0079] If, after comparison and judgment, the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction needs to be added to the waiting list, and the current data access instruction is added to the tail of all data access instructions in the waiting list. In this way, the data access instructions in the waiting list are arranged in chronological order, so that the data access instructions in the subsequent waiting list can be awakened according to the first-in-first-out principle, to prevent the existence of data access instructions that have not been awakened.

[0080] The data access instructions added to the waiting queue are put into a dormant state.

[0081] In order to improve the utilization of the chip, the data access instructions added to the waiting queue do not need to be in the awake state all the time. If the data access instructions added to the waiting queue are in the awake state all the time, it will waste chip resources. Therefore, the data access instructions added to the waiting queue are put into a dormant state to maximize the utilization of chip resources. After the data access instructions in the authorization list are executed, the data access list with the earlier time in the waiting list can be awakened.

[0082] In one embodiment, after the locking operation is performed on the logic block that performs the data writing operation, the method further includes:

[0083] After any data access instruction in the authorization list completes the write operation, the logic block corresponding to the write operation is unlocked;

[0084] After locking the logic block that performs the data write operation, after a period of time, some data access instructions in the authorization list will be executed; after any data access instruction in the authorization list completes the write operation, the corresponding logic block needs to perform an unlocking operation, and only the logic block in the unlocked state can perform the data write operation of the next data access instruction; therefore, after any data access instruction in the authorization list completes the write operation, the corresponding logic block with which the write operation has been completed will be unlocked, so that the next data access instruction that performs a data write operation on the logic block in the area can perform the data write operation.

[0085] The data access instructions in the waiting queue are awakened in chronological order to determine whether the awakened data access instructions conflict with the data access instructions in the authorization list.

[0086] When a data access instruction for executing a data write operation conflicts with a write operation in an authorization list, the data access instruction corresponding to the write operation that conflicts with the authorization list is added to a waiting list, and the data access instruction corresponding to the write operation that conflicts with the authorization list is added to the tail of all the data access instructions in the waiting list, so that the data access instructions in the waiting list are arranged in chronological order; after any data access instruction in the authorization list completes the write operation, the data access instruction earlier in the waiting list is awakened first, and then a comparison is made to determine whether the awakened data access instruction conflicts with the data access instruction in the authorization list, and the data write operation is executed after there is no conflict. The data access instructions in the waiting list follow the first-in-first-out wake-up principle, and the data access instruction in the authorization list is reduced by one, and the data access instructions in the waiting list are awakened one by one in sequence and executed in sequence.

[0087] Embodiment 2:

[0088] The virtual disk access method of this embodiment refers to Figure 1-2 As shown, Figure 1 A first method flow chart of the virtual disk access method of the present invention; Figure 2 It is a second method flow chart of the virtual disk access method of the present invention.

[0089] S10, receiving a data access instruction;

[0090] Before executing the data write operation in units of logic blocks according to the data operation information, a data access instruction is received to execute the data write operation according to the data operation information in the data access instruction.

[0091] S20, judging the legality of the data access instruction;

[0092] After receiving the data access instruction, it is necessary to determine whether the data access instruction is legal. If the data access instruction is legal, enter step S30 to extract the data operation information in the data access instruction in the authorization list; if the data access instruction is illegal, the error code corresponding to the erroneous instruction is returned to the virtual machine, and the virtual machine modifies the instruction. If it is still illegal after the modification and exceeds the preset number of times, an alarm is required to notify the operation and maintenance personnel to perform maintenance.

[0093] S30, extracting data operation information in the data access instruction in the authorization list;

[0094] The address for data write operation can be determined according to the data operation information in the data access instruction, and then the data write operation is performed in the corresponding logic block. Therefore, the data operation information in the data access instruction in the authorization list must be extracted.

[0095] S40, determining whether there is a data access instruction in the authorization list;

[0096] After the data access instruction is judged to be legal, it is necessary to determine whether the data access instruction exists in the authorization list. If the data access instruction exists in the authorization list, it means that there is a data access instruction that is performing a write operation, then execute S50 to determine whether the current data access instruction conflicts with the data access instruction in the authorization list; if the data access instruction does not exist in the authorization list, it means that there is no data access instruction that is performing a write operation, then the current data access instruction executes S60 to add the current data access instruction to the authorization list to perform the data write operation.

[0097] S50, determining whether the current data access instruction conflicts with the data access instruction in the authorization list;

[0098] After extracting the data operation information, determine whether the current data access instruction conflicts with the data access instructions in the authorization list based on the data operation information. If the current data access instruction conflicts with the data access instructions in the authorization list, it means that the address of the write operation to be performed by the current data access instruction is in a state of being written, that is, there are other data access instructions that are already performing write operations. Therefore, it is necessary to execute S70 to add the current data access instruction to the waiting list, and then perform the write operation of the data access instruction after any data access instruction that is currently performing a write operation in the authorization list is executed; if the current data access instruction does not conflict with the data access instruction in the authorization list, it means that there are no other data access instructions performing data write operations at the address of the write operation to be performed by the current data access instruction. Therefore, it is necessary to execute S60 to add the current data access instruction to the authorization list to perform the data write operation.

[0099] S60, adding the current data access instruction to the authorization list;

[0100] If the current data access instruction does not conflict with the data access instructions in the authorization list, it means that there is no other data access instruction to perform a data write operation at the address of the write operation to be performed by the current data access instruction. Therefore, the current data access instruction needs to be added to the authorization list to perform the data write operation.

[0101] S70, adding the current data access instruction to a waiting list;

[0102] If the current data access instruction conflicts with the data access instructions in the authorization list, it means that the address of the write operation to be performed by the current data access instruction is in the state of being written, that is, there are other data access instructions that are already performing write operations. Therefore, the current data access instruction needs to be added to the waiting list and added to the end of all data access instructions in the waiting list. The write operation of the data access instruction can only be performed after any data access instruction in the authorization list that is performing a write operation has been executed.

[0103] S80, performing a data write operation in units of logic blocks according to the data operation information;

[0104] In order to solve the problem that when multiple virtual hosts simultaneously write to a virtual disk, the entire virtual disk is locked, resulting in poor read and write performance, it is proposed to perform data write operations in units of logical blocks.

[0105] S90, performing a locking operation on the logic block that performs the data writing operation;

[0106] While executing a data write operation, in order to prevent other data access instructions from performing a write operation on the logical block that is performing a write operation, it is necessary to lock the logical block that is performing a write operation, that is, to perform a locking operation on the data access instructions in the authorization list. After the locking operation is performed, the logical block will no longer allow other data access instructions to perform a write operation on the locked logical block, thereby avoiding the problem of data inconsistency caused by simultaneous write operations, and there is no need to lock the entire virtual disk, only the logical block needs to be locked, which reduces the locked area and performs a more fine-grained locking of write operations, thereby improving the read and write performance and sharing of the virtual disk.

[0107] S100, after any data access instruction in the authorization list completes the write operation, unlock the logic block corresponding to the completed write operation;

[0108] After locking the logic block that performs the data write operation, after a period of time, some data access instructions in the authorization list will be executed; after any data access instruction in the authorization list completes the write operation, the corresponding logic block needs to perform an unlocking operation, and only the logic block in the unlocked state can perform the data write operation of the next data access instruction; therefore, after any data access instruction in the authorization list completes the write operation, the corresponding logic block with which the write operation has been completed will be unlocked, so that the next data access instruction that performs a data write operation on the logic block in the area can perform the data write operation.

[0109] S110, the data access instructions in the waiting queue are awakened in chronological order to determine whether the awakened data access instructions conflict with the data access instructions in the authorization list.

[0110] When a data access instruction for executing a data write operation conflicts with a write operation in an authorization list, the data access instruction corresponding to the write operation that conflicts with the authorization list is added to a waiting list, and the data access instruction corresponding to the write operation that conflicts with the authorization list is added to the tail of all the data access instructions in the waiting list, so that the data access instructions in the waiting list are arranged in chronological order; after any data access instruction in the authorization list completes the write operation, the data access instruction earlier in the waiting list is awakened first, and then a comparison is made to determine whether the awakened data access instruction conflicts with the data access instruction in the authorization list, and the data write operation is executed after there is no conflict. The data access instructions in the waiting list follow the first-in-first-out wake-up principle, and the data access instruction in the authorization list is reduced by one, and the data access instructions in the waiting list are awakened one by one in sequence and executed in sequence.

[0111] Embodiment three:

[0112] The virtual disk access method of this embodiment refers to Figure 3 As shown, Figure 3 This is a flow chart of a third method of the virtual disk access method of the present invention.

[0113] For a storage device with multiple nodes, the method includes the following steps: the storage device includes multiple nodes, the receiving of a data access instruction, and judging whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information, including:

[0114] Select one of the nodes of the storage device as the master node;

[0115] If the master node receives a data access instruction, the current data access instruction is compared with the data access instructions in the master node's authorization list;

[0116] If the non-master node receives the data access instruction, the current data access instruction is compared with the data access instructions in the authorization list of the non-master node and compared with the data access instructions in the authorization list of the master node.

[0117] A storage device may have multiple nodes that can receive data access instructions. These multiple nodes can read the same virtual disk at the same time. Therefore, a multi-node management mechanism is required to uniformly manage the waiting list and authorization list to improve the read and write efficiency. The specific method is: select one of the nodes as the master node. If the master node receives the data access instruction, the current data access instruction is compared with the data access instruction in the authorization list of the master node; if the current data access instruction conflicts with the data access instruction in the authorization list of the master node, the current data access instruction is added to the waiting list of the master node; if the current data access instruction does not conflict with the data access instruction in the authorization list of the master node, the current data access instruction is added to the authorization list of the master node to perform data write operations. If the non-master node receives the data access instruction, the current data access instruction is compared with the data access instruction in the authorization list of the non-master node, and compared with the data access instruction in the authorization list of the master node. If one of the comparisons is conflicting, the current data access instruction is added to the waiting list of the non-master node; if both comparisons are not conflicting, the current data access instruction is added to the authorization list of the master node and the non-master node to perform data write operations. This avoids the possibility of conflicts caused by multiple nodes reading the same virtual disk at the same time, ensures data consistency, and improves the management performance of the waiting list and the authorization list.

[0118] The data access instructions in the authorization list are grouped into instruction groups according to the number of logic blocks they operate on. The data operation instructions of the same instruction group operate on the same number of logic blocks, while the data operation instructions of different instruction groups operate on different numbers of logic blocks.

[0119] If a data access instruction performs a write operation on a larger number of logical blocks, the write operation will take longer, because the probability that the current data access instruction will conflict with other instructions when performing a write operation on data is greater. Therefore, in order to reduce the time of locking and waiting, the authorization list is grouped according to the number of logical blocks it operates to form an instruction group. Preferably, the grouping is performed according to the maximum number of logical blocks that the virtual machine can operate, that is, the data access instructions in the authorization list are divided into eight groups of instruction groups. The number of logical blocks operated by the data operation instructions of the same instruction group is the same, and the number of logical blocks operated by the data operation instructions of different instruction groups is different, that is, the data access instructions of the first group of instruction groups perform a write operation on 1 logical block; the data access instructions of the second group of instruction groups perform a write operation on 2 logical blocks; the data access instructions of the third group of instruction groups perform a write operation on 3 logical blocks; and recursively, the data access instructions of the eighth group of instruction groups perform a write operation on 8 logical blocks. By grouping the data access instructions in the authorization list so as to facilitate subsequent comparison and judgment by probability, the waiting time can be effectively reduced and the read and write performance can be improved.

[0120] In one implementation, if the master node crashes, one of the non-master nodes is selected as the master node.

[0121] A running node may crash due to unexpected circumstances. Therefore, if the master node crashes, one of the non-master nodes is selected as the new master node to manage the waiting list and authorization list, avoiding the possibility of conflicts caused by multiple nodes reading the same virtual disk at the same time and ensuring data consistency.

[0122] It should be understood that although Figures 1 to 3 The steps in the flowchart are shown in sequence as indicated by the arrows, but these steps are not necessarily executed in the order indicated by the arrows. Unless otherwise specified in this document, there is no strict order restriction for the execution of these steps, and these steps can be executed in other orders. Moreover, Figures 1 to 3 At least part of the steps may include multiple sub-steps or multiple stages. These sub-steps or stages are not necessarily executed at the same time, but can be executed at different times. The execution order of these sub-steps or stages is not necessarily sequential, but can be executed in turn or alternately with other steps or at least part of the sub-steps or stages of other steps.

[0123] Embodiment 4:

[0124] Reference Figure 4 As shown, Figure 4 It is a system structure diagram of the virtual disk access system of the present invention.

[0125] The virtual disk access system of this embodiment includes:

[0126] A logic block writing module is used to write data in units of logic blocks;

[0127] The authorization list stores data access instructions for data write operations. The data access instructions store data operation information. Therefore, the address of the data write operation can be determined based on the data operation information in the data access instructions, and then the data is written to the corresponding logic block through the logic block read and write module.

[0128] A logic block lock module is used to perform locking and unlocking operations on logic blocks;

[0129] In order to solve the problem of poor read and write performance caused by locking the entire virtual disk when multiple virtual hosts write to a virtual disk at the same time, a mechanism for locking in units of logical blocks is proposed to achieve more fine-grained locking. After the logical block is locked, other data access instructions are no longer allowed to write to the locked logical block, avoiding the problem of data inconsistency caused by simultaneous write operations. In addition, there is no need to lock the entire virtual disk. Only the logical block needs to be locked through the logical block lock module, which reduces the locked area and locks the write operation in a finer granularity, thereby improving the read and write performance and sharing of the virtual disk. After any data access instruction in the authorization list completes the write operation, the corresponding logical block needs to be unlocked through the logical block lock module. Only the logical block in the unlocked state can execute the data write operation of the next data access instruction; therefore, after any data access instruction in the authorization list completes the write operation, the logical block corresponding to the completed write operation is unlocked through the logical block lock module, so that the next data access instruction that writes data to the logical block in the area can execute the data write operation.

[0130] The authorization list module is used to store the data access instructions being executed and to group and sort the data access instructions.

[0131] If a data access instruction writes to more logical blocks, the write operation will take longer, because the probability of the current data access instruction executing the data write operation conflicting with other instructions is greater. Therefore, in order to reduce the locking and waiting time, the authorization list is grouped into instruction groups according to the number of logical blocks it operates through the authorization list module, and the instruction groups are sorted from most to least according to the number of logical blocks they operate through the authorization list module. When performing comparison and judgment, the current data access instruction is compared with the instruction groups sorted from most to least in the authorization list in turn, which effectively reduces the comparison and judgment time through probability and effectively improves the read and write rate.

[0132] In one embodiment, the virtual disk access system further includes:

[0133] A comparison and judgment module, used for comparing and judging the current data access instruction with the data access instruction in the authorization list;

[0134] The comparison and judgment module determines whether the current data access instruction conflicts with the data access instruction in the authorization list; if the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction is added to the waiting list; if the current data access instruction does not conflict with the data access instruction in the authorization list, the current data access instruction is added to the authorization list.

[0135] A waiting list module is used to store data access instructions that need to be waited for and sort the data access instructions in chronological order;

[0136] After any data access instruction in the authorization list completes the write operation, the data access instruction earlier in the waiting list is awakened first, and then compared with the data access instruction in the authorization list to see if it conflicts. The data access instructions in the waiting list follow the first-in-first-out wake-up principle, and the data access instructions in the waiting list are arranged in chronological order through the waiting list module.

[0137] A multi-node management module is used to manage the write operations of multiple nodes of the storage device to the virtual disk;

[0138] A storage device may have multiple nodes that can receive data access instructions. These multiple nodes can read the same virtual disk at the same time, so a multi-node management mechanism is needed. The waiting list and authorization list are uniformly managed through the multi-node management module to improve the reading and writing efficiency.

[0139] The specific definition of the virtual disk access system can be found in the definition of the method above, which will not be repeated here. Each module in the above virtual disk access system can be implemented in whole or in part by software, hardware and a combination thereof. Each of the above modules can be embedded in or independent of the processor in the computer device in the form of hardware, or can be stored in the memory of the computer device in the form of software, so that the processor can call and execute the operations corresponding to each of the above modules.

[0140] Embodiment five:

[0141] This embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of a virtual disk access method when executing the computer program.

[0142] The computer device may be a terminal, and its internal structure diagram may be as follows: Figure 5 As shown. The computer device includes a processor, a memory, a network interface, a display screen and an input device connected through a system bus. Among them, the processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The network interface of the computer device is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a virtual disk access method is implemented. The display screen of the computer device can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a key, trackball or touchpad set on the computer device housing, or an external keyboard, touchpad or mouse, etc.

[0143] Those skilled in the art should understand that Figure 5 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0144] In one embodiment, a computer device is provided, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following steps are implemented:

[0145] Extract data operation information of data access instructions in the authorization list;

[0146] Performing a data write operation in units of logical blocks according to the data operation information;

[0147] Lock the logical block that performs the data write operation.

[0148] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0149] Receive a data access instruction, and determine whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information;

[0150] If the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction is added to the waiting list;

[0151] If the current data access instruction does not conflict with the data access instruction in the authorization list, the current data access instruction is added to the authorization list.

[0152] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0153] Sort the instruction groups in the authorization list from most to least according to the number of logic blocks they operate on;

[0154] According to the data operation information, the current data access instruction is compared with the instruction groups in the authorization list in descending order to make a judgment.

[0155] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0156] Add the current data access instruction to the end of all data access instructions in the waiting list;

[0157] The data access instructions added to the waiting queue are put into a dormant state.

[0158] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0159] After any data access instruction in the authorization list completes the write operation, the logic block corresponding to the write operation is unlocked;

[0160] The data access instructions in the waiting queue are awakened in chronological order to determine whether the awakened data access instructions conflict with the data access instructions in the authorization list.

[0161] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0162] Select one of the nodes of the storage device as the master node;

[0163] If the master node receives a data access instruction, the current data access instruction is compared with the data access instructions in the master node's authorization list;

[0164] If the non-master node receives the data access instruction, the current data access instruction is compared with the data access instructions in the authorization list of the non-master node and compared with the data access instructions in the authorization list of the master node.

[0165] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0166] If the master node crashes, one of the non-master nodes is selected as the master node.

[0167] Embodiment six:

[0168] This embodiment provides a computer-readable storage medium, on which a computer program is stored. When the computer program is executed by a processor, the following steps are implemented:

[0169] Extract data operation information of data access instructions in the authorization list;

[0170] Performing a data write operation in units of logical blocks according to the data operation information;

[0171] Lock the logical block that performs the data write operation.

[0172] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0173] Receive a data access instruction, and determine whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information;

[0174] If the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction is added to the waiting list;

[0175] If the current data access instruction does not conflict with the data access instruction in the authorization list, the current data access instruction is added to the authorization list.

[0176] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0177] Sort the instruction groups in the authorization list from most to least according to the number of logic blocks they operate on;

[0178] According to the data operation information, the current data access instruction is compared with the instruction groups in the authorization list in descending order to make a judgment.

[0179] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0180] Add the current data access instruction to the end of all data access instructions in the waiting list;

[0181] The data access instructions added to the waiting queue are put into a dormant state.

[0182] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0183] After any data access instruction in the authorization list completes the write operation, the logic block corresponding to the write operation is unlocked;

[0184] The data access instructions in the waiting queue are awakened in chronological order to determine whether the awakened data access instructions conflict with the data access instructions in the authorization list.

[0185] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0186] Select one of the nodes of the storage device as the master node;

[0187] If the master node receives a data access instruction, the current data access instruction is compared with the data access instructions in the master node's authorization list;

[0188] If the non-master node receives the data access instruction, the current data access instruction is compared with the data access instructions in the authorization list of the non-master node and compared with the data access instructions in the authorization list of the master node.

[0189] In one embodiment, when the processor executes the computer program, the processor further implements the following steps:

[0190] If the master node crashes, one of the non-master nodes is selected as the master node.

[0191] A person of ordinary skill in the art can understand that all or part of the processes in the virtual disk access method of the above-mentioned embodiment can be implemented by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application may include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM), etc.

[0192] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this specification.

[0193] The above-mentioned embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the invention patent. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the patent of the present application shall be subject to the attached claims.

Claims

1. A virtual disk access method, characterized in that: The virtual disk access method comprises: Extract data operation information of data access instructions in the authorization list; Performing a data write operation in units of logical blocks according to the data operation information; Lock the logic block that performs the data writing operation; The data access instructions in the authorization list are grouped into instruction groups according to the number of logic blocks they operate on. The number of logic blocks operated by the data operation instructions of the same instruction group is the same, and the number of logic blocks operated by the data operation instructions of different instruction groups is different. Before performing the data writing operation in units of logical blocks according to the data operation information, the method further includes: Receive a data access instruction, and determine whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information; If the current data access instruction conflicts with the data access instruction in the authorization list, the current data access instruction is added to the waiting list; If the current data access instruction does not conflict with the data access instruction in the authorization list, the current data access instruction is added to the authorization list.

2. The virtual disk access method according to claim 1, characterized in that: The step of judging whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information includes: Sort the instruction groups in the authorization list from most to least according to the number of logic blocks they operate on; According to the data operation information, the current data access instruction is compared with the instruction groups in the authorization list in descending order to make a judgment.

3. The virtual disk access method according to claim 1, characterized in that: The step of adding the current data access instruction to a waiting list includes: Add the current data access instruction to the end of all data access instructions in the waiting list; The data access instructions added to the waiting queue are put into a dormant state.

4. The virtual disk access method according to claim 1, characterized in that: After the logic block for performing the data writing operation is locked, the method further includes: After any data access instruction in the authorization list completes the write operation, the logic block corresponding to the write operation is unlocked; The data access instructions in the waiting queue are awakened in chronological order to determine whether the awakened data access instructions conflict with the data access instructions in the authorization list.

5. The virtual disk access method according to claim 1, characterized in that: The receiving of the data access instruction and judging whether the current data access instruction conflicts with the data access instruction in the authorization list according to the data operation information includes: Selecting one of the nodes of a storage device as a master node, wherein the storage device includes a plurality of nodes; If the master node receives a data access instruction, the current data access instruction is compared with the data access instructions in the master node's authorization list; If the non-master node receives the data access instruction, the current data access instruction is compared with the data access instructions in the authorization list of the non-master node and compared with the data access instructions in the authorization list of the master node.

6. The virtual disk access method according to claim 5, characterized in that: The virtual disk access method further includes: If the master node crashes, one of the non-master nodes is selected as the master node.

7. A virtual disk access system implementing the virtual disk access method according to any one of claims 1 to 6, characterized in that: The system comprises: A logic block writing module is used to write data in units of logic blocks; A logic block lock module is used to perform locking and unlocking operations on logic blocks; The authorization list module is used to store the data access instructions being executed and to group and sort the data access instructions.

8. A computer device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the steps of the method described in any one of claims 1 to 6 are implemented.

9. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a program, and when the program is executed by a processor, the processor executes the steps of the method according to any one of claims 1 to 6.

Citation Information

Patent Citations

  • Implementation method and equipment for SCSI lock in distributed network storage system

    CN110489388A

  • Method and system for facilitating fast crash recovery in storage device

    CN113722131A

  • Data prefetching method and device, electronic equipment and storage medium

    CN114138687A

  • Method for accessing storage media, data writing method, parameter adjusting method in storage device, and storage device, computer system and storage medium applying the same

    KR1020120121227A