Data writing method and device, electronic equipment and readable storage medium

By determining the write address occupancy status and selecting the target data for writing in a dual-active storage system, the problem of data asynchrony caused by write conflicts is solved, improving data synchronization efficiency and IO request response speed.

CN119620941BActive Publication Date: 2026-03-24MACROSAN TECH
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2026-03-24

AI Technical Summary

Technical Problem

In a dual-active storage system, write commands issued by an external server to two storage devices may cause write conflicts, resulting in data inconsistency between the two LUNs in the mirror, affecting backup functionality. Furthermore, existing technologies increase processing latency by forwarding write commands to one storage device for processing, impacting IO request response speed.

Method used

When a write command is received, it is determined whether the write address is occupied. If it is not occupied, the write is performed directly and an instruction is sent to the mirror device. If it is occupied, the target data that meets the conditions is selected for writing to avoid write conflicts, ensure data synchronization, and reduce the latency of write command forwarding.

Benefits of technology

It effectively reduces the probability of write conflicts, ensures data synchronization in the mirrored LUN, reduces processing latency, and guarantees the IO request response speed of the dual-active storage system.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119620941B_ABST
    Figure CN119620941B_ABST
Patent Text Reader

Abstract

The application provides a data writing method and device, electronic equipment and a readable storage medium. The application can solve the problem of data asynchronization in a dual-active storage system caused by writing conflicts, and does not need to forward the writing commands received by two storage devices to a storage device for queuing processing, which reduces the delay caused by repeated forwarding, saves the processing time of the writing commands, and ensures the response speed of the dual-active storage system in processing IO requests.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of data storage, and in particular to data writing methods, apparatus, electronic devices, and readable storage media. Background Technology

[0002] Active-active storage synchronizes data across two logical unit numbers (LUNs) on two storage devices through data mirroring. This allows for data recovery using the other LUN if one LUN fails, ensuring the reliability of the storage system. However, in certain situations, two external servers might issue write commands to the same address on two different storage devices. This can lead to write conflicts when either storage device executes the server's write command and when the mirrored storage is used. This causes the data stored in the two mirrored LUNs to become out of sync, resulting in different data read from the two LUNs and ultimately compromising the backup function.

[0003] In existing technologies, the write command received on one of the two storage devices is forwarded to the other storage device for processing to resolve the write conflict issue. For example, storage device 2 forwards all received write commands to storage device 1, which then sorts the write commands it receives and those received from storage device 2 and processes them in order. This solves the problem of data asynchrony in a dual-active storage system caused by write conflicts.

[0004] However, in the above method, a lot of interaction is required between the two storage devices, and storage device 2 can only execute write commands in sequence, which will generate a lot of processing latency and affect the response speed of the dual-active storage system in handling input / output (IO) requests. Summary of the Invention

[0005] In view of this, embodiments of this application provide a data writing method, apparatus, electronic device, and readable storage medium, so as not to affect the response speed of the dual-active storage system in processing IO requests.

[0006] This application provides a data writing method, which is applied to any storage device in a dual-active storage system, the storage system including two storage devices; wherein, for any storage device in the dual-active storage system, when the storage device receives a write command for a local logical unit number (LUN) from an external server, the storage device is used as the source storage device for this write operation, the LUN is determined as the source LUN, and the other storage device is used as the mirror storage device for this write operation, the LUN in the other storage device is used as the mirror LUN; the method includes:

[0007] When determining that this device is the source storage device, it checks whether the write address indicated by the received write command is currently occupied;

[0008] If not, the data to be written in the write command is stored in the write address indicated by the write command in the source LUN, and an instruction is sent to the mirror storage device of this device so that the mirror device writes the data according to the write address indicated by the instruction;

[0009] When it is determined that this device is a mirrored storage device, it receives an instruction from the source storage device and determines whether the write address indicated by the instruction is occupied at the current moment;

[0010] If not, the data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction.

[0011] If so, when the write address indicated by the instruction is fully occupied at the current moment, select the target data that meets the set conditions from the data occupying the write address and the data of the overlapping area address to be written in the instruction; and after the write command occupying the write address is processed, execute the write operation so that the target data is written to the write address indicated by the instruction.

[0012] When the write address indicated by the instruction is partially occupied at the current time, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction; and after the write command occupying the write address is processed, the write operation is performed so that the target data is written to the overlapping area address, and the data to be written to the unoccupied non-overlapping area address in the instruction is written to the non-overlapping area address.

[0013] This application embodiment also provides a data writing apparatus, which is applied to any storage device in a dual-active storage system, the storage system including two storage devices; wherein, for any storage device in the dual-active storage system, when the storage device receives a write command for a local logical unit number (LUN) from an external server, the storage device is used as the source storage device for this write operation, the LUN is determined as the source LUN, and the other storage device is used as the mirror storage device for this write operation, the LUN in the other storage device is used as the mirror LUN; the apparatus includes:

[0014] The first judgment module is used to determine whether the write address indicated by the received write command is occupied at the current moment when the device is determined to be the source storage device.

[0015] The first execution module is configured to, if not, store the data to be written in the write command in the source LUN at the write address indicated by the write command, and send an instruction to the mirror storage device of this device so that the mirror device writes data according to the write address indicated by the instruction;

[0016] The second judgment module is used to receive an indication from the source storage device when it is determined that this device is a mirror storage device, and to determine whether the write address indicated by the indication is occupied at the current time.

