Data storage method, device, system, electronic equipment and storage medium

By working collaboratively with arbitration nodes and storage nodes, the problems of low data backup efficiency and insufficient reliability in existing block storage methods are solved. This enables efficient data backup and reliable storage when storage node connections are abnormal, thereby improving system availability.

CN115268776BActive Publication Date: 2026-06-16CHINA TELECOM CLOUD TECH CO LTD

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CHINA TELECOM CLOUD TECH CO LTD
Filing Date
2022-07-20
Publication Date
2026-06-16

Smart Images

  • Figure CN115268776B_ABST
    Figure CN115268776B_ABST
Patent Text Reader

Abstract

The application discloses a data storage method, device, system, electronic equipment and storage medium. The data storage method is applied to a data storage system. The data storage system comprises an arbitration node and two storage nodes. The arbitration node is connected with each storage node respectively, and each storage node is connected with each other. The method comprises the following steps: a storage node receives a data write request sent by a terminal device; if it is determined that the connection between the storage node and other storage nodes is normal, the to-be-written data information carried in the data write request is synchronized to the other storage nodes, so that the write data operation is performed in parallel with the other storage nodes; if it is determined that the connection between the storage node and the other storage nodes is abnormal, an arbitration request is sent to the arbitration node; if it is determined that a write data instruction sent by the arbitration node is received, the write data operation is performed according to the data write request; and when the connection between the storage node and the other storage nodes is restored to normal, the to-be-written data information is synchronized to the other storage nodes, so that the other storage nodes perform the write data operation.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data storage technology, and in particular to a data storage method, apparatus, system, electronic device, and storage medium. Background Technology

[0002] Block storage involves breaking data down into blocks and storing each block separately. It's a storage method that provides raw disk space to the host. Block storage is typically configured to decouple data from the user's environment and distribute it across multiple environments that can better serve it. It is often combined with Storage Area Networks (SANs) and distributed cloud storage to provide storage to users.

[0003] Currently, mainstream block storage methods generally employ block storage gateways to provide services via a common network (such as TCP Transmission Control Protocol). Block storage gateways are typically deployed in single-machine or active / passive modes, with their backend connected to the same storage device or distributed storage cluster to store data. However, this active / passive mode first stores data on the primary storage node, then sends the data to the backup storage node for backup. This results in low data backup efficiency, and if any storage node loses power or the distributed storage cluster becomes unavailable, the storage service will be unusable, causing significant losses for users with high availability requirements. Summary of the Invention

[0004] To address the issues of low data backup efficiency and insufficient reliability of existing block storage methods, embodiments of this application provide a data storage method, apparatus, system, electronic device, and storage medium.

[0005] In a first aspect, embodiments of this application provide a data storage system, including an arbitration node and two storage nodes, wherein the arbitration node is connected to each storage node respectively, and the storage nodes are connected to each other, wherein:

[0006] The arbitration node is used to receive the arbitration request sent by the storage node, determine the target storage node to perform the write data operation based on the connection status with each storage node, and send the write data instruction to the target storage node.

[0007] The storage node is configured to receive data write requests sent by the terminal device. If it determines that the connection with other storage nodes is normal, it synchronizes the data to be written carried in the data write request to the other storage nodes, so that the storage node and the other storage nodes can perform data write operations in parallel. If it determines that the connection with other storage nodes is abnormal, it sends an arbitration request to the arbitration node. If it determines that it has received a write data instruction sent by the arbitration node, it performs a data write operation according to the data write request, and when the connection with the other storage nodes is restored to normal, it synchronizes the data to be written to the other storage nodes, so that the other storage nodes can perform data write operations according to the data to be written.

[0008] In one possible implementation, the storage node includes a storage gateway node and a storage device. The storage gateway node includes an input / output processing module, a data transceiver module, a distributed lock module, a data synchronization module, and a heartbeat module. The data to be written information includes a disk identifier to be written, a starting logical block address, the data content to be written, and the length of the data to be written.

[0009] The input / output processing module is used to receive the data write request sent by the terminal device, and send the data to be written information to the data transceiver module; if it is determined based on the lock information obtained by the distributed lock module that the logic block to be written is not locked, then the data to be written content is written into the logic block to be written.

[0010] The data transceiver module is used to receive the data information to be written sent by the input / output processing module;

[0011] The distributed lock module is used to determine the address of the logical block to be written based on the starting logical block address and the length of the data to be written, obtain the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written in the storage device, and lock the logical block to be written when the input / output processing module writes the data content to be written in the logical block to be written.

[0012] The heartbeat module is used to monitor the connection status with other storage nodes.

[0013] In one possible implementation, the distributed lock module is further configured to synchronize the lock information to the distributed lock modules of the other storage nodes when the connection between the storage node and the other storage nodes is normal.

[0014] The data transceiver module is further configured to, when the connection between the storage node and the other storage nodes is normal, send the data to be written to the data transceiver module of the other storage node, which then sends it to the input / output processing module of the other storage node, which then writes the data to be written into the storage device of the other storage node based on the lock information.

[0015] In one possible implementation, the data synchronization module is configured to, in the event of an abnormal connection between the storage node and the other storage nodes, store the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to the other storage nodes, and send the address information of the logical block to be written corresponding to the data content to be written to the data synchronization module of the other storage nodes for synchronization when the connection between the storage node and the other storage nodes is restored to normal.

[0016] In one possible implementation, the distributed lock module is specifically configured to: determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk; determine the number of regions spanned by the logical block to be written corresponding to the data to be written based on the region offset, the data length, and the number of logical blocks in each region of the disk; determine the target region of the logical block to be written corresponding to the data to be written based on the region of the starting logical block on the disk and the number of regions spanned; perform a hash calculation on the disk identifier to be written and the target region identifier to obtain a hash value; search for the flag information of each logical block address of the target region corresponding to the hash value in a preset hash table; and determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

[0017] In one possible implementation, the distributed lock module is specifically used to set a flag bit of the address of the logic block to be written when the input / output processing module writes the data content to be written into the logic block to lock the logic block to be written.

[0018] Secondly, embodiments of this application provide a data storage method applied to a data storage system, the data storage system including an arbitration node and two storage nodes, the arbitration node being connected to each storage node respectively, and the storage nodes being connected to each other, the method including:

[0019] The storage node receives a data write request sent by the terminal device;

[0020] If the connection with other storage nodes is confirmed to be normal, the data to be written information carried in the data write request is synchronized to the other storage nodes so that the write data operation can be performed in parallel with the other storage nodes.

[0021] If an anomaly is detected in the connection with other storage nodes, an arbitration request is sent to the arbitration node;

