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

By judging the usage of the write address in the storage device of the dual-live storage system and selecting the target data for writing, the data is not synchronized due to write conflicts is solved, and data synchronization and efficient IO response speed are achieved.

CN119620941AActive Publication Date: 2025-03-14MACROSAN TECH
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202411692479.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-22
Publication Date
2025-03-14
Estimated Expiration
2044-11-22

AI Technical Summary

Technical Problem

In a dual-live storage system, external servers may issue write commands for the same address to two storage devices, resulting in write conflicts, which in turn makes the data stored in the two mirrored LUNs unable to be synchronized and loses the backup function.

Method used

By determining in the storage device whether the write address indicated by the write command is occupied, if it is not occupied, the data to be written is stored to the corresponding LUN, and an instruction is sent to the mirror storage device for data writing. If the write address is occupied, the target data that meets the set conditions is selected and the write operation is performed after the write conflict is resolved.

Benefits of technology

It reduces the probability of write conflicts, ensures the synchronization of data in the live-action storage system, avoids the data out-of-synchronization problem caused by write conflicts, reduces processing delays, and improves the response speed of IO requests.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119620941A_ABST
    Figure CN119620941A_ABST
Patent Text Reader

Abstract

The invention provides a data writing method and device, electronic equipment and a readable storage medium. According to the method and the device, the problem of data asynchronization in the active-active storage system caused by writing conflicts can be solved, and writing commands received by two storage devices do not need to be forwarded to one storage device for queuing processing in the prior art, so that the delay caused by repeated forwarding is reduced, the writing command processing time is saved, and the writing efficiency is improved. And the response speed of the dual-active storage system for processing the IO request is ensured.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data storage, and in particular to a data writing method, device, electronic device and readable storage medium. Background Art

[0002] Active-active storage synchronizes the data of two logical unit numbers (LUNs) in two storage devices through data mirroring, so that when a LUN in one storage device fails, the other LUN can be used to recover data, thereby ensuring the reliability of the storage system. However, in special cases, two external servers may send write commands for the same address to two storage devices respectively. For any storage device, a write conflict will occur when it executes the write command sent by the server and when it performs mirror storage, which makes it impossible to synchronize the data stored in the two mirrored LUNs, so that the data read from the two LUNs is different, and the backup function is lost.

[0003] In the prior art, the write conflict problem is solved by forwarding the write command received on one of the two storage devices to the other storage device for processing by the other storage device. For example, storage device 2 forwards all the received write commands to storage device 1, and storage device 1 sorts the write commands received by itself and the write commands received from storage device 2 and processes them in sequence, thereby solving the problem of data asynchrony in the active-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 delays and affect the response speed of the active-active storage system in processing input / output (IO) requests. Summary of the invention

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

[0006] The embodiment of the present application provides a data writing method, which is applied to any storage device in an active-active storage system, wherein the storage system includes two storage devices; wherein, for any storage device in the active-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 a source storage device for current storage, the LUN is determined as a source LUN, another storage device is used as a mirror storage device for current storage, and the LUN in the other storage device is used as a mirror LUN; the method includes:

[0007] When determining that the device is a source storage device, determining whether the write address indicated by the received write command is occupied at the current moment;