[0017] The second execution module is configured to, if not, store the data to be written in the instruction to the write address indicated by the instruction in the mirror LUN;

[0018] If so, when the write address indicated by the instruction is fully occupied at the current moment, select the target data that meets the set conditions from the data occupying the write address and the data of the overlapping area address to be written in the instruction; and after the write command that is currently occupying the write address is processed, perform the write operation so that the target data is written to the write address indicated by the instruction.

[0019] When the write address indicated by the instruction is partially occupied at the current time, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction; and after the write command occupying the write address is processed, the write operation is performed so that the target data is written to the overlapping area address, and the data to be written to the unoccupied non-overlapping area address in the instruction is written to the non-overlapping area address.

[0020] This application also provides an electronic device, including: a processor and a memory for storing computer program instructions, which, when executed by the processor, cause the processor to perform the steps of the method described above.

[0021] This application also provides a machine-readable storage medium storing computer program instructions that, when executed, enable the implementation of the steps described above.

[0022] As can be seen from the above technical solutions, in this embodiment, when the device is the source storage device, the data to be written is written to the write address indicated by the write command only when the write address indicated by the received write command is not occupied by other write commands at the current moment, and an instruction is sent to the mirror storage device of the device so that the mirror device writes data according to the write address indicated by the instruction. This method can reduce the probability of write conflicts and thus alleviate the problem of data asynchrony in the dual-active storage system caused by write conflicts.

[0023] Furthermore, in this embodiment, when it is determined that this device is a mirrored storage device, if the write address indicated by the indication from the source storage device is currently occupied, it is further determined whether the write address indicated by the indication is fully or partially occupied at the current moment. If it is fully occupied, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication. After the write command occupying the write address is processed, a write operation is performed to write the target data to the write address indicated by the indication. If it is partially occupied, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication. After the write command occupying the write address is processed, a write operation is performed to write the target data to the overlapping area address, and the data to be written to the unoccupied non-overlapping area address in the indication is written to the non-overlapping area address.

[0024] In this way, it can be guaranteed that the data ultimately written to the mirrored storage device is definite, which avoids the problem in existing technologies where it is impossible to know which data was overwritten, thus making it impossible to know the final write result. Based on this, when the two devices in a dual-active storage system each act as mirrored storage devices, they are executed in the above manner, and the final write result of both storage devices is definite, which enables the data stored in the two mirrored LUNs to be synchronized.

[0025] Furthermore, in this embodiment, there is no need to forward write commands received by two storage devices to one storage device for queuing processing, as is done in the previous technology. This reduces the latency caused by repeated forwarding, saves the time for processing write commands, and ensures the response speed of the dual-active storage system in handling IO requests. Attached Figure Description

[0026] Figure 1 This is an architecture diagram of a dual-active storage system provided in an embodiment of this application;

[0027] Figure 2 A flowchart illustrating the data writing method provided in this application embodiment;

[0028] Figure 3 This is a flowchart illustrating the process of determining target data provided in an embodiment of this application.

[0029] Figure 4 This is a schematic diagram of the device provided in the embodiments of this application;

[0030] Figure 5 This is a schematic diagram of the hardware structure of the electronic device provided in the embodiments of this application. Detailed Implementation

[0031] To enable those skilled in the art to better understand the technical solutions provided in the embodiments of this application, and to make the above-mentioned objectives, features and advantages of the embodiments of this application more apparent and understandable, the technical solutions in the embodiments of this application will be further described in detail below with reference to the accompanying drawings.

[0032] Before describing the method provided in this application, let's first combine... Figure 1 The dual-active storage system shown here provides a detailed explanation of the write conflict problem present in existing technologies:

[0033] Dual-active storage is a data protection and high-availability technology based on mirroring. It synchronizes the data of two LUNs in two storage devices through data mirroring, so that if the LUN in one storage device fails, the other LUN can be used to recover the data, thus ensuring the reliability of the storage system. Furthermore, the LUNs in both storage devices can provide data access to the server simultaneously.

[0034] See Figure 1 , Figure 1 This is an architecture diagram of a dual-active storage system provided in an embodiment of this application. Figure 1 As shown, storage device A and storage device B form a dual-active storage system. LUN-1 on storage device A and LUN-2 on storage device B are configured to mirror each other. In actual operation, when data is written to either LUN-1 or LUN-2, the data must simultaneously be mirrored and written to the other LUN to ensure data synchronization between the two LUNs. In this way, both LUNs provide data access services to the external server, and the failure of either LUN ensures uninterrupted service for the external server.

[0035] In special circumstances such as communication failures, servers A and B may simultaneously issue write commands to mirrored LUN-1 and LUN-2, and the write addresses may overlap (e.g., complete or partial overlap). In this case, the write address of the write command received by LUN-1 from the external server conflicts with the write address that triggers LUN-1 to perform the mirror write when LUN-2 executes its write command, resulting in a write conflict. For a single LUN, if two write commands, one for writing data A and the other for writing data B, are issued simultaneously, the order of execution is uncertain, meaning the final storage result could be either data A or data B. For LUN-1 and LUN-2, the following issues will arise: Figure 1In the four scenarios shown, (a) and (b) the data stored in the two mirrored LUNs is still synchronized, and the server reads the same data from both LUNs. In (c) and (d) the data stored in the two mirrored LUNs is not synchronized, causing the server to read different data from the two LUNs, thus losing the backup function.