[0022] If it is determined that a write data instruction sent by the arbitration node has been received, a write data operation is performed according to the data write request; and when the connection with the other storage nodes is restored to normal, the data to be written information is synchronized to the other storage nodes so that the other storage nodes can perform a write data operation according to the data to be written information.

[0023] In one possible implementation, the data to be written information includes the disk identifier to be written, the starting logical block address, the data content to be written, and the data length to be written;

[0024] Perform write data operations in the following ways:

[0025] The address of the logical block to be written is determined based on the starting logical block address and the length of the data to be written.

[0026] Obtain the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written;

[0027] If it is determined based on the lock information that the logic block to be written is not locked, then the data content to be written is written into the logic block to be written; and when the data content to be written is written into the logic block to be written, the logic block to be written is locked.

[0028] In one possible implementation, assuming normal connectivity with other storage nodes, the method further includes:

[0029] The lock information is synchronized to the other storage nodes, and the other storage nodes perform write data operations based on the lock information and the data to be written.

[0030] In one possible implementation, in the event of a connectivity anomaly with the other storage nodes, the following is also included:

[0031] Store the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to the other storage nodes;

[0032] Once the connection with the other storage nodes is restored to normal, the address information of the logical block to be written corresponding to the data to be written will be sent to the other storage nodes for synchronization.

[0033] In one possible implementation, obtaining the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written specifically includes:

[0034] The region and region offset of the starting logical block on the disk are determined based on the starting logical block address and the number of logical blocks in each region of the disk.

[0035] The number of regions spanned by the logical blocks corresponding to the data to be written is determined based on the region offset, the data length, and the number of logical blocks in each region of the disk.

[0036] Based on the region of the disk where the starting logical block is located and the number of regions spanned, the target region of the disk where the logical block corresponding to the data to be written is located is determined.

[0037] The hash value is obtained by hashing the disk identifier to be written and the target area identifier. The flag information of each logical block address of the target area corresponding to the hash value is found in the preset hash table. The flag information of the logical block address to be written is determined as the lock information corresponding to the logical block to be written.

[0038] In one possible implementation, locking the logic block to be written when writing the data content to be written specifically includes:

[0039] When writing the data to be written to the logic block, the flag bit of the address of the logic block to be written is set to lock the logic block to be written.

[0040] Thirdly, embodiments of this application provide a data storage device applied to a data storage system. The data storage system includes an arbitration node and two storage nodes. The arbitration node is connected to each storage node, and the storage nodes are connected to each other. The device includes:

[0041] The receiving unit is used to receive data write requests sent by the terminal device;

[0042] The synchronization unit is used to synchronize the data to be written information carried in the data write request to the other storage nodes if it is determined that the connection between the data and the other storage nodes is normal, so as to perform the data write operation in parallel with the other storage nodes.

[0043] The first sending unit is configured to send an arbitration request to the arbitration node if it is determined that the connection with other storage nodes is abnormal.

[0044] The processing unit is configured to, if it determines that a write data instruction has been received from the arbitration node, perform a write data operation according to the data write request; and, when the connection with the other storage nodes is restored to normal, synchronize the data to be written to the other storage nodes so that the other storage nodes can perform a write data operation according to the data to be written.

[0045] In one possible implementation, the data to be written information includes the disk identifier to be written, the starting logical block address, the data content to be written, and the data length to be written;

[0046] The synchronization unit is specifically used to perform write data operations in the following ways: determining the address of the logical block to be written based on the starting logical block address and the length of the data to be written; obtaining the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written; if it is determined based on the lock information that the logical block to be written is not locked, then writing the data to be written into the logical block to be written; and locking the logical block to be written when writing the data to be written into the logical block to be written.

[0047] In one possible implementation, the synchronization unit is further configured to synchronize the lock information to the other storage nodes when the connection between the storage nodes and the other storage nodes is normal, so that the other storage nodes can perform write data operations based on the lock information and the data to be written information.

[0048] In one possible implementation, the device further includes:

[0049] The storage unit is used to store the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to the other storage nodes in the event of an abnormal connection with the other storage nodes.

[0050] The second sending unit is used to send the address information of the logical block to be written corresponding to the data to be written to the other storage nodes for synchronization when the connection between the data to be written and the other storage nodes is restored to normal.

[0051] In one possible implementation, the synchronization unit is specifically configured to: determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk; determine the number of regions spanned by the logical block to be written corresponding to the data to be written based on the region offset, the data length, and the number of logical blocks in each region of the disk; determine the target region of the logical block to be written corresponding to the data to be written based on the region of the starting logical block on the disk and the number of regions spanned; perform a hash calculation on the disk identifier to be written and the target region identifier to obtain a hash value; search for the flag information of each logical block address of the target region corresponding to the hash value in a preset hash table; and determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

[0052] In one possible implementation, the synchronization unit is specifically used to set a flag bit of the address of the logic block to be written when the data content to be written is being written to the logic block to be written, so as to lock the logic block to be written.

[0053] Fourthly, embodiments of this application provide an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, it implements the data storage method of the data storage system described in this application.

[0054] Fifthly, embodiments of this application provide a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the data storage method of the data storage system described in this application.

[0055] The beneficial effects of the embodiments of this application are as follows:

[0056] In the data storage scheme provided in this application embodiment, the data storage system includes an arbitration node and two storage nodes. The arbitration node is connected to each storage node, and the storage nodes are connected to each other. A storage node receives a data write request from a terminal device. If the connection with other storage nodes is normal, it synchronizes the data to be written carried in the data write request to the other storage nodes, enabling the storage node and other storage nodes to perform write operations in parallel. If the connection with other storage nodes is abnormal, it sends an arbitration request to the arbitration node. The arbitration node receives the arbitration request from the storage nodes, determines the target storage node for the write operation based on the connection status with each storage node, and sends a write instruction to the target storage node. If a storage node confirms receipt of the write instruction from the arbitration node, it performs the write operation according to the data write request. Once the connection with other storage nodes is restored, it synchronizes the data to be written to the other storage nodes, enabling the other storage nodes to perform write operations based on the data to be written. Compared to existing master-slave mode data storage methods, the data storage system provided in this application embodiment offers advantages over traditional methods. This new method does not distinguish between primary and standby storage nodes and introduces an arbitration node. Whenever any storage node receives a write request from a terminal device, provided the connection between storage nodes is normal, that node will synchronize the data to be written carried in the write request to other storage nodes. This allows all storage nodes to perform write operations simultaneously and in parallel. Compared to the existing data storage method where primary and standby storage nodes perform write operations serially, this improves data backup efficiency. If the connection between storage nodes is abnormal, the arbitration node determines the storage node to perform the write operation first based on the connection status with each storage node. Once the connection between that storage node and other storage nodes is restored, the data to be written is synchronized to other storage nodes, enabling them to perform data backup. In this way, the arbitration node can select a storage node with better network performance to store data first, and then perform data backup on other storage nodes after the connection between that storage node and other storage nodes is restored, thus avoiding data loss and improving the reliability of the storage service.