[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 the device so that the mirror device writes the data according to the write address indicated by the instruction;

[0009] When determining that the device is a mirror storage device, receiving an instruction from the source storage device, and determining whether the write address indicated by the instruction is occupied at the current moment;

[0010] If not, storing the data to be written indicated by the indication to the write address indicated by the indication in the mirror LUN;

[0011] If yes, when the write address indicated by the indication is fully occupied at the current moment, select the target data that meets the set condition from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, perform a write operation so that the target data is written to the write address indicated by the indication;

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

[0013] The embodiment of the present application further provides a data writing device, which is applied to any storage device in an active-active storage system, and the storage system includes two storage devices; wherein, for any storage device in the active-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 a source storage device for this storage, the LUN is determined as the source LUN, another storage device is used as a mirror storage device for this storage, and the LUN in the other storage device is used as a mirror LUN; the device includes:

[0014] A first judgment module, for judging whether the write address indicated by the received write command is occupied at the current moment when the device is determined to be a source storage device;

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

[0016] A second judgment module is used to receive an instruction from a source storage device when determining that the device is a mirror storage device, and to judge whether the write address indicated by the instruction is occupied at the current moment;

[0017] A second execution module, configured to, if no, store the to-be-written data indicated by the indication to the write address indicated by the indication in the mirror LUN;

[0018] If yes, when the write address indicated by the indication is currently occupied, target data satisfying the set condition is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, a write operation is performed so that the target data is written to the write address indicated by the indication;

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

[0020] An embodiment of the present application also provides an electronic device, including: a processor and a memory for storing computer program instructions, and when the computer program instructions are executed by the processor, the processor executes the steps of the above method.

[0021] An embodiment of the present application also provides a machine-readable storage medium, which stores computer program instructions. When the computer program instructions are executed, the steps of the above method can be implemented.

[0022] It can be seen from the above technical solution that in this embodiment, when this device is a 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 this 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 alleviate the problem of data asynchrony in the active-active storage system caused by write conflicts.

[0023] Further, in this embodiment, when it is determined that the device is a mirror storage device, when the write address indicated by the indication from the source storage device is occupied at the current moment, it is further determined whether the write address indicated by the indication is fully occupied or partially occupied at the current moment. If it is fully occupied, the 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, 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 write address indicated by the indication. If it is partially occupied, the 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, 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 indication is written to the non-overlapping area address.

[0024] In this way, it can be ensured that the data written to the mirror storage device is determined, which avoids the problem in the prior art that the final writing result cannot be determined because it is not clear which of the two data is overwritten by which. Based on this, when the two devices in the active-active storage system are each used as mirror storage devices, they are executed in the above manner, and the final writing results of the two storage devices are clear, which enables the data stored in the two mirrored LUNs to be synchronized.

[0025] Furthermore, in the embodiment of the present application, there is no need to forward the write commands received by the two storage devices to one storage device for queue processing as in the technology, which reduces the delay caused by repeated forwarding, saves the time for writing command processing, and ensures the response speed of the active-active storage system in processing IO requests. BRIEF DESCRIPTION OF THE DRAWINGS

[0026] Figure 1 An architecture diagram of a dual-active storage system provided in an embodiment of the present application;

[0027] Figure 2 A schematic diagram of a data writing method according to an embodiment of the present application;

[0028] Figure 3 A schematic diagram of a process for determining target data provided in an embodiment of the present application;

[0029] Figure 4 A schematic diagram of the structure of the device provided in the embodiment of the present application;

[0030] Figure 5 A schematic diagram of the hardware structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0031] In order to enable those skilled in the art to better understand the technical solutions provided by the embodiments of the present application and to make the above-mentioned purposes, features and advantages of the embodiments of the present application more obvious and understandable, the technical solutions in the embodiments of the present application are further described in detail below in conjunction with the accompanying drawings.

[0032] Before describing the method provided by this application, Figure 1 The active-active storage system shown in the figure elaborates on the write conflict problem existing in the prior art:

[0033] The so-called active-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. When a LUN in one of the storage devices fails, the other LUN can be used for data recovery to ensure the reliability of the storage system. In addition, the LUNs in the two storage devices can provide data access to the server at the same time.

[0034] See also Figure 1 , Figure 1 This is an architecture diagram of the active-active storage system provided in the embodiment of the present application. Figure 1 As shown, storage device A and storage device B form an active-active storage system, and 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 any of LUN-1 and LUN-2, the data needs to be mirrored to the other LUN at the same time to ensure data synchronization between the two LUNs. In this way, for an external server, both LUNs provide data access services to it, and if any of the LUNs fails, the business continuity of the external server can be guaranteed.