[0036] To solve the above problems, existing technologies unify the processing of these two write commands into one, for example, the write commands can be processed on storage device A. The specific steps are as follows:

[0037] 1. When storage device A receives a write command (the write command indicates that data A should be written), it first processes the write command to write data A to LUN-1, then writes data A to LUN-2, and finally returns a success message to the server.

[0038] 2. Storage device B receives a write command (the write command indicates that data B should be written), and storage device B forwards the write command to storage device A. Storage device A then writes data B to LUN-1.

[0039] 3. Storage device A notifies storage device B to write data B, or forwards the write command to storage device B again. Storage device B writes data B to LUN-2 and notifies storage device A that the write is complete.

[0040] 4. Storage device A notifies storage device B that both local write and image write are complete.

[0041] 5. Storage device B returned a success message to the server.

[0042] As described above, the write command processing requires multiple communications between storage device A and storage device B, and most steps can only be executed sequentially and cannot be processed in parallel, resulting in significant command processing latency and performance degradation. This generates substantial processing latency, impacting the response speed of the dual-active storage system in handling I / O requests.

[0043] In order to solve the above problems, this application provides a data writing method, apparatus, electronic device and readable storage medium.

[0044] The method provided in the embodiments of this application is described below:

[0045] See Figure 2 , Figure 2 This is a flowchart illustrating the data writing method provided in an embodiment of this application. The method is applied to either storage device in a dual-active storage system, where the storage system includes two storage devices.

[0046] It should be noted that, for any storage device in a dual-active storage system, when the storage device receives a write command for the local logical unit number LUN from an external server, the storage device is used as the source storage device for this storage, and the LUN is determined as the source LUN. The other storage device is used as the mirror storage device for this storage, and the LUN in the other storage device is used as the mirror LUN.

[0047] like Figure 2 As shown, the process includes the following steps:

[0048] S201, when determining that this device is the source storage device, determine whether the write address indicated by the received write command is occupied at the current moment.

[0049] In this embodiment, if the write address indicated by the command is currently occupied, it indicates that another write command is writing to that write address. This write command writing to that write address is called the first conflicting write command that conflicts with the received write command. The first conflicting write command is an indication when the peer storage device performs mirrored data writing as a mirrored storage device (for ease of description, it can be simply referred to as a mirrored write command).

[0050] At this point, if both the received write command and the first conflicting write command are executed, it cannot be guaranteed which data will be written last (i.e., a conflict occurs). Figure 1 (In cases (c) and (d)), therefore, to prevent this situation, when the execution result of step S201 is yes, the write command is not executed, and a write error instruction is returned to the server.

[0051] If the result of S201 is negative, indicating that there is no first conflicting write command that conflicts with the received write command, then proceed to step S202. This avoids data inconsistency in the dual-active storage system caused by write conflicts.

[0052] In this embodiment, the determination in S201 whether the write address indicated by the received write command is occupied at the current moment will be explained in detail later, and will not be repeated here.

[0053] 202. The data to be written in the write command is stored in the source LUN at the write address indicated by the write command, and an instruction is sent to the mirror storage device of this device so that the mirror device writes the data according to the write address indicated by the instruction.

[0054] 203. When it is determined that this device is a mirror storage device, receive an instruction from the source storage device and determine whether the write address indicated by the instruction is occupied at the current time.

[0055] In this embodiment, when the local device receives an instruction sent by the peer device (i.e., the mirror write command described above), it can determine that the local device is the mirror storage device of the peer device. After receiving the mirror write command, it is determined whether the write address indicated by the mirror write command is currently occupied. If the write address indicated by the mirror write command is occupied, it indicates that another write command is writing to that write address. This write command writing to that write address is called the second conflicting write command that conflicts with the mirror write command. The second conflicting write command is the write command received from the server when the peer storage device is acting as the source storage device.

[0056] If the result of S203 is negative, it indicates that there is no second conflicting write command that conflicts with the mirror write command, and then the following step S204 is executed. This prevents data inconsistency issues in the dual-active storage system caused by write conflicts.

[0057] If the execution result of S203 is yes, it indicates that there is a second conflicting write command that conflicts with the mirror write command. At this time, control is required to avoid the dual-active storage system from becoming out of sync due to the write conflict. That is, the following steps S205 and S206 need to be executed.

[0058] In this embodiment, the determination in S203 whether the write address indicated by the instruction is occupied at the current moment will be explained in detail later, and will not be repeated here.

[0059] S204 then stores the data to be written in the LUN indicated by the instruction to the write address indicated by the instruction.

[0060] S205, when the write address indicated by the instruction is fully occupied at the current time, select the target data that meets the set conditions from the data occupying the write address and the data of the overlapping area address to be written in the instruction. After the write command occupying the write address is processed, execute the write operation so that the target data is written to the write address indicated by the instruction.

[0061] In this embodiment, if the write address indicated by the instruction is fully occupied at the current moment, it means that the range of all write addresses of the second conflicting write command currently occupying that write address is greater than or equal to the write address indicated by the instruction. Here, the data occupying the write address refers to part or all of the data in the second conflicting write command. When the range of all write addresses of the second conflicting write command is equal to the write address indicated by the instruction, the data occupying the write address is all the data in the second conflicting write command. When the range of all write addresses of the second conflicting write command is greater than or equal to the write address indicated by the instruction, the data occupying the write address is part of the data in the second conflicting write command. Here, part or all of the data may be being written or may be waiting to be written. The data to be written in the occupied overlapping area address in the instruction is all the data to be written indicated by the instruction.