[0057] Other features and advantages of this application will be set forth in the description which follows, and will be apparent in part from the description, or may be learned by practicing the application. The objectives and other advantages of this application may be realized and obtained by means of the structures particularly pointed out in the written description, claims, and drawings. Attached Figure Description

[0058] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0059] Figure 1 This is one of the structural diagrams of the data storage system provided in the embodiments of this application;

[0060] Figure 2 This is a second structural diagram of the data storage system provided in the embodiments of this application;

[0061] Figure 3 This is the third structural diagram of the data storage system provided in the embodiments of this application;

[0062] Figure 4 A schematic diagram of a distributed lock provided for an embodiment of this application;

[0063] Figure 5(a) , 5(b) This is an example diagram of the disk area structure to be written provided in an embodiment of this application;

[0064] Figure 6 A schematic diagram illustrating the implementation process of the data storage method provided in this application embodiment;

[0065] Figure 7 A schematic diagram illustrating the implementation process of performing write data operations on a storage node provided in this application embodiment;

[0066] Figure 8 This is a schematic diagram illustrating the implementation process of obtaining lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written, as provided in an embodiment of this application.

[0067] Figure 9 A schematic diagram illustrating another implementation of the data storage method provided in this application;

[0068] Figure 10 This is a schematic diagram of the data storage structure provided in the embodiments of this application;

[0069] Figure 11 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Detailed Implementation

[0070] To address the problems in the background art, embodiments of this application provide a data storage method, apparatus, system, electronic device, and storage medium.

[0071] The preferred embodiments of this application are described below with reference to the accompanying drawings. It should be understood that the preferred embodiments described herein are for illustration and explanation only and are not intended to limit this application. Furthermore, the embodiments and features in the embodiments of this application can be combined with each other without conflict.

[0072] In this document, it is important to understand that the technical terms used in this application refer to:

[0073] 1. LBA (Logical Block Address): This is a common mechanism for describing the block of data located on a computer storage device, typically used in auxiliary memory devices such as hard drives. An LBA can refer to the address of a specific data block or the data block pointed to by a given address.

[0074] 2. BitMap: Each bit represents a certain state. It is essentially an application implementation of a hash table. In this embodiment, the BitMap is used to record the flag bits of the logical block addresses of the disk area. When the flag bit of a certain logical block address is 1, it means that the logical block is currently being written to. When the flag bit of a certain logical block address is 0, it means that the logical block is not currently being written to.

[0075] 3. Offset: The distance between the actual address of a memory cell and the segment address of the segment it belongs to is called the segment offset, also known as the effective address.

[0076] like Figure 1 As shown, this is one of the structural diagrams of a data storage system provided in an embodiment of this application. The data storage system may include an arbitration node 11 and at least two storage nodes 12. The arbitration node 11 is connected to each storage node 12 via a network, and the storage nodes 12 are connected to each other via a network.

[0077] Arbitration node 11 is used to receive arbitration requests sent by storage node 12, determine the target storage node 12 to perform write data operation based on the connection status with each storage node 12, and send write data instruction to the target storage node 12.

[0078] Storage node 12 is used to receive data write requests sent by terminal devices. If it is determined that the connection between storage node 12 and other storage nodes 12 is normal, it will synchronize the data to be written carried in the data write request to other storage nodes 12 so that storage node 12 and other storage nodes 12 can perform data write operations in parallel. If it is determined that the connection between storage node 12 and other storage nodes 12 is abnormal, it will send an arbitration request to arbitration node 11. If it is determined that a write data instruction sent by arbitration node 11 is received, it will perform data write operations according to the data write request, and when the connection between storage node 12 and other storage nodes 12 is restored to normal, it will synchronize the data to be written to other storage nodes 12 so that other storage nodes 12 can perform data write operations according to the data to be written.

[0079] In specific implementation, this application embodiment only uses two storage nodes 12: storage node 1 and storage node 2 for illustration. The number and geographical location of storage nodes 12 can be set as needed, and this application embodiment does not limit this. Each storage node 12 may include a storage gateway node 121 and a storage device 122. The storage gateway node 121 and the storage device 122 are connected through a network. The storage device can be a server or a distributed server cluster, and this application embodiment does not limit this.

[0080] In this embodiment of the application, storage node 12 receives an IO request sent by the terminal device. The IO request can be a data write request or a data read request. Figure 2 As shown, this is a second structural diagram of the data storage system provided in this application embodiment. If the storage node 12 receiving the data write request (or data read request) sent by the receiving terminal is storage node 1, then the other storage nodes 12 are storage nodes 2. If the storage node 12 receiving the data write request (or data read request) sent by the receiving terminal is storage node 2, then the other storage nodes are storage nodes 1.

[0081] Arbitration node 11 is connected to the storage gateway node 121 of each storage node 12 via a network, and the storage gateway nodes 121 of each storage node 12 are connected to each other via a network.

[0082] Storage gateway node 121, when receiving a data write request from a terminal device, if it determines that the connection between its own storage node 12 and other storage nodes 12 is normal, synchronizes the data to be written carried in the data write request to other storage nodes 12, so that storage gateway node 121 and the storage gateway nodes 121 of other storage nodes 12 can write the data to be written carried in the data write request to their respective connected storage devices 122 in parallel; if it determines that the connection between its own storage node 12 and other storage nodes 12 is abnormal, it sends an arbitration request to arbitration node 11; if it determines that it has received a write data instruction sent by arbitration node 11, it writes the data to be written carried in the data write request to the connected storage device 122, and waits for the connection between the storage node 12 and other storage nodes 12 to be restored to normal, synchronizes the data to be written to the storage gateway nodes 121 of other storage nodes 12, so that other storage nodes 12 can write the data to be written to the connected storage device 122.

[0083] The data to be written may include, but is not limited to, the following information: disk identifier, starting logical block address, data content to be written, and data length to be written. The disk to be written is a disk in storage device 122. Storage device 122 may contain multiple disks, each disk has a unique identifier, and the disk may be divided into multiple regions, each region may be divided into multiple logical blocks. For example, storage device 122 contains 5 disks, each disk contains 10 regions, and each region contains 20 logical blocks. In implementation, the number of disks in storage device 122, the number of regions of the disks, and the number of logical blocks in the regions can be set according to actual needs and the capacity of storage device 122. This application embodiment does not limit this.

[0084] Storage device 122 is used to store the data to be written by storage gateway node 121.