[0035] In special circumstances such as communication failure, server A and server B may issue write commands to mirrored LUN-1 and LUN-2 at the same time, and the write addresses may overlap (such as complete overlap or partial overlap). At this time, the write address of the write command received by LUN-1 from the external server and the write address that triggers LUN-1 to perform mirrored writing when LUN-2 executes the write command are in conflict, and a write conflict occurs. For a single LUN, two write commands to write data A and write data B are issued at the same time. Since it is uncertain which of the two write commands will be executed first, the order cannot be guaranteed, so the final storage result may be data A or data B. For LUN-1 and LUN-2, the following will be generated Figure 1In the four cases shown in (a) and (b), the data stored in the two mirrored LUNs are still synchronized, and the data read by the server from the two LUNs is still the same. In (c) and (d), the data stored in the two mirrored LUNs cannot be synchronized, so the data read by the server from the two LUNs is different, thus losing the backup function.

[0036] In order to solve the above problem, the prior art unifies the two write commands to be processed on one side. For example, the write commands can be unified to be processed on storage device A. The specific steps are as follows:

[0037] 1. Storage device A receives a write command (the write command indicates writing data A), and first processes the write command to write data A to LUN-1, then writes data A to LUN-2, and finally returns success to the server.

[0038] 2. Storage device B receives a write command (the write command indicates writing data B), and storage device B forwards the write command to storage device A, and storage device A 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 writing is complete.

[0040] 4. Storage device A notifies storage device B that both local writing and mirror writing are completed.

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

[0042] In the above, the write command processing process 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 a large command processing delay and performance degradation. This will generate a large amount of processing delay, affecting the response speed of the active-active storage system in processing IO requests.

[0043] Based on this, in order to solve the above problems, the embodiments of the present application provide a data writing method, device, electronic device and readable storage medium.

[0044] The method provided in the embodiment of the present application is described below:

[0045] See also Figure 2 , Figure 2 The present invention provides a flow chart of a data writing method provided in an embodiment of the present invention. The method is applied to any storage device in an active-active storage system, and the storage system includes two storage devices.

[0046] It should be noted that, for any storage device in the active-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 it is determined that the device is a source storage device, it is determined 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 the write address, and the write command currently writing to the write address is referred to as a first conflicting write command that conflicts with the received write command. The first conflicting write command is an indication of the peer storage device when the peer storage device uses the device as a mirror storage device to write mirror data (for ease of description, it may be referred to as a mirror write command).