[0062] For example, if the write address range of the second conflicting write command is 1K-4K, and the write address range of the write command is also 1K-4K, then the target data is directly selected from all the data in the second conflicting write command and all the data in the write command. If the write address range of the second conflicting write command is 1K-5K, and the write address range of the write command is also 1K-4K, then the target data is directly selected from the data corresponding to 1K-4K in the second conflicting write command and all the data in the write command.

[0063] S206, when the write address indicated by the instruction is partially occupied at the current time, select target data that meets the set conditions from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction. After the write command occupying the write address is processed, execute the write operation so that the target data is written to the overlapping area address, and the data to be written to the unoccupied non-overlapping area address in the instruction is written to the non-overlapping area address.

[0064] In this embodiment, the write address indicated by the instruction is currently partially occupied.

[0065] Here, the data occupying the write address refers to the portion of the overlapping region address that is being written or to be written in the second conflict write command. The data to be written to the occupied overlapping region address in this instruction is the data to be written to the overlapping region address indicated in this instruction.

[0066] For example, if the write address range of the second conflicting write command is 1K-4K and the write address range of the write command is 2K-5K, then the target data is directly selected from the data in the 2K-5K range corresponding to the second conflicting write command and the data in the 2K-5K range corresponding to the write command.

[0067] Through the control of steps S205 and S206 described above, it can be ensured that the data ultimately written to the mirrored storage device is definite. This avoids the following situation in the prior art: because it is impossible to know which of the two data sets was overwritten, the final write result cannot be definitively determined. Thus, when both devices in a dual-active storage system act as mirrored storage devices and execute the above procedure, the final write result of both storage devices is definite, enabling the data stored in the two mirrored LUNs to be synchronized.

[0068] In this embodiment, the specific method for selecting target data and how to perform the write operation after selecting target data will be explained later, and will not be repeated here.

[0069] This concludes the process. Figure 2 The process is shown below.

[0070] pass Figure 2 As shown in the process, in this embodiment of the application, when the device is the source storage device, the data to be written is written to the write address indicated by the write command only when the write address indicated by the received write command is not occupied by other write commands at the current moment, and an instruction is sent to the mirror storage device of the device so that the mirror device writes data according to the write address indicated by the instruction. This method can reduce the probability of write conflicts and thus alleviate the problem of data asynchrony in the dual-active storage system caused by write conflicts.

[0071] Furthermore, in this embodiment, when it is determined that this device is a mirrored storage device, if the write address indicated by the indication from the source storage device is currently occupied, it is further determined whether the write address indicated by the indication is fully or partially occupied at the current moment. If it is fully occupied, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication. After the write command occupying the write address is processed, a write operation is performed to write the target data to the write address indicated by the indication. If it is partially occupied, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication. After the write command occupying the write address is processed, a write operation is performed to write the target data to the overlapping area address, and the data to be written to the unoccupied non-overlapping area address in the indication is written to the non-overlapping area address.

[0072] In this way, it can be guaranteed that the data ultimately written to the mirrored storage device is definite, which avoids the problem in existing technologies where it is impossible to know which data was overwritten, thus making it impossible to know the final write result. Based on this, when the two devices in a dual-active storage system each act as mirrored storage devices, they are executed in the above manner, and the final write result of both storage devices is definite, which enables the data stored in the two mirrored LUNs to be synchronized.

[0073] Furthermore, in this embodiment, there is no need to forward write commands received by two storage devices to one storage device for queuing processing, as is done in the previous technology. This reduces the latency caused by repeated forwarding, saves the time for processing write commands, and ensures the response speed of the dual-active storage system in handling IO requests.

[0074] The following section elaborates on the determination in S201 of whether the write address indicated by the received write command is currently occupied:

[0075] As an example, after the source storage device stores the data to be written in the write command to the write address indicated by the write command in the source LUN, it records the write address indicated by the write command in the execution list of the source storage device.

[0076] Based on this, the execution list of the source storage device records the write addresses of the write commands being executed. Therefore, after the source device receives a write command, it only needs to determine whether there is a write address in the local execution list that overlaps with the write address indicated by the write command. If so, it is determined that the write address indicated by the received write command is currently occupied by other write commands; if not, it is determined that the write address indicated by the received write command is not currently occupied by other write commands.

[0077] The above provides a detailed explanation of whether the write address indicated by the received write command is currently occupied in step S201.

[0078] The following section elaborates on the determination in S203 above regarding whether the write address indicated by the instruction is currently occupied:

[0079] As an example, after the indicated data to be written is stored in the mirrored LUN at the write address indicated by the instruction, the write address indicated by the instruction is recorded in the execution list of the mirrored storage device.

[0080] Based on this, the execution list of the mirrored storage device records the write addresses of the write commands being executed. After receiving the instruction from the source device, it is determined whether there is a write address in the local execution list that overlaps with the write address indicated by the instruction. If so, it is determined that the write address indicated by the instruction is currently occupied by other write commands; if not, it is determined that the write address indicated by the instruction is not currently occupied by other write commands.

[0081] The above provides a detailed explanation of the determination in S203 of whether the write address indicated by the instruction is currently occupied.

[0082] The following section elaborates on how to determine the target data and how to perform the write operation after determining the target data:

[0083] See Figure 3 , Figure 3 This is a schematic diagram of the process for determining target data provided in an embodiment of this application.