[0085] like Figure 3 As shown, this is the third structural diagram of the data storage system provided in this application embodiment. The storage gateway node 121 may include an input / output processing module 1211, a data transceiver module 1212, a distributed lock module 1213, a data synchronization module 1214, and a heartbeat module 1215, wherein:

[0086] The input / output processing module 1211 is used to receive data write requests sent by the terminal device and send the data to be written to the data transceiver module 1212; if it is determined from the lock information obtained by the distributed lock module 1213 that the logic block to be written is not locked, then the data to be written is written to the logic block to be written.

[0087] In practice, if the block to be written is not locked, it means that no write operation is being performed on the block, and the data to be written can be written into the block. If the block to be written is locked, it means that one or more blocks to be written are being written. After the write operation is completed, the block will be set to unlocked. So, when the current state of the block to be written is locked, it is necessary to wait until the lock information obtained by the distributed lock module 1213 is that the block to be written is unlocked.

[0088] The data transceiver module 1212 is used to receive the data information to be written sent by the input / output processing module 1211.

[0089] The distributed lock module 1213 is used to determine the address of the logical block to be written based on the starting logical block address and the length of the data to be written, obtain the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written in the storage device 122, and lock the logical block to be written when the input / output processing module 1211 writes the data content to be written in the logical block.

[0090] The heartbeat module 1215 is used to monitor the connection status with other storage nodes 12.

[0091] In specific implementation, the heartbeat module 1215 can send heartbeat packets to the heartbeat module 1215 in the storage gateway node 121 of other storage nodes 12 according to a preset time period. If the heartbeat module 1215 of other storage nodes 12 returns a response message within the set time period, the connection between storage nodes 12 is normal; otherwise, the connection between storage nodes 12 is abnormal. The preset time period and the set time period can be set as needed, and this application embodiment does not limit them.

[0092] The distributed lock module 1213 is also used to synchronize lock information to the distributed lock modules of other storage nodes 12 when the connection between its own storage node 12 and other storage nodes 12 is normal.

[0093] The data transceiver module 1212 is also used to send the data to be written to the data transceiver module 1212 of other storage nodes 12 when the connection between its own storage node 12 and other storage nodes 12 is normal. The data transceiver module 1212 of other storage nodes 12 then sends the data to its input / output processing module 1211, which writes the data to be written into its storage device 122 based on the lock information.

[0094] In practice, the starting logical block of the disk to be written can be located based on the disk identifier and the starting logical block address. The ending logical block address can be obtained by summing the starting logical block address and the length of the data to be written. The logical blocks between the starting logical block address and the ending logical block address are the logical blocks to be written.

[0095] The distributed lock module 1213 is specifically used to determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk; to determine the number of regions across which the logical block to be written corresponds to the data to be written; to determine the target region of the logical block to be written corresponding to the data to be written based on the region and the number of regions across which the starting logical block is located; to perform a hash calculation on the disk identifier to be written and the target region identifier to obtain a hash value; to look up the flag information of each logical block address in the target region corresponding to the hash value from a preset hash table; and to determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

[0096] The distributed lock module 1213 is specifically used to set the flag bit of the address of the logic block to be written when the input / output processing module 1211 is writing the data content to be written into the logic block to lock the logic block to be written.

[0097] In practice, the region value of the starting logical block located on the disk (i.e., the disk corresponding to the disk identifier to be written, i.e., the disk to be written) can be calculated using the following formula:

[0098] Zone Value = LBA0|a+1

[0099] The Zone Value represents the region on the disk where the starting logical block is located.

[0100] LBA0 represents the address of the starting logical block;

[0101] 'a' represents the number of logical blocks in each region of the disk;

[0102] LBA0|a represents the starting logical block address divided by the number of logical blocks in each region of the disk.

[0103] The region offset corresponding to the starting logic block can be calculated using the following formula:

[0104] Offset = LBA0%a

[0105] Offset represents the region offset corresponding to the starting logical block;

[0106] LBA0%a represents the remainder after dividing the starting logical block address by the number of logical blocks in each region of the disk. The number of regions spanned by the logical block to be written can be calculated using the following formula:

[0107] b = (Offset + length) | a + 1

[0108] Where b represents the number of regions that the logical block to be written corresponds to;

[0109] Length indicates the length of the data to be written;

[0110] (Offset+length)|a represents the sum of the region offset corresponding to the starting logical block and the length of the data to be written, divided by the number of logical blocks in each region of the disk.

[0111] Therefore, the target area of ​​the logical block to be written on the disk can be determined based on the region of the starting logical block and the number of regions it spans.

[0112] The distributed lock module 1213 pre-stores a hash table. The hash values ​​in the hash table are obtained by hashing disk identifiers and different disk region values ​​(i.e., region identifiers). It also stores the correspondence between hash values ​​and bitmaps. The bitmap is used to record the flag bits of logical block addresses of disk regions to indicate whether a logical block is currently being written to. If the flag bit of a logical block address is 1, it means that the logical block is currently being written to. If the flag bit of a logical block address is 0, it means that the logical block is not currently being written to.

[0113] After determining that the logical block to be written, corresponding to the data to be written, is located in the target region of the disk to be written, the distributed lock module 1213 performs a hash calculation on the disk identifier and the target region value to obtain a hash value. It then searches the hash table for the bitmap corresponding to the address of each logical block in the target region corresponding to the hash value. From the flag information of each logical block address recorded in the bitmap, it searches for the flag information of the logical block address to be written. The flag information of the logical block address is the lock information corresponding to the logical block to be written. If the flags of each logical block address are 0, it is determined that the logical block to be written is not locked. Therefore, when the input / output processing module 1211 writes the data to be written to the logical block, it sets the flags of the logical block address, i.e., the logical block to be written is locked. The flag bit of the logical block address is set to 1 to lock the logical block to be written, and a synchronization message is sent to the distributed lock module 1213 in the storage gateway node 121 of other storage nodes 12. The flag bit information of the logical block address to be written after being set (i.e., the bitmap recording the flag bit information of the logical block address to be written after being set) is synchronized to the distributed lock module 1213 in the storage gateway node 121 of other storage nodes 12. The input / output processing module 1211 of other storage nodes 12 writes the data content to be written into the logical block to be written in the storage device 122 to which it is connected, based on the flag bit information of the logical block address to be written. Thus, the data write operation is executed simultaneously and in parallel by each storage node 12. In this embodiment, the lock information: the flag bit information of the logical block address to be written can be stored in memory or cache to provide access speed. The schematic diagram of the above distributed lock is as follows. Figure 4 As shown.

[0114] The following example illustrates the specific process of obtaining the flag information of the address of the logical block to be written:

[0115] Assume the disk to be written in the storage device contains five regions: Region 1 to Region 5, and the disk structure is shown in Figure 5(a). Assume each region contains 20 logical blocks, and each logical block can store 1 bit of data. Then, the writable data in Region 1 is bits 1 to 20, in Region 2 bits 21 to 40, in Region 3 bits 41 to 60, in Region 4 bits 61 to 80, and in Region 5 bits 81 to 100. Assume the starting logical block address corresponding to the data to be written is located at bit 30 of the disk to be written, and the length of the data to be written is 20 bits. Then, the region value of the starting logical block on the disk to be written is: starting logical block address | number of logical blocks in each region + 1 = 30 | 20 + 1 = 1 + 1 = 2. That is to say, the starting logical block is located in Region 2 of the disk to be written, and the region corresponding to the starting logical block is biased. The displacement is: starting logical block address % number of logical blocks in each region = 30% 20 = 10. Therefore, the target regions of the logical block to be written corresponding to the data content to be written in the disk to be written are: region 2 and region 3, as shown in Figure 5(b). The shaded part is the location of the logical block to be written, which spans two regions, region 2 and region 3. The disk identifier to be written and region 2 and region 3 are hashed to obtain the hash value. The bitmap corresponding to the hash value is found in the hash table, that is, the bitmap corresponding to region 2 and region 3 of the disk to be written. The bitmap is composed of multiple bits, and the value of each bit is 0 or 1. Each bit of the bitmap corresponding to region 2 and region 3 identifies the flag bit corresponding to each logical block in region 2 and region 3 respectively. The bitmap corresponding to region 2 and region 3 is a 40-bit string, and the value of each bit is 0 or 1.

[0116] If the connection between the storage node 12 that currently receives the data write request and other storage nodes 12 is abnormal, an arbitration request is sent to the arbitration node 11 through the heartbeat module 1215. The arbitration node 11 sends heartbeat packets to the heartbeat modules 1215 of each storage node 12 to detect the connection status between itself and each storage node 12. It sends a write data instruction to the target storage node 12 with normal network connection, and the target storage node 12 performs the write data operation first. If the connection status between the arbitration node 11 and each storage node 12 is normal, the storage node 12 with high data integrity can be selected as the target storage node and the write data operation can be performed first.

[0117] Specifically, the arbitration node 11 can select the storage node 12 with more unsynchronized data as the target storage node, that is: the storage node 12 with more flag bits of the unsynchronized logical block address stored in the data synchronization module 1214 is selected as the target storage node.

[0118] The data synchronization module 1214 is used to store the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to other storage nodes 12 when the connection between its own storage node 12 and other storage nodes 12 is abnormal. When the connection between the storage node 12 and other storage nodes 12 is restored to normal, the address information of the logical block to be written corresponding to the data content to be written is sent to the data synchronization module 1214 of other storage nodes 12 for synchronization.

[0119] In specific implementation, if the connection between storage node 12 and other storage nodes 12 is abnormal, the data synchronization module 1214 stores the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to other storage nodes 12. When the connection between storage node 12 and other storage nodes 12 is restored to normal, the address information of the logical block to be written corresponding to the data content to be written is sent to the data synchronization module 1214 of other storage nodes 12. The data transceiver module 1212 sends the data information to be written to the data transceiver module 1212 of other storage nodes 12, and then its data transceiver module 1212 sends it to its input / output processing module 1211. Thus, the input / output processing module of other storage nodes 12 writes the data content to be written into the logical block to be written of the storage device 122 it is connected to based on the address information of the logical block to be written corresponding to the data content to be written.

[0120] Once the storage node 12 and other storage nodes 12 have completed the data write operation, the bits in the bitmap corresponding to the address of the logical block to be written are reset to 0 to release the lock, and the input / output processing module 1211 of the storage node 12 returns a message of successful data storage to the terminal device.

[0121] If storage node 12 (i.e., the storage node 12 that receives the data write request sent by the terminal device) does not receive the write data instruction sent by arbitration node 11, and arbitration node 11 sends the write data instruction to other storage nodes 12, then other storage nodes 12 perform the write data operation according to the data write request, and when the connection between them and other storage nodes 12 is restored to normal, they receive the write logical address information corresponding to the write data content synchronized by other storage nodes 12, and write the write data content to the write logical block of storage device 122 based on the write logical block address information corresponding to the write data content.

[0122] Storage node 12 is also used to return requested data to the terminal device if it receives a data read request sent by the terminal device.

[0123] In specific implementation, the input / output processing module 1211 is used to receive data read requests sent by the terminal device, read the requested data content from the storage device 122, and return the requested data content to the terminal device.

[0124] The data storage system provided in this application embodiment implements dual-write backup of real-time business data across storage nodes located in different regions, fully utilizing storage node resources and improving system availability. A high-speed distributed lock mechanism ensures that data writes between storage gateway nodes on different storage nodes do not conflict, and lock information is stored in memory or cache to improve access speed. An arbitration node ensures that in the event of a network connection failure between storage nodes, the optimal storage node is selected to provide uninterrupted storage services, improving the reliability of the data storage system. Furthermore, once the network between a storage node or storage nodes is restored, the backup data can be automatically synchronized, ensuring data consistency across storage devices. The storage gateway node does not require the computing power of storage device nodes, has low cost, and is applicable to various storage devices, such as traditional storage media (disks, etc.) or distributed storage cluster servers.

[0125] Based on the same inventive concept, this application also provides a data storage method. Since the principle of the above data storage method in solving the problem is similar to that of the data storage system, the implementation of the above method can refer to the implementation of the system, and the repeated parts will not be described again.

[0126] like Figure 6 The diagram illustrates the implementation flow of the data storage method provided in this embodiment of the invention. This data storage method is applied to the data storage system provided in this application embodiment. The data storage system includes an arbitration node and at least two storage nodes. The arbitration node is connected to each storage node via a network, and the storage nodes are connected to each other via a network. Each storage node includes a storage gateway node and a storage device. The storage gateway node includes an input / output processing module, a data transceiver module, a distributed lock module, a data synchronization module, and a heartbeat module. The data storage method may specifically include the following steps:

[0127] S21. The storage node receives a data write request sent by the terminal device.

[0128] In practice, the terminal device can send an I / O request to the storage node. The I / O request can be a data write request or a data read request. The input / output module of the storage gateway node of the storage node receives the data write request sent by the terminal device. The data write request carries information about the data to be written, which may include at least: the disk identifier to be written, the starting logical block address, the data content to be written, and the length of the data to be written.

[0129] S22. If a storage node determines that the connection with other storage nodes is normal, it will synchronize the data to be written carried in the data write request to other storage nodes so that the write data operation can be performed in parallel with other storage nodes.

[0130] In practice, storage nodes can monitor the connection status with other storage nodes through the heartbeat module of the storage gateway node. For details on the implementation process, please refer to the implementation in the data storage system. It will not be elaborated here.

