Data replication method, apparatus, and electronic device
By creating multiple replica LUNs in the storage device and using a difference bitmap to select the target LUN for incremental or full replication, the problem of insufficient data recovery in existing technologies is solved, thereby improving the reliability and efficiency of data recovery.
Patent Information
- Application Number
- CN202411972346.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-30
- Publication Date
- 2025-11-07
- Estimated Expiration
- 2044-12-30
AI Technical Summary
Existing one-to-one data replication solutions cannot effectively recover historical data when the source LUN suffers a disaster, resulting in insufficient data availability and reliability.
A one-to-many replication scheme is adopted to create multiple replica LUNs to save the historical data of the source LUN. The target LUN is selected for incremental or full replication by using the difference bitmap and availability status to ensure the reliability and efficiency of data recovery.
It improves the reliability and availability of data recovery, reduces the impact of data replication on the source LUN, and enhances the IO request processing performance of the front-end application server.
Smart Images

Figure CN119883736B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of data processing, and in particular to a data replication method and device and electronic equipment. BACKGROUND
[0002] With the advent of the big data era, the amount of data is growing, and the protection of data is becoming more and more important. Replication is one of the common means of data protection, and is also a common solution to "hard disaster" and "soft disaster". The so-called hard disaster, also known as "hard" disaster, usually refers to the physical damage or unreadability of production data due to factors such as Redundant Arrays of Independent Disks (RAID) failure, earthquake, fire, etc. The so-called soft disaster usually refers to the logical damage of data due to factors such as virus, misoperation, software bug, etc.
[0003] At present, in actual application, a Logical Unit Number (LUN) is usually created on a storage device for writing data generated by a front-end application server, which can be referred to as a source LUN. LUN refers to an independently available storage space created based on RAID. Then, a one-to-one replication scheme is adopted, that is, a copy LUN is created for the source LUN to replicate the data in the source LUN by using replication technology. The source LUN and the copy LUN are physically independent, so that when the source LUN suffers from a hard disaster or a soft disaster, the data in the copy LUN can be used for data recovery. However, the one-to-one replication scheme described above cannot retrieve the historical data of the source LUN before the disaster occurs when the source LUN suffers from a disaster such as a hard disaster or a soft disaster, thereby affecting the availability of data. SUMMARY
[0004] Therefore, the present application provides a data replication method, device and electronic equipment to improve the reliability of data recovery.
[0005] The present application provides a data replication method, which is applied to a storage device including a source LUN to be replicated. The method comprises:
[0006] When it is determined to start replicating data in the storage space corresponding to the source LUN once, a copy LUN with a primary state in a current copy LUN list corresponding to the source LUN is obtained as a target LUN for this time data replication. The primary state of any copy LUN in the current copy LUN list indicates that the copy LUN currently allows data replication.
[0007] When the state of the difference bitmap corresponding to the source LUN is the valid state, and at least one copy LUN that has completed data replication currently exists based on the current copy LUN list, the copy LUN that has completed data replication most recently is determined as the reference LUN based on the current copy LUN list, and it is checked whether the reference LUN and the target LUN are the same LUN. If yes, the data increment in the storage space corresponding to the source LUN is replicated to the target LUN based on the difference bitmap corresponding to the source LUN; otherwise, the data full amount in the storage space corresponding to the reference LUN is replicated to the target LUN, and the data increment in the storage space corresponding to the source LUN is replicated to the target LUN based on the difference bitmap corresponding to the source LUN; the difference bitmap indicates the changed data between the time when the data in the storage space corresponding to the source LUN is last determined to be replicated and the time when the data in the storage space corresponding to the source LUN is currently determined to be replicated.
[0008] When no copy LUN that has completed data replication currently exists based on the current copy LUN list, or the state of the difference bitmap corresponding to the source LUN is the invalid state, the data full amount in the storage space corresponding to the source LUN is replicated to the target LUN; wherein when it is determined that no copy LUN that has completed data replication currently exists, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state.
[0009] Embodiments of the present application also provide a data replication device, which is applied to a storage device including a source LUN to be replicated; the device includes:
[0010] The obtaining module is configured to, when data in the storage space corresponding to the source LUN is determined to be replicated, obtain a copy LUN with the available state being the primary state from a current copy LUN list corresponding to the source LUN as a target LUN to which the data is replicated this time; the available state of any copy LUN in the current copy LUN list being the primary state indicates that the copy LUN currently allows data replication;
[0011] the first replication module is configured to, when the state of the difference bitmap corresponding to the source LUN is a valid state and at least one completed-data-replication copy LUN currently exists based on the current copy LUN list, determine a latest completed-data-replication copy LUN based on the current copy LUN list as a reference LUN, and check whether the reference LUN and the target LUN are the same LUN, if yes, perform incremental replication of data in the storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN, and if not, perform full replication of data in the storage space corresponding to the reference LUN to the target LUN, and perform incremental replication of data in the storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN; the difference bitmap indicates data changed between a time when the last time the replication of data in the storage space corresponding to the source LUN is started to be determined and a time when the current time the replication of data in the storage space corresponding to the source LUN is started to be determined;
[0012] the second replication module is configured to, when no completed-data-replication copy LUN currently exists based on the current copy LUN list, or the state of the difference bitmap corresponding to the source LUN is an invalid state, perform full replication of data in the storage space corresponding to the source LUN to the target LUN; wherein when it is determined that no completed-data-replication copy LUN currently exists, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state.
[0013] Embodiments of the present application also provide an electronic device, which comprises:
[0014] a processor; and
[0015] a computer readable storage medium, in which computer program instructions are stored, and the computer program instructions, when executed by the processor, cause the processor to perform the steps of the above method.
[0016] Embodiments of the present application also provide a computer readable storage medium, in which computer program instructions are stored, and the computer program instructions, when executed by the processor, cause the processor to perform the steps of the above method.
[0017] It can be seen from the above technical solution that, in the embodiment of the application, a plurality of copy LUNs corresponding to a source LUN are created for subsequent copying of data in the storage space corresponding to the source LUN. It can be seen that the embodiment adopts a one-to-many replication scheme, that is, a replication scheme in which one source LUN corresponds to a plurality of copy LUNs. The plurality of copy LUNs correspondingly store historical data of the source LUN at a plurality of historical moments. In this way, the historical data at the plurality of historical moments can be retrieved through the plurality of copy LUNs when a disaster occurs in the source LUN, thereby improving the availability of data. In addition, when one or more copy LUNs corresponding to the source LUN also experience a disaster, data recovery can also be performed using the copy LUNs corresponding to the source LUN except for the copy LUN that experiences a disaster, thereby avoiding the complete loss of data due to a disaster in the copy LUN in a one-to-one replication scheme, and thereby improving the reliability of data recovery.
[0018] Further, when it is determined to start one-time replication, the available states of the copy LUNs corresponding to the source LUN are used to select a target LUN to which data is to be replicated this time. Then, if the current target LUN is the same as the copy LUN on which the last data replication was completed, that is, the target LUN to which the last data replication was performed, it means that the last data replication and this time's data replication are to the same LUN. In this case, only the incremental replication method is used to replicate the data changed in the source LUN since the last replication to the current target LUN. Otherwise, the data on the target LUN to which the last data replication was performed is replicated to the current target LUN in full, and then the incremental replication method is used to replicate the data changed in the source LUN since the last replication to the current target LUN. When the difference bitmap of the source LUN is invalid or none of the copy LUNs has ever performed data replication, the full replication method is used to replicate the data on the source LUN to the target LUN to complete this time's replication. In this way, as much as possible, a large amount of data replication operations are completed between the copy LUNs, effectively reducing the impact of data replication on the source LUN, and improving the processing performance of the source LUN for IO requests from the front-end application server.
[0019] Still further, the storage device including the source LUN is used to perform replication of data in the storage space corresponding to the source LUN. The replication process does not need to pass through the front-end application server, but directly reads data locally for corresponding replication. In this way, the normal business operation of the front-end application server is not affected, and the efficiency of data replication is effectively improved. BRIEF DESCRIPTION OF DRAWINGS
[0020] The accompanying drawings, which are incorporated herein and form a part of the specification, illustrate embodiments consistent with the present application and, together with the description, further serve to explain the principles of the application.
[0021] Figure 1 This is a flowchart illustrating the method provided in an embodiment of this application.
[0022] Figure 2 Another method flowchart provided for an embodiment of this application.
[0023] Figure 3 This is another method flowchart provided for an embodiment of this application.
[0024] Figure 4 This is a schematic diagram of the device structure provided in the embodiments of this application.
[0025] Figure 5 This is a schematic diagram of the electronic device structure provided in an embodiment of this application. Detailed Implementation
[0026] 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.
[0027] See Figure 1 , Figure 1 This is a flowchart illustrating a method provided in an embodiment of this application. The method is applied to a storage device, which includes a source LUN to be copied. As one embodiment, the storage device may be an electronic device such as a computer or server; this embodiment is not specifically limited to this.
[0028] like Figure 1 As shown, the process may include the following steps:
[0029] Step 101: When it is determined to start a copy of data in the storage space corresponding to the source LUN, obtain the available replica LUN in the primary state from the list of current replica LUNs corresponding to the source LUN as the target LUN to which the data is copied this time.
[0030] In this embodiment, the source LUN refers to the LUN from which the data to be copied is stored. This embodiment supports configuring a one-to-many replication relationship for the source LUN, meaning that the source LUN can be configured with multiple replica LUNs for subsequent copying of data from the storage space corresponding to the source LUN. Here, the number of replica LUNs corresponding to the source LUN is not specifically limited; for example, it can be 10, 20, or 30, etc.
[0031] The source LUN is deployed in the storage device. As an embodiment, the source LUN and the plurality of copy LUNs corresponding to the source LUN can be deployed in the same storage device (i.e., the storage device); or, the source LUN and the plurality of copy LUNs corresponding to the source LUN can be deployed in different storage devices, in which case the plurality of copy LUNs corresponding to the source LUN can be deployed in the same storage device or in different storage devices; the embodiment is not specifically limited in this regard.
[0032] In this embodiment, a corresponding replication trigger strategy can be configured for replication of data in the storage space corresponding to the source LUN based on actual needs in advance; for example, as an embodiment, the replication trigger strategy can set a timing task for triggering data replication for the source LUN, for example, can be set to trigger replication of data in the storage space corresponding to the source LUN once at 8 p.m. every day, and the like, based on which, for example, when the time reaches 8 p.m. every day, it is determined to start replication of data in the storage space corresponding to the source LUN once.
[0033] In this embodiment, the storage device in which the source LUN is located can maintain a copy LUN list corresponding to the source LUN, which can be used to record LUN information such as the availability of each copy LUN corresponding to the source LUN, and the information recorded in the copy LUN list can be dynamically changed.
[0034] The plurality of copy LUNs corresponding to the source LUN in this embodiment are used in a cycle, that is, data replication is performed only to one of the copy LUNs corresponding to the source LUN. Based on this, when it is determined to start replication of data in the storage space corresponding to the source LUN, if the availability of any copy LUN in the current copy LUN list corresponding to the source LUN is the master state, it indicates that the copy LUN currently allows data replication; under this premise, the availability of each copy LUN can be used to determine the copy LUN to which the data is replicated this time, i.e., the target LUN, for example, the copy LUN that currently allows data replication, i.e., the copy LUN with the availability of the master state, can be obtained from the current copy LUN list corresponding to the source LUN to serve as the target LUN to which the data is replicated this time.
[0035] Step 102, when the state of the difference bitmap corresponding to the source LUN is the valid state, and it is determined based on the current copy LUN list that there is at least one copy LUN that has completed data replication, the copy LUN that has completed data replication the latest is determined as the reference LUN based on the current copy LUN list, and it is checked whether the reference LUN and the target LUN are the same LUN. If yes, the data increment in the storage space corresponding to the source LUN is replicated to the target LUN based on the difference bitmap corresponding to the source LUN; otherwise, the data in the storage space corresponding to the reference LUN is replicated to the target LUN in full, and the data increment in the storage space corresponding to the source LUN is replicated to the target LUN based on the difference bitmap corresponding to the source LUN.
[0036] In the embodiment, the difference bitmap indicates the data changed between the time when the source LUN last determined to start the replication of the data in the storage space corresponding to the source LUN and the time when the source LUN determines to start the replication of the data in the storage space corresponding to the source LUN. It can be seen that the difference bitmap is dynamically changeable. For example, it is assumed that the replication of the data in the storage space corresponding to the source LUN is triggered once every night at 8 o'clock. When the time reaches 8 o'clock today, the difference bitmap corresponding to the source LUN indicates the data changed between 8 o'clock yesterday and 8 o'clock today. When the time reaches 8 o'clock yesterday, the difference bitmap corresponding to the source LUN indicates the data changed between 8 o'clock the day before yesterday and 8 o'clock yesterday.
[0037] In the embodiment, when the state of the difference bitmap is the valid state, it indicates that the data in the storage space corresponding to the source LUN can be replicated incrementally based on the difference bitmap corresponding to the source LUN. Correspondingly, when the state of the difference bitmap is the invalid state, for example, the difference bitmap is empty, the data in the storage space corresponding to the source LUN cannot be replicated incrementally based on the difference bitmap corresponding to the source LUN.
[0038] In addition, it should be noted that the source LUN records the data difference corresponding to each write IO record transmitted by the front-end application server by using the difference bitmap after triggering the full replication of the data for the first time. It can be seen that the source LUN does not have the corresponding difference bitmap before triggering the full replication of the data for the first time, for example, the difference bitmap is empty. At this time, it can also be considered that the state of the difference bitmap corresponding to the source LUN is the invalid state. Based on this, when the state of the difference bitmap corresponding to the source LUN is the invalid state in the embodiment, the source LUN starts the replication, and the full replication is performed. Before the full replication is performed, the state of the difference bitmap corresponding to the source LUN is automatically changed from the invalid state to the valid state.
[0039] The full volume replication refers to a replication mode of copying all data in the storage space corresponding to the source LUN to the corresponding target LUN. The incremental replication refers to a replication mode of copying only the data changed in the storage space corresponding to the source LUN since the last data replication to the corresponding target LUN each time of data replication. During the full volume replication or the incremental replication, the data in the space of the target LUN that has been replicated corresponds to new data, and the data in the space that has not been replicated corresponds to old data, that is, the data in the target LUN is not the same as the data in the source LUN at the time when the current replication is started.
[0040] Based on the above description, after determining the target LUN to which the current data is replicated, the embodiment first checks whether the state of the difference bitmap corresponding to the source LUN is a valid state;
[0041] Then, if the state of the difference bitmap corresponding to the source LUN is a valid state, it is determined based on the current copy LUN list whether there is at least one copy LUN that has completed data replication. When there is at least one copy LUN that has completed data replication, the copy LUN that has completed data replication most recently (i.e., the LUN to which the last data replication is performed) is determined based on the current copy LUN list as a reference LUN, and it is checked whether the reference LUN and the target LUN are the same LUN. If the reference LUN and the target LUN are the same LUN, it means that the LUN to which the last data replication is performed and the LUN to which the current data replication is performed are the same LUN, and therefore only the data changed in the source LUN since the last replication needs to be copied to the current target LUN, for example, the data in the storage space corresponding to the source LUN is incrementally replicated to the target LUN based on the difference bitmap corresponding to the source LUN, so as to complete the current data replication.
[0042] If the reference LUN and the target LUN are not the same LUN, the data in the storage space corresponding to the reference LUN is first full volume replicated to the target LUN, which means that the data in the source LUN that has been replicated last time has been all copied to the target LUN, and then the data changed in the source LUN since the last replication is copied to the current target LUN, for example, the data in the storage space corresponding to the source LUN is incrementally replicated to the target LUN based on the difference bitmap corresponding to the source LUN, so that the data in the storage space corresponding to the target LUN is consistent with the data in the storage space corresponding to the current source LUN, that is, the current data replication is completed.
[0043] As to how to determine whether there is at least one completed data replication copy LUN based on the current copy LUN list, how to determine the latest completed data replication copy LUN based on the current copy LUN list, and how to copy the data increment in the storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN in this step 102, examples will be described below, which will not be described here.
[0044] Step 103, when it is determined that there is no completed data replication copy LUN based on the current copy LUN list, or the state of the difference bitmap corresponding to the source LUN is the invalid state, full data replication from the storage space corresponding to the source LUN to the target LUN is performed; wherein when it is determined that there is no completed data replication copy LUN, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state.
[0045] In this embodiment, if the state of the difference bitmap corresponding to the source LUN is the invalid state, or it is determined that there is no completed data replication copy LUN based on the current copy LUN list (i.e. it is indicated that each copy LUN in the current copy LUN list has not been executed data replication), at this time, full data replication from the storage space corresponding to the source LUN to the target LUN is required. Moreover, when it is determined that there is no completed data replication copy LUN, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, to indicate that the data in the storage space corresponding to the source LUN cannot be incrementally replicated at present, that is, the full replication mode is to be used.
[0046] At this point, the process shown in Figure 1 is completed.
[0047] As can be seen from the process shown in Figure 1 , in the embodiment of the present application, multiple copy LUNs corresponding to the source LUN are created for subsequent data replication in the storage space corresponding to the source LUN. It can be seen that the one-to-many replication scheme, i.e. the replication scheme of one source LUN corresponding to multiple copy LUNs, is adopted in this embodiment, and the historical data of the source LUN at multiple historical moments is saved in the multiple copy LUNs, so that the historical data at multiple historical moments can be retrieved through the multiple copy LUNs when the source LUN suffers a disaster, and the data availability is improved. Moreover, when one or more copy LUNs corresponding to the source LUN also suffer a disaster, data recovery can also be performed using the copy LUNs corresponding to the source LUN except the copy LUNs suffering the disaster, so that the situation of complete data loss due to the disaster of the copy LUN in the one-to-one replication scheme is avoided, and the reliability of data recovery is improved.
[0048] Further, when the embodiment of the present application determines to start a data replication, the source LUN is used to select a target LUN to which the data is replicated this time according to the available state of each replica LUN corresponding to the source LUN. Then, when the difference bitmap of the source LUN is valid, if the replica LUN on which the latest data replication is completed, i.e., the target LUN to which the last data replication is performed, is the same as the current target LUN, it means that the last data replication and the current data replication are performed on the same LUN. In this case, only the incremental replication is used to replicate the data changed in the source LUN since the last data replication to the current target LUN. Otherwise, the data on the target LUN to which the last data replication is performed is replicated to the current target LUN in full, and then the incremental replication is used to replicate the data changed in the source LUN since the last data replication to the current target LUN. When the difference bitmap of the source LUN is invalid or each replica LUN has never been performed data replication, the full replication is used to replicate the data on the source LUN to the target LUN to complete the current replication. In this way, the data replication operation is performed between the replica LUNs as much as possible, which effectively reduces the influence of data replication on the source LUN and improves the processing performance of the source LUN for the IO request of the front-end application server.
[0049] Further, the embodiment of the present application uses the storage device including the source LUN to perform the replication of the data in the storage space corresponding to the source LUN. The replication process does not need to pass through the front-end application server, but directly reads the data locally for corresponding replication. In this way, the normal business operation of the front-end application server is not affected, and the efficiency of data replication is effectively improved.
[0050] The following further describes the processing of the target LUN after the target LUN to which the data is replicated this time is determined in step 101:
[0051] In the embodiment, the current replica LUN list also records the time stamp value of each replica LUN corresponding to the source LUN. The time stamp value of any replica LUN in the current replica LUN list which is determined as the target LUN and has the specified value indicates that the replica LUN is currently performing data replication. In this way, it can be indicated that the data in the replica LUN is not the complete and consistent data of the source LUN at the time when the current replication is started, and cannot be used to restore the data of the source LUN. Here, the specified value is pre-configured based on actual needs, such as 0. Non-specified values are, for example, 1, 2, 3, and other non-zero numerical values.
[0052] Based on the above description, as an embodiment, in order to indicate the available state of the copy LUN, the embodiment obtains the copy LUN with the active state from the current copy LUN list corresponding to the source LUN as the target LUN for the data replication this time, and then indicates that the data replication this time corresponding to the source LUN is to use the target LUN to perform data replication. At this time, the target LUN can be marked by modifying the timestamp value of the target LUN, so that the data in the target LUN is incomplete and cannot be used to restore the data of the source LUN. Specifically, if the timestamp value corresponding to the target LUN in the current copy LUN list is a non-specified value, the timestamp value corresponding to the target LUN in the current copy LUN list is modified from the non-specified value to the specified value. If the timestamp value corresponding to the target LUN in the current copy LUN list is the specified value, the timestamp value corresponding to the target LUN is continuously maintained as the specified value.
[0053] The above step 102 is further described as follows:
[0054] In the embodiment, the timestamp value corresponding to any copy LUN with the non-specified value in the current copy LUN list is used to indicate the timestamp when the copy LUN is last executed for data replication. The timestamp value corresponding to any copy LUN with the specified value in the current copy LUN list and not being the target LUN is used to indicate that the copy LUN has never been executed for data replication, and the copy LUN does not save the data of the source LUN and cannot be used to restore the data of the source LUN.
[0055] As described above, in the embodiment, the copy LUNs corresponding to the source LUN are cyclically used for the data replication in the storage space corresponding to the source LUN, and only one copy LUN is used for each data replication. Based on this, in the embodiment, for any copy LUN with the non-specified value in the current copy LUN list, the smaller the timestamp value of the copy LUN, the earlier the time when the copy LUN is last executed for data replication, and correspondingly, the larger the timestamp value of the copy LUN, the later the time when the copy LUN is last executed for data replication. As described above, in the embodiment, the timestamp value is not represented by the time on the storage device, but represented by the numerical values 0, 1, 2, etc. This can avoid the situation that the use order of the cyclically used copy LUNs corresponding to the source LUN is incorrect due to the fact that the time on the storage device is modifiable.
[0056] For example, assuming that the time stamp values of the replica LUN1 and the replica LUN2 are 1 and 2 respectively, and 1 is less than 2, then the time (e.g., the starting time) at which the data replication is last performed on the replica LUN1 is earlier than the time (e.g., the starting time) at which the data replication is last performed on the replica LUN2. For example, if the data replication on the storage space corresponding to the source LUN is triggered once every night at 8:00, then the starting time at which the data replication is last performed on the replica LUN1 is 8:00 last night, and the starting time at which the data replication is last performed on the replica LUN2 is 8:00 today.
[0057] Based on the above description, as an embodiment, the step 102 of determining, based on the current replica LUN list, that there is at least one replica LUN on which the data replication has been completed, may include, for example, checking whether there is at least one replica LUN with a time stamp value being the non-designated value from the current replica LUN list. If yes, it is determined that there is at least one replica LUN on which the data replication has been completed. Otherwise, it is determined that there is no replica LUN on which the data replication has been completed. Based on this, the step 102 of determining, based on the current replica LUN list, the replica LUN on which the data replication has been completed last, may be, for example, obtaining, from the current replica LUN list, the replica LUN with the time stamp value being the non-designated value and the largest time stamp value as the replica LUN on which the data replication has been completed last.
[0058] In the embodiment, the available state of the replica LUN further includes a standby replication in progress state and a standby state. When the available state of any replica LUN in the current replica LUN list is the standby replication in progress state, it indicates that the data full replication from the storage space corresponding to the replica LUN to the current target LUN is in progress, and the replica LUN is not allowed to perform other data replication except for the data full replication from the storage space corresponding to the replica LUN to the current target LUN. When the available state of any replica LUN in the current replica LUN list is the standby state, it indicates that the replica LUN is not allowed to perform data replication. Based on this, as described above, if the reference LUN and the target LUN are not the same LUN, it indicates that the full replication using the reference LUN and the incremental replication using the source LUN are needed in the current data replication. Under this premise, as an embodiment, the available state of the reference LUN in the current replica LUN list can be modified to the standby replication in progress state. After the data full replication from the storage space corresponding to the reference LUN to the target LUN is completed, it indicates that the reference LUN has been used up, and thus the available state of the reference LUN in the current replica LUN list can be modified from the standby replication in progress state to the standby state.
[0059] As an embodiment, the step 102 of copying the data increment in the storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN in the foregoing embodiment can be implemented as follows: first, the difference bitmap corresponding to the source LUN is converted into a transmission bitmap, and then the data increment in the storage space corresponding to the source LUN is copied to the target LUN based on the transmission bitmap.
[0060] In the embodiment, as described above, the difference bitmap is used to record the changed data of the source LUN since the last data replication. Specifically, the difference bitmap is a data structure, each bit of which corresponds to a storage block that has been divided on the source LUN, and the value of each bit in the difference bitmap is used to indicate whether the data on the corresponding storage block has changed. For example, if the value of any bit in the difference bitmap is 0, it indicates that the data on the bit corresponding storage block has not changed, and if the value of any bit in the difference bitmap is 1, it indicates that the data on the bit corresponding storage block has changed.
[0061] In the incremental replication, the transmission bitmap is also a data structure, which is used to indicate which storage blocks on the source LUN need to be replicated. Based on the working principle of the incremental replication described above, the changed data needs to be replicated, and therefore the transmission bitmap can be similar to the difference bitmap. For example, each bit of the transmission bitmap corresponds to a storage block that has been divided on the source LUN, and the value of each bit in the transmission bitmap is used to indicate whether the data on the corresponding storage block needs to be replicated. For example, if the value of any bit in the transmission bitmap is 0, it indicates that the data on the bit corresponding storage block does not need to be replicated, and if the value of any bit in the transmission bitmap is 1, it indicates that the data on the bit corresponding storage block needs to be replicated. The embodiment does not limit this.
[0062] Based on the above description, in the embodiment, the difference bitmap corresponding to the source LUN can be used to know which storage blocks on the source LUN have changed, and based on this, it can be known which storage blocks on the source LUN need to be replicated, so that the transmission bitmap can be obtained based on the difference bitmap.
[0063] The following further describes how to process the target LUN after the replication of the data in the storage space corresponding to the source LUN is completed:
[0064] In this embodiment, as an example, after the current data replication is completed, if there are at least two copy LUNs (including the target LUN) in the current copy LUN list, at this time the current data replication has used the target LUN, based on the scheme of sequentially circulating the use of copy LUNs in the above embodiment, the copy LUN for the next data replication is other copy LUNs except the target LUN, then the available state of the target LUN in the current copy LUN list can be modified from the primary state to the standby state, and the timestamp value of the target LUN is modified according to the sum of the maximum timestamp value in the current copy LUN list and the set value, for example, the sum of the maximum timestamp value in the current copy LUN list and the set value is used as the timestamp value corresponding to the target LUN, and the embodiment does not specifically limit this. In addition, in order to ensure the selection of the target LUN in the next data replication, the available state of the copy LUN with the standby state and the minimum timestamp value in the current copy LUN list also needs to be modified from the standby state to the primary state, so that the copy LUN with the primary state and the minimum timestamp value is selected as the target LUN when the next data replication is triggered.
[0065] It can be seen that the plurality of copy LUNs corresponding to the source LUN are sequentially and circularly used in this embodiment, so that the resource utilization rate of the copy LUN can be improved, and the plurality of copy LUNs can correspondingly save the copy data of the recent data on the plurality of source LUNs, thereby guaranteeing the availability and comprehensiveness of the copy data.
[0066] If there is only the target LUN in the current copy LUN list after the current data replication is completed, in order to ensure the normal operation of the next data replication, the available state corresponding to the target LUN in the current copy LUN list needs to be maintained as the primary state, so that the target LUN can be used for data replication in the next data replication.
[0067] The copy LUN in this embodiment is further described as follows:
[0068] In this embodiment, the copy LUN corresponding to the source LUN is configured, for example, at least one LUN can be added as the copy LUN corresponding to the source LUN, or at least one LUN can be removed from the copy LUN corresponding to the source LUN. The following describes how to add at least one LUN as the copy LUN corresponding to the source LUN:
[0069] First, before describing how to add at least one LUN as the copy LUN corresponding to the source LUN, the copy LUN list maintained by the storage device is described as follows:
[0070] In this embodiment, the information recorded in the list of replica LUNs corresponding to the source LUNs maintained by the storage device is not specifically limited. For example, as shown in Table 1, the list of replica LUNs may include the device identifier (such as the IP address of the storage device), the replica LUN identifier (such as the replica LUN name), the availability status, and the timestamp value of each replica LUN corresponding to the source LUN. It should be noted that initially, the timestamp value of each replica LUN in the list is 0 (i.e., the specified value mentioned above) to indicate that the replica LUN has never been copied.
[0071] Table 1: Example 1 of a replica LUN list
[0072]
[0073] Subsequently, as an example, when an instruction is received to add at least one LUN to be added as a replica LUN corresponding to the source LUN, for each LUN to be added, the LUN to be added, its availability status, and its timestamp value are added to the current replica LUN list. Wherein, if there is a replica LUN in the current replica LUN list that meets the set conditions, the availability status of the LUN to be added is standby, and the timestamp value of the LUN to be added is a specified value; otherwise, the availability status of the LUN to be added is primary, and the timestamp value of the LUN to be added is a specified value. Here, the set conditions are any of the following: the availability status is standby and the timestamp value is a specified value; the timestamp value is not a specified value and the timestamp value is the smallest; the availability status is primary.
[0074] In this embodiment, the aforementioned additional instructions may be instructions manually triggered by relevant managers based on actual needs, and this embodiment does not impose specific limitations.
[0075] For example, suppose the replica LUNs in the current replica LUN list corresponding to the source LUN are arranged in a specified order. This specified order can be, for example, the order of the replica LUN names, such as LUN A1, LUN A2, LUN A3, LUN A4, ..., LUN An, where n is greater than 1. Initially, LUN A1 is in the primary state, and all other replica LUNs in the current replica LUN list except LUN A1 are in the standby state. The timestamp value of each replica LUN in the current replica LUN list is 0 to indicate that the corresponding replica LUN has never been copied.
[0076] Based on the above description, see [link / reference] Figure 2 As shown, when an instruction to add LUN Ax as a replica LUN corresponding to the source LUN is received, how to process the LUN Ax can include the following steps in a specific implementation:
[0077] Step 201, find whether there is a copy LUN with standby state and time stamp value of 0 in the current copy LUN list corresponding to the source LUN, if yes, execute step 202, otherwise execute step 203.
[0078] Step 202, determine the record corresponding to the copy LUN with the LUN name ranked first in each copy LUN found in the current copy LUN list as the target record, and insert the record of LUN Ax with standby state and time stamp value of 0 before the target record.
[0079] In the embodiment, if at least one copy LUN with standby state and time stamp value of 0 is found, the record corresponding to the copy LUN with the LUN name ranked first in each copy LUN found in the current copy LUN list is determined as the target record, as shown in Table 2, the record corresponding to LUN A3 (“127.0.0.1, LUN A3, standby state, 0”) is the target record found. At this time, the IP address of the storage device to which LUN Ax belongs, the copy LUN name, the available state, and the time stamp value can be added to the current copy LUN list as a new record, wherein the available state of LUN Ax is standby state and the time stamp value is 0; as shown in Table 3, the record corresponding to LUN Ax (“127.0.0.1, LUN Ax, standby state, 0”) can be inserted before the target record.
[0080] Table 2: copy LUN list example 2
[0081]
[0082] Table 3: copy LUN list example 3
[0083]
[0084] Step 203, find whether there is a copy LUN with non-0 time stamp value in the current copy LUN list, if yes, execute step 204, otherwise execute step 205.
[0085] Step 204, determine the record corresponding to the copy LUN with non-0 time stamp value and the smallest time stamp value in the current copy LUN list as the target record, and insert the record of LUN Ax with standby state and time stamp value of 0 before the target record.
[0086] In the embodiment, if at least one copy LUN with a non-0 timestamp value is found, the record corresponding to the copy LUN with a non-0 timestamp value and the smallest timestamp value in the previous copy LUN list (i.e., the copy LUN with the earliest timestamp when the data replication is performed last time) is determined as the target record, as shown in Table 4, the record corresponding to LUN Al (‘127.0.0.1, LUN Al, standby state, 1’) is the target record found. At this time, as described above, the record corresponding to the LUN Ax to be added can be added to the current copy LUN list, where the available state of the LUN Ax is the standby state and the timestamp value is 0; as shown in Table 5, the record corresponding to the LUN Ax (‘127.0.0.1, LUN Ax, standby state, 0’) can be inserted before the target record.
[0087] Table 4: copy LUN list example 4
[0088]
[0089] Table 5: copy LUN list example 5
[0090]
[0091] In step 205, when the copy LUN with the active state of the active state exists in the current copy LUN list, the record corresponding to the copy LUN in the current copy LUN list is determined as the target record, and the record corresponding to the LUN Ax with the available state of the standby state and the timestamp value of 0 is inserted before the target record, otherwise the record corresponding to the LUN Ax with the active state and the timestamp value of 0 is added to the current copy LUN list.
[0092] In the embodiment, if the copy LUN with the non-0 timestamp value is not found, whether the copy LUN with the active state of the active state exists in the current copy LUN list is found; if the copy LUN with the active state is found, it actually means that the current copy LUN list only contains the copy LUN with the active state, and the record corresponding to the copy LUN in the current copy LUN list is determined as the target record, as shown in Table 6, the record corresponding to LUN Al (‘127.0.0.1, LUN Al, active state, 0’) is the target record found. At this time, the record corresponding to the LUN Ax to be added can be added to the current copy LUN list, where the available state of the LUN Ax is the standby state and the timestamp value is 0; as shown in Table 7, the record corresponding to the LUN Ax (‘127.0.0.1, LUN Ax, standby state, 0’) can be inserted before the target record.
[0093] Table 6: copy LUN list example 6
[0094]
[0095] Table 7: Example 7 of the replica LUN list
[0096]
[0097] If no replica LUN in the available state of the primary state is found, which actually means that the current replica LUN list is an empty list, the record corresponding to the LUN Ax to be added is added to the current replica LUN list as the first record in the current replica LUN list, where the available state of the LUN Ax is the primary state and the timestamp value is 0; as shown in Table 8, the record corresponding to the LUN Ax is "127.0.0.1, LUN Ax, primary state, 0".
[0098] Table 8: Example 8 of the replica LUN list
[0099]
[0100] So far, the description of how to add at least one LUN as a replica LUN corresponding to the source LUN is completed. The following describes how to remove at least one LUN from the replica LUN corresponding to the source LUN:
[0101] In this embodiment, as an example, when receiving a removal instruction indicating the removal of at least one replica LUN in the replica LUN corresponding to the source LUN, the removal instruction includes at least one LUN to be removed. For each LUN to be removed, the LUN to be removed and the available state and timestamp value of the LUN to be removed are removed from the current replica LUN list. Here, the triggering mode of the removal instruction is not specifically limited in this embodiment, such as the instruction manually triggered by the relevant management personnel based on the actual needs, similar to the above-mentioned addition instruction.
[0102] If there are at least two replica LUNs in the current replica LUN list, and the available state of the LUN to be removed in the current replica LUN list is the primary state, the available state of the replica LUN with the minimum timestamp value in the current replica LUN list is modified to the primary state to ensure the selection of the target LUN next time the data is copied, thereby ensuring the normal operation of the next data replication;
[0103] If there are at least two copy LUNs in the current copy LUN list, and the available state of the to-be-removed LUN in the current copy LUN list is the standby replication state, it indicates that the to-be-removed LUN is currently copying the full amount of data in the corresponding storage space to the current target LUN, and because the to-be-removed LUN is to be removed, it is necessary to stop copying the full amount of data to the current target LUN, and instead use the full amount of data to copy the data on the source LUN to the target LUN to complete the data replication. Based on this, when the state of the difference bitmap corresponding to the source LUN is the valid state, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, and when the state of the difference bitmap corresponding to the source LUN is the invalid state, the state of the difference bitmap corresponding to the source LUN is maintained unchanged, so that the source LUN cannot perform incremental replication and instead uses full replication to complete the data replication. In addition, the replication relationship between the to-be-removed LUN and the current target LUN corresponding to the to-be-removed LUN is modified to the disabled replication relationship, so that the to-be-removed LUN stops the current data replication.
[0104] In the current copy LUN list, the replication relationship between any copy LUN and any other copy LUN except the copy LUN is a disabled replication relationship, indicating that the copy LUN is currently prohibited from copying data in the corresponding storage space to the other copy LUN.
[0105] For example, referring to FIG. 6, when receiving an instruction to remove the copy LUN Ax corresponding to the source LUN, how to process the LUN Ax, in a specific implementation, can include the following steps: Figure 3
[0106] Step 301, in the case where the current copy LUN list corresponding to the source LUN includes a copy LUN, check whether the current copy LUN list corresponding to the source LUN includes only one record corresponding to a copy LUN, if so, execute step 302, otherwise, execute steps 303, 304 and 305.
[0107] Step 302, directly remove the record corresponding to the LUN Ax.
[0108] In this embodiment, if the current copy LUN list corresponding to the source LUN includes only one record corresponding to the LUN Ax, the record corresponding to the LUN Ax is directly removed.
[0109] Step 303, when the available state of the LUN Ax is the primary state, modify the available state in the next record corresponding to the LUN Ax in the current copy LUN list to the primary state, and then remove the record corresponding to the LUN Ax.
[0110] In the embodiment, if the current copy LUN list includes a plurality of records corresponding to copy LUNs, when the availability state of LUN Ax is the primary state, the availability state in the next record corresponding to LUN Ax in the current copy LUN list (i.e., the record corresponding to the copy LUN with the minimum timestamp value and the standby state) is modified to the primary state, so as to ensure the normal operation of the next data replication, and then the record corresponding to LUN Ax is removed.
[0111] It should be noted that if the record corresponding to LUN Ax is the last record in the current copy LUN list, the next record corresponding to LUN Ax can be the first record in the current copy LUN list.
[0112] In step 304, when the availability state of LUN Ax is the standby state, the record corresponding to LUN Ax in the current copy LUN list is directly removed.
[0113] In step 305, when the availability state of LUN Ax is the standby replication state, if the state of the difference bitmap corresponding to the source LUN is the valid state, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, and if the state of the difference bitmap corresponding to the source LUN is the invalid state, the state of the difference bitmap corresponding to the source LUN is maintained unchanged; and the replication relationship between the to-be-removed LUN and the current target LUN corresponding to the to-be-removed LUN is modified to the disabled replication relationship; and then the record corresponding to LUN Ax is removed.
[0114] Thus, the description of how to remove at least one LUN from the copy LUN corresponding to the source LUN is completed.
[0115] In the embodiment, as an example, if the reference LUN and the target LUN are not the same LUN, the method further includes: if it is found that the replication relationship between the reference LUN and the target LUN is the disabled replication relationship, it can be known based on the above description that the reference LUN may be to be removed, and because the to-be-removed LUN is to be removed, it is necessary to stop full data replication to the current target LUN, and to re-use the full data replication to copy the data on the source LUN to the target LUN to complete the data replication; based on this, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, so that the source LUN cannot perform incremental replication but uses full data replication to complete the data replication, and then the data in the storage space corresponding to the source LUN is full replicated to the target LUN to complete the data replication.
[0116] Thus, the description of the method provided in the embodiments of the present application is completed, and the device provided in the embodiments of the present application is described below.
[0117] Referring to Figure 4 , Figure 4 A structural schematic diagram of a data replication device provided by an embodiment of the present application. The device is applied to a storage device, which includes a source LUN to be replicated. As shown in Figure 4 , the device 400 includes an obtaining module 401, a first replication module 402, and a second replication module 403;
[0118] The obtaining module 401 is configured to, when it is determined to start replicating data in a storage space corresponding to a source LUN this time, obtain a copy LUN in a main state from a current copy LUN list corresponding to the source LUN as a target LUN to which data is replicated this time; and the state of any copy LUN in the current copy LUN list is in the main state, which indicates that the copy LUN currently allows data replication.
[0119] The first replication module 402 is configured to, when the state of a difference bitmap corresponding to the source LUN is in a valid state, and at least one copy LUN on which data replication has been completed exists based on the current copy LUN list, determine a copy LUN on which data replication has been completed most recently based on the current copy LUN list as a reference LUN, and check whether the reference LUN and the target LUN are the same LUN; if yes, incrementally replicate data in a storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN; otherwise, full-amount replicate data in a storage space corresponding to the reference LUN to the target LUN, and incrementally replicate data in a storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN; the difference bitmap indicates data changed between a time when data replication of the storage space corresponding to the source LUN is last determined to be started and a time when data replication of the storage space corresponding to the source LUN is determined to be started this time.
[0120] The second replication module 403 is configured to, when no copy LUN on which data replication has been completed exists based on the current copy LUN list, or the state of the difference bitmap corresponding to the source LUN is in an invalid state, full-amount replicate data in a storage space corresponding to the source LUN to the target LUN; and when it is determined that no copy LUN on which data replication has been completed exists, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state.
[0121] As an embodiment, after obtaining a copy LUN in a main state from a current copy LUN list corresponding to a source LUN as a target LUN to which data is replicated this time, the device further includes:
[0122] The modification module is configured to modify the time stamp value corresponding to the target LUN in the current copy LUN list from the non-designated value to the designated value if the time stamp value corresponding to the target LUN in the current copy LUN list is the non-designated value; and continue to maintain the time stamp value corresponding to the target LUN as the designated value if the time stamp value corresponding to the target LUN in the current copy LUN list is the designated value.
[0123] In the current copy LUN list, the time stamp value corresponding to any copy LUN with the non-designated value indicates the time stamp when the copy LUN is last executed for data replication; the time stamp value corresponding to any copy LUN determined as the target LUN and with the designated value indicates that the copy LUN is currently being executed for data replication; and the time stamp value corresponding to any copy LUN that is not the target LUN and with the designated value indicates that the copy LUN has never been executed for data replication.
[0124] As an embodiment, determining that there is at least one copy LUN that has completed data replication based on the current copy LUN list comprises: searching the current copy LUN list to determine whether there is at least one copy LUN with the non-designated time stamp value, and if yes, determining that there is at least one copy LUN that has completed data replication, and otherwise, determining that there is no copy LUN that has completed data replication.
[0125] As an embodiment, determining the copy LUN that has most recently completed data replication based on the current copy LUN list comprises: obtaining, from the current copy LUN list, the copy LUN with the non-designated time stamp value and the largest time stamp value as the copy LUN that has most recently completed data replication.
[0126] As an embodiment, if the reference LUN is not the same as the target LUN, the modification module is further configured to modify the available state of the reference LUN in the current copy LUN list to the standby replication state; and if the available state of any copy LUN in the current copy LUN list is the standby replication state, it indicates that the data in the storage space corresponding to the copy LUN is being fully replicated to the current target LUN, and the copy LUN is not allowed to perform other data replication at present except for the full replication of the data in the corresponding storage space to the current target LUN.
[0127] As an embodiment, after the data in the storage space corresponding to the reference LUN is fully replicated to the target LUN, the modification module is further configured to modify the available state of the reference LUN in the current copy LUN list from the standby replication state to the standby state; and if the available state of any copy LUN in the current copy LUN list is the standby state, it indicates that the copy LUN is not allowed to perform data replication at present.
[0128] As an embodiment, after the current replication of the data in the storage space corresponding to the source LUN is completed, the modifying module is further configured to:
[0129] If there are at least two replica LUNs in the current replica LUN list, the available state of the target LUN in the current replica LUN list is modified from the primary state to the standby state, and the timestamp value of the target LUN is modified according to the sum of the largest timestamp value in the current replica LUN list and the set value; and the available state of the replica LUN with the standby state and the smallest timestamp value in the current replica LUN list is modified from the standby state to the primary state.
[0130] If there is only the target LUN in the current replica LUN list, the available state corresponding to the target LUN in the current replica LUN list is continuously maintained as the primary state.
[0131] As an embodiment, the apparatus further comprises:
[0132] The increasing module is configured to, when an increasing instruction indicating to increase at least one to-be-increased LUN as a replica LUN corresponding to the source LUN is received, add, for each to-be-increased LUN, the to-be-increased LUN, the available state of the to-be-increased LUN, and the timestamp value of the to-be-increased LUN into the current replica LUN list.
[0133] If there is a replica LUN satisfying the set condition in the current replica LUN list, the available state of the to-be-increased LUN is the standby state, and the timestamp value of the to-be-increased LUN is the specified value; otherwise, the available state of the to-be-increased LUN is the primary state, and the timestamp value of the to-be-increased LUN is the specified value; the set condition is any one of the following conditions: the available state is the standby state and the timestamp value is the specified value, the timestamp value is the non-specified value and the timestamp value is the smallest, and the available state is the primary state.
[0134] As an embodiment, the apparatus further comprises:
[0135] The removing module is configured to, when a removing instruction indicating to remove at least one replica LUN corresponding to the source LUN is received, the removing instruction comprising at least one to-be-removed LUN, remove, for each to-be-removed LUN, the to-be-removed LUN, and the available state and the timestamp value of the to-be-removed LUN from the current replica LUN list.
[0136] If there are at least two replica LUNs in the current replica LUN list, and the available state of the to-be-removed LUN in the current replica LUN list is the primary state, the available state of the replica LUN with the non-primary state and the smallest timestamp value in the current replica LUN list is modified to the primary state.
[0137] If there are at least two copy LUNs in the current copy LUN list, and the available state of the to-be-removed LUN in the current copy LUN list is a standby replication state, when the state of the difference bitmap corresponding to the source LUN is a valid state, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to an invalid state, when the state of the difference bitmap corresponding to the source LUN is the invalid state, the state of the difference bitmap corresponding to the source LUN is maintained unchanged; and the replication relationship between the to-be-removed LUN and the current target LUN corresponding to the to-be-removed LUN is modified to a disabled replication relationship; the replication relationship between any copy LUN in the current copy LUN list and any other copy LUN except the copy LUN is a disabled replication relationship, indicating that the copy LUN is currently prohibited from copying data in the corresponding storage space to the other copy LUN.
[0138] As an embodiment, if the reference LUN and the target LUN are not the same LUN, the modification module is further used to:
[0139] If it is found that the replication relationship between the reference LUN and the target LUN is a disabled replication relationship, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, and the full amount of data in the storage space corresponding to the source LUN is copied to the target LUN.
[0140] At this point, the Figure 4 The structure of the device is described.
[0141] The implementation process of the functions and roles of each module in the above device is specifically described in the implementation process of the corresponding steps in the above method, which will not be repeated here.
[0142] For the device embodiment, since it basically corresponds to the method embodiment, the related parts are described in the part of the method embodiment. The device embodiments described above are only illustrative, and the modules described as separate components can or can not be physically separated, and the components displayed as modules can or can not be physical modules, that is, they can be located in one place, or they can be distributed on multiple network modules. According to actual needs, some or all of the modules can be selected to achieve the purpose of the present application. Those skilled in the art can understand and implement without creative labor.
[0143] Please refer to Figure 5A hardware structure schematic diagram of an electronic device is provided for an exemplary embodiment of the present application. The electronic device can include a processor 501, a communication interface 502, a computer readable storage medium 503 and a communication bus 504. The processor 501, the communication interface 502 and the computer readable storage medium 503 complete the communication among each other through the communication bus 504. Among them, the computer readable storage medium 503 stores computer program instructions; the processor 501 can execute the steps of the method described in the above embodiment by executing the computer program instructions stored in the computer readable storage medium 503. The electronic device can also include other hardware according to the actual function of the electronic device, which will not be described here.
[0144] Correspondingly, the present application also provides a computer readable storage medium, which stores a plurality of computer program instructions, and the computer program instructions can implement the method disclosed in the above exemplary embodiments of the present application when executed by a processor.
[0145] Exemplarily, the above computer readable storage medium can be any electronic, magnetic, optical or other physical storage apparatus, and can contain or store information such as executable instructions, data, etc. For example, the computer readable storage medium can be: RAM (Random Access Memory), volatile memory, non-volatile memory, flash memory, storage drive (such as hard disk drive), solid state disk, any type of storage disk (such as optical disk, dvd, etc.), or similar storage medium, or combination thereof. The processor and the memory can be supplemented by or incorporated into a special logic circuit.
[0146] The above is only a preferred embodiment of the present application, and is not used to limit the present application, any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A data replication method, characterized by, The method is applied to a storage device including a source logical unit number (LUN) to be copied, and the method includes the following steps. When it is determined to start data replication in a storage space corresponding to the source LUN, a copy LUN with an active state of a master state is obtained from a current copy LUN list corresponding to the source LUN to serve as a target LUN for this time data replication; if any copy LUN in the current copy LUN list has an active state of a master state, it indicates that the copy LUN currently allows data replication. When a state of a difference bitmap corresponding to the source LUN is a valid state, and at least one copy LUN that has completed data replication currently exists based on the current copy LUN list, a copy LUN that has completed data replication most recently is determined based on the current copy LUN list to serve as a reference LUN, and it is checked whether the reference LUN and the target LUN are the same LUN; if yes, data in the storage space corresponding to the source LUN is incrementally replicated to the target LUN based on the difference bitmap corresponding to the source LUN; otherwise, data in the storage space corresponding to the reference LUN is totally replicated to the target LUN, and data in the storage space corresponding to the source LUN is incrementally replicated to the target LUN based on the difference bitmap corresponding to the source LUN; the difference bitmap indicates data changed between a time when data replication in the storage space corresponding to the source LUN was last determined to be started and a time when data replication in the storage space corresponding to the source LUN is currently determined to be started. When there is no copy LUN that has completed data replication currently based on the current copy LUN list, or a state of the difference bitmap corresponding to the source LUN is an invalid state, data in the storage space corresponding to the source LUN is totally replicated to the target LUN; when it is determined that there is no copy LUN that has completed data replication currently, the state of the difference bitmap corresponding to the source LUN is modified from a valid state to an invalid state.
2. The method of claim 1, wherein, After the copy LUN with the active state of the master state is obtained from the current copy LUN list corresponding to the source LUN to serve as the target LUN for this time data replication, the method further includes the following steps. If a time stamp value corresponding to the target LUN in the current copy LUN list is a non-designated value, the time stamp value corresponding to the target LUN in the current copy LUN list is modified from the non-designated value to a designated value; if the time stamp value corresponding to the target LUN in the current copy LUN list is the designated value, the time stamp value corresponding to the target LUN is continuously maintained as the designated value. The timestamp value corresponding to any copy LUN with a non-designated value in the current copy LUN list indicates the timestamp when the copy LUN was last subjected to data replication; the timestamp value corresponding to any copy LUN determined as a target LUN and with a designated value in the current copy LUN list indicates that the copy LUN is currently subjected to data replication; and the timestamp value corresponding to any copy LUN that is not a target LUN and with a designated value in the current copy LUN list indicates that the copy LUN has never been subjected to data replication.
3. The method of claim 2, wherein, the determining, based on the current copy LUN list, that there is at least one copy LUN that has completed data replication comprises: checking, from the current copy LUN list, whether there is at least one copy LUN with a non-designated timestamp value, and if so, determining that there is at least one copy LUN that has completed data replication, and otherwise, determining that there is no copy LUN that has completed data replication.
4. The method of claim 2, wherein, the determining, based on the current copy LUN list, that there is at least one copy LUN that has completed data replication comprises: obtaining, from the current copy LUN list, a copy LUN with a non-designated timestamp value and a maximum timestamp value as the copy LUN that has completed data replication.
5. The method of claim 2, wherein, if the reference LUN and the target LUN are not the same LUN, the method further comprises: modifying the available state of the reference LUN in the current copy LUN list to a standby replication state; and the available state of any copy LUN in the current copy LUN list being the standby replication state indicates that the data in the storage space corresponding to the copy LUN is being fully replicated to the current target LUN, and the copy LUN is not allowed to perform other data replication.
6. The method of claim 5, wherein, after the data in the storage space corresponding to the reference LUN is fully replicated to the target LUN, the method further comprises: modifying the available state of the reference LUN in the current copy LUN list from the standby replication state to a standby state; and the available state of any copy LUN in the current copy LUN list being the standby state indicates that the copy LUN is not allowed to perform data replication.
7. The method of claim 6, wherein, after the current replication of the data in the storage space corresponding to the source LUN is completed, the method further comprises: if there are at least two copy LUNs in the current copy LUN list, modifying the available state of the target LUN in the current copy LUN list from a primary state to a standby state, modifying the timestamp value of the target LUN according to the sum of the maximum timestamp value in the current copy LUN list and a designated value, and modifying the available state of the copy LUN with the smallest timestamp value in the current copy LUN list from a standby state to a primary state; and If there is only the target LUN in the current copy LUN list, the available state of the target LUN corresponding to the current copy LUN list is continuously maintained as the primary state.
8. The method of claim 6, wherein, The method further comprises: When receiving an increase instruction indicating to increase at least one to-be-increased LUN as a copy LUN corresponding to the source LUN, for each to-be-increased LUN, adding the to-be-increased LUN, the available state of the to-be-increased LUN, and the timestamp value of the to-be-increased LUN to the current copy LUN list; If there is a copy LUN in the current copy LUN list satisfying a set condition, the available state of the to-be-increased LUN is the standby state, and the timestamp value of the to-be-increased LUN is the specified value; otherwise, the available state of the to-be-increased LUN is the primary state, and the timestamp value of the to-be-increased LUN is the specified value; the set condition is any one of the following conditions: the available state is the standby state and the timestamp value is the specified value, the timestamp value is the non-specified value and the timestamp value is the minimum, and the available state is the primary state.
9. The method of claim 6, wherein, The method further comprises: When receiving a removal instruction indicating to remove at least one copy LUN corresponding to the source LUN, the removal instruction includes at least one to-be-removed LUN, for each to-be-removed LUN, removing the to-be-removed LUN, the available state of the to-be-removed LUN, and the timestamp value of the to-be-removed LUN from the current copy LUN list; If there are at least two copy LUNs in the current copy LUN list, and the available state of the to-be-removed LUN in the current copy LUN list is the primary state, the available state of the copy LUN with the non-primary state and the minimum timestamp value in the current copy LUN list is modified to the primary state; If there are at least two copy LUNs in the current copy LUN list, and the available state of the to-be-removed LUN in the current copy LUN list is the standby copy state, when the state of the difference bitmap corresponding to the source LUN is the valid state, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, when the state of the difference bitmap corresponding to the source LUN is the invalid state, the state of the difference bitmap corresponding to the source LUN is maintained unchanged; and the replication relationship between the to-be-removed LUN and the current target LUN corresponding to the to-be-removed LUN is modified to the disabled replication relationship; the replication relationship between any copy LUN in the current copy LUN list and any other copy LUN except the copy LUN is the disabled replication relationship, indicating that the copy LUN is currently prohibited from replicating data in the corresponding storage space to the other copy LUN.
10. The method of claim 9, wherein, If the reference LUN and the target LUN are not the same LUN, the method further comprises: If it is found that the replication relationship between the reference LUN and the target LUN is the disabled replication relationship, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state, and the full amount of data in the storage space corresponding to the source LUN is replicated to the target LUN.
11. A data replication apparatus characterized by comprising: The device is applied to a storage device, and the storage device includes a source logical unit number (LUN) to be copied; The device includes: An obtaining module is configured to, when it is determined to start data replication in a storage space corresponding to a source LUN, obtain a copy LUN in a main state from a current copy LUN list corresponding to the source LUN as a target LUN to which data is replicated this time; and the state of any copy LUN in the current copy LUN list is the main state, which indicates that the copy LUN currently allows data replication. A first replication module is configured to, when a state of a difference bitmap corresponding to the source LUN is a valid state, and at least one copy LUN on which data replication has been completed currently exists based on a current copy LUN list, determine a copy LUN on which data replication has been completed most recently based on the current copy LUN list as a reference LUN, and check whether the reference LUN and the target LUN are the same LUN; if yes, incrementally replicate data in a storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN; otherwise, fully replicate data in a storage space corresponding to the reference LUN to the target LUN, and incrementally replicate data in a storage space corresponding to the source LUN to the target LUN based on the difference bitmap corresponding to the source LUN; the difference bitmap indicates data that has changed between a time when data replication in the storage space corresponding to the source LUN was last determined to be started and a time when data replication in the storage space corresponding to the source LUN is currently determined to be started. A second replication module is configured to, when no copy LUN on which data replication has been completed currently exists based on the current copy LUN list, or a state of the difference bitmap corresponding to the source LUN is an invalid state, fully replicate data in the storage space corresponding to the source LUN to the target LUN; and when it is determined that no copy LUN on which data replication has been completed currently exists, the state of the difference bitmap corresponding to the source LUN is modified from the valid state to the invalid state.
12. An electronic device, comprising: The electronic device includes: a processor; and a computer readable storage medium having stored therein computer program instructions, which, when executed by the processor, cause the processor to perform the steps in any one of the methods of claims 1-10.
Citation Information
Patent Citations
Data replication method, data replication device and storage device
CN104363977A
Automated restart of asynchronous remote replication after failures
US12086036B1