[0084] like Figure 3 As shown, the process may include the following steps:

[0085] S301, the first encoded data and the second encoded data are obtained from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction, respectively.

[0086] In this embodiment, the data occupying the write address and the data to be written to the occupied overlapping area address in the indication are encoded in the same encoding method; the first encoded data and the second encoded data are the first different encoded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication.

[0087] S302, compare the size of the first encoded data and the second encoded data.

[0088] In this embodiment, the first encoded data and the second encoded data are compared according to encoding rules. For example, the size is compared according to the encoding rules of ASCII code.

[0089] S303, if the sizes of the first encoded data and the second encoded data are not equal, the data from which the encoded data that meets the specified size requirement in the first encoded data and the second encoded data originates shall be used as the target data.

[0090] In this embodiment, meeting the specified requirement means either larger or smaller encoded data. Since the main purpose is to determine which data should ultimately be written to the overlapping address region, it is acceptable to use the same specified requirement interface in the dual-active storage system, that is, to always choose either larger or smaller encoded data.

[0091] Whichever encoded data in the first or second encoded data is determined to meet the specified size requirement, the data from which it originates will prevail in the arbitration.

[0092] S304, if the sizes of the first encoded data and the second encoded data are equal, the data occupying the write address is used as the target data.

[0093] If it is impossible to determine which one wins, the data being written locally on the mirrored storage device will win.

[0094] As an example, if the write address indicated by the instruction is fully occupied at the current moment, and the target data comes from the data to be written in the occupied overlapping area address in the instruction (i.e., the mirror write command wins), then after the write command occupying the write address is processed, the data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction, thereby completing the mirror storage of the mirror storage device.

[0095] As another embodiment, if the write address indicated by the instruction is fully occupied at the current moment, and the target data comes from the data occupying the write address (i.e., the second conflicting write command wins), then after the write command occupying the write address is processed, the instruction received from the source storage device is prohibited from being executed, thereby completing the mirror storage of the mirror storage device.

[0096] As another embodiment, when the write address indicated by the instruction is partially occupied at the current moment, if the target data comes from the data to be written to the occupied overlapping area address in the instruction (i.e., the mirror write command wins), then after the write command occupying the write address is processed, the data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction, thereby completing the mirror storage of the mirror storage device.

[0097] As another embodiment, when the write address indicated by the instruction is partially occupied at the current moment, if the target data comes from the data occupying the write address (i.e., the second conflicting write command wins), after the write command occupying the write address is processed, the data to be written to the unoccupied non-overlapping area address in the instruction is written to the non-overlapping area address, thereby completing the mirror storage of the mirror storage device.

[0098] The above provides a detailed explanation of how to determine the target data and how to perform the write operation after determining the target data.

[0099] To illustrate the method provided in this application in more detail, the solution provided in this application will be described more specifically below by way of specific embodiments.

[0100] In this embodiment, for ease of description, the terms source storage device, mirror storage device, source LUN, mirror LUN, write command, mirror write command, first conflict write command, and second conflict write command are used to illustrate the concept.

[0101] The method includes the following steps:

[0102] 1. The source storage device receives a write command for the source LUN from an external server. It determines whether there is a first conflicting write command that conflicts with the write command by checking whether there is a write address with an overlapping area address among the write addresses in the local execution list.

[0103] If yes, proceed to step 2 below; otherwise, proceed to step 3 below.

[0104] 2. Do not execute the write command, and return a write error instruction to the server.

[0105] 3. Store the data to be written in the write command to the write address indicated by the write command in the source LUN, send an instruction to the mirror storage device to perform mirror storage, and record the write address indicated by the write command in the execution list of the source storage device.

[0106] 4. After receiving the mirror write command, the mirror storage device determines whether there is a second conflicting write command that conflicts with the mirror write command by checking whether there is a write address with an overlapping area address in each write address in the local execution list.

[0107] If not, proceed to step 5 below; if yes, proceed to step 6 below.

[0108] 5. Then, the data to be written in the mirror write command is stored in the mirror LUN at the write address indicated by the mirror write command, the write address indicated by the mirror write command is recorded in the execution list of the mirror storage device, and a mirror write success message is returned to the source storage device.

[0109] 6. Obtain the address of the overlapping region between the write address indicated by the mirror write command and the write address indicated by the second conflict write command. Obtain the first different encoded data (i.e., the first encoded data and the second encoded data) from the data corresponding to the overlapping region of the mirror write command and the data corresponding to the overlapping region of the second conflict write command. Compare the first encoded data and the second encoded data to determine which of the mirror write command and the second conflict write command wins the arbitration.

[0110] If the mirror write command wins, proceed to step 7 below; if the second conflict write command wins, proceed to step 8 below.

[0111] 7. After the second conflict write command is processed, the data to be written in the mirror write command is stored in the write address indicated by the mirror write command in the mirror LUN, and a mirror write success message is returned to the source storage device.

[0112] 8. When the write addresses of the mirror write command and the second conflicting write command are completely overlapping, the mirror write command is prohibited from being executed after the second conflicting write command is processed; when the write addresses of the mirror write command and the second conflicting write command are partially overlapping, after the second conflicting write command is processed, only the data to be written to the non-overlapping area address in the mirror write command is written to the non-overlapping area address.

[0113] After completing step 7 or 8, proceed to step 9 below.