[0131] If a storage node determines that the connection with other storage nodes is normal, it can send the data to be written to its data transceiver module through its input / output processing module. The data transceiver module then sends the data to the data transceiver module of the storage gateway node of the other storage node, and the data transceiver module of the other storage node sends the data to the input / output processing module of that other storage node.

[0132] Specifically, storage nodes can be accessed through methods such as Figure 7 The process shown executes a write data operation:

[0133] S221. Determine the address of the logic block to be written based on the starting logic block address and the length of the data to be written.

[0134] In practice, the input / output module in the storage node obtains the lock information corresponding to the logical block to be written of the disk corresponding to the disk identifier to be written from the distributed lock module, and writes the data content to be written into the logical block to be written of the storage device based on the lock information.

[0135] The distributed lock module determines the address of the logical block to be written based on the starting logical block address and the length of the data to be written.

[0136] S222. Obtain the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written.

[0137] In practical implementation, the distributed lock module can be implemented through methods such as... Figure 8 The process shown retrieves the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written:

[0138] S2221. Determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk.

[0139] S2222. Determine the number of regions spanned by the logical blocks to be written corresponding to the data content to be written, based on the region offset, data length, and the number of logical blocks in each region of the disk.

[0140] S2223. Based on the region of the disk where the starting logical block is located and the number of regions, determine the target region of the disk where the logical block corresponding to the data to be written is located.

[0141] S2224. Perform a hash calculation on the disk identifier to be written and the target area identifier to obtain a hash value. Search the preset hash table for the flag information of each logical block address of the target area corresponding to the hash value, and determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

[0142] S223. If it is determined from the lock information that the logic block to be written is not locked, then write the data content to be written into the logic block to be written; and when writing the data content to be written into the logic block to be written, lock the logic block to be written.

[0143] In practice, the distributed lock module returns the lock information corresponding to the logic block to be written to the input / output processing module. If the input / output processing module determines that the logic block to be written is not locked based on the lock information, it writes the data content to be written into the logic block and locks the logic block when writing the data content to be written.

[0144] Locking a block of logic to be written can be achieved by setting a flag at the address of the block when writing data to it.

[0145] For specific implementation details of the above steps, please refer to the implementation of the corresponding part in the data storage system; they will not be repeated here.

[0146] Assuming normal connectivity with other storage nodes, the storage node also includes:

[0147] The lock information of the logic block to be written is synchronized to other storage nodes, and the other storage nodes perform write data operations based on the lock information and the data to be written.

[0148] In practice, when the storage node is connected normally with other storage nodes, the distributed lock module of the storage node synchronizes the lock information of the logic block to be written to the distributed lock modules of other storage nodes for storage. The input / output processing modules of other storage nodes then perform the write data operation based on the lock information and the data to be written.

[0149] S23. If a storage node determines that the connection between itself and other storage nodes is abnormal, it sends an arbitration request to the arbitration node.

[0150] In practice, if the connection between the storage node currently receiving the data write request and other storage nodes is abnormal, an arbitration request is sent to the arbitration node through the heartbeat module. The arbitration node sends heartbeat packets to the heartbeat modules of each storage node to detect the connection status between itself and each storage node. It sends a write data instruction to the target storage node with normal network connection, and the target storage node performs the write data operation first. If the connection status between the arbitration node and each storage node is normal, the storage node with high data integrity can be selected as the target storage node and the write data operation can be performed first. That is, the storage node with more unsynchronized data can be selected as the target storage node, that is, the storage node with more flag bits of unsynchronized logical block addresses stored in the data synchronization module is selected as the target storage node.

[0151] S24. If a storage node determines that it has received a write data instruction sent by the arbitration node, it shall perform a write data operation according to the data write request; and when the connection between the storage node and other storage nodes is restored to normal, it shall synchronize the data to be written to other storage nodes so that other storage nodes may perform a write data operation according to the data to be written.

[0152] The write data instruction is sent by the arbitration node to the target storage node to perform the write data operation, based on the connection status with each storage node.

[0153] In the event of a storage node experiencing connectivity issues with other storage nodes, the following also applies:

[0154] Store the address information of the logical block to be written corresponding to the data to be written that has not been synchronized to other storage nodes; when the connection between the data to be written and other storage nodes is restored to normal, send the address information of the logical block to be written corresponding to the data to be written to other storage nodes for synchronization.

[0155] In practice, when a connection between a storage node and other storage nodes is abnormal, the data synchronization module of the storage node stores the address information of the logical block to be written corresponding to the data to be written that has not been synchronized to other storage nodes. When the connection between the storage node and other storage nodes is restored, the address information of the logical block to be written corresponding to the data to be written is sent to the data synchronization module of other storage nodes for synchronization. The input / output processing module of the storage node sends the data to be written information to its data transceiver module, which then sends it to the data transceiver module of other storage nodes. The data transceiver module of other storage nodes then sends it to the input / output processing module of that other storage node. The input / output processing module of the other storage node writes the data to be written into the logical block to be written of the storage device of that other storage node based on the data to be written information and the address information of the logical block to be written corresponding to the data to be written.

[0156] The following is combined Figure 2The data storage system architecture of this application is described, along with the overall flow of the data storage method provided in the embodiments. Figure 9 As shown, the data storage method includes the following steps:

[0157] Suppose that storage node 1 receives an IO request sent by the terminal device.

[0158] S31, The storage gateway node of storage node 1 receives IO requests sent by the terminal device.

[0159] S32. Determine whether the type of the IO request is a data write request. If it is a data write request, proceed to step S33. If it is a data read request, proceed to step S315.

[0160] S33. The storage gateway node of storage node 1 determines whether the network connection between it and the storage gateway node of storage node 2 is normal. If it is normal, proceed to step S34; otherwise, proceed to step S311.

[0161] S34. The storage gateway node of storage node 1 determines whether it has successfully acquired the distributed lock. If it has successfully acquired the distributed lock, proceed to steps S36 to S310; otherwise, proceed to step S35.

[0162] Storage Node 1's storage gateway node acquires the distributed lock and determines whether the acquisition was successful. If the acquisition was successful, steps S36 to S310 are executed; otherwise, step S35 is executed.

[0163] S35. Storage node 1 continues to attempt to acquire the distributed lock until it acquires the distributed lock, after which it executes steps S36 to S310.

[0164] S36. The storage gateway node of storage node 1 writes the data to be written carried in the data write request to the storage device.

[0165] S37. The storage gateway node of storage node 1 sends the data to be written information in the data write request to the storage gateway node of storage node 2.

[0166] S38, The storage gateway node of storage node 2 writes the data to be written to the storage device.

[0167] S39. Determine whether data was successfully written to storage node 1 and storage node 2. If data was successfully written to both, proceed to step S310.