[0050] At this time, if the received write command and the first conflicting write command are both executed, it is impossible to guarantee which data is written last (i.e., Figure 1 Therefore, in order 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 executing S201 is no, indicating that there is no first conflicting write command that conflicts with the received write command, then the following step S202 is executed. In this way, data asynchrony in the active-active storage system caused by write conflicts is avoided.

[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 described in detail later and will not be repeated here.

[0053] 202, store the data to be written in the write command to the write address indicated by the write command in the source LUN, and send an instruction to the mirror storage device of the local 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 the 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 moment.

[0055] In this embodiment, when the device receives an instruction sent by the peer device (i.e., the mirror write command described above), it can be determined that the device is a 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 occupied at the current moment. If the write address indicated by the mirror write command is occupied, it indicates that another write command is writing to the write address. The write command that is writing to the write address is called the second conflicting write command that conflicts with the mirror write command. The second conflicting write command is a write command received from the server when the peer storage device is used as a source storage device.

[0056] If the result of executing S203 is no, 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. In this way, the problem of data asynchrony in the active-active storage system caused by write conflicts will not occur.

[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 being 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 indication is occupied at the current moment will also be described in detail later and will not be repeated here.

[0059] S204: The data to be written indicated by the indication is stored in the write address indicated by the indication in the mirror LUN.

[0060] S205, when the write address indicated by the indication 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 occupied overlapping area address to be written in the indication, and after the write command occupying the write address is processed, perform the write operation so that the target data is written to the write address indicated by the indication.

[0061] In this embodiment, if the write address indicated by the indication is fully occupied at the current moment, it means that the range of all write addresses of the second conflicting write command occupying the write address is greater than or equal to the write address indicated by the indication. 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 indication, the data occupying the write address is all of 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 indication, the data occupying the write address is part of the data in the second conflicting write command. Here, part of the data or all of the data may be being written or may be to be written. The data to be written to the occupied overlapping area address in the indication is all of the data to be written indicated in the indication.

[0062] For example, 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. At this time, the target data is directly selected from all the data of the second conflicting write command and all the data of the write command. 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. At this time, the target data is directly selected from the data corresponding to 1K-4K in the second conflicting write command and all the data of the write command.

[0063] S206, when the write address indicated by the indication is partially occupied at the current moment, target data that meets the set conditions is selected from the data occupying the write address and the data to be written in the occupied overlapping area address in the indication, and after the write command occupying the write address is processed, a write operation is performed to make the target data written to the overlapping area address, and the data to be written in the unoccupied non-overlapping area address in the indication is written to the non-overlapping area address.

[0064] In this embodiment, the write address indicated by the indication is partially occupied at the current moment.

[0065] Here, the data occupying the write address refers to the data being written or to be written to the overlap area address in the second conflicting write command. The data to be written to the occupied overlap area address in the indication is the data to be written to the overlap area address indicated in the indication.

[0066] For example, the write address range of the second conflicting write command is 1K-4K, and the write address range of the write command is also 2K-5K. At this time, the target data is directly selected from the data on 2K-5K corresponding to the second conflicting write command and the data on 2K-5K corresponding to the write command.

[0067] Through the control of the above steps S205 and S206, it can be ensured that the data finally written into the mirror storage device is determined, which avoids the following situation in the prior art: because it is not clear which of the two data is overwritten by which, it is not possible to clearly know the final writing result. In this way, when the two devices in the active-active storage system are each used as mirror storage devices, they are executed in the above manner, and the final writing results of the two storage devices are clear, which enables the data stored in the two mirrored LUNs to be synchronized.

[0068] In this embodiment, how to select the target data and how to perform the write operation after selecting the target data will be described later and will not be described in detail here.

[0069] So far, completed Figure 2 The process shown.

[0070] pass Figure 2 The process shown, in the embodiment of the present application, in this embodiment, when the present device is a 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 present 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 can also alleviate the problem of data asynchrony in the active-active storage system caused by write conflicts.

[0071] Further, in this embodiment, when it is determined that the device is a mirror storage device, when the write address indicated by the indication from the source storage device is occupied at the current moment, it is further determined whether the write address indicated by the indication is fully occupied or partially occupied at the current moment. If it is fully occupied, the 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, 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 write address indicated by the indication. If it is partially occupied, the 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, 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 indication is written to the non-overlapping area address.

[0072] In this way, it can be ensured that the data written to the mirror storage device is determined, which avoids the problem in the prior art that the final writing result cannot be determined because it is not clear which of the two data is overwritten by which. Based on this, when the two devices in the active-active storage system are each used as mirror storage devices, they are executed in the above manner, and the final writing results of the two storage devices are clear, which enables the data stored in the two mirrored LUNs to be synchronized.

[0073] Furthermore, in the embodiment of the present application, there is no need to forward the write commands received by the two storage devices to one storage device for queue processing as in the technology, which reduces the delay caused by repeated forwarding, saves the time for writing command processing, and ensures the response speed of the active-active storage system in processing IO requests.

[0074] The following is a detailed description of the above step S201 of determining whether the write address indicated by the received write command is currently occupied:

[0075] As an embodiment, 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, the source storage device records the write address indicated by the write command in the execution list of the source storage device.

[0076] On this basis, the execution list of the source storage device records the write address of the write command being executed. Therefore, after the source device receives the write command, it only needs to determine whether there is a write address in the local execution list that has an overlapping area address 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 occupied by other write commands at the current moment; if not, it is determined that the write address indicated by the received write command is not occupied by other write commands at the current moment.

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

[0078] The following is a detailed description of the above S203 in which it is determined whether the write address indicated by the instruction is occupied at the current moment:

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

[0080] On this basis, the execution list of the mirror storage device records the write address of the write command being executed. Then, after receiving the indication from the source device, it is determined whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the indication; if so, it is determined that the write address indicated by the indication is occupied by other write commands at the current moment; if not, it is determined that the write address indicated by the indication is not occupied by other write commands at the current moment.

[0081] The above is a detailed description of the step of determining whether the write address indicated by the instruction is currently occupied in S203.

[0082] The following describes in detail how to determine the target data and how to perform the write operation after the target data is determined:

[0083] See also Figure 3 , Figure 3 A schematic diagram of a process for determining target data provided in an embodiment of the present application.

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

[0085] S301, respectively obtaining first coded data and second coded data from the data occupying the write address and the data of the occupied overlapping area address to be written in the indication.

[0086] In this embodiment, the data occupying the write address and the data to be written in the occupied overlapping area address in the indication are encoded according to 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 in the occupied overlapping area address in the indication.

[0087] S302, comparing the sizes of the first encoded data and the second encoded data.

[0088] In this embodiment, the first coded data and the second coded data are compared according to a coding rule. For example, the sizes are compared according to a coding rule of ASCII code.

[0089] S303: When the sizes of the first coded data and the second coded data are not equal, the data from which the coded data satisfying the specified size requirement in the first coded data and the second coded data comes is used as the target data.

[0090] In this embodiment, satisfying the specified requirement refers to larger coded data or smaller coded data. Since the main purpose is to determine which data needs to be written to the overlapping address area in the end, as long as the same specified requirement interface is used in the active-active storage system, that is, always keep selecting a larger code or always keep selecting a smaller code.

[0091] Whichever of the first encoded data and the second encoded data is determined to satisfy the specified size requirement, the data from which it is sourced wins the arbitration.

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

[0093] If the winner cannot be determined, the data being written locally on the mirrored storage device wins.

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

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

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

[0097] As another embodiment, when the write address indicated by the indication is partially occupied at the current moment, if the target data comes from the data occupying the write address (that is, 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 indication is written to the non-overlapping area address, thereby completing the mirror storage of the mirror storage device.

[0098] The above describes in detail how to determine the target data and how to perform the write operation after the target data is determined.

[0099] In order to explain the method provided by the present application in more detail, the scheme provided by the present application is described in more detail below in the form of specific embodiments.

[0100] In this embodiment, for the convenience of description, a source storage device, a mirror storage device, a source LUN, a mirror LUN, a write command, a mirror write command, a first conflicting write command, and a second conflicting write command are used to illustrate.

[0101] The method comprises the following steps:

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

[0103] If yes, execute step 2 below; if no, execute 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 for 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 locally that conflicts with the mirror write command by checking whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the mirror write command.

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

[0108] 5. 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 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 area 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 of the mirror write command corresponding to the overlapping area and the data of the second conflict write command corresponding to the overlapping area, compare the first encoded data and the second encoded data, and determine which of the mirror write command and the second conflict write command wins in the arbitration.

[0110] If the mirror write command wins, then execute the following step 7, and if the second conflicting write command wins, then execute the following step 8.

[0111] 7. After the second conflicting 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 conflict write command are completely overlapped, after the second conflict write command is processed, the execution of the mirror write command is prohibited; when the write addresses of the mirror write command and the second conflict write command are partially overlapped, after the second conflict 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 executing step 7 or 8, execute step 9 described below.

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

[0115] 10. After both the source storage device and the mirror storage device are completed, if the source storage device determines that both the local and mirror storage devices are written successfully, a write success message is returned to the server; if the source storage device determines that the local write is successful and the mirror write conflicts, a write success message is also returned to the server.

[0116] The above completes a write operation in the active-active storage system. If the external server subsequently sends a read command, the data is directly read at the receiving end that receives the read command and returned to the server.

[0117] At this point, the description of the method provided in this embodiment is completed. The following describes the device provided in this embodiment of the application:

[0118] See also Figure 4 , Figure 4A schematic diagram of the structure of the device provided in the embodiment of the present application. The device is applied to any storage device in a dual-active storage system, and 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 storage, the LUN is determined as the source LUN, and 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; 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] The device is applied to any storage device in an active-active storage system, and the storage system includes two storage devices; wherein, for any storage device in the active-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 a source storage device for this storage, the LUN is determined as the source LUN, another storage device is used as a mirror storage device for this storage, and the LUN in the other storage device is used as a mirror LUN; the device includes:

[0120] The first judgment module 401 is used to judge 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 used for, if not, storing the data to be written in the write command to the write address indicated by the write command in the source LUN, and sending an instruction to the mirror storage device of the device so that the mirror device writes the data according to the write address indicated by the instruction;

[0122] The second judgment module 403 is used to receive an instruction from the source storage device when it is determined that the device is a mirror storage device, and to judge whether the write address indicated by the instruction is occupied at the current moment;

[0123] The second execution module 404 is configured to, if no, store the to-be-written data indicated by the indication to the write address indicated by the indication in the mirror LUN;

[0124] If yes, when the write address indicated by the indication is currently occupied, target data satisfying the set condition is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, a write operation is performed so that the target data is written to the write address indicated by the indication;

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

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

[0127] The first coded data and the second coded data are obtained respectively from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; 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 mode; the first coded data and the second coded data are the first different coded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication;

[0128] Comparing the sizes of the first encoded data and the second encoded data;

[0129] In the case where the sizes of the first coded data and the second coded data are not equal, the data from which the coded data satisfying the specified size requirement in the first coded data and the second coded data originates is used as the target data; satisfying the specified requirement means the larger coded data or the smaller coded data;

[0130] In the case where the sizes of the first encoded data and the second encoded data are equal, the data occupying the write address is taken as the target data.

[0131] As an embodiment, when the target data comes from the data to be written in the occupied overlapping area address in the indication, performing 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 the data occupying the write address, performing a write operation includes:

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

[0134] If the write address indicated by the indication is partially occupied at the current moment, the data to be written in the unoccupied non-overlapping area address in the indication is written into the non-overlapping area address.

[0135] As an embodiment, after determining whether the write address indicated by the received write command is occupied at the current moment, the first execution module is further specifically configured to:

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

[0137] As an embodiment, determining whether the write address indicated by the received write command is occupied at the current moment includes:

[0138] Determine whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the write command; if yes, determine that the write address indicated by the received write command is currently occupied by other write commands; if no, determine that the write address indicated by the received write command is currently not occupied by other write commands;

[0139] Determining whether the write address indicated by the instruction is occupied at the current moment includes:

[0140] Determine whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the indication; if so, determine that the write address indicated by the indication is occupied by other write commands at the current moment; if not, determine that the write address indicated by the indication is not occupied by other write commands at the current moment.

[0141] As an embodiment, 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] Recording the write address indicated by the write command in an execution list of the source storage device, so that when the source storage device subsequently receives the write command, it is determined 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 to the write address indicated by the mirror write command in the source LUN, the second execution module is further used to:

[0144] The write address indicated by the indication is recorded in the execution list of the mirror storage device, so that when the mirror storage device receives a write command subsequently, it is determined whether the write address indicated by the write command is occupied at the current moment.

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

[0146] The write address indicated by the instruction and the write address in the execution list of the mirror storage device that has an overlapping area address with the write address indicated by the instruction are deleted from the execution list of the mirror storage device.

[0147] So far, completed Figure 4 Structural description of the device shown.

[0148] See also Figure 5 , Figure 5 This is a structural diagram of an electronic device provided in an embodiment of the present 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, an embodiment of the present application also provides a machine-readable storage medium, on which a number of computer instructions are stored. When the computer instructions are executed by a processor, the method disclosed in the above example of the present application can be implemented.

[0150] Exemplarily, the above-mentioned 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 example, the machine-readable storage medium can be: RAM (Radom Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state drive, any type of storage disk (such as CD, DVD, etc.), or similar storage medium, or a combination thereof.

[0151] The above is only an embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included in the scope of the claims of the present application.

Claims

1. A data writing method, characterized in that: The method is applied to any storage device in an active-active storage system, wherein the storage system includes two storage devices; wherein, for any storage device in the active-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 a source storage device for current storage, the LUN is determined as a source LUN, another storage device is used as a mirror storage device for current storage, and the LUN in the other storage device is used as a mirror LUN; the method includes: When determining that the device is a source storage device, determining whether the write address indicated by the received write command is occupied at the current moment; If not, storing the data to be written in the write command to the write address indicated by the write command in the source LUN, and sending an instruction to the mirror storage device of the device so that the mirror device writes the data according to the write address indicated by the instruction; When determining that the device is a mirror storage device, receiving an instruction from the source storage device, and determining whether the write address indicated by the instruction is occupied at the current moment; If not, storing the data to be written indicated by the indication to the write address indicated by the indication in the mirror LUN; If yes, when the write address indicated by the indication is currently occupied, target data satisfying the set condition is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, a write operation is performed so that the target data is written to the write address indicated by the indication; When the write address indicated by the indication is partially occupied at the current moment, target data that meets the set conditions is selected from the data occupying the write address and the data to be written in the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, a write operation is performed so that the target data is written to the overlapping area address, and the data to be written in the unoccupied non-overlapping area address in the indication is written to the non-overlapping area address.

2. The method according to claim 1, characterized in that: The target data that meets the set conditions is selected as follows: The first coded data and the second coded data are obtained respectively from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; 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 mode; the first coded data and the second coded data are the first different coded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; comparing the sizes of the first encoded data and the second encoded data; In the case where the sizes of the first coded data and the second coded data are not equal, the data from which the coded data satisfying the specified size requirement among the first coded data and the second coded data is derived is used as the target data; satisfying the specified requirement means larger coded data or smaller coded data; In the case where 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.

3. The method according to claim 1, characterized in that When the target data comes from the data to be written in the indication at the occupied overlapping area address, the performing the write operation includes: storing the indicated data to be written in the write address indicated by the indication in the mirror LUN; When the target data comes from the data occupying the write address, performing the write operation includes: If the write address indicated by the instruction is fully occupied at the current moment, the execution of the write instruction is prohibited; If the write address indicated by the indication is partially occupied at the current moment, the data to be written in the unoccupied non-overlapping area address in the indication is written into the non-overlapping area address.

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

5. The method according to claim 1, characterized in that The step of determining whether the write address indicated by the received write command is currently occupied comprises: Determine whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the write command; if yes, determine that the write address indicated by the received write command is currently occupied by other write commands; if no, determine that the write address indicated by the received write command is not currently occupied by other write commands; The step of determining whether the write address indicated by the indication is occupied at the current moment includes: Determine whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the indication; if so, determine that the write address indicated by the indication is occupied by other write commands at the current moment; if not, determine that the write address indicated by the indication is not occupied by other write commands at the current moment.

6. The method according to claim 5, 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: recording the write address indicated by the write command in an 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 the write command; After storing the indicated data to be written in the mirror LUN at the write address indicated by the indication, the method further includes: The write address indicated by the indication is recorded in the execution list of the mirror storage device, so that when the mirror storage device receives a write command subsequently, it is determined whether the write address indicated by the write command is occupied at the current moment.

7. The method according to claim 6, characterized in that After the writing operation is performed, the method further comprises: The write address indicated by the instruction and the write address in the execution list of the mirror storage device that has an overlapping area address with the write address indicated by the instruction are deleted from the execution list of the mirror storage device.

8. A data writing device, characterized in that: The device is applied to any storage device in an active-active storage system, wherein the storage system includes two storage devices; wherein, for any storage device in the active-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 a source storage device for current storage, the LUN is determined as a source LUN, another storage device is used as a mirror storage device for current storage, and the LUN in the other storage device is used as a mirror LUN; the device includes: A first judgment module, used to judge whether the write address indicated by the received write command is occupied at the current moment when determining that the device is a source storage device; A first execution module is configured to, if not, store the data to be written in the write command to the write address indicated by the write command in the source LUN, and send an instruction to the mirror storage device of the device so that the mirror device writes the data according to the write address indicated by the instruction; A second judgment module is used to receive an instruction from a source storage device when determining that the device is a mirror storage device, and to judge whether the write address indicated by the instruction is occupied at the current moment; A second execution module, configured to, if no, store the to-be-written data indicated by the indication to the write address indicated by the indication in the mirror LUN; If yes, when the write address indicated by the indication is currently occupied, target data satisfying the set condition is selected from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, a write operation is performed so that the target data is written to the write address indicated by the indication; When the write address indicated by the indication is partially occupied at the current moment, target data that meets the set conditions is selected from the data occupying the write address and the data to be written in the occupied overlapping area address in the indication; and after the write command occupying the write address is processed, a write operation is performed so that the target data is written to the overlapping area address, and the data to be written in the unoccupied non-overlapping area address in the indication is written to the non-overlapping area address.

9. The device according to claim 8, characterized in that The target data that meets the set conditions is selected as follows: The first coded data and the second coded data are obtained respectively from the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; 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 mode; the first coded data and the second coded data are the first different coded data among the data occupying the write address and the data to be written to the occupied overlapping area address in the indication; comparing the sizes of the first encoded data and the second encoded data; In the case where the sizes of the first coded data and the second coded data are not equal, the data from which the coded data satisfying the specified size requirement among the first coded data and the second coded data is derived is used as the target data; satisfying the specified requirement means larger coded data or smaller coded data; In the case where 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; and / or, When the target data comes from the data to be written in the indication at the occupied overlapping area address, the performing the write operation includes: storing the indicated data to be written in the write address indicated by the indication in the mirror LUN; When the target data comes from the data occupying the write address, performing the write operation includes: If the write address indicated by the instruction is fully occupied at the current moment, the execution of the write instruction is prohibited; If the write address indicated by the indication is partially occupied at the current moment, then the data to be written to the unoccupied non-overlapping area address in the indication is written into the non-overlapping area address; and / or, After determining whether the write address indicated by the received write command is occupied at the current moment, the first execution module is further specifically configured to: If yes, the write command is not executed, and a write error instruction is returned to the server; and / or, The step of determining whether the write address indicated by the received write command is currently occupied comprises: Determine whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the write command; if yes, determine that the write address indicated by the received write command is currently occupied by other write commands; if no, determine that the write address indicated by the received write command is not currently occupied by other write commands; The step of determining whether the write address indicated by the indication is occupied at the current moment includes: Check whether there is a write address in the local execution list that has an overlapping area address with the write address indicated by the indication; if yes, determine that the write address indicated by the indication is occupied by other write commands at the current moment; if no, determine that the write address indicated by the indication is not occupied by other write commands at the current moment; 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 used to: recording the write address indicated by the write command in an 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 the write command; After storing the data to be written in the mirror write command to the write address indicated by the mirror write command in the source LUN, the second execution module is further used for: recording the write address indicated by the indication in an execution list of the mirror storage device, so as to determine whether the write address indicated by the write command is occupied at the current moment when the mirror storage device subsequently receives a write command; and / or, After the write operation is performed, the second execution module is further used for: The write address indicated by the instruction and the write address in the execution list of the mirror storage device that has an overlapping area address with the write address indicated by the instruction are deleted from the execution list of the mirror storage device.

10. An electronic device, characterized in that: The electronic device includes: Processor; and A computer-readable storage medium, wherein computer program instructions are stored in the computer-readable storage medium, and when the computer program instructions are executed by the processor, the processor is caused to perform the steps of the method according to any one of claims 1 to 7.

11. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer program instructions, which, when executed by a processor, enable the processor to perform the steps of any one of the methods of claims 1 to 7.

Citation Information

Patent Citations

  • Fail safe refresh of data stored in NAND memory device

    CN105723462A

  • Write-in request processing method, apparatus and device

    CN106843749A

  • Method and device for processing writing conflict

    CN108762668A

  • Remote active-active disaster recovery system

    CN116708140A

  • Initiating Recovery Actions When A Dataset Ceases To Be Synchronously Replicated Across A Set Of Storage Systems

    US20220358019A1