[0114] 9. Return a write conflict message to the source storage device and delete the write address record of the mirror write command and the second conflicting write command from the execution list.

[0115] 10. After both the source storage device and the mirror storage device have completed the write operation, if the source storage device determines that both the local and mirror storage devices have been successfully written, it returns a write success message to the server; if the source storage device determines that the local write operation was successful but the mirror write operation is conflicting, it also returns a write success message to the server.

[0116] The above completes one write operation for the dual-active storage system. Subsequently, when an external server issues a read command, the receiving end directly reads the data and returns it to the server.

[0117] This concludes the description of the method provided in this embodiment. The apparatus provided in this application embodiment will now be described:

[0118] See Figure 4 , Figure 4This is a schematic diagram of the device provided in an embodiment of this application. The device is applied to any storage device in a dual-active storage system, which includes two storage devices. Specifically, for any storage device in the dual-active storage system, when the storage device receives a write command for a local logical unit number (LUN) from an external server, that storage device is used as the source storage device for this write operation, and the LUN is determined as the source LUN. The other storage device is used as the mirror storage device for this write operation, and the LUN in the other storage device is used as the mirror LUN. Figure 4 As shown, the device 400 includes: a first judgment module 401, a first execution module 402, a second judgment module 403, and a second execution module 404.

[0119] This device is applied to any storage device in a dual-active storage system, which includes two storage devices. Specifically, for any storage device in the dual-active storage system, when that storage device receives a write command for a local logical unit number (LUN) from an external server, that storage device is designated as the source storage device for this write operation, and the LUN is identified as the source LUN. The other storage device is designated as the mirror storage device for this write operation, and the LUN in the other storage device is identified as the mirror LUN. The device includes:

[0120] The first judgment module 401 is used to determine whether the write address indicated by the received write command is occupied at the current moment when the device is determined to be the source storage device.

[0121] The first execution module 402 is configured to, if not, store the data to be written in the write command in the source LUN at the write address indicated by the write command, and send an instruction to the mirror storage device of this device so that the mirror device writes data according to the write address indicated by the instruction;

[0122] The second judgment module 403 is used to receive an indication from the source storage device when it is determined that this device is a mirror storage device, and to determine whether the write address indicated by the indication is occupied at the current time.

[0123] The second execution module 404 is configured to, if not, store the data to be written in the instruction in the image LUN at the write address indicated by the instruction;

[0124] If so, when the write address indicated by the instruction is fully occupied at the current moment, select the target data that meets the set conditions from the data occupying the write address and the data of the overlapping area address to be written in the instruction; and after the write command that is currently occupying the write address is processed, perform the write operation so that the target data is written to the write address indicated by the instruction.

[0125] When the write address indicated by the instruction is partially occupied at the current time, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction; and after the write command occupying the write address is processed, the write operation is performed so that the target data is written to the overlapping area address, and the data to be written to the unoccupied non-overlapping area address in the instruction is written to the non-overlapping area address.

[0126] As an example, selecting target data that meets the set conditions includes:

[0127] First encoded data and second encoded data are obtained from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication, respectively; wherein the data occupying the write address and the data to be written to the occupied overlapping area address in the indication are encoded in the same encoding method; the first encoded data and the second encoded data are the first different encoded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication.

[0128] Compare the size of the first encoded data and the second encoded data;

[0129] If the sizes of the first coded data and the second coded data are not equal, the data from which the coded data that meets the specified size requirement in the first coded data and the second coded data originates shall be used as the target data; meeting the specified requirement means either the larger coded data or the smaller coded data.

[0130] If the sizes of the first encoded data and the second encoded data are equal, the data occupying the write address will be used as the target data.

[0131] As an example, when the target data comes from the data to be written to the occupied overlapping region address in the indication, the write operation includes: storing the data to be written in the indication to the write address indicated by the indication in the mirror LUN;

[0132] When the target data comes from data occupying the write address, the write operation includes:

[0133] If the write address indicated by the instruction is fully occupied at the current moment, then the execution of the write instruction is prohibited;

[0134] If the write address indicated by the instruction is partially occupied at the current time, then the data to be written to the unoccupied non-overlapping region address in the instruction will be written to the non-overlapping region address.

[0135] As an example, after determining whether the write address indicated by the received write command is currently occupied, the first execution module is further specifically used for:

[0136] If so, the write command is not executed, and a write error instruction is returned to the server.

[0137] As one example, determining whether the write address indicated by the received write command is currently occupied includes:

[0138] Determine if any of the write addresses in the local execution list have an overlapping region with the write address indicated by the write command; if so, determine if the write address indicated by the received write command is currently occupied by another write command; if not, determine if the write address indicated by the received write command is currently not occupied by another write command.

[0139] Determining whether the write address indicated by the instruction is currently occupied includes:

[0140] Determine if any of the write addresses in the local execution list have an overlapping region with the write address indicated by the instruction; if so, determine that the write address indicated by the instruction is currently occupied by other write commands; if not, determine that the write address indicated by the instruction is not currently occupied by other write commands.

[0141] As an example, after storing the data to be written in the write command to the write address indicated by the write command in the source LUN, the first execution module is further configured to:

[0142] The write address indicated by the write command is recorded in the execution list of the source storage device so that when the source storage device receives a write command later, it can determine whether the write address indicated by the write command is occupied at the current moment.

[0143] After storing the data to be written in the mirror write command into the write address indicated by the mirror write command in the source LUN, the second execution module is further configured to:

[0144] The write address indicated by the instruction is recorded in the execution list of the mirrored storage device so that when the mirrored storage device subsequently receives a write command, it can determine whether the write address indicated by the write command is currently occupied.

[0145] As an example, after performing the write operation, the second execution module is further used to:

[0146] Remove write addresses that have overlapping regions with the write address indicated by the instruction from the execution list of the mirrored storage device.

[0147] This concludes the process. Figure 4 Structural description of the device shown.

[0148] Please see Figure 5 , Figure 5 This is a structural diagram of an electronic device provided in an embodiment of this application. Figure 5 As shown, the hardware structure may include: a processor and a machine-readable storage medium, the machine-readable storage medium storing machine-executable instructions that can be executed by the processor; the processor is used to execute the machine-executable instructions to implement the method disclosed in the above example of this application.

[0149] Based on the same application concept as the above method, this application embodiment also provides a machine-readable storage medium storing a plurality of computer instructions, which, when executed by a processor, can implement the method disclosed in the above examples of this application.

[0150] For example, the aforementioned machine-readable storage medium can be any electronic, magnetic, optical, or other physical storage device that can contain or store information such as executable instructions, data, etc. For instance, machine-readable storage media can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drives (such as hard disk drives), solid-state drives, any type of storage disk (such as optical discs, DVDs, etc.), or similar storage media, or combinations thereof.

[0151] The above description is merely an embodiment of this application and is not intended to limit the scope of this application. Various modifications and variations can be made to this application by those skilled in the art. Any modifications, equivalent substitutions, improvements, etc., made within the spirit and principles of this application should be included within the scope of the claims of this application.

Claims

1. A data writing method, characterized in that, This method is applied to any storage device in a dual-active storage system, wherein the storage system includes two storage devices; wherein, for any storage device in the dual-active storage system, when the storage device receives a write command for a local logical unit number (LUN) from an external server, the storage device is used as the source storage device for this write operation, and the LUN is determined as the source LUN; the other storage device is used as the mirror storage device for this write operation, and the LUN in the other storage device is used as the mirror LUN; the method includes: When determining that this device is the source storage device, it checks whether the write address indicated by the received write command is currently occupied; If not, the data to be written in the write command is stored in the write address indicated by the write command in the source LUN, and an instruction is sent to the mirror storage device of this device so that the mirror storage device writes the data according to the write address indicated by the instruction; When it is determined that this device is a mirrored storage device, it receives an instruction from the source storage device and determines whether the write address indicated by the instruction is occupied at the current moment; If not, the data to be written, as indicated by the instruction, is stored in the mirrored LUN at the write address indicated by the instruction. If so, when the write address indicated by the instruction is fully occupied at the current moment, select target data that meets the set conditions from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction; and after the write command currently occupying the write address is processed, if the target data comes from the data occupying the write address, then the instruction received from the source storage device is prohibited from being executed; if the target data comes from the data to be written to the occupied overlapping area address in the instruction, then the data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction. When the write address indicated by the instruction is partially occupied at the current time, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping region address in the instruction; and after the write command occupying the write address is processed, if the target data comes from the data occupying the write address, the data to be written to the unoccupied non-overlapping region address in the instruction is written to the non-overlapping region address; if the target data comes from the data to be written to the occupied overlapping region address in the instruction, the data to be written in the instruction is stored in the write address indicated by the instruction in the mirror LUN.

2. The method according to claim 1, characterized in that, The selected target data that meets the set conditions includes: First encoded data and second encoded data are obtained from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication, respectively; wherein the data occupying the write address and the data to be written to the occupied overlapping area address in the indication are encoded in the same encoding method; the first encoded data and the second encoded data are the first different encoded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication. Compare the sizes of the first encoded data and the second encoded data; When the sizes of the first encoded data and the second encoded data are not equal, the data from which the encoded data in the first encoded data and the second encoded data that meets the specified size requirement is taken as the target data; meeting the specified requirement means either larger encoded data or smaller encoded data. If the first encoded data and the second encoded data are of equal size, the data occupying the write address is used as the target data.

3. The method according to claim 1, characterized in that, After determining whether the write address indicated by the received write command is currently occupied, the method further includes: If so, the write command is not executed, and a write error instruction is returned to the server.

4. The method according to claim 1, characterized in that, The determination of whether the write address indicated by the received write command is currently occupied includes: Determine whether there is a write address in the local execution list that overlaps with the write address indicated by the write command; if so, determine that the write address indicated by the received write command is currently occupied by other write commands; if not, determine that the write address indicated by the received write command is not currently occupied by other write commands. The determination of whether the write address indicated by the instruction is currently occupied includes: Determine if any of the write addresses in the local execution list have an overlapping region with the write address indicated by the instruction; if so, determine that the write address indicated by the instruction is currently occupied by other write commands; if not, determine that the write address indicated by the instruction is not currently occupied by other write commands.

5. The method according to claim 4, characterized in that, After storing the data to be written in the write command to the write address indicated by the write command in the source LUN, the method further includes: The write address indicated by the write command is recorded in the execution list of the source storage device so as to determine whether the write address indicated by the write command is occupied at the current moment when the source storage device subsequently receives a write command. After storing the data to be written indicated by the instruction into the write address indicated by the instruction in the mirrored LUN, the method further includes: The write address indicated by the instruction is recorded in the execution list of the mirrored storage device so as to determine whether the write address indicated by the write command is occupied at the current moment when the mirrored storage device subsequently receives a write command.