[0168] S310, storage node 1 returns a message to the terminal device that the data has been successfully stored.

[0169] S311. Storage node 1 sends an arbitration request to the arbitration node and determines whether the arbitration node will arbitrate the write data operation performed by storage node 1. If yes, proceed to step S312; otherwise, proceed to step S39.

[0170] S312, The storage gateway node of storage node 1 writes the data to be written carried in the data write request to the storage device.

[0171] S313. If storage node 1 successfully writes data, its storage gateway node updates the bitmap of the logical address to be written in order to record the unsynchronized data information.

[0172] S314. The storage gateway node of storage node 1 returns the execution result of the data write operation to the terminal device.

[0173] S315, The storage gateway node of storage node 1 reads the requested data content from the storage device.

[0174] S316, The storage gateway node of storage node 1 returns the read data content to the terminal device.

[0175] The specific implementation of each of the above steps refers to the implementation of the data storage device described in the embodiments of this application, and will not be repeated here.

[0176] Based on the same inventive concept, this invention also provides a data storage device. Since the principle of the data storage device in solving the problem is similar to that of the data storage system, the implementation of the device can refer to the implementation of the system, and repeated details will not be described again.

[0177] like Figure 10 The diagram shown is a structural schematic of a data storage device provided in an embodiment of the present invention. This data storage device is applied to the data storage system described above in this application embodiment. The data storage system includes an arbitration node and two storage nodes. The arbitration node is connected to each storage node, and the storage nodes are connected to each other. The device includes:

[0178] Receiving unit 41 is used to receive data write requests sent by terminal devices;

[0179] Synchronization unit 42 is used to synchronize the data to be written information carried in the data write request to the other storage nodes if it is determined that the connection between the data and the other storage nodes is normal, so as to perform the data write operation in parallel with the other storage nodes.

[0180] The first sending unit 43 is used to send an arbitration request to the arbitration node if it is determined that the connection between the node and other storage nodes is abnormal.

[0181] The processing unit 44 is configured to, if it determines that a write data instruction sent by the arbitration node has been received, perform a write data operation according to the data write request; and when the connection with the other storage nodes is restored to normal, synchronize the data to be written to the other storage nodes so that the other storage nodes can perform a write data operation according to the data to be written.

[0182] In one possible implementation, the data to be written information includes the disk identifier to be written, the starting logical block address, the data content to be written, and the data length to be written;

[0183] The synchronization unit 42 is specifically used to perform write data operations in the following ways: determining the address of the logical block to be written based on the starting logical block address and the length of the data to be written; obtaining the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written; if it is determined based on the lock information that the logical block to be written is not locked, then writing the data content to be written into the logical block to be written; and locking the logical block to be written when writing the data content to be written into the logical block to be written.

[0184] In one possible implementation, the synchronization unit 42 is further configured to synchronize the lock information to the other storage nodes when the connection between the two storage nodes is normal, so that the other storage nodes can perform write data operations based on the lock information and the data to be written information.

[0185] In one possible implementation, the device further includes:

[0186] The storage unit is used to store the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to the other storage nodes in the event of an abnormal connection with the other storage nodes.

[0187] The second sending unit is used to send the address information of the logical block to be written corresponding to the data to be written to the other storage nodes for synchronization when the connection between the data to be written and the other storage nodes is restored to normal.

[0188] In one possible implementation, the synchronization unit 42 is specifically configured to: determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk; determine the number of regions spanned by the logical block to be written corresponding to the data to be written based on the region offset, the data length, and the number of logical blocks in each region of the disk; determine the target region of the logical block to be written corresponding to the data to be written based on the region of the starting logical block on the disk and the number of regions spanned; perform a hash calculation on the disk identifier to be written and the target region identifier to obtain a hash value; search for the flag information of each logical block address of the target region corresponding to the hash value in a preset hash table; and determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

[0189] In one possible implementation, the synchronization unit 42 is specifically used to set the flag bit of the address of the logic block to be written when the data content to be written is written to the logic block to be written, so as to lock the logic block to be written.

[0190] Based on the same technical concept, this invention also provides an electronic device 500, referring to... Figure 11 As shown, the electronic device 500 is used to implement the data storage method or data storage device described in the above-described method embodiments. The electronic device 500 in this embodiment may include: a memory 501, a processor 502, and a computer program stored in the memory and executable on the processor, such as a data storage program or a data packet transmission program. When the processor executes the computer program, it implements the steps in the various data storage method embodiments described above, for example... Figure 6 Step S21 is shown.

[0191] The specific connection medium between the memory 501 and the processor 502 described above is not limited in the embodiments of this invention. This application embodiment... Figure 11 The memory 501 and the processor 502 are connected via a bus 503, and the bus 503 is in Figure 11 The connections between other components are shown in bold lines only and are not intended to be limiting. The bus 503 can be divided into address bus, data bus, control bus, etc. For ease of illustration, Figure 11 The bus is represented by a single thick line, but this does not mean that there is only one bus or one type of bus.

[0192] Memory 501 may be volatile memory, such as random-access memory (RAM); memory 501 may also be non-volatile memory, such as read-only memory, flash memory, hard disk drive (HDD), or solid-state drive (SSD); or memory 501 may be any other medium capable of carrying or storing desired program code in the form of instructions or data structures and accessible by a computer, but is not limited thereto. Memory 501 may be a combination of the above-mentioned memories.

[0193] Processor 502, used to implement such Figure 6 This illustrates a data storage method.

[0194] This application also provides a computer-readable storage medium storing computer-executable instructions required to execute the processor, including a program required to execute the processor.

[0195] In some possible implementations, various aspects of the data storage method provided by the present invention can also be implemented as a program product comprising program code that, when the program product is run on an electronic device, causes the electronic device to perform the steps in the data storage method according to various exemplary embodiments of the present invention described above.

[0196] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, apparatus, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0197] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (devices), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, and combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart illustrations and / or block diagrams. Figure 1One or more processes and / or boxes Figure 1 A device that provides the functions specified in one or more boxes.

[0198] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including instruction means, which are implemented in a process Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.

[0199] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.

[0200] Although preferred embodiments of the invention have been described, those skilled in the art, upon learning the basic inventive concept, can make other changes and modifications to these embodiments. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments as well as all changes and modifications falling within the scope of the invention.

[0201] Obviously, those skilled in the art can make various modifications and variations to this invention without departing from its spirit and scope. Therefore, if these modifications and variations fall within the scope of the claims of this invention and their equivalents, this invention also intends to include these modifications and variations.

Claims

1. A data storage method, characterized in that, The method, applied to a data storage system including an arbitration node and two storage nodes, wherein the arbitration node is connected to each storage node respectively, and the storage nodes are connected to each other, includes: The storage node receives a data write request sent by the terminal device; If the connection with other storage nodes is confirmed to be normal, the data to be written information carried in the data write request is synchronized to the other storage nodes so that the write data operation can be performed in parallel with the other storage nodes. If an anomaly is detected in the connection with other storage nodes, an arbitration request is sent to the arbitration node; If it is determined that a write data instruction sent by the arbitration node has been received, then a write data operation is performed according to the data write request; and when the connection with the other storage nodes is restored to normal, the data to be written information is synchronized to the other storage nodes so that the other storage nodes can perform a write data operation according to the data to be written information. The data to be written information includes a disk identifier to be written, a starting logical block address, data content to be written, and data length to be written. The disk corresponding to the disk identifier to be written includes lock information corresponding to the logical block to be written. The logical block to be written is determined based on the address of the logical block to be written, which is determined according to the starting logical block address and the data length to be written. Assuming normal connectivity with other storage nodes, this also includes: The lock information is synchronized to the other storage nodes, and the other storage nodes perform write data operations based on the lock information and the data to be written. Obtaining the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written, specifically includes: The region and region offset of the starting logical block on the disk are determined based on the starting logical block address and the number of logical blocks in each region of the disk. The number of regions spanned by the logical blocks corresponding to the data to be written is determined based on the region offset, the data length, and the number of logical blocks in each region of the disk. Based on the region of the disk where the starting logical block is located and the number of regions spanned, the target region of the disk where the logical block corresponding to the data to be written is located is determined. The hash value is obtained by hashing the disk identifier to be written and the target area identifier. The flag information of each logical block address of the target area corresponding to the hash value is found in the preset hash table. The flag information of the logical block address to be written is determined as the lock information corresponding to the logical block to be written.

2. The method as described in claim 1, characterized in that, Perform write data operations in the following ways: The address of the logical block to be written is determined based on the starting logical block address and the length of the data to be written. Obtain the lock information corresponding to the logical block to be written in the disk corresponding to the disk identifier to be written; If it is determined based on the lock information that the logic block to be written is not locked, then the data content to be written is written into the logic block to be written. And when writing the data content to be written in the logic block to be written, the logic block to be written is locked.

3. The method as described in claim 1, characterized in that, In the event of a connection failure with the other storage nodes, the following is also included: Store the address information of the logical block to be written corresponding to the data content to be written that has not been synchronized to the other storage nodes; Once the connection with the other storage nodes is restored to normal, the address information of the logical block to be written corresponding to the data to be written will be sent to the other storage nodes for synchronization.

4. The method as described in claim 1, characterized in that, When writing the data content to be written to the logic block, locking the logic block to be written specifically includes: When writing the data to be written to the logic block, the flag bit of the address of the logic block to be written is set to lock the logic block to be written.

5. A data storage device, characterized in that, An apparatus for use in a data storage system, the data storage system comprising an arbitration node and two storage nodes, wherein the arbitration node is connected to each storage node respectively, and the storage nodes are connected to each other, the apparatus comprising: The receiving unit is used to receive data write requests sent by the terminal device; The synchronization unit is used to synchronize the data to be written information carried in the data write request to the other storage nodes if it is determined that the connection between the data and the other storage nodes is normal, so as to perform the data write operation in parallel with the other storage nodes. The first sending unit is configured to send an arbitration request to the arbitration node if it is determined that the connection with other storage nodes is abnormal. The processing unit is configured to, if it determines that a write data instruction sent by the arbitration node has been received, perform a write data operation according to the data write request; and when the connection with the other storage nodes is restored to normal, synchronize the data to be written information to the other storage nodes so that the other storage nodes can perform a write data operation according to the data to be written information. The data to be written information includes a disk identifier to be written, a starting logical block address, data content to be written, and data length to be written. The disk corresponding to the disk identifier to be written includes lock information corresponding to the logical block to be written. The logical block to be written is determined based on the address of the logical block to be written, which is determined according to the starting logical block address and the data length to be written. The synchronization unit is also used to synchronize the lock information to the other storage nodes when the connection between them is normal, so that the other storage nodes can perform write data operations based on the lock information and the data to be written. The synchronization unit is specifically configured to: determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk; determine the number of regions across which the logical block to be written corresponds to the data to be written; determine the target region of the logical block to be written corresponding to the data to be written based on the region of the starting logical block on the disk and the number of regions across; perform a hash calculation on the disk identifier to be written and the target region identifier to obtain a hash value; search for the flag information of each logical block address of the target region corresponding to the hash value from a preset hash table; and determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

6. A data storage system, characterized in that, It includes an arbitration node and two storage nodes. The arbitration node is connected to each storage node, and the storage nodes are connected to each other. The arbitration node is used to receive the arbitration request sent by the storage node, determine the target storage node to perform the write data operation based on the connection status with each storage node, and send the write data instruction to the target storage node. The storage node is configured to receive data write requests sent by the terminal device. If the connection with other storage nodes is determined to be normal, the node synchronizes the data to be written information carried in the data write request to the other storage nodes, so that the storage node and the other storage nodes can perform write data operations in parallel. If the connection with other storage nodes is determined to be abnormal, the node sends an arbitration request to the arbitration node. If the node receives a write data instruction sent by the arbitration node, it performs a write data operation according to the data write request. When the connection with other storage nodes is restored to normal, the node synchronizes the data to be written information to the other storage nodes, so that the other storage nodes can perform write data operations according to the data to be written information. The data to be written information includes a disk identifier to be written, a starting logical block address, data content to be written, and data length to be written. The disk corresponding to the disk identifier to be written includes lock information corresponding to the logical block to be written. The logical block to be written is determined based on the address of the logical block to be written, which is determined according to the starting logical block address and the data length to be written. The storage node includes a storage gateway node and a storage device, and the storage gateway node includes a distributed lock module. The distributed lock module is used to synchronize the lock information to the distributed lock modules of the other storage nodes when the connection between the storage node and the other storage nodes is normal. The distributed lock module is further configured to: determine the region and region offset of the starting logical block on the disk based on the starting logical block address and the number of logical blocks in each region of the disk; determine the number of regions across which the logical block to be written corresponds to the data to be written; determine the target region of the logical block to be written corresponding to the data to be written based on the region of the starting logical block on the disk and the number of regions across; perform a hash calculation on the disk identifier to be written and the target region identifier to obtain a hash value; search for the flag information of each logical block address of the target region corresponding to the hash value from a preset hash table; and determine the flag information of the logical block address to be written as the lock information corresponding to the logical block to be written.

7. An electronic 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 program, it implements the data storage method as described in any one of claims 1 to 4.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the program is executed by the processor, it implements the steps in the data storage method as described in any one of claims 1 to 4.