6. The method according to claim 5, characterized in that, After completing any of the following steps: The instruction received from the source storage device is prohibited from being executed; The data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction; Write the data to be written to the unoccupied, non-overlapping region address in the instruction to the non-overlapping region address; The method also includes: Remove the write address indicated by the instruction and any write addresses in the execution list of the mirrored storage device that have overlapping regions with the write address indicated by the instruction from the execution list of the mirrored storage device.

7. A data writing device, characterized in that, This device is applied to any storage device in a dual-active storage system, wherein the storage system includes two storage devices; wherein, for any storage device in the dual-active storage system, when the storage device receives a write command for a local logical unit number (LUN) from an external server, the storage device is used as the source storage device for this write operation, and the LUN is determined as the source LUN; the other storage device is used as the mirror storage device for this write operation, and the LUN in the other storage device is used as the mirror LUN; the device includes: The first judgment module is used to determine whether the write address indicated by the received write command is occupied at the current moment when the device is determined to be the source storage device. The first execution module is configured to, if not, store the data to be written in the write command in the source LUN at the write address indicated by the write command, and send an instruction to the mirror storage device of this device so that the mirror storage device writes data according to the write address indicated by the instruction; The second judgment module is used to receive an indication from the source storage device when it is determined that this device is a mirror storage device, and to determine whether the write address indicated by the indication is occupied at the current time. The second execution module is configured to, if not, store the data to be written in the instruction to the write address indicated by the instruction in the mirror LUN; If so, when the write address indicated by the instruction is fully occupied at the current moment, select target data that meets the set conditions from the data occupying the write address and the data to be written to the occupied overlapping area address in the instruction; and after the write command currently occupying the write address is processed, if the target data comes from the data occupying the write address, then the instruction received from the source storage device is prohibited from being executed; if the target data comes from the data to be written to the occupied overlapping area address in the instruction, then the data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction. When the write address indicated by the instruction is partially occupied at the current time, target data that meets the set conditions is selected from the data occupying the write address and the data to be written to the occupied overlapping region address in the instruction; and after the write command occupying the write address is processed, if the target data comes from the data occupying the write address, the data to be written to the unoccupied non-overlapping region address in the instruction is written to the non-overlapping region address; if the target data comes from the data to be written to the occupied overlapping region address in the instruction, the data to be written in the instruction is stored in the write address indicated by the instruction in the mirror LUN.

8. The apparatus according to claim 7, characterized in that, The selected target data that meets the set conditions includes: First encoded data and second encoded data are obtained from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication, respectively; wherein the data occupying the write address and the data to be written to the occupied overlapping area address in the indication are encoded in the same encoding method; the first encoded data and the second encoded data are the first different encoded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication. Compare the sizes of the first encoded data and the second encoded data; When the sizes of the first encoded data and the second encoded data are not equal, the data from which the encoded data in the first encoded data and the second encoded data that meets the specified size requirement is taken as the target data; meeting the specified requirement means either larger encoded data or smaller encoded data. When the first encoded data and the second encoded data are of equal size, the data occupying the write address is used as the target data; And / or, After determining whether the write address indicated by the received write command is currently occupied, the first execution module is further specifically used for: If so, the write command is not executed, and a write error instruction is returned to the server; And / or, The determination of whether the write address indicated by the received write command is currently occupied includes: Determine whether there is a write address in the local execution list that overlaps with the write address indicated by the write command; if so, determine that the write address indicated by the received write command is currently occupied by other write commands; if not, determine that the write address indicated by the received write command is not currently occupied by other write commands. The determination of whether the write address indicated by the instruction is currently occupied includes: If there is a write address in the local execution list that overlaps with the write address indicated by the instruction, then it is determined that the write address indicated by the instruction is currently occupied by other write commands; otherwise, it is determined that the write address indicated by the instruction is not currently occupied by other write commands. And / or, After storing the data to be written in the write command to the write address indicated by the write command in the source LUN, the first execution module is further configured to: The write address indicated by the write command is recorded in the execution list of the source storage device so as to determine whether the write address indicated by the write command is occupied at the current moment when the source storage device subsequently receives a write command. After storing the data to be written as indicated by the instruction into the write address indicated by the instruction in the mirror LUN, the second execution module is further configured to: The write address indicated by the instruction is recorded in the execution list of the mirrored storage device so as to determine whether the write address indicated by the write command is occupied at the current moment when the mirrored storage device subsequently receives a write command. And / or, After completing any of the following steps: The instruction received from the source storage device is prohibited from being executed; The data to be written in the instruction is stored in the mirror LUN at the write address indicated by the instruction; The data to be written to the unoccupied, non-overlapping region address in the instruction is written to the non-overlapping region address; the second execution module is further configured to: Remove the write address indicated by the instruction and any write addresses in the execution list of the mirrored storage device that have overlapping regions with the write address indicated by the instruction from the execution list of the mirrored storage device.

9. An electronic device, characterized in that, The electronic device includes: Processor; and A computer-readable storage medium storing computer program instructions that, when executed by the processor, cause the processor to perform the steps of the method as described in any one of claims 1 to 6.

10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer program instructions that, when executed by a processor, cause the processor to perform the steps of the method as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • Write-in request processing method, apparatus and device

    CN106843749A

  • Method and device for processing writing conflict

    CN108762668A